Index: stable/11/UPDATING =================================================================== --- stable/11/UPDATING (revision 329139) +++ stable/11/UPDATING (revision 329140) @@ -1,1736 +1,1741 @@ Updating Information for FreeBSD current users. This file is maintained and copyrighted by M. Warner Losh . See end of file for further details. For commonly done items, please see the COMMON ITEMS: section later in the file. These instructions assume that you basically know what you are doing. If not, then please consult the FreeBSD handbook: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-src.html Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. NOTE: FreeBSD has switched from gcc to clang. If you have trouble bootstrapping from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20180211: + The LOADER_FIREWIRE_SUPPORT build variable as been renamed to + WITH/OUT_LOADER_FIREWIRE. LOADER_{NO_,}GELI_SUPPORT has been renamed + to WITH/OUT_LOADER_GELI. + 20180210: The geli password typed at boot is now hidden. To restore the previous behavior, see geli(8) for configuration options. 20180113: The SW_WATCHDOG option is no longer necessary to enable the hardclock-based software watchdog if no hardware watchdog is configured. As before, SW_WATCHDOG will cause the software watchdog to be enabled even if a hardware watchdog is configured. 20180108: lint(1) binaries and library are no longer built by default. To enable building them, define WITH_LINT in src.conf. If you are using a FreeBSD 12 or later system to build 11-stable, you may need to install a lint(1) binary to use WITH_LINT. 20171003: When building multiple kernels using KERNCONF, non-existent KERNCONF files will produce an error and buildkernel will fail. Previously missing KERNCONF files silently failed giving no indication as to why, only to subsequently discover during installkernel that the desired kernel was never built in the first place. 20170926: Clang, llvm, lldb, compiler-rt and libc++ have been upgraded to 5.0.0. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. 20170822: Since the switch to GPT disk labels, fsck for UFS/FFS has been unable to automatically find alternate superblocks. As of r322806, the information needed to find alternate superblocks has been moved to the end of the area reserved for the boot block. Filesystems created with a newfs of this vintage or later will create the recovery information. If you have a filesystem created prior to this change and wish to have a recovery block created for your filesystem, you can do so by running fsck in forground mode (i.e., do not use the -p or -y options). As it starts, fsck will ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS'' to which you should answer yes. 20170518: arm64 builds now use the base system LLD 4.0.0 linker by default, instead of requiring that the aarch64-binutils port or package be installed. To continue using aarch64-binutils, set CROSS_BINUTILS_PREFIX=/usr/local/aarch64-freebsd/bin . 20170529: The ctl.ko module no longer implements the iSCSI target frontend: cfiscsi.ko does instead. If building cfiscsi.ko as a kernel module, the module can be loaded via one of the following methods: - `cfiscsi_load="YES"` in loader.conf(5). - Add `cfiscsi` to `$kld_list` in rc.conf(5). - ctladm(8)/ctld(8), when compiled with iSCSI support (`WITH_ISCSI=yes` in src.conf(5)) Please see cfiscsi(4) for more details. 20170511: The mmcsd.ko module now additionally depends on geom_flashmap.ko. Also, mmc.ko and mmcsd.ko need to be a matching pair built from the same source (previously, the dependency of mmcsd.ko on mmc.ko was missing, but mmcsd.ko now will refuse to load if it is incompatible with mmc.ko). 20170414: Binds and sends to the loopback addresses, IPv6 and IPv4, will now use any explicitly assigned loopback address available in the jail instead of using the first assigned address of the jail. 20170413: As of r316810 for ipfilter, keep frags is no longer assumed when keep state is specified in a rule. r316810 aligns ipfilter with documentation in man pages separating keep frags from keep state. This allows keep state to specified without forcing keep frags and allows keep frags to be specified independently of keep state. To maintain previous behaviour, also specify keep frags with keep state (as documented in ipf.conf.5). 20170402: Clang, llvm, lldb, compiler-rt and libc++ have been upgraded to 4.0.0. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. 20170323: The code that provides support for ZFS .zfs/ directory functionality has been reimplemented. It's not possible now to create a snapshot by mkdir under .zfs/snapshot/. That should be the only user visible change. 20170319: Many changes in the IPsec code have been merged from the FreeBSD-CURRENT branch. The IPSEC_FILTERTUNNEL kernel option is removed in favour of corresponding sysctl. The IPSEC_NAT_T kernel option is also removed, and now NAT-T is supported by default. Security associations now use the single namespace for SPI allocation, so if you use several manually configured security associations with the same SPI, this configuration needs modification. 20161217: Clang, llvm, lldb, compiler-rt and libc++ have been upgraded to 3.9.1. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. 20161124: Clang, llvm, lldb, compiler-rt and libc++ have been upgraded to 3.9.0. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. 20161119: The layout of the pmap structure has changed for powerpc to put the pmap statistics at the front for all CPU variations. libkvm(3) and all tools that link against it need to be recompiled. 20161030: isl(4) and cyapa(4) drivers now require a new driver, chromebook_platform(4), to work properly on Chromebook-class hardware. On other types of hardware the drivers may need to be configured using device hints. Please see the corresponding manual pages for details. 20161210: Relocatable object files with the extension of .So have been renamed to use an extension of .pico instead. The purpose of this change is to avoid a name clash with shared libraries on case-insensitive file systems. On those file systems, foo.So is the same file as foo.so. 20160622: The libc stub for the pipe(2) system call has been replaced with a wrapper that calls the pipe2(2) system call and the pipe(2) system call is now only implemented by the kernels that include "options COMPAT_FREEBSD10" in their config file (this is the default). Users should ensure that this option is enabled in their kernel or upgrade userspace to r302092 before upgrading their kernel. 20160527: CAM will now strip leading spaces from SCSI disks' serial numbers. This will effect users who create UFS filesystems on SCSI disks using those disk's diskid device nodes. For example, if /etc/fstab previously contained a line like "/dev/diskid/DISK-%20%20%20%20%20%20%20ABCDEFG0123456", you should change it to "/dev/diskid/DISK-ABCDEFG0123456". Users of geom transforms like gmirror may also be affected. ZFS users should generally be fine. 20160523: The bitstring(3) API has been updated with new functionality and improved performance. But it is binary-incompatible with the old API. Objects built with the new headers may not be linked against objects built with the old headers. 20160520: The brk and sbrk functions have been removed from libc on arm64. Binutils from ports has been updated to not link to these functions and should be updated to the latest version before installing a new libc. 20160517: The armv6 port now defaults to hard float ABI. Limited support for running both hardfloat and soft float on the same system is available using the libraries installed with -DWITH_LIBSOFT. This has only been tested as an upgrade path for installworld and packages may fail or need manual intervention to run. New packages will be needed. To update an existing self-hosted armv6hf system, you must add TARGET_ARCH=armv6 on the make command line for both the build and the install steps. 20160510: Kernel modules compiled outside of a kernel build now default to installing to /boot/modules instead of /boot/kernel. Many kernel modules built this way (such as those in ports) already overrode KMODDIR explicitly to install into /boot/modules. However, manually building and installing a module from /sys/modules will now install to /boot/modules instead of /boot/kernel. 20160414: The CAM I/O scheduler has been committed to the kernel. There should be no user visible impact. This does enable NCQ Trim on ada SSDs. While the list of known rogues that claim support for this but actually corrupt data is believed to be complete, be on the lookout for data corruption. The known rogue list is believed to be complete: o Crucial MX100, M550 drives with MU01 firmware. o Micron M510 and M550 drives with MU01 firmware. o Micron M500 prior to MU07 firmware o Samsung 830, 840, and 850 all firmwares o FCCT M500 all firmwares Crucial has firmware http://www.crucial.com/usa/en/support-ssd-firmware with working NCQ TRIM. For Micron branded drives, see your sales rep for updated firmware. Black listed drives will work correctly because these drives work correctly so long as no NCQ TRIMs are sent to them. Given this list is the same as found in Linux, it's believed there are no other rogues in the market place. All other models from the above vendors work. To be safe, if you are at all concerned, you can quirk each of your drives to prevent NCQ from being sent by setting: kern.cam.ada.X.quirks="0x2" in loader.conf. If the drive requires the 4k sector quirk, set the quirks entry to 0x3. 20160330: The FAST_DEPEND build option has been removed and its functionality is now the one true way. The old mkdep(1) style of 'make depend' has been removed. See 20160311 for further details. 20160317: Resource range types have grown from unsigned long to uintmax_t. All drivers, and anything using libdevinfo, need to be recompiled. 20160311: WITH_FAST_DEPEND is now enabled by default for in-tree and out-of-tree builds. It no longer runs mkdep(1) during 'make depend', and the 'make depend' stage can safely be skipped now as it is auto ran when building 'make all' and will generate all SRCS and DPSRCS before building anything else. Dependencies are gathered at compile time with -MF flags kept in separate .depend files per object file. Users should run 'make cleandepend' once if using -DNO_CLEAN to clean out older stale .depend files. 20160306: On amd64, clang 3.8.0 can now insert sections of type AMD64_UNWIND into kernel modules. Therefore, if you load any kernel modules at boot time, please install the boot loaders after you install the kernel, but before rebooting, e.g.: make buildworld make kernel KERNCONF=YOUR_KERNEL_HERE make -C sys/boot install Then follow the usual steps, described in the General Notes section, below. 20160305: Clang, llvm, lldb and compiler-rt have been upgraded to 3.8.0. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. 20160301: The AIO subsystem is now a standard part of the kernel. The VFS_AIO kernel option and aio.ko kernel module have been removed. Due to stability concerns, asynchronous I/O requests are only permitted on sockets and raw disks by default. To enable asynchronous I/O requests on all file types, set the vfs.aio.enable_unsafe sysctl to a non-zero value. 20160226: The ELF object manipulation tool objcopy is now provided by the ELF Tool Chain project rather than by GNU binutils. It should be a drop-in replacement, with the addition of arm64 support. The (temporary) src.conf knob WITHOUT_ELFCOPY_AS_OBJCOPY knob may be set to obtain the GNU version if necessary. 20160129: Building ZFS pools on top of zvols is prohibited by default. That feature has never worked safely; it's always been prone to deadlocks. Using a zvol as the backing store for a VM guest's virtual disk will still work, even if the guest is using ZFS. Legacy behavior can be restored by setting vfs.zfs.vol.recursive=1. 20160119: The NONE and HPN patches has been removed from OpenSSH. They are still available in the security/openssh-portable port. 20160113: With the addition of ypldap(8), a new _ypldap user is now required during installworld. "mergemaster -p" can be used to add the user prior to installworld, as documented in the handbook. 20151216: The tftp loader (pxeboot) now uses the option root-path directive. As a consequence it no longer looks for a pxeboot.4th file on the tftp server. Instead it uses the regular /boot infrastructure as with the other loaders. 20151211: The code to start recording plug and play data into the modules has been committed. While the old tools will properly build a new kernel, a number of warnings about "unknown metadata record 4" will be produced for an older kldxref. To avoid such warnings, make sure to rebuild the kernel toolchain (or world). Make sure that you have r292078 or later when trying to build 292077 or later before rebuilding. 20151207: Debug data files are now built by default with 'make buildworld' and installed with 'make installworld'. This facilitates debugging but requires more disk space both during the build and for the installed world. Debug files may be disabled by setting WITHOUT_DEBUG_FILES=yes in src.conf(5). 20151130: r291527 changed the internal interface between the nfsd.ko and nfscommon.ko modules. As such, they must both be upgraded to-gether. __FreeBSD_version has been bumped because of this. 20151108: Add support for unicode collation strings leads to a change of order of files listed by ls(1) for example. To get back to the old behaviour, set LC_COLLATE environment variable to "C". Databases administrators will need to reindex their databases given collation results will be different. Due to a bug in install(1) it is recommended to remove the ancient locales before running make installworld. rm -rf /usr/share/locale/* 20151030: The OpenSSL has been upgraded to 1.0.2d. Any binaries requiring libcrypto.so.7 or libssl.so.7 must be recompiled. 20151020: Qlogic 24xx/25xx firmware images were updated from 5.5.0 to 7.3.0. Kernel modules isp_2400_multi and isp_2500_multi were removed and should be replaced with isp_2400 and isp_2500 modules respectively. 20151017: The build previously allowed using 'make -n' to not recurse into sub-directories while showing what commands would be executed, and 'make -n -n' to recursively show commands. Now 'make -n' will recurse and 'make -N' will not. 20151012: If you specify SENDMAIL_MC or SENDMAIL_CF in make.conf, mergemaster and etcupdate will now use this file. A custom sendmail.cf is now updated via this mechanism rather than via installworld. If you had excluded sendmail.cf in mergemaster.rc or etcupdate.conf, you may want to remove the exclusion or change it to "always install". /etc/mail/sendmail.cf is now managed the same way regardless of whether SENDMAIL_MC/SENDMAIL_CF is used. If you are not using SENDMAIL_MC/SENDMAIL_CF there should be no change in behavior. 20151011: Compatibility shims for legacy ATA device names have been removed. It includes ATA_STATIC_ID kernel option, kern.cam.ada.legacy_aliases and kern.geom.raid.legacy_aliases loader tunables, kern.devalias.* environment variables, /dev/ad* and /dev/ar* symbolic links. 20151006: Clang, llvm, lldb, compiler-rt and libc++ have been upgraded to 3.7.0. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. 20150924: Kernel debug files have been moved to /usr/lib/debug/boot/kernel/, and renamed from .symbols to .debug. This reduces the size requirements on the boot partition or file system and provides consistency with userland debug files. When using the supported kernel installation method the /usr/lib/debug/boot/kernel directory will be renamed (to kernel.old) as is done with /boot/kernel. Developers wishing to maintain the historical behavior of installing debug files in /boot/kernel/ can set KERN_DEBUGDIR="" in src.conf(5). 20150827: The wireless drivers had undergone changes that remove the 'parent interface' from the ifconfig -l output. The rc.d network scripts used to check presence of a parent interface in the list, so old scripts would fail to start wireless networking. Thus, etcupdate(3) or mergemaster(8) run is required after kernel update, to update your rc.d scripts in /etc. 20150827: pf no longer supports 'scrub fragment crop' or 'scrub fragment drop-ovl' These configurations are now automatically interpreted as 'scrub fragment reassemble'. 20150817: Kernel-loadable modules for the random(4) device are back. To use them, the kernel must have device random options RANDOM_LOADABLE kldload(8) can then be used to load random_fortuna.ko or random_yarrow.ko. Please note that due to the indirect function calls that the loadable modules need to provide, the build-in variants will be slightly more efficient. The random(4) kernel option RANDOM_DUMMY has been retired due to unpopularity. It was not all that useful anyway. 20150813: The WITHOUT_ELFTOOLCHAIN_TOOLS src.conf(5) knob has been retired. Control over building the ELF Tool Chain tools is now provided by the WITHOUT_TOOLCHAIN knob. 20150810: The polarity of Pulse Per Second (PPS) capture events with the uart(4) driver has been corrected. Prior to this change the PPS "assert" event corresponded to the trailing edge of a positive PPS pulse and the "clear" event was the leading edge of the next pulse. As the width of a PPS pulse in a typical GPS receiver is on the order of 1 millisecond, most users will not notice any significant difference with this change. Anyone who has compensated for the historical polarity reversal by configuring a negative offset equal to the pulse width will need to remove that workaround. 20150809: The default group assigned to /dev/dri entries has been changed from 'wheel' to 'video' with the id of '44'. If you want to have access to the dri devices please add yourself to the video group with: # pw groupmod video -m $USER 20150806: The menu.rc and loader.rc files will now be replaced during upgrades. Please migrate local changes to menu.rc.local and loader.rc.local instead. 20150805: GNU Binutils versions of addr2line, c++filt, nm, readelf, size, strings and strip have been removed. The src.conf(5) knob WITHOUT_ELFTOOLCHAIN_TOOLS no longer provides the binutils tools. 20150728: As ZFS requires more kernel stack pages than is the default on some architectures e.g. i386, it now warns if KSTACK_PAGES is less than ZFS_MIN_KSTACK_PAGES (which is 4 at the time of writing). Please consider using 'options KSTACK_PAGES=X' where X is greater than or equal to ZFS_MIN_KSTACK_PAGES i.e. 4 in such configurations. 20150706: sendmail has been updated to 8.15.2. Starting with FreeBSD 11.0 and sendmail 8.15, sendmail uses uncompressed IPv6 addresses by default, i.e., they will not contain "::". For example, instead of ::1, it will be 0:0:0:0:0:0:0:1. This permits a zero subnet to have a more specific match, such as different map entries for IPv6:0:0 vs IPv6:0. This change requires that configuration data (including maps, files, classes, custom ruleset, etc.) must use the same format, so make certain such configuration data is upgrading. As a very simple check search for patterns like 'IPv6:[0-9a-fA-F:]*::' and 'IPv6::'. To return to the old behavior, set the m4 option confUSE_COMPRESSED_IPV6_ADDRESSES or the cf option UseCompressedIPv6Addresses. 20150630: The default kernel entropy-processing algorithm is now Fortuna, replacing Yarrow. Assuming you have 'device random' in your kernel config file, the configurations allow a kernel option to override this default. You may choose *ONE* of: options RANDOM_YARROW # Legacy /dev/random algorithm. options RANDOM_DUMMY # Blocking-only driver. If you have neither, you get Fortuna. For most people, read no further, Fortuna will give a /dev/random that works like it always used to, and the difference will be irrelevant. If you remove 'device random', you get *NO* kernel-processed entropy at all. This may be acceptable to folks building embedded systems, but has complications. Carry on reading, and it is assumed you know what you need. *PLEASE* read random(4) and random(9) if you are in the habit of tweaking kernel configs, and/or if you are a member of the embedded community, wanting specific and not-usual behaviour from your security subsystems. NOTE!! If you use RANDOM_DUMMY and/or have no 'device random', you will NOT have a functioning /dev/random, and many cryptographic features will not work, including SSH. You may also find strange behaviour from the random(3) set of library functions, in particular sranddev(3), srandomdev(3) and arc4random(3). The reason for this is that the KERN_ARND sysctl only returns entropy if it thinks it has some to share, and with RANDOM_DUMMY or no 'device random' this will never happen. 20150623: An additional fix for the issue described in the 20150614 sendmail entry below has been been committed in revision 284717. 20150616: FreeBSD's old make (fmake) has been removed from the system. It is available as the devel/fmake port or via pkg install fmake. 20150615: The fix for the issue described in the 20150614 sendmail entry below has been been committed in revision 284436. The work around described in that entry is no longer needed unless the default setting is overridden by a confDH_PARAMETERS configuration setting of '5' or pointing to a 512 bit DH parameter file. 20150614: ALLOW_DEPRECATED_ATF_TOOLS/ATFFILE support has been removed from atf.test.mk (included from bsd.test.mk). Please upgrade devel/atf and devel/kyua to version 0.20+ and adjust any calling code to work with Kyuafile and kyua. 20150614: The import of openssl to address the FreeBSD-SA-15:10.openssl security advisory includes a change which rejects handshakes with DH parameters below 768 bits. sendmail releases prior to 8.15.2 (not yet released), defaulted to a 512 bit DH parameter setting for client connections. To work around this interoperability, sendmail can be configured to use a 2048 bit DH parameter by: 1. Edit /etc/mail/`hostname`.mc 2. If a setting for confDH_PARAMETERS does not exist or exists and is set to a string beginning with '5', replace it with '2'. 3. If a setting for confDH_PARAMETERS exists and is set to a file path, create a new file with: openssl dhparam -out /path/to/file 2048 4. Rebuild the .cf file: cd /etc/mail/; make; make install 5. Restart sendmail: cd /etc/mail/; make restart A sendmail patch is coming, at which time this file will be updated. 20150604: Generation of legacy formatted entries have been disabled by default in pwd_mkdb(8), as all base system consumers of the legacy formatted entries were converted to use the new format by default when the new, machine independent format have been added and supported since FreeBSD 5.x. Please see the pwd_mkdb(8) manual page for further details. 20150525: Clang and llvm have been upgraded to 3.6.1 release. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using 3.5.0 or higher. 20150521: TI platform code switched to using vendor DTS files and this update may break existing systems running on Beaglebone, Beaglebone Black, and Pandaboard: - dtb files should be regenerated/reinstalled. Filenames are the same but content is different now - GPIO addressing was changed, now each GPIO bank (32 pins per bank) has its own /dev/gpiocX device, e.g. pin 121 on /dev/gpioc0 in old addressing scheme is now pin 25 on /dev/gpioc3. - Pandaboard: /etc/ttys should be updated, serial console device is now /dev/ttyu2, not /dev/ttyu0 20150501: soelim(1) from gnu/usr.bin/groff has been replaced by usr.bin/soelim. If you need the GNU extension from groff soelim(1), install groff from package: pkg install groff, or via ports: textproc/groff. 20150423: chmod, chflags, chown and chgrp now affect symlinks in -R mode as defined in symlink(7); previously symlinks were silently ignored. 20150415: The const qualifier has been removed from iconv(3) to comply with POSIX. The ports tree is aware of this from r384038 onwards. 20150416: Libraries specified by LIBADD in Makefiles must have a corresponding DPADD_ variable to ensure correct dependencies. This is now enforced in src.libnames.mk. 20150324: From legacy ata(4) driver was removed support for SATA controllers supported by more functional drivers ahci(4), siis(4) and mvs(4). Kernel modules ataahci and ataadaptec were removed completely, replaced by ahci and mvs modules respectively. 20150315: Clang, llvm and lldb have been upgraded to 3.6.0 release. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using 3.5.0 or higher. 20150307: The 32-bit PowerPC kernel has been changed to a position-independent executable. This can only be booted with a version of loader(8) newer than January 31, 2015, so make sure to update both world and kernel before rebooting. 20150217: If you are running a -CURRENT kernel since r273872 (Oct 30th, 2014), but before r278950, the RNG was not seeded properly. Immediately upgrade the kernel to r278950 or later and regenerate any keys (e.g. ssh keys or openssl keys) that were generated w/ a kernel from that range. This does not affect programs that directly used /dev/random or /dev/urandom. All userland uses of arc4random(3) are affected. 20150210: The autofs(4) ABI was changed in order to restore binary compatibility with 10.1-RELEASE. The automountd(8) daemon needs to be rebuilt to work with the new kernel. 20150131: The powerpc64 kernel has been changed to a position-independent executable. This can only be booted with a new version of loader(8), so make sure to update both world and kernel before rebooting. 20150118: Clang and llvm have been upgraded to 3.5.1 release. This is a bugfix only release, no new features have been added. Please see the 20141231 entry below for information about prerequisites and upgrading, if you are not already using 3.5.0. 20150107: ELF tools addr2line, elfcopy (strip), nm, size, and strings are now taken from the ELF Tool Chain project rather than GNU binutils. They should be drop-in replacements, with the addition of arm64 support. The WITHOUT_ELFTOOLCHAIN_TOOLS= knob may be used to obtain the binutils tools, if necessary. See 20150805 for updated information. 20150105: The default Unbound configuration now enables remote control using a local socket. Users who have already enabled the local_unbound service should regenerate their configuration by running "service local_unbound setup" as root. 20150102: The GNU texinfo and GNU info pages have been removed. To be able to view GNU info pages please install texinfo from ports. 20141231: Clang, llvm and lldb have been upgraded to 3.5.0 release. As of this release, a prerequisite for building clang, llvm and lldb is a C++11 capable compiler and C++11 standard library. This means that to be able to successfully build the cross-tools stage of buildworld, with clang as the bootstrap compiler, your system compiler or cross compiler should either be clang 3.3 or later, or gcc 4.8 or later, and your system C++ library should be libc++, or libdstdc++ from gcc 4.8 or later. On any standard FreeBSD 10.x or 11.x installation, where clang and libc++ are on by default (that is, on x86 or arm), this should work out of the box. On 9.x installations where clang is enabled by default, e.g. on x86 and powerpc, libc++ will not be enabled by default, so libc++ should be built (with clang) and installed first. If both clang and libc++ are missing, build clang first, then use it to build libc++. On 8.x and earlier installations, upgrade to 9.x first, and then follow the instructions for 9.x above. Sparc64 and mips users are unaffected, as they still use gcc 4.2.1 by default, and do not build clang. Many embedded systems are resource constrained, and will not be able to build clang in a reasonable time, or in some cases at all. In those cases, cross building bootable systems on amd64 is a workaround. This new version of clang introduces a number of new warnings, of which the following are most likely to appear: -Wabsolute-value This warns in two cases, for both C and C++: * When the code is trying to take the absolute value of an unsigned quantity, which is effectively a no-op, and almost never what was intended. The code should be fixed, if at all possible. If you are sure that the unsigned quantity can be safely cast to signed, without loss of information or undefined behavior, you can add an explicit cast, or disable the warning. * When the code is trying to take an absolute value, but the called abs() variant is for the wrong type, which can lead to truncation. If you want to disable the warning instead of fixing the code, please make sure that truncation will not occur, or it might lead to unwanted side-effects. -Wtautological-undefined-compare and -Wundefined-bool-conversion These warn when C++ code is trying to compare 'this' against NULL, while 'this' should never be NULL in well-defined C++ code. However, there is some legacy (pre C++11) code out there, which actively abuses this feature, which was less strictly defined in previous C++ versions. Squid and openjdk do this, for example. The warning can be turned off for C++98 and earlier, but compiling the code in C++11 mode might result in unexpected behavior; for example, the parts of the program that are unreachable could be optimized away. 20141222: The old NFS client and server (kernel options NFSCLIENT, NFSSERVER) kernel sources have been removed. The .h files remain, since some utilities include them. This will need to be fixed later. If "mount -t oldnfs ..." is attempted, it will fail. If the "-o" option on mountd(8), nfsd(8) or nfsstat(1) is used, the utilities will report errors. 20141121: The handling of LOCAL_LIB_DIRS has been altered to skip addition of directories to top level SUBDIR variable when their parent directory is included in LOCAL_DIRS. Users with build systems with such hierarchies and without SUBDIR entries in the parent directory Makefiles should add them or add the directories to LOCAL_DIRS. 20141109: faith(4) and faithd(8) have been removed from the base system. Faith has been obsolete for a very long time. 20141104: vt(4), the new console driver, is enabled by default. It brings support for Unicode and double-width characters, as well as support for UEFI and integration with the KMS kernel video drivers. You may need to update your console settings in /etc/rc.conf, most probably the keymap. During boot, /etc/rc.d/syscons will indicate what you need to do. vt(4) still has issues and lacks some features compared to syscons(4). See the wiki for up-to-date information: https://wiki.freebsd.org/Newcons If you want to keep using syscons(4), you can do so by adding the following line to /boot/loader.conf: kern.vty=sc 20141102: pjdfstest has been integrated into kyua as an opt-in test suite. Please see share/doc/pjdfstest/README for more details on how to execute it. 20141009: gperf has been removed from the base system for architectures that use clang. Ports that require gperf will obtain it from the devel/gperf port. 20140923: pjdfstest has been moved from tools/regression/pjdfstest to contrib/pjdfstest . 20140922: At svn r271982, The default linux compat kernel ABI has been adjusted to 2.6.18 in support of the linux-c6 compat ports infrastructure update. If you wish to continue using the linux-f10 compat ports, add compat.linux.osrelease=2.6.16 to your local sysctl.conf. Users are encouraged to update their linux-compat packages to linux-c6 during their next update cycle. 20140729: The ofwfb driver, used to provide a graphics console on PowerPC when using vt(4), no longer allows mmap() of all physical memory. This will prevent Xorg on PowerPC with some ATI graphics cards from initializing properly unless x11-servers/xorg-server is updated to 1.12.4_8 or newer. 20140723: The xdev targets have been converted to using TARGET and TARGET_ARCH instead of XDEV and XDEV_ARCH. 20140719: The default unbound configuration has been modified to address issues with reverse lookups on networks that use private address ranges. If you use the local_unbound service, run "service local_unbound setup" as root to regenerate your configuration, then "service local_unbound reload" to load the new configuration. 20140709: The GNU texinfo and GNU info pages are not built and installed anymore, WITH_INFO knob has been added to allow to built and install them again. UPDATE: see 20150102 entry on texinfo's removal 20140708: The GNU readline library is now an INTERNALLIB - that is, it is statically linked into consumers (GDB and variants) in the base system, and the shared library is no longer installed. The devel/readline port is available for third party software that requires readline. 20140702: The Itanium architecture (ia64) has been removed from the list of known architectures. This is the first step in the removal of the architecture. 20140701: Commit r268115 has added NFSv4.1 server support, merged from projects/nfsv4.1-server. Since this includes changes to the internal interfaces between the NFS related modules, a full build of the kernel and modules will be necessary. __FreeBSD_version has been bumped. 20140629: The WITHOUT_VT_SUPPORT kernel config knob has been renamed WITHOUT_VT. (The other _SUPPORT knobs have a consistent meaning which differs from the behaviour controlled by this knob.) 20140619: Maximal length of the serial number in CTL was increased from 16 to 64 chars, that breaks ABI. All CTL-related tools, such as ctladm and ctld, need to be rebuilt to work with a new kernel. 20140606: The libatf-c and libatf-c++ major versions were downgraded to 0 and 1 respectively to match the upstream numbers. They were out of sync because, when they were originally added to FreeBSD, the upstream versions were not respected. These libraries are private and not yet built by default, so renumbering them should be a non-issue. However, unclean source trees will yield broken test programs once the operator executes "make delete-old-libs" after a "make installworld". Additionally, the atf-sh binary was made private by moving it into /usr/libexec/. Already-built shell test programs will keep the path to the old binary so they will break after "make delete-old" is run. If you are using WITH_TESTS=yes (not the default), wipe the object tree and rebuild from scratch to prevent spurious test failures. This is only needed once: the misnumbered libraries and misplaced binaries have been added to OptionalObsoleteFiles.inc so they will be removed during a clean upgrade. 20140512: Clang and llvm have been upgraded to 3.4.1 release. 20140508: We bogusly installed src.opts.mk in /usr/share/mk. This file should be removed to avoid issues in the future (and has been added to ObsoleteFiles.inc). 20140505: /etc/src.conf now affects only builds of the FreeBSD src tree. In the past, it affected all builds that used the bsd.*.mk files. The old behavior was a bug, but people may have relied upon it. To get this behavior back, you can .include /etc/src.conf from /etc/make.conf (which is still global and isn't changed). This also changes the behavior of incremental builds inside the tree of individual directories. Set MAKESYSPATH to ".../share/mk" to do that. Although this has survived make universe and some upgrade scenarios, other upgrade scenarios may have broken. At least one form of temporary breakage was fixed with MAKESYSPATH settings for buildworld as well... In cases where MAKESYSPATH isn't working with this setting, you'll need to set it to the full path to your tree. One side effect of all this cleaning up is that bsd.compiler.mk is no longer implicitly included by bsd.own.mk. If you wish to use COMPILER_TYPE, you must now explicitly include bsd.compiler.mk as well. 20140430: The lindev device has been removed since /dev/full has been made a standard device. __FreeBSD_version has been bumped. 20140424: The knob WITHOUT_VI was added to the base system, which controls building ex(1), vi(1), etc. Older releases of FreeBSD required ex(1) in order to reorder files share/termcap and didn't build ex(1) as a build tool, so building/installing with WITH_VI is highly advised for build hosts for older releases. This issue has been fixed in stable/9 and stable/10 in r277022 and r276991, respectively. 20140418: The YES_HESIOD knob has been removed. It has been obsolete for a decade. Please move to using WITH_HESIOD instead or your builds will silently lack HESIOD. 20140405: The uart(4) driver has been changed with respect to its handling of the low-level console. Previously the uart(4) driver prevented any process from changing the baudrate or the CLOCAL and HUPCL control flags. By removing the restrictions, operators can make changes to the serial console port without having to reboot. However, when getty(8) is started on the serial device that is associated with the low-level console, a misconfigured terminal line in /etc/ttys will now have a real impact. Before upgrading the kernel, make sure that /etc/ttys has the serial console device configured as 3wire without baudrate to preserve the previous behaviour. E.g: ttyu0 "/usr/libexec/getty 3wire" vt100 on secure 20140306: Support for libwrap (TCP wrappers) in rpcbind was disabled by default to improve performance. To re-enable it, if needed, run rpcbind with command line option -W. 20140226: Switched back to the GPL dtc compiler due to updates in the upstream dts files not being supported by the BSDL dtc compiler. You will need to rebuild your kernel toolchain to pick up the new compiler. Core dumps may result while building dtb files during a kernel build if you fail to do so. Set WITHOUT_GPL_DTC if you require the BSDL compiler. 20140216: Clang and llvm have been upgraded to 3.4 release. 20140216: The nve(4) driver has been removed. Please use the nfe(4) driver for NVIDIA nForce MCP Ethernet adapters instead. 20140212: An ABI incompatibility crept into the libc++ 3.4 import in r261283. This could cause certain C++ applications using shared libraries built against the previous version of libc++ to crash. The incompatibility has now been fixed, but any C++ applications or shared libraries built between r261283 and r261801 should be recompiled. 20140204: OpenSSH will now ignore errors caused by kernel lacking of Capsicum capability mode support. Please note that enabling the feature in kernel is still highly recommended. 20140131: OpenSSH is now built with sandbox support, and will use sandbox as the default privilege separation method. This requires Capsicum capability mode support in kernel. 20140128: The libelf and libdwarf libraries have been updated to newer versions from upstream. Shared library version numbers for these two libraries were bumped. Any ports or binaries requiring these two libraries should be recompiled. __FreeBSD_version is bumped to 1100006. 20140110: If a Makefile in a tests/ directory was auto-generating a Kyuafile instead of providing an explicit one, this would prevent such Makefile from providing its own Kyuafile in the future during NO_CLEAN builds. This has been fixed in the Makefiles but manual intervention is needed to clean an objdir if you use NO_CLEAN: # find /usr/obj -name Kyuafile | xargs rm -f 20131213: The behavior of gss_pseudo_random() for the krb5 mechanism has changed, for applications requesting a longer random string than produced by the underlying enctype's pseudo-random() function. In particular, the random string produced from a session key of enctype aes256-cts-hmac-sha1-96 or aes256-cts-hmac-sha1-96 will be different at the 17th octet and later, after this change. The counter used in the PRF+ construction is now encoded as a big-endian integer in accordance with RFC 4402. __FreeBSD_version is bumped to 1100004. 20131108: The WITHOUT_ATF build knob has been removed and its functionality has been subsumed into the more generic WITHOUT_TESTS. If you were using the former to disable the build of the ATF libraries, you should change your settings to use the latter. 20131025: The default version of mtree is nmtree which is obtained from NetBSD. The output is generally the same, but may vary slightly. If you found you need identical output adding "-F freebsd9" to the command line should do the trick. For the time being, the old mtree is available as fmtree. 20131014: libbsdyml has been renamed to libyaml and moved to /usr/lib/private. This will break ports-mgmt/pkg. Rebuild the port, or upgrade to pkg 1.1.4_8 and verify bsdyml not linked in, before running "make delete-old-libs": # make -C /usr/ports/ports-mgmt/pkg build deinstall install clean or # pkg install pkg; ldd /usr/local/sbin/pkg | grep bsdyml 20131010: The stable/10 branch has been created in subversion from head revision r256279. 20131010: The rc.d/jail script has been updated to support jail(8) configuration file. The "jail__*" rc.conf(5) variables for per-jail configuration are automatically converted to /var/run/jail..conf before the jail(8) utility is invoked. This is transparently backward compatible. See below about some incompatibilities and rc.conf(5) manual page for more details. These variables are now deprecated in favor of jail(8) configuration file. One can use "rc.d/jail config " command to generate a jail(8) configuration file in /var/run/jail..conf without running the jail(8) utility. The default pathname of the configuration file is /etc/jail.conf and can be specified by using $jail_conf or $jail__conf variables. Please note that jail_devfs_ruleset accepts an integer at this moment. Please consider to rewrite the ruleset name with an integer. 20130930: BIND has been removed from the base system. If all you need is a local resolver, simply enable and start the local_unbound service instead. Otherwise, several versions of BIND are available in the ports tree. The dns/bind99 port is one example. With this change, nslookup(1) and dig(1) are no longer in the base system. Users should instead use host(1) and drill(1) which are in the base system. Alternatively, nslookup and dig can be obtained by installing the dns/bind-tools port. 20130916: With the addition of unbound(8), a new unbound user is now required during installworld. "mergemaster -p" can be used to add the user prior to installworld, as documented in the handbook. 20130911: OpenSSH is now built with DNSSEC support, and will by default silently trust signed SSHFP records. This can be controlled with the VerifyHostKeyDNS client configuration setting. DNSSEC support can be disabled entirely with the WITHOUT_LDNS option in src.conf. 20130906: The GNU Compiler Collection and C++ standard library (libstdc++) are no longer built by default on platforms where clang is the system compiler. You can enable them with the WITH_GCC and WITH_GNUCXX options in src.conf. 20130905: The PROCDESC kernel option is now part of the GENERIC kernel configuration and is required for the rwhod(8) to work. If you are using custom kernel configuration, you should include 'options PROCDESC'. 20130905: The API and ABI related to the Capsicum framework was modified in backward incompatible way. The userland libraries and programs have to be recompiled to work with the new kernel. This includes the following libraries and programs, but the whole buildworld is advised: libc, libprocstat, dhclient, tcpdump, hastd, hastctl, kdump, procstat, rwho, rwhod, uniq. 20130903: AES-NI intrinsic support has been added to gcc. The AES-NI module has been updated to use this support. A new gcc is required to build the aesni module on both i386 and amd64. 20130821: The PADLOCK_RNG and RDRAND_RNG kernel options are now devices. Thus "device padlock_rng" and "device rdrand_rng" should be used instead of "options PADLOCK_RNG" & "options RDRAND_RNG". 20130813: WITH_ICONV has been split into two feature sets. WITH_ICONV now enables just the iconv* functionality and is now on by default. WITH_LIBICONV_COMPAT enables the libiconv api and link time compatibility. Set WITHOUT_ICONV to build the old way. If you have been using WITH_ICONV before, you will very likely need to turn on WITH_LIBICONV_COMPAT. 20130806: INVARIANTS option now enables DEBUG for code with OpenSolaris and Illumos origin, including ZFS. If you have INVARIANTS in your kernel configuration, then there is no need to set DEBUG or ZFS_DEBUG explicitly. DEBUG used to enable witness(9) tracking of OpenSolaris (mostly ZFS) locks if WITNESS option was set. Because that generated a lot of witness(9) reports and all of them were believed to be false positives, this is no longer done. New option OPENSOLARIS_WITNESS can be used to achieve the previous behavior. 20130806: Timer values in IPv6 data structures now use time_uptime instead of time_second. Although this is not a user-visible functional change, userland utilities which directly use them---ndp(8), rtadvd(8), and rtsold(8) in the base system---need to be updated to r253970 or later. 20130802: find -delete can now delete the pathnames given as arguments, instead of only files found below them or if the pathname did not contain any slashes. Formerly, the following error message would result: find: -delete: : relative path potentially not safe Deleting the pathnames given as arguments can be prevented without error messages using -mindepth 1 or by changing directory and passing "." as argument to find. This works in the old as well as the new version of find. 20130726: Behavior of devfs rules path matching has been changed. Pattern is now always matched against fully qualified devfs path and slash characters must be explicitly matched by slashes in pattern (FNM_PATHNAME). Rulesets involving devfs subdirectories must be reviewed. 20130716: The default ARM ABI has changed to the ARM EABI. The old ABI is incompatible with the ARM EABI and all programs and modules will need to be rebuilt to work with a new kernel. To keep using the old ABI ensure the WITHOUT_ARM_EABI knob is set. NOTE: Support for the old ABI will be removed in the future and users are advised to upgrade. 20130709: pkg_install has been disconnected from the build if you really need it you should add WITH_PKGTOOLS in your src.conf(5). 20130709: Most of network statistics structures were changed to be able keep 64-bits counters. Thus all tools, that work with networking statistics, must be rebuilt (netstat(1), bsnmpd(1), etc.) 20130618: Fix a bug that allowed a tracing process (e.g. gdb) to write to a memory-mapped file in the traced process's address space even if neither the traced process nor the tracing process had write access to that file. 20130615: CVS has been removed from the base system. An exact copy of the code is available from the devel/cvs port. 20130613: Some people report the following error after the switch to bmake: make: illegal option -- J usage: make [-BPSXeiknpqrstv] [-C directory] [-D variable] ... *** [buildworld] Error code 2 this likely due to an old instance of make in ${MAKEPATH} (${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}) which src/Makefile will use that blindly, if it exists, so if you see the above error: rm -rf `make -V MAKEPATH` should resolve it. 20130516: Use bmake by default. Whereas before one could choose to build with bmake via -DWITH_BMAKE one must now use -DWITHOUT_BMAKE to use the old make. The goal is to remove these knobs for 10-RELEASE. It is worth noting that bmake (like gmake) treats the command line as the unit of failure, rather than statements within the command line. Thus '(cd some/where && dosomething)' is safer than 'cd some/where; dosomething'. The '()' allows consistent behavior in parallel build. 20130429: Fix a bug that allows NFS clients to issue READDIR on files. 20130426: The WITHOUT_IDEA option has been removed because the IDEA patent expired. 20130426: The sysctl which controls TRIM support under ZFS has been renamed from vfs.zfs.trim_disable -> vfs.zfs.trim.enabled and has been enabled by default. 20130425: The mergemaster command now uses the default MAKEOBJDIRPREFIX rather than creating it's own in the temporary directory in order allow access to bootstrapped versions of tools such as install and mtree. When upgrading from version of FreeBSD where the install command does not support -l, you will need to install a new mergemaster command if mergemaster -p is required. This can be accomplished with the command (cd src/usr.sbin/mergemaster && make install). 20130404: Legacy ATA stack, disabled and replaced by new CAM-based one since FreeBSD 9.0, completely removed from the sources. Kernel modules atadisk and atapi*, user-level tools atacontrol and burncd are removed. Kernel option `options ATA_CAM` is now permanently enabled and removed. 20130319: SOCK_CLOEXEC and SOCK_NONBLOCK flags have been added to socket(2) and socketpair(2). Software, in particular Kerberos, may automatically detect and use these during building. The resulting binaries will not work on older kernels. 20130308: CTL_DISABLE has also been added to the sparc64 GENERIC (for further information, see the respective 20130304 entry). 20130304: Recent commits to callout(9) changed the size of struct callout, so the KBI is probably heavily disturbed. Also, some functions in callout(9)/sleep(9)/sleepqueue(9)/condvar(9) KPIs were replaced by macros. Every kernel module using it won't load, so rebuild is requested. The ctl device has been re-enabled in GENERIC for i386 and amd64, but does not initialize by default (because of the new CTL_DISABLE option) to save memory. To re-enable it, remove the CTL_DISABLE option from the kernel config file or set kern.cam.ctl.disable=0 in /boot/loader.conf. 20130301: The ctl device has been disabled in GENERIC for i386 and amd64. This was done due to the extra memory being allocated at system initialisation time by the ctl driver which was only used if a CAM target device was created. This makes a FreeBSD system unusable on 128MB or less of RAM. 20130208: A new compression method (lz4) has been merged to -HEAD. Please refer to zpool-features(7) for more information. Please refer to the "ZFS notes" section of this file for information on upgrading boot ZFS pools. 20130129: A BSD-licensed patch(1) variant has been added and is installed as bsdpatch, being the GNU version the default patch. To inverse the logic and use the BSD-licensed one as default, while having the GNU version installed as gnupatch, rebuild and install world with the WITH_BSD_PATCH knob set. 20130121: Due to the use of the new -l option to install(1) during build and install, you must take care not to directly set the INSTALL make variable in your /etc/make.conf, /etc/src.conf, or on the command line. If you wish to use the -C flag for all installs you may be able to add INSTALL+=-C to /etc/make.conf or /etc/src.conf. 20130118: The install(1) option -M has changed meaning and now takes an argument that is a file or path to append logs to. In the unlikely event that -M was the last option on the command line and the command line contained at least two files and a target directory the first file will have logs appended to it. The -M option served little practical purpose in the last decade so its use is expected to be extremely rare. 20121223: After switching to Clang as the default compiler some users of ZFS on i386 systems started to experience stack overflow kernel panics. Please consider using 'options KSTACK_PAGES=4' in such configurations. 20121222: GEOM_LABEL now mangles label names read from file system metadata. Mangling affect labels containing spaces, non-printable characters, '%' or '"'. Device names in /etc/fstab and other places may need to be updated. 20121217: By default, only the 10 most recent kernel dumps will be saved. To restore the previous behaviour (no limit on the number of kernel dumps stored in the dump directory) add the following line to /etc/rc.conf: savecore_flags="" 20121201: With the addition of auditdistd(8), a new auditdistd user is now required during installworld. "mergemaster -p" can be used to add the user prior to installworld, as documented in the handbook. 20121117: The sin6_scope_id member variable in struct sockaddr_in6 is now filled by the kernel before passing the structure to the userland via sysctl or routing socket. This means the KAME-specific embedded scope id in sin6_addr.s6_addr[2] is always cleared in userland application. This behavior can be controlled by net.inet6.ip6.deembed_scopeid. __FreeBSD_version is bumped to 1000025. 20121105: On i386 and amd64 systems WITH_CLANG_IS_CC is now the default. This means that the world and kernel will be compiled with clang and that clang will be installed as /usr/bin/cc, /usr/bin/c++, and /usr/bin/cpp. To disable this behavior and revert to building with gcc, compile with WITHOUT_CLANG_IS_CC. Really old versions of current may need to bootstrap WITHOUT_CLANG first if the clang build fails (its compatibility window doesn't extend to the 9 stable branch point). 20121102: The IPFIREWALL_FORWARD kernel option has been removed. Its functionality now turned on by default. 20121023: The ZERO_COPY_SOCKET kernel option has been removed and split into SOCKET_SEND_COW and SOCKET_RECV_PFLIP. NB: SOCKET_SEND_COW uses the VM page based copy-on-write mechanism which is not safe and may result in kernel crashes. NB: The SOCKET_RECV_PFLIP mechanism is useless as no current driver supports disposeable external page sized mbuf storage. Proper replacements for both zero-copy mechanisms are under consideration and will eventually lead to complete removal of the two kernel options. 20121023: The IPv4 network stack has been converted to network byte order. The following modules need to be recompiled together with kernel: carp(4), divert(4), gif(4), siftr(4), gre(4), pf(4), ipfw(4), ng_ipfw(4), stf(4). 20121022: Support for non-MPSAFE filesystems was removed from VFS. The VFS_VERSION was bumped, all filesystem modules shall be recompiled. 20121018: All the non-MPSAFE filesystems have been disconnected from the build. The full list includes: codafs, hpfs, ntfs, nwfs, portalfs, smbfs, xfs. 20121016: The interface cloning API and ABI has changed. The following modules need to be recompiled together with kernel: ipfw(4), pfsync(4), pflog(4), usb(4), wlan(4), stf(4), vlan(4), disc(4), edsc(4), if_bridge(4), gif(4), tap(4), faith(4), epair(4), enc(4), tun(4), if_lagg(4), gre(4). 20121015: The sdhci driver was split in two parts: sdhci (generic SD Host Controller logic) and sdhci_pci (actual hardware driver). No kernel config modifications are required, but if you load sdhc as a module you must switch to sdhci_pci instead. 20121014: Import the FUSE kernel and userland support into base system. 20121013: The GNU sort(1) program has been removed since the BSD-licensed sort(1) has been the default for quite some time and no serious problems have been reported. The corresponding WITH_GNU_SORT knob has also gone. 20121006: The pfil(9) API/ABI for AF_INET family has been changed. Packet filtering modules: pf(4), ipfw(4), ipfilter(4) need to be recompiled with new kernel. 20121001: The net80211(4) ABI has been changed to allow for improved driver PS-POLL and power-save support. All wireless drivers need to be recompiled to work with the new kernel. 20120913: The random(4) support for the VIA hardware random number generator (`PADLOCK') is no longer enabled unconditionally. Add the padlock_rng device in the custom kernel config if needed. The GENERIC kernels on i386 and amd64 do include the device, so the change only affects the custom kernel configurations. 20120908: The pf(4) packet filter ABI has been changed. pfctl(8) and snmp_pf module need to be recompiled to work with new kernel. 20120828: A new ZFS feature flag "com.delphix:empty_bpobj" has been merged to -HEAD. Pools that have empty_bpobj in active state can not be imported read-write with ZFS implementations that do not support this feature. For more information read the zpool-features(5) manual page. 20120727: The sparc64 ZFS loader has been changed to no longer try to auto- detect ZFS providers based on diskN aliases but now requires these to be explicitly listed in the OFW boot-device environment variable. 20120712: The OpenSSL has been upgraded to 1.0.1c. Any binaries requiring libcrypto.so.6 or libssl.so.6 must be recompiled. Also, there are configuration changes. Make sure to merge /etc/ssl/openssl.cnf. 20120712: The following sysctls and tunables have been renamed for consistency with other variables: kern.cam.da.da_send_ordered -> kern.cam.da.send_ordered kern.cam.ada.ada_send_ordered -> kern.cam.ada.send_ordered 20120628: The sort utility has been replaced with BSD sort. For now, GNU sort is also available as "gnusort" or the default can be set back to GNU sort by setting WITH_GNU_SORT. In this case, BSD sort will be installed as "bsdsort". 20120611: A new version of ZFS (pool version 5000) has been merged to -HEAD. Starting with this version the old system of ZFS pool versioning is superseded by "feature flags". This concept enables forward compatibility against certain future changes in functionality of ZFS pools. The first read-only compatible "feature flag" for ZFS pools is named "com.delphix:async_destroy". For more information read the new zpool-features(5) manual page. Please refer to the "ZFS notes" section of this file for information on upgrading boot ZFS pools. 20120417: The malloc(3) implementation embedded in libc now uses sources imported as contrib/jemalloc. The most disruptive API change is to /etc/malloc.conf. If your system has an old-style /etc/malloc.conf, delete it prior to installworld, and optionally re-create it using the new format after rebooting. See malloc.conf(5) for details (specifically the TUNING section and the "opt.*" entries in the MALLCTL NAMESPACE section). 20120328: Big-endian MIPS TARGET_ARCH values no longer end in "eb". mips64eb is now spelled mips64. mipsn32eb is now spelled mipsn32. mipseb is now spelled mips. This is to aid compatibility with third-party software that expects this naming scheme in uname(3). Little-endian settings are unchanged. If you are updating a big-endian mips64 machine from before this change, you may need to set MACHINE_ARCH=mips64 in your environment before the new build system will recognize your machine. 20120306: Disable by default the option VFS_ALLOW_NONMPSAFE for all supported platforms. 20120229: Now unix domain sockets behave "as expected" on nullfs(5). Previously nullfs(5) did not pass through all behaviours to the underlying layer, as a result if we bound to a socket on the lower layer we could connect only to the lower path; if we bound to the upper layer we could connect only to the upper path. The new behavior is one can connect to both the lower and the upper paths regardless what layer path one binds to. 20120211: The getifaddrs upgrade path broken with 20111215 has been restored. If you have upgraded in between 20111215 and 20120209 you need to recompile libc again with your kernel. You still need to recompile world to be able to configure CARP but this restriction already comes from 20111215. 20120114: The set_rcvar() function has been removed from /etc/rc.subr. All base and ports rc.d scripts have been updated, so if you have a port installed with a script in /usr/local/etc/rc.d you can either hand-edit the rcvar= line, or reinstall the port. An easy way to handle the mass-update of /etc/rc.d: rm /etc/rc.d/* && mergemaster -i 20120109: panic(9) now stops other CPUs in the SMP systems, disables interrupts on the current CPU and prevents other threads from running. This behavior can be reverted using the kern.stop_scheduler_on_panic tunable/sysctl. The new behavior can be incompatible with kern.sync_on_panic. 20111215: The carp(4) facility has been changed significantly. Configuration of the CARP protocol via ifconfig(8) has changed, as well as format of CARP events submitted to devd(8) has changed. See manual pages for more information. The arpbalance feature of carp(4) is currently not supported anymore. Size of struct in_aliasreq, struct in6_aliasreq has changed. User utilities using SIOCAIFADDR, SIOCAIFADDR_IN6, e.g. ifconfig(8), need to be recompiled. 20111122: The acpi_wmi(4) status device /dev/wmistat has been renamed to /dev/wmistat0. 20111108: The option VFS_ALLOW_NONMPSAFE option has been added in order to explicitely support non-MPSAFE filesystems. It is on by default for all supported platform at this present time. 20111101: The broken amd(4) driver has been replaced with esp(4) in the amd64, i386 and pc98 GENERIC kernel configuration files. 20110930: sysinstall has been removed 20110923: The stable/9 branch created in subversion. This corresponds to the RELENG_9 branch in CVS. COMMON ITEMS: General Notes ------------- Avoid using make -j when upgrading. While generally safe, there are sometimes problems using -j to upgrade. If your upgrade fails with -j, please try again without -j. From time to time in the past there have been problems using -j with buildworld and/or installworld. This is especially true when upgrading between "distant" versions (eg one that cross a major release boundary or several minor releases, or when several months have passed on the -current branch). Sometimes, obscure build problems are the result of environment poisoning. This can happen because the make utility reads its environment when searching for values for global variables. To run your build attempts in an "environmental clean room", prefix all make commands with 'env -i '. See the env(1) manual page for more details. When upgrading from one major version to another it is generally best to upgrade to the latest code in the currently installed branch first, then do an upgrade to the new branch. This is the best-tested upgrade path, and has the highest probability of being successful. Please try this approach before reporting problems with a major version upgrade. When upgrading a live system, having a root shell around before installing anything can help undo problems. Not having a root shell around can lead to problems if pam has changed too much from your starting point to allow continued authentication after the upgrade. This file should be read as a log of events. When a later event changes information of a prior event, the prior event should not be deleted. Instead, a pointer to the entry with the new information should be placed in the old entry. Readers of this file should also sanity check older entries before relying on them blindly. Authors of new entries should write them with this in mind. ZFS notes --------- When upgrading the boot ZFS pool to a new version, always follow these two steps: 1.) recompile and reinstall the ZFS boot loader and boot block (this is part of "make buildworld" and "make installworld") 2.) update the ZFS boot block on your boot drive The following example updates the ZFS boot block on the first partition (freebsd-boot) of a GPT partitioned drive ada0: "gpart bootcode -p /boot/gptzfsboot -i 1 ada0" Non-boot pools do not need these updates. To build a kernel ----------------- If you are updating from a prior version of FreeBSD (even one just a few days old), you should follow this procedure. It is the most failsafe as it uses a /usr/obj tree with a fresh mini-buildworld, make kernel-toolchain make -DALWAYS_CHECK_MAKE buildkernel KERNCONF=YOUR_KERNEL_HERE make -DALWAYS_CHECK_MAKE installkernel KERNCONF=YOUR_KERNEL_HERE To test a kernel once --------------------- If you just want to boot a kernel once (because you are not sure if it works, or if you want to boot a known bad kernel to provide debugging information) run make installkernel KERNCONF=YOUR_KERNEL_HERE KODIR=/boot/testkernel nextboot -k testkernel To just build a kernel when you know that it won't mess you up -------------------------------------------------------------- This assumes you are already running a CURRENT system. Replace ${arch} with the architecture of your machine (e.g. "i386", "arm", "amd64", "ia64", "pc98", "sparc64", "powerpc", "mips", etc). cd src/sys/${arch}/conf config KERNEL_NAME_HERE cd ../compile/KERNEL_NAME_HERE make depend make make install If this fails, go to the "To build a kernel" section. To rebuild everything and install it on the current system. ----------------------------------------------------------- # Note: sometimes if you are running current you gotta do more than # is listed here if you are upgrading from a really old current. make buildworld make kernel KERNCONF=YOUR_KERNEL_HERE [1] [3] mergemaster -Fp [5] make installworld mergemaster -Fi [4] make delete-old [6] To cross-install current onto a separate partition -------------------------------------------------- # In this approach we use a separate partition to hold # current's root, 'usr', and 'var' directories. A partition # holding "/", "/usr" and "/var" should be about 2GB in # size. make buildworld make buildkernel KERNCONF=YOUR_KERNEL_HERE make installworld DESTDIR=${CURRENT_ROOT} -DDB_FROM_SRC make distribution DESTDIR=${CURRENT_ROOT} # if newfs'd make installkernel KERNCONF=YOUR_KERNEL_HERE DESTDIR=${CURRENT_ROOT} cp /etc/fstab ${CURRENT_ROOT}/etc/fstab # if newfs'd To upgrade in-place from stable to current ---------------------------------------------- make buildworld [9] make kernel KERNCONF=YOUR_KERNEL_HERE [8] [1] [3] mergemaster -Fp [5] make installworld mergemaster -Fi [4] make delete-old [6] Make sure that you've read the UPDATING file to understand the tweaks to various things you need. At this point in the life cycle of current, things change often and you are on your own to cope. The defaults can also change, so please read ALL of the UPDATING entries. Also, if you are tracking -current, you must be subscribed to freebsd-current@freebsd.org. Make sure that before you update your sources that you have read and understood all the recent messages there. If in doubt, please track -stable which has much fewer pitfalls. [1] If you have third party modules, such as vmware, you should disable them at this point so they don't crash your system on reboot. [3] From the bootblocks, boot -s, and then do fsck -p mount -u / mount -a cd src adjkerntz -i # if CMOS is wall time Also, when doing a major release upgrade, it is required that you boot into single user mode to do the installworld. [4] Note: This step is non-optional. Failure to do this step can result in a significant reduction in the functionality of the system. Attempting to do it by hand is not recommended and those that pursue this avenue should read this file carefully, as well as the archives of freebsd-current and freebsd-hackers mailing lists for potential gotchas. The -U option is also useful to consider. See mergemaster(8) for more information. [5] Usually this step is a noop. However, from time to time you may need to do this if you get unknown user in the following step. It never hurts to do it all the time. You may need to install a new mergemaster (cd src/usr.sbin/mergemaster && make install) after the buildworld before this step if you last updated from current before 20130425 or from -stable before 20130430. [6] This only deletes old files and directories. Old libraries can be deleted by "make delete-old-libs", but you have to make sure that no program is using those libraries anymore. [8] In order to have a kernel that can run the 4.x binaries needed to do an installworld, you must include the COMPAT_FREEBSD4 option in your kernel. Failure to do so may leave you with a system that is hard to boot to recover. A similar kernel option COMPAT_FREEBSD5 is required to run the 5.x binaries on more recent kernels. And so on for COMPAT_FREEBSD6 and COMPAT_FREEBSD7. Make sure that you merge any new devices from GENERIC since the last time you updated your kernel config file. [9] When checking out sources, you must include the -P flag to have cvs prune empty directories. If CPUTYPE is defined in your /etc/make.conf, make sure to use the "?=" instead of the "=" assignment operator, so that buildworld can override the CPUTYPE if it needs to. MAKEOBJDIRPREFIX must be defined in an environment variable, and not on the command line, or in /etc/make.conf. buildworld will warn if it is improperly defined. FORMAT: This file contains a list, in reverse chronological order, of major breakages in tracking -current. It is not guaranteed to be a complete list of such breakages, and only contains entries since September 23, 2011. If you need to see UPDATING entries from before that date, you will need to fetch an UPDATING file from an older FreeBSD release. Copyright information: Copyright 1998-2009 M. Warner Losh. All Rights Reserved. Redistribution, publication, translation and use, with or without modification, in full or in part, in any form or format of this document are permitted without further permission from the author. THIS DOCUMENT IS PROVIDED BY WARNER LOSH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WARNER LOSH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Contact Warner Losh if you have any questions about your use of this document. $FreeBSD$ Index: stable/11/share/mk/src.opts.mk =================================================================== --- stable/11/share/mk/src.opts.mk (revision 329139) +++ stable/11/share/mk/src.opts.mk (revision 329140) @@ -1,476 +1,478 @@ # $FreeBSD$ # # Option file for FreeBSD /usr/src builds. # # Users define WITH_FOO and WITHOUT_FOO on the command line or in /etc/src.conf # and /etc/make.conf files. These translate in the build system to MK_FOO={yes,no} # with sensible (usually) defaults. # # Makefiles must include bsd.opts.mk after defining specific MK_FOO options that # are applicable for that Makefile (typically there are none, but sometimes there # are exceptions). Recursive makes usually add MK_FOO=no for options that they wish # to omit from that make. # # Makefiles must include bsd.mkopt.mk before they test the value of any MK_FOO # variable. # # Makefiles may also assume that this file is included by src.opts.mk should it # need variables defined there prior to the end of the Makefile where # bsd.{subdir,lib.bin}.mk is traditionally included. # # The old-style YES_FOO and NO_FOO are being phased out. No new instances of them # should be added. Old instances should be removed since they were just to # bridge the gap between FreeBSD 4 and FreeBSD 5. # # Makefiles should never test WITH_FOO or WITHOUT_FOO directly (although an # exception is made for _WITHOUT_SRCONF which turns off this mechanism # completely inside bsd.*.mk files). # .if !target(____) ____: .include # # Define MK_* variables (which are either "yes" or "no") for users # to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the # make(1) environment. # These should be tested with `== "no"' or `!= "no"' in makefiles. # The NO_* variables should only be set by makefiles for variables # that haven't been converted over. # # These options are used by src the builds __DEFAULT_YES_OPTIONS = \ ACCT \ ACPI \ AMD \ APM \ AT \ ATM \ AUDIT \ AUTHPF \ AUTOFS \ BHYVE \ BINUTILS \ BINUTILS_BOOTSTRAP \ BLACKLIST \ BLUETOOTH \ BOOT \ BOOTPARAMD \ BOOTPD \ BSD_CPIO \ BSD_GREP_FASTMATCH \ BSDINSTALL \ BSNMP \ BZIP2 \ CALENDAR \ CAPSICUM \ CASPER \ CCD \ CDDL \ CPP \ CROSS_COMPILER \ CRYPT \ CTM \ CUSE \ CXX \ DIALOG \ DICT \ DMAGENT \ DYNAMICROOT \ ED_CRYPTO \ EE \ ELFCOPY_AS_OBJCOPY \ EFI \ ELFTOOLCHAIN_BOOTSTRAP \ EXAMPLES \ FDT \ FILE \ FINGER \ FLOPPY \ FMTREE \ FORTH \ FP_LIBC \ FREEBSD_UPDATE \ FTP \ GAMES \ GCOV \ GDB \ GNU \ GNU_GREP_COMPAT \ GPIO \ GPL_DTC \ GROFF \ HAST \ HTML \ HYPERV \ ICONV \ INET \ INET6 \ INETD \ IPFILTER \ IPFW \ ISCSI \ JAIL \ KDUMP \ KVM \ LDNS \ LDNS_UTILS \ LEGACY_CONSOLE \ LIB32 \ LIBPTHREAD \ LIBTHR \ + LOADER_GELI \ LOCALES \ LOCATE \ LPR \ LS_COLORS \ LZMA_SUPPORT \ MAIL \ MAILWRAPPER \ MAKE \ MANDOCDB \ NDIS \ NETCAT \ NETGRAPH \ NLS_CATALOGS \ NS_CACHING \ NTP \ OPENSSL \ PAM \ PC_SYSINSTALL \ PF \ PKGBOOTSTRAP \ PMC \ PORTSNAP \ PPP \ QUOTAS \ RADIUS_SUPPORT \ RCMDS \ RBOOTD \ RCS \ RESCUE \ ROUTED \ SENDMAIL \ SETUID_LOGIN \ SHAREDOCS \ SOURCELESS \ SOURCELESS_HOST \ SOURCELESS_UCODE \ SVNLITE \ SYSCONS \ SYSTEM_COMPILER \ TALK \ TCP_WRAPPERS \ TCSH \ TELNET \ TESTS \ TEXTPROC \ TFTP \ TIMED \ UNBOUND \ USB \ UTMPX \ VI \ VT \ WIRELESS \ WPA_SUPPLICANT_EAPOL \ ZFS \ ZONEINFO __DEFAULT_NO_OPTIONS = \ BSD_GREP \ CLANG_EXTRAS \ DTRACE_TESTS \ EISA \ HESIOD \ LIBSOFT \ LINT \ + LOADER_FIREWIRE \ LOADER_FORCE_LE \ NAND \ OFED \ OPENLDAP \ REPRODUCIBLE_BUILD \ RPCBIND_WARMSTART_SUPPORT \ SHARED_TOOLCHAIN \ SORT_THREADS \ SVN \ ZONEINFO_LEAPSECONDS_SUPPORT \ ZONEINFO_OLD_TIMEZONES_SUPPORT \ # # Default behaviour of some options depends on the architecture. Unfortunately # this means that we have to test TARGET_ARCH (the buildworld case) as well # as MACHINE_ARCH (the non-buildworld case). Normally TARGET_ARCH is not # used at all in bsd.*.mk, but we have to make an exception here if we want # to allow defaults for some things like clang to vary by target architecture. # Additional, per-target behavior should be rarely added only after much # gnashing of teeth and grinding of gears. # .if defined(TARGET_ARCH) __T=${TARGET_ARCH} .else __T=${MACHINE_ARCH} .endif .if defined(TARGET) __TT=${TARGET} .else __TT=${MACHINE} .endif .include # If the compiler is not C++11 capable, disable Clang and use GCC instead. # This means that architectures that have GCC 4.2 as default can not # build Clang without using an external compiler. .if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \ ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386") # Clang is enabled, and will be installed as the default /usr/bin/cc. __DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD __DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX .elif ${COMPILER_FEATURES:Mc++11} && ${__T} != "riscv64" && ${__T} != "sparc64" # If an external compiler that supports C++11 is used as ${CC} and Clang # supports the target, then Clang is enabled but GCC is installed as the # default /usr/bin/cc. __DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL GCC GCC_BOOTSTRAP GNUCXX __DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC LLD .else # Everything else disables Clang, and uses GCC instead. __DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX __DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD .endif # In-tree binutils/gcc are older versions without modern architecture support. .if ${__T} == "aarch64" || ${__T} == "riscv64" BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB __DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND .else __DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND .endif .if ${__T} == "riscv64" BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V" BROKEN_OPTIONS+=TESTS # "undefined reference to `_Unwind_Resume'" BROKEN_OPTIONS+=CXX # "libcxxrt.so: undefined reference to `_Unwind_Resume_or_Rethrow'" .endif .if ${__T} == "aarch64" __DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD .else __DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD .endif .if ${__T} == "aarch64" || ${__T} == "amd64" __DEFAULT_YES_OPTIONS+=LLDB .else __DEFAULT_NO_OPTIONS+=LLDB .endif # LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5 .if ${__T} == "arm" || ${__T} == "armeb" BROKEN_OPTIONS+=LLDB .endif # Only doing soft float API stuff on armv6 .if ${__T} != "armv6" BROKEN_OPTIONS+=LIBSOFT .endif .if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || ${__T:Mriscv*} BROKEN_OPTIONS+=EFI .endif .if ${__T:Mmips64*} # profiling won't work on MIPS64 because there is only assembly for o32 BROKEN_OPTIONS+=PROFILE .endif .if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \ ${__T} == "powerpc64" || ${__T} == "sparc64" __DEFAULT_YES_OPTIONS+=CXGBETOOL .else __DEFAULT_NO_OPTIONS+=CXGBETOOL .endif .include # # MK_* options that default to "yes" if the compiler is a C++11 compiler. # .for var in \ LIBCPLUSPLUS .if !defined(MK_${var}) .if ${COMPILER_FEATURES:Mc++11} .if defined(WITHOUT_${var}) MK_${var}:= no .else MK_${var}:= yes .endif .else .if defined(WITH_${var}) MK_${var}:= yes .else MK_${var}:= no .endif .endif .endif .endfor # # Force some options off if their dependencies are off. # Order is somewhat important. # .if ${MK_CAPSICUM} == "no" MK_CASPER:= no .endif .if ${MK_LIBPTHREAD} == "no" MK_LIBTHR:= no .endif .if ${MK_LDNS} == "no" MK_LDNS_UTILS:= no MK_UNBOUND:= no .endif .if ${MK_SOURCELESS} == "no" MK_SOURCELESS_HOST:= no MK_SOURCELESS_UCODE:= no .endif .if ${MK_CDDL} == "no" MK_ZFS:= no MK_CTF:= no .endif .if ${MK_CRYPT} == "no" MK_OPENSSL:= no MK_OPENSSH:= no MK_KERBEROS:= no .endif .if ${MK_CXX} == "no" MK_CLANG:= no MK_GROFF:= no MK_GNUCXX:= no .endif .if ${MK_DIALOG} == "no" MK_BSDINSTALL:= no .endif .if ${MK_MAIL} == "no" MK_MAILWRAPPER:= no MK_SENDMAIL:= no MK_DMAGENT:= no .endif .if ${MK_NETGRAPH} == "no" MK_ATM:= no MK_BLUETOOTH:= no .endif .if ${MK_NLS} == "no" MK_NLS_CATALOGS:= no .endif .if ${MK_OPENSSL} == "no" MK_OPENSSH:= no MK_KERBEROS:= no .endif .if ${MK_PF} == "no" MK_AUTHPF:= no .endif .if ${MK_TESTS} == "no" MK_DTRACE_TESTS:= no .endif .if ${MK_TEXTPROC} == "no" MK_GROFF:= no .endif .if ${MK_ZONEINFO} == "no" MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no .endif .if ${MK_CROSS_COMPILER} == "no" MK_BINUTILS_BOOTSTRAP:= no MK_CLANG_BOOTSTRAP:= no MK_ELFTOOLCHAIN_BOOTSTRAP:= no MK_GCC_BOOTSTRAP:= no .endif .if ${MK_META_MODE} == "yes" MK_SYSTEM_COMPILER:= no .endif .if ${MK_TOOLCHAIN} == "no" MK_BINUTILS:= no MK_CLANG:= no MK_GCC:= no MK_GDB:= no MK_INCLUDES:= no MK_LLD:= no MK_LLDB:= no .endif .if ${MK_CLANG} == "no" MK_CLANG_EXTRAS:= no MK_CLANG_FULL:= no .endif # # MK_* options whose default value depends on another option. # .for vv in \ GSSAPI/KERBEROS \ MAN_UTILS/MAN .if defined(WITH_${vv:H}) MK_${vv:H}:= yes .elif defined(WITHOUT_${vv:H}) MK_${vv:H}:= no .else MK_${vv:H}:= ${MK_${vv:T}} .endif .endfor # # Set defaults for the MK_*_SUPPORT variables. # # # MK_*_SUPPORT options which default to "yes" unless their corresponding # MK_* variable is set to "no". # .for var in \ BLACKLIST \ BZIP2 \ GNU \ INET \ INET6 \ KERBEROS \ KVM \ NETGRAPH \ PAM \ TESTS \ WIRELESS .if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no" MK_${var}_SUPPORT:= no .else MK_${var}_SUPPORT:= yes .endif .endfor .if !${COMPILER_FEATURES:Mc++11} MK_LLDB:= no .endif # gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case. # while in theory we could build it with that, we don't want to do # that since it creates too much confusion for too little gain. # XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too # to prevent Makefile.inc1 from bootstrapping unneeded dependencies # and to support 'make delete-old' when supplying an external toolchain. .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800 MK_GNUCXX:=no MK_GCC:=no .endif .endif # !target(____) Index: stable/11/sys/arm/include/metadata.h =================================================================== --- stable/11/sys/arm/include/metadata.h (revision 329139) +++ stable/11/sys/arm/include/metadata.h (revision 329140) @@ -1,42 +1,57 @@ /*- * Copyright (c) 2003 Peter Wemm * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _MACHINE_METADATA_H_ #define _MACHINE_METADATA_H_ #define MODINFOMD_BOOTINFO 0x1001 #define MODINFOMD_DTBP 0x1002 #define MODINFOMD_EFI_MAP 0x1003 struct efi_map_header { uint64_t memory_size; uint64_t descriptor_size; uint32_t descriptor_version; }; +/* + * Placeholder for now + */ +struct efi_fb { + uint64_t fb_addr; + uint64_t fb_size; + uint32_t fb_height; + uint32_t fb_width; + uint32_t fb_stride; + uint32_t fb_mask_red; + uint32_t fb_mask_green; + uint32_t fb_mask_blue; + uint32_t fb_mask_reserved; +}; + #endif /* !_MACHINE_METADATA_H_ */ Index: stable/11/sys/arm64/include/metadata.h =================================================================== --- stable/11/sys/arm64/include/metadata.h (revision 329139) +++ stable/11/sys/arm64/include/metadata.h (revision 329140) @@ -1,41 +1,54 @@ /*- * Copyright (c) 2014 Andrew Turner * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _MACHINE_METADATA_H_ #define _MACHINE_METADATA_H_ #define MODINFOMD_EFI_MAP 0x1001 #define MODINFOMD_DTBP 0x1002 +#define MODINFOMD_EFI_FB 0x1003 struct efi_map_header { size_t memory_size; size_t descriptor_size; uint32_t descriptor_version; +}; + +struct efi_fb { + uint64_t fb_addr; + uint64_t fb_size; + uint32_t fb_height; + uint32_t fb_width; + uint32_t fb_stride; + uint32_t fb_mask_red; + uint32_t fb_mask_green; + uint32_t fb_mask_blue; + uint32_t fb_mask_reserved; }; #endif /* !_MACHINE_METADATA_H_ */ Index: stable/11/sys/boot/Makefile =================================================================== --- stable/11/sys/boot/Makefile (revision 329139) +++ stable/11/sys/boot/Makefile (revision 329140) @@ -1,22 +1,20 @@ # $FreeBSD$ .include SUBDIR+= libsa .if ${MK_FORTH} != "no" # Build the add-in FORTH interpreter. SUBDIR+= ficl SUBDIR+= forth .endif SUBDIR+= man .include -# Pick the machine-dependent subdir based on the target architecture. -ADIR= ${MACHINE:S/powerpc64/powerpc/} -.if exists(${.CURDIR}/${ADIR}/.) -SUBDIR+= ${ADIR} +.if exists(${.CURDIR}/${MACHINE}/.) +SUBDIR+= ${MACHINE} .endif .include Index: stable/11/sys/boot/Makefile.amd64 =================================================================== --- stable/11/sys/boot/Makefile.amd64 (revision 329139) +++ stable/11/sys/boot/Makefile.amd64 (revision 329140) @@ -1,16 +1,18 @@ # $FreeBSD$ -SUBDIR+= efi SUBDIR+= libsa32 -SUBDIR+= zfs -SUBDIR+= userboot - -.if !defined(LOADER_NO_GELI_SUPPORT) -SUBDIR+= geli +.if ${MK_ZFS} != "no" +SUBDIR+= zfs zfs32 .endif - .if ${MK_FORTH} != "no" SUBDIR+= ficl32 +.endif + +SUBDIR+= efi +SUBDIR+= userboot + +.if ${LOADER_GELI_SUPPORT:Uyes} == "yes" +SUBDIR+= geli .endif SUBDIR+= i386 Index: stable/11/sys/boot/Makefile.arm =================================================================== --- stable/11/sys/boot/Makefile.arm (revision 329139) +++ stable/11/sys/boot/Makefile.arm (revision 329140) @@ -1,7 +1,10 @@ # $FreeBSD$ .if ${MK_FDT} != "no" SUBDIR+= fdt .endif +.if ${MK_ZFS} != "no" +SUBDIR+= zfs +.endif SUBDIR+= efi uboot Index: stable/11/sys/boot/Makefile.arm64 =================================================================== --- stable/11/sys/boot/Makefile.arm64 (revision 329139) +++ stable/11/sys/boot/Makefile.arm64 (revision 329140) @@ -1,7 +1,10 @@ # $FreeBSD$ .if ${MK_FDT} != "no" SUBDIR+= fdt .endif +.if ${MK_ZFS} != "no" +SUBDIR+= zfs +.endif SUBDIR+= efi Index: stable/11/sys/boot/Makefile.i386 =================================================================== --- stable/11/sys/boot/Makefile.i386 (revision 329139) +++ stable/11/sys/boot/Makefile.i386 (revision 329140) @@ -1,9 +1,10 @@ # $FreeBSD$ -SUBDIR+= efi -SUBDIR+= libsa32 -SUBDIR+= zfs - -.if !defined(LOADER_NO_GELI_SUPPORT) +.if ${LOADER_GELI_SUPPORT:Uyes} == "yes" SUBDIR+= geli .endif +.if ${MK_ZFS} != "no" +SUBDIR+= zfs +.endif + +SUBDIR+= efi Index: stable/11/sys/boot/Makefile.inc =================================================================== --- stable/11/sys/boot/Makefile.inc (revision 329139) +++ stable/11/sys/boot/Makefile.inc (revision 329140) @@ -1,43 +1,37 @@ # $FreeBSD$ -.include +.include "defs.mk" .if !defined(__BOOT_MAKEFILE_INC__) __BOOT_MAKEFILE_INC__=${MFILE} - -SASRC=${SRCTOP}/sys/boot/libsa -# Normal Standalone library -LIBSA=${OBJTOP}/sys/boot/libsa/libsa.a -# Standalone library compiled for 32-bit version of the processor -LIBSA32=${OBJTOP}/sys/boot/libsa32/libsa32.a CFLAGS+=-I${SASRC} SSP_CFLAGS= .if ${MACHINE_CPUARCH} == "arm" # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). # Also, the fpu is not available in a standalone environment. .if ${COMPILER_VERSION} < 30800 CFLAGS.clang+= -mllvm -arm-use-movt=0 .else CFLAGS.clang+= -mno-movt .endif CFLAGS.clang+= -mfpu=none .endif # The boot loader build uses dd status=none, where possible, for reproducible # build output (since performance varies from run to run). Trouble is that # option was recently (10.3) added to FreeBSD and is non-standard. Only use it # when this test succeeds rather than require dd to be a bootstrap tool. DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true DD=dd ${DD_NOSTATUS} .if ${MK_LOADER_FORCE_LE} != "no" .if ${MACHINE_ARCH} == "powerpc64" CFLAGS+= -mlittle-endian .endif .endif .endif Index: stable/11/sys/boot/Makefile.powerpc =================================================================== --- stable/11/sys/boot/Makefile.powerpc (revision 329139) +++ stable/11/sys/boot/Makefile.powerpc (revision 329140) @@ -1,9 +1,8 @@ # $FreeBSD$ .if ${MK_FDT} != "no" SUBDIR+= fdt .endif -SUBDIR+= libsa32 SUBDIR+= ofw SUBDIR+= uboot Index: stable/11/sys/boot/Makefile.sparc64 =================================================================== --- stable/11/sys/boot/Makefile.sparc64 (revision 329139) +++ stable/11/sys/boot/Makefile.sparc64 (revision 329140) @@ -1,4 +1,6 @@ # $FreeBSD$ SUBDIR+= ofw +.if ${MK_ZFS} != "no" SUBDIR+= zfs +.endif Index: stable/11/sys/boot/arm/at91/Makefile.inc =================================================================== --- stable/11/sys/boot/arm/at91/Makefile.inc (revision 329139) +++ stable/11/sys/boot/arm/at91/Makefile.inc (nonexistent) @@ -1,57 +0,0 @@ -# $FreeBSD$ - -.if !target(__at91_boot_Makefile.inc__) -.PATH: ${.CURDIR}/../../../../libkern ${.CURDIR}/../../../../libkern/arm - -__at91_boot_Makefile.inc__: - -# tsc, bwct, kb920x, centipad are the supported flavors -BOOT_FLAVOR?=kb920x - -CFLAGS=-Os -mcpu=arm9 -ffreestanding \ - -I${.CURDIR}/../libat91 \ - -I${.CURDIR}/../../../.. \ - -I${.CURDIR}/../../../../arm \ - -D_KERNEL \ - -Wall -Waggregate-return \ - -Wnested-externs \ - -Wpointer-arith -Wshadow -Wwrite-strings \ - -Werror \ - -Wmissing-prototypes \ - -Wmissing-declarations -# -Wstrict-prototypes - -CFLAGS+=-DBOOT_${BOOT_FLAVOR:tu} - -LIBAT91=${.OBJDIR}/../libat91/libat91.a - -LD ?= ld -OBJCOPY ?= objcopy - -.if defined(P) -${P}: ${P}.out - ${OBJCOPY} -S -O binary ${P}.out ${.TARGET} - @set -- `ls -l ${.TARGET}`; x=$$((12288-$$5)); \ - echo "$$x bytes available"; test $$x -ge 0 - -${P}.out: ${OBJS} - ${LD} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LIBAT91} - -CLEANFILES+= ${P} ${P}.out -.endif - -.if defined(WITH_TAG_LIST) -MK_TAG_LIST:=yes -.else -MK_TAG_LIST:=no -.endif - -.if defined(WITH_FPGA) -MK_FPGA:=yes -.else -MK_FPGA:=no -.endif - -.endif - -.include "../Makefile.inc" Property changes on: stable/11/sys/boot/arm/at91/Makefile.inc ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/linker.cfg =================================================================== --- stable/11/sys/boot/arm/at91/linker.cfg (revision 329139) +++ stable/11/sys/boot/arm/at91/linker.cfg (nonexistent) @@ -1,56 +0,0 @@ -/******************************************************************************* - * - * Filename: linker.cfg - * - * linker config file used for internal RAM or eeprom images at address 0. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin move data to SDRAM - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - ******************************************************************************/ -OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", - "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(start) -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = 0; - .text : - { - *(.text) - } - PROVIDE (__etext = .); - PROVIDE (_etext = .); - PROVIDE (etext = .); - .data : - { - __data_start = . ; - *(.data) - } - _edata = .; - PROVIDE (edata = .); - __bss_start = .; - __bss_start__ = .; - .bss : - { - *(.bss) - . = ALIGN(32 / 8); - } - . = ALIGN(32 / 8); - _end = .; - _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; - PROVIDE (end = .); -} Property changes on: stable/11/sys/boot/arm/at91/linker.cfg ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/Makefile (nonexistent) @@ -1,5 +0,0 @@ -# $FreeBSD$ - -SUBDIR= libat91 boot0 boot0iic boot0spi boot2 bootiic bootspi - -.include Property changes on: stable/11/sys/boot/arm/at91/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0/main.c =================================================================== --- stable/11/sys/boot/arm/at91/boot0/main.c (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0/main.c (nonexistent) @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "lib.h" -#include "at91rm9200_lowlevel.h" - -typedef void fn_t(void); - -int main(void); - -int -main(void) -{ - char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ - fn_t *fn = (fn_t *)(SDRAM_BASE + (1 << 20)); /* Load to base + 1MB */ - - while (xmodem_rx(addr) == -1) - continue; - fn(); - return (0); -} Property changes on: stable/11/sys/boot/arm/at91/boot0/main.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0/README =================================================================== --- stable/11/sys/boot/arm/at91/boot0/README (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0/README (nonexistent) @@ -1,7 +0,0 @@ -This is a bootstrap bootloader. It is intended to be used when the -AT91RM9200 is running xmodem over DBGU. It will download the next stage -of the booting process (or the recovery program) and jump to it. It loads -the program at a 1MB offset into SDRAM. Programs are expected to be -smaller than this and copy themselves to the right location. - -$FreeBSD$ Property changes on: stable/11/sys/boot/arm/at91/boot0/README ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0/linker.cfg =================================================================== --- stable/11/sys/boot/arm/at91/boot0/linker.cfg (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0/linker.cfg (nonexistent) @@ -1,84 +0,0 @@ -/******************************************************************************* - * - * Filename: linker.cfg - * - * linker config file used for internal RAM or eeprom images at address 0. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin move data to SDRAM - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - ******************************************************************************/ -OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", - "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(start) -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = 0; - .text : - { - *(.text) - *(.text.*) - *(.stub) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t.*) - *(.glue_7t) *(.glue_7) - } - PROVIDE (__etext = .); - PROVIDE (_etext = .); - PROVIDE (etext = .); - .data : - { - __data_start = . ; - *(.data) - *(.data.*) - *(.gnu.linkonce.d.*) - SORT(CONSTRUCTORS) - } - _edata = .; - PROVIDE (edata = .); - __bss_start = .; - __bss_start__ = .; - .sbss : - { - PROVIDE (__sbss_start = .); - PROVIDE (___sbss_start = .); - *(.dynsbss) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.sb.*) - *(.scommon) - PROVIDE (__sbss_end = .); - PROVIDE (___sbss_end = .); - } - .bss : - { - *(.dynbss) - *(.bss) - *(.bss.*) - *(.gnu.linkonce.b.*) - *(COMMON) - /* Align here to ensure that the .bss section occupies space up to - _end. Align after .bss to ensure correct alignment even if the - .bss section disappears because there are no input sections. */ - . = ALIGN(32 / 8); - } - . = ALIGN(32 / 8); - _end = .; - _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; - PROVIDE (end = .); -} Property changes on: stable/11/sys/boot/arm/at91/boot0/linker.cfg ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/boot0/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0/Makefile (nonexistent) @@ -1,14 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libat91 - -P=boot0 -FILES=${P} -SRCS=arm_init.S main.c -MAN= -LDFLAGS=-e 0 -T ${.CURDIR}/linker.cfg -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -.include - -CFLAGS+=-DBOOT_BOOT0 Property changes on: stable/11/sys/boot/arm/at91/boot0/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0iic/main.c =================================================================== --- stable/11/sys/boot/arm/at91/boot0iic/main.c (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0iic/main.c (nonexistent) @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "lib.h" -#include "at91rm9200_lowlevel.h" - -int main(void); - -int -main(void) -{ - char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ - int len, sec; - - printf("\nSend data to be written into EEPROM\n"); - while ((len = xmodem_rx(addr)) == -1) - continue; - sec = GetSeconds() + 1; - while (sec >= GetSeconds()) - continue; - printf("\nWriting EEPROM from 0x%x to addr 0, 0x%x bytes\n", addr, - len); - InitEEPROM(); - printf("init done\n"); - WriteEEPROM(0, addr, len); - printf("\nWrote %d bytes. Press reset\n", len); - return (1); -} Property changes on: stable/11/sys/boot/arm/at91/boot0iic/main.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0iic/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/boot0iic/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0iic/Makefile (nonexistent) @@ -1,14 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libat91 - -P=boot0iic -FILES=${P} -SRCS=arm_init.S main.c -MAN= -LDFLAGS=-e 0 -T ${.CURDIR}/../linker.cfg -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -.include - -CFLAGS+=-DBOOT_BOOT0 Property changes on: stable/11/sys/boot/arm/at91/boot0iic/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0spi/main.c =================================================================== --- stable/11/sys/boot/arm/at91/boot0spi/main.c (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0spi/main.c (nonexistent) @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "lib.h" -#include "at91rm9200_lowlevel.h" -#include "spi_flash.h" - -#define OFFSET 0 - -int main(void); - -int -main(void) -{ - int len, i, j, off, sec; - char *addr = (char *)SDRAM_BASE + (1 << 20); /* download at + 1MB */ - char *addr2 = (char *)SDRAM_BASE + (2 << 20); /* readback to + 2MB */ - - SPI_InitFlash(); - printf("Waiting for data\n"); - while ((len = xmodem_rx(addr)) == -1) - continue; - printf("Writing %u bytes at %u\n", len, OFFSET); - for (i = 0; i < len; i+= FLASH_PAGE_SIZE) { - off = i + OFFSET; - for (j = 0; j < 10; j++) { - SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE); - SPI_ReadFlash(off, addr2 + i, FLASH_PAGE_SIZE); - if (p_memcmp(addr + i, addr2 + i, FLASH_PAGE_SIZE) == 0) - break; - } - if (j >= 10) - printf("Bad Readback at %u\n", i); - } - sec = GetSeconds() + 2; - while (sec <= GetSeconds()) - continue; - printf("Done\n"); - reset(); - return (1); -} Property changes on: stable/11/sys/boot/arm/at91/boot0spi/main.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot0spi/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/boot0spi/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/boot0spi/Makefile (nonexistent) @@ -1,14 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libat91 - -P=boot0spi -FILES=${P} -SRCS=arm_init.S main.c -MAN= -LDFLAGS=-e 0 -T ${.CURDIR}/../linker.cfg -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -.include - -CFLAGS+=-DBOOT_BOOT0 Property changes on: stable/11/sys/boot/arm/at91/boot0spi/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot2/bwct_board.c =================================================================== --- stable/11/sys/boot/arm/at91/boot2/bwct_board.c (revision 329139) +++ stable/11/sys/boot/arm/at91/boot2/bwct_board.c (nonexistent) @@ -1,125 +0,0 @@ -#include -__FBSDID("$FreeBSD$"); - -#include - -#include "at91rm9200_lowlevel.h" -#include "at91rm9200.h" -#include "emac.h" -#include "lib.h" -#include "ee.h" -#include "board.h" -#include "sd-card.h" - -unsigned char mac[6] = { 0x00, 0x0e, 0x42, 0x02, 0x00, 0x28 }; - -static void USART0_Init(); -static void USART1_Init(); -static void USART2_Init(); -static void USART3_Init(); -static void DS1672_Init(); - -static void -DS1672_Init() { - char buf[] = {0x00, 0xa9}; - - EEWrite(0xd0, buf, sizeof(buf)); -} - -static void -USART0_Init() { - - AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; - AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; - - // setup GPIO - pPio->PIO_ASR = AT91C_PA17_TXD0 | AT91C_PA18_RXD0; - pPio->PIO_PDR = AT91C_PA17_TXD0 | AT91C_PA18_RXD0; - - // enable power - pPMC->PMC_PCER = 1u << AT91C_ID_US0; -} - -static void -USART1_Init() { - - AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; - AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; - - // setup GPIO - pPio->PIO_ASR = AT91C_PB20_TXD1 | AT91C_PB21_RXD1; - pPio->PIO_PDR = AT91C_PB20_TXD1 | AT91C_PB21_RXD1; - - // enable power - pPMC->PMC_PCER = 1u << AT91C_ID_US1; -} - -static void -USART2_Init() { - - AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; - AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; - - // setup GPIO - pPio->PIO_ASR = AT91C_PA23_TXD2 | AT91C_PA22_RXD2; - pPio->PIO_PDR = AT91C_PA23_TXD2 | AT91C_PA22_RXD2; - - // enable power - pPMC->PMC_PCER = 1u << AT91C_ID_US2; -} - -static void -USART3_Init() { - - AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; - AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; - - // setup GPIO - pPio->PIO_BSR = AT91C_PA5_TXD3 | AT91C_PA6_RXD3; - pPio->PIO_PDR = AT91C_PA5_TXD3 | AT91C_PA6_RXD3; - - // enable power - pPMC->PMC_PCER = 1u << AT91C_ID_US3; -} - -void -board_init(void) -{ - - printf("\n\n"); - printf("BWCT FSB-A920-1\n"); - printf("http://www.bwct.de\n"); - printf("\n"); -#if defined(SDRAM_128M) - printf("AT92RM9200 180MHz 128MB\n"); -#else - printf("AT92RM9200 180MHz 64MB\n"); -#endif - printf("Initialising USART0\n"); - USART0_Init(); - printf("Initialising USART1\n"); - USART1_Init(); - printf("Initialising USART2\n"); - USART2_Init(); - printf("Initialising USART3\n"); - USART3_Init(); - printf("Initialising TWI\n"); - EEInit(); - printf("Initialising DS1672\n"); - DS1672_Init(); - printf("Initialising Ethernet\n"); - printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0], - mac[1], mac[2], mac[3], mac[4], mac[5]); - EMAC_Init(); - EMAC_SetMACAddress(mac); - printf("Initialising SD-card\n"); - sdcard_init(); -} - -#include "../bootspi/ee.c" - -int -drvread(void *buf, unsigned lba, unsigned nblk) -{ - return (MCI_read((char *)buf, lba << 9, nblk << 9)); -} Property changes on: stable/11/sys/boot/arm/at91/boot2/bwct_board.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot2/centipad_board.c =================================================================== --- stable/11/sys/boot/arm/at91/boot2/centipad_board.c (revision 329139) +++ stable/11/sys/boot/arm/at91/boot2/centipad_board.c (nonexistent) @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include "emac.h" -#include "lib.h" -#include "board.h" -#include "sd-card.h" - -unsigned char mac[6] = { 0x42, 0x53, 0x44, 0, 1, 1 }; - -static void -MacFromEE() -{ -#if 0 - uint32_t sig; - sig = 0; - ReadEEPROM(12 * 1024, (uint8_t *)&sig, sizeof(sig)); - if (sig != 0x92021054) - return; - ReadEEPROM(12 * 1024 + 4, mac, 6); -#endif - printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0], - mac[1], mac[2], mac[3], mac[4], mac[5]); -} - -void -board_init(void) -{ - InitEEPROM(); - MacFromEE(); - EMAC_Init(); - EMAC_SetMACAddress(mac); - while (sdcard_init() == 0) - printf("Looking for SD card\n"); -} - -int -drvread(void *buf, unsigned lba, unsigned nblk) -{ - return (MCI_read((char *)buf, lba << 9, nblk << 9)); -} Property changes on: stable/11/sys/boot/arm/at91/boot2/centipad_board.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot2/board.h =================================================================== --- stable/11/sys/boot/arm/at91/boot2/board.h (revision 329139) +++ stable/11/sys/boot/arm/at91/boot2/board.h (nonexistent) @@ -1,29 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -void Update(void); -void board_init(void); -int drvread(void *, unsigned, unsigned); Property changes on: stable/11/sys/boot/arm/at91/boot2/board.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot2/boot2.c =================================================================== --- stable/11/sys/boot/arm/at91/boot2/boot2.c (revision 329139) +++ stable/11/sys/boot/arm/at91/boot2/boot2.c (nonexistent) @@ -1,361 +0,0 @@ -/*- - * Copyright (c) 2008 John Hay - * Copyright (c) 2006 M Warner Losh - * Copyright (c) 1998 Robert Nordier - * All rights reserved. - * - * Redistribution and use in source and binary forms are freely - * permitted provided that the above copyright notice and this - * paragraph and the following disclaimer are duplicated in all - * such forms. - * - * This software is provided "AS IS" and without any express or - * implied warranties, including, without limitation, the implied - * warranties of merchantability and fitness for a particular - * purpose. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include - -#include - -#include "lib.h" -#include "board.h" -#include "paths.h" -#include "rbx.h" - -#undef PATH_KERNEL -#define PATH_KERNEL "/boot/kernel/kernel.gz.tramp" - -extern uint32_t _end; - -#define NOPT 6 - -static const char optstr[NOPT] = "agnrsv"; -static const unsigned char bootflags[NOPT] = { - RBX_ASKNAME, - RBX_GDB, - RBX_NOINTR, - RBX_DFLTROOT, - RBX_SINGLE, - RBX_VERBOSE -}; - -unsigned board_id; /* board type to pass to kernel, if set by board_* code */ -unsigned dsk_start; -static char cmd[512]; -static char kname[1024]; -static uint32_t opts; -static uint8_t dsk_meta; - -int main(void); -static void load(void); -static int parse(void); -static int dskread(void *, unsigned, unsigned); -#ifdef FIXUP_BOOT_DRV -static void fixup_boot_drv(caddr_t, int, int, int); -#endif - -#define UFS_SMALL_CGBASE -#include "ufsread.c" - -#ifdef DEBUG -#define DPRINTF(fmt, ...) printf(fmt, __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) -#endif - -static inline int -xfsread(ufs_ino_t inode, void *buf, size_t nbyte) -{ - if ((size_t)fsread(inode, buf, nbyte) != nbyte) - return -1; - return 0; -} - -static inline void -getstr(int c) -{ - char *s; - - s = cmd; - if (c == 0) - c = getc(10000); - for (;;) { - switch (c) { - case 0: - break; - case '\177': - case '\b': - if (s > cmd) { - s--; - printf("\b \b"); - } - break; - case '\n': - case '\r': - *s = 0; - return; - default: - if (s - cmd < sizeof(cmd) - 1) - *s++ = c; - xputchar(c); - } - c = getc(10000); - } -} - -int -main(void) -{ - int autoboot, c = 0; - ufs_ino_t ino; - - dmadat = (void *)(0x20000000 + (16 << 20)); - board_init(); - - autoboot = 1; - - /* Process configuration file */ - if ((ino = lookup(PATH_CONFIG)) || - (ino = lookup(PATH_DOTCONFIG))) - fsread(ino, cmd, sizeof(cmd)); - - if (*cmd) { - if (parse()) - autoboot = 0; - printf("%s: %s\n", PATH_CONFIG, cmd); - /* Do not process this command twice */ - *cmd = 0; - } - - if (*kname == '\0') - strcpy(kname, PATH_KERNEL); - - /* Present the user with the boot2 prompt. */ - for (;;) { - printf("\nDefault: %s\nboot: ", kname); - if (!autoboot || - (OPT_CHECK(RBX_NOINTR) == 0 && (c = getc(2)) != 0)) - getstr(c); - xputchar('\n'); - autoboot = 0; - c = 0; - if (parse()) - xputchar('\a'); - else - load(); - } - return (1); -} - -static void -load(void) -{ - Elf32_Ehdr eh; - static Elf32_Phdr ep[2]; - caddr_t p; - ufs_ino_t ino; - uint32_t addr; - int i, j; -#ifdef FIXUP_BOOT_DRV - caddr_t staddr; - int klen; - - staddr = (caddr_t)0xffffffff; - klen = 0; -#endif - if (!(ino = lookup(kname))) { - if (!ls) - printf("No %s\n", kname); - return; - } - if (xfsread(ino, &eh, sizeof(eh))) - return; - if (!IS_ELF(eh)) { - printf("Invalid %s\n", "format"); - return; - } - fs_off = eh.e_phoff; - for (j = i = 0; i < eh.e_phnum && j < 2; i++) { - if (xfsread(ino, ep + j, sizeof(ep[0]))) - return; - if (ep[j].p_type == PT_LOAD) - j++; - } - for (i = 0; i < 2; i++) { - p = (caddr_t)ep[i].p_paddr; - fs_off = ep[i].p_offset; -#ifdef FIXUP_BOOT_DRV - if (staddr == (caddr_t)0xffffffff) - staddr = p; - klen += ep[i].p_filesz; -#endif - if (xfsread(ino, p, ep[i].p_filesz)) - return; - } - addr = eh.e_entry; -#ifdef FIXUP_BOOT_DRV - fixup_boot_drv(staddr, klen, bootslice, bootpart); -#endif - ((void(*)(int, int, int, int))addr)(opts & RBX_MASK, board_id, 0, 0); -} - -static int -parse() -{ - char *arg = cmd; - char *ep, *p; - int c, i; - - while ((c = *arg++)) { - if (c == ' ' || c == '\t' || c == '\n') - continue; - for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); - ep = p; - if (*p) - *p++ = 0; - if (c == '-') { - while ((c = *arg++)) { - for (i = 0; c != optstr[i]; i++) - if (i == NOPT - 1) - return -1; - opts ^= OPT_SET(bootflags[i]); - } - } else { - arg--; - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(kname)) - return -1; - memcpy(kname, arg, i + 1); - } - } - arg = p; - } - return 0; -} - -static int -dskread(void *buf, unsigned lba, unsigned nblk) -{ - struct dos_partition *dp; - struct disklabel *d; - char *sec; - int i; - - if (!dsk_meta) { - sec = dmadat->secbuf; - dsk_start = 0; - if (drvread(sec, DOSBBSECTOR, 1)) - return -1; - dp = (void *)(sec + DOSPARTOFF); - for (i = 0; i < NDOSPART; i++) { - if (dp[i].dp_typ == DOSPTYP_386BSD) - break; - } - if (i == NDOSPART) - return -1; - /* - * Although dp_start is aligned within the disk - * partition structure, DOSPARTOFF is 446, which is - * only word (2) aligned, not longword (4) aligned. - * Cope by using memcpy to fetch the start of this - * partition. - */ - memcpy(&dsk_start, &dp[1].dp_start, 4); - if (drvread(sec, dsk_start + LABELSECTOR, 1)) - return -1; - d = (void *)(sec + LABELOFFSET); - if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) { - printf("Invalid %s\n", "label"); - return -1; - } - if (!d->d_partitions[0].p_size) { - printf("Invalid %s\n", "partition"); - return -1; - } - dsk_start += d->d_partitions[0].p_offset; - dsk_start -= d->d_partitions[RAW_PART].p_offset; - dsk_meta++; - } - return drvread(buf, dsk_start + lba, nblk); -} - -#ifdef FIXUP_BOOT_DRV -/* - * fixup_boot_drv() will try to find the ROOTDEVNAME spec in the kernel - * and change it to what was specified on the comandline or /boot.conf - * file or to what was encountered on the disk. It will try to handle 3 - * different disk layouts, raw (dangerously dedicated), slice only and - * slice + partition. It will look for the following strings in the - * kernel, but if it is one of the first three, the string in the kernel - * must use the correct form to match the actual disk layout: - * - ufs:ad0a - * - ufs:ad0s1 - * - ufs:ad0s1a - * - ufs:ROOTDEVNAME - * In the case of the first three strings, only the "a" at the end and - * the "1" after the "s" will be modified, if they exist. The string - * length will not be changed. In the case of the last string, the - * whole string will be built up and nul, '\0' terminated. - */ -static void -fixup_boot_drv(caddr_t addr, int klen, int bs, int bp) -{ - const u_int8_t op[] = "ufs:ROOTDEVNAME"; - const u_int8_t op2[] = "ufs:ad0"; - u_int8_t *p, *ps; - - DPRINTF("fixup_boot_drv: 0x%x, %d, slice %d, partition %d\n", - (int)addr, klen, bs, bp); - if (bs > 4) - return; - if (bp > 7) - return; - ps = memmem(addr, klen, op, sizeof(op)); - if (ps != NULL) { - p = ps + 4; /* past ufs: */ - DPRINTF("Found it at 0x%x\n", (int)ps); - p[0] = 'a'; p[1] = 'd'; p[2] = '0'; /* ad0 */ - p += 3; - if (bs > 0) { - /* append slice */ - *p++ = 's'; - *p++ = bs + '0'; - } - if (disk_layout != DL_SLICE) { - /* append partition */ - *p++ = bp + 'a'; - } - *p = '\0'; - } else { - ps = memmem(addr, klen, op2, sizeof(op2) - 1); - if (ps != NULL) { - p = ps + sizeof(op2) - 1; - DPRINTF("Found it at 0x%x\n", (int)ps); - if (*p == 's') { - /* fix slice */ - p++; - *p++ = bs + '0'; - } - if (*p == 'a') - *p = bp + 'a'; - } - } - if (ps == NULL) { - printf("Could not locate \"%s\" to fix kernel boot device, " - "check ROOTDEVNAME is set\n", op); - return; - } - DPRINTF("Changed boot device to %s\n", ps); -} -#endif Property changes on: stable/11/sys/boot/arm/at91/boot2/boot2.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot2/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/boot2/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/boot2/Makefile (nonexistent) @@ -1,22 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libat91 ${.CURDIR}/../bootspi - -P=boot2 -FILES=${P} -SRCS=arm_init.S boot2.c ${BOOT_FLAVOR:tl}_board.c -MAN= -LDFLAGS=-e 0 -T ${.CURDIR}/../linker.cfg -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -.include - -.if ${BOOT_FLAVOR} == "kb920x" -CFLAGS+=-DBOOT_IIC -.endif -CFLAGS+= \ - -I${.CURDIR}/../bootspi \ - -I${.CURDIR}/../../../common \ - -I${.CURDIR}/../../../.. \ - -D_KERNEL \ - -DUFS1_ONLY Property changes on: stable/11/sys/boot/arm/at91/boot2/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/boot2/kb920x_board.c =================================================================== --- stable/11/sys/boot/arm/at91/boot2/kb920x_board.c (revision 329139) +++ stable/11/sys/boot/arm/at91/boot2/kb920x_board.c (nonexistent) @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include "emac.h" -#include "lib.h" -#include "board.h" -#include "sd-card.h" - -unsigned char mac[6] = { 0x42, 0x53, 0x44, 0, 0, 1 }; - -static void -MacFromEE() -{ - uint32_t sig; - sig = 0; - ReadEEPROM(12 * 1024, (uint8_t *)&sig, sizeof(sig)); - if (sig != 0x92021054) - return; - ReadEEPROM(12 * 1024 + 4, mac, 6); - printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0], - mac[1], mac[2], mac[3], mac[4], mac[5]); -} - -void -board_init(void) -{ - InitEEPROM(); - MacFromEE(); - EMAC_Init(); - EMAC_SetMACAddress(mac); - while (sdcard_init() == 0) - printf("Looking for SD card\n"); -} - -int -drvread(void *buf, unsigned lba, unsigned nblk) -{ - return (MCI_read((char *)buf, lba << 9, nblk << 9)); -} Property changes on: stable/11/sys/boot/arm/at91/boot2/kb920x_board.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootiic/env_vars.c =================================================================== --- stable/11/sys/boot/arm/at91/bootiic/env_vars.c (revision 329139) +++ stable/11/sys/boot/arm/at91/bootiic/env_vars.c (nonexistent) @@ -1,207 +0,0 @@ -/****************************************************************************** - * - * Filename: env_vars.c - * - * Instantiation of environment variables, structures, and other globals. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "env_vars.h" -#include "loader_prompt.h" -#include "lib.h" - -/******************************* GLOBALS *************************************/ -char boot_commands[MAX_BOOT_COMMANDS][MAX_INPUT_SIZE]; - -char env_table[MAX_ENV_SIZE_BYTES]; - -extern char BootCommandSection; - -/************************** PRIVATE FUNCTIONS ********************************/ - - -static int currentIndex; -static int currentOffset; - - -/* - * .KB_C_FN_DEFINITION_START - * int ReadCharFromEnvironment(char *) - * This private function reads characters from the environment variables - * to service the command prompt during auto-boot or just to setup the - * default environment. Returns positive value if valid character was - * set in the pointer. Returns negative value to signal input stream - * terminated. Returns 0 to indicate _wait_ condition. - * .KB_C_FN_DEFINITION_END - */ -static int -ReadCharFromEnvironment(int timeout) -{ - int ch; - - if (currentIndex < MAX_BOOT_COMMANDS) { - ch = boot_commands[currentIndex][currentOffset++]; - if (ch == '\0' || (currentOffset >= MAX_INPUT_SIZE)) { - currentOffset = 0; - ++currentIndex; - ch = '\r'; - } - return (ch); - } - - return (-1); -} - - -/*************************** GLOBAL FUNCTIONS ********************************/ - - -/* - * .KB_C_FN_DEFINITION_START - * void WriteCommandTable(void) - * This global function write the current command table to the non-volatile - * memory. - * .KB_C_FN_DEFINITION_END - */ -void -WriteCommandTable(void) -{ - int i, size = MAX_ENV_SIZE_BYTES, copySize; - char *cPtr = env_table; - - p_memset(env_table, 0, sizeof(env_table)); - - for (i = 0; i < MAX_BOOT_COMMANDS; ++i) { - - copySize = p_strlen(boot_commands[i]); - size -= copySize + 1; - - if (size < 0) { - continue; - } - memcpy(cPtr, boot_commands[i], copySize); - cPtr += copySize; - *cPtr++ = 0; - } - - /* We're executing in low RAM so addr in ram == offset in eeprom */ - WriteEEPROM((unsigned)&BootCommandSection, env_table, - sizeof(env_table)); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void SetBootCommand(int index, char *command) - * This global function replaces the specified index with the string residing - * at command. Execute this function with a NULL string to clear the - * associated command index. - * .KB_C_FN_DEFINITION_END - */ -void -SetBootCommand(int index, char *command) -{ - int i; - - if ((unsigned)index < MAX_BOOT_COMMANDS) { - - p_memset(boot_commands[index], 0, MAX_INPUT_SIZE); - - if (!command) - return ; - - for (i = 0; i < MAX_INPUT_SIZE; ++i) { - boot_commands[index][i] = command[i]; - if (!(boot_commands[index][i])) - return; - } - } -} - - -/* - * .KB_C_FN_DEFINITION_START - * void DumpBootCommands(void) - * This global function displays the current boot commands. - * .KB_C_FN_DEFINITION_END - */ -void -DumpBootCommands(void) -{ - int i, j; - - for (i = 0; i < MAX_BOOT_COMMANDS; ++i) { - printf("0x%x : ", i); - for (j = 0; j < MAX_INPUT_SIZE; ++j) { - putchar(boot_commands[i][j]); - if (!(boot_commands[i][j])) - break; - } - printf("[E]\n\r"); - } -} - - -/* - * .KB_C_FN_DEFINITION_START - * void LoadBootCommands(void) - * This global function loads the existing boot commands from raw format and - * coverts it to the standard, command-index format. Notice, the processed - * boot command table has much more space allocated than the actual table - * stored in non-volatile memory. This is because the processed table - * exists in RAM which is larger than the non-volatile space. - * .KB_C_FN_DEFINITION_END - */ -void -LoadBootCommands(void) -{ - int index, j, size; - char *cPtr; - - p_memset((char*)boot_commands, 0, sizeof(boot_commands)); - - cPtr = &BootCommandSection; - - size = MAX_ENV_SIZE_BYTES; - - for (index = 0; (index < MAX_BOOT_COMMANDS) && size; ++index) { - for (j = 0; (j < MAX_INPUT_SIZE) && size; ++j) { - size--; - boot_commands[index][j] = *cPtr++; - if (!(boot_commands[index][j])) { - break; - } - } - } -} - - -/* - * .KB_C_FN_DEFINITION_START - * void ExecuteEnvironmentFunctions(void) - * This global function executes applicable entries in the environment. - * .KB_C_FN_DEFINITION_END - */ -void -ExecuteEnvironmentFunctions(void) -{ - currentIndex = 0; - currentOffset = 0; - - DumpBootCommands(); - Bootloader(ReadCharFromEnvironment); -} Property changes on: stable/11/sys/boot/arm/at91/bootiic/env_vars.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootiic/loader_prompt.h =================================================================== --- stable/11/sys/boot/arm/at91/bootiic/loader_prompt.h (revision 329139) +++ stable/11/sys/boot/arm/at91/bootiic/loader_prompt.h (nonexistent) @@ -1,55 +0,0 @@ -/****************************************************************************** - * - * Filename: loader_prompt.h - * - * Definition of the interactive loader functions. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#ifndef _LOADER_PROMPT_H_ -#define _LOADER_PROMPT_H_ - -#define MAX_INPUT_SIZE 256 -#define MAX_COMMAND_PARAMS 10 - -enum { - COMMAND_INVALID = 0, - COMMAND_COPY, - COMMAND_DUMP, - COMMAND_EXEC, - COMMAND_HELP, - COMMAND_LOCAL_IP, - COMMAND_MAC, - COMMAND_SERVER_IP, - COMMAND_SET, - COMMAND_TAG, - COMMAND_TFTP, - COMMAND_WRITE, - COMMAND_XMODEM, - COMMAND_FINAL_FLAG -} e_cmd_t; - - -typedef struct { - int command; - const char *c_string; -} command_entry_t; - -void EnterInteractiveBootloader(int(*inputFunction)(int)); -void Bootloader(int(*inputFunction)(int)); - -#endif /* _LOADER_PROMPT_H_ */ Property changes on: stable/11/sys/boot/arm/at91/bootiic/loader_prompt.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootiic/main.c =================================================================== --- stable/11/sys/boot/arm/at91/bootiic/main.c (revision 329139) +++ stable/11/sys/boot/arm/at91/bootiic/main.c (nonexistent) @@ -1,55 +0,0 @@ -/******************************************************************************* - * - * Filename: main.c - * - * Basic entry points for top-level functions - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin cosmetic changes - * 29APR2005 kb_admin modified boot delay - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - ******************************************************************************/ - -#include "env_vars.h" -#include "at91rm9200_lowlevel.h" -#include "loader_prompt.h" -#include "emac.h" -#include "lib.h" - -int main(void); - -/* - * .KB_C_FN_DEFINITION_START - * int main(void) - * This global function waits at least one second, but not more than two - * seconds, for input from the serial port. If no response is recognized, - * it acts according to the parameters specified by the environment. For - * example, the function might boot an operating system. Do not return - * from this function. - * .KB_C_FN_DEFINITION_END - */ -int -main(void) -{ - InitEEPROM(); - EMAC_Init(); - LoadBootCommands(); - printf("\n\rKB9202(www.kwikbyte.com)\n\rAuto boot..\n\r"); - if (getc(1) == -1) - ExecuteEnvironmentFunctions(); - Bootloader(0); - - return (1); -} Property changes on: stable/11/sys/boot/arm/at91/bootiic/main.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootiic/README =================================================================== --- stable/11/sys/boot/arm/at91/bootiic/README (revision 329139) +++ stable/11/sys/boot/arm/at91/bootiic/README (nonexistent) @@ -1,35 +0,0 @@ -$FreeBSD$ - -This image is intended to be programmed into boot EEPROM. The image is nearly -0x4000 so it will not fit in KB9200's 0x2000. It is intended for KB9201 or -later. Alternatively, the KB9200 can be upgraded with larger EEPROM. -It performs basic functions prior to executing an image at a -specified address. The pre-boot functions can be modified and saved back into -EEPROM. -The MAC address is set with 0.0.0.0.0.0 by default. This is an invalid address -and must be changed to a valid value in order to use the ethernet interface. - -Memory usage: - -EEPROM = 0x4000 -SDRAM = - run stack = 0x21800000 - variables = 0x21200000 - ethernet = 0x21000000 (buffers and descriptors) - - -Functions supported: - - c - copy - d - display auto command table (in RAM) - e - execute image - ? - help - ip - set local ip - m - set mac - server_ip - set server ip - s - set auto command entry - t - create linux boot tag list - tftp - download image via tftp - w - update auto command table - x - download image via xmodem - Property changes on: stable/11/sys/boot/arm/at91/bootiic/README ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootiic/env_vars.h =================================================================== --- stable/11/sys/boot/arm/at91/bootiic/env_vars.h (revision 329139) +++ stable/11/sys/boot/arm/at91/bootiic/env_vars.h (nonexistent) @@ -1,54 +0,0 @@ -/****************************************************************************** - * - * Filename: env_vars.h - * - * Definition of environment variables, structures, and other globals. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#ifndef _ENV_VARS_H_ -#define _ENV_VARS_H_ - -/* each environment variable is a string following the standard command */ -/* definition used by the interactive loader in the following format: */ -/* ... */ -/* all environment variables (or commands) are stored in a string */ -/* format: NULL-terminated. */ -/* this implies that commands can never utilize 0-values: actual 0, not */ -/* the string '0'. this is not an issue as the string '0' is handled */ -/* by the command parse routine. */ - -/* the following defines the maximum size of the environment for */ -/* including variables. */ -/* this value must match that declared in the low-level file that */ -/* actually reserves the space for the non-volatile environment. */ -#define MAX_ENV_SIZE_BYTES 0x100 - -#define MAX_BOOT_COMMANDS 10 - -/* C-style reference section */ -#ifndef __ASSEMBLY__ - -extern void WriteCommandTable(void); -extern void SetBootCommand(int index, char *command); -extern void DumpBootCommands(void); -extern void LoadBootCommands(void); -extern void ExecuteEnvironmentFunctions(void); - -#endif /* !__ASSEMBLY__ */ - -#endif /* _ENV_VARS_H_ */ Property changes on: stable/11/sys/boot/arm/at91/bootiic/env_vars.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootiic/loader_prompt.c =================================================================== --- stable/11/sys/boot/arm/at91/bootiic/loader_prompt.c (revision 329139) +++ stable/11/sys/boot/arm/at91/bootiic/loader_prompt.c (nonexistent) @@ -1,387 +0,0 @@ -/****************************************************************************** - * - * Filename: loader_prompt.c - * - * Instantiation of the interactive loader functions. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin massive changes for tftp, strings, and more - * 05JUL2005 kb_admin save tag address, and set registers on boot - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "at91rm9200_lowlevel.h" -#ifdef SUPPORT_TAG_LIST -#include "tag_list.h" -#endif -#include "emac.h" -#include "loader_prompt.h" -#include "env_vars.h" -#include "lib.h" - - -/******************************* GLOBALS *************************************/ - - -/*********************** PRIVATE FUNCTIONS/DATA ******************************/ - -static char inputBuffer[MAX_INPUT_SIZE]; -static int buffCount; - -// argv pointer are either NULL or point to locations in inputBuffer -static char *argv[MAX_COMMAND_PARAMS]; - -static const char *backspaceString = "\010 \010"; - -static const command_entry_t CommandTable[] = { - {COMMAND_COPY, "c"}, - {COMMAND_DUMP, "d"}, - {COMMAND_EXEC, "e"}, - {COMMAND_HELP, "?"}, - {COMMAND_LOCAL_IP, "ip"}, - {COMMAND_MAC, "m"}, - {COMMAND_SERVER_IP, "server_ip"}, - {COMMAND_SET, "s"}, -#ifdef SUPPORT_TAG_LIST - {COMMAND_TAG, "t"}, -#endif - {COMMAND_TFTP, "tftp"}, - {COMMAND_WRITE, "w"}, - {COMMAND_XMODEM, "x"}, - {COMMAND_FINAL_FLAG, 0} -}; - -static unsigned tagAddress; - -/* - * .KB_C_FN_DEFINITION_START - * unsigned BuildIP(void) - * This private function packs the test IP info to an unsigned value. - * .KB_C_FN_DEFINITION_END - */ -static unsigned -BuildIP(void) -{ - return ((p_ASCIIToDec(argv[1]) << 24) | - (p_ASCIIToDec(argv[2]) << 16) | - (p_ASCIIToDec(argv[3]) << 8) | - p_ASCIIToDec(argv[4])); -} - - -/* - * .KB_C_FN_DEFINITION_START - * int StringToCommand(char *cPtr) - * This private function converts a command string to a command code. - * .KB_C_FN_DEFINITION_END - */ -static int -StringToCommand(char *cPtr) -{ - int i; - - for (i = 0; CommandTable[i].command != COMMAND_FINAL_FLAG; ++i) - if (!strcmp(CommandTable[i].c_string, cPtr)) - return (CommandTable[i].command); - - return (COMMAND_INVALID); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void RestoreSpace(int) - * This private function restores NULL characters to spaces in order to - * process the remaining args as a string. The number passed is the argc - * of the first entry to begin restoring space in the inputBuffer. - * .KB_C_FN_DEFINITION_END - */ -static void -RestoreSpace(int startArgc) -{ - char *cPtr; - - for (startArgc++; startArgc < MAX_COMMAND_PARAMS; startArgc++) { - if ((cPtr = argv[startArgc])) - *(cPtr - 1) = ' '; - } -} - - -/* - * .KB_C_FN_DEFINITION_START - * int BreakCommand(char *) - * This private function splits the buffer into separate strings as pointed - * by argv and returns the number of parameters (< 0 on failure). - * .KB_C_FN_DEFINITION_END - */ -static int -BreakCommand(char *buffer) -{ - int pCount, cCount, state; - - state = pCount = 0; - p_memset((char*)argv, 0, sizeof(argv)); - - for (cCount = 0; cCount < MAX_INPUT_SIZE; ++cCount) { - - if (!state) { - /* look for next command */ - if (!p_IsWhiteSpace(buffer[cCount])) { - argv[pCount++] = &buffer[cCount]; - state = 1; - } else { - buffer[cCount] = 0; - } - } else { - /* in command, find next white space */ - if (p_IsWhiteSpace(buffer[cCount])) { - buffer[cCount] = 0; - state = 0; - } - } - - if (pCount >= MAX_COMMAND_PARAMS) { - return (-1); - } - } - - return (pCount); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void ParseCommand(char *) - * This private function executes matching functions. - * .KB_C_FN_DEFINITION_END - */ -static void -ParseCommand(char *buffer) -{ - int argc, i; - - if ((argc = BreakCommand(buffer)) < 1) - return; - - switch (StringToCommand(argv[0])) { - case COMMAND_COPY: - { - // "c " - // copy memory - char *to, *from; - unsigned size; - - if (argc > 3) { - to = (char *)p_ASCIIToHex(argv[1]); - from = (char *)p_ASCIIToHex(argv[2]); - size = p_ASCIIToHex(argv[3]); - memcpy(to, from, size); - } - break; - } - - case COMMAND_DUMP: - // display boot commands - DumpBootCommands(); - break; - - case COMMAND_EXEC: - { - // "e
" - // execute at address - void (*execAddr)(unsigned, unsigned, unsigned); - - if (argc > 1) { - /* in future, include machtypes (MACH_KB9200 = 612) */ - execAddr = (void (*)(unsigned, unsigned, unsigned)) - p_ASCIIToHex(argv[1]); - (*execAddr)(0, 612, tagAddress); - } - break; - } - - case COMMAND_TFTP: - { - // "tftp " - // tftp download - unsigned address = 0; - - if (argc > 2) - address = p_ASCIIToHex(argv[1]); - TFTP_Download(address, argv[2]); - break; - } - - case COMMAND_SERVER_IP: - // "server_ip " - // set download server address - if (argc > 4) - SetServerIPAddress(BuildIP()); - break; - - case COMMAND_HELP: - // dump command info - printf("Commands:\n" - "\tc\n" - "\td\n" - "\te\n" - "\tip\n" - "\tserver_ip\n" - "\tm\n" - "\ttftp\n" - "\ts\n" -#ifdef SUPPORT_TAG_LIST - "\tt\n" -#endif - "\tw\n" - "\tx\n"); - break; - - case COMMAND_LOCAL_IP: - // "local_ip - // set ip of this module - if (argc > 4) - SetLocalIPAddress(BuildIP()); - break; - - case COMMAND_MAC: - { - // "m - // set mac address using 6 byte values - unsigned char mac[6]; - - if (argc > 6) { - for (i = 0; i < 6; i++) - mac[i] = p_ASCIIToHex(argv[i + 1]); - EMAC_SetMACAddress(mac); - } - break; - } - - case COMMAND_SET: - { - // s - // set the boot command at index (0-based) - unsigned index; - - if (argc > 1) { - RestoreSpace(2); - index = p_ASCIIToHex(argv[1]); - SetBootCommand(index, argv[2]); - } - break; - } - -#ifdef SUPPORT_TAG_LIST - case COMMAND_TAG: - // t
- // create tag-list for linux boot - if (argc > 2) { - RestoreSpace(2); - tagAddress = p_ASCIIToHex(argv[1]); - InitTagList(argv[2], (void*)tagAddress); - } - break; -#endif - - case COMMAND_WRITE: - // write the command table to non-volatile - WriteCommandTable(); - break; - - case COMMAND_XMODEM: - { - // "x
" - // download X-modem record at address - if (argc > 1) - xmodem_rx((char *)p_ASCIIToHex(argv[1])); - break; - } - - default: - break; - } - - printf("\n"); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void ServicePrompt(char) - * This private function process each character checking for valid commands. - * This function is only executed if the character is considered valid. - * Each command is terminated with NULL (0) or ''. - * .KB_C_FN_DEFINITION_END - */ -static void -ServicePrompt(char p_char) -{ - if (p_char == '\r') - p_char = 0; - - if (p_char == '\010') { - if (buffCount) { - /* handle backspace BS */ - inputBuffer[--buffCount] = 0; - printf(backspaceString); - } - return; - } - if (buffCount < MAX_INPUT_SIZE - 1) { - inputBuffer[buffCount++] = p_char; - putchar(p_char); - } - if (!p_char) { - printf("\n"); - ParseCommand(inputBuffer); - p_memset(inputBuffer, 0, MAX_INPUT_SIZE); - buffCount = 0; - printf("\n>"); - } -} - - -/* ************************** GLOBAL FUNCTIONS ********************************/ - - -/* - * .KB_C_FN_DEFINITION_START - * void Bootloader(void *inputFunction) - * This global function is the entry point for the bootloader. If the - * inputFunction pointer is NULL, the loader input will be serviced from - * the uart. Otherwise, inputFunction is called to get characters which - * the loader will parse. - * .KB_C_FN_DEFINITION_END - */ -void -Bootloader(int(*inputFunction)(int)) -{ - int ch = 0; - - p_memset((void*)inputBuffer, 0, sizeof(inputBuffer)); - - buffCount = 0; - if (!inputFunction) { - inputFunction = getc; - } - - printf("\n>"); - - while (1) - if ((ch = ((*inputFunction)(0))) > 0) - ServicePrompt(ch); -} Property changes on: stable/11/sys/boot/arm/at91/bootiic/loader_prompt.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootiic/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/bootiic/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/bootiic/Makefile (nonexistent) @@ -1,14 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../libat91 - -P=bootiic -FILES=${P} -SRCS=arm_init.S main.c loader_prompt.c env_vars.c -MAN= -LDFLAGS=-e 0 -T ${.CURDIR}/../linker.cfg -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -.include - -CFLAGS += -DBOOT_IIC -DBOOT_COMMANDS Property changes on: stable/11/sys/boot/arm/at91/bootiic/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/env_vars.c =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/env_vars.c (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/env_vars.c (nonexistent) @@ -1,130 +0,0 @@ -/****************************************************************************** - * - * Filename: env_vars.c - * - * Instantiation of environment variables, structures, and other globals. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "env_vars.h" -#include "loader_prompt.h" -#include "lib.h" - -/******************************* GLOBALS *************************************/ -char boot_commands[MAX_BOOT_COMMANDS][MAX_INPUT_SIZE]; - -char env_table[MAX_ENV_SIZE_BYTES]; - -extern char BootCommandSection; - -/************************** PRIVATE FUNCTIONS ********************************/ - - -static int currentIndex; -static int currentOffset; - - -/* - * .KB_C_FN_DEFINITION_START - * int ReadCharFromEnvironment(char *) - * This private function reads characters from the environment variables - * to service the command prompt during auto-boot or just to setup the - * default environment. Returns positive value if valid character was - * set in the pointer. Returns negative value to signal input stream - * terminated. Returns 0 to indicate _wait_ condition. - * .KB_C_FN_DEFINITION_END - */ -static int -ReadCharFromEnvironment(int timeout) -{ - int ch; - - if (currentIndex < MAX_BOOT_COMMANDS) { - ch = boot_commands[currentIndex][currentOffset++]; - if (ch == '\0' || (currentOffset >= MAX_INPUT_SIZE)) { - currentOffset = 0; - ++currentIndex; - ch = '\r'; - } - return (ch); - } - - return (-1); -} - - -/*************************** GLOBAL FUNCTIONS ********************************/ - - -/* - * .KB_C_FN_DEFINITION_START - * void DumpBootCommands(void) - * This global function displays the current boot commands. - * .KB_C_FN_DEFINITION_END - */ -void -DumpBootCommands(void) -{ - int i; - - for (i = 0; boot_commands[i][0]; i++) - printf("0x%x : %s[E]\n", i, boot_commands[i]); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void LoadBootCommands(void) - * This global function loads the existing boot commands from raw format and - * coverts it to the standard, command-index format. Notice, the processed - * boot command table has much more space allocated than the actual table - * stored in non-volatile memory. This is because the processed table - * exists in RAM which is larger than the non-volatile space. - * .KB_C_FN_DEFINITION_END - */ -void -LoadBootCommands(void) -{ - int index, j; - char *cptr; - - p_memset((char*)boot_commands, 0, sizeof(boot_commands)); - cptr = &BootCommandSection; - for (index = 0; *cptr; index++) { - for (j = 0; *cptr; j++) - boot_commands[index][j] = *cptr++; - cptr++; - } -} - - -/* - * .KB_C_FN_DEFINITION_START - * void ExecuteEnvironmentFunctions(void) - * This global function executes applicable entries in the environment. - * .KB_C_FN_DEFINITION_END - */ -void -ExecuteEnvironmentFunctions(void) -{ - currentIndex = 0; - currentOffset = 0; - - DumpBootCommands(); - printf("Autoboot...\n"); - Bootloader(ReadCharFromEnvironment); -} Property changes on: stable/11/sys/boot/arm/at91/bootspi/env_vars.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/loader_prompt.h =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/loader_prompt.h (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/loader_prompt.h (nonexistent) @@ -1,62 +0,0 @@ -/****************************************************************************** - * - * Filename: loader_prompt.h - * - * Definition of the interactive loader functions. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#ifndef _LOADER_PROMPT_H_ -#define _LOADER_PROMPT_H_ - -#define MAX_INPUT_SIZE 256 -#define MAX_COMMAND_PARAMS 10 - -enum { - COMMAND_INVALID = 0, - COMMAND_COPY, - COMMAND_DUMP, - COMMAND_EXEC, - COMMAND_HELP, - COMMAND_LOCAL_IP, - COMMAND_MAC, - COMMAND_SERVER_IP, - COMMAND_SET, - COMMAND_TAG, - COMMAND_TFTP, - COMMAND_WRITE, - COMMAND_XMODEM, - COMMAND_RESET, - COMMAND_LOAD_SPI_KERNEL, - COMMAND_REPLACE_KERNEL_VIA_XMODEM, - COMMAND_REPLACE_FLASH_VIA_XMODEM, - COMMAND_REPLACE_FPGA_VIA_XMODEM, - COMMAND_REPLACE_ID_EEPROM, - COMMAND_FINAL_FLAG -} e_cmd_t; - - -typedef struct { - int command; - const char *c_string; -} command_entry_t; - -void EnterInteractiveBootloader(int(*inputFunction)(int)); -void Bootloader(int(*inputFunction)(int)); -void fpga_load(void); - -#endif /* _LOADER_PROMPT_H_ */ Property changes on: stable/11/sys/boot/arm/at91/bootspi/loader_prompt.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/main.c =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/main.c (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/main.c (nonexistent) @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provided by kwikbyte without - * copyright as follows: - * - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * - * $FreeBSD$ - */ - -#include "env_vars.h" -#include "at91rm9200.h" -#include "at91rm9200_lowlevel.h" -#include "loader_prompt.h" -#include "emac.h" -#include "lib.h" -#include "spi_flash.h" -#include "ee.h" - -int main(void); - -int -main(void) -{ - printf("\nBoot\n"); - EEInit(); - SPI_InitFlash(); -#ifdef TSC_FPGA - fpga_load(); -#endif - EMAC_Init(); - LoadBootCommands(); - if (getc(1) == -1) { - start_wdog(30); - ExecuteEnvironmentFunctions(); - } - Bootloader(getc); - return (1); -} Property changes on: stable/11/sys/boot/arm/at91/bootspi/main.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/README =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/README (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/README (nonexistent) @@ -1,34 +0,0 @@ -$FreeBSD$ - -This image is intended to be programmed into boot EEPROM. The image is nearly -0x4000 so it will not fit in KB9200's 0x2000. It is intended for KB9201 or -later. Alternatively, the KB9200 can be upgraded with larger EEPROM. -It performs basic functions prior to executing an image at a -specified address. The pre-boot functions can be modified and saved back into -EEPROM. -The MAC address is set with 0.0.0.0.0.0 by default. This is an invalid address -and must be changed to a valid value in order to use the ethernet interface. - -Memory usage: - -EEPROM = 0x4000 -SDRAM = - run stack = 0x21800000 - variables = 0x21200000 - ethernet = 0x21000000 (buffers and descriptors) - - -Functions supported: - - c - copy - d - display auto command table (in RAM) - e - execute image - ? - help - ip - set local ip - m - set mac - server_ip - set server ip - s - set auto command entry - t - create linux boot tag list - tftp - download image via tftp - w - update auto command table - x - download image via xmodem Property changes on: stable/11/sys/boot/arm/at91/bootspi/README ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/env_vars.h =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/env_vars.h (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/env_vars.h (nonexistent) @@ -1,54 +0,0 @@ -/****************************************************************************** - * - * Filename: env_vars.h - * - * Definition of environment variables, structures, and other globals. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#ifndef _ENV_VARS_H_ -#define _ENV_VARS_H_ - -/* each environment variable is a string following the standard command */ -/* definition used by the interactive loader in the following format: */ -/* ... */ -/* all environment variables (or commands) are stored in a string */ -/* format: NULL-terminated. */ -/* this implies that commands can never utilize 0-values: actual 0, not */ -/* the string '0'. this is not an issue as the string '0' is handled */ -/* by the command parse routine. */ - -/* the following defines the maximum size of the environment for */ -/* including variables. */ -/* this value must match that declared in the low-level file that */ -/* actually reserves the space for the non-volatile environment. */ -#define MAX_ENV_SIZE_BYTES 0x100 - -#define MAX_BOOT_COMMANDS 10 - -/* C-style reference section */ -#ifndef __ASSEMBLY__ - -extern void WriteCommandTable(void); -extern void SetBootCommand(int index, char *command); -extern void DumpBootCommands(void); -extern void LoadBootCommands(void); -extern void ExecuteEnvironmentFunctions(void); - -#endif /* !__ASSEMBLY__ */ - -#endif /* _ENV_VARS_H_ */ Property changes on: stable/11/sys/boot/arm/at91/bootspi/env_vars.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/ee.c =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/ee.c (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/ee.c (nonexistent) @@ -1,160 +0,0 @@ -/****************************************************************************** - * - * Filename: eeprom.c - * - * Instantiation of eeprom routines - * - * Revision information: - * - * 28AUG2004 kb_admin initial creation - adapted from Atmel sources - * 12JAN2005 kb_admin fixed clock generation, write polling, init - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "at91rm9200_lowlevel.h" -#include "at91rm9200.h" -#include "lib.h" -#include "ee.h" - -/******************************* GLOBALS *************************************/ - - -/*********************** PRIVATE FUNCTIONS/DATA ******************************/ - - -/* Use a macro to calculate the TWI clock generator value to save code space. */ -#define AT91C_TWSI_CLOCK 100000 -#define TWSI_EEPROM_ADDRESS 0x40 - -#define TWI_CLK_BASE_DIV ((AT91C_MASTER_CLOCK/(4*AT91C_TWSI_CLOCK)) - 2) -#define SET_TWI_CLOCK ((0x00010000) | (TWI_CLK_BASE_DIV) | (TWI_CLK_BASE_DIV << 8)) - - -/*************************** GLOBAL FUNCTIONS ********************************/ - - -/* - * .KB_C_FN_DEFINITION_START - * void InitEEPROM(void) - * This global function initializes the EEPROM interface (TWI). Intended - * to be called a single time. - * .KB_C_FN_DEFINITION_END - */ -void -EEInit(void) -{ - - AT91PS_TWI twiPtr = (AT91PS_TWI)AT91C_BASE_TWI; - - AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; - AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; - - pPio->PIO_ASR = AT91C_PIO_PA25 | AT91C_PIO_PA26; - pPio->PIO_PDR = AT91C_PIO_PA25 | AT91C_PIO_PA26; - - pPio->PIO_MDDR = ~AT91C_PIO_PA25; - pPio->PIO_MDER = AT91C_PIO_PA25; - - pPMC->PMC_PCER = 1u << AT91C_ID_TWI; - - twiPtr->TWI_IDR = 0xffffffffu; - twiPtr->TWI_CR = AT91C_TWI_SWRST; - twiPtr->TWI_CR = AT91C_TWI_MSEN | AT91C_TWI_SVDIS; - - twiPtr->TWI_CWGR = SET_TWI_CLOCK; -} - -static inline unsigned -iicaddr(unsigned ee_off) -{ - return (TWSI_EEPROM_ADDRESS | ((ee_off >> 8) & 0x7)); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size) - * This global function reads data from the eeprom at ee_addr storing data - * to data_addr for size bytes. Assume the TWI has been initialized. - * This function does not utilize the page read mode to simplify the code. - * .KB_C_FN_DEFINITION_END - */ -void -EERead(unsigned ee_off, char *data_addr, unsigned size) -{ - const AT91PS_TWI twiPtr = AT91C_BASE_TWI; - unsigned int status; - - if ((ee_off & ~0xff) != ((ee_off + size) & ~0xff)) { - printf("Crosses page boundary: 0x%x 0x%x\n", ee_off, size); - return; - } - - status = twiPtr->TWI_SR; - status = twiPtr->TWI_RHR; - twiPtr->TWI_MMR = (iicaddr(ee_off) << 16) | AT91C_TWI_IADRSZ_1_BYTE | - AT91C_TWI_MREAD; - twiPtr->TWI_IADR = ee_off & 0xff; - twiPtr->TWI_CR = AT91C_TWI_START; - while (size-- > 1) { - while (!(twiPtr->TWI_SR & AT91C_TWI_RXRDY)) - continue; - *(data_addr++) = twiPtr->TWI_RHR; - } - twiPtr->TWI_CR = AT91C_TWI_STOP; - status = twiPtr->TWI_SR; - while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)) - continue; - *data_addr = twiPtr->TWI_RHR; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void WriteEEPROM(unsigned ee_off, char *data_addr, unsigned size) - * This global function writes data to the eeprom at ee_off using data - * from data_addr for size bytes. Assume the TWI has been initialized. - * This function does not utilize the page write mode as the write time is - * much greater than the time required to access the device for byte-write - * functionality. This allows the function to be much simpler. - * .KB_C_FN_DEFINITION_END - */ -void -EEWrite(unsigned ee_off, const char *data_addr, unsigned size) -{ - const AT91PS_TWI twiPtr = AT91C_BASE_TWI; - unsigned status; - char test_data; - - while (size--) { - // Set the TWI Master Mode Register - twiPtr->TWI_MMR = (iicaddr(ee_off) << 16) | - AT91C_TWI_IADRSZ_1_BYTE; - twiPtr->TWI_IADR = ee_off++; - status = twiPtr->TWI_SR; - - // Load one data byte - twiPtr->TWI_THR = *(data_addr++); - twiPtr->TWI_CR = AT91C_TWI_START; - while (!(twiPtr->TWI_SR & AT91C_TWI_TXRDY)) - continue; - twiPtr->TWI_CR = AT91C_TWI_STOP; - status = twiPtr->TWI_SR; - while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)) - continue; - - // wait for write operation to complete, it is done once - // we can read it back... - EERead(ee_off, &test_data, 1); - } -} Property changes on: stable/11/sys/boot/arm/at91/bootspi/ee.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/ee.h =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/ee.h (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/ee.h (nonexistent) @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ - -void EEInit(void); -void EERead(unsigned ee_off, char *data_addr, unsigned size); -void EEWrite(unsigned ee_off, const char *data_addr, unsigned size); - Property changes on: stable/11/sys/boot/arm/at91/bootspi/ee.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/loader_prompt.c =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/loader_prompt.c (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/loader_prompt.c (nonexistent) @@ -1,363 +0,0 @@ -/****************************************************************************** - * - * Filename: loader_prompt.c - * - * Instantiation of the interactive loader functions. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin massive changes for tftp, strings, and more - * 05JUL2005 kb_admin save tag address, and set registers on boot - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "at91rm9200_lowlevel.h" -#include "at91rm9200.h" -#include "emac.h" -#include "loader_prompt.h" -#include "env_vars.h" -#include "lib.h" -#include "spi_flash.h" -#include "ee.h" - -/******************************* GLOBALS *************************************/ - - -/*********************** PRIVATE FUNCTIONS/DATA ******************************/ - -static char inputBuffer[MAX_INPUT_SIZE]; -static int buffCount; - -// argv pointer are either NULL or point to locations in inputBuffer -static char *argv[MAX_COMMAND_PARAMS]; - -#define FLASH_OFFSET (0 * FLASH_PAGE_SIZE) -#define KERNEL_OFFSET (220 * FLASH_PAGE_SIZE) -#define KERNEL_LEN (6 * 1024 * FLASH_PAGE_SIZE) -static const char *backspaceString = "\010 \010"; - -static const command_entry_t CommandTable[] = { - {COMMAND_DUMP, "d"}, - {COMMAND_EXEC, "e"}, - {COMMAND_LOCAL_IP, "ip"}, - {COMMAND_MAC, "m"}, - {COMMAND_SERVER_IP, "server_ip"}, - {COMMAND_TFTP, "tftp"}, - {COMMAND_XMODEM, "x"}, - {COMMAND_RESET, "R"}, - {COMMAND_LOAD_SPI_KERNEL, "k"}, - {COMMAND_REPLACE_KERNEL_VIA_XMODEM, "K"}, - {COMMAND_REPLACE_FLASH_VIA_XMODEM, "I"}, - {COMMAND_REPLACE_ID_EEPROM, "E"}, - {COMMAND_FINAL_FLAG, 0} -}; - -/* - * .KB_C_FN_DEFINITION_START - * unsigned BuildIP(void) - * This private function packs the test IP info to an unsigned value. - * .KB_C_FN_DEFINITION_END - */ -static unsigned -BuildIP(void) -{ - return ((p_ASCIIToDec(argv[1]) << 24) | - (p_ASCIIToDec(argv[2]) << 16) | - (p_ASCIIToDec(argv[3]) << 8) | - p_ASCIIToDec(argv[4])); -} - - -/* - * .KB_C_FN_DEFINITION_START - * int StringToCommand(char *cPtr) - * This private function converts a command string to a command code. - * .KB_C_FN_DEFINITION_END - */ -static int -StringToCommand(char *cPtr) -{ - int i; - - for (i = 0; CommandTable[i].command != COMMAND_FINAL_FLAG; ++i) - if (!strcmp(CommandTable[i].c_string, cPtr)) - return (CommandTable[i].command); - - return (COMMAND_INVALID); -} - - -/* - * .KB_C_FN_DEFINITION_START - * int BreakCommand(char *) - * This private function splits the buffer into separate strings as pointed - * by argv and returns the number of parameters (< 0 on failure). - * .KB_C_FN_DEFINITION_END - */ -static int -BreakCommand(char *buffer) -{ - int pCount, cCount, state; - - state = pCount = 0; - p_memset((char*)argv, 0, sizeof(argv)); - - for (cCount = 0; cCount < MAX_INPUT_SIZE; ++cCount) { - - if (!state) { - /* look for next command */ - if (!p_IsWhiteSpace(buffer[cCount])) { - argv[pCount++] = &buffer[cCount]; - state = 1; - } else { - buffer[cCount] = 0; - } - } else { - /* in command, find next white space */ - if (p_IsWhiteSpace(buffer[cCount])) { - buffer[cCount] = 0; - state = 0; - } - } - - if (pCount >= MAX_COMMAND_PARAMS) { - return (-1); - } - } - - return (pCount); -} - -#if 0 -static void -UpdateEEProm(int eeaddr) -{ - char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ - int len; - - while ((len = xmodem_rx(addr)) == -1) - continue; - printf("\nDownloaded %u bytes.\n", len); - WriteEEPROM(eeaddr, 0, addr, len); -} -#endif - -static void -UpdateFlash(int offset) -{ - char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ - int len, i, off; - - while ((len = xmodem_rx(addr)) == -1) - continue; - printf("\nDownloaded %u bytes.\n", len); - for (i = 0; i < len; i+= FLASH_PAGE_SIZE) { - off = i + offset; - SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE); - } -} - -static void -LoadKernelFromSpi(char *addr) -{ - int i, off; - - for (i = 0; i < KERNEL_LEN; i+= FLASH_PAGE_SIZE) { - off = i + KERNEL_OFFSET; - SPI_ReadFlash(off, addr + i, FLASH_PAGE_SIZE); - } -} - -/* - * .KB_C_FN_DEFINITION_START - * void ParseCommand(char *) - * This private function executes matching functions. - * .KB_C_FN_DEFINITION_END - */ -static void -ParseCommand(char *buffer) -{ - int argc, i; - - if ((argc = BreakCommand(buffer)) < 1) - return; - - switch (StringToCommand(argv[0])) { - case COMMAND_DUMP: - // display boot commands - DumpBootCommands(); - break; - - case COMMAND_EXEC: - { - // "e
" - // execute at address - void (*execAddr)(unsigned, unsigned); - - if (argc > 1) { - /* in future, include machtypes (MACH_KB9200 = 612) */ - execAddr = (void (*)(unsigned, unsigned)) - p_ASCIIToHex(argv[1]); - (*execAddr)(0, 612); - } - break; - } - - case COMMAND_TFTP: - { - // "tftp " - // tftp download - unsigned address = 0; - - if (argc > 2) - address = p_ASCIIToHex(argv[1]); - TFTP_Download(address, argv[2]); - break; - } - - case COMMAND_SERVER_IP: - // "server_ip " - // set download server address - if (argc > 4) - SetServerIPAddress(BuildIP()); - break; - - case COMMAND_LOCAL_IP: - // "local_ip - // set ip of this module - if (argc > 4) - SetLocalIPAddress(BuildIP()); - break; - - case COMMAND_MAC: - { - // "m - // set mac address using 6 byte values - unsigned char mac[6]; - - if (argc > 6) { - for (i = 0; i < 6; i++) - mac[i] = p_ASCIIToHex(argv[i + 1]); - EMAC_SetMACAddress(mac); - } - break; - } - - case COMMAND_LOAD_SPI_KERNEL: - // "k
" - if (argc > 1) - LoadKernelFromSpi((char *)p_ASCIIToHex(argv[1])); - break; - - case COMMAND_XMODEM: - // "x
" - // download X-modem record at address - if (argc > 1) - xmodem_rx((char *)p_ASCIIToHex(argv[1])); - break; - - case COMMAND_RESET: - printf("Reset\n"); - reset(); - while (1) continue; - break; - - case COMMAND_REPLACE_KERNEL_VIA_XMODEM: - printf("Updating KERNEL image\n"); - UpdateFlash(KERNEL_OFFSET); - break; - case COMMAND_REPLACE_FLASH_VIA_XMODEM: - printf("Updating FLASH image\n"); - UpdateFlash(FLASH_OFFSET); - break; - - case COMMAND_REPLACE_ID_EEPROM: - { - char buf[25]; - printf("Testing Config EEPROM\n"); - EEWrite(0, "This is a test", 15); - EERead(0, buf, 15); - printf("Found '%s'\n", buf); - break; - } - default: - break; - } - - printf("\n"); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void ServicePrompt(char) - * This private function process each character checking for valid commands. - * This function is only executed if the character is considered valid. - * Each command is terminated with NULL (0) or ''. - * .KB_C_FN_DEFINITION_END - */ -static void -ServicePrompt(char p_char) -{ - if (p_char == '\r') - p_char = 0; - - if (p_char == '\010') { - if (buffCount) { - /* handle backspace BS */ - inputBuffer[--buffCount] = 0; - printf(backspaceString); - } - return; - } - if (buffCount < MAX_INPUT_SIZE - 1) { - inputBuffer[buffCount++] = p_char; - putchar(p_char); - } - if (!p_char) { - printf("\n"); - ParseCommand(inputBuffer); - p_memset(inputBuffer, 0, MAX_INPUT_SIZE); - buffCount = 0; - printf("\n>"); - } -} - - -/* ************************** GLOBAL FUNCTIONS ********************************/ - - -/* - * .KB_C_FN_DEFINITION_START - * void Bootloader(void *inputFunction) - * This global function is the entry point for the bootloader. If the - * inputFunction pointer is NULL, the loader input will be serviced from - * the uart. Otherwise, inputFunction is called to get characters which - * the loader will parse. - * .KB_C_FN_DEFINITION_END - */ -void -Bootloader(int(*inputFunction)(int)) -{ - int ch = 0; - - p_memset((void*)inputBuffer, 0, sizeof(inputBuffer)); - buffCount = 0; - - printf("\n>"); - - while (1) - if ((ch = ((*inputFunction)(0))) > 0) - ServicePrompt(ch); -} Property changes on: stable/11/sys/boot/arm/at91/bootspi/loader_prompt.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/bootspi/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/bootspi/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/bootspi/Makefile (nonexistent) @@ -1,19 +0,0 @@ -# $FreeBSD$ - -.include - -.PATH: ${.CURDIR}/../libat91 - -P=bootspi -FILES=${P} -SRCS=arm_init.S main.c loader_prompt.c env_vars.c ee.c -MAN= -LDFLAGS=-e 0 -T ${.CURDIR}/../linker.cfg -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -.include - -.if ${MK_FPGA} == "yes" -CFLAGS += -DTSC_FPGA -.endif -CFLAGS += -DBOOT_COMMANDS Property changes on: stable/11/sys/boot/arm/at91/bootspi/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h (nonexistent) @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _AT91RM9200_LOWLEVEL_H_ -#define _AT91RM9200_LOWLEVEL_H_ - -/* default system config parameters */ - -#define SDRAM_BASE 0x20000000 - -#ifdef BOOT_KB920X -/* The following divisor sets PLLA frequency: e.g. 10/5 * 90 = 180MHz */ -#define OSC_MAIN_FREQ_DIV 5 /* for 10MHz osc */ -#define SDRAM_WIDTH AT91C_SDRC_DBW_16_BITS -typedef unsigned short sdram_size_t; -#define OSC_MAIN_MULT 90 -#endif - -#ifdef BOOT_CENTIPAD -/* The following divisor sets PLLA frequency: e.g. 10/5 * 90 = 180MHz */ -#define OSC_MAIN_FREQ_DIV 5 /* for 10MHz osc */ -#define SDRAM_WIDTH AT91C_SDRC_DBW_16_BITS -typedef unsigned short sdram_size_t; -#define OSC_MAIN_MULT 90 -#endif - -#ifdef BOOT_BWCT -/* The following divisor sets PLLA frequency: e.g. 16/4 * 45 = 180MHz */ -#define OSC_MAIN_FREQ_DIV 4 /* for 16MHz osc */ -#define SDRAM_WIDTH AT91C_SDRC_DBW_32_BITS -typedef unsigned int sdram_size_t; -#define OSC_MAIN_MULT 45 -#endif - -#ifdef BOOT_TSC -/* The following divisor sets PLLA frequency: e.g. 16/4 * 45 = 180MHz */ -#define OSC_MAIN_FREQ_DIV 4 /* for 16MHz osc */ -#define SDRAM_WIDTH AT91C_SDRC_DBW_32_BITS -typedef unsigned int sdram_size_t; -#define OSC_MAIN_MULT 45 -#endif - -/* Master clock frequency at power-up */ -#define AT91C_MASTER_CLOCK 60000000 - -/* #define GetSeconds() (AT91C_BASE_RTC->RTC_TIMR & AT91C_RTC_SEC) */ -#define GetSeconds() (AT91C_BASE_ST->ST_CRTR >> 15) - -extern void _init(void); - -#endif /* _AT91RM9200_LOWLEVEL_H_ */ Property changes on: stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/sd-card.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/sd-card.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/sd-card.h (nonexistent) @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. - * - * $FreeBSD$ - */ - -#ifndef __SD_CARD_H -#define __SD_CARD_H - -/* MCI_read() is the original read function, taking a byte offset and byte - * count. It is preserved to support existing customized boot code that still - * refers to it; it will work fine even on SDHC cards as long as the kernel and - * the metadata for locating it all exist within the first 4GB of the card. - * - * MCI_readblocks() is the new read function, taking offset and length in terms - * of block counts (where the SD spec defines a block as 512 bytes), allowing - * the kernel and filesystem metadata to be located anywhere on an SDHC card. - * - * Returns 0 on success, non-zero on failure. - */ - -int MCI_read (char* dest, unsigned bytenum, unsigned length); -int MCI_readblocks (char* dest, unsigned blknum, unsigned blkcount); - -/* sdcard_init() - get things set up to read from an SD or SDHC card. - * - * Returns 0 on failure, non-zero on success. - */ - -int sdcard_init(void); - -/* By default sdcard_init() sets things up for a 1-wire interface to the - * SD card. Calling sdcard_4wire(true) after sdcard_init() allows customized - * boot code to change to 4-bit transfers when the hardware supports it. - * - * Returns 0 on failure, non-zero on success. - */ -int sdcard_use4wire(int use4wire); - -#endif - Property changes on: stable/11/sys/boot/arm/at91/libat91/sd-card.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/putchar.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/putchar.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/putchar.c (nonexistent) @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provided by kwikbyte without - * copyright as follows: - * - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "at91rm9200_lowlevel.h" -#include "lib.h" - -/* - * void putchar(int ch) - * Writes a character to the DBGU port. It assumes that DBGU has - * already been initialized. - */ -void -putchar(int ch) -{ - AT91PS_USART pUSART = (AT91PS_USART)AT91C_BASE_DBGU; - - while (!(pUSART->US_CSR & AT91C_US_TXRDY)) - continue; - pUSART->US_THR = (ch & 0xFF); -} - -void -xputchar(int ch) -{ - if (ch == '\n') - putchar('\r'); - putchar(ch); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/putchar.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/reset.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/reset.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/reset.c (nonexistent) @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "lib.h" - -/* - * void reset() - * - * Forces a reset of the system. Uses watchdog timer of '1', which - * corresponds to 128 / SLCK seconds (SLCK is 32,768 Hz, so 128/32768 is - * 1 / 256 ~= 5.4ms - */ -void -reset(void) -{ - // The following should effect a reset. - AT91C_BASE_ST->ST_WDMR = 1 | AT91C_ST_RSTEN; - AT91C_BASE_ST->ST_CR = AT91C_ST_WDRST; -} - -/* - * void start_wdog() - * - * Starts a watchdog timer. We force the boot process to get to the point - * it can kick the watch dog part of the ST part for the OS's driver. - */ -void -start_wdog(int n) -{ - // The following should effect a reset after N seconds. - AT91C_BASE_ST->ST_WDMR = (n * (32768 / 128)) | AT91C_ST_RSTEN; - AT91C_BASE_ST->ST_CR = AT91C_ST_WDRST; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/reset.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/emac_init.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/emac_init.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/emac_init.c (nonexistent) @@ -1,117 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. - * - * $FreeBSD$ - */ - -/****************************************************************************** - * - * Filename: emac.c - * - * Instantiation of routines for MAC/ethernet functions supporting tftp. - * - * Revision information: - * - * 28AUG2004 kb_admin initial creation - * 08JAN2005 kb_admin added tftp download - * also adapted from external sources - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - ******************************************************************************/ - -#include "at91rm9200.h" -#include "at91rm9200_lowlevel.h" -#include "emac.h" -#include "lib.h" - -/* ****************************** GLOBALS *************************************/ - -unsigned localMACSet; -unsigned char localMACAddr[6]; -unsigned localMAClow, localMAChigh; - -/* ********************** PRIVATE FUNCTIONS/DATA ******************************/ - -/* - * .KB_C_FN_DEFINITION_START - * void EMAC_SetMACAddress(unsigned low_address, unsigned high_address) - * This global function sets the MAC address. low_address is the first - * four bytes while high_address is the last 2 bytes of the 48-bit value. - * .KB_C_FN_DEFINITION_END - */ -void -EMAC_SetMACAddress(unsigned char mac[6]) -{ - AT91PS_PMC pPMC = AT91C_BASE_PMC; - AT91PS_EMAC pEmac = AT91C_BASE_EMAC; - - /* enable the peripheral clock before using EMAC */ - pPMC->PMC_PCER = ((unsigned) 1 << AT91C_ID_EMAC); - - memcpy(localMACAddr, mac, 6); - localMAClow = (mac[3] << 24) | (mac[2] << 16) | (mac[1] << 8) | mac[0]; - localMAChigh = (mac[5] << 8) | mac[4]; - localMACSet = 1; - - AT91C_BASE_PMC->PMC_PCER = 1u << AT91C_ID_EMAC; - AT91C_BASE_PIOA->PIO_ASR = - AT91C_PIO_PA14 | AT91C_PIO_PA12 | AT91C_PIO_PA13 | - AT91C_PIO_PA8 | AT91C_PIO_PA16 | AT91C_PIO_PA9 | - AT91C_PIO_PA10 | AT91C_PIO_PA11 | AT91C_PIO_PA15 | - AT91C_PIO_PA7; - AT91C_BASE_PIOA->PIO_PDR = - AT91C_PIO_PA14 | AT91C_PIO_PA12 | AT91C_PIO_PA13 | - AT91C_PIO_PA8 | AT91C_PIO_PA16 | AT91C_PIO_PA9 | - AT91C_PIO_PA10 | AT91C_PIO_PA11 | AT91C_PIO_PA15 | - AT91C_PIO_PA7; -#if defined(BOOT_KB920X) | defined(BOOT_BWCT) /* Really !RMII */ - AT91C_BASE_PIOB->PIO_BSR = - AT91C_PIO_PB12 | AT91C_PIO_PB13 | AT91C_PIO_PB14 | - AT91C_PIO_PB15 | AT91C_PIO_PB16 | AT91C_PIO_PB17 | - AT91C_PIO_PB18 | AT91C_PIO_PB19; - AT91C_BASE_PIOB->PIO_PDR = - AT91C_PIO_PB12 | AT91C_PIO_PB13 | AT91C_PIO_PB14 | - AT91C_PIO_PB15 | AT91C_PIO_PB16 | AT91C_PIO_PB17 | - AT91C_PIO_PB18 | AT91C_PIO_PB19; -#endif - pEmac->EMAC_CTL = 0; - - pEmac->EMAC_CFG = (pEmac->EMAC_CFG & ~(AT91C_EMAC_CLK)) | -#ifdef BOOT_TSC - AT91C_EMAC_RMII | -#endif - AT91C_EMAC_CLK_HCLK_32 | AT91C_EMAC_CAF; - // the sequence write EMAC_SA1L and write EMAC_SA1H must be respected - pEmac->EMAC_SA1L = localMAClow; - pEmac->EMAC_SA1H = localMAChigh; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/emac_init.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/at91rm9200.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/at91rm9200.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/at91rm9200.h (nonexistent) @@ -1,2411 +0,0 @@ -// ---------------------------------------------------------------------------- -// ATMEL Microcontroller Software Support - ROUSSET - -// ---------------------------------------------------------------------------- -// The software is delivered "AS IS" without warranty or condition of any -// kind, either express, implied or statutory. This includes without -// limitation any warranty or condition with respect to merchantability or -// fitness for any particular purpose, or against the infringements of -// intellectual property rights of others. -// ---------------------------------------------------------------------------- -// $FreeBSD$ -// -// File Name : AT91RM9200.h -// Object : AT91RM9200 definitions -// Generated : AT91 SW Application Group 07/04/2003 (11:05:04) -// -// CVS Reference : /AT91RM9200.pl/1.16/Fri Feb 07 09:29:50 2003// -// CVS Reference : /SYS_AT91RM9200.pl/1.2/Fri Jan 17 11:44:36 2003// -// CVS Reference : /MC_1760A.pl/1.1/Fri Aug 23 13:38:22 2002// -// CVS Reference : /AIC_1796B.pl/1.1.1.1/Fri Jun 28 08:36:46 2002// -// CVS Reference : /PMC_2636A.pl/1.1.1.1/Fri Jun 28 08:36:48 2002// -// CVS Reference : /ST_1763B.pl/1.1/Fri Aug 23 13:41:42 2002// -// CVS Reference : /RTC_1245D.pl/1.2/Fri Jan 31 11:19:06 2003// -// CVS Reference : /PIO_1725D.pl/1.1.1.1/Fri Jun 28 08:36:46 2002// -// CVS Reference : /DBGU_1754A.pl/1.4/Fri Jan 31 11:18:24 2003// -// CVS Reference : /UDP_1765B.pl/1.3/Fri Aug 02 13:45:38 2002// -// CVS Reference : /MCI_1764A.pl/1.2/Thu Nov 14 16:48:24 2002// -// CVS Reference : /US_1739C.pl/1.2/Fri Jul 12 06:49:24 2002// -// CVS Reference : /SPI_AT91RMxxxx.pl/1.3/Tue Nov 26 09:20:28 2002// -// CVS Reference : /SSC_1762A.pl/1.2/Fri Nov 08 12:26:38 2002// -// CVS Reference : /TC_1753B.pl/1.2/Fri Jan 31 11:19:54 2003// -// CVS Reference : /TWI_1761B.pl/1.4/Fri Feb 07 09:30:06 2003// -// CVS Reference : /PDC_1734B.pl/1.2/Thu Nov 21 15:38:22 2002// -// CVS Reference : /UHP_xxxxA.pl/1.1/Mon Jul 22 11:21:58 2002// -// CVS Reference : /EMAC_1794A.pl/1.4/Fri Jan 17 11:11:54 2003// -// CVS Reference : /EBI_1759B.pl/1.10/Fri Jan 17 11:44:28 2003// -// CVS Reference : /SMC_1783A.pl/1.3/Thu Oct 31 13:38:16 2002// -// CVS Reference : /SDRC_1758B.pl/1.2/Thu Oct 03 12:04:40 2002// -// CVS Reference : /BFC_1757B.pl/1.3/Thu Oct 31 13:38:00 2002// -// ---------------------------------------------------------------------------- - -#ifndef AT91RM9200_H -#define AT91RM9200_H - -#define ATMEL_ENV - -typedef volatile unsigned int AT91_REG;// Hardware register definition - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR System Peripherals -// ***************************************************************************** -typedef struct _AT91S_SYS { - AT91_REG AIC_SMR[32]; // Source Mode Register - AT91_REG AIC_SVR[32]; // Source Vector Register - AT91_REG AIC_IVR; // IRQ Vector Register - AT91_REG AIC_FVR; // FIQ Vector Register - AT91_REG AIC_ISR; // Interrupt Status Register - AT91_REG AIC_IPR; // Interrupt Pending Register - AT91_REG AIC_IMR; // Interrupt Mask Register - AT91_REG AIC_CISR; // Core Interrupt Status Register - AT91_REG Reserved0[2]; // - AT91_REG AIC_IECR; // Interrupt Enable Command Register - AT91_REG AIC_IDCR; // Interrupt Disable Command Register - AT91_REG AIC_ICCR; // Interrupt Clear Command Register - AT91_REG AIC_ISCR; // Interrupt Set Command Register - AT91_REG AIC_EOICR; // End of Interrupt Command Register - AT91_REG AIC_SPU; // Spurious Vector Register - AT91_REG AIC_DCR; // Debug Control Register (Protect) - AT91_REG Reserved1[1]; // - AT91_REG AIC_FFER; // Fast Forcing Enable Register - AT91_REG AIC_FFDR; // Fast Forcing Disable Register - AT91_REG AIC_FFSR; // Fast Forcing Status Register - AT91_REG Reserved2[45]; // - AT91_REG DBGU_CR; // Control Register - AT91_REG DBGU_MR; // Mode Register - AT91_REG DBGU_IER; // Interrupt Enable Register - AT91_REG DBGU_IDR; // Interrupt Disable Register - AT91_REG DBGU_IMR; // Interrupt Mask Register - AT91_REG DBGU_CSR; // Channel Status Register - AT91_REG DBGU_RHR; // Receiver Holding Register - AT91_REG DBGU_THR; // Transmitter Holding Register - AT91_REG DBGU_BRGR; // Baud Rate Generator Register - AT91_REG Reserved3[7]; // - AT91_REG DBGU_C1R; // Chip ID1 Register - AT91_REG DBGU_C2R; // Chip ID2 Register - AT91_REG DBGU_FNTR; // Force NTRST Register - AT91_REG Reserved4[45]; // - AT91_REG DBGU_RPR; // Receive Pointer Register - AT91_REG DBGU_RCR; // Receive Counter Register - AT91_REG DBGU_TPR; // Transmit Pointer Register - AT91_REG DBGU_TCR; // Transmit Counter Register - AT91_REG DBGU_RNPR; // Receive Next Pointer Register - AT91_REG DBGU_RNCR; // Receive Next Counter Register - AT91_REG DBGU_TNPR; // Transmit Next Pointer Register - AT91_REG DBGU_TNCR; // Transmit Next Counter Register - AT91_REG DBGU_PTCR; // PDC Transfer Control Register - AT91_REG DBGU_PTSR; // PDC Transfer Status Register - AT91_REG Reserved5[54]; // - AT91_REG PIOA_PER; // PIO Enable Register - AT91_REG PIOA_PDR; // PIO Disable Register - AT91_REG PIOA_PSR; // PIO Status Register - AT91_REG Reserved6[1]; // - AT91_REG PIOA_OER; // Output Enable Register - AT91_REG PIOA_ODR; // Output Disable Registerr - AT91_REG PIOA_OSR; // Output Status Register - AT91_REG Reserved7[1]; // - AT91_REG PIOA_IFER; // Input Filter Enable Register - AT91_REG PIOA_IFDR; // Input Filter Disable Register - AT91_REG PIOA_IFSR; // Input Filter Status Register - AT91_REG Reserved8[1]; // - AT91_REG PIOA_SODR; // Set Output Data Register - AT91_REG PIOA_CODR; // Clear Output Data Register - AT91_REG PIOA_ODSR; // Output Data Status Register - AT91_REG PIOA_PDSR; // Pin Data Status Register - AT91_REG PIOA_IER; // Interrupt Enable Register - AT91_REG PIOA_IDR; // Interrupt Disable Register - AT91_REG PIOA_IMR; // Interrupt Mask Register - AT91_REG PIOA_ISR; // Interrupt Status Register - AT91_REG PIOA_MDER; // Multi-driver Enable Register - AT91_REG PIOA_MDDR; // Multi-driver Disable Register - AT91_REG PIOA_MDSR; // Multi-driver Status Register - AT91_REG Reserved9[1]; // - AT91_REG PIOA_PPUDR; // Pull-up Disable Register - AT91_REG PIOA_PPUER; // Pull-up Enable Register - AT91_REG PIOA_PPUSR; // Pad Pull-up Status Register - AT91_REG Reserved10[1]; // - AT91_REG PIOA_ASR; // Select A Register - AT91_REG PIOA_BSR; // Select B Register - AT91_REG PIOA_ABSR; // AB Select Status Register - AT91_REG Reserved11[9]; // - AT91_REG PIOA_OWER; // Output Write Enable Register - AT91_REG PIOA_OWDR; // Output Write Disable Register - AT91_REG PIOA_OWSR; // Output Write Status Register - AT91_REG Reserved12[85]; // - AT91_REG PIOB_PER; // PIO Enable Register - AT91_REG PIOB_PDR; // PIO Disable Register - AT91_REG PIOB_PSR; // PIO Status Register - AT91_REG Reserved13[1]; // - AT91_REG PIOB_OER; // Output Enable Register - AT91_REG PIOB_ODR; // Output Disable Registerr - AT91_REG PIOB_OSR; // Output Status Register - AT91_REG Reserved14[1]; // - AT91_REG PIOB_IFER; // Input Filter Enable Register - AT91_REG PIOB_IFDR; // Input Filter Disable Register - AT91_REG PIOB_IFSR; // Input Filter Status Register - AT91_REG Reserved15[1]; // - AT91_REG PIOB_SODR; // Set Output Data Register - AT91_REG PIOB_CODR; // Clear Output Data Register - AT91_REG PIOB_ODSR; // Output Data Status Register - AT91_REG PIOB_PDSR; // Pin Data Status Register - AT91_REG PIOB_IER; // Interrupt Enable Register - AT91_REG PIOB_IDR; // Interrupt Disable Register - AT91_REG PIOB_IMR; // Interrupt Mask Register - AT91_REG PIOB_ISR; // Interrupt Status Register - AT91_REG PIOB_MDER; // Multi-driver Enable Register - AT91_REG PIOB_MDDR; // Multi-driver Disable Register - AT91_REG PIOB_MDSR; // Multi-driver Status Register - AT91_REG Reserved16[1]; // - AT91_REG PIOB_PPUDR; // Pull-up Disable Register - AT91_REG PIOB_PPUER; // Pull-up Enable Register - AT91_REG PIOB_PPUSR; // Pad Pull-up Status Register - AT91_REG Reserved17[1]; // - AT91_REG PIOB_ASR; // Select A Register - AT91_REG PIOB_BSR; // Select B Register - AT91_REG PIOB_ABSR; // AB Select Status Register - AT91_REG Reserved18[9]; // - AT91_REG PIOB_OWER; // Output Write Enable Register - AT91_REG PIOB_OWDR; // Output Write Disable Register - AT91_REG PIOB_OWSR; // Output Write Status Register - AT91_REG Reserved19[85]; // - AT91_REG PIOC_PER; // PIO Enable Register - AT91_REG PIOC_PDR; // PIO Disable Register - AT91_REG PIOC_PSR; // PIO Status Register - AT91_REG Reserved20[1]; // - AT91_REG PIOC_OER; // Output Enable Register - AT91_REG PIOC_ODR; // Output Disable Registerr - AT91_REG PIOC_OSR; // Output Status Register - AT91_REG Reserved21[1]; // - AT91_REG PIOC_IFER; // Input Filter Enable Register - AT91_REG PIOC_IFDR; // Input Filter Disable Register - AT91_REG PIOC_IFSR; // Input Filter Status Register - AT91_REG Reserved22[1]; // - AT91_REG PIOC_SODR; // Set Output Data Register - AT91_REG PIOC_CODR; // Clear Output Data Register - AT91_REG PIOC_ODSR; // Output Data Status Register - AT91_REG PIOC_PDSR; // Pin Data Status Register - AT91_REG PIOC_IER; // Interrupt Enable Register - AT91_REG PIOC_IDR; // Interrupt Disable Register - AT91_REG PIOC_IMR; // Interrupt Mask Register - AT91_REG PIOC_ISR; // Interrupt Status Register - AT91_REG PIOC_MDER; // Multi-driver Enable Register - AT91_REG PIOC_MDDR; // Multi-driver Disable Register - AT91_REG PIOC_MDSR; // Multi-driver Status Register - AT91_REG Reserved23[1]; // - AT91_REG PIOC_PPUDR; // Pull-up Disable Register - AT91_REG PIOC_PPUER; // Pull-up Enable Register - AT91_REG PIOC_PPUSR; // Pad Pull-up Status Register - AT91_REG Reserved24[1]; // - AT91_REG PIOC_ASR; // Select A Register - AT91_REG PIOC_BSR; // Select B Register - AT91_REG PIOC_ABSR; // AB Select Status Register - AT91_REG Reserved25[9]; // - AT91_REG PIOC_OWER; // Output Write Enable Register - AT91_REG PIOC_OWDR; // Output Write Disable Register - AT91_REG PIOC_OWSR; // Output Write Status Register - AT91_REG Reserved26[85]; // - AT91_REG PIOD_PER; // PIO Enable Register - AT91_REG PIOD_PDR; // PIO Disable Register - AT91_REG PIOD_PSR; // PIO Status Register - AT91_REG Reserved27[1]; // - AT91_REG PIOD_OER; // Output Enable Register - AT91_REG PIOD_ODR; // Output Disable Registerr - AT91_REG PIOD_OSR; // Output Status Register - AT91_REG Reserved28[1]; // - AT91_REG PIOD_IFER; // Input Filter Enable Register - AT91_REG PIOD_IFDR; // Input Filter Disable Register - AT91_REG PIOD_IFSR; // Input Filter Status Register - AT91_REG Reserved29[1]; // - AT91_REG PIOD_SODR; // Set Output Data Register - AT91_REG PIOD_CODR; // Clear Output Data Register - AT91_REG PIOD_ODSR; // Output Data Status Register - AT91_REG PIOD_PDSR; // Pin Data Status Register - AT91_REG PIOD_IER; // Interrupt Enable Register - AT91_REG PIOD_IDR; // Interrupt Disable Register - AT91_REG PIOD_IMR; // Interrupt Mask Register - AT91_REG PIOD_ISR; // Interrupt Status Register - AT91_REG PIOD_MDER; // Multi-driver Enable Register - AT91_REG PIOD_MDDR; // Multi-driver Disable Register - AT91_REG PIOD_MDSR; // Multi-driver Status Register - AT91_REG Reserved30[1]; // - AT91_REG PIOD_PPUDR; // Pull-up Disable Register - AT91_REG PIOD_PPUER; // Pull-up Enable Register - AT91_REG PIOD_PPUSR; // Pad Pull-up Status Register - AT91_REG Reserved31[1]; // - AT91_REG PIOD_ASR; // Select A Register - AT91_REG PIOD_BSR; // Select B Register - AT91_REG PIOD_ABSR; // AB Select Status Register - AT91_REG Reserved32[9]; // - AT91_REG PIOD_OWER; // Output Write Enable Register - AT91_REG PIOD_OWDR; // Output Write Disable Register - AT91_REG PIOD_OWSR; // Output Write Status Register - AT91_REG Reserved33[85]; // - AT91_REG PMC_SCER; // System Clock Enable Register - AT91_REG PMC_SCDR; // System Clock Disable Register - AT91_REG PMC_SCSR; // System Clock Status Register - AT91_REG Reserved34[1]; // - AT91_REG PMC_PCER; // Peripheral Clock Enable Register - AT91_REG PMC_PCDR; // Peripheral Clock Disable Register - AT91_REG PMC_PCSR; // Peripheral Clock Status Register - AT91_REG Reserved35[1]; // - AT91_REG CKGR_MOR; // Main Oscillator Register - AT91_REG CKGR_MCFR; // Main Clock Frequency Register - AT91_REG CKGR_PLLAR; // PLL A Register - AT91_REG CKGR_PLLBR; // PLL B Register - AT91_REG PMC_MCKR; // Master Clock Register - AT91_REG Reserved36[3]; // - AT91_REG PMC_PCKR[8]; // Programmable Clock Register - AT91_REG PMC_IER; // Interrupt Enable Register - AT91_REG PMC_IDR; // Interrupt Disable Register - AT91_REG PMC_SR; // Status Register - AT91_REG PMC_IMR; // Interrupt Mask Register - AT91_REG Reserved37[36]; // - AT91_REG ST_CR; // Control Register - AT91_REG ST_PIMR; // Period Interval Mode Register - AT91_REG ST_WDMR; // Watchdog Mode Register - AT91_REG ST_RTMR; // Real-time Mode Register - AT91_REG ST_SR; // Status Register - AT91_REG ST_IER; // Interrupt Enable Register - AT91_REG ST_IDR; // Interrupt Disable Register - AT91_REG ST_IMR; // Interrupt Mask Register - AT91_REG ST_RTAR; // Real-time Alarm Register - AT91_REG ST_CRTR; // Current Real-time Register - AT91_REG Reserved38[54]; // - AT91_REG RTC_CR; // Control Register - AT91_REG RTC_MR; // Mode Register - AT91_REG RTC_TIMR; // Time Register - AT91_REG RTC_CALR; // Calendar Register - AT91_REG RTC_TIMALR; // Time Alarm Register - AT91_REG RTC_CALALR; // Calendar Alarm Register - AT91_REG RTC_SR; // Status Register - AT91_REG RTC_SCCR; // Status Clear Command Register - AT91_REG RTC_IER; // Interrupt Enable Register - AT91_REG RTC_IDR; // Interrupt Disable Register - AT91_REG RTC_IMR; // Interrupt Mask Register - AT91_REG RTC_VER; // Valid Entry Register - AT91_REG Reserved39[52]; // - AT91_REG MC_RCR; // MC Remap Control Register - AT91_REG MC_ASR; // MC Abort Status Register - AT91_REG MC_AASR; // MC Abort Address Status Register - AT91_REG Reserved40[1]; // - AT91_REG MC_PUIA[16]; // MC Protection Unit Area - AT91_REG MC_PUP; // MC Protection Unit Peripherals - AT91_REG MC_PUER; // MC Protection Unit Enable Register - AT91_REG Reserved41[2]; // - AT91_REG EBI_CSA; // Chip Select Assignment Register - AT91_REG EBI_CFGR; // Configuration Register - AT91_REG Reserved42[2]; // - AT91_REG EBI_SMC2_CSR[8]; // SMC2 Chip Select Register - AT91_REG EBI_SDRC_MR; // SDRAM Controller Mode Register - AT91_REG EBI_SDRC_TR; // SDRAM Controller Refresh Timer Register - AT91_REG EBI_SDRC_CR; // SDRAM Controller Configuration Register - AT91_REG EBI_SDRC_SRR; // SDRAM Controller Self Refresh Register - AT91_REG EBI_SDRC_LPR; // SDRAM Controller Low Power Register - AT91_REG EBI_SDRC_IER; // SDRAM Controller Interrupt Enable Register - AT91_REG EBI_SDRC_IDR; // SDRAM Controller Interrupt Disable Register - AT91_REG EBI_SDRC_IMR; // SDRAM Controller Interrupt Mask Register - AT91_REG EBI_SDRC_ISR; // SDRAM Controller Interrupt Mask Register - AT91_REG Reserved43[3]; // - AT91_REG EBI_BFC_MR; // BFC Mode Register -} AT91S_SYS, *AT91PS_SYS; - - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Memory Controller Interface -// ***************************************************************************** -typedef struct _AT91S_MC { - AT91_REG MC_RCR; // MC Remap Control Register - AT91_REG MC_ASR; // MC Abort Status Register - AT91_REG MC_AASR; // MC Abort Address Status Register - AT91_REG Reserved0[1]; // - AT91_REG MC_PUIA[16]; // MC Protection Unit Area - AT91_REG MC_PUP; // MC Protection Unit Peripherals - AT91_REG MC_PUER; // MC Protection Unit Enable Register -} AT91S_MC, *AT91PS_MC; - -// -------- MC_RCR : (MC Offset: 0x0) MC Remap Control Register -------- -#define AT91C_MC_RCB (0x1u << 0) // (MC) Remap Command Bit -// -------- MC_ASR : (MC Offset: 0x4) MC Abort Status Register -------- -#define AT91C_MC_UNDADD (0x1u << 0) // (MC) Undefined Addess Abort Status -#define AT91C_MC_MISADD (0x1u << 1) // (MC) Misaligned Addess Abort Status -#define AT91C_MC_MPU (0x1u << 2) // (MC) Memory protection Unit Abort Status -#define AT91C_MC_ABTSZ (0x3u << 8) // (MC) Abort Size Status -#define AT91C_MC_ABTSZ_BYTE (0x0u << 8) // (MC) Byte -#define AT91C_MC_ABTSZ_HWORD (0x1u << 8) // (MC) Half-word -#define AT91C_MC_ABTSZ_WORD (0x2u << 8) // (MC) Word -#define AT91C_MC_ABTTYP (0x3u << 10) // (MC) Abort Type Status -#define AT91C_MC_ABTTYP_DATAR (0x0u << 10) // (MC) Data Read -#define AT91C_MC_ABTTYP_DATAW (0x1u << 10) // (MC) Data Write -#define AT91C_MC_ABTTYP_FETCH (0x2u << 10) // (MC) Code Fetch -#define AT91C_MC_MST0 (0x1u << 16) // (MC) Master 0 Abort Source -#define AT91C_MC_MST1 (0x1u << 17) // (MC) Master 1 Abort Source -#define AT91C_MC_SVMST0 (0x1u << 24) // (MC) Saved Master 0 Abort Source -#define AT91C_MC_SVMST1 (0x1u << 25) // (MC) Saved Master 1 Abort Source -// -------- MC_PUIA : (MC Offset: 0x10) MC Protection Unit Area -------- -#define AT91C_MC_PROT (0x3u << 0) // (MC) Protection -#define AT91C_MC_PROT_PNAUNA 0x0u // (MC) Privilege: No Access, User: No Access -#define AT91C_MC_PROT_PRWUNA 0x1u // (MC) Privilege: Read/Write, User: No Access -#define AT91C_MC_PROT_PRWURO 0x2u // (MC) Privilege: Read/Write, User: Read Only -#define AT91C_MC_PROT_PRWURW 0x3u // (MC) Privilege: Read/Write, User: Read/Write -#define AT91C_MC_SIZE (0xFu << 4) // (MC) Internal Area Size -#define AT91C_MC_SIZE_1KB (0x0u << 4) // (MC) Area size 1KByte -#define AT91C_MC_SIZE_2KB (0x1u << 4) // (MC) Area size 2KByte -#define AT91C_MC_SIZE_4KB (0x2u << 4) // (MC) Area size 4KByte -#define AT91C_MC_SIZE_8KB (0x3u << 4) // (MC) Area size 8KByte -#define AT91C_MC_SIZE_16KB (0x4u << 4) // (MC) Area size 16KByte -#define AT91C_MC_SIZE_32KB (0x5u << 4) // (MC) Area size 32KByte -#define AT91C_MC_SIZE_64KB (0x6u << 4) // (MC) Area size 64KByte -#define AT91C_MC_SIZE_128KB (0x7u << 4) // (MC) Area size 128KByte -#define AT91C_MC_SIZE_256KB (0x8u << 4) // (MC) Area size 256KByte -#define AT91C_MC_SIZE_512KB (0x9u << 4) // (MC) Area size 512KByte -#define AT91C_MC_SIZE_1MB (0xAu << 4) // (MC) Area size 1MByte -#define AT91C_MC_SIZE_2MB (0xBu << 4) // (MC) Area size 2MByte -#define AT91C_MC_SIZE_4MB (0xCu << 4) // (MC) Area size 4MByte -#define AT91C_MC_SIZE_8MB (0xDu << 4) // (MC) Area size 8MByte -#define AT91C_MC_SIZE_16MB (0xEu << 4) // (MC) Area size 16MByte -#define AT91C_MC_SIZE_64MB (0xFu << 4) // (MC) Area size 64MByte -#define AT91C_MC_BA (0x3FFFFu << 10) // (MC) Internal Area Base Address -// -------- MC_PUP : (MC Offset: 0x50) MC Protection Unit Peripheral -------- -// -------- MC_PUER : (MC Offset: 0x54) MC Protection Unit Area -------- -#define AT91C_MC_PUEB (0x1u << 0) // (MC) Protection Unit enable Bit - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Real-time Clock Alarm and Parallel Load Interface -// ***************************************************************************** -typedef struct _AT91S_RTC { - AT91_REG RTC_CR; // Control Register - AT91_REG RTC_MR; // Mode Register - AT91_REG RTC_TIMR; // Time Register - AT91_REG RTC_CALR; // Calendar Register - AT91_REG RTC_TIMALR; // Time Alarm Register - AT91_REG RTC_CALALR; // Calendar Alarm Register - AT91_REG RTC_SR; // Status Register - AT91_REG RTC_SCCR; // Status Clear Command Register - AT91_REG RTC_IER; // Interrupt Enable Register - AT91_REG RTC_IDR; // Interrupt Disable Register - AT91_REG RTC_IMR; // Interrupt Mask Register - AT91_REG RTC_VER; // Valid Entry Register -} AT91S_RTC, *AT91PS_RTC; - -// -------- RTC_CR : (RTC Offset: 0x0) RTC Control Register -------- -#define AT91C_RTC_UPDTIM (0x1u << 0) // (RTC) Update Request Time Register -#define AT91C_RTC_UPDCAL (0x1u << 1) // (RTC) Update Request Calendar Register -#define AT91C_RTC_TIMEVSEL (0x3u << 8) // (RTC) Time Event Selection -#define AT91C_RTC_TIMEVSEL_MINUTE (0x0u << 8) // (RTC) Minute change. -#define AT91C_RTC_TIMEVSEL_HOUR (0x1u << 8) // (RTC) Hour change. -#define AT91C_RTC_TIMEVSEL_DAY24 (0x2u << 8) // (RTC) Every day at midnight. -#define AT91C_RTC_TIMEVSEL_DAY12 (0x3u << 8) // (RTC) Every day at noon. -#define AT91C_RTC_CALEVSEL (0x3u << 16) // (RTC) Calendar Event Selection -#define AT91C_RTC_CALEVSEL_WEEK (0x0u << 16) // (RTC) Week change (every Monday at time 00:00:00). -#define AT91C_RTC_CALEVSEL_MONTH (0x1u << 16) // (RTC) Month change (every 01 of each month at time 00:00:00). -#define AT91C_RTC_CALEVSEL_YEAR (0x2u << 16) // (RTC) Year change (every January 1 at time 00:00:00). -// -------- RTC_MR : (RTC Offset: 0x4) RTC Mode Register -------- -#define AT91C_RTC_HRMOD (0x1u << 0) // (RTC) 12-24 hour Mode -// -------- RTC_TIMR : (RTC Offset: 0x8) RTC Time Register -------- -#define AT91C_RTC_SEC (0x7Fu << 0) // (RTC) Current Second -#define AT91C_RTC_MIN (0x7Fu << 8) // (RTC) Current Minute -#define AT91C_RTC_HOUR (0x1Fu << 16) // (RTC) Current Hour -#define AT91C_RTC_AMPM (0x1u << 22) // (RTC) Ante Meridiem, Post Meridiem Indicator -// -------- RTC_CALR : (RTC Offset: 0xc) RTC Calendar Register -------- -#define AT91C_RTC_CENT (0x3Fu << 0) // (RTC) Current Century -#define AT91C_RTC_YEAR (0xFFu << 8) // (RTC) Current Year -#define AT91C_RTC_MONTH (0x1Fu << 16) // (RTC) Current Month -#define AT91C_RTC_DAY (0x7u << 21) // (RTC) Current Day -#define AT91C_RTC_DATE (0x3Fu << 24) // (RTC) Current Date -// -------- RTC_TIMALR : (RTC Offset: 0x10) RTC Time Alarm Register -------- -#define AT91C_RTC_SECEN (0x1u << 7) // (RTC) Second Alarm Enable -#define AT91C_RTC_MINEN (0x1u << 15) // (RTC) Minute Alarm -#define AT91C_RTC_HOUREN (0x1u << 23) // (RTC) Current Hour -// -------- RTC_CALALR : (RTC Offset: 0x14) RTC Calendar Alarm Register -------- -#define AT91C_RTC_MONTHEN (0x1u << 23) // (RTC) Month Alarm Enable -#define AT91C_RTC_DATEEN (0x1u << 31) // (RTC) Date Alarm Enable -// -------- RTC_SR : (RTC Offset: 0x18) RTC Status Register -------- -#define AT91C_RTC_ACKUPD (0x1u << 0) // (RTC) Acknowledge for Update -#define AT91C_RTC_ALARM (0x1u << 1) // (RTC) Alarm Flag -#define AT91C_RTC_SECEV (0x1u << 2) // (RTC) Second Event -#define AT91C_RTC_TIMEV (0x1u << 3) // (RTC) Time Event -#define AT91C_RTC_CALEV (0x1u << 4) // (RTC) Calendar event -// -------- RTC_SCCR : (RTC Offset: 0x1c) RTC Status Clear Command Register -------- -// -------- RTC_IER : (RTC Offset: 0x20) RTC Interrupt Enable Register -------- -// -------- RTC_IDR : (RTC Offset: 0x24) RTC Interrupt Disable Register -------- -// -------- RTC_IMR : (RTC Offset: 0x28) RTC Interrupt Mask Register -------- -// -------- RTC_VER : (RTC Offset: 0x2c) RTC Valid Entry Register -------- -#define AT91C_RTC_NVTIM (0x1u << 0) // (RTC) Non valid Time -#define AT91C_RTC_NVCAL (0x1u << 1) // (RTC) Non valid Calendar -#define AT91C_RTC_NVTIMALR (0x1u << 2) // (RTC) Non valid time Alarm -#define AT91C_RTC_NVCALALR (0x1u << 3) // (RTC) Nonvalid Calendar Alarm - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR System Timer Interface -// ***************************************************************************** -typedef struct _AT91S_ST { - AT91_REG ST_CR; // Control Register - AT91_REG ST_PIMR; // Period Interval Mode Register - AT91_REG ST_WDMR; // Watchdog Mode Register - AT91_REG ST_RTMR; // Real-time Mode Register - AT91_REG ST_SR; // Status Register - AT91_REG ST_IER; // Interrupt Enable Register - AT91_REG ST_IDR; // Interrupt Disable Register - AT91_REG ST_IMR; // Interrupt Mask Register - AT91_REG ST_RTAR; // Real-time Alarm Register - AT91_REG ST_CRTR; // Current Real-time Register -} AT91S_ST, *AT91PS_ST; - -// -------- ST_CR : (ST Offset: 0x0) System Timer Control Register -------- -#define AT91C_ST_WDRST (0x1u << 0) // (ST) Watchdog Timer Restart -// -------- ST_PIMR : (ST Offset: 0x4) System Timer Period Interval Mode Register -------- -#define AT91C_ST_PIV (0xFFFFu << 0) // (ST) Watchdog Timer Restart -// -------- ST_WDMR : (ST Offset: 0x8) System Timer Watchdog Mode Register -------- -#define AT91C_ST_WDV (0xFFFFu << 0) // (ST) Watchdog Timer Restart -#define AT91C_ST_RSTEN (0x1u << 16) // (ST) Reset Enable -#define AT91C_ST_EXTEN (0x1u << 17) // (ST) External Signal Assertion Enable -// -------- ST_RTMR : (ST Offset: 0xc) System Timer Real-time Mode Register -------- -#define AT91C_ST_RTPRES (0xFFFFu << 0) // (ST) Real-time Timer Prescaler Value -// -------- ST_SR : (ST Offset: 0x10) System Timer Status Register -------- -#define AT91C_ST_PITS (0x1u << 0) // (ST) Period Interval Timer Interrupt -#define AT91C_ST_WDOVF (0x1u << 1) // (ST) Watchdog Overflow -#define AT91C_ST_RTTINC (0x1u << 2) // (ST) Real-time Timer Increment -#define AT91C_ST_ALMS (0x1u << 3) // (ST) Alarm Status -// -------- ST_IER : (ST Offset: 0x14) System Timer Interrupt Enable Register -------- -// -------- ST_IDR : (ST Offset: 0x18) System Timer Interrupt Disable Register -------- -// -------- ST_IMR : (ST Offset: 0x1c) System Timer Interrupt Mask Register -------- -// -------- ST_RTAR : (ST Offset: 0x20) System Timer Real-time Alarm Register -------- -#define AT91C_ST_ALMV (0xFFFFFu << 0) // (ST) Alarm Value Value -// -------- ST_CRTR : (ST Offset: 0x24) System Timer Current Real-time Register -------- -#define AT91C_ST_CRTV (0xFFFFFu << 0) // (ST) Current Real-time Value - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Power Management Controller -// ***************************************************************************** -typedef struct _AT91S_PMC { - AT91_REG PMC_SCER; // System Clock Enable Register - AT91_REG PMC_SCDR; // System Clock Disable Register - AT91_REG PMC_SCSR; // System Clock Status Register - AT91_REG Reserved0[1]; // - AT91_REG PMC_PCER; // Peripheral Clock Enable Register - AT91_REG PMC_PCDR; // Peripheral Clock Disable Register - AT91_REG PMC_PCSR; // Peripheral Clock Status Register - AT91_REG Reserved1[5]; // - AT91_REG PMC_MCKR; // Master Clock Register - AT91_REG Reserved2[3]; // - AT91_REG PMC_PCKR[8]; // Programmable Clock Register - AT91_REG PMC_IER; // Interrupt Enable Register - AT91_REG PMC_IDR; // Interrupt Disable Register - AT91_REG PMC_SR; // Status Register - AT91_REG PMC_IMR; // Interrupt Mask Register -} AT91S_PMC, *AT91PS_PMC; - -// -------- PMC_SCER : (PMC Offset: 0x0) System Clock Enable Register -------- -#define AT91C_PMC_PCK (0x1u << 0) // (PMC) Processor Clock -#define AT91C_PMC_UDP (0x1u << 1) // (PMC) USB Device Port Clock -#define AT91C_PMC_MCKUDP (0x1u << 2) // (PMC) USB Device Port Master Clock Automatic Disable on Suspend -#define AT91C_PMC_UHP (0x1u << 4) // (PMC) USB Host Port Clock -#define AT91C_PMC_PCK0 (0x1u << 8) // (PMC) Programmable Clock Output -#define AT91C_PMC_PCK1 (0x1u << 9) // (PMC) Programmable Clock Output -#define AT91C_PMC_PCK2 (0x1u << 10) // (PMC) Programmable Clock Output -#define AT91C_PMC_PCK3 (0x1u << 11) // (PMC) Programmable Clock Output -#define AT91C_PMC_PCK4 (0x1u << 12) // (PMC) Programmable Clock Output -#define AT91C_PMC_PCK5 (0x1u << 13) // (PMC) Programmable Clock Output -#define AT91C_PMC_PCK6 (0x1u << 14) // (PMC) Programmable Clock Output -#define AT91C_PMC_PCK7 (0x1u << 15) // (PMC) Programmable Clock Output -// -------- PMC_SCDR : (PMC Offset: 0x4) System Clock Disable Register -------- -// -------- PMC_SCSR : (PMC Offset: 0x8) System Clock Status Register -------- -// -------- PMC_MCKR : (PMC Offset: 0x30) Master Clock Register -------- -#define AT91C_PMC_CSS (0x3u << 0) // (PMC) Programmable Clock Selection -#define AT91C_PMC_CSS_SLOW_CLK 0x0u // (PMC) Slow Clock is selected -#define AT91C_PMC_CSS_MAIN_CLK 0x1u // (PMC) Main Clock is selected -#define AT91C_PMC_CSS_PLLA_CLK 0x2u // (PMC) Clock from PLL A is selected -#define AT91C_PMC_CSS_PLLB_CLK 0x3u // (PMC) Clock from PLL B is selected -#define AT91C_PMC_PRES (0x7u << 2) // (PMC) Programmable Clock Prescaler -#define AT91C_PMC_PRES_CLK (0x0u << 2) // (PMC) Selected clock -#define AT91C_PMC_PRES_CLK_2 (0x1u << 2) // (PMC) Selected clock divided by 2 -#define AT91C_PMC_PRES_CLK_4 (0x2u << 2) // (PMC) Selected clock divided by 4 -#define AT91C_PMC_PRES_CLK_8 (0x3u << 2) // (PMC) Selected clock divided by 8 -#define AT91C_PMC_PRES_CLK_16 (0x4u << 2) // (PMC) Selected clock divided by 16 -#define AT91C_PMC_PRES_CLK_32 (0x5u << 2) // (PMC) Selected clock divided by 32 -#define AT91C_PMC_PRES_CLK_64 (0x6u << 2) // (PMC) Selected clock divided by 64 -#define AT91C_PMC_MDIV (0x3u << 8) // (PMC) Master Clock Division -#define AT91C_PMC_MDIV_1 (0x0u << 8) // (PMC) The master clock and the processor clock are the same -#define AT91C_PMC_MDIV_2 (0x1u << 8) // (PMC) The processor clock is twice as fast as the master clock -#define AT91C_PMC_MDIV_3 (0x2u << 8) // (PMC) The processor clock is three times faster than the master clock -#define AT91C_PMC_MDIV_4 (0x3u << 8) // (PMC) The processor clock is four times faster than the master clock -// -------- PMC_PCKR : (PMC Offset: 0x40) Programmable Clock Register -------- -// -------- PMC_IER : (PMC Offset: 0x60) PMC Interrupt Enable Register -------- -#define AT91C_PMC_MOSCS (0x1u << 0) // (PMC) MOSC Status/Enable/Disable/Mask -#define AT91C_PMC_LOCKA (0x1u << 1) // (PMC) PLL A Status/Enable/Disable/Mask -#define AT91C_PMC_LOCKB (0x1u << 2) // (PMC) PLL B Status/Enable/Disable/Mask -#define AT91C_PMC_MCKRDY (0x1u << 3) // (PMC) MCK_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK0RDY (0x1u << 8) // (PMC) PCK0_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK1RDY (0x1u << 9) // (PMC) PCK1_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK2RDY (0x1u << 10) // (PMC) PCK2_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK3RDY (0x1u << 11) // (PMC) PCK3_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK4RDY (0x1u << 12) // (PMC) PCK4_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK5RDY (0x1u << 13) // (PMC) PCK5_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK6RDY (0x1u << 14) // (PMC) PCK6_RDY Status/Enable/Disable/Mask -#define AT91C_PMC_PCK7RDY (0x1u << 15) // (PMC) PCK7_RDY Status/Enable/Disable/Mask -// -------- PMC_IDR : (PMC Offset: 0x64) PMC Interrupt Disable Register -------- -// -------- PMC_SR : (PMC Offset: 0x68) PMC Status Register -------- -// -------- PMC_IMR : (PMC Offset: 0x6c) PMC Interrupt Mask Register -------- - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Clock Generator Controller -// ***************************************************************************** -typedef struct _AT91S_CKGR { - AT91_REG CKGR_MOR; // Main Oscillator Register - AT91_REG CKGR_MCFR; // Main Clock Frequency Register - AT91_REG CKGR_PLLAR; // PLL A Register - AT91_REG CKGR_PLLBR; // PLL B Register -} AT91S_CKGR, *AT91PS_CKGR; - -// -------- CKGR_MOR : (CKGR Offset: 0x0) Main Oscillator Register -------- -#define AT91C_CKGR_MOSCEN (0x1u << 0) // (CKGR) Main Oscillator Enable -#define AT91C_CKGR_OSCTEST (0x1u << 1) // (CKGR) Oscillator Test -#define AT91C_CKGR_OSCOUNT (0xFFu << 8) // (CKGR) Main Oscillator Start-up Time -// -------- CKGR_MCFR : (CKGR Offset: 0x4) Main Clock Frequency Register -------- -#define AT91C_CKGR_MAINF (0xFFFFu << 0) // (CKGR) Main Clock Frequency -#define AT91C_CKGR_MAINRDY (0x1u << 16) // (CKGR) Main Clock Ready -// -------- CKGR_PLLAR : (CKGR Offset: 0x8) PLL A Register -------- -#define AT91C_CKGR_DIVA (0xFFu << 0) // (CKGR) Divider Selected -#define AT91C_CKGR_DIVA_0 0x0u // (CKGR) Divider output is 0 -#define AT91C_CKGR_DIVA_BYPASS 0x1u // (CKGR) Divider is bypassed -#define AT91C_CKGR_PLLACOUNT (0x3Fu << 8) // (CKGR) PLL A Counter -#define AT91C_CKGR_OUTA (0x3u << 14) // (CKGR) PLL A Output Frequency Range -#define AT91C_CKGR_OUTA_0 (0x0u << 14) // (CKGR) Please refer to the PLLA datasheet -#define AT91C_CKGR_OUTA_1 (0x1u << 14) // (CKGR) Please refer to the PLLA datasheet -#define AT91C_CKGR_OUTA_2 (0x2u << 14) // (CKGR) Please refer to the PLLA datasheet -#define AT91C_CKGR_OUTA_3 (0x3u << 14) // (CKGR) Please refer to the PLLA datasheet -#define AT91C_CKGR_MULA (0x7FFu << 16) // (CKGR) PLL A Multiplier -#define AT91C_CKGR_SRCA (0x1u << 29) // (CKGR) PLL A Source -// -------- CKGR_PLLBR : (CKGR Offset: 0xc) PLL B Register -------- -#define AT91C_CKGR_DIVB (0xFFu << 0) // (CKGR) Divider Selected -#define AT91C_CKGR_DIVB_0 0x0u // (CKGR) Divider output is 0 -#define AT91C_CKGR_DIVB_BYPASS 0x1u // (CKGR) Divider is bypassed -#define AT91C_CKGR_PLLBCOUNT (0x3Fu << 8) // (CKGR) PLL B Counter -#define AT91C_CKGR_OUTB (0x3u << 14) // (CKGR) PLL B Output Frequency Range -#define AT91C_CKGR_OUTB_0 (0x0u << 14) // (CKGR) Please refer to the PLLB datasheet -#define AT91C_CKGR_OUTB_1 (0x1u << 14) // (CKGR) Please refer to the PLLB datasheet -#define AT91C_CKGR_OUTB_2 (0x2u << 14) // (CKGR) Please refer to the PLLB datasheet -#define AT91C_CKGR_OUTB_3 (0x3u << 14) // (CKGR) Please refer to the PLLB datasheet -#define AT91C_CKGR_MULB (0x7FFu << 16) // (CKGR) PLL B Multiplier -#define AT91C_CKGR_USB_96M (0x1u << 28) // (CKGR) Divider for USB Ports -#define AT91C_CKGR_USB_PLL (0x1u << 29) // (CKGR) PLL Use - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Parallel Input Output Controller -// ***************************************************************************** -typedef struct _AT91S_PIO { - AT91_REG PIO_PER; // PIO Enable Register - AT91_REG PIO_PDR; // PIO Disable Register - AT91_REG PIO_PSR; // PIO Status Register - AT91_REG Reserved0[1]; // - AT91_REG PIO_OER; // Output Enable Register - AT91_REG PIO_ODR; // Output Disable Registerr - AT91_REG PIO_OSR; // Output Status Register - AT91_REG Reserved1[1]; // - AT91_REG PIO_IFER; // Input Filter Enable Register - AT91_REG PIO_IFDR; // Input Filter Disable Register - AT91_REG PIO_IFSR; // Input Filter Status Register - AT91_REG Reserved2[1]; // - AT91_REG PIO_SODR; // Set Output Data Register - AT91_REG PIO_CODR; // Clear Output Data Register - AT91_REG PIO_ODSR; // Output Data Status Register - AT91_REG PIO_PDSR; // Pin Data Status Register - AT91_REG PIO_IER; // Interrupt Enable Register - AT91_REG PIO_IDR; // Interrupt Disable Register - AT91_REG PIO_IMR; // Interrupt Mask Register - AT91_REG PIO_ISR; // Interrupt Status Register - AT91_REG PIO_MDER; // Multi-driver Enable Register - AT91_REG PIO_MDDR; // Multi-driver Disable Register - AT91_REG PIO_MDSR; // Multi-driver Status Register - AT91_REG Reserved3[1]; // - AT91_REG PIO_PPUDR; // Pull-up Disable Register - AT91_REG PIO_PPUER; // Pull-up Enable Register - AT91_REG PIO_PPUSR; // Pad Pull-up Status Register - AT91_REG Reserved4[1]; // - AT91_REG PIO_ASR; // Select A Register - AT91_REG PIO_BSR; // Select B Register - AT91_REG PIO_ABSR; // AB Select Status Register - AT91_REG Reserved5[9]; // - AT91_REG PIO_OWER; // Output Write Enable Register - AT91_REG PIO_OWDR; // Output Write Disable Register - AT91_REG PIO_OWSR; // Output Write Status Register -} AT91S_PIO, *AT91PS_PIO; - - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Debug Unit -// ***************************************************************************** -typedef struct _AT91S_DBGU { - AT91_REG DBGU_CR; // Control Register - AT91_REG DBGU_MR; // Mode Register - AT91_REG DBGU_IER; // Interrupt Enable Register - AT91_REG DBGU_IDR; // Interrupt Disable Register - AT91_REG DBGU_IMR; // Interrupt Mask Register - AT91_REG DBGU_CSR; // Channel Status Register - AT91_REG DBGU_RHR; // Receiver Holding Register - AT91_REG DBGU_THR; // Transmitter Holding Register - AT91_REG DBGU_BRGR; // Baud Rate Generator Register - AT91_REG Reserved0[7]; // - AT91_REG DBGU_C1R; // Chip ID1 Register - AT91_REG DBGU_C2R; // Chip ID2 Register - AT91_REG DBGU_FNTR; // Force NTRST Register - AT91_REG Reserved1[45]; // - AT91_REG DBGU_RPR; // Receive Pointer Register - AT91_REG DBGU_RCR; // Receive Counter Register - AT91_REG DBGU_TPR; // Transmit Pointer Register - AT91_REG DBGU_TCR; // Transmit Counter Register - AT91_REG DBGU_RNPR; // Receive Next Pointer Register - AT91_REG DBGU_RNCR; // Receive Next Counter Register - AT91_REG DBGU_TNPR; // Transmit Next Pointer Register - AT91_REG DBGU_TNCR; // Transmit Next Counter Register - AT91_REG DBGU_PTCR; // PDC Transfer Control Register - AT91_REG DBGU_PTSR; // PDC Transfer Status Register -} AT91S_DBGU, *AT91PS_DBGU; - -// -------- DBGU_CR : (DBGU Offset: 0x0) Debug Unit Control Register -------- -#define AT91C_US_RSTRX (0x1u << 2) // (DBGU) Reset Receiver -#define AT91C_US_RSTTX (0x1u << 3) // (DBGU) Reset Transmitter -#define AT91C_US_RXEN (0x1u << 4) // (DBGU) Receiver Enable -#define AT91C_US_RXDIS (0x1u << 5) // (DBGU) Receiver Disable -#define AT91C_US_TXEN (0x1u << 6) // (DBGU) Transmitter Enable -#define AT91C_US_TXDIS (0x1u << 7) // (DBGU) Transmitter Disable -// -------- DBGU_MR : (DBGU Offset: 0x4) Debug Unit Mode Register -------- -#define AT91C_US_PAR (0x7u << 9) // (DBGU) Parity type -#define AT91C_US_PAR_EVEN (0x0u << 9) // (DBGU) Even Parity -#define AT91C_US_PAR_ODD (0x1u << 9) // (DBGU) Odd Parity -#define AT91C_US_PAR_SPACE (0x2u << 9) // (DBGU) Parity forced to 0 (Space) -#define AT91C_US_PAR_MARK (0x3u << 9) // (DBGU) Parity forced to 1 (Mark) -#define AT91C_US_PAR_NONE (0x4u << 9) // (DBGU) No Parity -#define AT91C_US_PAR_MULTI_DROP (0x6u << 9) // (DBGU) Multi-drop mode -#define AT91C_US_CHMODE (0x3u << 14) // (DBGU) Channel Mode -#define AT91C_US_CHMODE_NORMAL (0x0u << 14) // (DBGU) Normal Mode: The USART channel operates as an RX/TX USART. -#define AT91C_US_CHMODE_AUTO (0x1u << 14) // (DBGU) Automatic Echo: Receiver Data Input is connected to the TXD pin. -#define AT91C_US_CHMODE_LOCAL (0x2u << 14) // (DBGU) Local Loopback: Transmitter Output Signal is connected to Receiver Input Signal. -#define AT91C_US_CHMODE_REMOTE (0x3u << 14) // (DBGU) Remote Loopback: RXD pin is internally connected to TXD pin. -// -------- DBGU_IER : (DBGU Offset: 0x8) Debug Unit Interrupt Enable Register -------- -#define AT91C_US_RXRDY (0x1u << 0) // (DBGU) RXRDY Interrupt -#define AT91C_US_TXRDY (0x1u << 1) // (DBGU) TXRDY Interrupt -#define AT91C_US_ENDRX (0x1u << 3) // (DBGU) End of Receive Transfer Interrupt -#define AT91C_US_ENDTX (0x1u << 4) // (DBGU) End of Transmit Interrupt -#define AT91C_US_OVRE (0x1u << 5) // (DBGU) Overrun Interrupt -#define AT91C_US_FRAME (0x1u << 6) // (DBGU) Framing Error Interrupt -#define AT91C_US_PARE (0x1u << 7) // (DBGU) Parity Error Interrupt -#define AT91C_US_TXEMPTY (0x1u << 9) // (DBGU) TXEMPTY Interrupt -#define AT91C_US_TXBUFE (0x1u << 11) // (DBGU) TXBUFE Interrupt -#define AT91C_US_RXBUFF (0x1u << 12) // (DBGU) RXBUFF Interrupt -#define AT91C_US_COMM_TX (0x1u << 30) // (DBGU) COMM_TX Interrupt -#define AT91C_US_COMM_RX (0x1u << 31) // (DBGU) COMM_RX Interrupt -// -------- DBGU_IDR : (DBGU Offset: 0xc) Debug Unit Interrupt Disable Register -------- -// -------- DBGU_IMR : (DBGU Offset: 0x10) Debug Unit Interrupt Mask Register -------- -// -------- DBGU_CSR : (DBGU Offset: 0x14) Debug Unit Channel Status Register -------- -// -------- DBGU_FNTR : (DBGU Offset: 0x48) Debug Unit FORCE_NTRST Register -------- -#define AT91C_US_FORCE_NTRST (0x1u << 0) // (DBGU) Force NTRST in JTAG - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Peripheral Data Controller -// ***************************************************************************** -typedef struct _AT91S_PDC { - AT91_REG PDC_RPR; // Receive Pointer Register - AT91_REG PDC_RCR; // Receive Counter Register - AT91_REG PDC_TPR; // Transmit Pointer Register - AT91_REG PDC_TCR; // Transmit Counter Register - AT91_REG PDC_RNPR; // Receive Next Pointer Register - AT91_REG PDC_RNCR; // Receive Next Counter Register - AT91_REG PDC_TNPR; // Transmit Next Pointer Register - AT91_REG PDC_TNCR; // Transmit Next Counter Register - AT91_REG PDC_PTCR; // PDC Transfer Control Register - AT91_REG PDC_PTSR; // PDC Transfer Status Register -} AT91S_PDC, *AT91PS_PDC; - -// -------- PDC_PTCR : (PDC Offset: 0x20) PDC Transfer Control Register -------- -#define AT91C_PDC_RXTEN (0x1u << 0) // (PDC) Receiver Transfer Enable -#define AT91C_PDC_RXTDIS (0x1u << 1) // (PDC) Receiver Transfer Disable -#define AT91C_PDC_TXTEN (0x1u << 8) // (PDC) Transmitter Transfer Enable -#define AT91C_PDC_TXTDIS (0x1u << 9) // (PDC) Transmitter Transfer Disable -// -------- PDC_PTSR : (PDC Offset: 0x24) PDC Transfer Status Register -------- - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Advanced Interrupt Controller -// ***************************************************************************** -typedef struct _AT91S_AIC { - AT91_REG AIC_SMR[32]; // Source Mode Register - AT91_REG AIC_SVR[32]; // Source Vector Register - AT91_REG AIC_IVR; // IRQ Vector Register - AT91_REG AIC_FVR; // FIQ Vector Register - AT91_REG AIC_ISR; // Interrupt Status Register - AT91_REG AIC_IPR; // Interrupt Pending Register - AT91_REG AIC_IMR; // Interrupt Mask Register - AT91_REG AIC_CISR; // Core Interrupt Status Register - AT91_REG Reserved0[2]; // - AT91_REG AIC_IECR; // Interrupt Enable Command Register - AT91_REG AIC_IDCR; // Interrupt Disable Command Register - AT91_REG AIC_ICCR; // Interrupt Clear Command Register - AT91_REG AIC_ISCR; // Interrupt Set Command Register - AT91_REG AIC_EOICR; // End of Interrupt Command Register - AT91_REG AIC_SPU; // Spurious Vector Register - AT91_REG AIC_DCR; // Debug Control Register (Protect) - AT91_REG Reserved1[1]; // - AT91_REG AIC_FFER; // Fast Forcing Enable Register - AT91_REG AIC_FFDR; // Fast Forcing Disable Register - AT91_REG AIC_FFSR; // Fast Forcing Status Register -} AT91S_AIC, *AT91PS_AIC; - -// -------- AIC_SMR : (AIC Offset: 0x0) Control Register -------- -#define AT91C_AIC_PRIOR (0x7u << 0) // (AIC) Priority Level -#define AT91C_AIC_PRIOR_LOWEST 0x0u // (AIC) Lowest priority level -#define AT91C_AIC_PRIOR_HIGHEST 0x7u // (AIC) Highest priority level -#define AT91C_AIC_SRCTYPE (0x3u << 5) // (AIC) Interrupt Source Type -#define AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE (0x0u << 5) // (AIC) Internal Sources Code Label Level Sensitive -#define AT91C_AIC_SRCTYPE_INT_EDGE_TRIGGERED (0x1u << 5) // (AIC) Internal Sources Code Label Edge triggered -#define AT91C_AIC_SRCTYPE_EXT_HIGH_LEVEL (0x2u << 5) // (AIC) External Sources Code Label High-level Sensitive -#define AT91C_AIC_SRCTYPE_EXT_POSITIVE_EDGE (0x3u << 5) // (AIC) External Sources Code Label Positive Edge triggered -// -------- AIC_CISR : (AIC Offset: 0x114) AIC Core Interrupt Status Register -------- -#define AT91C_AIC_NFIQ (0x1u << 0) // (AIC) NFIQ Status -#define AT91C_AIC_NIRQ (0x1u << 1) // (AIC) NIRQ Status -// -------- AIC_DCR : (AIC Offset: 0x138) AIC Debug Control Register (Protect) -------- -#define AT91C_AIC_DCR_PROT (0x1u << 0) // (AIC) Protection Mode -#define AT91C_AIC_DCR_GMSK (0x1u << 1) // (AIC) General Mask - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Serial Parallel Interface -// ***************************************************************************** -typedef struct _AT91S_SPI { - AT91_REG SPI_CR; // Control Register - AT91_REG SPI_MR; // Mode Register - AT91_REG SPI_RDR; // Receive Data Register - AT91_REG SPI_TDR; // Transmit Data Register - AT91_REG SPI_SR; // Status Register - AT91_REG SPI_IER; // Interrupt Enable Register - AT91_REG SPI_IDR; // Interrupt Disable Register - AT91_REG SPI_IMR; // Interrupt Mask Register - AT91_REG Reserved0[4]; // - AT91_REG SPI_CSR[4]; // Chip Select Register - AT91_REG Reserved1[48]; // - AT91_REG SPI_RPR; // Receive Pointer Register - AT91_REG SPI_RCR; // Receive Counter Register - AT91_REG SPI_TPR; // Transmit Pointer Register - AT91_REG SPI_TCR; // Transmit Counter Register - AT91_REG SPI_RNPR; // Receive Next Pointer Register - AT91_REG SPI_RNCR; // Receive Next Counter Register - AT91_REG SPI_TNPR; // Transmit Next Pointer Register - AT91_REG SPI_TNCR; // Transmit Next Counter Register - AT91_REG SPI_PTCR; // PDC Transfer Control Register - AT91_REG SPI_PTSR; // PDC Transfer Status Register -} AT91S_SPI, *AT91PS_SPI; - -// -------- SPI_CR : (SPI Offset: 0x0) SPI Control Register -------- -#define AT91C_SPI_SPIEN (0x1u << 0) // (SPI) SPI Enable -#define AT91C_SPI_SPIDIS (0x1u << 1) // (SPI) SPI Disable -#define AT91C_SPI_SWRST (0x1u << 7) // (SPI) SPI Software reset -// -------- SPI_MR : (SPI Offset: 0x4) SPI Mode Register -------- -#define AT91C_SPI_MSTR (0x1u << 0) // (SPI) Master/Slave Mode -#define AT91C_SPI_PS (0x1u << 1) // (SPI) Peripheral Select -#define AT91C_SPI_PS_FIXED (0x0u << 1) // (SPI) Fixed Peripheral Select -#define AT91C_SPI_PS_VARIABLE (0x1u << 1) // (SPI) Variable Peripheral Select -#define AT91C_SPI_PCSDEC (0x1u << 2) // (SPI) Chip Select Decode -#define AT91C_SPI_DIV32 (0x1u << 3) // (SPI) Clock Selection -#define AT91C_SPI_MODFDIS (0x1u << 4) // (SPI) Mode Fault Detection -#define AT91C_SPI_LLB (0x1u << 7) // (SPI) Clock Selection -#define AT91C_SPI_PCS (0xFu << 16) // (SPI) Peripheral Chip Select -#define AT91C_SPI_DLYBCS (0xFFu << 24) // (SPI) Delay Between Chip Selects -// -------- SPI_RDR : (SPI Offset: 0x8) Receive Data Register -------- -#define AT91C_SPI_RD (0xFFFFu << 0) // (SPI) Receive Data -#define AT91C_SPI_RPCS (0xFu << 16) // (SPI) Peripheral Chip Select Status -// -------- SPI_TDR : (SPI Offset: 0xc) Transmit Data Register -------- -#define AT91C_SPI_TD (0xFFFFu << 0) // (SPI) Transmit Data -#define AT91C_SPI_TPCS (0xFu << 16) // (SPI) Peripheral Chip Select Status -// -------- SPI_SR : (SPI Offset: 0x10) Status Register -------- -#define AT91C_SPI_RDRF (0x1u << 0) // (SPI) Receive Data Register Full -#define AT91C_SPI_TDRE (0x1u << 1) // (SPI) Transmit Data Register Empty -#define AT91C_SPI_MODF (0x1u << 2) // (SPI) Mode Fault Error -#define AT91C_SPI_OVRES (0x1u << 3) // (SPI) Overrun Error Status -#define AT91C_SPI_SPENDRX (0x1u << 4) // (SPI) End of Receiver Transfer -#define AT91C_SPI_SPENDTX (0x1u << 5) // (SPI) End of Receiver Transfer -#define AT91C_SPI_RXBUFF (0x1u << 6) // (SPI) RXBUFF Interrupt -#define AT91C_SPI_TXBUFE (0x1u << 7) // (SPI) TXBUFE Interrupt -#define AT91C_SPI_SPIENS (0x1u << 16) // (SPI) Enable Status -// -------- SPI_IER : (SPI Offset: 0x14) Interrupt Enable Register -------- -// -------- SPI_IDR : (SPI Offset: 0x18) Interrupt Disable Register -------- -// -------- SPI_IMR : (SPI Offset: 0x1c) Interrupt Mask Register -------- -// -------- SPI_CSR : (SPI Offset: 0x30) Chip Select Register -------- -#define AT91C_SPI_CPOL (0x1u << 0) // (SPI) Clock Polarity -#define AT91C_SPI_NCPHA (0x1u << 1) // (SPI) Clock Phase -#define AT91C_SPI_BITS (0xFu << 4) // (SPI) Bits Per Transfer -#define AT91C_SPI_BITS_8 (0x0u << 4) // (SPI) 8 Bits Per transfer -#define AT91C_SPI_BITS_9 (0x1u << 4) // (SPI) 9 Bits Per transfer -#define AT91C_SPI_BITS_10 (0x2u << 4) // (SPI) 10 Bits Per transfer -#define AT91C_SPI_BITS_11 (0x3u << 4) // (SPI) 11 Bits Per transfer -#define AT91C_SPI_BITS_12 (0x4u << 4) // (SPI) 12 Bits Per transfer -#define AT91C_SPI_BITS_13 (0x5u << 4) // (SPI) 13 Bits Per transfer -#define AT91C_SPI_BITS_14 (0x6u << 4) // (SPI) 14 Bits Per transfer -#define AT91C_SPI_BITS_15 (0x7u << 4) // (SPI) 15 Bits Per transfer -#define AT91C_SPI_BITS_16 (0x8u << 4) // (SPI) 16 Bits Per transfer -#define AT91C_SPI_SCBR (0xFFu << 8) // (SPI) Serial Clock Baud Rate -#define AT91C_SPI_DLYBS (0xFFu << 16) // (SPI) Serial Clock Baud Rate -#define AT91C_SPI_DLYBCT (0xFFu << 24) // (SPI) Delay Between Consecutive Transfers - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Synchronous Serial Controller Interface -// ***************************************************************************** -typedef struct _AT91S_SSC { - AT91_REG SSC_CR; // Control Register - AT91_REG SSC_CMR; // Clock Mode Register - AT91_REG Reserved0[2]; // - AT91_REG SSC_RCMR; // Receive Clock ModeRegister - AT91_REG SSC_RFMR; // Receive Frame Mode Register - AT91_REG SSC_TCMR; // Transmit Clock Mode Register - AT91_REG SSC_TFMR; // Transmit Frame Mode Register - AT91_REG SSC_RHR; // Receive Holding Register - AT91_REG SSC_THR; // Transmit Holding Register - AT91_REG Reserved1[2]; // - AT91_REG SSC_RSHR; // Receive Sync Holding Register - AT91_REG SSC_TSHR; // Transmit Sync Holding Register - AT91_REG SSC_RC0R; // Receive Compare 0 Register - AT91_REG SSC_RC1R; // Receive Compare 1 Register - AT91_REG SSC_SR; // Status Register - AT91_REG SSC_IER; // Interrupt Enable Register - AT91_REG SSC_IDR; // Interrupt Disable Register - AT91_REG SSC_IMR; // Interrupt Mask Register - AT91_REG Reserved2[44]; // - AT91_REG SSC_RPR; // Receive Pointer Register - AT91_REG SSC_RCR; // Receive Counter Register - AT91_REG SSC_TPR; // Transmit Pointer Register - AT91_REG SSC_TCR; // Transmit Counter Register - AT91_REG SSC_RNPR; // Receive Next Pointer Register - AT91_REG SSC_RNCR; // Receive Next Counter Register - AT91_REG SSC_TNPR; // Transmit Next Pointer Register - AT91_REG SSC_TNCR; // Transmit Next Counter Register - AT91_REG SSC_PTCR; // PDC Transfer Control Register - AT91_REG SSC_PTSR; // PDC Transfer Status Register -} AT91S_SSC, *AT91PS_SSC; - -// -------- SSC_CR : (SSC Offset: 0x0) SSC Control Register -------- -#define AT91C_SSC_RXEN (0x1u << 0) // (SSC) Receive Enable -#define AT91C_SSC_RXDIS (0x1u << 1) // (SSC) Receive Disable -#define AT91C_SSC_TXEN (0x1u << 8) // (SSC) Transmit Enable -#define AT91C_SSC_TXDIS (0x1u << 9) // (SSC) Transmit Disable -#define AT91C_SSC_SWRST (0x1u << 15) // (SSC) Software Reset -// -------- SSC_RCMR : (SSC Offset: 0x10) SSC Receive Clock Mode Register -------- -#define AT91C_SSC_CKS (0x3u << 0) // (SSC) Receive/Transmit Clock Selection -#define AT91C_SSC_CKS_DIV 0x0u // (SSC) Divided Clock -#define AT91C_SSC_CKS_TK 0x1u // (SSC) TK Clock signal -#define AT91C_SSC_CKS_RK 0x2u // (SSC) RK pin -#define AT91C_SSC_CKO (0x7u << 2) // (SSC) Receive/Transmit Clock Output Mode Selection -#define AT91C_SSC_CKO_NONE (0x0u << 2) // (SSC) Receive/Transmit Clock Output Mode: None RK pin: Input-only -#define AT91C_SSC_CKO_CONTINOUS (0x1u << 2) // (SSC) Continuous Receive/Transmit Clock RK pin: Output -#define AT91C_SSC_CKO_DATA_TX (0x2u << 2) // (SSC) Receive/Transmit Clock only during data transfers RK pin: Output -#define AT91C_SSC_CKI (0x1u << 5) // (SSC) Receive/Transmit Clock Inversion -#define AT91C_SSC_CKG (0x3u << 6) // (SSC) Receive/Transmit Clock Gating Selection -#define AT91C_SSC_CKG_NONE (0x0u << 6) // (SSC) Receive/Transmit Clock Gating: None, continuous clock -#define AT91C_SSC_CKG_LOW (0x1u << 6) // (SSC) Receive/Transmit Clock enabled only if RF Low -#define AT91C_SSC_CKG_HIGH (0x2u << 6) // (SSC) Receive/Transmit Clock enabled only if RF High -#define AT91C_SSC_START (0xFu << 8) // (SSC) Receive/Transmit Start Selection -#define AT91C_SSC_START_CONTINOUS (0x0u << 8) // (SSC) Continuous, as soon as the receiver is enabled, and immediately after the end of transfer of the previous data. -#define AT91C_SSC_START_TX (0x1u << 8) // (SSC) Transmit/Receive start -#define AT91C_SSC_START_LOW_RF (0x2u << 8) // (SSC) Detection of a low level on RF input -#define AT91C_SSC_START_HIGH_RF (0x3u << 8) // (SSC) Detection of a high level on RF input -#define AT91C_SSC_START_FALL_RF (0x4u << 8) // (SSC) Detection of a falling edge on RF input -#define AT91C_SSC_START_RISE_RF (0x5u << 8) // (SSC) Detection of a rising edge on RF input -#define AT91C_SSC_START_LEVEL_RF (0x6u << 8) // (SSC) Detection of any level change on RF input -#define AT91C_SSC_START_EDGE_RF (0x7u << 8) // (SSC) Detection of any edge on RF input -#define AT91C_SSC_START_0 (0x8u << 8) // (SSC) Compare 0 -#define AT91C_SSC_STOP (0x1u << 12) // (SSC) Receive Stop Selection -#define AT91C_SSC_STTOUT (0x1u << 15) // (SSC) Receive/Transmit Start Output Selection -#define AT91C_SSC_STTDLY (0xFFu << 16) // (SSC) Receive/Transmit Start Delay -#define AT91C_SSC_PERIOD (0xFFu << 24) // (SSC) Receive/Transmit Period Divider Selection -// -------- SSC_RFMR : (SSC Offset: 0x14) SSC Receive Frame Mode Register -------- -#define AT91C_SSC_DATLEN (0x1Fu << 0) // (SSC) Data Length -#define AT91C_SSC_LOOP (0x1u << 5) // (SSC) Loop Mode -#define AT91C_SSC_MSBF (0x1u << 7) // (SSC) Most Significant Bit First -#define AT91C_SSC_DATNB (0xFu << 8) // (SSC) Data Number per Frame -#define AT91C_SSC_FSLEN (0xFu << 16) // (SSC) Receive/Transmit Frame Sync length -#define AT91C_SSC_FSOS (0x7u << 20) // (SSC) Receive/Transmit Frame Sync Output Selection -#define AT91C_SSC_FSOS_NONE (0x0u << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: None RK pin Input-only -#define AT91C_SSC_FSOS_NEGATIVE (0x1u << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Negative Pulse -#define AT91C_SSC_FSOS_POSITIVE (0x2u << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Positive Pulse -#define AT91C_SSC_FSOS_LOW (0x3u << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Driver Low during data transfer -#define AT91C_SSC_FSOS_HIGH (0x4u << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Driver High during data transfer -#define AT91C_SSC_FSOS_TOGGLE (0x5u << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Toggling at each start of data transfer -#define AT91C_SSC_FSEDGE (0x1u << 24) // (SSC) Frame Sync Edge Detection -// -------- SSC_TCMR : (SSC Offset: 0x18) SSC Transmit Clock Mode Register -------- -// -------- SSC_TFMR : (SSC Offset: 0x1c) SSC Transmit Frame Mode Register -------- -#define AT91C_SSC_DATDEF (0x1u << 5) // (SSC) Data Default Value -#define AT91C_SSC_FSDEN (0x1u << 23) // (SSC) Frame Sync Data Enable -// -------- SSC_SR : (SSC Offset: 0x40) SSC Status Register -------- -#define AT91C_SSC_TXRDY (0x1u << 0) // (SSC) Transmit Ready -#define AT91C_SSC_TXEMPTY (0x1u << 1) // (SSC) Transmit Empty -#define AT91C_SSC_ENDTX (0x1u << 2) // (SSC) End Of Transmission -#define AT91C_SSC_TXBUFE (0x1u << 3) // (SSC) Transmit Buffer Empty -#define AT91C_SSC_RXRDY (0x1u << 4) // (SSC) Receive Ready -#define AT91C_SSC_OVRUN (0x1u << 5) // (SSC) Receive Overrun -#define AT91C_SSC_ENDRX (0x1u << 6) // (SSC) End of Reception -#define AT91C_SSC_RXBUFF (0x1u << 7) // (SSC) Receive Buffer Full -#define AT91C_SSC_CP0 (0x1u << 8) // (SSC) Compare 0 -#define AT91C_SSC_CP1 (0x1u << 9) // (SSC) Compare 1 -#define AT91C_SSC_TXSYN (0x1u << 10) // (SSC) Transmit Sync -#define AT91C_SSC_RXSYN (0x1u << 11) // (SSC) Receive Sync -#define AT91C_SSC_TXENA (0x1u << 16) // (SSC) Transmit Enable -#define AT91C_SSC_RXENA (0x1u << 17) // (SSC) Receive Enable -// -------- SSC_IER : (SSC Offset: 0x44) SSC Interrupt Enable Register -------- -// -------- SSC_IDR : (SSC Offset: 0x48) SSC Interrupt Disable Register -------- -// -------- SSC_IMR : (SSC Offset: 0x4c) SSC Interrupt Mask Register -------- - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Usart -// ***************************************************************************** -typedef struct _AT91S_USART { - AT91_REG US_CR; // Control Register - AT91_REG US_MR; // Mode Register - AT91_REG US_IER; // Interrupt Enable Register - AT91_REG US_IDR; // Interrupt Disable Register - AT91_REG US_IMR; // Interrupt Mask Register - AT91_REG US_CSR; // Channel Status Register - AT91_REG US_RHR; // Receiver Holding Register - AT91_REG US_THR; // Transmitter Holding Register - AT91_REG US_BRGR; // Baud Rate Generator Register - AT91_REG US_RTOR; // Receiver Time-out Register - AT91_REG US_TTGR; // Transmitter Time-guard Register - AT91_REG Reserved0[5]; // - AT91_REG US_FIDI; // FI_DI_Ratio Register - AT91_REG US_NER; // Nb Errors Register - AT91_REG US_XXR; // XON_XOFF Register - AT91_REG US_IF; // IRDA_FILTER Register - AT91_REG Reserved1[44]; // - AT91_REG US_RPR; // Receive Pointer Register - AT91_REG US_RCR; // Receive Counter Register - AT91_REG US_TPR; // Transmit Pointer Register - AT91_REG US_TCR; // Transmit Counter Register - AT91_REG US_RNPR; // Receive Next Pointer Register - AT91_REG US_RNCR; // Receive Next Counter Register - AT91_REG US_TNPR; // Transmit Next Pointer Register - AT91_REG US_TNCR; // Transmit Next Counter Register - AT91_REG US_PTCR; // PDC Transfer Control Register - AT91_REG US_PTSR; // PDC Transfer Status Register -} AT91S_USART, *AT91PS_USART; - -// -------- US_CR : (USART Offset: 0x0) Debug Unit Control Register -------- -#define AT91C_US_RSTSTA (0x1u << 8) // (USART) Reset Status Bits -#define AT91C_US_STTBRK (0x1u << 9) // (USART) Start Break -#define AT91C_US_STPBRK (0x1u << 10) // (USART) Stop Break -#define AT91C_US_STTTO (0x1u << 11) // (USART) Start Time-out -#define AT91C_US_SENDA (0x1u << 12) // (USART) Send Address -#define AT91C_US_RSTIT (0x1u << 13) // (USART) Reset Iterations -#define AT91C_US_RSTNACK (0x1u << 14) // (USART) Reset Non Acknowledge -#define AT91C_US_RETTO (0x1u << 15) // (USART) Rearm Time-out -#define AT91C_US_DTREN (0x1u << 16) // (USART) Data Terminal ready Enable -#define AT91C_US_DTRDIS (0x1u << 17) // (USART) Data Terminal ready Disable -#define AT91C_US_RTSEN (0x1u << 18) // (USART) Request to Send enable -#define AT91C_US_RTSDIS (0x1u << 19) // (USART) Request to Send Disable -// -------- US_MR : (USART Offset: 0x4) Debug Unit Mode Register -------- -#define AT91C_US_USMODE (0xFu << 0) // (USART) Usart mode -#define AT91C_US_USMODE_NORMAL 0x0u // (USART) Normal -#define AT91C_US_USMODE_RS485 0x1u // (USART) RS485 -#define AT91C_US_USMODE_HWHSH 0x2u // (USART) Hardware Handshaking -#define AT91C_US_USMODE_MODEM 0x3u // (USART) Modem -#define AT91C_US_USMODE_ISO7816_0 0x4u // (USART) ISO7816 protocol: T = 0 -#define AT91C_US_USMODE_ISO7816_1 0x6u // (USART) ISO7816 protocol: T = 1 -#define AT91C_US_USMODE_IRDA 0x8u // (USART) IrDA -#define AT91C_US_USMODE_SWHSH 0xCu // (USART) Software Handshaking -#define AT91C_US_CLKS (0x3u << 4) // (USART) Clock Selection (Baud Rate generator Input Clock -#define AT91C_US_CLKS_CLOCK (0x0u << 4) // (USART) Clock -#define AT91C_US_CLKS_FDIV1 (0x1u << 4) // (USART) fdiv1 -#define AT91C_US_CLKS_SLOW (0x2u << 4) // (USART) slow_clock (ARM) -#define AT91C_US_CLKS_EXT (0x3u << 4) // (USART) External (SCK) -#define AT91C_US_CHRL (0x3u << 6) // (USART) Clock Selection (Baud Rate generator Input Clock -#define AT91C_US_CHRL_5_BITS (0x0u << 6) // (USART) Character Length: 5 bits -#define AT91C_US_CHRL_6_BITS (0x1u << 6) // (USART) Character Length: 6 bits -#define AT91C_US_CHRL_7_BITS (0x2u << 6) // (USART) Character Length: 7 bits -#define AT91C_US_CHRL_8_BITS (0x3u << 6) // (USART) Character Length: 8 bits -#define AT91C_US_SYNC (0x1u << 8) // (USART) Synchronous Mode Select -#define AT91C_US_NBSTOP (0x3u << 12) // (USART) Number of Stop bits -#define AT91C_US_NBSTOP_1_BIT (0x0u << 12) // (USART) 1 stop bit -#define AT91C_US_NBSTOP_15_BIT (0x1u << 12) // (USART) Asynchronous (SYNC=0) 2 stop bits Synchronous (SYNC=1) 2 stop bits -#define AT91C_US_NBSTOP_2_BIT (0x2u << 12) // (USART) 2 stop bits -#define AT91C_US_MSBF (0x1u << 16) // (USART) Bit Order -#define AT91C_US_MODE9 (0x1u << 17) // (USART) 9-bit Character length -#define AT91C_US_CKLO (0x1u << 18) // (USART) Clock Output Select -#define AT91C_US_OVER (0x1u << 19) // (USART) Over Sampling Mode -#define AT91C_US_INACK (0x1u << 20) // (USART) Inhibit Non Acknowledge -#define AT91C_US_DSNACK (0x1u << 21) // (USART) Disable Successive NACK -#define AT91C_US_MAX_ITER (0x1u << 24) // (USART) Number of Repetitions -#define AT91C_US_FILTER (0x1u << 28) // (USART) Receive Line Filter -// -------- US_IER : (USART Offset: 0x8) Debug Unit Interrupt Enable Register -------- -#define AT91C_US_RXBRK (0x1u << 2) // (USART) Break Received/End of Break -#define AT91C_US_TIMEOUT (0x1u << 8) // (USART) Receiver Time-out -#define AT91C_US_ITERATION (0x1u << 10) // (USART) Max number of Repetitions Reached -#define AT91C_US_NACK (0x1u << 13) // (USART) Non Acknowledge -#define AT91C_US_RIIC (0x1u << 16) // (USART) Ring INdicator Input Change Flag -#define AT91C_US_DSRIC (0x1u << 17) // (USART) Data Set Ready Input Change Flag -#define AT91C_US_DCDIC (0x1u << 18) // (USART) Data Carrier Flag -#define AT91C_US_CTSIC (0x1u << 19) // (USART) Clear To Send Input Change Flag -// -------- US_IDR : (USART Offset: 0xc) Debug Unit Interrupt Disable Register -------- -// -------- US_IMR : (USART Offset: 0x10) Debug Unit Interrupt Mask Register -------- -// -------- US_CSR : (USART Offset: 0x14) Debug Unit Channel Status Register -------- -#define AT91C_US_RI (0x1u << 20) // (USART) Image of RI Input -#define AT91C_US_DSR (0x1u << 21) // (USART) Image of DSR Input -#define AT91C_US_DCD (0x1u << 22) // (USART) Image of DCD Input -#define AT91C_US_CTS (0x1u << 23) // (USART) Image of CTS Input - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Two-wire Interface -// ***************************************************************************** -typedef struct _AT91S_TWI { - AT91_REG TWI_CR; // Control Register - AT91_REG TWI_MMR; // Master Mode Register - AT91_REG TWI_SMR; // Slave Mode Register - AT91_REG TWI_IADR; // Internal Address Register - AT91_REG TWI_CWGR; // Clock Waveform Generator Register - AT91_REG Reserved0[3]; // - AT91_REG TWI_SR; // Status Register - AT91_REG TWI_IER; // Interrupt Enable Register - AT91_REG TWI_IDR; // Interrupt Disable Register - AT91_REG TWI_IMR; // Interrupt Mask Register - AT91_REG TWI_RHR; // Receive Holding Register - AT91_REG TWI_THR; // Transmit Holding Register -} AT91S_TWI, *AT91PS_TWI; - -// -------- TWI_CR : (TWI Offset: 0x0) TWI Control Register -------- -#define AT91C_TWI_START (0x1u << 0) // (TWI) Send a START Condition -#define AT91C_TWI_STOP (0x1u << 1) // (TWI) Send a STOP Condition -#define AT91C_TWI_MSEN (0x1u << 2) // (TWI) TWI Master Transfer Enabled -#define AT91C_TWI_MSDIS (0x1u << 3) // (TWI) TWI Master Transfer Disabled -#define AT91C_TWI_SVEN (0x1u << 4) // (TWI) TWI Slave Transfer Enabled -#define AT91C_TWI_SVDIS (0x1u << 5) // (TWI) TWI Slave Transfer Disabled -#define AT91C_TWI_SWRST (0x1u << 7) // (TWI) Software Reset -// -------- TWI_MMR : (TWI Offset: 0x4) TWI Master Mode Register -------- -#define AT91C_TWI_IADRSZ (0x3u << 8) // (TWI) Internal Device Address Size -#define AT91C_TWI_IADRSZ_NO (0x0u << 8) // (TWI) No internal device address -#define AT91C_TWI_IADRSZ_1_BYTE (0x1u << 8) // (TWI) One-byte internal device address -#define AT91C_TWI_IADRSZ_2_BYTE (0x2u << 8) // (TWI) Two-byte internal device address -#define AT91C_TWI_IADRSZ_3_BYTE (0x3u << 8) // (TWI) Three-byte internal device address -#define AT91C_TWI_MREAD (0x1u << 12) // (TWI) Master Read Direction -#define AT91C_TWI_DADR (0x7Fu << 16) // (TWI) Device Address -// -------- TWI_SMR : (TWI Offset: 0x8) TWI Slave Mode Register -------- -#define AT91C_TWI_SADR (0x7Fu << 16) // (TWI) Slave Device Address -// -------- TWI_CWGR : (TWI Offset: 0x10) TWI Clock Waveform Generator Register -------- -#define AT91C_TWI_CLDIV (0xFFu << 0) // (TWI) Clock Low Divider -#define AT91C_TWI_CHDIV (0xFFu << 8) // (TWI) Clock High Divider -#define AT91C_TWI_CKDIV (0x7u << 16) // (TWI) Clock Divider -// -------- TWI_SR : (TWI Offset: 0x20) TWI Status Register -------- -#define AT91C_TWI_TXCOMP (0x1u << 0) // (TWI) Transmission Completed -#define AT91C_TWI_RXRDY (0x1u << 1) // (TWI) Receive holding register ReaDY -#define AT91C_TWI_TXRDY (0x1u << 2) // (TWI) Transmit holding register ReaDY -#define AT91C_TWI_SVREAD (0x1u << 3) // (TWI) Slave Read -#define AT91C_TWI_SVACC (0x1u << 4) // (TWI) Slave Access -#define AT91C_TWI_GCACC (0x1u << 5) // (TWI) General Call Access -#define AT91C_TWI_OVRE (0x1u << 6) // (TWI) Overrun Error -#define AT91C_TWI_UNRE (0x1u << 7) // (TWI) Underrun Error -#define AT91C_TWI_NACK (0x1u << 8) // (TWI) Not Acknowledged -#define AT91C_TWI_ARBLST (0x1u << 9) // (TWI) Arbitration Lost -// -------- TWI_IER : (TWI Offset: 0x24) TWI Interrupt Enable Register -------- -// -------- TWI_IDR : (TWI Offset: 0x28) TWI Interrupt Disable Register -------- -// -------- TWI_IMR : (TWI Offset: 0x2c) TWI Interrupt Mask Register -------- - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Multimedia Card Interface -// ***************************************************************************** -typedef struct _AT91S_MCI { - AT91_REG MCI_CR; // MCI Control Register - AT91_REG MCI_MR; // MCI Mode Register - AT91_REG MCI_DTOR; // MCI Data Timeout Register - AT91_REG MCI_SDCR; // MCI SD Card Register - AT91_REG MCI_ARGR; // MCI Argument Register - AT91_REG MCI_CMDR; // MCI Command Register - AT91_REG Reserved0[2]; // - AT91_REG MCI_RSPR[4]; // MCI Response Register - AT91_REG MCI_RDR; // MCI Receive Data Register - AT91_REG MCI_TDR; // MCI Transmit Data Register - AT91_REG Reserved1[2]; // - AT91_REG MCI_SR; // MCI Status Register - AT91_REG MCI_IER; // MCI Interrupt Enable Register - AT91_REG MCI_IDR; // MCI Interrupt Disable Register - AT91_REG MCI_IMR; // MCI Interrupt Mask Register - AT91_REG Reserved2[44]; // - AT91_REG MCI_RPR; // Receive Pointer Register - AT91_REG MCI_RCR; // Receive Counter Register - AT91_REG MCI_TPR; // Transmit Pointer Register - AT91_REG MCI_TCR; // Transmit Counter Register - AT91_REG MCI_RNPR; // Receive Next Pointer Register - AT91_REG MCI_RNCR; // Receive Next Counter Register - AT91_REG MCI_TNPR; // Transmit Next Pointer Register - AT91_REG MCI_TNCR; // Transmit Next Counter Register - AT91_REG MCI_PTCR; // PDC Transfer Control Register - AT91_REG MCI_PTSR; // PDC Transfer Status Register -} AT91S_MCI, *AT91PS_MCI; - -// -------- MCI_CR : (MCI Offset: 0x0) MCI Control Register -------- -#define AT91C_MCI_MCIEN (0x1u << 0) // (MCI) Multimedia Interface Enable -#define AT91C_MCI_MCIDIS (0x1u << 1) // (MCI) Multimedia Interface Disable -#define AT91C_MCI_PWSEN (0x1u << 2) // (MCI) Power Save Mode Enable -#define AT91C_MCI_PWSDIS (0x1u << 3) // (MCI) Power Save Mode Disable -// -------- MCI_MR : (MCI Offset: 0x4) MCI Mode Register -------- -#define AT91C_MCI_CLKDIV (0x1u << 0) // (MCI) Clock Divider -#define AT91C_MCI_PWSDIV (0x1u << 8) // (MCI) Power Saving Divider -#define AT91C_MCI_PDCPADV (0x1u << 14) // (MCI) PDC Padding Value -#define AT91C_MCI_PDCMODE (0x1u << 15) // (MCI) PDC Oriented Mode -#define AT91C_MCI_BLKLEN (0x1u << 18) // (MCI) Data Block Length -// -------- MCI_DTOR : (MCI Offset: 0x8) MCI Data Timeout Register -------- -#define AT91C_MCI_DTOCYC (0x1u << 0) // (MCI) Data Timeout Cycle Number -#define AT91C_MCI_DTOMUL (0x7u << 4) // (MCI) Data Timeout Multiplier -#define AT91C_MCI_DTOMUL_1 (0x0u << 4) // (MCI) DTOCYC x 1 -#define AT91C_MCI_DTOMUL_16 (0x1u << 4) // (MCI) DTOCYC x 16 -#define AT91C_MCI_DTOMUL_128 (0x2u << 4) // (MCI) DTOCYC x 128 -#define AT91C_MCI_DTOMUL_256 (0x3u << 4) // (MCI) DTOCYC x 256 -#define AT91C_MCI_DTOMUL_1024 (0x4u << 4) // (MCI) DTOCYC x 1024 -#define AT91C_MCI_DTOMUL_4096 (0x5u << 4) // (MCI) DTOCYC x 4096 -#define AT91C_MCI_DTOMUL_65536 (0x6u << 4) // (MCI) DTOCYC x 65536 -#define AT91C_MCI_DTOMUL_1048576 (0x7u << 4) // (MCI) DTOCYC x 1048576 -// -------- MCI_SDCR : (MCI Offset: 0xc) MCI SD Card Register -------- -#define AT91C_MCI_SCDSEL (0x1u << 0) // (MCI) SD Card Selector -#define AT91C_MCI_SCDBUS (0x1u << 7) // (MCI) SD Card Bus Width -// -------- MCI_CMDR : (MCI Offset: 0x14) MCI Command Register -------- -// -------- MCI_SR : (MCI Offset: 0x40) MCI Status Register -------- -#define AT91C_MCI_CMDRDY (0x1u << 0) // (MCI) Command Ready flag -#define AT91C_MCI_RXRDY (0x1u << 1) // (MCI) RX Ready flag -#define AT91C_MCI_TXRDY (0x1u << 2) // (MCI) TX Ready flag -#define AT91C_MCI_BLKE (0x1u << 3) // (MCI) Data Block Transfer Ended flag -#define AT91C_MCI_DTIP (0x1u << 4) // (MCI) Data Transfer in Progress flag -#define AT91C_MCI_NOTBUSY (0x1u << 5) // (MCI) Data Line Not Busy flag -#define AT91C_MCI_ENDRX (0x1u << 6) // (MCI) End of RX Buffer flag -#define AT91C_MCI_ENDTX (0x1u << 7) // (MCI) End of TX Buffer flag -#define AT91C_MCI_RXBUFF (0x1u << 14) // (MCI) RX Buffer Full flag -#define AT91C_MCI_TXBUFE (0x1u << 15) // (MCI) TX Buffer Empty flag -#define AT91C_MCI_RINDE (0x1u << 16) // (MCI) Response Index Error flag -#define AT91C_MCI_RDIRE (0x1u << 17) // (MCI) Response Direction Error flag -#define AT91C_MCI_RCRCE (0x1u << 18) // (MCI) Response CRC Error flag -#define AT91C_MCI_RENDE (0x1u << 19) // (MCI) Response End Bit Error flag -#define AT91C_MCI_RTOE (0x1u << 20) // (MCI) Response Time-out Error flag -#define AT91C_MCI_DCRCE (0x1u << 21) // (MCI) data CRC Error flag -#define AT91C_MCI_DTOE (0x1u << 22) // (MCI) Data timeout Error flag -#define AT91C_MCI_OVRE (0x1u << 30) // (MCI) Overrun flag -#define AT91C_MCI_UNRE (0x1u << 31) // (MCI) Underrun flag -// -------- MCI_IER : (MCI Offset: 0x44) MCI Interrupt Enable Register -------- -// -------- MCI_IDR : (MCI Offset: 0x48) MCI Interrupt Disable Register -------- -// -------- MCI_IMR : (MCI Offset: 0x4c) MCI Interrupt Mask Register -------- - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR USB Device Interface -// ***************************************************************************** -typedef struct _AT91S_UDP { - AT91_REG UDP_NUM; // Frame Number Register - AT91_REG UDP_GLBSTATE; // Global State Register - AT91_REG UDP_FADDR; // Function Address Register - AT91_REG Reserved0[1]; // - AT91_REG UDP_IER; // Interrupt Enable Register - AT91_REG UDP_IDR; // Interrupt Disable Register - AT91_REG UDP_IMR; // Interrupt Mask Register - AT91_REG UDP_ISR; // Interrupt Status Register - AT91_REG UDP_ICR; // Interrupt Clear Register - AT91_REG Reserved1[1]; // - AT91_REG UDP_RSTEP; // Reset Endpoint Register - AT91_REG Reserved2[1]; // - AT91_REG UDP_CSR[8]; // Endpoint Control and Status Register - AT91_REG UDP_FDR[8]; // Endpoint FIFO Data Register -} AT91S_UDP, *AT91PS_UDP; - -// -------- UDP_FRM_NUM : (UDP Offset: 0x0) USB Frame Number Register -------- -#define AT91C_UDP_FRM_NUM (0x7FFu << 0) // (UDP) Frame Number as Defined in the Packet Field Formats -#define AT91C_UDP_FRM_ERR (0x1u << 16) // (UDP) Frame Error -#define AT91C_UDP_FRM_OK (0x1u << 17) // (UDP) Frame OK -// -------- UDP_GLB_STATE : (UDP Offset: 0x4) USB Global State Register -------- -#define AT91C_UDP_FADDEN (0x1u << 0) // (UDP) Function Address Enable -#define AT91C_UDP_CONFG (0x1u << 1) // (UDP) Configured -#define AT91C_UDP_RMWUPE (0x1u << 2) // (UDP) Remote Wake Up Enable -#define AT91C_UDP_RSMINPR (0x1u << 3) // (UDP) A Resume Has Been Sent to the Host -// -------- UDP_FADDR : (UDP Offset: 0x8) USB Function Address Register -------- -#define AT91C_UDP_FADD (0xFFu << 0) // (UDP) Function Address Value -#define AT91C_UDP_FEN (0x1u << 8) // (UDP) Function Enable -// -------- UDP_IER : (UDP Offset: 0x10) USB Interrupt Enable Register -------- -#define AT91C_UDP_EPINT0 (0x1u << 0) // (UDP) Endpoint 0 Interrupt -#define AT91C_UDP_EPINT1 (0x1u << 1) // (UDP) Endpoint 0 Interrupt -#define AT91C_UDP_EPINT2 (0x1u << 2) // (UDP) Endpoint 2 Interrupt -#define AT91C_UDP_EPINT3 (0x1u << 3) // (UDP) Endpoint 3 Interrupt -#define AT91C_UDP_EPINT4 (0x1u << 4) // (UDP) Endpoint 4 Interrupt -#define AT91C_UDP_EPINT5 (0x1u << 5) // (UDP) Endpoint 5 Interrupt -#define AT91C_UDP_EPINT6 (0x1u << 6) // (UDP) Endpoint 6 Interrupt -#define AT91C_UDP_EPINT7 (0x1u << 7) // (UDP) Endpoint 7 Interrupt -#define AT91C_UDP_RXSUSP (0x1u << 8) // (UDP) USB Suspend Interrupt -#define AT91C_UDP_RXRSM (0x1u << 9) // (UDP) USB Resume Interrupt -#define AT91C_UDP_EXTRSM (0x1u << 10) // (UDP) USB External Resume Interrupt -#define AT91C_UDP_SOFINT (0x1u << 11) // (UDP) USB Start Of frame Interrupt -#define AT91C_UDP_WAKEUP (0x1u << 13) // (UDP) USB Resume Interrupt -// -------- UDP_IDR : (UDP Offset: 0x14) USB Interrupt Disable Register -------- -// -------- UDP_IMR : (UDP Offset: 0x18) USB Interrupt Mask Register -------- -// -------- UDP_ISR : (UDP Offset: 0x1c) USB Interrupt Status Register -------- -#define AT91C_UDP_ENDBUSRES (0x1u << 12) // (UDP) USB End Of Bus Reset Interrupt -// -------- UDP_ICR : (UDP Offset: 0x20) USB Interrupt Clear Register -------- -// -------- UDP_RST_EP : (UDP Offset: 0x28) USB Reset Endpoint Register -------- -#define AT91C_UDP_EP0 (0x1u << 0) // (UDP) Reset Endpoint 0 -#define AT91C_UDP_EP1 (0x1u << 1) // (UDP) Reset Endpoint 1 -#define AT91C_UDP_EP2 (0x1u << 2) // (UDP) Reset Endpoint 2 -#define AT91C_UDP_EP3 (0x1u << 3) // (UDP) Reset Endpoint 3 -#define AT91C_UDP_EP4 (0x1u << 4) // (UDP) Reset Endpoint 4 -#define AT91C_UDP_EP5 (0x1u << 5) // (UDP) Reset Endpoint 5 -#define AT91C_UDP_EP6 (0x1u << 6) // (UDP) Reset Endpoint 6 -#define AT91C_UDP_EP7 (0x1u << 7) // (UDP) Reset Endpoint 7 -// -------- UDP_CSR : (UDP Offset: 0x30) USB Endpoint Control and Status Register -------- -#define AT91C_UDP_TXCOMP (0x1u << 0) // (UDP) Generates an IN packet with data previously written in the DPR -#define AT91C_UDP_RX_DATA_BK0 (0x1u << 1) // (UDP) Receive Data Bank 0 -#define AT91C_UDP_RXSETUP (0x1u << 2) // (UDP) Sends STALL to the Host (Control endpoints) -#define AT91C_UDP_ISOERROR (0x1u << 3) // (UDP) Isochronous error (Isochronous endpoints) -#define AT91C_UDP_TXPKTRDY (0x1u << 4) // (UDP) Transmit Packet Ready -#define AT91C_UDP_FORCESTALL (0x1u << 5) // (UDP) Force Stall (used by Control, Bulk and Isochronous endpoints). -#define AT91C_UDP_RX_DATA_BK1 (0x1u << 6) // (UDP) Receive Data Bank 1 (only used by endpoints with ping-pong attributes). -#define AT91C_UDP_DIR (0x1u << 7) // (UDP) Transfer Direction -#define AT91C_UDP_EPTYPE (0x7u << 8) // (UDP) Endpoint type -#define AT91C_UDP_EPTYPE_CTRL (0x0u << 8) // (UDP) Control -#define AT91C_UDP_EPTYPE_ISO_OUT (0x1u << 8) // (UDP) Isochronous OUT -#define AT91C_UDP_EPTYPE_BULK_OUT (0x2u << 8) // (UDP) Bulk OUT -#define AT91C_UDP_EPTYPE_INT_OUT (0x3u << 8) // (UDP) Interrupt OUT -#define AT91C_UDP_EPTYPE_ISO_IN (0x5u << 8) // (UDP) Isochronous IN -#define AT91C_UDP_EPTYPE_BULK_IN (0x6u << 8) // (UDP) Bulk IN -#define AT91C_UDP_EPTYPE_INT_IN (0x7u << 8) // (UDP) Interrupt IN -#define AT91C_UDP_DTGLE (0x1u << 11) // (UDP) Data Toggle -#define AT91C_UDP_EPEDS (0x1u << 15) // (UDP) Endpoint Enable Disable -#define AT91C_UDP_RXBYTECNT (0x7FFu << 16) // (UDP) Number Of Bytes Available in the FIFO - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Timer Counter Channel Interface -// ***************************************************************************** -typedef struct _AT91S_TC { - AT91_REG TC_CCR; // Channel Control Register - AT91_REG TC_CMR; // Channel Mode Register - AT91_REG Reserved0[2]; // - AT91_REG TC_CV; // Counter Value - AT91_REG TC_RA; // Register A - AT91_REG TC_RB; // Register B - AT91_REG TC_RC; // Register C - AT91_REG TC_SR; // Status Register - AT91_REG TC_IER; // Interrupt Enable Register - AT91_REG TC_IDR; // Interrupt Disable Register - AT91_REG TC_IMR; // Interrupt Mask Register -} AT91S_TC, *AT91PS_TC; - -// -------- TC_CCR : (TC Offset: 0x0) TC Channel Control Register -------- -#define AT91C_TC_CLKEN (0x1u << 0) // (TC) Counter Clock Enable Command -#define AT91C_TC_CLKDIS (0x1u << 1) // (TC) Counter Clock Disable Command -#define AT91C_TC_SWTRG (0x1u << 2) // (TC) Software Trigger Command -// -------- TC_CMR : (TC Offset: 0x4) TC Channel Mode Register: Capture Mode / Waveform Mode -------- -#define AT91C_TC_CPCSTOP (0x1u << 6) // (TC) Counter Clock Stopped with RC Compare -#define AT91C_TC_CPCDIS (0x1u << 7) // (TC) Counter Clock Disable with RC Compare -#define AT91C_TC_EEVTEDG (0x3u << 8) // (TC) External Event Edge Selection -#define AT91C_TC_EEVTEDG_NONE (0x0u << 8) // (TC) Edge: None -#define AT91C_TC_EEVTEDG_RISING (0x1u << 8) // (TC) Edge: rising edge -#define AT91C_TC_EEVTEDG_FALLING (0x2u << 8) // (TC) Edge: falling edge -#define AT91C_TC_EEVTEDG_BOTH (0x3u << 8) // (TC) Edge: each edge -#define AT91C_TC_EEVT (0x3u << 10) // (TC) External Event Selection -#define AT91C_TC_EEVT_NONE (0x0u << 10) // (TC) Signal selected as external event: TIOB TIOB direction: input -#define AT91C_TC_EEVT_RISING (0x1u << 10) // (TC) Signal selected as external event: XC0 TIOB direction: output -#define AT91C_TC_EEVT_FALLING (0x2u << 10) // (TC) Signal selected as external event: XC1 TIOB direction: output -#define AT91C_TC_EEVT_BOTH (0x3u << 10) // (TC) Signal selected as external event: XC2 TIOB direction: output -#define AT91C_TC_ENETRG (0x1u << 12) // (TC) External Event Trigger enable -#define AT91C_TC_WAVESEL (0x3u << 13) // (TC) Waveform Selection -#define AT91C_TC_WAVESEL_UP (0x0u << 13) // (TC) UP mode without atomatic trigger on RC Compare -#define AT91C_TC_WAVESEL_UP_AUTO (0x1u << 13) // (TC) UP mode with automatic trigger on RC Compare -#define AT91C_TC_WAVESEL_UPDOWN (0x2u << 13) // (TC) UPDOWN mode without automatic trigger on RC Compare -#define AT91C_TC_WAVESEL_UPDOWN_AUTO (0x3u << 13) // (TC) UPDOWN mode with automatic trigger on RC Compare -#define AT91C_TC_CPCTRG (0x1u << 14) // (TC) RC Compare Trigger Enable -#define AT91C_TC_WAVE (0x1u << 15) // (TC) -#define AT91C_TC_ACPA (0x3u << 16) // (TC) RA Compare Effect on TIOA -#define AT91C_TC_ACPA_NONE (0x0u << 16) // (TC) Effect: none -#define AT91C_TC_ACPA_SET (0x1u << 16) // (TC) Effect: set -#define AT91C_TC_ACPA_CLEAR (0x2u << 16) // (TC) Effect: clear -#define AT91C_TC_ACPA_TOGGLE (0x3u << 16) // (TC) Effect: toggle -#define AT91C_TC_ACPC (0x3u << 18) // (TC) RC Compare Effect on TIOA -#define AT91C_TC_ACPC_NONE (0x0u << 18) // (TC) Effect: none -#define AT91C_TC_ACPC_SET (0x1u << 18) // (TC) Effect: set -#define AT91C_TC_ACPC_CLEAR (0x2u << 18) // (TC) Effect: clear -#define AT91C_TC_ACPC_TOGGLE (0x3u << 18) // (TC) Effect: toggle -#define AT91C_TC_AEEVT (0x3u << 20) // (TC) External Event Effect on TIOA -#define AT91C_TC_AEEVT_NONE (0x0u << 20) // (TC) Effect: none -#define AT91C_TC_AEEVT_SET (0x1u << 20) // (TC) Effect: set -#define AT91C_TC_AEEVT_CLEAR (0x2u << 20) // (TC) Effect: clear -#define AT91C_TC_AEEVT_TOGGLE (0x3u << 20) // (TC) Effect: toggle -#define AT91C_TC_ASWTRG (0x3u << 22) // (TC) Software Trigger Effect on TIOA -#define AT91C_TC_ASWTRG_NONE (0x0u << 22) // (TC) Effect: none -#define AT91C_TC_ASWTRG_SET (0x1u << 22) // (TC) Effect: set -#define AT91C_TC_ASWTRG_CLEAR (0x2u << 22) // (TC) Effect: clear -#define AT91C_TC_ASWTRG_TOGGLE (0x3u << 22) // (TC) Effect: toggle -#define AT91C_TC_BCPB (0x3u << 24) // (TC) RB Compare Effect on TIOB -#define AT91C_TC_BCPB_NONE (0x0u << 24) // (TC) Effect: none -#define AT91C_TC_BCPB_SET (0x1u << 24) // (TC) Effect: set -#define AT91C_TC_BCPB_CLEAR (0x2u << 24) // (TC) Effect: clear -#define AT91C_TC_BCPB_TOGGLE (0x3u << 24) // (TC) Effect: toggle -#define AT91C_TC_BCPC (0x3u << 26) // (TC) RC Compare Effect on TIOB -#define AT91C_TC_BCPC_NONE (0x0u << 26) // (TC) Effect: none -#define AT91C_TC_BCPC_SET (0x1u << 26) // (TC) Effect: set -#define AT91C_TC_BCPC_CLEAR (0x2u << 26) // (TC) Effect: clear -#define AT91C_TC_BCPC_TOGGLE (0x3u << 26) // (TC) Effect: toggle -#define AT91C_TC_BEEVT (0x3u << 28) // (TC) External Event Effect on TIOB -#define AT91C_TC_BEEVT_NONE (0x0u << 28) // (TC) Effect: none -#define AT91C_TC_BEEVT_SET (0x1u << 28) // (TC) Effect: set -#define AT91C_TC_BEEVT_CLEAR (0x2u << 28) // (TC) Effect: clear -#define AT91C_TC_BEEVT_TOGGLE (0x3u << 28) // (TC) Effect: toggle -#define AT91C_TC_BSWTRG (0x3u << 30) // (TC) Software Trigger Effect on TIOB -#define AT91C_TC_BSWTRG_NONE (0x0u << 30) // (TC) Effect: none -#define AT91C_TC_BSWTRG_SET (0x1u << 30) // (TC) Effect: set -#define AT91C_TC_BSWTRG_CLEAR (0x2u << 30) // (TC) Effect: clear -#define AT91C_TC_BSWTRG_TOGGLE (0x3u << 30) // (TC) Effect: toggle -// -------- TC_SR : (TC Offset: 0x20) TC Channel Status Register -------- -#define AT91C_TC_COVFS (0x1u << 0) // (TC) Counter Overflow -#define AT91C_TC_LOVRS (0x1u << 1) // (TC) Load Overrun -#define AT91C_TC_CPAS (0x1u << 2) // (TC) RA Compare -#define AT91C_TC_CPBS (0x1u << 3) // (TC) RB Compare -#define AT91C_TC_CPCS (0x1u << 4) // (TC) RC Compare -#define AT91C_TC_LDRAS (0x1u << 5) // (TC) RA Loading -#define AT91C_TC_LDRBS (0x1u << 6) // (TC) RB Loading -#define AT91C_TC_ETRCS (0x1u << 7) // (TC) External Trigger -#define AT91C_TC_ETRGS (0x1u << 16) // (TC) Clock Enabling -#define AT91C_TC_MTIOA (0x1u << 17) // (TC) TIOA Mirror -#define AT91C_TC_MTIOB (0x1u << 18) // (TC) TIOA Mirror -// -------- TC_IER : (TC Offset: 0x24) TC Channel Interrupt Enable Register -------- -// -------- TC_IDR : (TC Offset: 0x28) TC Channel Interrupt Disable Register -------- -// -------- TC_IMR : (TC Offset: 0x2c) TC Channel Interrupt Mask Register -------- - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Timer Counter Interface -// ***************************************************************************** -typedef struct _AT91S_TCB { - AT91S_TC TCB_TC0; // TC Channel 0 - AT91_REG Reserved0[4]; // - AT91S_TC TCB_TC1; // TC Channel 1 - AT91_REG Reserved1[4]; // - AT91S_TC TCB_TC2; // TC Channel 2 - AT91_REG Reserved2[4]; // - AT91_REG TCB_BCR; // TC Block Control Register - AT91_REG TCB_BMR; // TC Block Mode Register -} AT91S_TCB, *AT91PS_TCB; - -// -------- TCB_BCR : (TCB Offset: 0xc0) TC Block Control Register -------- -#define AT91C_TCB_SYNC (0x1u << 0) // (TCB) Synchro Command -// -------- TCB_BMR : (TCB Offset: 0xc4) TC Block Mode Register -------- -#define AT91C_TCB_TC0XC0S (0x1u << 0) // (TCB) External Clock Signal 0 Selection -#define AT91C_TCB_TC0XC0S_TCLK0 0x0u // (TCB) TCLK0 connected to XC0 -#define AT91C_TCB_TC0XC0S_NONE 0x1u // (TCB) None signal connected to XC0 -#define AT91C_TCB_TC0XC0S_TIOA1 0x2u // (TCB) TIOA1 connected to XC0 -#define AT91C_TCB_TC0XC0S_TIOA2 0x3u // (TCB) TIOA2 connected to XC0 -#define AT91C_TCB_TC1XC1S (0x1u << 2) // (TCB) External Clock Signal 1 Selection -#define AT91C_TCB_TC1XC1S_TCLK1 (0x0u << 2) // (TCB) TCLK1 connected to XC1 -#define AT91C_TCB_TC1XC1S_NONE (0x1u << 2) // (TCB) None signal connected to XC1 -#define AT91C_TCB_TC1XC1S_TIOA0 (0x2u << 2) // (TCB) TIOA0 connected to XC1 -#define AT91C_TCB_TC1XC1S_TIOA2 (0x3u << 2) // (TCB) TIOA2 connected to XC1 -#define AT91C_TCB_TC2XC2S (0x1u << 4) // (TCB) External Clock Signal 2 Selection -#define AT91C_TCB_TC2XC2S_TCLK2 (0x0u << 4) // (TCB) TCLK2 connected to XC2 -#define AT91C_TCB_TC2XC2S_NONE (0x1u << 4) // (TCB) None signal connected to XC2 -#define AT91C_TCB_TC2XC2S_TIOA0 (0x2u << 4) // (TCB) TIOA0 connected to XC2 -#define AT91C_TCB_TC2XC2S_TIOA2 (0x3u << 4) // (TCB) TIOA2 connected to XC2 - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR USB Host Interface -// ***************************************************************************** -typedef struct _AT91S_UHP { - AT91_REG UHP_HcRevision; // Revision - AT91_REG UHP_HcControl; // Operating modes for the Host Controller - AT91_REG UHP_HcCommandStatus; // Command & status Register - AT91_REG UHP_HcInterruptStatus; // Interrupt Status Register - AT91_REG UHP_HcInterruptEnable; // Interrupt Enable Register - AT91_REG UHP_HcInterruptDisable; // Interrupt Disable Register - AT91_REG UHP_HcHCCA; // Pointer to the Host Controller Communication Area - AT91_REG UHP_HcPeriodCurrentED; // Current Isochronous or Interrupt Endpoint Descriptor - AT91_REG UHP_HcControlHeadED; // First Endpoint Descriptor of the Control list - AT91_REG UHP_HcControlCurrentED; // Endpoint Control and Status Register - AT91_REG UHP_HcBulkHeadED; // First endpoint register of the Bulk list - AT91_REG UHP_HcBulkCurrentED; // Current endpoint of the Bulk list - AT91_REG UHP_HcBulkDoneHead; // Last completed transfer descriptor - AT91_REG UHP_HcFmInterval; // Bit time between 2 consecutive SOFs - AT91_REG UHP_HcFmRemaining; // Bit time remaining in the current Frame - AT91_REG UHP_HcFmNumber; // Frame number - AT91_REG UHP_HcPeriodicStart; // Periodic Start - AT91_REG UHP_HcLSThreshold; // LS Threshold - AT91_REG UHP_HcRhDescriptorA; // Root Hub characteristics A - AT91_REG UHP_HcRhDescriptorB; // Root Hub characteristics B - AT91_REG UHP_HcRhStatus; // Root Hub Status register - AT91_REG UHP_HcRhPortStatus[2]; // Root Hub Port Status Register -} AT91S_UHP, *AT91PS_UHP; - - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Ethernet MAC -// ***************************************************************************** -typedef struct _AT91S_EMAC { - AT91_REG EMAC_CTL; // Network Control Register - AT91_REG EMAC_CFG; // Network Configuration Register - AT91_REG EMAC_SR; // Network Status Register - AT91_REG EMAC_TAR; // Transmit Address Register - AT91_REG EMAC_TCR; // Transmit Control Register - AT91_REG EMAC_TSR; // Transmit Status Register - AT91_REG EMAC_RBQP; // Receive Buffer Queue Pointer - AT91_REG Reserved0[1]; // - AT91_REG EMAC_RSR; // Receive Status Register - AT91_REG EMAC_ISR; // Interrupt Status Register - AT91_REG EMAC_IER; // Interrupt Enable Register - AT91_REG EMAC_IDR; // Interrupt Disable Register - AT91_REG EMAC_IMR; // Interrupt Mask Register - AT91_REG EMAC_MAN; // PHY Maintenance Register - AT91_REG Reserved1[2]; // - AT91_REG EMAC_FRA; // Frames Transmitted OK Register - AT91_REG EMAC_SCOL; // Single Collision Frame Register - AT91_REG EMAC_MCOL; // Multiple Collision Frame Register - AT91_REG EMAC_OK; // Frames Received OK Register - AT91_REG EMAC_SEQE; // Frame Check Sequence Error Register - AT91_REG EMAC_ALE; // Alignment Error Register - AT91_REG EMAC_DTE; // Deferred Transmission Frame Register - AT91_REG EMAC_LCOL; // Late Collision Register - AT91_REG EMAC_ECOL; // Excessive Collision Register - AT91_REG EMAC_CSE; // Carrier Sense Error Register - AT91_REG EMAC_TUE; // Transmit Underrun Error Register - AT91_REG EMAC_CDE; // Code Error Register - AT91_REG EMAC_ELR; // Excessive Length Error Register - AT91_REG EMAC_RJB; // Receive Jabber Register - AT91_REG EMAC_USF; // Undersize Frame Register - AT91_REG EMAC_SQEE; // SQE Test Error Register - AT91_REG EMAC_DRFC; // Discarded RX Frame Register - AT91_REG Reserved2[3]; // - AT91_REG EMAC_HSH; // Hash Address High[63:32] - AT91_REG EMAC_HSL; // Hash Address Low[31:0] - AT91_REG EMAC_SA1L; // Specific Address 1 Low, First 4 bytes - AT91_REG EMAC_SA1H; // Specific Address 1 High, Last 2 bytes - AT91_REG EMAC_SA2L; // Specific Address 2 Low, First 4 bytes - AT91_REG EMAC_SA2H; // Specific Address 2 High, Last 2 bytes - AT91_REG EMAC_SA3L; // Specific Address 3 Low, First 4 bytes - AT91_REG EMAC_SA3H; // Specific Address 3 High, Last 2 bytes - AT91_REG EMAC_SA4L; // Specific Address 4 Low, First 4 bytes - AT91_REG EMAC_SA4H; // Specific Address 4 High, Last 2 bytesr -} AT91S_EMAC, *AT91PS_EMAC; - -// -------- EMAC_CTL : (EMAC Offset: 0x0) -------- -#define AT91C_EMAC_LB (0x1u << 0) // (EMAC) Loopback. Optional. When set, loopback signal is at high level. -#define AT91C_EMAC_LBL (0x1u << 1) // (EMAC) Loopback local. -#define AT91C_EMAC_RE (0x1u << 2) // (EMAC) Receive enable. -#define AT91C_EMAC_TE (0x1u << 3) // (EMAC) Transmit enable. -#define AT91C_EMAC_MPE (0x1u << 4) // (EMAC) Management port enable. -#define AT91C_EMAC_CSR (0x1u << 5) // (EMAC) Clear statistics registers. -#define AT91C_EMAC_ISR (0x1u << 6) // (EMAC) Increment statistics registers. -#define AT91C_EMAC_WES (0x1u << 7) // (EMAC) Write enable for statistics registers. -#define AT91C_EMAC_BP (0x1u << 8) // (EMAC) Back pressure. -// -------- EMAC_CFG : (EMAC Offset: 0x4) Network Configuration Register -------- -#define AT91C_EMAC_SPD (0x1u << 0) // (EMAC) Speed. -#define AT91C_EMAC_FD (0x1u << 1) // (EMAC) Full duplex. -#define AT91C_EMAC_BR (0x1u << 2) // (EMAC) Bit rate. -#define AT91C_EMAC_CAF (0x1u << 4) // (EMAC) Copy all frames. -#define AT91C_EMAC_NBC (0x1u << 5) // (EMAC) No broadcast. -#define AT91C_EMAC_MTI (0x1u << 6) // (EMAC) Multicast hash enable -#define AT91C_EMAC_UNI (0x1u << 7) // (EMAC) Unicast hash enable. -#define AT91C_EMAC_BIG (0x1u << 8) // (EMAC) Receive 1522 bytes. -#define AT91C_EMAC_EAE (0x1u << 9) // (EMAC) External address match enable. -#define AT91C_EMAC_CLK (0x3u << 10) // (EMAC) -#define AT91C_EMAC_CLK_HCLK_8 (0x0u << 10) // (EMAC) HCLK divided by 8 -#define AT91C_EMAC_CLK_HCLK_16 (0x1u << 10) // (EMAC) HCLK divided by 16 -#define AT91C_EMAC_CLK_HCLK_32 (0x2u << 10) // (EMAC) HCLK divided by 32 -#define AT91C_EMAC_CLK_HCLK_64 (0x3u << 10) // (EMAC) HCLK divided by 64 -#define AT91C_EMAC_RTY (0x1u << 12) // (EMAC) -#define AT91C_EMAC_RMII (0x1u << 13) // (EMAC) -// -------- EMAC_SR : (EMAC Offset: 0x8) Network Status Register -------- -#define AT91C_EMAC_MDIO (0x1u << 1) // (EMAC) -#define AT91C_EMAC_IDLE (0x1u << 2) // (EMAC) -// -------- EMAC_TCR : (EMAC Offset: 0x10) Transmit Control Register -------- -#define AT91C_EMAC_LEN (0x7FFu << 0) // (EMAC) -#define AT91C_EMAC_NCRC (0x1u << 15) // (EMAC) -// -------- EMAC_TSR : (EMAC Offset: 0x14) Transmit Control Register -------- -#define AT91C_EMAC_OVR (0x1u << 0) // (EMAC) -#define AT91C_EMAC_COL (0x1u << 1) // (EMAC) -#define AT91C_EMAC_RLE (0x1u << 2) // (EMAC) -#define AT91C_EMAC_TXIDLE (0x1u << 3) // (EMAC) -#define AT91C_EMAC_BNQ (0x1u << 4) // (EMAC) -#define AT91C_EMAC_COMP (0x1u << 5) // (EMAC) -#define AT91C_EMAC_UND (0x1u << 6) // (EMAC) -// -------- EMAC_RSR : (EMAC Offset: 0x20) Receive Status Register -------- -#define AT91C_EMAC_BNA (0x1u << 0) // (EMAC) -#define AT91C_EMAC_REC (0x1u << 1) // (EMAC) -// -------- EMAC_ISR : (EMAC Offset: 0x24) Interrupt Status Register -------- -#define AT91C_EMAC_DONE (0x1u << 0) // (EMAC) -#define AT91C_EMAC_RCOM (0x1u << 1) // (EMAC) -#define AT91C_EMAC_RBNA (0x1u << 2) // (EMAC) -#define AT91C_EMAC_TOVR (0x1u << 3) // (EMAC) -#define AT91C_EMAC_TUND (0x1u << 4) // (EMAC) -#define AT91C_EMAC_RTRY (0x1u << 5) // (EMAC) -#define AT91C_EMAC_TBRE (0x1u << 6) // (EMAC) -#define AT91C_EMAC_TCOM (0x1u << 7) // (EMAC) -#define AT91C_EMAC_TIDLE (0x1u << 8) // (EMAC) -#define AT91C_EMAC_LINK (0x1u << 9) // (EMAC) -#define AT91C_EMAC_ROVR (0x1u << 10) // (EMAC) -#define AT91C_EMAC_HRESP (0x1u << 11) // (EMAC) -// -------- EMAC_IER : (EMAC Offset: 0x28) Interrupt Enable Register -------- -// -------- EMAC_IDR : (EMAC Offset: 0x2c) Interrupt Disable Register -------- -// -------- EMAC_IMR : (EMAC Offset: 0x30) Interrupt Mask Register -------- -// -------- EMAC_MAN : (EMAC Offset: 0x34) PHY Maintenance Register -------- -#define AT91C_EMAC_DATA (0xFFFFu << 0) // (EMAC) -#define AT91C_EMAC_CODE (0x3u << 16) // (EMAC) -#define AT91C_EMAC_REGA (0x1Fu << 18) // (EMAC) -#define AT91C_EMAC_PHYA (0x1Fu << 23) // (EMAC) -#define AT91C_EMAC_RW (0x3u << 28) // (EMAC) -#define AT91C_EMAC_HIGH (0x1u << 30) // (EMAC) -#define AT91C_EMAC_LOW (0x1u << 31) // (EMAC) - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR External Bus Interface -// ***************************************************************************** -typedef struct _AT91S_EBI { - AT91_REG EBI_CSA; // Chip Select Assignment Register - AT91_REG EBI_CFGR; // Configuration Register -} AT91S_EBI, *AT91PS_EBI; - -// -------- EBI_CSA : (EBI Offset: 0x0) Chip Select Assignment Register -------- -#define AT91C_EBI_CS0A (0x1u << 0) // (EBI) Chip Select 0 Assignment -#define AT91C_EBI_CS0A_SMC 0x0u // (EBI) Chip Select 0 is assigned to the Static Memory Controller. -#define AT91C_EBI_CS0A_BFC 0x1u // (EBI) Chip Select 0 is assigned to the Burst Flash Controller. -#define AT91C_EBI_CS1A (0x1u << 1) // (EBI) Chip Select 1 Assignment -#define AT91C_EBI_CS1A_SMC (0x0u << 1) // (EBI) Chip Select 1 is assigned to the Static Memory Controller. -#define AT91C_EBI_CS1A_SDRAMC (0x1u << 1) // (EBI) Chip Select 1 is assigned to the SDRAM Controller. -#define AT91C_EBI_CS3A (0x1u << 3) // (EBI) Chip Select 3 Assignment -#define AT91C_EBI_CS3A_SMC (0x0u << 3) // (EBI) Chip Select 3 is only assigned to the Static Memory Controller and NCS3 behaves as defined by the SMC2. -#define AT91C_EBI_CS3A_SMC_SmartMedia (0x1u << 3) // (EBI) Chip Select 3 is assigned to the Static Memory Controller and the SmartMedia Logic is activated. -#define AT91C_EBI_CS4A (0x1u << 4) // (EBI) Chip Select 4 Assignment -#define AT91C_EBI_CS4A_SMC (0x0u << 4) // (EBI) Chip Select 4 is assigned to the Static Memory Controller and NCS4,NCS5 and NCS6 behave as defined by the SMC2. -#define AT91C_EBI_CS4A_SMC_CompactFlash (0x1u << 4) // (EBI) Chip Select 4 is assigned to the Static Memory Controller and the CompactFlash Logic is activated. -// -------- EBI_CFGR : (EBI Offset: 0x4) Configuration Register -------- -#define AT91C_EBI_DBPUC (0x1u << 0) // (EBI) Data Bus Pull-Up Configuration -#define AT91C_EBI_EBSEN (0x1u << 1) // (EBI) Bus Sharing Enable - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Static Memory Controller 2 Interface -// ***************************************************************************** -typedef struct _AT91S_SMC2 { - AT91_REG SMC2_CSR[8]; // SMC2 Chip Select Register -} AT91S_SMC2, *AT91PS_SMC2; - -// -------- SMC2_CSR : (SMC2 Offset: 0x0) SMC2 Chip Select Register -------- -#define AT91C_SMC2_NWS (0x7Fu << 0) // (SMC2) Number of Wait States -#define AT91C_SMC2_WSEN (0x1u << 7) // (SMC2) Wait State Enable -#define AT91C_SMC2_TDF (0xFu << 8) // (SMC2) Data Float Time -#define AT91C_SMC2_BAT (0x1u << 12) // (SMC2) Byte Access Type -#define AT91C_SMC2_DBW (0x1u << 13) // (SMC2) Data Bus Width -#define AT91C_SMC2_DBW_16 (0x1u << 13) // (SMC2) 16-bit. -#define AT91C_SMC2_DBW_8 (0x2u << 13) // (SMC2) 8-bit. -#define AT91C_SMC2_DRP (0x1u << 15) // (SMC2) Data Read Protocol -#define AT91C_SMC2_ACSS (0x3u << 16) // (SMC2) Address to Chip Select Setup -#define AT91C_SMC2_ACSS_STANDARD (0x0u << 16) // (SMC2) Standard, asserted at the beginning of the access and deasserted at the end. -#define AT91C_SMC2_ACSS_1_CYCLE (0x1u << 16) // (SMC2) One cycle less at the beginning and the end of the access. -#define AT91C_SMC2_ACSS_2_CYCLES (0x2u << 16) // (SMC2) Two cycles less at the beginning and the end of the access. -#define AT91C_SMC2_ACSS_3_CYCLES (0x3u << 16) // (SMC2) Three cycles less at the beginning and the end of the access. -#define AT91C_SMC2_RWSETUP (0x7u << 24) // (SMC2) Read and Write Signal Setup Time -#define AT91C_SMC2_RWHOLD (0x7u << 29) // (SMC2) Read and Write Signal Hold Time - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR SDRAM Controller Interface -// ***************************************************************************** -typedef struct _AT91S_SDRC { - AT91_REG SDRC_MR; // SDRAM Controller Mode Register - AT91_REG SDRC_TR; // SDRAM Controller Refresh Timer Register - AT91_REG SDRC_CR; // SDRAM Controller Configuration Register - AT91_REG SDRC_SRR; // SDRAM Controller Self Refresh Register - AT91_REG SDRC_LPR; // SDRAM Controller Low Power Register - AT91_REG SDRC_IER; // SDRAM Controller Interrupt Enable Register - AT91_REG SDRC_IDR; // SDRAM Controller Interrupt Disable Register - AT91_REG SDRC_IMR; // SDRAM Controller Interrupt Mask Register - AT91_REG SDRC_ISR; // SDRAM Controller Interrupt Mask Register -} AT91S_SDRC, *AT91PS_SDRC; - -// -------- SDRC_MR : (SDRC Offset: 0x0) SDRAM Controller Mode Register -------- -#define AT91C_SDRC_MODE (0xFu << 0) // (SDRC) Mode -#define AT91C_SDRC_MODE_NORMAL_CMD 0x0u // (SDRC) Normal Mode -#define AT91C_SDRC_MODE_NOP_CMD 0x1u // (SDRC) NOP Command -#define AT91C_SDRC_MODE_PRCGALL_CMD 0x2u // (SDRC) All Banks Precharge Command -#define AT91C_SDRC_MODE_LMR_CMD 0x3u // (SDRC) Load Mode Register Command -#define AT91C_SDRC_MODE_RFSH_CMD 0x4u // (SDRC) Refresh Command -#define AT91C_SDRC_DBW (0x1u << 4) // (SDRC) Data Bus Width -#define AT91C_SDRC_DBW_32_BITS (0x0u << 4) // (SDRC) 32 Bits datas bus -#define AT91C_SDRC_DBW_16_BITS (0x1u << 4) // (SDRC) 16 Bits datas bus -// -------- SDRC_TR : (SDRC Offset: 0x4) SDRC Refresh Timer Register -------- -#define AT91C_SDRC_COUNT (0xFFFu << 0) // (SDRC) Refresh Counter -// -------- SDRC_CR : (SDRC Offset: 0x8) SDRAM Configuration Register -------- -#define AT91C_SDRC_NC (0x3u << 0) // (SDRC) Number of Column Bits -#define AT91C_SDRC_NC_8 0x0u // (SDRC) 8 Bits -#define AT91C_SDRC_NC_9 0x1u // (SDRC) 9 Bits -#define AT91C_SDRC_NC_10 0x2u // (SDRC) 10 Bits -#define AT91C_SDRC_NC_11 0x3u // (SDRC) 11 Bits -#define AT91C_SDRC_NR (0x3u << 2) // (SDRC) Number of Row Bits -#define AT91C_SDRC_NR_11 (0x0u << 2) // (SDRC) 11 Bits -#define AT91C_SDRC_NR_12 (0x1u << 2) // (SDRC) 12 Bits -#define AT91C_SDRC_NR_13 (0x2u << 2) // (SDRC) 13 Bits -#define AT91C_SDRC_NB (0x1u << 4) // (SDRC) Number of Banks -#define AT91C_SDRC_NB_2_BANKS (0x0u << 4) // (SDRC) 2 banks -#define AT91C_SDRC_NB_4_BANKS (0x1u << 4) // (SDRC) 4 banks -#define AT91C_SDRC_CAS (0x3u << 5) // (SDRC) CAS Latency -#define AT91C_SDRC_CAS_2 (0x2u << 5) // (SDRC) 2 cycles -#define AT91C_SDRC_TWR (0xFu << 7) // (SDRC) Number of Write Recovery Time Cycles -#define AT91C_SDRC_TRC (0xFu << 11) // (SDRC) Number of RAS Cycle Time Cycles -#define AT91C_SDRC_TRP (0xFu << 15) // (SDRC) Number of RAS Precharge Time Cycles -#define AT91C_SDRC_TRCD (0xFu << 19) // (SDRC) Number of RAS to CAS Delay Cycles -#define AT91C_SDRC_TRAS (0xFu << 23) // (SDRC) Number of RAS Active Time Cycles -#define AT91C_SDRC_TXSR (0xFu << 27) // (SDRC) Number of Command Recovery Time Cycles -// -------- SDRC_SRR : (SDRC Offset: 0xc) SDRAM Controller Self-refresh Register -------- -#define AT91C_SDRC_SRCB (0x1u << 0) // (SDRC) Self-refresh Command Bit -// -------- SDRC_LPR : (SDRC Offset: 0x10) SDRAM Controller Low-power Register -------- -#define AT91C_SDRC_LPCB (0x1u << 0) // (SDRC) Low-power Command Bit -// -------- SDRC_IER : (SDRC Offset: 0x14) SDRAM Controller Interrupt Enable Register -------- -#define AT91C_SDRC_RES (0x1u << 0) // (SDRC) Refresh Error Status -// -------- SDRC_IDR : (SDRC Offset: 0x18) SDRAM Controller Interrupt Disable Register -------- -// -------- SDRC_IMR : (SDRC Offset: 0x1c) SDRAM Controller Interrupt Mask Register -------- -// -------- SDRC_ISR : (SDRC Offset: 0x20) SDRAM Controller Interrupt Status Register -------- - -// ***************************************************************************** -// SOFTWARE API DEFINITION FOR Burst Flash Controller Interface -// ***************************************************************************** -typedef struct _AT91S_BFC { - AT91_REG BFC_MR; // BFC Mode Register -} AT91S_BFC, *AT91PS_BFC; - -// -------- BFC_MR : (BFC Offset: 0x0) BFC Mode Register -------- -#define AT91C_BFC_BFCOM (0x3u << 0) // (BFC) Burst Flash Controller Operating Mode -#define AT91C_BFC_BFCOM_DISABLED 0x0u // (BFC) NPCS0 is driven by the SMC or remains high. -#define AT91C_BFC_BFCOM_ASYNC 0x1u // (BFC) Asynchronous -#define AT91C_BFC_BFCOM_BURST_READ 0x2u // (BFC) Burst Read -#define AT91C_BFC_BFCC (0x3u << 2) // (BFC) Burst Flash Controller Operating Mode -#define AT91C_BFC_BFCC_MCK (0x1u << 2) // (BFC) Master Clock. -#define AT91C_BFC_BFCC_MCK_DIV_2 (0x2u << 2) // (BFC) Master Clock divided by 2. -#define AT91C_BFC_BFCC_MCK_DIV_4 (0x3u << 2) // (BFC) Master Clock divided by 4. -#define AT91C_BFC_AVL (0xFu << 4) // (BFC) Address Valid Latency -#define AT91C_BFC_PAGES (0x7u << 8) // (BFC) Page Size -#define AT91C_BFC_PAGES_NO_PAGE (0x0u << 8) // (BFC) No page handling. -#define AT91C_BFC_PAGES_16 (0x1u << 8) // (BFC) 16 bytes page size. -#define AT91C_BFC_PAGES_32 (0x2u << 8) // (BFC) 32 bytes page size. -#define AT91C_BFC_PAGES_64 (0x3u << 8) // (BFC) 64 bytes page size. -#define AT91C_BFC_PAGES_128 (0x4u << 8) // (BFC) 128 bytes page size. -#define AT91C_BFC_PAGES_256 (0x5u << 8) // (BFC) 256 bytes page size. -#define AT91C_BFC_PAGES_512 (0x6u << 8) // (BFC) 512 bytes page size. -#define AT91C_BFC_PAGES_1024 (0x7u << 8) // (BFC) 1024 bytes page size. -#define AT91C_BFC_OEL (0x3u << 12) // (BFC) Output Enable Latency -#define AT91C_BFC_BAAEN (0x1u << 16) // (BFC) Burst Address Advance Enable -#define AT91C_BFC_BFOEH (0x1u << 17) // (BFC) Burst Flash Output Enable Handling -#define AT91C_BFC_MUXEN (0x1u << 18) // (BFC) Multiplexed Bus Enable -#define AT91C_BFC_RDYEN (0x1u << 19) // (BFC) Ready Enable Mode - -// ***************************************************************************** -// REGISTER ADDRESS DEFINITION FOR AT91RM9200 -// ***************************************************************************** -// ========== Register definition for SYS peripheral ========== -// ========== Register definition for MC peripheral ========== -#define AT91C_MC_PUER ((AT91_REG *) 0xFFFFFF54) // (MC) MC Protection Unit Enable Register -#define AT91C_MC_ASR ((AT91_REG *) 0xFFFFFF04) // (MC) MC Abort Status Register -#define AT91C_MC_PUP ((AT91_REG *) 0xFFFFFF50) // (MC) MC Protection Unit Peripherals -#define AT91C_MC_PUIA ((AT91_REG *) 0xFFFFFF10) // (MC) MC Protection Unit Area -#define AT91C_MC_AASR ((AT91_REG *) 0xFFFFFF08) // (MC) MC Abort Address Status Register -#define AT91C_MC_RCR ((AT91_REG *) 0xFFFFFF00) // (MC) MC Remap Control Register -// ========== Register definition for RTC peripheral ========== -#define AT91C_RTC_IMR ((AT91_REG *) 0xFFFFFE28) // (RTC) Interrupt Mask Register -#define AT91C_RTC_IER ((AT91_REG *) 0xFFFFFE20) // (RTC) Interrupt Enable Register -#define AT91C_RTC_SR ((AT91_REG *) 0xFFFFFE18) // (RTC) Status Register -#define AT91C_RTC_TIMALR ((AT91_REG *) 0xFFFFFE10) // (RTC) Time Alarm Register -#define AT91C_RTC_TIMR ((AT91_REG *) 0xFFFFFE08) // (RTC) Time Register -#define AT91C_RTC_CR ((AT91_REG *) 0xFFFFFE00) // (RTC) Control Register -#define AT91C_RTC_VER ((AT91_REG *) 0xFFFFFE2C) // (RTC) Valid Entry Register -#define AT91C_RTC_IDR ((AT91_REG *) 0xFFFFFE24) // (RTC) Interrupt Disable Register -#define AT91C_RTC_SCCR ((AT91_REG *) 0xFFFFFE1C) // (RTC) Status Clear Command Register -#define AT91C_RTC_CALALR ((AT91_REG *) 0xFFFFFE14) // (RTC) Calendar Alarm Register -#define AT91C_RTC_CALR ((AT91_REG *) 0xFFFFFE0C) // (RTC) Calendar Register -#define AT91C_RTC_MR ((AT91_REG *) 0xFFFFFE04) // (RTC) Mode Register -// ========== Register definition for ST peripheral ========== -#define AT91C_ST_CRTR ((AT91_REG *) 0xFFFFFD24) // (ST) Current Real-time Register -#define AT91C_ST_IMR ((AT91_REG *) 0xFFFFFD1C) // (ST) Interrupt Mask Register -#define AT91C_ST_IER ((AT91_REG *) 0xFFFFFD14) // (ST) Interrupt Enable Register -#define AT91C_ST_RTMR ((AT91_REG *) 0xFFFFFD0C) // (ST) Real-time Mode Register -#define AT91C_ST_PIMR ((AT91_REG *) 0xFFFFFD04) // (ST) Period Interval Mode Register -#define AT91C_ST_RTAR ((AT91_REG *) 0xFFFFFD20) // (ST) Real-time Alarm Register -#define AT91C_ST_IDR ((AT91_REG *) 0xFFFFFD18) // (ST) Interrupt Disable Register -#define AT91C_ST_SR ((AT91_REG *) 0xFFFFFD10) // (ST) Status Register -#define AT91C_ST_WDMR ((AT91_REG *) 0xFFFFFD08) // (ST) Watchdog Mode Register -#define AT91C_ST_CR ((AT91_REG *) 0xFFFFFD00) // (ST) Control Register -// ========== Register definition for PMC peripheral ========== -#define AT91C_PMC_SCSR ((AT91_REG *) 0xFFFFFC08) // (PMC) System Clock Status Register -#define AT91C_PMC_SCER ((AT91_REG *) 0xFFFFFC00) // (PMC) System Clock Enable Register -#define AT91C_PMC_IMR ((AT91_REG *) 0xFFFFFC6C) // (PMC) Interrupt Mask Register -#define AT91C_PMC_IDR ((AT91_REG *) 0xFFFFFC64) // (PMC) Interrupt Disable Register -#define AT91C_PMC_PCDR ((AT91_REG *) 0xFFFFFC14) // (PMC) Peripheral Clock Disable Register -#define AT91C_PMC_SCDR ((AT91_REG *) 0xFFFFFC04) // (PMC) System Clock Disable Register -#define AT91C_PMC_SR ((AT91_REG *) 0xFFFFFC68) // (PMC) Status Register -#define AT91C_PMC_IER ((AT91_REG *) 0xFFFFFC60) // (PMC) Interrupt Enable Register -#define AT91C_PMC_MCKR ((AT91_REG *) 0xFFFFFC30) // (PMC) Master Clock Register -#define AT91C_PMC_PCER ((AT91_REG *) 0xFFFFFC10) // (PMC) Peripheral Clock Enable Register -#define AT91C_PMC_PCSR ((AT91_REG *) 0xFFFFFC18) // (PMC) Peripheral Clock Status Register -#define AT91C_PMC_PCKR ((AT91_REG *) 0xFFFFFC40) // (PMC) Programmable Clock Register -// ========== Register definition for CKGR peripheral ========== -#define AT91C_CKGR_PLLBR ((AT91_REG *) 0xFFFFFC2C) // (CKGR) PLL B Register -#define AT91C_CKGR_MCFR ((AT91_REG *) 0xFFFFFC24) // (CKGR) Main Clock Frequency Register -#define AT91C_CKGR_PLLAR ((AT91_REG *) 0xFFFFFC28) // (CKGR) PLL A Register -#define AT91C_CKGR_MOR ((AT91_REG *) 0xFFFFFC20) // (CKGR) Main Oscillator Register -// ========== Register definition for PIOD peripheral ========== -#define AT91C_PIOD_PDSR ((AT91_REG *) 0xFFFFFA3C) // (PIOD) Pin Data Status Register -#define AT91C_PIOD_CODR ((AT91_REG *) 0xFFFFFA34) // (PIOD) Clear Output Data Register -#define AT91C_PIOD_OWER ((AT91_REG *) 0xFFFFFAA0) // (PIOD) Output Write Enable Register -#define AT91C_PIOD_MDER ((AT91_REG *) 0xFFFFFA50) // (PIOD) Multi-driver Enable Register -#define AT91C_PIOD_IMR ((AT91_REG *) 0xFFFFFA48) // (PIOD) Interrupt Mask Register -#define AT91C_PIOD_IER ((AT91_REG *) 0xFFFFFA40) // (PIOD) Interrupt Enable Register -#define AT91C_PIOD_ODSR ((AT91_REG *) 0xFFFFFA38) // (PIOD) Output Data Status Register -#define AT91C_PIOD_SODR ((AT91_REG *) 0xFFFFFA30) // (PIOD) Set Output Data Register -#define AT91C_PIOD_PER ((AT91_REG *) 0xFFFFFA00) // (PIOD) PIO Enable Register -#define AT91C_PIOD_OWDR ((AT91_REG *) 0xFFFFFAA4) // (PIOD) Output Write Disable Register -#define AT91C_PIOD_PPUER ((AT91_REG *) 0xFFFFFA64) // (PIOD) Pull-up Enable Register -#define AT91C_PIOD_MDDR ((AT91_REG *) 0xFFFFFA54) // (PIOD) Multi-driver Disable Register -#define AT91C_PIOD_ISR ((AT91_REG *) 0xFFFFFA4C) // (PIOD) Interrupt Status Register -#define AT91C_PIOD_IDR ((AT91_REG *) 0xFFFFFA44) // (PIOD) Interrupt Disable Register -#define AT91C_PIOD_PDR ((AT91_REG *) 0xFFFFFA04) // (PIOD) PIO Disable Register -#define AT91C_PIOD_ODR ((AT91_REG *) 0xFFFFFA14) // (PIOD) Output Disable Registerr -#define AT91C_PIOD_OWSR ((AT91_REG *) 0xFFFFFAA8) // (PIOD) Output Write Status Register -#define AT91C_PIOD_ABSR ((AT91_REG *) 0xFFFFFA78) // (PIOD) AB Select Status Register -#define AT91C_PIOD_ASR ((AT91_REG *) 0xFFFFFA70) // (PIOD) Select A Register -#define AT91C_PIOD_PPUSR ((AT91_REG *) 0xFFFFFA68) // (PIOD) Pad Pull-up Status Register -#define AT91C_PIOD_PPUDR ((AT91_REG *) 0xFFFFFA60) // (PIOD) Pull-up Disable Register -#define AT91C_PIOD_MDSR ((AT91_REG *) 0xFFFFFA58) // (PIOD) Multi-driver Status Register -#define AT91C_PIOD_PSR ((AT91_REG *) 0xFFFFFA08) // (PIOD) PIO Status Register -#define AT91C_PIOD_OER ((AT91_REG *) 0xFFFFFA10) // (PIOD) Output Enable Register -#define AT91C_PIOD_OSR ((AT91_REG *) 0xFFFFFA18) // (PIOD) Output Status Register -#define AT91C_PIOD_IFER ((AT91_REG *) 0xFFFFFA20) // (PIOD) Input Filter Enable Register -#define AT91C_PIOD_BSR ((AT91_REG *) 0xFFFFFA74) // (PIOD) Select B Register -#define AT91C_PIOD_IFDR ((AT91_REG *) 0xFFFFFA24) // (PIOD) Input Filter Disable Register -#define AT91C_PIOD_IFSR ((AT91_REG *) 0xFFFFFA28) // (PIOD) Input Filter Status Register -// ========== Register definition for PIOC peripheral ========== -#define AT91C_PIOC_IFDR ((AT91_REG *) 0xFFFFF824) // (PIOC) Input Filter Disable Register -#define AT91C_PIOC_ODR ((AT91_REG *) 0xFFFFF814) // (PIOC) Output Disable Registerr -#define AT91C_PIOC_ABSR ((AT91_REG *) 0xFFFFF878) // (PIOC) AB Select Status Register -#define AT91C_PIOC_SODR ((AT91_REG *) 0xFFFFF830) // (PIOC) Set Output Data Register -#define AT91C_PIOC_IFSR ((AT91_REG *) 0xFFFFF828) // (PIOC) Input Filter Status Register -#define AT91C_PIOC_CODR ((AT91_REG *) 0xFFFFF834) // (PIOC) Clear Output Data Register -#define AT91C_PIOC_ODSR ((AT91_REG *) 0xFFFFF838) // (PIOC) Output Data Status Register -#define AT91C_PIOC_IER ((AT91_REG *) 0xFFFFF840) // (PIOC) Interrupt Enable Register -#define AT91C_PIOC_IMR ((AT91_REG *) 0xFFFFF848) // (PIOC) Interrupt Mask Register -#define AT91C_PIOC_OWDR ((AT91_REG *) 0xFFFFF8A4) // (PIOC) Output Write Disable Register -#define AT91C_PIOC_MDDR ((AT91_REG *) 0xFFFFF854) // (PIOC) Multi-driver Disable Register -#define AT91C_PIOC_PDSR ((AT91_REG *) 0xFFFFF83C) // (PIOC) Pin Data Status Register -#define AT91C_PIOC_IDR ((AT91_REG *) 0xFFFFF844) // (PIOC) Interrupt Disable Register -#define AT91C_PIOC_ISR ((AT91_REG *) 0xFFFFF84C) // (PIOC) Interrupt Status Register -#define AT91C_PIOC_PDR ((AT91_REG *) 0xFFFFF804) // (PIOC) PIO Disable Register -#define AT91C_PIOC_OWSR ((AT91_REG *) 0xFFFFF8A8) // (PIOC) Output Write Status Register -#define AT91C_PIOC_OWER ((AT91_REG *) 0xFFFFF8A0) // (PIOC) Output Write Enable Register -#define AT91C_PIOC_ASR ((AT91_REG *) 0xFFFFF870) // (PIOC) Select A Register -#define AT91C_PIOC_PPUSR ((AT91_REG *) 0xFFFFF868) // (PIOC) Pad Pull-up Status Register -#define AT91C_PIOC_PPUDR ((AT91_REG *) 0xFFFFF860) // (PIOC) Pull-up Disable Register -#define AT91C_PIOC_MDSR ((AT91_REG *) 0xFFFFF858) // (PIOC) Multi-driver Status Register -#define AT91C_PIOC_MDER ((AT91_REG *) 0xFFFFF850) // (PIOC) Multi-driver Enable Register -#define AT91C_PIOC_IFER ((AT91_REG *) 0xFFFFF820) // (PIOC) Input Filter Enable Register -#define AT91C_PIOC_OSR ((AT91_REG *) 0xFFFFF818) // (PIOC) Output Status Register -#define AT91C_PIOC_OER ((AT91_REG *) 0xFFFFF810) // (PIOC) Output Enable Register -#define AT91C_PIOC_PSR ((AT91_REG *) 0xFFFFF808) // (PIOC) PIO Status Register -#define AT91C_PIOC_PER ((AT91_REG *) 0xFFFFF800) // (PIOC) PIO Enable Register -#define AT91C_PIOC_BSR ((AT91_REG *) 0xFFFFF874) // (PIOC) Select B Register -#define AT91C_PIOC_PPUER ((AT91_REG *) 0xFFFFF864) // (PIOC) Pull-up Enable Register -// ========== Register definition for PIOB peripheral ========== -#define AT91C_PIOB_OWSR ((AT91_REG *) 0xFFFFF6A8) // (PIOB) Output Write Status Register -#define AT91C_PIOB_PPUSR ((AT91_REG *) 0xFFFFF668) // (PIOB) Pad Pull-up Status Register -#define AT91C_PIOB_PPUDR ((AT91_REG *) 0xFFFFF660) // (PIOB) Pull-up Disable Register -#define AT91C_PIOB_MDSR ((AT91_REG *) 0xFFFFF658) // (PIOB) Multi-driver Status Register -#define AT91C_PIOB_MDER ((AT91_REG *) 0xFFFFF650) // (PIOB) Multi-driver Enable Register -#define AT91C_PIOB_IMR ((AT91_REG *) 0xFFFFF648) // (PIOB) Interrupt Mask Register -#define AT91C_PIOB_OSR ((AT91_REG *) 0xFFFFF618) // (PIOB) Output Status Register -#define AT91C_PIOB_OER ((AT91_REG *) 0xFFFFF610) // (PIOB) Output Enable Register -#define AT91C_PIOB_PSR ((AT91_REG *) 0xFFFFF608) // (PIOB) PIO Status Register -#define AT91C_PIOB_PER ((AT91_REG *) 0xFFFFF600) // (PIOB) PIO Enable Register -#define AT91C_PIOB_BSR ((AT91_REG *) 0xFFFFF674) // (PIOB) Select B Register -#define AT91C_PIOB_PPUER ((AT91_REG *) 0xFFFFF664) // (PIOB) Pull-up Enable Register -#define AT91C_PIOB_IFDR ((AT91_REG *) 0xFFFFF624) // (PIOB) Input Filter Disable Register -#define AT91C_PIOB_ODR ((AT91_REG *) 0xFFFFF614) // (PIOB) Output Disable Registerr -#define AT91C_PIOB_ABSR ((AT91_REG *) 0xFFFFF678) // (PIOB) AB Select Status Register -#define AT91C_PIOB_ASR ((AT91_REG *) 0xFFFFF670) // (PIOB) Select A Register -#define AT91C_PIOB_IFER ((AT91_REG *) 0xFFFFF620) // (PIOB) Input Filter Enable Register -#define AT91C_PIOB_IFSR ((AT91_REG *) 0xFFFFF628) // (PIOB) Input Filter Status Register -#define AT91C_PIOB_SODR ((AT91_REG *) 0xFFFFF630) // (PIOB) Set Output Data Register -#define AT91C_PIOB_ODSR ((AT91_REG *) 0xFFFFF638) // (PIOB) Output Data Status Register -#define AT91C_PIOB_CODR ((AT91_REG *) 0xFFFFF634) // (PIOB) Clear Output Data Register -#define AT91C_PIOB_PDSR ((AT91_REG *) 0xFFFFF63C) // (PIOB) Pin Data Status Register -#define AT91C_PIOB_OWER ((AT91_REG *) 0xFFFFF6A0) // (PIOB) Output Write Enable Register -#define AT91C_PIOB_IER ((AT91_REG *) 0xFFFFF640) // (PIOB) Interrupt Enable Register -#define AT91C_PIOB_OWDR ((AT91_REG *) 0xFFFFF6A4) // (PIOB) Output Write Disable Register -#define AT91C_PIOB_MDDR ((AT91_REG *) 0xFFFFF654) // (PIOB) Multi-driver Disable Register -#define AT91C_PIOB_ISR ((AT91_REG *) 0xFFFFF64C) // (PIOB) Interrupt Status Register -#define AT91C_PIOB_IDR ((AT91_REG *) 0xFFFFF644) // (PIOB) Interrupt Disable Register -#define AT91C_PIOB_PDR ((AT91_REG *) 0xFFFFF604) // (PIOB) PIO Disable Register -// ========== Register definition for PIOA peripheral ========== -#define AT91C_PIOA_IMR ((AT91_REG *) 0xFFFFF448) // (PIOA) Interrupt Mask Register -#define AT91C_PIOA_IER ((AT91_REG *) 0xFFFFF440) // (PIOA) Interrupt Enable Register -#define AT91C_PIOA_OWDR ((AT91_REG *) 0xFFFFF4A4) // (PIOA) Output Write Disable Register -#define AT91C_PIOA_ISR ((AT91_REG *) 0xFFFFF44C) // (PIOA) Interrupt Status Register -#define AT91C_PIOA_PPUDR ((AT91_REG *) 0xFFFFF460) // (PIOA) Pull-up Disable Register -#define AT91C_PIOA_MDSR ((AT91_REG *) 0xFFFFF458) // (PIOA) Multi-driver Status Register -#define AT91C_PIOA_MDER ((AT91_REG *) 0xFFFFF450) // (PIOA) Multi-driver Enable Register -#define AT91C_PIOA_PER ((AT91_REG *) 0xFFFFF400) // (PIOA) PIO Enable Register -#define AT91C_PIOA_PSR ((AT91_REG *) 0xFFFFF408) // (PIOA) PIO Status Register -#define AT91C_PIOA_OER ((AT91_REG *) 0xFFFFF410) // (PIOA) Output Enable Register -#define AT91C_PIOA_BSR ((AT91_REG *) 0xFFFFF474) // (PIOA) Select B Register -#define AT91C_PIOA_PPUER ((AT91_REG *) 0xFFFFF464) // (PIOA) Pull-up Enable Register -#define AT91C_PIOA_MDDR ((AT91_REG *) 0xFFFFF454) // (PIOA) Multi-driver Disable Register -#define AT91C_PIOA_PDR ((AT91_REG *) 0xFFFFF404) // (PIOA) PIO Disable Register -#define AT91C_PIOA_ODR ((AT91_REG *) 0xFFFFF414) // (PIOA) Output Disable Registerr -#define AT91C_PIOA_IFDR ((AT91_REG *) 0xFFFFF424) // (PIOA) Input Filter Disable Register -#define AT91C_PIOA_ABSR ((AT91_REG *) 0xFFFFF478) // (PIOA) AB Select Status Register -#define AT91C_PIOA_ASR ((AT91_REG *) 0xFFFFF470) // (PIOA) Select A Register -#define AT91C_PIOA_PPUSR ((AT91_REG *) 0xFFFFF468) // (PIOA) Pad Pull-up Status Register -#define AT91C_PIOA_ODSR ((AT91_REG *) 0xFFFFF438) // (PIOA) Output Data Status Register -#define AT91C_PIOA_SODR ((AT91_REG *) 0xFFFFF430) // (PIOA) Set Output Data Register -#define AT91C_PIOA_IFSR ((AT91_REG *) 0xFFFFF428) // (PIOA) Input Filter Status Register -#define AT91C_PIOA_IFER ((AT91_REG *) 0xFFFFF420) // (PIOA) Input Filter Enable Register -#define AT91C_PIOA_OSR ((AT91_REG *) 0xFFFFF418) // (PIOA) Output Status Register -#define AT91C_PIOA_IDR ((AT91_REG *) 0xFFFFF444) // (PIOA) Interrupt Disable Register -#define AT91C_PIOA_PDSR ((AT91_REG *) 0xFFFFF43C) // (PIOA) Pin Data Status Register -#define AT91C_PIOA_CODR ((AT91_REG *) 0xFFFFF434) // (PIOA) Clear Output Data Register -#define AT91C_PIOA_OWSR ((AT91_REG *) 0xFFFFF4A8) // (PIOA) Output Write Status Register -#define AT91C_PIOA_OWER ((AT91_REG *) 0xFFFFF4A0) // (PIOA) Output Write Enable Register -// ========== Register definition for DBGU peripheral ========== -#define AT91C_DBGU_C2R ((AT91_REG *) 0xFFFFF244) // (DBGU) Chip ID2 Register -#define AT91C_DBGU_THR ((AT91_REG *) 0xFFFFF21C) // (DBGU) Transmitter Holding Register -#define AT91C_DBGU_CSR ((AT91_REG *) 0xFFFFF214) // (DBGU) Channel Status Register -#define AT91C_DBGU_IDR ((AT91_REG *) 0xFFFFF20C) // (DBGU) Interrupt Disable Register -#define AT91C_DBGU_MR ((AT91_REG *) 0xFFFFF204) // (DBGU) Mode Register -#define AT91C_DBGU_FNTR ((AT91_REG *) 0xFFFFF248) // (DBGU) Force NTRST Register -#define AT91C_DBGU_C1R ((AT91_REG *) 0xFFFFF240) // (DBGU) Chip ID1 Register -#define AT91C_DBGU_BRGR ((AT91_REG *) 0xFFFFF220) // (DBGU) Baud Rate Generator Register -#define AT91C_DBGU_RHR ((AT91_REG *) 0xFFFFF218) // (DBGU) Receiver Holding Register -#define AT91C_DBGU_IMR ((AT91_REG *) 0xFFFFF210) // (DBGU) Interrupt Mask Register -#define AT91C_DBGU_IER ((AT91_REG *) 0xFFFFF208) // (DBGU) Interrupt Enable Register -#define AT91C_DBGU_CR ((AT91_REG *) 0xFFFFF200) // (DBGU) Control Register -// ========== Register definition for PDC_DBGU peripheral ========== -#define AT91C_DBGU_TNCR ((AT91_REG *) 0xFFFFF31C) // (PDC_DBGU) Transmit Next Counter Register -#define AT91C_DBGU_RNCR ((AT91_REG *) 0xFFFFF314) // (PDC_DBGU) Receive Next Counter Register -#define AT91C_DBGU_PTCR ((AT91_REG *) 0xFFFFF320) // (PDC_DBGU) PDC Transfer Control Register -#define AT91C_DBGU_PTSR ((AT91_REG *) 0xFFFFF324) // (PDC_DBGU) PDC Transfer Status Register -#define AT91C_DBGU_RCR ((AT91_REG *) 0xFFFFF304) // (PDC_DBGU) Receive Counter Register -#define AT91C_DBGU_TCR ((AT91_REG *) 0xFFFFF30C) // (PDC_DBGU) Transmit Counter Register -#define AT91C_DBGU_RPR ((AT91_REG *) 0xFFFFF300) // (PDC_DBGU) Receive Pointer Register -#define AT91C_DBGU_TPR ((AT91_REG *) 0xFFFFF308) // (PDC_DBGU) Transmit Pointer Register -#define AT91C_DBGU_RNPR ((AT91_REG *) 0xFFFFF310) // (PDC_DBGU) Receive Next Pointer Register -#define AT91C_DBGU_TNPR ((AT91_REG *) 0xFFFFF318) // (PDC_DBGU) Transmit Next Pointer Register -// ========== Register definition for AIC peripheral ========== -#define AT91C_AIC_ICCR ((AT91_REG *) 0xFFFFF128) // (AIC) Interrupt Clear Command Register -#define AT91C_AIC_IECR ((AT91_REG *) 0xFFFFF120) // (AIC) Interrupt Enable Command Register -#define AT91C_AIC_SMR ((AT91_REG *) 0xFFFFF000) // (AIC) Source Mode Register -#define AT91C_AIC_ISCR ((AT91_REG *) 0xFFFFF12C) // (AIC) Interrupt Set Command Register -#define AT91C_AIC_EOICR ((AT91_REG *) 0xFFFFF130) // (AIC) End of Interrupt Command Register -#define AT91C_AIC_DCR ((AT91_REG *) 0xFFFFF138) // (AIC) Debug Control Register (Protect) -#define AT91C_AIC_FFER ((AT91_REG *) 0xFFFFF140) // (AIC) Fast Forcing Enable Register -#define AT91C_AIC_SVR ((AT91_REG *) 0xFFFFF080) // (AIC) Source Vector Register -#define AT91C_AIC_SPU ((AT91_REG *) 0xFFFFF134) // (AIC) Spurious Vector Register -#define AT91C_AIC_FFDR ((AT91_REG *) 0xFFFFF144) // (AIC) Fast Forcing Disable Register -#define AT91C_AIC_FVR ((AT91_REG *) 0xFFFFF104) // (AIC) FIQ Vector Register -#define AT91C_AIC_FFSR ((AT91_REG *) 0xFFFFF148) // (AIC) Fast Forcing Status Register -#define AT91C_AIC_IMR ((AT91_REG *) 0xFFFFF110) // (AIC) Interrupt Mask Register -#define AT91C_AIC_ISR ((AT91_REG *) 0xFFFFF108) // (AIC) Interrupt Status Register -#define AT91C_AIC_IVR ((AT91_REG *) 0xFFFFF100) // (AIC) IRQ Vector Register -#define AT91C_AIC_IDCR ((AT91_REG *) 0xFFFFF124) // (AIC) Interrupt Disable Command Register -#define AT91C_AIC_CISR ((AT91_REG *) 0xFFFFF114) // (AIC) Core Interrupt Status Register -#define AT91C_AIC_IPR ((AT91_REG *) 0xFFFFF10C) // (AIC) Interrupt Pending Register -// ========== Register definition for PDC_SPI peripheral ========== -#define AT91C_SPI_PTCR ((AT91_REG *) 0xFFFE0120) // (PDC_SPI) PDC Transfer Control Register -#define AT91C_SPI_TNPR ((AT91_REG *) 0xFFFE0118) // (PDC_SPI) Transmit Next Pointer Register -#define AT91C_SPI_RNPR ((AT91_REG *) 0xFFFE0110) // (PDC_SPI) Receive Next Pointer Register -#define AT91C_SPI_TPR ((AT91_REG *) 0xFFFE0108) // (PDC_SPI) Transmit Pointer Register -#define AT91C_SPI_RPR ((AT91_REG *) 0xFFFE0100) // (PDC_SPI) Receive Pointer Register -#define AT91C_SPI_PTSR ((AT91_REG *) 0xFFFE0124) // (PDC_SPI) PDC Transfer Status Register -#define AT91C_SPI_TNCR ((AT91_REG *) 0xFFFE011C) // (PDC_SPI) Transmit Next Counter Register -#define AT91C_SPI_RNCR ((AT91_REG *) 0xFFFE0114) // (PDC_SPI) Receive Next Counter Register -#define AT91C_SPI_TCR ((AT91_REG *) 0xFFFE010C) // (PDC_SPI) Transmit Counter Register -#define AT91C_SPI_RCR ((AT91_REG *) 0xFFFE0104) // (PDC_SPI) Receive Counter Register -// ========== Register definition for SPI peripheral ========== -#define AT91C_SPI_CSR ((AT91_REG *) 0xFFFE0030) // (SPI) Chip Select Register -#define AT91C_SPI_IDR ((AT91_REG *) 0xFFFE0018) // (SPI) Interrupt Disable Register -#define AT91C_SPI_SR ((AT91_REG *) 0xFFFE0010) // (SPI) Status Register -#define AT91C_SPI_RDR ((AT91_REG *) 0xFFFE0008) // (SPI) Receive Data Register -#define AT91C_SPI_CR ((AT91_REG *) 0xFFFE0000) // (SPI) Control Register -#define AT91C_SPI_IMR ((AT91_REG *) 0xFFFE001C) // (SPI) Interrupt Mask Register -#define AT91C_SPI_IER ((AT91_REG *) 0xFFFE0014) // (SPI) Interrupt Enable Register -#define AT91C_SPI_TDR ((AT91_REG *) 0xFFFE000C) // (SPI) Transmit Data Register -#define AT91C_SPI_MR ((AT91_REG *) 0xFFFE0004) // (SPI) Mode Register -// ========== Register definition for PDC_SSC2 peripheral ========== -#define AT91C_SSC2_PTCR ((AT91_REG *) 0xFFFD8120) // (PDC_SSC2) PDC Transfer Control Register -#define AT91C_SSC2_TNPR ((AT91_REG *) 0xFFFD8118) // (PDC_SSC2) Transmit Next Pointer Register -#define AT91C_SSC2_RNPR ((AT91_REG *) 0xFFFD8110) // (PDC_SSC2) Receive Next Pointer Register -#define AT91C_SSC2_TPR ((AT91_REG *) 0xFFFD8108) // (PDC_SSC2) Transmit Pointer Register -#define AT91C_SSC2_RPR ((AT91_REG *) 0xFFFD8100) // (PDC_SSC2) Receive Pointer Register -#define AT91C_SSC2_PTSR ((AT91_REG *) 0xFFFD8124) // (PDC_SSC2) PDC Transfer Status Register -#define AT91C_SSC2_TNCR ((AT91_REG *) 0xFFFD811C) // (PDC_SSC2) Transmit Next Counter Register -#define AT91C_SSC2_RNCR ((AT91_REG *) 0xFFFD8114) // (PDC_SSC2) Receive Next Counter Register -#define AT91C_SSC2_TCR ((AT91_REG *) 0xFFFD810C) // (PDC_SSC2) Transmit Counter Register -#define AT91C_SSC2_RCR ((AT91_REG *) 0xFFFD8104) // (PDC_SSC2) Receive Counter Register -// ========== Register definition for SSC2 peripheral ========== -#define AT91C_SSC2_IMR ((AT91_REG *) 0xFFFD804C) // (SSC2) Interrupt Mask Register -#define AT91C_SSC2_IER ((AT91_REG *) 0xFFFD8044) // (SSC2) Interrupt Enable Register -#define AT91C_SSC2_RC1R ((AT91_REG *) 0xFFFD803C) // (SSC2) Receive Compare 1 Register -#define AT91C_SSC2_TSHR ((AT91_REG *) 0xFFFD8034) // (SSC2) Transmit Sync Holding Register -#define AT91C_SSC2_CMR ((AT91_REG *) 0xFFFD8004) // (SSC2) Clock Mode Register -#define AT91C_SSC2_IDR ((AT91_REG *) 0xFFFD8048) // (SSC2) Interrupt Disable Register -#define AT91C_SSC2_TCMR ((AT91_REG *) 0xFFFD8018) // (SSC2) Transmit Clock Mode Register -#define AT91C_SSC2_RCMR ((AT91_REG *) 0xFFFD8010) // (SSC2) Receive Clock ModeRegister -#define AT91C_SSC2_CR ((AT91_REG *) 0xFFFD8000) // (SSC2) Control Register -#define AT91C_SSC2_RFMR ((AT91_REG *) 0xFFFD8014) // (SSC2) Receive Frame Mode Register -#define AT91C_SSC2_TFMR ((AT91_REG *) 0xFFFD801C) // (SSC2) Transmit Frame Mode Register -#define AT91C_SSC2_THR ((AT91_REG *) 0xFFFD8024) // (SSC2) Transmit Holding Register -#define AT91C_SSC2_SR ((AT91_REG *) 0xFFFD8040) // (SSC2) Status Register -#define AT91C_SSC2_RC0R ((AT91_REG *) 0xFFFD8038) // (SSC2) Receive Compare 0 Register -#define AT91C_SSC2_RSHR ((AT91_REG *) 0xFFFD8030) // (SSC2) Receive Sync Holding Register -#define AT91C_SSC2_RHR ((AT91_REG *) 0xFFFD8020) // (SSC2) Receive Holding Register -// ========== Register definition for PDC_SSC1 peripheral ========== -#define AT91C_SSC1_PTCR ((AT91_REG *) 0xFFFD4120) // (PDC_SSC1) PDC Transfer Control Register -#define AT91C_SSC1_TNPR ((AT91_REG *) 0xFFFD4118) // (PDC_SSC1) Transmit Next Pointer Register -#define AT91C_SSC1_RNPR ((AT91_REG *) 0xFFFD4110) // (PDC_SSC1) Receive Next Pointer Register -#define AT91C_SSC1_TPR ((AT91_REG *) 0xFFFD4108) // (PDC_SSC1) Transmit Pointer Register -#define AT91C_SSC1_RPR ((AT91_REG *) 0xFFFD4100) // (PDC_SSC1) Receive Pointer Register -#define AT91C_SSC1_PTSR ((AT91_REG *) 0xFFFD4124) // (PDC_SSC1) PDC Transfer Status Register -#define AT91C_SSC1_TNCR ((AT91_REG *) 0xFFFD411C) // (PDC_SSC1) Transmit Next Counter Register -#define AT91C_SSC1_RNCR ((AT91_REG *) 0xFFFD4114) // (PDC_SSC1) Receive Next Counter Register -#define AT91C_SSC1_TCR ((AT91_REG *) 0xFFFD410C) // (PDC_SSC1) Transmit Counter Register -#define AT91C_SSC1_RCR ((AT91_REG *) 0xFFFD4104) // (PDC_SSC1) Receive Counter Register -// ========== Register definition for SSC1 peripheral ========== -#define AT91C_SSC1_RFMR ((AT91_REG *) 0xFFFD4014) // (SSC1) Receive Frame Mode Register -#define AT91C_SSC1_CMR ((AT91_REG *) 0xFFFD4004) // (SSC1) Clock Mode Register -#define AT91C_SSC1_IDR ((AT91_REG *) 0xFFFD4048) // (SSC1) Interrupt Disable Register -#define AT91C_SSC1_SR ((AT91_REG *) 0xFFFD4040) // (SSC1) Status Register -#define AT91C_SSC1_RC0R ((AT91_REG *) 0xFFFD4038) // (SSC1) Receive Compare 0 Register -#define AT91C_SSC1_RSHR ((AT91_REG *) 0xFFFD4030) // (SSC1) Receive Sync Holding Register -#define AT91C_SSC1_RHR ((AT91_REG *) 0xFFFD4020) // (SSC1) Receive Holding Register -#define AT91C_SSC1_TCMR ((AT91_REG *) 0xFFFD4018) // (SSC1) Transmit Clock Mode Register -#define AT91C_SSC1_RCMR ((AT91_REG *) 0xFFFD4010) // (SSC1) Receive Clock ModeRegister -#define AT91C_SSC1_CR ((AT91_REG *) 0xFFFD4000) // (SSC1) Control Register -#define AT91C_SSC1_IMR ((AT91_REG *) 0xFFFD404C) // (SSC1) Interrupt Mask Register -#define AT91C_SSC1_IER ((AT91_REG *) 0xFFFD4044) // (SSC1) Interrupt Enable Register -#define AT91C_SSC1_RC1R ((AT91_REG *) 0xFFFD403C) // (SSC1) Receive Compare 1 Register -#define AT91C_SSC1_TSHR ((AT91_REG *) 0xFFFD4034) // (SSC1) Transmit Sync Holding Register -#define AT91C_SSC1_THR ((AT91_REG *) 0xFFFD4024) // (SSC1) Transmit Holding Register -#define AT91C_SSC1_TFMR ((AT91_REG *) 0xFFFD401C) // (SSC1) Transmit Frame Mode Register -// ========== Register definition for PDC_SSC0 peripheral ========== -#define AT91C_SSC0_PTCR ((AT91_REG *) 0xFFFD0120) // (PDC_SSC0) PDC Transfer Control Register -#define AT91C_SSC0_TNPR ((AT91_REG *) 0xFFFD0118) // (PDC_SSC0) Transmit Next Pointer Register -#define AT91C_SSC0_RNPR ((AT91_REG *) 0xFFFD0110) // (PDC_SSC0) Receive Next Pointer Register -#define AT91C_SSC0_TPR ((AT91_REG *) 0xFFFD0108) // (PDC_SSC0) Transmit Pointer Register -#define AT91C_SSC0_RPR ((AT91_REG *) 0xFFFD0100) // (PDC_SSC0) Receive Pointer Register -#define AT91C_SSC0_PTSR ((AT91_REG *) 0xFFFD0124) // (PDC_SSC0) PDC Transfer Status Register -#define AT91C_SSC0_TNCR ((AT91_REG *) 0xFFFD011C) // (PDC_SSC0) Transmit Next Counter Register -#define AT91C_SSC0_RNCR ((AT91_REG *) 0xFFFD0114) // (PDC_SSC0) Receive Next Counter Register -#define AT91C_SSC0_TCR ((AT91_REG *) 0xFFFD010C) // (PDC_SSC0) Transmit Counter Register -#define AT91C_SSC0_RCR ((AT91_REG *) 0xFFFD0104) // (PDC_SSC0) Receive Counter Register -// ========== Register definition for SSC0 peripheral ========== -#define AT91C_SSC0_IMR ((AT91_REG *) 0xFFFD004C) // (SSC0) Interrupt Mask Register -#define AT91C_SSC0_IER ((AT91_REG *) 0xFFFD0044) // (SSC0) Interrupt Enable Register -#define AT91C_SSC0_RC1R ((AT91_REG *) 0xFFFD003C) // (SSC0) Receive Compare 1 Register -#define AT91C_SSC0_TSHR ((AT91_REG *) 0xFFFD0034) // (SSC0) Transmit Sync Holding Register -#define AT91C_SSC0_THR ((AT91_REG *) 0xFFFD0024) // (SSC0) Transmit Holding Register -#define AT91C_SSC0_TFMR ((AT91_REG *) 0xFFFD001C) // (SSC0) Transmit Frame Mode Register -#define AT91C_SSC0_RFMR ((AT91_REG *) 0xFFFD0014) // (SSC0) Receive Frame Mode Register -#define AT91C_SSC0_CMR ((AT91_REG *) 0xFFFD0004) // (SSC0) Clock Mode Register -#define AT91C_SSC0_IDR ((AT91_REG *) 0xFFFD0048) // (SSC0) Interrupt Disable Register -#define AT91C_SSC0_SR ((AT91_REG *) 0xFFFD0040) // (SSC0) Status Register -#define AT91C_SSC0_RC0R ((AT91_REG *) 0xFFFD0038) // (SSC0) Receive Compare 0 Register -#define AT91C_SSC0_RSHR ((AT91_REG *) 0xFFFD0030) // (SSC0) Receive Sync Holding Register -#define AT91C_SSC0_RHR ((AT91_REG *) 0xFFFD0020) // (SSC0) Receive Holding Register -#define AT91C_SSC0_TCMR ((AT91_REG *) 0xFFFD0018) // (SSC0) Transmit Clock Mode Register -#define AT91C_SSC0_RCMR ((AT91_REG *) 0xFFFD0010) // (SSC0) Receive Clock ModeRegister -#define AT91C_SSC0_CR ((AT91_REG *) 0xFFFD0000) // (SSC0) Control Register -// ========== Register definition for PDC_US3 peripheral ========== -#define AT91C_US3_PTSR ((AT91_REG *) 0xFFFCC124) // (PDC_US3) PDC Transfer Status Register -#define AT91C_US3_TNCR ((AT91_REG *) 0xFFFCC11C) // (PDC_US3) Transmit Next Counter Register -#define AT91C_US3_RNCR ((AT91_REG *) 0xFFFCC114) // (PDC_US3) Receive Next Counter Register -#define AT91C_US3_TCR ((AT91_REG *) 0xFFFCC10C) // (PDC_US3) Transmit Counter Register -#define AT91C_US3_RCR ((AT91_REG *) 0xFFFCC104) // (PDC_US3) Receive Counter Register -#define AT91C_US3_PTCR ((AT91_REG *) 0xFFFCC120) // (PDC_US3) PDC Transfer Control Register -#define AT91C_US3_TNPR ((AT91_REG *) 0xFFFCC118) // (PDC_US3) Transmit Next Pointer Register -#define AT91C_US3_RNPR ((AT91_REG *) 0xFFFCC110) // (PDC_US3) Receive Next Pointer Register -#define AT91C_US3_TPR ((AT91_REG *) 0xFFFCC108) // (PDC_US3) Transmit Pointer Register -#define AT91C_US3_RPR ((AT91_REG *) 0xFFFCC100) // (PDC_US3) Receive Pointer Register -// ========== Register definition for US3 peripheral ========== -#define AT91C_US3_IF ((AT91_REG *) 0xFFFCC04C) // (US3) IRDA_FILTER Register -#define AT91C_US3_NER ((AT91_REG *) 0xFFFCC044) // (US3) Nb Errors Register -#define AT91C_US3_RTOR ((AT91_REG *) 0xFFFCC024) // (US3) Receiver Time-out Register -#define AT91C_US3_THR ((AT91_REG *) 0xFFFCC01C) // (US3) Transmitter Holding Register -#define AT91C_US3_CSR ((AT91_REG *) 0xFFFCC014) // (US3) Channel Status Register -#define AT91C_US3_IDR ((AT91_REG *) 0xFFFCC00C) // (US3) Interrupt Disable Register -#define AT91C_US3_MR ((AT91_REG *) 0xFFFCC004) // (US3) Mode Register -#define AT91C_US3_XXR ((AT91_REG *) 0xFFFCC048) // (US3) XON_XOFF Register -#define AT91C_US3_FIDI ((AT91_REG *) 0xFFFCC040) // (US3) FI_DI_Ratio Register -#define AT91C_US3_TTGR ((AT91_REG *) 0xFFFCC028) // (US3) Transmitter Time-guard Register -#define AT91C_US3_BRGR ((AT91_REG *) 0xFFFCC020) // (US3) Baud Rate Generator Register -#define AT91C_US3_RHR ((AT91_REG *) 0xFFFCC018) // (US3) Receiver Holding Register -#define AT91C_US3_IMR ((AT91_REG *) 0xFFFCC010) // (US3) Interrupt Mask Register -#define AT91C_US3_IER ((AT91_REG *) 0xFFFCC008) // (US3) Interrupt Enable Register -#define AT91C_US3_CR ((AT91_REG *) 0xFFFCC000) // (US3) Control Register -// ========== Register definition for PDC_US2 peripheral ========== -#define AT91C_US2_PTSR ((AT91_REG *) 0xFFFC8124) // (PDC_US2) PDC Transfer Status Register -#define AT91C_US2_TNCR ((AT91_REG *) 0xFFFC811C) // (PDC_US2) Transmit Next Counter Register -#define AT91C_US2_RNCR ((AT91_REG *) 0xFFFC8114) // (PDC_US2) Receive Next Counter Register -#define AT91C_US2_TCR ((AT91_REG *) 0xFFFC810C) // (PDC_US2) Transmit Counter Register -#define AT91C_US2_PTCR ((AT91_REG *) 0xFFFC8120) // (PDC_US2) PDC Transfer Control Register -#define AT91C_US2_RCR ((AT91_REG *) 0xFFFC8104) // (PDC_US2) Receive Counter Register -#define AT91C_US2_TNPR ((AT91_REG *) 0xFFFC8118) // (PDC_US2) Transmit Next Pointer Register -#define AT91C_US2_RPR ((AT91_REG *) 0xFFFC8100) // (PDC_US2) Receive Pointer Register -#define AT91C_US2_TPR ((AT91_REG *) 0xFFFC8108) // (PDC_US2) Transmit Pointer Register -#define AT91C_US2_RNPR ((AT91_REG *) 0xFFFC8110) // (PDC_US2) Receive Next Pointer Register -// ========== Register definition for US2 peripheral ========== -#define AT91C_US2_XXR ((AT91_REG *) 0xFFFC8048) // (US2) XON_XOFF Register -#define AT91C_US2_FIDI ((AT91_REG *) 0xFFFC8040) // (US2) FI_DI_Ratio Register -#define AT91C_US2_TTGR ((AT91_REG *) 0xFFFC8028) // (US2) Transmitter Time-guard Register -#define AT91C_US2_BRGR ((AT91_REG *) 0xFFFC8020) // (US2) Baud Rate Generator Register -#define AT91C_US2_RHR ((AT91_REG *) 0xFFFC8018) // (US2) Receiver Holding Register -#define AT91C_US2_IMR ((AT91_REG *) 0xFFFC8010) // (US2) Interrupt Mask Register -#define AT91C_US2_IER ((AT91_REG *) 0xFFFC8008) // (US2) Interrupt Enable Register -#define AT91C_US2_CR ((AT91_REG *) 0xFFFC8000) // (US2) Control Register -#define AT91C_US2_IF ((AT91_REG *) 0xFFFC804C) // (US2) IRDA_FILTER Register -#define AT91C_US2_NER ((AT91_REG *) 0xFFFC8044) // (US2) Nb Errors Register -#define AT91C_US2_RTOR ((AT91_REG *) 0xFFFC8024) // (US2) Receiver Time-out Register -#define AT91C_US2_THR ((AT91_REG *) 0xFFFC801C) // (US2) Transmitter Holding Register -#define AT91C_US2_CSR ((AT91_REG *) 0xFFFC8014) // (US2) Channel Status Register -#define AT91C_US2_IDR ((AT91_REG *) 0xFFFC800C) // (US2) Interrupt Disable Register -#define AT91C_US2_MR ((AT91_REG *) 0xFFFC8004) // (US2) Mode Register -// ========== Register definition for PDC_US1 peripheral ========== -#define AT91C_US1_PTSR ((AT91_REG *) 0xFFFC4124) // (PDC_US1) PDC Transfer Status Register -#define AT91C_US1_TNCR ((AT91_REG *) 0xFFFC411C) // (PDC_US1) Transmit Next Counter Register -#define AT91C_US1_RNCR ((AT91_REG *) 0xFFFC4114) // (PDC_US1) Receive Next Counter Register -#define AT91C_US1_TCR ((AT91_REG *) 0xFFFC410C) // (PDC_US1) Transmit Counter Register -#define AT91C_US1_RCR ((AT91_REG *) 0xFFFC4104) // (PDC_US1) Receive Counter Register -#define AT91C_US1_PTCR ((AT91_REG *) 0xFFFC4120) // (PDC_US1) PDC Transfer Control Register -#define AT91C_US1_TNPR ((AT91_REG *) 0xFFFC4118) // (PDC_US1) Transmit Next Pointer Register -#define AT91C_US1_RNPR ((AT91_REG *) 0xFFFC4110) // (PDC_US1) Receive Next Pointer Register -#define AT91C_US1_TPR ((AT91_REG *) 0xFFFC4108) // (PDC_US1) Transmit Pointer Register -#define AT91C_US1_RPR ((AT91_REG *) 0xFFFC4100) // (PDC_US1) Receive Pointer Register -// ========== Register definition for US1 peripheral ========== -#define AT91C_US1_XXR ((AT91_REG *) 0xFFFC4048) // (US1) XON_XOFF Register -#define AT91C_US1_RHR ((AT91_REG *) 0xFFFC4018) // (US1) Receiver Holding Register -#define AT91C_US1_IMR ((AT91_REG *) 0xFFFC4010) // (US1) Interrupt Mask Register -#define AT91C_US1_IER ((AT91_REG *) 0xFFFC4008) // (US1) Interrupt Enable Register -#define AT91C_US1_CR ((AT91_REG *) 0xFFFC4000) // (US1) Control Register -#define AT91C_US1_RTOR ((AT91_REG *) 0xFFFC4024) // (US1) Receiver Time-out Register -#define AT91C_US1_THR ((AT91_REG *) 0xFFFC401C) // (US1) Transmitter Holding Register -#define AT91C_US1_CSR ((AT91_REG *) 0xFFFC4014) // (US1) Channel Status Register -#define AT91C_US1_IDR ((AT91_REG *) 0xFFFC400C) // (US1) Interrupt Disable Register -#define AT91C_US1_FIDI ((AT91_REG *) 0xFFFC4040) // (US1) FI_DI_Ratio Register -#define AT91C_US1_BRGR ((AT91_REG *) 0xFFFC4020) // (US1) Baud Rate Generator Register -#define AT91C_US1_TTGR ((AT91_REG *) 0xFFFC4028) // (US1) Transmitter Time-guard Register -#define AT91C_US1_IF ((AT91_REG *) 0xFFFC404C) // (US1) IRDA_FILTER Register -#define AT91C_US1_NER ((AT91_REG *) 0xFFFC4044) // (US1) Nb Errors Register -#define AT91C_US1_MR ((AT91_REG *) 0xFFFC4004) // (US1) Mode Register -// ========== Register definition for PDC_US0 peripheral ========== -#define AT91C_US0_PTCR ((AT91_REG *) 0xFFFC0120) // (PDC_US0) PDC Transfer Control Register -#define AT91C_US0_TNPR ((AT91_REG *) 0xFFFC0118) // (PDC_US0) Transmit Next Pointer Register -#define AT91C_US0_RNPR ((AT91_REG *) 0xFFFC0110) // (PDC_US0) Receive Next Pointer Register -#define AT91C_US0_TPR ((AT91_REG *) 0xFFFC0108) // (PDC_US0) Transmit Pointer Register -#define AT91C_US0_RPR ((AT91_REG *) 0xFFFC0100) // (PDC_US0) Receive Pointer Register -#define AT91C_US0_PTSR ((AT91_REG *) 0xFFFC0124) // (PDC_US0) PDC Transfer Status Register -#define AT91C_US0_TNCR ((AT91_REG *) 0xFFFC011C) // (PDC_US0) Transmit Next Counter Register -#define AT91C_US0_RNCR ((AT91_REG *) 0xFFFC0114) // (PDC_US0) Receive Next Counter Register -#define AT91C_US0_TCR ((AT91_REG *) 0xFFFC010C) // (PDC_US0) Transmit Counter Register -#define AT91C_US0_RCR ((AT91_REG *) 0xFFFC0104) // (PDC_US0) Receive Counter Register -// ========== Register definition for US0 peripheral ========== -#define AT91C_US0_TTGR ((AT91_REG *) 0xFFFC0028) // (US0) Transmitter Time-guard Register -#define AT91C_US0_BRGR ((AT91_REG *) 0xFFFC0020) // (US0) Baud Rate Generator Register -#define AT91C_US0_RHR ((AT91_REG *) 0xFFFC0018) // (US0) Receiver Holding Register -#define AT91C_US0_IMR ((AT91_REG *) 0xFFFC0010) // (US0) Interrupt Mask Register -#define AT91C_US0_NER ((AT91_REG *) 0xFFFC0044) // (US0) Nb Errors Register -#define AT91C_US0_RTOR ((AT91_REG *) 0xFFFC0024) // (US0) Receiver Time-out Register -#define AT91C_US0_XXR ((AT91_REG *) 0xFFFC0048) // (US0) XON_XOFF Register -#define AT91C_US0_FIDI ((AT91_REG *) 0xFFFC0040) // (US0) FI_DI_Ratio Register -#define AT91C_US0_CR ((AT91_REG *) 0xFFFC0000) // (US0) Control Register -#define AT91C_US0_IER ((AT91_REG *) 0xFFFC0008) // (US0) Interrupt Enable Register -#define AT91C_US0_IF ((AT91_REG *) 0xFFFC004C) // (US0) IRDA_FILTER Register -#define AT91C_US0_MR ((AT91_REG *) 0xFFFC0004) // (US0) Mode Register -#define AT91C_US0_IDR ((AT91_REG *) 0xFFFC000C) // (US0) Interrupt Disable Register -#define AT91C_US0_CSR ((AT91_REG *) 0xFFFC0014) // (US0) Channel Status Register -#define AT91C_US0_THR ((AT91_REG *) 0xFFFC001C) // (US0) Transmitter Holding Register -// ========== Register definition for TWI peripheral ========== -#define AT91C_TWI_RHR ((AT91_REG *) 0xFFFB8030) // (TWI) Receive Holding Register -#define AT91C_TWI_IDR ((AT91_REG *) 0xFFFB8028) // (TWI) Interrupt Disable Register -#define AT91C_TWI_SR ((AT91_REG *) 0xFFFB8020) // (TWI) Status Register -#define AT91C_TWI_CWGR ((AT91_REG *) 0xFFFB8010) // (TWI) Clock Waveform Generator Register -#define AT91C_TWI_SMR ((AT91_REG *) 0xFFFB8008) // (TWI) Slave Mode Register -#define AT91C_TWI_CR ((AT91_REG *) 0xFFFB8000) // (TWI) Control Register -#define AT91C_TWI_THR ((AT91_REG *) 0xFFFB8034) // (TWI) Transmit Holding Register -#define AT91C_TWI_IMR ((AT91_REG *) 0xFFFB802C) // (TWI) Interrupt Mask Register -#define AT91C_TWI_IER ((AT91_REG *) 0xFFFB8024) // (TWI) Interrupt Enable Register -#define AT91C_TWI_IADR ((AT91_REG *) 0xFFFB800C) // (TWI) Internal Address Register -#define AT91C_TWI_MMR ((AT91_REG *) 0xFFFB8004) // (TWI) Master Mode Register -// ========== Register definition for PDC_MCI peripheral ========== -#define AT91C_MCI_PTCR ((AT91_REG *) 0xFFFB4120) // (PDC_MCI) PDC Transfer Control Register -#define AT91C_MCI_TNPR ((AT91_REG *) 0xFFFB4118) // (PDC_MCI) Transmit Next Pointer Register -#define AT91C_MCI_RNPR ((AT91_REG *) 0xFFFB4110) // (PDC_MCI) Receive Next Pointer Register -#define AT91C_MCI_TPR ((AT91_REG *) 0xFFFB4108) // (PDC_MCI) Transmit Pointer Register -#define AT91C_MCI_RPR ((AT91_REG *) 0xFFFB4100) // (PDC_MCI) Receive Pointer Register -#define AT91C_MCI_PTSR ((AT91_REG *) 0xFFFB4124) // (PDC_MCI) PDC Transfer Status Register -#define AT91C_MCI_TNCR ((AT91_REG *) 0xFFFB411C) // (PDC_MCI) Transmit Next Counter Register -#define AT91C_MCI_RNCR ((AT91_REG *) 0xFFFB4114) // (PDC_MCI) Receive Next Counter Register -#define AT91C_MCI_TCR ((AT91_REG *) 0xFFFB410C) // (PDC_MCI) Transmit Counter Register -#define AT91C_MCI_RCR ((AT91_REG *) 0xFFFB4104) // (PDC_MCI) Receive Counter Register -// ========== Register definition for MCI peripheral ========== -#define AT91C_MCI_IDR ((AT91_REG *) 0xFFFB4048) // (MCI) MCI Interrupt Disable Register -#define AT91C_MCI_SR ((AT91_REG *) 0xFFFB4040) // (MCI) MCI Status Register -#define AT91C_MCI_RDR ((AT91_REG *) 0xFFFB4030) // (MCI) MCI Receive Data Register -#define AT91C_MCI_RSPR ((AT91_REG *) 0xFFFB4020) // (MCI) MCI Response Register -#define AT91C_MCI_ARGR ((AT91_REG *) 0xFFFB4010) // (MCI) MCI Argument Register -#define AT91C_MCI_DTOR ((AT91_REG *) 0xFFFB4008) // (MCI) MCI Data Timeout Register -#define AT91C_MCI_CR ((AT91_REG *) 0xFFFB4000) // (MCI) MCI Control Register -#define AT91C_MCI_IMR ((AT91_REG *) 0xFFFB404C) // (MCI) MCI Interrupt Mask Register -#define AT91C_MCI_IER ((AT91_REG *) 0xFFFB4044) // (MCI) MCI Interrupt Enable Register -#define AT91C_MCI_TDR ((AT91_REG *) 0xFFFB4034) // (MCI) MCI Transmit Data Register -#define AT91C_MCI_CMDR ((AT91_REG *) 0xFFFB4014) // (MCI) MCI Command Register -#define AT91C_MCI_SDCR ((AT91_REG *) 0xFFFB400C) // (MCI) MCI SD Card Register -#define AT91C_MCI_MR ((AT91_REG *) 0xFFFB4004) // (MCI) MCI Mode Register -// ========== Register definition for UDP peripheral ========== -#define AT91C_UDP_ISR ((AT91_REG *) 0xFFFB001C) // (UDP) Interrupt Status Register -#define AT91C_UDP_IDR ((AT91_REG *) 0xFFFB0014) // (UDP) Interrupt Disable Register -#define AT91C_UDP_GLBSTATE ((AT91_REG *) 0xFFFB0004) // (UDP) Global State Register -#define AT91C_UDP_FDR ((AT91_REG *) 0xFFFB0050) // (UDP) Endpoint FIFO Data Register -#define AT91C_UDP_CSR ((AT91_REG *) 0xFFFB0030) // (UDP) Endpoint Control and Status Register -#define AT91C_UDP_RSTEP ((AT91_REG *) 0xFFFB0028) // (UDP) Reset Endpoint Register -#define AT91C_UDP_ICR ((AT91_REG *) 0xFFFB0020) // (UDP) Interrupt Clear Register -#define AT91C_UDP_IMR ((AT91_REG *) 0xFFFB0018) // (UDP) Interrupt Mask Register -#define AT91C_UDP_IER ((AT91_REG *) 0xFFFB0010) // (UDP) Interrupt Enable Register -#define AT91C_UDP_FADDR ((AT91_REG *) 0xFFFB0008) // (UDP) Function Address Register -#define AT91C_UDP_NUM ((AT91_REG *) 0xFFFB0000) // (UDP) Frame Number Register -// ========== Register definition for TC5 peripheral ========== -#define AT91C_TC5_CMR ((AT91_REG *) 0xFFFA4084) // (TC5) Channel Mode Register -#define AT91C_TC5_IDR ((AT91_REG *) 0xFFFA40A8) // (TC5) Interrupt Disable Register -#define AT91C_TC5_SR ((AT91_REG *) 0xFFFA40A0) // (TC5) Status Register -#define AT91C_TC5_RB ((AT91_REG *) 0xFFFA4098) // (TC5) Register B -#define AT91C_TC5_CV ((AT91_REG *) 0xFFFA4090) // (TC5) Counter Value -#define AT91C_TC5_CCR ((AT91_REG *) 0xFFFA4080) // (TC5) Channel Control Register -#define AT91C_TC5_IMR ((AT91_REG *) 0xFFFA40AC) // (TC5) Interrupt Mask Register -#define AT91C_TC5_IER ((AT91_REG *) 0xFFFA40A4) // (TC5) Interrupt Enable Register -#define AT91C_TC5_RC ((AT91_REG *) 0xFFFA409C) // (TC5) Register C -#define AT91C_TC5_RA ((AT91_REG *) 0xFFFA4094) // (TC5) Register A -// ========== Register definition for TC4 peripheral ========== -#define AT91C_TC4_IMR ((AT91_REG *) 0xFFFA406C) // (TC4) Interrupt Mask Register -#define AT91C_TC4_IER ((AT91_REG *) 0xFFFA4064) // (TC4) Interrupt Enable Register -#define AT91C_TC4_RC ((AT91_REG *) 0xFFFA405C) // (TC4) Register C -#define AT91C_TC4_RA ((AT91_REG *) 0xFFFA4054) // (TC4) Register A -#define AT91C_TC4_CMR ((AT91_REG *) 0xFFFA4044) // (TC4) Channel Mode Register -#define AT91C_TC4_IDR ((AT91_REG *) 0xFFFA4068) // (TC4) Interrupt Disable Register -#define AT91C_TC4_SR ((AT91_REG *) 0xFFFA4060) // (TC4) Status Register -#define AT91C_TC4_RB ((AT91_REG *) 0xFFFA4058) // (TC4) Register B -#define AT91C_TC4_CV ((AT91_REG *) 0xFFFA4050) // (TC4) Counter Value -#define AT91C_TC4_CCR ((AT91_REG *) 0xFFFA4040) // (TC4) Channel Control Register -// ========== Register definition for TC3 peripheral ========== -#define AT91C_TC3_IMR ((AT91_REG *) 0xFFFA402C) // (TC3) Interrupt Mask Register -#define AT91C_TC3_CV ((AT91_REG *) 0xFFFA4010) // (TC3) Counter Value -#define AT91C_TC3_CCR ((AT91_REG *) 0xFFFA4000) // (TC3) Channel Control Register -#define AT91C_TC3_IER ((AT91_REG *) 0xFFFA4024) // (TC3) Interrupt Enable Register -#define AT91C_TC3_CMR ((AT91_REG *) 0xFFFA4004) // (TC3) Channel Mode Register -#define AT91C_TC3_RA ((AT91_REG *) 0xFFFA4014) // (TC3) Register A -#define AT91C_TC3_RC ((AT91_REG *) 0xFFFA401C) // (TC3) Register C -#define AT91C_TC3_IDR ((AT91_REG *) 0xFFFA4028) // (TC3) Interrupt Disable Register -#define AT91C_TC3_RB ((AT91_REG *) 0xFFFA4018) // (TC3) Register B -#define AT91C_TC3_SR ((AT91_REG *) 0xFFFA4020) // (TC3) Status Register -// ========== Register definition for TCB1 peripheral ========== -#define AT91C_TCB1_BCR ((AT91_REG *) 0xFFFA4140) // (TCB1) TC Block Control Register -#define AT91C_TCB1_BMR ((AT91_REG *) 0xFFFA4144) // (TCB1) TC Block Mode Register -// ========== Register definition for TC2 peripheral ========== -#define AT91C_TC2_IMR ((AT91_REG *) 0xFFFA00AC) // (TC2) Interrupt Mask Register -#define AT91C_TC2_IER ((AT91_REG *) 0xFFFA00A4) // (TC2) Interrupt Enable Register -#define AT91C_TC2_RC ((AT91_REG *) 0xFFFA009C) // (TC2) Register C -#define AT91C_TC2_RA ((AT91_REG *) 0xFFFA0094) // (TC2) Register A -#define AT91C_TC2_CMR ((AT91_REG *) 0xFFFA0084) // (TC2) Channel Mode Register -#define AT91C_TC2_IDR ((AT91_REG *) 0xFFFA00A8) // (TC2) Interrupt Disable Register -#define AT91C_TC2_SR ((AT91_REG *) 0xFFFA00A0) // (TC2) Status Register -#define AT91C_TC2_RB ((AT91_REG *) 0xFFFA0098) // (TC2) Register B -#define AT91C_TC2_CV ((AT91_REG *) 0xFFFA0090) // (TC2) Counter Value -#define AT91C_TC2_CCR ((AT91_REG *) 0xFFFA0080) // (TC2) Channel Control Register -// ========== Register definition for TC1 peripheral ========== -#define AT91C_TC1_IMR ((AT91_REG *) 0xFFFA006C) // (TC1) Interrupt Mask Register -#define AT91C_TC1_IER ((AT91_REG *) 0xFFFA0064) // (TC1) Interrupt Enable Register -#define AT91C_TC1_RC ((AT91_REG *) 0xFFFA005C) // (TC1) Register C -#define AT91C_TC1_RA ((AT91_REG *) 0xFFFA0054) // (TC1) Register A -#define AT91C_TC1_CMR ((AT91_REG *) 0xFFFA0044) // (TC1) Channel Mode Register -#define AT91C_TC1_IDR ((AT91_REG *) 0xFFFA0068) // (TC1) Interrupt Disable Register -#define AT91C_TC1_SR ((AT91_REG *) 0xFFFA0060) // (TC1) Status Register -#define AT91C_TC1_RB ((AT91_REG *) 0xFFFA0058) // (TC1) Register B -#define AT91C_TC1_CV ((AT91_REG *) 0xFFFA0050) // (TC1) Counter Value -#define AT91C_TC1_CCR ((AT91_REG *) 0xFFFA0040) // (TC1) Channel Control Register -// ========== Register definition for TC0 peripheral ========== -#define AT91C_TC0_IMR ((AT91_REG *) 0xFFFA002C) // (TC0) Interrupt Mask Register -#define AT91C_TC0_IER ((AT91_REG *) 0xFFFA0024) // (TC0) Interrupt Enable Register -#define AT91C_TC0_RC ((AT91_REG *) 0xFFFA001C) // (TC0) Register C -#define AT91C_TC0_RA ((AT91_REG *) 0xFFFA0014) // (TC0) Register A -#define AT91C_TC0_CMR ((AT91_REG *) 0xFFFA0004) // (TC0) Channel Mode Register -#define AT91C_TC0_IDR ((AT91_REG *) 0xFFFA0028) // (TC0) Interrupt Disable Register -#define AT91C_TC0_SR ((AT91_REG *) 0xFFFA0020) // (TC0) Status Register -#define AT91C_TC0_RB ((AT91_REG *) 0xFFFA0018) // (TC0) Register B -#define AT91C_TC0_CV ((AT91_REG *) 0xFFFA0010) // (TC0) Counter Value -#define AT91C_TC0_CCR ((AT91_REG *) 0xFFFA0000) // (TC0) Channel Control Register -// ========== Register definition for TCB0 peripheral ========== -#define AT91C_TCB0_BMR ((AT91_REG *) 0xFFFA00C4) // (TCB0) TC Block Mode Register -#define AT91C_TCB0_BCR ((AT91_REG *) 0xFFFA00C0) // (TCB0) TC Block Control Register -// ========== Register definition for UHP peripheral ========== -#define AT91C_UHP_HcRhDescriptorA ((AT91_REG *) 0x00300048) // (UHP) Root Hub characteristics A -#define AT91C_UHP_HcRhPortStatus ((AT91_REG *) 0x00300054) // (UHP) Root Hub Port Status Register -#define AT91C_UHP_HcRhDescriptorB ((AT91_REG *) 0x0030004C) // (UHP) Root Hub characteristics B -#define AT91C_UHP_HcControl ((AT91_REG *) 0x00300004) // (UHP) Operating modes for the Host Controller -#define AT91C_UHP_HcInterruptStatus ((AT91_REG *) 0x0030000C) // (UHP) Interrupt Status Register -#define AT91C_UHP_HcRhStatus ((AT91_REG *) 0x00300050) // (UHP) Root Hub Status register -#define AT91C_UHP_HcRevision ((AT91_REG *) 0x00300000) // (UHP) Revision -#define AT91C_UHP_HcCommandStatus ((AT91_REG *) 0x00300008) // (UHP) Command & status Register -#define AT91C_UHP_HcInterruptEnable ((AT91_REG *) 0x00300010) // (UHP) Interrupt Enable Register -#define AT91C_UHP_HcHCCA ((AT91_REG *) 0x00300018) // (UHP) Pointer to the Host Controller Communication Area -#define AT91C_UHP_HcControlHeadED ((AT91_REG *) 0x00300020) // (UHP) First Endpoint Descriptor of the Control list -#define AT91C_UHP_HcInterruptDisable ((AT91_REG *) 0x00300014) // (UHP) Interrupt Disable Register -#define AT91C_UHP_HcPeriodCurrentED ((AT91_REG *) 0x0030001C) // (UHP) Current Isochronous or Interrupt Endpoint Descriptor -#define AT91C_UHP_HcControlCurrentED ((AT91_REG *) 0x00300024) // (UHP) Endpoint Control and Status Register -#define AT91C_UHP_HcBulkCurrentED ((AT91_REG *) 0x0030002C) // (UHP) Current endpoint of the Bulk list -#define AT91C_UHP_HcFmInterval ((AT91_REG *) 0x00300034) // (UHP) Bit time between 2 consecutive SOFs -#define AT91C_UHP_HcBulkHeadED ((AT91_REG *) 0x00300028) // (UHP) First endpoint register of the Bulk list -#define AT91C_UHP_HcBulkDoneHead ((AT91_REG *) 0x00300030) // (UHP) Last completed transfer descriptor -#define AT91C_UHP_HcFmRemaining ((AT91_REG *) 0x00300038) // (UHP) Bit time remaining in the current Frame -#define AT91C_UHP_HcPeriodicStart ((AT91_REG *) 0x00300040) // (UHP) Periodic Start -#define AT91C_UHP_HcLSThreshold ((AT91_REG *) 0x00300044) // (UHP) LS Threshold -#define AT91C_UHP_HcFmNumber ((AT91_REG *) 0x0030003C) // (UHP) Frame number -// ========== Register definition for EMAC peripheral ========== -#define AT91C_EMAC_RSR ((AT91_REG *) 0xFFFBC020) // (EMAC) Receive Status Register -#define AT91C_EMAC_MAN ((AT91_REG *) 0xFFFBC034) // (EMAC) PHY Maintenance Register -#define AT91C_EMAC_HSH ((AT91_REG *) 0xFFFBC090) // (EMAC) Hash Address High[63:32] -#define AT91C_EMAC_MCOL ((AT91_REG *) 0xFFFBC048) // (EMAC) Multiple Collision Frame Register -#define AT91C_EMAC_IER ((AT91_REG *) 0xFFFBC028) // (EMAC) Interrupt Enable Register -#define AT91C_EMAC_SA2H ((AT91_REG *) 0xFFFBC0A4) // (EMAC) Specific Address 2 High, Last 2 bytes -#define AT91C_EMAC_HSL ((AT91_REG *) 0xFFFBC094) // (EMAC) Hash Address Low[31:0] -#define AT91C_EMAC_LCOL ((AT91_REG *) 0xFFFBC05C) // (EMAC) Late Collision Register -#define AT91C_EMAC_OK ((AT91_REG *) 0xFFFBC04C) // (EMAC) Frames Received OK Register -#define AT91C_EMAC_CFG ((AT91_REG *) 0xFFFBC004) // (EMAC) Network Configuration Register -#define AT91C_EMAC_SA3L ((AT91_REG *) 0xFFFBC0A8) // (EMAC) Specific Address 3 Low, First 4 bytes -#define AT91C_EMAC_SEQE ((AT91_REG *) 0xFFFBC050) // (EMAC) Frame Check Sequence Error Register -#define AT91C_EMAC_ECOL ((AT91_REG *) 0xFFFBC060) // (EMAC) Excessive Collision Register -#define AT91C_EMAC_ELR ((AT91_REG *) 0xFFFBC070) // (EMAC) Excessive Length Error Register -#define AT91C_EMAC_SR ((AT91_REG *) 0xFFFBC008) // (EMAC) Network Status Register -#define AT91C_EMAC_RBQP ((AT91_REG *) 0xFFFBC018) // (EMAC) Receive Buffer Queue Pointer -#define AT91C_EMAC_CSE ((AT91_REG *) 0xFFFBC064) // (EMAC) Carrier Sense Error Register -#define AT91C_EMAC_RJB ((AT91_REG *) 0xFFFBC074) // (EMAC) Receive Jabber Register -#define AT91C_EMAC_USF ((AT91_REG *) 0xFFFBC078) // (EMAC) Undersize Frame Register -#define AT91C_EMAC_IDR ((AT91_REG *) 0xFFFBC02C) // (EMAC) Interrupt Disable Register -#define AT91C_EMAC_SA1L ((AT91_REG *) 0xFFFBC098) // (EMAC) Specific Address 1 Low, First 4 bytes -#define AT91C_EMAC_IMR ((AT91_REG *) 0xFFFBC030) // (EMAC) Interrupt Mask Register -#define AT91C_EMAC_FRA ((AT91_REG *) 0xFFFBC040) // (EMAC) Frames Transmitted OK Register -#define AT91C_EMAC_SA3H ((AT91_REG *) 0xFFFBC0AC) // (EMAC) Specific Address 3 High, Last 2 bytes -#define AT91C_EMAC_SA1H ((AT91_REG *) 0xFFFBC09C) // (EMAC) Specific Address 1 High, Last 2 bytes -#define AT91C_EMAC_SCOL ((AT91_REG *) 0xFFFBC044) // (EMAC) Single Collision Frame Register -#define AT91C_EMAC_ALE ((AT91_REG *) 0xFFFBC054) // (EMAC) Alignment Error Register -#define AT91C_EMAC_TAR ((AT91_REG *) 0xFFFBC00C) // (EMAC) Transmit Address Register -#define AT91C_EMAC_SA4L ((AT91_REG *) 0xFFFBC0B0) // (EMAC) Specific Address 4 Low, First 4 bytes -#define AT91C_EMAC_SA2L ((AT91_REG *) 0xFFFBC0A0) // (EMAC) Specific Address 2 Low, First 4 bytes -#define AT91C_EMAC_TUE ((AT91_REG *) 0xFFFBC068) // (EMAC) Transmit Underrun Error Register -#define AT91C_EMAC_DTE ((AT91_REG *) 0xFFFBC058) // (EMAC) Deferred Transmission Frame Register -#define AT91C_EMAC_TCR ((AT91_REG *) 0xFFFBC010) // (EMAC) Transmit Control Register -#define AT91C_EMAC_CTL ((AT91_REG *) 0xFFFBC000) // (EMAC) Network Control Register -#define AT91C_EMAC_SA4H ((AT91_REG *) 0xFFFBC0B4) // (EMAC) Specific Address 4 High, Last 2 bytesr -#define AT91C_EMAC_CDE ((AT91_REG *) 0xFFFBC06C) // (EMAC) Code Error Register -#define AT91C_EMAC_SQEE ((AT91_REG *) 0xFFFBC07C) // (EMAC) SQE Test Error Register -#define AT91C_EMAC_TSR ((AT91_REG *) 0xFFFBC014) // (EMAC) Transmit Status Register -#define AT91C_EMAC_DRFC ((AT91_REG *) 0xFFFBC080) // (EMAC) Discarded RX Frame Register -// ========== Register definition for EBI peripheral ========== -#define AT91C_EBI_CFGR ((AT91_REG *) 0xFFFFFF64) // (EBI) Configuration Register -#define AT91C_EBI_CSA ((AT91_REG *) 0xFFFFFF60) // (EBI) Chip Select Assignment Register -// ========== Register definition for SMC2 peripheral ========== -#define AT91C_SMC2_CSR ((AT91_REG *) 0xFFFFFF70) // (SMC2) SMC2 Chip Select Register -// ========== Register definition for SDRC peripheral ========== -#define AT91C_SDRC_IMR ((AT91_REG *) 0xFFFFFFAC) // (SDRC) SDRAM Controller Interrupt Mask Register -#define AT91C_SDRC_IER ((AT91_REG *) 0xFFFFFFA4) // (SDRC) SDRAM Controller Interrupt Enable Register -#define AT91C_SDRC_SRR ((AT91_REG *) 0xFFFFFF9C) // (SDRC) SDRAM Controller Self Refresh Register -#define AT91C_SDRC_TR ((AT91_REG *) 0xFFFFFF94) // (SDRC) SDRAM Controller Refresh Timer Register -#define AT91C_SDRC_ISR ((AT91_REG *) 0xFFFFFFB0) // (SDRC) SDRAM Controller Interrupt Mask Register -#define AT91C_SDRC_IDR ((AT91_REG *) 0xFFFFFFA8) // (SDRC) SDRAM Controller Interrupt Disable Register -#define AT91C_SDRC_LPR ((AT91_REG *) 0xFFFFFFA0) // (SDRC) SDRAM Controller Low Power Register -#define AT91C_SDRC_CR ((AT91_REG *) 0xFFFFFF98) // (SDRC) SDRAM Controller Configuration Register -#define AT91C_SDRC_MR ((AT91_REG *) 0xFFFFFF90) // (SDRC) SDRAM Controller Mode Register -// ========== Register definition for BFC peripheral ========== -#define AT91C_BFC_MR ((AT91_REG *) 0xFFFFFFC0) // (BFC) BFC Mode Register - -#include - -// ***************************************************************************** -// PERIPHERAL ID DEFINITIONS FOR AT91RM9200 -// ***************************************************************************** -#define AT91C_ID_FIQ 0u // Advanced Interrupt Controller (FIQ) -#define AT91C_ID_SYS 1u // System Peripheral -#define AT91C_ID_PIOA 2u // Parallel IO Controller A -#define AT91C_ID_PIOB 3u // Parallel IO Controller B -#define AT91C_ID_PIOC 4u // Parallel IO Controller C -#define AT91C_ID_PIOD 5u // Parallel IO Controller D -#define AT91C_ID_US0 6u // USART 0 -#define AT91C_ID_US1 7u // USART 1 -#define AT91C_ID_US2 8u // USART 2 -#define AT91C_ID_US3 9u // USART 3 -#define AT91C_ID_MCI 10u // Multimedia Card Interface -#define AT91C_ID_UDP 11u // USB Device Port -#define AT91C_ID_TWI 12u // Two-Wire Interface -#define AT91C_ID_SPI 13u // Serial Peripheral Interface -#define AT91C_ID_SSC0 14u // Serial Synchronous Controller 0 -#define AT91C_ID_SSC1 15u // Serial Synchronous Controller 1 -#define AT91C_ID_SSC2 16u // Serial Synchronous Controller 2 -#define AT91C_ID_TC0 17u // Timer Counter 0 -#define AT91C_ID_TC1 18u // Timer Counter 1 -#define AT91C_ID_TC2 19u // Timer Counter 2 -#define AT91C_ID_TC3 20u // Timer Counter 3 -#define AT91C_ID_TC4 21u // Timer Counter 4 -#define AT91C_ID_TC5 22u // Timer Counter 5 -#define AT91C_ID_UHP 23u // USB Host port -#define AT91C_ID_EMAC 24u // Ethernet MAC -#define AT91C_ID_IRQ0 25u // Advanced Interrupt Controller (IRQ0) -#define AT91C_ID_IRQ1 26u // Advanced Interrupt Controller (IRQ1) -#define AT91C_ID_IRQ2 27u // Advanced Interrupt Controller (IRQ2) -#define AT91C_ID_IRQ3 28u // Advanced Interrupt Controller (IRQ3) -#define AT91C_ID_IRQ4 29u // Advanced Interrupt Controller (IRQ4) -#define AT91C_ID_IRQ5 30u // Advanced Interrupt Controller (IRQ5) -#define AT91C_ID_IRQ6 31u // Advanced Interrupt Controller (IRQ6) - -// ***************************************************************************** -// BASE ADDRESS DEFINITIONS FOR AT91RM9200 -// ***************************************************************************** -#define AT91C_BASE_SYS ((AT91PS_SYS) 0xFFFFF000) // (SYS) Base Address -#define AT91C_BASE_MC ((AT91PS_MC) 0xFFFFFF00) // (MC) Base Address -#define AT91C_BASE_RTC ((AT91PS_RTC) 0xFFFFFE00) // (RTC) Base Address -#define AT91C_BASE_ST ((AT91PS_ST) 0xFFFFFD00) // (ST) Base Address -#define AT91C_BASE_PMC ((AT91PS_PMC) 0xFFFFFC00) // (PMC) Base Address -#define AT91C_BASE_CKGR ((AT91PS_CKGR) 0xFFFFFC20) // (CKGR) Base Address -#define AT91C_BASE_PIOD ((AT91PS_PIO) 0xFFFFFA00) // (PIOD) Base Address -#define AT91C_BASE_PIOC ((AT91PS_PIO) 0xFFFFF800) // (PIOC) Base Address -#define AT91C_BASE_PIOB ((AT91PS_PIO) 0xFFFFF600) // (PIOB) Base Address -#define AT91C_BASE_PIOA ((AT91PS_PIO) 0xFFFFF400) // (PIOA) Base Address -#define AT91C_BASE_DBGU ((AT91PS_DBGU) 0xFFFFF200) // (DBGU) Base Address -#define AT91C_BASE_PDC_DBGU ((AT91PS_PDC) 0xFFFFF300) // (PDC_DBGU) Base Address -#define AT91C_BASE_AIC ((AT91PS_AIC) 0xFFFFF000) // (AIC) Base Address -#define AT91C_BASE_PDC_SPI ((AT91PS_PDC) 0xFFFE0100) // (PDC_SPI) Base Address -#define AT91C_BASE_SPI ((AT91PS_SPI) 0xFFFE0000) // (SPI) Base Address -#define AT91C_BASE_PDC_SSC2 ((AT91PS_PDC) 0xFFFD8100) // (PDC_SSC2) Base Address -#define AT91C_BASE_SSC2 ((AT91PS_SSC) 0xFFFD8000) // (SSC2) Base Address -#define AT91C_BASE_PDC_SSC1 ((AT91PS_PDC) 0xFFFD4100) // (PDC_SSC1) Base Address -#define AT91C_BASE_SSC1 ((AT91PS_SSC) 0xFFFD4000) // (SSC1) Base Address -#define AT91C_BASE_PDC_SSC0 ((AT91PS_PDC) 0xFFFD0100) // (PDC_SSC0) Base Address -#define AT91C_BASE_SSC0 ((AT91PS_SSC) 0xFFFD0000) // (SSC0) Base Address -#define AT91C_BASE_PDC_US3 ((AT91PS_PDC) 0xFFFCC100) // (PDC_US3) Base Address -#define AT91C_BASE_US3 ((AT91PS_USART) 0xFFFCC000) // (US3) Base Address -#define AT91C_BASE_PDC_US2 ((AT91PS_PDC) 0xFFFC8100) // (PDC_US2) Base Address -#define AT91C_BASE_US2 ((AT91PS_USART) 0xFFFC8000) // (US2) Base Address -#define AT91C_BASE_PDC_US1 ((AT91PS_PDC) 0xFFFC4100) // (PDC_US1) Base Address -#define AT91C_BASE_US1 ((AT91PS_USART) 0xFFFC4000) // (US1) Base Address -#define AT91C_BASE_PDC_US0 ((AT91PS_PDC) 0xFFFC0100) // (PDC_US0) Base Address -#define AT91C_BASE_US0 ((AT91PS_USART) 0xFFFC0000) // (US0) Base Address -#define AT91C_BASE_TWI ((AT91PS_TWI) 0xFFFB8000) // (TWI) Base Address -#define AT91C_BASE_PDC_MCI ((AT91PS_PDC) 0xFFFB4100) // (PDC_MCI) Base Address -#define AT91C_BASE_MCI ((AT91PS_MCI) 0xFFFB4000) // (MCI) Base Address -#define AT91C_BASE_UDP ((AT91PS_UDP) 0xFFFB0000) // (UDP) Base Address -#define AT91C_BASE_TC5 ((AT91PS_TC) 0xFFFA4080) // (TC5) Base Address -#define AT91C_BASE_TC4 ((AT91PS_TC) 0xFFFA4040) // (TC4) Base Address -#define AT91C_BASE_TC3 ((AT91PS_TC) 0xFFFA4000) // (TC3) Base Address -#define AT91C_BASE_TCB1 ((AT91PS_TCB) 0xFFFA4080) // (TCB1) Base Address -#define AT91C_BASE_TC2 ((AT91PS_TC) 0xFFFA0080) // (TC2) Base Address -#define AT91C_BASE_TC1 ((AT91PS_TC) 0xFFFA0040) // (TC1) Base Address -#define AT91C_BASE_TC0 ((AT91PS_TC) 0xFFFA0000) // (TC0) Base Address -#define AT91C_BASE_TCB0 ((AT91PS_TCB) 0xFFFA0000) // (TCB0) Base Address -#define AT91C_BASE_UHP ((AT91PS_UHP) 0x00300000) // (UHP) Base Address -#define AT91C_BASE_EMAC ((AT91PS_EMAC) 0xFFFBC000) // (EMAC) Base Address -#define AT91C_BASE_EBI ((AT91PS_EBI) 0xFFFFFF60) // (EBI) Base Address -#define AT91C_BASE_SMC2 ((AT91PS_SMC2) 0xFFFFFF70) // (SMC2) Base Address -#define AT91C_BASE_SDRC ((AT91PS_SDRC) 0xFFFFFF90) // (SDRC) Base Address -#define AT91C_BASE_BFC ((AT91PS_BFC) 0xFFFFFFC0) // (BFC) Base Address - -// ***************************************************************************** -// MEMORY MAPPING DEFINITIONS FOR AT91RM9200 -// ***************************************************************************** -#define AT91C_ISRAM ((char *) 0x00200000) // Internal SRAM base address -#define AT91C_ISRAM_SIZE 0x00004000u // Internal SRAM size in byte (16 Kbyte) -#define AT91C_IROM ((char *) 0x00100000) // Internal ROM base address -#define AT91C_IROM_SIZE 0x00020000u // Internal ROM size in byte (128 Kbyte) - -#endif Property changes on: stable/11/sys/boot/arm/at91/libat91/at91rm9200.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/spi_flash.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/spi_flash.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/spi_flash.c (nonexistent) @@ -1,267 +0,0 @@ -/****************************************************************************** - * - * Filename: spi_flash.c - * - * Instantiation of SPI flash control routines supporting AT45DB161B - * - * Revision information: - * - * 17JAN2005 kb_admin initial creation - * adapted from external sources - * tested for basic operation only!!! - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "at91rm9200.h" -#include "spi_flash.h" -#include "lib.h" - -/*********************** PRIVATE FUNCTIONS/DATA ******************************/ - - -static spiCommand_t spi_command; -static char tx_commandBuffer[8], rx_commandBuffer[8]; - -/* - * .KB_C_FN_DEFINITION_START - * void SendCommand(spiCommand_t *pCommand) - * Private function sends 8-bit value to the device and returns the 8-bit - * value in response. - * .KB_C_FN_DEFINITION_END - */ -static void -SendCommand(spiCommand_t *pCommand) -{ - AT91PS_SPI pSPI = AT91C_BASE_SPI; - - pSPI->SPI_PTCR = AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS; - - pSPI->SPI_RPR = (unsigned)pCommand->rx_cmd; - pSPI->SPI_RCR = pCommand->rx_cmd_size; - pSPI->SPI_TPR = (unsigned)pCommand->tx_cmd; - pSPI->SPI_TCR = pCommand->tx_cmd_size; - - pSPI->SPI_TNPR = (unsigned)pCommand->tx_data; - pSPI->SPI_TNCR = pCommand->tx_data_size; - pSPI->SPI_RNPR = (unsigned)pCommand->rx_data; - pSPI->SPI_RNCR = pCommand->rx_data_size; - - pSPI->SPI_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTEN; - - // wait for completion - while (!(pSPI->SPI_SR & AT91C_SPI_SPENDRX)) - Delay(700); -} - - -/* - * .KB_C_FN_DEFINITION_START - * char GetFlashStatus(void) - * Private function to return device status. - * .KB_C_FN_DEFINITION_END - */ -static char -GetFlashStatus(void) -{ - p_memset((char *)&spi_command, 0, sizeof(spi_command)); - p_memset(tx_commandBuffer, 0, 8); - tx_commandBuffer[0] = STATUS_REGISTER_READ; - p_memset(rx_commandBuffer, 0, 8); - spi_command.tx_cmd = tx_commandBuffer; - spi_command.rx_cmd = rx_commandBuffer; - spi_command.rx_cmd_size = 2; - spi_command.tx_cmd_size = 2; - SendCommand(&spi_command); - return (rx_commandBuffer[1]); -} - -/* - * .KB_C_FN_DEFINITION_START - * void WaitForDeviceReady(void) - * Private function to poll until the device is ready for next operation. - * .KB_C_FN_DEFINITION_END - */ -static void -WaitForDeviceReady(void) -{ - while (!(GetFlashStatus() & 0x80)) ; -} - -/*************************** GLOBAL FUNCTIONS ********************************/ - - -/* - * .KB_C_FN_DEFINITION_START - * void SPI_ReadFlash(unsigned flash_addr, unsigned dest_addr, unsigned size) - * Global function to read the SPI flash device using the continuous read - * array command. - * .KB_C_FN_DEFINITION_END - */ -void -SPI_ReadFlash(unsigned flash_addr, char *dest_addr, unsigned size) -{ - unsigned pageAddress, byteAddress; - - // determine page address - pageAddress = flash_addr / FLASH_PAGE_SIZE; - - // determine byte address - byteAddress = flash_addr % FLASH_PAGE_SIZE; - - p_memset(tx_commandBuffer, 0, 8); -#ifdef BOOT_BWCT - tx_commandBuffer[0] = 0xd2; - tx_commandBuffer[1] = ((pageAddress >> 6) & 0xFF); - tx_commandBuffer[2] = ((pageAddress << 2) & 0xFC) | - ((byteAddress >> 8) & 0x3); - tx_commandBuffer[3] = byteAddress & 0xFF; - spi_command.tx_cmd = tx_commandBuffer; - spi_command.tx_cmd_size = 8; - spi_command.tx_data_size = size; - spi_command.tx_data = dest_addr; - - p_memset(rx_commandBuffer, 0, 8); - spi_command.rx_cmd = rx_commandBuffer; - spi_command.rx_cmd_size = 8; - spi_command.rx_data_size = size; - spi_command.rx_data = dest_addr; -#else - tx_commandBuffer[0] = CONTINUOUS_ARRAY_READ_HF; - tx_commandBuffer[1] = ((pageAddress >> 5) & 0xFF); - tx_commandBuffer[2] = ((pageAddress << 3) & 0xF8) | - ((byteAddress >> 8) & 0x7); - tx_commandBuffer[3] = byteAddress & 0xFF; - spi_command.tx_cmd = tx_commandBuffer; - spi_command.tx_cmd_size = 5; - spi_command.tx_data_size = size; - spi_command.tx_data = dest_addr; - - p_memset(rx_commandBuffer, 0, 8); - spi_command.rx_cmd = rx_commandBuffer; - spi_command.rx_cmd_size = 5; - spi_command.rx_data_size = size; - spi_command.rx_data = dest_addr; -#endif - - SendCommand(&spi_command); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void SPI_WriteFlash(unsigned flash_addr, unsigned src_addr, unsigned size) - * Global function to program the SPI flash device. Notice the warning - * provided in lower-level functions regarding corruption of data in non- - * page aligned write operations. - * .KB_C_FN_DEFINITION_END - */ -void -SPI_WriteFlash(unsigned flash_addr, char *src_addr, unsigned size) -{ - unsigned pageAddress, byteAddress; - - // determine page address - pageAddress = flash_addr / FLASH_PAGE_SIZE; - - // determine byte address - byteAddress = flash_addr % FLASH_PAGE_SIZE; - - p_memset(tx_commandBuffer, 0, 8); -#ifdef BOOT_BWCT - tx_commandBuffer[0] = 0x82; - tx_commandBuffer[1] = ((pageAddress >> 6) & 0xFF); - tx_commandBuffer[2] = ((pageAddress << 2) & 0xFC) | - ((byteAddress >> 8) & 0x3); - tx_commandBuffer[3] = (byteAddress & 0xFF); -#else - tx_commandBuffer[0] = PROGRAM_THROUGH_BUFFER; - tx_commandBuffer[1] = ((pageAddress >> 5) & 0xFF); - tx_commandBuffer[2] = ((pageAddress << 3) & 0xF8) | - ((byteAddress >> 8) & 0x7); - tx_commandBuffer[3] = (byteAddress & 0xFF); -#endif - - p_memset(rx_commandBuffer, 0, 8); - - spi_command.tx_cmd = tx_commandBuffer; - spi_command.rx_cmd = rx_commandBuffer; - spi_command.rx_cmd_size = 4; - spi_command.tx_cmd_size = 4; - - spi_command.tx_data_size = size; - spi_command.tx_data = src_addr; - spi_command.rx_data_size = size; - spi_command.rx_data = src_addr; - - SendCommand(&spi_command); - - WaitForDeviceReady(); -} - -/* - * .KB_C_FN_DEFINITION_START - * void SPI_InitFlash(void) - * Global function to initialize the SPI flash device/accessor functions. - * .KB_C_FN_DEFINITION_END - */ -void -SPI_InitFlash(void) -{ - AT91PS_PIO pPio; - AT91PS_SPI pSPI = AT91C_BASE_SPI; - unsigned value; - - // enable CS0, CLK, MOSI, MISO - pPio = (AT91PS_PIO)AT91C_BASE_PIOA; - pPio->PIO_ASR = AT91C_PIO_PA3 | AT91C_PIO_PA1 | AT91C_PIO_PA0 | - AT91C_PIO_PA2; - pPio->PIO_PDR = AT91C_PIO_PA3 | AT91C_PIO_PA1 | AT91C_PIO_PA0 | - AT91C_PIO_PA2; - - // enable clocks to SPI - AT91C_BASE_PMC->PMC_PCER = 1u << AT91C_ID_SPI; - - // reset the SPI - pSPI->SPI_CR = AT91C_SPI_SWRST; - - pSPI->SPI_MR = (0xf << 24) | AT91C_SPI_MSTR | AT91C_SPI_MODFDIS | - (0xE << 16); - - pSPI->SPI_CSR[0] = AT91C_SPI_CPOL | (4 << 16) | (2 << 8); - pSPI->SPI_CR = AT91C_SPI_SPIEN; - - pSPI->SPI_PTCR = AT91C_PDC_TXTDIS; - pSPI->SPI_PTCR = AT91C_PDC_RXTDIS; - pSPI->SPI_RNPR = 0; - pSPI->SPI_RNCR = 0; - pSPI->SPI_TNPR = 0; - pSPI->SPI_TNCR = 0; - pSPI->SPI_RPR = 0; - pSPI->SPI_RCR = 0; - pSPI->SPI_TPR = 0; - pSPI->SPI_TCR = 0; - pSPI->SPI_PTCR = AT91C_PDC_RXTEN; - pSPI->SPI_PTCR = AT91C_PDC_TXTEN; - - value = pSPI->SPI_RDR; - value = pSPI->SPI_SR; - - value = GetFlashStatus() & 0xFC; -#ifdef BOOT_BWCT - if (value != 0xB4 && value != 0xAC) - printf(" Bad SPI status: 0x%x\n", value); -#else - if (value != 0xBC) - printf(" Bad SPI status: 0x%x\n", value); -#endif -} Property changes on: stable/11/sys/boot/arm/at91/libat91/spi_flash.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/spi_flash.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/spi_flash.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/spi_flash.h (nonexistent) @@ -1,58 +0,0 @@ -/******************************************************************************* - * - * Filename: spi_flash.h - * - * Definition of flash control routines supporting AT45DB161B - * - * Revision information: - * - * 17JAN2005 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - ******************************************************************************/ - -#ifndef _SPI_FLASH_H_ -#define _SPI_FLASH_H_ - -typedef struct { - char *tx_cmd; - unsigned tx_cmd_size; - char *rx_cmd; - unsigned rx_cmd_size; - char *tx_data; - unsigned tx_data_size; - char *rx_data; - unsigned rx_data_size; -} spiCommand_t; - -void SPI_ReadFlash(unsigned flash_addr, char *dest_addr, unsigned size); -void SPI_WriteFlash(unsigned flash_addr, char *dest_addr, unsigned size); -void SPI_InitFlash(void); - -void SPI_GetId(unsigned *id); - -#ifdef BOOT_BWCT -#define FLASH_PAGE_SIZE 528 -#else -#define FLASH_PAGE_SIZE 1056 -#endif - -// Flash commands - -#define CONTINUOUS_ARRAY_READ 0xE8 -#define CONTINUOUS_ARRAY_READ_HF 0x0B -#define CONTINUOUS_ARRAY_READ_LF 0x03 -#define STATUS_REGISTER_READ 0xD7 -#define PROGRAM_THROUGH_BUFFER 0x82 -#define MANUFACTURER_ID 0x9F - -#endif Property changes on: stable/11/sys/boot/arm/at91/libat91/spi_flash.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/tag_list.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/tag_list.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/tag_list.c (nonexistent) @@ -1,81 +0,0 @@ -/****************************************************************************** - * - * Filename: tag_list.c - * - * Instantiation of basic routines that create linux-boot tag list. - * - * Revision information: - * - * 22AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -/******************************* GLOBALS *************************************/ - -/********************** PRIVATE FUNCTIONS/DATA/DEFINES ***********************/ - -#define u32 unsigned -#define u16 unsigned short -#define u8 unsigned char - -// #include "/usr/src/arm/linux/include/asm/setup.h" -#include -#include "tag_list.h" - -#define PAGE_SIZE 0x1000 -#define MEM_SIZE 0x2000000 -#define PHYS_OFFSET 0x20000000 - -/*************************** GLOBAL FUNCTIONS ********************************/ - -/* - * .KB_C_FN_DEFINITION_START - * void InitTagList(char*, void *) - * This global function populates a linux-boot style tag list from the - * string passed in the pointer at the location specified. - * .KB_C_FN_DEFINITION_END - */ -void InitTagList(char *parms, void *output) { - - char *src, *dst; - struct tag *tagList = (struct tag*)output; - - tagList->hdr.size = tag_size(tag_core); - tagList->hdr.tag = ATAG_CORE; - tagList->u.core.flags = 1; - tagList->u.core.pagesize = PAGE_SIZE; - tagList->u.core.rootdev = 0xff; - tagList = tag_next(tagList); - - tagList->hdr.size = tag_size(tag_mem32); - tagList->hdr.tag = ATAG_MEM; - tagList->u.mem.size = MEM_SIZE; - tagList->u.mem.start = PHYS_OFFSET; - tagList = tag_next(tagList); - - tagList->hdr.size = tag_size(tag_cmdline); - tagList->hdr.tag = ATAG_CMDLINE; - - src = parms; - dst = tagList->u.cmdline.cmdline; - while (*src) { - *dst++ = *src++; - } - *dst = 0; - - tagList->hdr.size += ((unsigned)(src - parms) + 1) / sizeof(unsigned); - tagList = tag_next(tagList); - - tagList->hdr.size = 0; - tagList->hdr.tag = ATAG_NONE; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/tag_list.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/Makefile =================================================================== --- stable/11/sys/boot/arm/at91/libat91/Makefile (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/Makefile (nonexistent) @@ -1,22 +0,0 @@ -# $FreeBSD$ - -.include -.include "${.CURDIR}/../Makefile.inc" - -SOC?=at91rm9200 - -LIB= at91 -INTERNALLIB= -SRCS=${SOC}_lowlevel.c delay.c eeprom.c emac.c emac_init.c getc.c \ - putchar.c printf.c reset.c spi_flash.c xmodem.c \ - sd-card.c strcvt.c strlen.c strcmp.c memcpy.c strcpy.c \ - memset.c memcmp.c -SRCS+=ashldi3.c divsi3.S -MAN= - -.if ${MK_TAG_LIST} != "no" -CFLAGS += -I${.CURDIR}/.. -DSUPPORT_TAG_LIST -SRCS+=tag_list.c -.endif - -.include Property changes on: stable/11/sys/boot/arm/at91/libat91/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/memset.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/memset.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/memset.c (nonexistent) @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "lib.h" - -void -p_memset(char *buffer, char value, int size) -{ - while (size--) - *buffer++ = value; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/memset.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/tag_list.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/tag_list.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/tag_list.h (nonexistent) @@ -1,28 +0,0 @@ -/***************************************************************************** - * - * Filename: tag_list.h - * - * Definition of basic routines that create linux-boot tag list. - * - * Revision information: - * - * 22AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - ****************************************************************************/ - -#ifndef _TAG_LIST_H_ -#define _TAG_LIST_H_ - -extern void InitTagList(char *parms, void*); - -#endif /* _TAG_LIST_H_ */ Property changes on: stable/11/sys/boot/arm/at91/libat91/tag_list.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/p_string.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/p_string.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/p_string.c (nonexistent) @@ -1,57 +0,0 @@ -/****************************************************************************** - * - * Filename: p_string.c - * - * Instantiation of basic string operations to prevent inclusion of full - * string library. These are simple implementations not necessarily optimized - * for speed, but rather to show intent. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin minor updates - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "lib.h" - -/* - * .KB_C_FN_DEFINITION_START - * void p_memset(char *buffer, char value, int size) - * This global function sets memory at the pointer for the specified - * number of bytes to value. - * .KB_C_FN_DEFINITION_END - */ -void -p_memset(char *buffer, char value, int size) -{ - while (size--) - *buffer++ = value; -} - -/* - * .KB_C_FN_DEFINITION_START - * int p_memcmp(char *to, char *from, unsigned size) - * This global function compares data at to against data at from for - * size bytes. Returns 0 if the locations are equal. size must be - * greater than 0. - * .KB_C_FN_DEFINITION_END - */ -int -p_memcmp(const char *to, const char *from, unsigned size) -{ - while ((--size) && (*to++ == *from++)) - continue; - - return (*to != *from); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/p_string.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/eeprom.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/eeprom.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/eeprom.c (nonexistent) @@ -1,185 +0,0 @@ -/****************************************************************************** - * - * Filename: eeprom.c - * - * Instantiation of eeprom routines - * - * Revision information: - * - * 28AUG2004 kb_admin initial creation - adapted from Atmel sources - * 12JAN2005 kb_admin fixed clock generation, write polling, init - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - -#include "at91rm9200_lowlevel.h" -#include "at91rm9200.h" -#include "lib.h" - -/******************************* GLOBALS *************************************/ - - -/*********************** PRIVATE FUNCTIONS/DATA ******************************/ - - -/* Use a macro to calculate the TWI clock generator value to save code space. */ -#define AT91C_TWSI_CLOCK 100000 -#define TWSI_EEPROM_ADDRESS 0x50 - -#define TWI_CLK_BASE_DIV ((AT91C_MASTER_CLOCK/(4*AT91C_TWSI_CLOCK)) - 2) -#define SET_TWI_CLOCK ((0x00010000) | (TWI_CLK_BASE_DIV) | (TWI_CLK_BASE_DIV << 8)) - - -/*************************** GLOBAL FUNCTIONS ********************************/ - - -/* - * .KB_C_FN_DEFINITION_START - * void InitEEPROM(void) - * This global function initializes the EEPROM interface (TWI). Intended - * to be called a single time. - * .KB_C_FN_DEFINITION_END - */ -void -InitEEPROM(void) -{ - - AT91PS_TWI twiPtr = (AT91PS_TWI)AT91C_BASE_TWI; - - AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA; - AT91PS_PMC pPMC = (AT91PS_PMC)AT91C_BASE_PMC; - - pPio->PIO_ASR = AT91C_PIO_PA25 | AT91C_PIO_PA26; - pPio->PIO_PDR = AT91C_PIO_PA25 | AT91C_PIO_PA26; - - pPio->PIO_MDDR = ~AT91C_PIO_PA25; - pPio->PIO_MDER = AT91C_PIO_PA25; - - pPMC->PMC_PCER = 1u << AT91C_ID_TWI; - - twiPtr->TWI_IDR = 0xffffffffu; - twiPtr->TWI_CR = AT91C_TWI_SWRST; - twiPtr->TWI_CR = AT91C_TWI_MSEN | AT91C_TWI_SVDIS; - - twiPtr->TWI_CWGR = SET_TWI_CLOCK; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size) - * This global function reads data from the eeprom at ee_addr storing data - * to data_addr for size bytes. Assume the TWI has been initialized. - * This function does not utilize the page read mode to simplify the code. - * .KB_C_FN_DEFINITION_END - */ -int -ReadEEPROM(unsigned ee_off, unsigned char *data_addr, unsigned size) -{ - const AT91PS_TWI twiPtr = AT91C_BASE_TWI; - unsigned int status; - unsigned int count; - - status = twiPtr->TWI_SR; - status = twiPtr->TWI_RHR; - - // Set the TWI Master Mode Register - twiPtr->TWI_MMR = (TWSI_EEPROM_ADDRESS << 16) | - AT91C_TWI_IADRSZ_2_BYTE | AT91C_TWI_MREAD; - - // Set TWI Internal Address Register - twiPtr->TWI_IADR = ee_off; - - // Start transfer - twiPtr->TWI_CR = AT91C_TWI_START; - - status = twiPtr->TWI_SR; - - while (size-- > 1){ - // Wait RHR Holding register is full - count = 1000000; - while (!(twiPtr->TWI_SR & AT91C_TWI_RXRDY) && --count > 0) - continue; - if (count <= 0) - return -1; - - // Read byte - *(data_addr++) = twiPtr->TWI_RHR; - } - - twiPtr->TWI_CR = AT91C_TWI_STOP; - - status = twiPtr->TWI_SR; - - // Wait transfer is finished - while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)) - continue; - - // Read last byte - *data_addr = twiPtr->TWI_RHR; - return 0; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void WriteEEPROM(unsigned ee_off, char *data_addr, unsigned size) - * This global function writes data to the eeprom at ee_off using data - * from data_addr for size bytes. Assume the TWI has been initialized. - * This function does not utilize the page write mode as the write time is - * much greater than the time required to access the device for byte-write - * functionality. This allows the function to be much simpler. - * .KB_C_FN_DEFINITION_END - */ -void -WriteEEPROM(unsigned ee_off, char *data_addr, unsigned size) -{ - const AT91PS_TWI twiPtr = AT91C_BASE_TWI; - unsigned status; - unsigned char test_data; - - while (size--) { - if (!(ee_off & 0x3f)) - putchar('.'); - - // Set the TWI Master Mode Register - twiPtr->TWI_MMR = ((TWSI_EEPROM_ADDRESS << 16) | - AT91C_TWI_IADRSZ_2_BYTE) & ~AT91C_TWI_MREAD; - - // Set TWI Internal Address Register - twiPtr->TWI_IADR = ee_off++; - - status = twiPtr->TWI_SR; - - twiPtr->TWI_THR = *(data_addr++); - - twiPtr->TWI_CR = AT91C_TWI_START; - - // Wait transfer is finished - while (!(twiPtr->TWI_SR & AT91C_TWI_TXRDY)) - continue; - - twiPtr->TWI_CR = AT91C_TWI_STOP; - - status = twiPtr->TWI_SR; - - // Wait transfer is finished - while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)) - continue; - - // wait for write operation to complete - ReadEEPROM(ee_off, &test_data, 1); - } - - putchar('\r'); - putchar('\n'); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/eeprom.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/delay.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/delay.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/delay.c (nonexistent) @@ -1,43 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "spi_flash.h" -#include "lib.h" - -void -Delay(int us) -{ - unsigned later, now; - - now = AT91C_BASE_ST->ST_CRTR; - later = (now + us / 25 + 1) & AT91C_ST_CRTV; - while (later != AT91C_BASE_ST->ST_CRTR) - continue; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/delay.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/lib.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/lib.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/lib.h (nonexistent) @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef ARM_BOOT_LIB_H -#define ARM_BOOT_LIB_H - -int getc(int); -void putchar(int); -void xputchar(int); -void printf(const char *fmt,...); - -/* The following function write eeprom at ee_addr using data */ -/* from data_add for size bytes. */ -int ReadEEPROM(unsigned eeoff, unsigned char *data_addr, unsigned size); -void WriteEEPROM(unsigned eeoff, char *data_addr, unsigned size); -void InitEEPROM(void); - -/* XMODEM protocol */ -int xmodem_rx(char *dst); - -/* */ -void start_wdog(int n); -void reset(void); - -/* Delay us */ -void Delay(int us); - -#define ToASCII(x) ((x > 9) ? (x + 'A' - 0xa) : (x + '0')) - -int p_IsWhiteSpace(char cValue); -unsigned p_HexCharValue(char cValue); -unsigned p_ASCIIToHex(const char *buf); -unsigned p_ASCIIToDec(const char *buf); - -void p_memset(char *buffer, char value, int size); -int p_strlen(const char *buffer); -char *strcpy(char *to, const char *from); -void memcpy(void *to, const void *from, unsigned size); -int p_memcmp(const char *to, const char *from, unsigned size); -int strcmp(const char *to, const char *from); - -#endif Property changes on: stable/11/sys/boot/arm/at91/libat91/lib.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/emac.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/emac.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/emac.c (nonexistent) @@ -1,575 +0,0 @@ -/******************************************************************************* - * - * Filename: emac.c - * - * Instantiation of routines for MAC/ethernet functions supporting tftp. - * - * Revision information: - * - * 28AUG2004 kb_admin initial creation - * 08JAN2005 kb_admin added tftp download - * also adapted from external sources - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - ******************************************************************************/ - -#include "at91rm9200.h" -#include "at91rm9200_lowlevel.h" -#include "emac.h" -#include "lib.h" - -/* ****************************** GLOBALS *************************************/ - -/* ********************** PRIVATE FUNCTIONS/DATA ******************************/ - -static receive_descriptor_t *p_rxBD; -static unsigned short localPort; -static unsigned short serverPort; -static unsigned serverMACSet; -static unsigned localIPSet, serverIPSet; -static unsigned lastSize; -static unsigned char serverMACAddr[6]; -static unsigned char localIPAddr[4], serverIPAddr[4]; -static int ackBlock; -static char *dlAddress; - -static unsigned transmitBuffer[1024 / sizeof(unsigned)]; -static unsigned tftpSendPacket[256 / sizeof(unsigned)]; - -/* - * .KB_C_FN_DEFINITION_START - * unsigned short IP_checksum(unsigned short *p, int len) - * This private function calculates the IP checksum for various headers. - * .KB_C_FN_DEFINITION_END - */ -static unsigned short -IP_checksum(unsigned short *p, int len) -{ - unsigned i, t; - - len &= ~1; - - for (i=0,t=0; i> 16); - return (~t); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void GetServerAddress(void) - * This private function sends an ARP request to determine the server MAC. - * .KB_C_FN_DEFINITION_END - */ -static void -GetServerAddress(void) -{ - arp_header_t *p_ARP; - - p_ARP = (arp_header_t*)transmitBuffer; - - p_memset((char*)p_ARP->dest_mac, 0xFF, 6); - - memcpy(p_ARP->src_mac, localMACAddr, 6); - - p_ARP->frame_type = SWAP16(PROTOCOL_ARP); - p_ARP->hard_type = SWAP16(1); - p_ARP->prot_type = SWAP16(PROTOCOL_IP); - p_ARP->hard_size = 6; - p_ARP->prot_size = 4; - p_ARP->operation = SWAP16(ARP_REQUEST); - - memcpy(p_ARP->sender_mac, localMACAddr, 6); - memcpy(p_ARP->sender_ip, localIPAddr, 4); - p_memset((char*)p_ARP->target_mac, 0, 6); - memcpy(p_ARP->target_ip, serverIPAddr, 4); - - // wait until transmit is available - while (!(*AT91C_EMAC_TSR & AT91C_EMAC_BNQ)) - continue; - - *AT91C_EMAC_TSR |= AT91C_EMAC_COMP; - *AT91C_EMAC_TAR = (unsigned)transmitBuffer; - *AT91C_EMAC_TCR = 0x40; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void Send_TFTP_Packet(char *tftpData, unsigned tftpLength) - * This private function initializes and send a TFTP packet. - * .KB_C_FN_DEFINITION_END - */ -static void -Send_TFTP_Packet(char *tftpData, unsigned tftpLength) -{ - transmit_header_t *macHdr = (transmit_header_t*)tftpSendPacket; - ip_header_t *ipHdr; - udp_header_t *udpHdr; - unsigned t_checksum; - - memcpy(macHdr->dest_mac, serverMACAddr, 6); - memcpy(macHdr->src_mac, localMACAddr, 6); - macHdr->proto_mac = SWAP16(PROTOCOL_IP); - - ipHdr = (ip_header_t*)&macHdr->packet_length; - - ipHdr->ip_v_hl = 0x45; - ipHdr->ip_tos = 0; - ipHdr->ip_len = SWAP16(28 + tftpLength); - ipHdr->ip_id = 0; - ipHdr->ip_off = SWAP16(0x4000); - ipHdr->ip_ttl = 64; - ipHdr->ip_p = PROTOCOL_UDP; - ipHdr->ip_sum = 0; - - memcpy(ipHdr->ip_src, localIPAddr, 4); - memcpy(ipHdr->ip_dst, serverIPAddr, 4); - - ipHdr->ip_sum = SWAP16(IP_checksum((unsigned short*)ipHdr, 20)); - - udpHdr = (udp_header_t*)(ipHdr + 1); - - udpHdr->src_port = localPort; - udpHdr->dst_port = serverPort; - udpHdr->udp_len = SWAP16(8 + tftpLength); - udpHdr->udp_cksum = 0; - - memcpy((char *)udpHdr+8, tftpData, tftpLength); - - t_checksum = IP_checksum((unsigned short*)ipHdr + 6, (16 + tftpLength)); - - t_checksum = (~t_checksum) & 0xFFFF; - t_checksum += 25 + tftpLength; - - t_checksum = (t_checksum & 0xffff) + (t_checksum >> 16); - t_checksum = (~t_checksum) & 0xFFFF; - - udpHdr->udp_cksum = SWAP16(t_checksum); - - while (!(*AT91C_EMAC_TSR & AT91C_EMAC_BNQ)) - continue; - - *AT91C_EMAC_TSR |= AT91C_EMAC_COMP; - *AT91C_EMAC_TAR = (unsigned)tftpSendPacket; - *AT91C_EMAC_TCR = 42 + tftpLength; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void TFTP_RequestFile(char *filename) - * This private function sends a RRQ packet to the server. - * .KB_C_FN_DEFINITION_END - */ -static void -TFTP_RequestFile(char *filename) -{ - tftp_header_t tftpHeader; - char *cPtr, *ePtr, *mPtr; - unsigned length; - - tftpHeader.opcode = TFTP_RRQ_OPCODE; - - cPtr = (char*)&(tftpHeader.block_num); - - ePtr = strcpy(cPtr, filename); - mPtr = strcpy(ePtr, "octet"); - - length = mPtr - cPtr; - length += 2; - - Send_TFTP_Packet((char*)&tftpHeader, length); -} - - -/* - * .KB_C_FN_DEFINITION_START - * void TFTP_ACK_Data(char *data, unsigned short block_num, unsigned short len) - * This private function sends an ACK packet to the server. - * .KB_C_FN_DEFINITION_END - */ -static void -TFTP_ACK_Data(unsigned char *data, unsigned short block_num, unsigned short len) -{ - tftp_header_t tftpHeader; - - if (block_num == (ackBlock + 1)) { - ++ackBlock; - memcpy(dlAddress, data, len); - dlAddress += len; - lastSize += len; - if (ackBlock % 128 == 0) - printf("tftp: %u kB\r", lastSize / 1024); - } - tftpHeader.opcode = TFTP_ACK_OPCODE; - tftpHeader.block_num = SWAP16(ackBlock); - Send_TFTP_Packet((char*)&tftpHeader, 4); - if (len < 512) { - ackBlock = -2; - printf("tftp: %u byte\n", lastSize); - } -} - - -/* - * .KB_C_FN_DEFINITION_START - * void CheckForNewPacket(ip_header_t *pHeader) - * This private function polls for received ethernet packets and handles - * any here. - * .KB_C_FN_DEFINITION_END - */ -static int -CheckForNewPacket(ip_header_t *pHeader) -{ - unsigned short *pFrameType; - unsigned i; - char *pData; - ip_header_t *pIpHeader; - arp_header_t *p_ARP; - int process = 0; - - process = 0; - for (i = 0; i < MAX_RX_PACKETS; ++i) { - if(p_rxBD[i].address & 0x1) { - process = 1; - (*AT91C_EMAC_RSR) |= (*AT91C_EMAC_RSR); - break; - } - } - - if (!process) - return (0); - process = i; - - pFrameType = (unsigned short *)((p_rxBD[i].address & 0xFFFFFFFC) + 12); - pData = (char *)(p_rxBD[i].address & 0xFFFFFFFC); - - switch (*pFrameType) { - - case SWAP16(PROTOCOL_ARP): - p_ARP = (arp_header_t*)pData; - if (p_ARP->operation == SWAP16(ARP_REPLY)) { - // check if new server info is available - if ((!serverMACSet) && - (!(p_memcmp((char*)p_ARP->sender_ip, - (char*)serverIPAddr, 4)))) { - - serverMACSet = 1; - memcpy(serverMACAddr, p_ARP->sender_mac, 6); - } - } else if (p_ARP->operation == SWAP16(ARP_REQUEST)) { - // ARP REPLY operation - p_ARP->operation = SWAP16(ARP_REPLY); - - // Fill the dest address and src address - for (i = 0; i <6; i++) { - // swap ethernet dest address and ethernet src address - pData[i] = pData[i+6]; - pData[i+6] = localMACAddr[i]; - // swap sender ethernet address and target ethernet address - pData[i+22] = localMACAddr[i]; - pData[i+32] = pData[i+6]; - } - - // swap sender IP address and target IP address - for (i = 0; i<4; i++) { - pData[i+38] = pData[i+28]; - pData[i+28] = localIPAddr[i]; - } - - if (!(*AT91C_EMAC_TSR & AT91C_EMAC_BNQ)) break; - - *AT91C_EMAC_TSR |= AT91C_EMAC_COMP; - *AT91C_EMAC_TAR = (unsigned)pData; - *AT91C_EMAC_TCR = 0x40; - } - break; - case SWAP16(PROTOCOL_IP): - pIpHeader = (ip_header_t*)(pData + 14); - memcpy(pHeader, pIpHeader, sizeof(ip_header_t)); - - if (pIpHeader->ip_p == PROTOCOL_UDP) { - udp_header_t *udpHdr; - tftp_header_t *tftpHdr; - - udpHdr = (udp_header_t*)((char*)pIpHeader+20); - tftpHdr = (tftp_header_t*)((char*)udpHdr + 8); - - if (udpHdr->dst_port != localPort) - break; - - if (tftpHdr->opcode != TFTP_DATA_OPCODE) - break; - - if (ackBlock == -1) { - if (tftpHdr->block_num != SWAP16(1)) - break; - serverPort = udpHdr->src_port; - ackBlock = 0; - } - - if (serverPort != udpHdr->src_port) - break; - - TFTP_ACK_Data(tftpHdr->data, - SWAP16(tftpHdr->block_num), - SWAP16(udpHdr->udp_len) - 12); - } - } - p_rxBD[process].address &= ~0x01; - return (1); -} - - -/* - * .KB_C_FN_DEFINITION_START - * unsigned short AT91F_MII_ReadPhy (AT91PS_EMAC pEmac, unsigned char addr) - * This private function reads the PHY device. - * .KB_C_FN_DEFINITION_END - */ -#ifndef BOOT_BWCT -static unsigned short -AT91F_MII_ReadPhy (AT91PS_EMAC pEmac, unsigned char addr) -{ - unsigned value = 0x60020000 | (addr << 18); - - pEmac->EMAC_CTL |= AT91C_EMAC_MPE; - pEmac->EMAC_MAN = value; - while(!((pEmac->EMAC_SR) & AT91C_EMAC_IDLE)); - pEmac->EMAC_CTL &= ~AT91C_EMAC_MPE; - return (pEmac->EMAC_MAN & 0x0000ffff); -} -#endif - -/* - * .KB_C_FN_DEFINITION_START - * unsigned short AT91F_MII_WritePhy (AT91PS_EMAC pEmac, unsigned char addr, unsigned short s) - * This private function writes the PHY device. - * .KB_C_FN_DEFINITION_END - */ -#ifdef BOOT_TSC -static unsigned short -AT91F_MII_WritePhy (AT91PS_EMAC pEmac, unsigned char addr, unsigned short s) -{ - unsigned value = 0x50020000 | (addr << 18) | s; - - pEmac->EMAC_CTL |= AT91C_EMAC_MPE; - pEmac->EMAC_MAN = value; - while(!((pEmac->EMAC_SR) & AT91C_EMAC_IDLE)); - pEmac->EMAC_CTL &= ~AT91C_EMAC_MPE; - return (pEmac->EMAC_MAN & 0x0000ffff); -} -#endif - -/* - * .KB_C_FN_DEFINITION_START - * void MII_GetLinkSpeed(AT91PS_EMAC pEmac) - * This private function determines the link speed set by the PHY. - * .KB_C_FN_DEFINITION_END - */ -static void -MII_GetLinkSpeed(AT91PS_EMAC pEmac) -{ -#if defined(BOOT_TSC) || defined(BOOT_KB920X) || defined(BOOT_CENTIPAD) - unsigned short stat2; -#endif - unsigned update; -#ifdef BOOT_TSC - unsigned sec; - int i; -#endif -#ifdef BOOT_BWCT - /* hardcoded link speed since we connect a switch via MII */ - update = pEmac->EMAC_CFG & ~(AT91C_EMAC_SPD | AT91C_EMAC_FD); - update |= AT91C_EMAC_SPD; - update |= AT91C_EMAC_FD; -#endif -#if defined(BOOT_KB920X) || defined(BOOT_CENTIPAD) - stat2 = AT91F_MII_ReadPhy(pEmac, MII_STS2_REG); - if (!(stat2 & MII_STS2_LINK)) - return ; - update = pEmac->EMAC_CFG & ~(AT91C_EMAC_SPD | AT91C_EMAC_FD); - if (stat2 & MII_STS2_100TX) - update |= AT91C_EMAC_SPD; - if (stat2 & MII_STS2_FDX) - update |= AT91C_EMAC_FD; -#endif -#ifdef BOOT_TSC - while (1) { - for (i = 0; i < 10; i++) { - stat2 = AT91F_MII_ReadPhy(pEmac, MII_STS_REG); - if (stat2 & MII_STS_LINK_STAT) - break; - printf("."); - sec = GetSeconds(); - while (GetSeconds() == sec) - continue; - } - if (stat2 & MII_STS_LINK_STAT) - break; - printf("Resetting MII..."); - AT91F_MII_WritePhy(pEmac, 0x0, 0x8000); - while (AT91F_MII_ReadPhy(pEmac, 0x0) & 0x8000) continue; - } - printf("emac: link"); - stat2 = AT91F_MII_ReadPhy(pEmac, MII_SPEC_STS_REG); - update = pEmac->EMAC_CFG & ~(AT91C_EMAC_SPD | AT91C_EMAC_FD); - if (stat2 & (MII_SSTS_100FDX | MII_SSTS_100HDX)) { - printf(" 100TX"); - update |= AT91C_EMAC_SPD; - } - if (stat2 & (MII_SSTS_100FDX | MII_SSTS_10FDX)) { - printf(" FDX"); - update |= AT91C_EMAC_FD; - } - printf("\n"); -#endif - pEmac->EMAC_CFG = update; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void AT91F_EmacEntry(void) - * This private function initializes the EMAC on the chip. - * .KB_C_FN_DEFINITION_END - */ -static void -AT91F_EmacEntry(void) -{ - unsigned i; - char *pRxPacket = (char*)RX_DATA_START; - AT91PS_EMAC pEmac = AT91C_BASE_EMAC; - - p_rxBD = (receive_descriptor_t*)RX_BUFFER_START; - localPort = SWAP16(0x8002); - - for (i = 0; i < MAX_RX_PACKETS; ++i) { - - p_rxBD[i].address = (unsigned)pRxPacket; - p_rxBD[i].size = 0; - pRxPacket += RX_PACKET_SIZE; - } - - // Set the WRAP bit at the end of the list descriptor - p_rxBD[MAX_RX_PACKETS-1].address |= 0x02; - - if (!(pEmac->EMAC_SR & AT91C_EMAC_LINK)) - MII_GetLinkSpeed(pEmac); - - pEmac->EMAC_RBQP = (unsigned) p_rxBD; - pEmac->EMAC_RSR |= (AT91C_EMAC_OVR | AT91C_EMAC_REC | AT91C_EMAC_BNA); - pEmac->EMAC_CTL = AT91C_EMAC_TE | AT91C_EMAC_RE; - - pEmac->EMAC_TAR = (unsigned)transmitBuffer; -} - - -/* ************************** GLOBAL FUNCTIONS ********************************/ - -/* - * .KB_C_FN_DEFINITION_START - * void SetServerIPAddress(unsigned address) - * This global function sets the IP of the TFTP download server. - * .KB_C_FN_DEFINITION_END - */ -void -SetServerIPAddress(unsigned address) -{ - // force update in case the IP has changed - serverMACSet = 0; - - serverIPAddr[0] = (address >> 24) & 0xFF; - serverIPAddr[1] = (address >> 16) & 0xFF; - serverIPAddr[2] = (address >> 8) & 0xFF; - serverIPAddr[3] = (address >> 0) & 0xFF; - - serverIPSet = 1; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void SetLocalIPAddress(unsigned address) - * This global function sets the IP of this module. - * .KB_C_FN_DEFINITION_END - */ -void -SetLocalIPAddress(unsigned address) -{ - // force update in case the IP has changed - serverMACSet = 0; - - localIPAddr[0] = (address >> 24) & 0xFF; - localIPAddr[1] = (address >> 16) & 0xFF; - localIPAddr[2] = (address >> 8) & 0xFF; - localIPAddr[3] = (address >> 0) & 0xFF; - - localIPSet = 1; -} - - -/* - * .KB_C_FN_DEFINITION_START - * void TFTP_Download(unsigned address, char *filename) - * This global function initiates and processes a tftp download request. - * The server IP, local IP, local MAC must be set before this function is - * executed. - * .KB_C_FN_DEFINITION_END - */ -void -TFTP_Download(unsigned address, char *filename) -{ - ip_header_t IpHeader; - unsigned thisSeconds; - int timeout; - - if ((!localMACSet) || (!localIPSet) || (!serverIPSet)) - return ; - - AT91F_EmacEntry(); - GetServerAddress(); - dlAddress = (char*)address; - lastSize = 0; - timeout = 10; - thisSeconds = (GetSeconds() + 2) % 32; - serverPort = SWAP16(69); - ++localPort; - ackBlock = -1; - - while (timeout) { - if (CheckForNewPacket(&IpHeader)) { - if (ackBlock == -2) - break; - timeout = 10; - thisSeconds = (GetSeconds() + 2) % 32; - } else if (GetSeconds() == thisSeconds) { - --timeout; - thisSeconds = (GetSeconds() + 2) % 32; - if (!serverMACSet) - GetServerAddress(); - else if (ackBlock == -1) - TFTP_RequestFile(filename); - else { - // Be sure to send a NAK, which is done by - // ACKing the last block we got. - TFTP_ACK_Data(0, ackBlock, 512); - printf("\nNAK %u\n", ackBlock); - } - } - } - if (timeout == 0) - printf("TFTP TIMEOUT!\n"); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/emac.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/memcmp.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/memcmp.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/memcmp.c (nonexistent) @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "lib.h" - -int -p_memcmp(const char *to, const char *from, unsigned size) -{ - while ((--size) && (*to++ == *from++)) - continue; - - return (size || (*to != *from)); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/memcmp.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/strlen.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/strlen.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/strlen.c (nonexistent) @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -/****************************************************************************** - * - * Filename: p_string.c - * - * Instantiation of basic string operations to prevent inclusion of full - * string library. These are simple implementations not necessarily optimized - * for speed, but rather to show intent. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin minor updates - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - *****************************************************************************/ - -#include "lib.h" - -/* - * .KB_C_FN_DEFINITION_START - * int p_strlen(char *) - * This global function returns the number of bytes starting at the pointer - * before (not including) the string termination character ('/0'). - * .KB_C_FN_DEFINITION_END - */ -int -p_strlen(const char *buffer) -{ - const char *ptr = buffer; - while (*ptr++) - continue; - return (ptr - buffer - 1); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/strlen.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/memcpy.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/memcpy.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/memcpy.c (nonexistent) @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "lib.h" - -void -memcpy(void *dst, const void *src, unsigned len) -{ - const char *s = src; - char *d = dst; - - while (len--) - *d++ = *s++; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/memcpy.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/xmodem.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/xmodem.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/xmodem.c (nonexistent) @@ -1,128 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. This version of xmodem has been nearly - * completely rewritten, but the CRC is from the original. - * - * $FreeBSD$ - */ - -#include "lib.h" - -#define PACKET_SIZE 128 - -/* Line control codes */ -#define SOH 0x01 /* start of header */ -#define ACK 0x06 /* Acknowledge */ -#define NAK 0x15 /* Negative acknowledge */ -#define CAN 0x18 /* Cancel */ -#define EOT 0x04 /* end of text */ - -#define TO 10 -/* - * int GetRecord(char , char *) - * This private function receives a x-modem record to the pointer and - * returns non-zero on success. - */ -static int -GetRecord(char blocknum, char *dest) -{ - int size; - int ch; - unsigned chk, j; - - chk = 0; - - if ((ch = getc(TO)) == -1) - goto err; - if (ch != blocknum) - goto err; - if ((ch = getc(TO)) == -1) - goto err; - if (ch != (~blocknum & 0xff)) - goto err; - - for (size = 0; size < PACKET_SIZE; ++size) { - if ((ch = getc(TO)) == -1) - goto err; - chk = chk ^ ch << 8; - for (j = 0; j < 8; ++j) { - if (chk & 0x8000) - chk = chk << 1 ^ 0x1021; - else - chk = chk << 1; - } - *dest++ = ch; - } - - chk &= 0xFFFF; - - if (((ch = getc(TO)) == -1) || ((ch & 0xff) != ((chk >> 8) & 0xFF))) - goto err; - if (((ch = getc(TO)) == -1) || ((ch & 0xff) != (chk & 0xFF))) - goto err; - putchar(ACK); - - return (1); -err:; - putchar(CAN); - // We should allow for resend, but we don't. - return (0); -} - -/* - * int xmodem_rx(char *) - * This global function receives a x-modem transmission consisting of - * (potentially) several blocks. Returns the number of bytes received or - * -1 on error. - */ -int -xmodem_rx(char *dest) -{ - int starting, ch; - char packetNumber, *startAddress = dest; - - packetNumber = 1; - starting = 1; - - while (1) { - if (starting) - putchar('C'); - if (((ch = getc(1)) == -1) || (ch != SOH && ch != EOT)) - continue; - if (ch == EOT) { - putchar(ACK); - return (dest - startAddress); - } - starting = 0; - // Xmodem packets: SOH PKT# ~PKT# 128-bytes CRC16 - if (!GetRecord(packetNumber, dest)) - return (-1); - dest += PACKET_SIZE; - packetNumber++; - } - - // the loop above should return in all cases - return (-1); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/xmodem.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/emac.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/emac.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/emac.h (nonexistent) @@ -1,135 +0,0 @@ -/****************************************************************************** - * - * Filename: emac.h - * - * Definition of routine to set the MAC address. - * - * Revision information: - * - * 28AUG2004 kb_admin initial creation - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - *****************************************************************************/ - - -#ifndef _EMAC_H_ -#define _EMAC_H_ - -extern void EMAC_SetMACAddress(unsigned char addr[6]); -extern void SetServerIPAddress(unsigned address); -extern void SetLocalIPAddress(unsigned address); -extern void EMAC_Init(void); -extern void TFTP_Download(unsigned address, char *filename); - -#define MAX_RX_PACKETS 8 -#define RX_PACKET_SIZE 1536 -#define RX_BUFFER_START 0x21000000 -#define RX_DATA_START (RX_BUFFER_START + (8 * MAX_RX_PACKETS)) - -#define ARP_REQUEST 0x0001 -#define ARP_REPLY 0x0002 -#define PROTOCOL_ARP 0x0806 -#define PROTOCOL_IP 0x0800 -#define PROTOCOL_UDP 0x11 - -#define SWAP16(x) ((((x) & 0xff) << 8) | ((x) >> 8)) - -typedef struct { - unsigned address; - unsigned size; -} receive_descriptor_t; - -typedef struct { - - unsigned char dest_mac[6]; - - unsigned char src_mac[6]; - - unsigned short frame_type; - unsigned short hard_type; - unsigned short prot_type; - unsigned char hard_size; - unsigned char prot_size; - - unsigned short operation; - - unsigned char sender_mac[6]; - unsigned char sender_ip[4]; - - unsigned char target_mac[6]; - unsigned char target_ip[4]; - -} __attribute__((__packed__)) arp_header_t; - -typedef struct { - unsigned char ip_v_hl; - unsigned char ip_tos; - unsigned short ip_len; - unsigned short ip_id; - unsigned short ip_off; - unsigned char ip_ttl; - unsigned char ip_p; - unsigned short ip_sum; - unsigned char ip_src[4]; - unsigned char ip_dst[4]; -} __attribute__((__packed__)) ip_header_t; - -typedef struct { - unsigned char dest_mac[6]; - unsigned char src_mac[6]; - unsigned short proto_mac; - unsigned short packet_length; - ip_header_t iphdr; -} __attribute__((__packed__)) transmit_header_t; - -typedef struct { - unsigned short src_port; - unsigned short dst_port; - unsigned short udp_len; - unsigned short udp_cksum; -} __attribute__((__packed__)) udp_header_t; - -typedef struct { - unsigned short opcode; - unsigned short block_num; - unsigned char data[512]; -} __attribute__((__packed__)) tftp_header_t; - -// Preswap bytes -#define TFTP_RRQ_OPCODE 0x0100 -#define TFTP_WRQ_OPCODE 0x0200 -#define TFTP_DATA_OPCODE 0x0300 -#define TFTP_ACK_OPCODE 0x0400 -#define TFTP_ERROR_OPCODE 0x0500 - -/* MII registers definition */ -#define MII_STS_REG 0x01 -#define MII_STS_LINK_STAT 0x04 -#if defined(BOOT_KB920X) || defined(BOOT_CENTIPAD) -#define MII_STS2_REG 0x11 -#define MII_STS2_LINK 0x400 -#define MII_STS2_100TX 0x4000 -#define MII_STS2_FDX 0x200 -#else -#define MII_SPEC_STS_REG 0x11 -#define MII_SSTS_100FDX 0x8000 -#define MII_SSTS_100HDX 0x4000 -#define MII_SSTS_10FDX 0x2000 -#define MII_SSTS_10HDX 0x1000 -#endif - -extern unsigned char localMACAddr[6]; -extern unsigned localMAClow, localMAChigh; -extern unsigned localMACSet; -#define EMAC_Init() - -#endif /* _EMAC_H_ */ Property changes on: stable/11/sys/boot/arm/at91/libat91/emac.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/printf.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/printf.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/printf.c (nonexistent) @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1998 Robert Nordier - * All rights reserved. - * Copyright (c) 2006 M. Warner Losh - * All rights reserved. - * - * Redistribution and use in source and binary forms are freely - * permitted provided that the above copyright notice and this - * paragraph and the following disclaimer are duplicated in all - * such forms. - * - * This software is provided "AS IS" and without any express or - * implied warranties, including, without limitation, the implied - * warranties of merchantability and fitness for a particular - * purpose. - * - * $FreeBSD$ - */ - -#include -#include "lib.h" - -void -printf(const char *fmt,...) -{ - va_list ap; - const char *hex = "0123456789abcdef"; - char buf[10]; - char *s; - unsigned u; - int c; - - va_start(ap, fmt); - while ((c = *fmt++)) { - if (c == '%') { - c = *fmt++; - switch (c) { - case 'c': - xputchar(va_arg(ap, int)); - continue; - case 's': - for (s = va_arg(ap, char *); *s; s++) - xputchar(*s); - continue; - case 'd': /* A lie, always prints unsigned */ - case 'u': - u = va_arg(ap, unsigned); - s = buf; - do - *s++ = '0' + u % 10U; - while (u /= 10U); - dumpbuf:; - while (--s >= buf) - xputchar(*s); - continue; - case 'x': - u = va_arg(ap, unsigned); - s = buf; - do - *s++ = hex[u & 0xfu]; - while (u >>= 4); - goto dumpbuf; - } - } - xputchar(c); - } - va_end(ap); - - return; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/printf.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/lib_AT91RM9200.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/lib_AT91RM9200.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/lib_AT91RM9200.h (nonexistent) @@ -1,277 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. - * - * $FreeBSD$ - */ - -#ifndef __LIBAT91RM9200_H -#define __LIBAT91RM9200_H - -#include "at91rm9200.h" - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PMC_EnablePeriphClock -//* \brief Enable peripheral clock -//*---------------------------------------------------------------------------- -static inline void -AT91F_PMC_EnablePeriphClock ( - AT91PS_PMC pPMC, // \arg pointer to PMC controller - unsigned int periphIds) // \arg IDs of peripherals to enable -{ - pPMC->PMC_PCER = periphIds; -} - -/* ***************************************************************************** - SOFTWARE API FOR PIO - ***************************************************************************** */ -//*---------------------------------------------------------------------------- -//* \fn AT91F_PIO_CfgPeriph -//* \brief Enable pins to be drived by peripheral -//*---------------------------------------------------------------------------- -static inline -void AT91F_PIO_CfgPeriph( - AT91PS_PIO pPio, // \arg pointer to a PIO controller - unsigned int periphAEnable, // \arg PERIPH A to enable - unsigned int periphBEnable) // \arg PERIPH B to enable - -{ - if (periphAEnable) - pPio->PIO_ASR = periphAEnable; - if (periphBEnable) - pPio->PIO_BSR = periphBEnable; - pPio->PIO_PDR = (periphAEnable | periphBEnable); // Set in Periph mode -} - -/* ***************************************************************************** - SOFTWARE API FOR MCI - ***************************************************************************** */ -//* Classic MCI Data Timeout Register Configuration with 1048576 MCK cycles between 2 data transfer -#define AT91C_MCI_DTOR_1MEGA_CYCLES (AT91C_MCI_DTOCYC | AT91C_MCI_DTOMUL) - -//* Classic MCI SDCard Register Configuration with 1-bit data bus on slot A -#define AT91C_MCI_MMC_SLOTA (AT91C_MCI_SCDSEL & 0x0) - -//* Classic MCI SDCard Register Configuration with 1-bit data bus on slot B -#define AT91C_MCI_MMC_SLOTB (AT91C_MCI_SCDSEL) - -//* Classic MCI SDCard Register Configuration with 4-bit data bus on slot A -#define AT91C_MCI_SDCARD_4BITS_SLOTA ( (AT91C_MCI_SCDSEL & 0x0) | AT91C_MCI_SCDBUS ) - -//* Classic MCI SDCard Register Configuration with 4-bit data bus on slot B -#define AT91C_MCI_SDCARD_4BITS_SLOTB (AT91C_MCI_SCDSEL | AT91C_MCI_SCDBUS) - - - -//*---------------------------------------------------------------------------- -//* \fn AT91F_MCI_Configure -//* \brief Configure the MCI -//*---------------------------------------------------------------------------- -static inline -void AT91F_MCI_Configure( - AT91PS_MCI pMCI, // \arg pointer to a MCI controller - unsigned int DTOR_register, // \arg Data Timeout Register to be programmed - unsigned int MR_register, // \arg Mode Register to be programmed - unsigned int SDCR_register) // \arg SDCard Register to be programmed -{ - //* Reset the MCI - pMCI->MCI_CR = AT91C_MCI_MCIEN | AT91C_MCI_PWSEN; - - //* Disable all the interrupts - pMCI->MCI_IDR = 0xFFFFFFFF; - - //* Set the Data Timeout Register - pMCI->MCI_DTOR = DTOR_register; - - //* Set the Mode Register - pMCI->MCI_MR = MR_register; - - //* Set the SDCard Register - pMCI->MCI_SDCR = SDCR_register; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_MCI_CfgPMC -//* \brief Enable Peripheral clock in PMC for MCI -//*---------------------------------------------------------------------------- -static inline void -AT91F_MCI_CfgPMC(void) -{ - AT91F_PMC_EnablePeriphClock( - AT91C_BASE_PMC, // PIO controller base address - ((unsigned int) 1 << AT91C_ID_MCI)); -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_MCI_CfgPIO -//* \brief Configure PIO controllers to drive MCI signals -//*---------------------------------------------------------------------------- -static inline void -AT91F_MCI_CfgPIO(void) -{ - // Configure PIO controllers to periph mode - AT91F_PIO_CfgPeriph( - AT91C_BASE_PIOA, // PIO controller base address - ((unsigned int) AT91C_PIO_PA28 ) | - ((unsigned int) AT91C_PIO_PA29 ) | - ((unsigned int) AT91C_PIO_PA27 ), // Peripheral A - 0); // Peripheral B - // Configure PIO controllers to periph mode - AT91F_PIO_CfgPeriph( - AT91C_BASE_PIOB, // PIO controller base address - 0, // Peripheral A - ((unsigned int) AT91C_PIO_PB5 ) | - ((unsigned int) AT91C_PIO_PB3 ) | - ((unsigned int) AT91C_PIO_PB4 )); // Peripheral B -} - - -/* ***************************************************************************** - SOFTWARE API FOR PDC - ***************************************************************************** */ -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_SetNextRx -//* \brief Set the next receive transfer descriptor -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_SetNextRx ( - AT91PS_PDC pPDC, // \arg pointer to a PDC controller - char *address, // \arg address to the next bloc to be received - unsigned int bytes) // \arg number of bytes to be received -{ - pPDC->PDC_RNPR = (unsigned int) address; - pPDC->PDC_RNCR = bytes; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_SetNextTx -//* \brief Set the next transmit transfer descriptor -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_SetNextTx( - AT91PS_PDC pPDC, // \arg pointer to a PDC controller - char *address, // \arg address to the next bloc to be transmitted - unsigned int bytes) // \arg number of bytes to be transmitted -{ - pPDC->PDC_TNPR = (unsigned int) address; - pPDC->PDC_TNCR = bytes; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_SetRx -//* \brief Set the receive transfer descriptor -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_SetRx( - AT91PS_PDC pPDC, // \arg pointer to a PDC controller - char *address, // \arg address to the next bloc to be received - unsigned int bytes) // \arg number of bytes to be received -{ - pPDC->PDC_RPR = (unsigned int) address; - pPDC->PDC_RCR = bytes; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_SetTx -//* \brief Set the transmit transfer descriptor -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_SetTx( - AT91PS_PDC pPDC, // \arg pointer to a PDC controller - char *address, // \arg address to the next bloc to be transmitted - unsigned int bytes) // \arg number of bytes to be transmitted -{ - pPDC->PDC_TPR = (unsigned int) address; - pPDC->PDC_TCR = bytes; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_EnableTx -//* \brief Enable transmit -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_EnableTx( - AT91PS_PDC pPDC ) // \arg pointer to a PDC controller -{ - pPDC->PDC_PTCR = AT91C_PDC_TXTEN; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_EnableRx -//* \brief Enable receive -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_EnableRx( - AT91PS_PDC pPDC ) // \arg pointer to a PDC controller -{ - pPDC->PDC_PTCR = AT91C_PDC_RXTEN; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_DisableTx -//* \brief Disable transmit -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_DisableTx( - AT91PS_PDC pPDC ) // \arg pointer to a PDC controller -{ - pPDC->PDC_PTCR = AT91C_PDC_TXTDIS; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_DisableRx -//* \brief Disable receive -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_DisableRx( - AT91PS_PDC pPDC ) // \arg pointer to a PDC controller -{ - pPDC->PDC_PTCR = AT91C_PDC_RXTDIS; -} - -//*---------------------------------------------------------------------------- -//* \fn AT91F_PDC_Open -//* \brief Open PDC: disable TX and RX reset transfer descriptors, re-enable RX and TX -//*---------------------------------------------------------------------------- -static inline void -AT91F_PDC_Open( - AT91PS_PDC pPDC) // \arg pointer to a PDC controller -{ - //* Disable the RX and TX PDC transfer requests - AT91F_PDC_DisableRx(pPDC); - AT91F_PDC_DisableTx(pPDC); - - //* Reset all Counter register Next buffer first - AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0); - AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0); - AT91F_PDC_SetTx(pPDC, (char *) 0, 0); - AT91F_PDC_SetRx(pPDC, (char *) 0, 0); - - //* Enable the RX and TX PDC transfer requests - AT91F_PDC_EnableRx(pPDC); - AT91F_PDC_EnableTx(pPDC); -} - -#endif Property changes on: stable/11/sys/boot/arm/at91/libat91/lib_AT91RM9200.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/strcmp.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/strcmp.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/strcmp.c (nonexistent) @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "lib.h" - -int -strcmp(const char *s1, const char *s2) -{ - for (; *s1 == *s2 && *s1; s1++, s2++); - return (unsigned char)*s1 - (unsigned char)*s2; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/strcmp.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/getc.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/getc.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/getc.c (nonexistent) @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provided by kwikbyte without - * copyright as follows: - * - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "at91rm9200_lowlevel.h" -#include "lib.h" - -/* - * int getc(int seconds) - * - * Reads a character from the DBGU port, if one is available within about - * seconds seconds. It assumes that DBGU has already been initialized. - */ -int -getc(int seconds) -{ - AT91PS_USART pUSART = (AT91PS_USART)AT91C_BASE_DBGU; - unsigned thisSecond; - - // Clamp to 20s - if (seconds > 20) - seconds = 20; - thisSecond = GetSeconds(); - seconds = thisSecond + seconds; - do { - if ((pUSART->US_CSR & AT91C_US_RXRDY)) - return (pUSART->US_RHR & 0xFF); - thisSecond = GetSeconds(); - } while (thisSecond != seconds); - return (-1); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/getc.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/strcpy.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/strcpy.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/strcpy.c (nonexistent) @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "lib.h" - -char * -strcpy(char *to, const char *from) -{ - while (*from) - *to++ = *from++; - *to++ = '\0'; - return (to); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/strcpy.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/arm_init.S =================================================================== --- stable/11/sys/boot/arm/at91/libat91/arm_init.S (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/arm_init.S (nonexistent) @@ -1,129 +0,0 @@ -/******************************************************************************* - * - * Filename: arm_init.s - * - * Initialization for C-environment and basic operation. Adapted from - * ATMEL cstartup.s. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin updated for 16KB eeprom - * Atmel stack prevents loading full size at once - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - * - * $FreeBSD$ - ******************************************************************************/ - - .equ TWI_EEPROM_SIZE, 0x3000 - .equ ARM_MODE_USER, 0x10 - .equ ARM_MODE_FIQ, 0x11 - .equ ARM_MODE_IRQ, 0x12 - .equ ARM_MODE_SVC, 0x13 - .equ ARM_MODE_ABORT, 0x17 - .equ ARM_MODE_UNDEF, 0x1B - .equ ARM_MODE_SYS, 0x1F - .equ I_BIT, 0x80 - .equ F_BIT, 0x40 - .equ T_BIT, 0x20 - -/* - * Stack definitions - * - * Start near top of internal RAM. - */ - .equ END_INT_SRAM, 0x4000 - .equ SVC_STACK_START, (END_INT_SRAM - 0x4) - .equ SVC_STACK_USE, 0x21800000 - -start: - -/* vectors - must reside at address 0 */ -/* the format of this table is defined in the datasheet */ - B InitReset @; reset -undefvec: - B undefvec @; Undefined Instruction -swivec: - B swivec @; Software Interrupt -pabtvec: - B pabtvec @; Prefetch Abort -dabtvec: - B dabtvec @; Data Abort -rsvdvec: -#ifdef BOOT_IIC - .long (TWI_EEPROM_SIZE >> 9) -#else -#ifdef BOOT_BWCT - .long ((528 << 17) | (13 << 13) | (12 * 2)) -#else - .long ((1056 << 17) | (13 << 13) | (12 * 2)) -#endif -#endif -irqvec: - ldr pc, [pc,#-0xF20] @; IRQ : read the AIC -fiqvec: - B fiqvec @; FIQ - -InitReset: - -/* Set stack and init for SVC */ - ldr r1, = SVC_STACK_START - mov sp, r1 @; Init stack SYS - - msr cpsr_c, #(ARM_MODE_SVC | I_BIT | F_BIT) - mov sp, r1 @ ; Init stack SYS - -/* Perform system initialization */ - - .extern _init - bl _init -#ifndef BOOT_BOOT0 - ldr r1, = SVC_STACK_USE - mov sp, r1 @ ; Move the stack to SDRAM -#endif - -/* Start execution at main */ - .extern main -_main: -__main: - bl main -/* main should not return. If it does, spin forever */ -infiniteLoop: - b infiniteLoop - -#ifdef BOOT_COMMANDS -/* the following section is used to store boot commands in */ -/* non-volatile memory. */ - - .global BootCommandSection -BootCommandSection: -#ifdef SUPPORT_LINUX - .string "Bootloader for KB9202 Evaluation Board." - .string "c 0x20210000 0x10100000 0x80000 " - .string "m 0 0 0 0 0 0 " - .string "t 0x20000100 console=ttyS0,115200 root=/dev/ram rw initrd=0x20210000,654933" - .string "e 0x10000000 " - .string " " -#else -#if 1 - .string "m 42 53 44 0 0 1" - .string "ip 206 168 13 194" - .string "server_ip 206 168 13 207" - .string "tftp 0x20000000 kernel.bin" - .string "e 0x20000000" -#else - .string "m 42 53 44 0 0 1" - .string "k 0x20000000" - .string "e 0x20000000" -#endif - .word 0 -#endif -#endif Property changes on: stable/11/sys/boot/arm/at91/libat91/arm_init.S ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/strcvt.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/strcvt.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/strcvt.c (nonexistent) @@ -1,132 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); - -/****************************************************************************** - * - * Filename: p_string.c - * - * Instantiation of basic string operations to prevent inclusion of full - * string library. These are simple implementations not necessarily optimized - * for speed, but rather to show intent. - * - * Revision information: - * - * 20AUG2004 kb_admin initial creation - * 12JAN2005 kb_admin minor updates - * - * BEGIN_KBDD_BLOCK - * No warranty, expressed or implied, is included with this software. It is - * provided "AS IS" and no warranty of any kind including statutory or aspects - * relating to merchantability or fitness for any purpose is provided. All - * intellectual property rights of others is maintained with the respective - * owners. This software is not copyrighted and is intended for reference - * only. - * END_BLOCK - *****************************************************************************/ - -#include "lib.h" - -/* - * .KB_C_FN_DEFINITION_START - * int p_IsWhiteSpace(char) - * This global function returns true if the character is not considered - * a non-space character. - * .KB_C_FN_DEFINITION_END - */ -int -p_IsWhiteSpace(char cValue) -{ - return ((cValue == ' ') || - (cValue == '\t') || - (cValue == 0) || - (cValue == '\r') || - (cValue == '\n')); -} - - -/* - * .KB_C_FN_DEFINITION_START - * unsigned p_HexCharValue(char) - * This global function returns the decimal value of the validated hex char. - * .KB_C_FN_DEFINITION_END - */ -unsigned -p_HexCharValue(char cValue) -{ - if (cValue < ('9' + 1)) - return (cValue - '0'); - if (cValue < ('F' + 1)) - return (cValue - 'A' + 10); - return (cValue - 'a' + 10); -} - -/* - * .KB_C_FN_DEFINITION_START - * unsigned p_ASCIIToHex(char *) - * This global function set the unsigned value equal to the converted - * hex number passed as a string. No error checking is performed; the - * string must be valid hex value, point at the start of string, and be - * NULL-terminated. - * .KB_C_FN_DEFINITION_END - */ -unsigned -p_ASCIIToHex(const char *buf) -{ - unsigned lValue = 0; - - if ((*buf == '0') && ((buf[1] == 'x') || (buf[1] == 'X'))) - buf += 2; - - while (*buf) { - lValue <<= 4; - lValue += p_HexCharValue(*buf++); - } - return (lValue); -} - - -/* - * .KB_C_FN_DEFINITION_START - * unsigned p_ASCIIToDec(char *) - * This global function set the unsigned value equal to the converted - * decimal number passed as a string. No error checking is performed; the - * string must be valid decimal value, point at the start of string, and be - * NULL-terminated. - * .KB_C_FN_DEFINITION_END - */ -unsigned -p_ASCIIToDec(const char *buf) -{ - unsigned v = 0; - - while (*buf) { - v *= 10; - v += (*buf++) - '0'; - } - return (v); -} Property changes on: stable/11/sys/boot/arm/at91/libat91/strcvt.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/mci_device.h =================================================================== --- stable/11/sys/boot/arm/at91/libat91/mci_device.h (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/mci_device.h (nonexistent) @@ -1,434 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. - * - * $FreeBSD$ - */ - -//*--------------------------------------------------------------------------- -//* ATMEL Microcontroller Software Support - ROUSSET - -//*--------------------------------------------------------------------------- -//* The software is delivered "AS IS" without warranty or condition of any -//* kind, either express, implied or statutory. This includes without -//* limitation any warranty or condition with respect to merchantability or -//* fitness for any particular purpose, or against the infringements of -//* intellectual property rights of others. -//*--------------------------------------------------------------------------- -//* File Name : AT91C_MCI_Device.h -//* Object : Data Flash Atmel Description File -//* Translator : -//* -//* 1.0 26/11/02 FB : Creation -//*--------------------------------------------------------------------------- - -#ifndef __MCI_Device_h -#define __MCI_Device_h - -#include - -typedef unsigned int AT91S_MCIDeviceStatus; - -/////////////////////////////////////////////////////////////////////////////// - -#define AT91C_CARD_REMOVED 0 -#define AT91C_MMC_CARD_INSERTED 1 -#define AT91C_SD_CARD_INSERTED 2 - -#define AT91C_NO_ARGUMENT 0x0 - -#define AT91C_FIRST_RCA 0xCAFE -#define AT91C_MAX_MCI_CARDS 10 - -#define AT91C_BUS_WIDTH_1BIT 0x00 -#define AT91C_BUS_WIDTH_4BITS 0x02 - -/* Driver State */ -#define AT91C_MCI_IDLE 0x0 -#define AT91C_MCI_TIMEOUT_ERROR 0x1 -#define AT91C_MCI_RX_SINGLE_BLOCK 0x2 -#define AT91C_MCI_RX_MULTIPLE_BLOCK 0x3 -#define AT91C_MCI_RX_STREAM 0x4 -#define AT91C_MCI_TX_SINGLE_BLOCK 0x5 -#define AT91C_MCI_TX_MULTIPLE_BLOCK 0x6 -#define AT91C_MCI_TX_STREAM 0x7 - -/* TimeOut */ -#define AT91C_TIMEOUT_CMDRDY 30 - - - -/////////////////////////////////////////////////////////////////////////////// -// MMC & SDCard Structures -/////////////////////////////////////////////////////////////////////////////// - -/*---------------------------------------------*/ -/* MCI Device Structure Definition */ -/*---------------------------------------------*/ -typedef struct _AT91S_MciDevice -{ - volatile unsigned char state; - unsigned char SDCard_bus_width; - unsigned char IsSDv2; - unsigned char IsSDHC; - unsigned int RCA; // RCA - unsigned int READ_BL_LEN; -#ifdef REPORT_SIZE - unsigned int Memory_Capacity; -#endif -} AT91S_MciDevice; - -#include - -/////////////////////////////////////////////////////////////////////////////// -// Functions returnals -/////////////////////////////////////////////////////////////////////////////// -#define AT91C_CMD_SEND_OK 0 // Command ok -#define AT91C_CMD_SEND_ERROR -1 // Command failed -#define AT91C_INIT_OK 2 // Init Successful -#define AT91C_INIT_ERROR 3 // Init Failed -#define AT91C_READ_OK 4 // Read Successful -#define AT91C_READ_ERROR 5 // Read Failed -#define AT91C_WRITE_OK 6 // Write Successful -#define AT91C_WRITE_ERROR 7 // Write Failed -#define AT91C_ERASE_OK 8 // Erase Successful -#define AT91C_ERASE_ERROR 9 // Erase Failed -#define AT91C_CARD_SELECTED_OK 10 // Card Selection Successful -#define AT91C_CARD_SELECTED_ERROR 11 // Card Selection Failed - -#define AT91C_MCI_SR_ERROR (AT91C_MCI_UNRE | AT91C_MCI_OVRE | AT91C_MCI_DTOE | \ - AT91C_MCI_DCRCE | AT91C_MCI_RTOE | AT91C_MCI_RENDE | AT91C_MCI_RCRCE | \ - AT91C_MCI_RDIRE | AT91C_MCI_RINDE) - -#define MMC_CMDNB (0x1Fu << 0) // Command Number -#define MMC_RSPTYP (0x3u << 6) // Response Type -#define MMC_RSPTYP_NO (0x0u << 6) // No response -#define MMC_RSPTYP_48 (0x1u << 6) // 48-bit response -#define MMC_RSPTYP_136 (0x2u << 6) // 136-bit response -#define MMC_SPCMD (0x7u << 8) // Special CMD -#define MMC_SPCMD_NONE (0x0u << 8) // Not a special CMD -#define MMC_SPCMD_INIT (0x1u << 8) // Initialization CMD -#define MMC_SPCMD_SYNC (0x2u << 8) // Synchronized CMD -#define MMC_SPCMD_IT_CMD (0x4u << 8) // Interrupt command -#define MMC_SPCMD_IT_REP (0x5u << 8) // Interrupt response -#define MMC_OPDCMD (0x1u << 11) // Open Drain Command -#define MMC_MAXLAT (0x1u << 12) // Maximum Latency for Command to respond -#define MMC_TRCMD (0x3u << 16) // Transfer CMD -#define MMC_TRCMD_NO (0x0u << 16) // No transfer -#define MMC_TRCMD_START (0x1u << 16) // Start transfer -#define MMC_TRCMD_STOP (0x2u << 16) // Stop transfer -#define MMC_TRDIR (0x1u << 18) // Transfer Direction -#define MMC_TRTYP (0x3u << 19) // Transfer Type -#define MMC_TRTYP_BLOCK (0x0u << 19) // Block Transfer type -#define MMC_TRTYP_MULTIPLE (0x1u << 19) // Multiple Block transfer type -#define MMC_TRTYP_STREAM (0x2u << 19) // Stream transfer type - -/////////////////////////////////////////////////////////////////////////////// -// MCI_CMD Register Value -/////////////////////////////////////////////////////////////////////////////// -#define POWER_ON_INIT \ - (0 | MMC_TRCMD_NO | MMC_SPCMD_INIT | MMC_OPDCMD) - -///////////////////////////////////////////////////////////////// -// Class 0 & 1 commands: Basic commands and Read Stream commands -///////////////////////////////////////////////////////////////// - -#define GO_IDLE_STATE_CMD \ - (0 | MMC_TRCMD_NO | MMC_SPCMD_NONE ) -#define MMC_GO_IDLE_STATE_CMD \ - (0 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_OPDCMD) -#define MMC_SEND_OP_COND_CMD \ - (1 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ - MMC_OPDCMD) - -#define ALL_SEND_CID_CMD \ - (2 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136) -#define MMC_ALL_SEND_CID_CMD \ - (2 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136 | \ - MMC_OPDCMD) - -#define SET_RELATIVE_ADDR_CMD \ - (3 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ - MMC_MAXLAT) -#define MMC_SET_RELATIVE_ADDR_CMD \ - (3 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ - MMC_MAXLAT | MMC_OPDCMD) - -#define SET_DSR_CMD \ - (4 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_NO | \ - MMC_MAXLAT) // no tested - -#define SEL_DESEL_CARD_CMD \ - (7 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ - MMC_MAXLAT) -#define SEND_CSD_CMD \ - (9 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136 | \ - MMC_MAXLAT) -#define SEND_CID_CMD \ - (10 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136 | \ - MMC_MAXLAT) -#define MMC_READ_DAT_UNTIL_STOP_CMD \ - (11 | MMC_TRTYP_STREAM | MMC_SPCMD_NONE | \ - MMC_RSPTYP_48 | MMC_TRDIR | MMC_TRCMD_START | \ - MMC_MAXLAT) - -#define STOP_TRANSMISSION_CMD \ - (12 | MMC_TRCMD_STOP | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ - MMC_MAXLAT) -#define STOP_TRANSMISSION_SYNC_CMD \ - (12 | MMC_TRCMD_STOP | MMC_SPCMD_SYNC | MMC_RSPTYP_48 | \ - MMC_MAXLAT) -#define SEND_STATUS_CMD \ - (13 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ - MMC_MAXLAT) -#define GO_INACTIVE_STATE_CMD \ - (15 | MMC_RSPTYP_NO) -#define SD_SEND_IF_COND_CMD \ - (8 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ - MMC_MAXLAT) -//*------------------------------------------------ -//* Class 2 commands: Block oriented Read commands -//*------------------------------------------------ - -#define SET_BLOCKLEN_CMD (16 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_MAXLAT ) -#define READ_SINGLE_BLOCK_CMD (17 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | MMC_TRTYP_BLOCK | MMC_TRDIR | MMC_MAXLAT) -#define READ_MULTIPLE_BLOCK_CMD (18 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | MMC_TRTYP_MULTIPLE | MMC_TRDIR | MMC_MAXLAT) - -//*-------------------------------------------- -//* Class 3 commands: Sequential write commands -//*-------------------------------------------- - -#define MMC_WRITE_DAT_UNTIL_STOP_CMD (20 | MMC_TRTYP_STREAM| MMC_SPCMD_NONE | MMC_RSPTYP_48 & ~(MMC_TRDIR) | MMC_TRCMD_START | MMC_MAXLAT ) // MMC - -//*------------------------------------------------ -//* Class 4 commands: Block oriented write commands -//*------------------------------------------------ - -#define WRITE_BLOCK_CMD (24 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | (MMC_TRTYP_BLOCK & ~(MMC_TRDIR)) | MMC_MAXLAT) -#define WRITE_MULTIPLE_BLOCK_CMD (25 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | (MMC_TRTYP_MULTIPLE & ~(MMC_TRDIR)) | MMC_MAXLAT) -#define PROGRAM_CSD_CMD (27 | MMC_RSPTYP_48 ) - - -//*---------------------------------------- -//* Class 6 commands: Group Write protect -//*---------------------------------------- - -#define SET_WRITE_PROT_CMD (28 | MMC_RSPTYP_48 ) -#define CLR_WRITE_PROT_CMD (29 | MMC_RSPTYP_48 ) -#define SEND_WRITE_PROT_CMD (30 | MMC_RSPTYP_48 ) - - -//*---------------------------------------- -//* Class 5 commands: Erase commands -//*---------------------------------------- - -#define TAG_SECTOR_START_CMD (32 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define TAG_SECTOR_END_CMD (33 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define MMC_UNTAG_SECTOR_CMD (34 | MMC_RSPTYP_48 ) -#define MMC_TAG_ERASE_GROUP_START_CMD (35 | MMC_RSPTYP_48 ) -#define MMC_TAG_ERASE_GROUP_END_CMD (36 | MMC_RSPTYP_48 ) -#define MMC_UNTAG_ERASE_GROUP_CMD (37 | MMC_RSPTYP_48 ) -#define ERASE_CMD (38 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT ) - -//*---------------------------------------- -//* Class 7 commands: Lock commands -//*---------------------------------------- - -#define LOCK_UNLOCK (42 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) // no tested - -//*----------------------------------------------- -// Class 8 commands: Application specific commands -//*----------------------------------------------- - -#define APP_CMD (55 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define GEN_CMD (56 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) // no tested - -#define SDCARD_SET_BUS_WIDTH_CMD (6 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define SDCARD_STATUS_CMD (13 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define SDCARD_SEND_NUM_WR_BLOCKS_CMD (22 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define SDCARD_SET_WR_BLK_ERASE_COUNT_CMD (23 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define SDCARD_APP_OP_COND_CMD (41 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define SDCARD_SET_CLR_CARD_DETECT_CMD (42 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define SDCARD_SEND_SCR_CMD (51 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) - -#define SDCARD_APP_ALL_CMD (SDCARD_SET_BUS_WIDTH_CMD +\ - SDCARD_STATUS_CMD +\ - SDCARD_SEND_NUM_WR_BLOCKS_CMD +\ - SDCARD_SET_WR_BLK_ERASE_COUNT_CMD +\ - SDCARD_APP_OP_COND_CMD +\ - SDCARD_SET_CLR_CARD_DETECT_CMD +\ - SDCARD_SEND_SCR_CMD) - -//*---------------------------------------- -//* Class 9 commands: IO Mode commands -//*---------------------------------------- - -#define MMC_FAST_IO_CMD (39 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_MAXLAT) -#define MMC_GO_IRQ_STATE_CMD (40 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) - -/////////////////////////////////////////////////////////////////////////////// -// OCR Register -/////////////////////////////////////////////////////////////////////////////// -#define AT91C_VDD_16_17 (1 << 4) -#define AT91C_VDD_17_18 (1 << 5) -#define AT91C_VDD_18_19 (1 << 6) -#define AT91C_VDD_19_20 (1 << 7) -#define AT91C_VDD_20_21 (1 << 8) -#define AT91C_VDD_21_22 (1 << 9) -#define AT91C_VDD_22_23 (1 << 10) -#define AT91C_VDD_23_24 (1 << 11) -#define AT91C_VDD_24_25 (1 << 12) -#define AT91C_VDD_25_26 (1 << 13) -#define AT91C_VDD_26_27 (1 << 14) -#define AT91C_VDD_27_28 (1 << 15) -#define AT91C_VDD_28_29 (1 << 16) -#define AT91C_VDD_29_30 (1 << 17) -#define AT91C_VDD_30_31 (1 << 18) -#define AT91C_VDD_31_32 (1 << 19) -#define AT91C_VDD_32_33 (1 << 20) -#define AT91C_VDD_33_34 (1 << 21) -#define AT91C_VDD_34_35 (1 << 22) -#define AT91C_VDD_35_36 (1 << 23) -#define AT91C_CCS (1 << 30) -#define AT91C_CARD_POWER_UP_DONE (1U << 31) - -#define AT91C_MMC_HOST_VOLTAGE_RANGE (AT91C_VDD_27_28 | AT91C_VDD_28_29 | \ - AT91C_VDD_29_30 | AT91C_VDD_30_31 | AT91C_VDD_31_32 | AT91C_VDD_32_33) - -/////////////////////////////////////////////////////////////////////////////// -// CURRENT_STATE & READY_FOR_DATA in SDCard Status Register definition (response type R1) -/////////////////////////////////////////////////////////////////////////////// -#define AT91C_SR_READY_FOR_DATA (1 << 8) // corresponds to buffer empty signalling on the bus -#define AT91C_SR_IDLE (0 << 9) -#define AT91C_SR_READY (1 << 9) -#define AT91C_SR_IDENT (2 << 9) -#define AT91C_SR_STBY (3 << 9) -#define AT91C_SR_TRAN (4 << 9) -#define AT91C_SR_DATA (5 << 9) -#define AT91C_SR_RCV (6 << 9) -#define AT91C_SR_PRG (7 << 9) -#define AT91C_SR_DIS (8 << 9) - -#define AT91C_SR_CARD_SELECTED (AT91C_SR_READY_FOR_DATA + AT91C_SR_TRAN) - -#define MMC_FIRST_RCA 0xCAFE - -/////////////////////////////////////////////////////////////////////////////// -// MMC CSD register header File -// CSD_x_xxx_S for shift value for word x -// CSD_x_xxx_M for mask value for word x -/////////////////////////////////////////////////////////////////////////////// - -// First Response INT <=> CSD[3] : bits 0 to 31 -#define CSD_3_BIT0_S 0 // [0:0] -#define CSD_3_BIT0_M 0x01 -#define CSD_3_CRC_S 1 // [7:1] -#define CSD_3_CRC_M 0x7F -#define CSD_3_MMC_ECC_S 8 // [9:8] reserved for MMC compatibility -#define CSD_3_MMC_ECC_M 0x03 -#define CSD_3_FILE_FMT_S 10 // [11:10] -#define CSD_3_FILE_FMT_M 0x03 -#define CSD_3_TMP_WP_S 12 // [12:12] -#define CSD_3_TMP_WP_M 0x01 -#define CSD_3_PERM_WP_S 13 // [13:13] -#define CSD_3_PERM_WP_M 0x01 -#define CSD_3_COPY_S 14 // [14:14] -#define CSD_3_COPY_M 0x01 -#define CSD_3_FILE_FMT_GRP_S 15 // [15:15] -#define CSD_3_FILE_FMT_GRP_M 0x01 -// reserved 16 // [20:16] -// reserved 0x1F -#define CSD_3_WBLOCK_P_S 21 // [21:21] -#define CSD_3_WBLOCK_P_M 0x01 -#define CSD_3_WBLEN_S 22 // [25:22] -#define CSD_3_WBLEN_M 0x0F -#define CSD_3_R2W_F_S 26 // [28:26] -#define CSD_3_R2W_F_M 0x07 -#define CSD_3_MMC_DEF_ECC_S 29 // [30:29] reserved for MMC compatibility -#define CSD_3_MMC_DEF_ECC_M 0x03 -#define CSD_3_WP_GRP_EN_S 31 // [31:31] -#define CSD_3_WP_GRP_EN_M 0x01 - -// Seconde Response INT <=> CSD[2] : bits 32 to 63 -#define CSD_2_v21_WP_GRP_SIZE_S 0 // [38:32] -#define CSD_2_v21_WP_GRP_SIZE_M 0x7F -#define CSD_2_v21_SECT_SIZE_S 7 // [45:39] -#define CSD_2_v21_SECT_SIZE_M 0x7F -#define CSD_2_v21_ER_BLEN_EN_S 14 // [46:46] -#define CSD_2_v21_ER_BLEN_EN_M 0x01 - -#define CSD_2_v22_WP_GRP_SIZE_S 0 // [36:32] -#define CSD_2_v22_WP_GRP_SIZE_M 0x1F -#define CSD_2_v22_ER_GRP_SIZE_S 5 // [41:37] -#define CSD_2_v22_ER_GRP_SIZE_M 0x1F -#define CSD_2_v22_SECT_SIZE_S 10 // [46:42] -#define CSD_2_v22_SECT_SIZE_M 0x1F - -#define CSD_2_C_SIZE_M_S 15 // [49:47] -#define CSD_2_C_SIZE_M_M 0x07 -#define CSD_2_VDD_WMAX_S 18 // [52:50] -#define CSD_2_VDD_WMAX_M 0x07 -#define CSD_2_VDD_WMIN_S 21 // [55:53] -#define CSD_2_VDD_WMIN_M 0x07 -#define CSD_2_RCUR_MAX_S 24 // [58:56] -#define CSD_2_RCUR_MAX_M 0x07 -#define CSD_2_RCUR_MIN_S 27 // [61:59] -#define CSD_2_RCUR_MIN_M 0x07 -#define CSD_2_CSIZE_L_S 30 // [63:62] <=> 2 LSB of CSIZE -#define CSD_2_CSIZE_L_M 0x03 - -// Third Response INT <=> CSD[1] : bits 64 to 95 -#define CSD_1_CSIZE_H_S 0 // [73:64] <=> 10 MSB of CSIZE -#define CSD_1_CSIZE_H_M 0x03FF -// reserved 10 // [75:74] -// reserved 0x03 -#define CSD_1_DSR_I_S 12 // [76:76] -#define CSD_1_DSR_I_M 0x01 -#define CSD_1_RD_B_MIS_S 13 // [77:77] -#define CSD_1_RD_B_MIS_M 0x01 -#define CSD_1_WR_B_MIS_S 14 // [78:78] -#define CSD_1_WR_B_MIS_M 0x01 -#define CSD_1_RD_B_PAR_S 15 // [79:79] -#define CSD_1_RD_B_PAR_M 0x01 -#define CSD_1_RD_B_LEN_S 16 // [83:80] -#define CSD_1_RD_B_LEN_M 0x0F -#define CSD_1_CCC_S 20 // [95:84] -#define CSD_1_CCC_M 0x0FFF - -// Fourth Response INT <=> CSD[0] : bits 96 to 127 -#define CSD_0_TRANS_SPEED_S 0 // [103:96] -#define CSD_0_TRANS_SPEED_M 0xFF -#define CSD_0_NSAC_S 8 // [111:104] -#define CSD_0_NSAC_M 0xFF -#define CSD_0_TAAC_S 16 // [119:112] -#define CSD_0_TAAC_M 0xFF -// reserved 24 // [121:120] -// reserved 0x03 -#define CSD_0_MMC_SPEC_VERS_S 26 // [125:122] reserved for MMC compatibility -#define CSD_0_MMC_SPEC_VERS_M 0x0F -#define CSD_0_STRUCT_S 30 // [127:126] -#define CSD_0_STRUCT_M 0x03 - -/////////////////////////////////////////////////////////////////////////////// -#endif Property changes on: stable/11/sys/boot/arm/at91/libat91/mci_device.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c (nonexistent) @@ -1,223 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. - * - * $FreeBSD$ - */ - -#include "at91rm9200.h" -#include "at91rm9200_lowlevel.h" - -extern int __bss_start__[]; -extern int __bss_end__[]; - -#define BAUD 115200 -#define AT91C_US_ASYNC_MODE (AT91C_US_USMODE_NORMAL | AT91C_US_NBSTOP_1_BIT | \ - AT91C_US_PAR_NONE | AT91C_US_CHRL_8_BITS | AT91C_US_CLKS_CLOCK) - -/* - * void DefaultSystemInit(void) - * Load the system with sane values based on how the system is configured. - * at91rm9200_lowlevel.h is expected to define the necessary parameters. - */ -void -_init(void) -{ - int *i; - - AT91PS_USART pUSART = (AT91PS_USART)AT91C_BASE_DBGU; - AT91PS_PDC pPDC = (AT91PS_PDC)&(pUSART->US_RPR); - - register unsigned value; - volatile sdram_size_t *p = (sdram_size_t *)SDRAM_BASE; - - AT91C_BASE_ST->ST_RTMR = 1; -#ifdef BOOT_TSC - // For the TSC board, we turn ON the one LED we have while - // early in boot. - AT91C_BASE_PIOC->PIO_PER = AT91C_PIO_PC10; - AT91C_BASE_PIOC->PIO_OER = AT91C_PIO_PC10; - AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC10; -#endif - -#if defined(BOOT_KB920X) - AT91C_BASE_PIOC->PIO_PER = AT91C_PIO_PC18 | AT91C_PIO_PC19 | - AT91C_PIO_PC20; - AT91C_BASE_PIOC->PIO_OER = AT91C_PIO_PC18 | AT91C_PIO_PC19 | - AT91C_PIO_PC20; - AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC18 | AT91C_PIO_PC19 | - AT91C_PIO_PC20; - AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC18; -#endif - - // configure clocks - // assume: - // main osc = 10Mhz - // PLLB configured for 96MHz (48MHz after div) - // CSS = PLLB - // set PLLA = 180MHz - // assume main osc = 10Mhz - // div = 5 , out = 2 (150MHz = 240MHz) - value = AT91C_BASE_CKGR->CKGR_PLLAR; - value &= ~(AT91C_CKGR_DIVA | AT91C_CKGR_OUTA | AT91C_CKGR_MULA); - value |= OSC_MAIN_FREQ_DIV | AT91C_CKGR_OUTA_2 | AT91C_CKGR_SRCA | - ((OSC_MAIN_MULT - 1) << 16); - AT91C_BASE_CKGR->CKGR_PLLAR = value; - - // wait for lock - while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCKA)) - continue; - - // change divider = 3, pres = 1 - value = AT91C_BASE_PMC->PMC_MCKR; - value &= ~(AT91C_PMC_MDIV | AT91C_PMC_PRES); - value |= AT91C_PMC_MDIV_3 | AT91C_PMC_PRES_CLK; - AT91C_BASE_PMC->PMC_MCKR = value; - - // wait for update - while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY)) - continue; - - // change CSS = PLLA - value &= ~AT91C_PMC_CSS; - value |= AT91C_PMC_CSS_PLLA_CLK; - AT91C_BASE_PMC->PMC_MCKR = value; - - // wait for update - while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY)) - continue; - -#ifdef BOOT_KB920X - // setup flash access (allow ample margin) - // 9 wait states, 1 setup, 1 hold, 1 float for 8-bit device - ((AT91PS_SMC2)AT91C_BASE_SMC2)->SMC2_CSR[0] = - AT91C_SMC2_WSEN | - (9 & AT91C_SMC2_NWS) | - ((1 << 8) & AT91C_SMC2_TDF) | - AT91C_SMC2_DBW_8 | - ((1 << 24) & AT91C_SMC2_RWSETUP) | - ((1 << 29) & AT91C_SMC2_RWHOLD); -#endif - - // setup SDRAM access - // EBI chip-select register (CS1 = SDRAM controller) - // 9 col, 13row, 4 bank, CAS2 - // write recovery = 2 (Twr) - // row cycle = 5 (Trc) - // precharge delay = 2 (Trp) - // row to col delay 2 (Trcd) - // active to precharge = 4 (Tras) - // exit self refresh to active = 6 (Txsr) - value = ((AT91PS_EBI)AT91C_BASE_EBI)->EBI_CSA; - value &= ~AT91C_EBI_CS1A; - value |= AT91C_EBI_CS1A_SDRAMC; - AT91C_BASE_EBI->EBI_CSA = value; - - AT91C_BASE_SDRC->SDRC_CR = -#if defined(KB9202_B) || defined(SDRAM_128M) - AT91C_SDRC_NC_10 | -#else - AT91C_SDRC_NC_9 | -#endif - AT91C_SDRC_NR_13 | - AT91C_SDRC_NB_4_BANKS | - AT91C_SDRC_CAS_2 | - ((2 << 7) & AT91C_SDRC_TWR) | - ((5 << 11) & AT91C_SDRC_TRC) | - ((2 << 15) & AT91C_SDRC_TRP) | - ((2 << 19) & AT91C_SDRC_TRCD) | - ((4 << 23) & AT91C_SDRC_TRAS) | - ((6 << 27) & AT91C_SDRC_TXSR); - - // Step 1: We assume 200us of idle time. - // Step 2: Issue an all banks precharge command - AT91C_BASE_SDRC->SDRC_MR = SDRAM_WIDTH | AT91C_SDRC_MODE_PRCGALL_CMD; - *p = 0; - - // Step 3: Issue 8 Auto-refresh (CBR) cycles - AT91C_BASE_SDRC->SDRC_MR = SDRAM_WIDTH | AT91C_SDRC_MODE_RFSH_CMD; - *p = 0; - *p = 0; - *p = 0; - *p = 0; - *p = 0; - *p = 0; - *p = 0; - *p = 0; - - // Step 4: Issue an Mode Set Register (MRS) cycle to program in - // the parameters that we setup in the SDRC_CR register above. - AT91C_BASE_SDRC->SDRC_MR = SDRAM_WIDTH | AT91C_SDRC_MODE_LMR_CMD; - *p = 0; - - // Step 5: set the refresh timer and access memory to start it - // running. We have to wait 3 clocks after the LMR_CMD above, - // and this fits the bill nicely. - AT91C_BASE_SDRC->SDRC_TR = 7 * AT91C_MASTER_CLOCK / 1000000; - *p = 0; - - // Step 6: Set normal mode. - AT91C_BASE_SDRC->SDRC_MR = SDRAM_WIDTH | AT91C_SDRC_MODE_NORMAL_CMD; - *p = 0; - -#if SDRAM_WIDTH == AT91C_SDRC_DBW_32_BITS - // Turn on the upper 16 bits on the SDRAM bus. - AT91C_BASE_PIOC->PIO_ASR = 0xffff0000; - AT91C_BASE_PIOC->PIO_PDR = 0xffff0000; -#endif - // Configure DBGU -use local routine optimized for space - AT91C_BASE_PIOA->PIO_ASR = AT91C_PIO_PA31 | AT91C_PIO_PA30; - AT91C_BASE_PIOA->PIO_PDR = AT91C_PIO_PA31 | AT91C_PIO_PA30; - pUSART->US_IDR = (unsigned int) -1; - pUSART->US_CR = - AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS; - pUSART->US_BRGR = ((((AT91C_MASTER_CLOCK*10)/(BAUD*16))+5)/10); - pUSART->US_TTGR = 0; - pPDC->PDC_PTCR = AT91C_PDC_RXTDIS; - pPDC->PDC_PTCR = AT91C_PDC_TXTDIS; - pPDC->PDC_TNPR = 0; - pPDC->PDC_TNCR = 0; - - pPDC->PDC_RNPR = 0; - pPDC->PDC_RNCR = 0; - - pPDC->PDC_TPR = 0; - pPDC->PDC_TCR = 0; - - pPDC->PDC_RPR = 0; - pPDC->PDC_RCR = 0; - - pPDC->PDC_PTCR = AT91C_PDC_RXTEN; - pPDC->PDC_PTCR = AT91C_PDC_TXTEN; - - pUSART->US_MR = AT91C_US_ASYNC_MODE; - pUSART->US_CR = AT91C_US_TXEN; - pUSART->US_CR = AT91C_US_RXEN; - - /* Zero BSS now that we have memory setup */ - i = (int *)__bss_start__; - while (i < (int *)__bss_end__) - *i++ = 0; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/at91/libat91/sd-card.c =================================================================== --- stable/11/sys/boot/arm/at91/libat91/sd-card.c (revision 329139) +++ stable/11/sys/boot/arm/at91/libat91/sd-card.c (nonexistent) @@ -1,517 +0,0 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software is derived from software provide by Kwikbyte who specifically - * disclaimed copyright on the code. - * - * $FreeBSD$ - */ - -//*---------------------------------------------------------------------------- -//* ATMEL Microcontroller Software Support - ROUSSET - -//*---------------------------------------------------------------------------- -//* The software is delivered "AS IS" without warranty or condition of any -//* kind, either express, implied or statutory. This includes without -//* limitation any warranty or condition with respect to merchantability or -//* fitness for any particular purpose, or against the infringements of -//* intellectual property rights of others. -//*---------------------------------------------------------------------------- -//* File Name : main.c -//* Object : main application written in C -//* Creation : FB 21/11/2002 -//* -//*---------------------------------------------------------------------------- -#include "at91rm9200.h" -#include "lib_AT91RM9200.h" -#include "mci_device.h" -#include "lib.h" -#include "sd-card.h" - -#define AT91C_MCI_TIMEOUT 1000000 /* For AT91F_MCIDeviceWaitReady */ -#define SD_BLOCK_SIZE 512 - -//* Global Variables -static AT91S_MciDevice MCI_Device; - -/****************************************************************************** -**Error return codes -******************************************************************************/ -#define MCI_UNSUPP_SIZE_ERROR 5 -#define MCI_UNSUPP_OFFSET_ERROR 6 - -//*---------------------------------------------------------------------------- -//* \fn MCIDeviceWaitReady -//* \brief Wait for MCI Device ready -//*---------------------------------------------------------------------------- -static unsigned int -MCIDeviceWaitReady(unsigned int timeout) -{ - volatile unsigned int status; - int waitfor; - - if (MCI_Device.state == AT91C_MCI_RX_SINGLE_BLOCK) - waitfor = AT91C_MCI_RXBUFF; - else - waitfor = AT91C_MCI_NOTBUSY; - do - { - status = AT91C_BASE_MCI->MCI_SR; - timeout--; - } - while( !(status & waitfor) && (timeout>0) ); - - status = AT91C_BASE_MCI->MCI_SR; - - // If End of Tx Buffer Empty interrupt occurred - if (MCI_Device.state == AT91C_MCI_TX_SINGLE_BLOCK && status & AT91C_MCI_TXBUFE) { - AT91C_BASE_MCI->MCI_IDR = AT91C_MCI_TXBUFE; - AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_TXTDIS; - MCI_Device.state = AT91C_MCI_IDLE; - } // End of if AT91C_MCI_TXBUFF - - // If End of Rx Buffer Full interrupt occurred - if (MCI_Device.state == AT91C_MCI_RX_SINGLE_BLOCK && status & AT91C_MCI_RXBUFF) { - AT91C_BASE_MCI->MCI_IDR = AT91C_MCI_RXBUFF; - AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_RXTDIS; - MCI_Device.state = AT91C_MCI_IDLE; - } // End of if AT91C_MCI_RXBUFF - - //printf("WaitReady returning status %x\n", status); - - return status; -} - -static inline unsigned int -swap(unsigned int v) -{ - unsigned int t1; - - __asm __volatile("eor %1, %0, %0, ror #16\n" - "bic %1, %1, #0x00ff0000\n" - "mov %0, %0, ror #8\n" - "eor %0, %0, %1, lsr #8\n" - : "+r" (v), "=r" (t1)); - - return (v); -} - -inline static unsigned int -wait_ready() -{ - int status; - int timeout = AT91C_MCI_TIMEOUT; - - // wait for CMDRDY Status flag to read the response - do - { - status = AT91C_BASE_MCI->MCI_SR; - } while( !(status & AT91C_MCI_CMDRDY) && (--timeout > 0) ); - - return status; -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_SendCommand -//* \brief Generic function to send a command to the MMC or SDCard -//*---------------------------------------------------------------------------- -static int -MCI_SendCommand( - unsigned int Cmd, - unsigned int Arg) -{ - unsigned int error; - unsigned int errorMask = AT91C_MCI_SR_ERROR; - unsigned int opcode = Cmd & 0x3F; - - //printf("SendCmd %d (%x) arg %x\n", opcode, Cmd, Arg); - - // Don't check response CRC on ACMD41 (R3 response type). - - if (opcode == 41) - errorMask &= ~AT91C_MCI_RCRCE; - - AT91C_BASE_MCI->MCI_ARGR = Arg; - AT91C_BASE_MCI->MCI_CMDR = Cmd; - - error = wait_ready(); - - if ((error & errorMask) != 0) { - return (1); - } - return 0; -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_GetStatus -//* \brief Addressed card sends its status register -//*---------------------------------------------------------------------------- -static unsigned int -MCI_GetStatus() -{ - if (MCI_SendCommand(SEND_STATUS_CMD, MCI_Device.RCA << 16)) - return 0; - return (AT91C_BASE_MCI->MCI_RSPR[0]); - -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_ReadBlock -//* \brief Start the read for a single 512-byte block -//*---------------------------------------------------------------------------- -static int -MCI_StartReadBlock(unsigned blknum, void *dataBuffer) -{ - // Init Mode Register - AT91C_BASE_MCI->MCI_MR |= ((SD_BLOCK_SIZE << 16) | AT91C_MCI_PDCMODE); - - // (PDC) Receiver Transfer Enable - AT91C_BASE_PDC_MCI->PDC_PTCR = (AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS); - AT91C_BASE_PDC_MCI->PDC_RPR = (unsigned int)dataBuffer; - AT91C_BASE_PDC_MCI->PDC_RCR = SD_BLOCK_SIZE / 4; - AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_RXTEN; - - // SDHC wants block offset, non-HC wants byte offset. - if (!MCI_Device.IsSDHC) - blknum *= SD_BLOCK_SIZE; - - // Send the Read single block command - if (MCI_SendCommand(READ_SINGLE_BLOCK_CMD, blknum)) { - return AT91C_READ_ERROR; - } - MCI_Device.state = AT91C_MCI_RX_SINGLE_BLOCK; - - return 0; -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_readblocks -//* \brief Read one or more blocks -//*---------------------------------------------------------------------------- -int -MCI_readblocks(char* dest, unsigned blknum, unsigned blkcount) -{ - unsigned int status; - unsigned int *walker; - - if (MCI_Device.state != AT91C_MCI_IDLE) { - return 1; - } - - if ((MCI_GetStatus() & AT91C_SR_READY_FOR_DATA) == 0) { - return 1; - } - - // As long as there is data to read - while (blkcount) - { - //Do the reading - if (MCI_StartReadBlock(blknum, dest)) - return -1; - - // Wait MCI Device Ready - status = MCIDeviceWaitReady(AT91C_MCI_TIMEOUT); - if (status & AT91C_MCI_SR_ERROR) - return 1; - - // Fix erratum in MCI part - endian-swap all data. - for (walker = (unsigned int *)dest; - walker < (unsigned int *)(dest + SD_BLOCK_SIZE); walker++) - *walker = swap(*walker); - - // Update counters & pointers - ++blknum; - --blkcount; - dest += SD_BLOCK_SIZE; - } - - - return 0; -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_read -//* \brief Legacy read function, takes byte offset and length but was always -//* used to read full blocks; interface preserved for existing boot code. -//*---------------------------------------------------------------------------- -int -MCI_read(char* dest, unsigned byteoffset, unsigned length) -{ - return MCI_readblocks(dest, - byteoffset/SD_BLOCK_SIZE, length/SD_BLOCK_SIZE); -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_SDCard_SendAppCommand -//* \brief Specific function to send a specific command to the SDCard -//*---------------------------------------------------------------------------- -static int -MCI_SDCard_SendAppCommand( - unsigned int Cmd_App, - unsigned int Arg) -{ - int status; - - if ((status = MCI_SendCommand(APP_CMD, (MCI_Device.RCA << 16))) == 0) - status = MCI_SendCommand(Cmd_App,Arg); - return status; -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_GetCSD -//* \brief Asks to the specified card to send its CSD -//*---------------------------------------------------------------------------- -static int -MCI_GetCSD(unsigned int rca, unsigned int *response) -{ - if (MCI_SendCommand(SEND_CSD_CMD, (rca << 16))) - return 1; - - response[0] = AT91C_BASE_MCI->MCI_RSPR[0]; - response[1] = AT91C_BASE_MCI->MCI_RSPR[1]; - response[2] = AT91C_BASE_MCI->MCI_RSPR[2]; - response[3] = AT91C_BASE_MCI->MCI_RSPR[3]; - - return 0; -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_SDCard_GetOCR -//* \brief Wait for card to power up and determine whether it's SDHC or not. -//*---------------------------------------------------------------------------- -static int -MCI_SDCard_GetOCR() -{ - unsigned int response; - unsigned int arg = AT91C_MMC_HOST_VOLTAGE_RANGE; - int timeout = AT91C_MCI_TIMEOUT; - - // Force card to idle state. - - MCI_SendCommand(GO_IDLE_STATE_CMD, AT91C_NO_ARGUMENT); - - // Begin probe for SDHC by sending CMD8; only v2.0 cards respond to it. - // - // Arg is vvpp where vv is voltage range and pp is an arbitrary bit - // pattern that gets echoed back in the response. The only voltage - // ranges defined are: - // 0x01 = 2.7 - 3.6 - // 0x02 = "reserved for low voltage" whatever that means. - // - // If the card fails to respond then it's not v2.0. If it responds by - // echoing back exactly the arg we sent, then it's a v2.0 card and can - // run at our voltage. That means that when we send the ACMD41 (in - // MCI_SDCard_GetOCR) we can include the HCS bit to inquire about SDHC. - - if (MCI_SendCommand(SD_SEND_IF_COND_CMD, 0x01AA) == 0) { - MCI_Device.IsSDv2 = (AT91C_BASE_MCI->MCI_RSPR[0] == 0x01AA); - } - - // If we've determined the card supports v2.0 functionality, set the - // HCS/CCS bit to indicate that we support SDHC. This will cause a - // v2.0 card to report whether it is SDHC in the ACMD41 response. - - if (MCI_Device.IsSDv2) { - arg |= AT91C_CCS; - } - - // The RCA to be used for CMD55 in Idle state shall be the card's - // default RCA=0x0000. - - MCI_Device.RCA = 0x0; - - // Repeat ACMD41 until the card comes out of power-up-busy state. - - do { - if (MCI_SDCard_SendAppCommand(SDCARD_APP_OP_COND_CMD, arg)) { - return 1; - } - response = AT91C_BASE_MCI->MCI_RSPR[0]; - } while (!(response & AT91C_CARD_POWER_UP_DONE) && (--timeout > 0)); - - // A v2.0 card sets CCS (card capacity status) in the response if it's SDHC. - - if (MCI_Device.IsSDv2) { - MCI_Device.IsSDHC = ((response & AT91C_CCS) == AT91C_CCS); - } - - return (0); -} - -//*---------------------------------------------------------------------------- -//* \fn MCI_SDCard_GetCID -//* \brief Asks to the SDCard on the chosen slot to send its CID -//*---------------------------------------------------------------------------- -static int -MCI_SDCard_GetCID(unsigned int *response) -{ - if (MCI_SendCommand(ALL_SEND_CID_CMD, AT91C_NO_ARGUMENT)) - return 1; - - response[0] = AT91C_BASE_MCI->MCI_RSPR[0]; - response[1] = AT91C_BASE_MCI->MCI_RSPR[1]; - response[2] = AT91C_BASE_MCI->MCI_RSPR[2]; - response[3] = AT91C_BASE_MCI->MCI_RSPR[3]; - - return 0; -} - -//*---------------------------------------------------------------------------- -//* \fn sdcard_4wire -//* \brief Set bus width to 1-bit or 4-bit according to the parm. -//* -//* Unlike most functions in this file, the return value from this one is -//* bool-ish; returns 0 on failure, 1 on success. -//*---------------------------------------------------------------------------- -int -sdcard_use4wire(int use4wire) -{ - volatile int ret_value; - - do { - ret_value=MCI_GetStatus(); - } - while((ret_value > 0) && ((ret_value & AT91C_SR_READY_FOR_DATA) == 0)); - - // If going to 4-wire mode, ask the card to turn off the DAT3 card detect - // pullup resistor, if going to 1-wire ask it to turn it back on. - - ret_value = MCI_SDCard_SendAppCommand(SDCARD_SET_CLR_CARD_DETECT_CMD, - use4wire ? 0 : 1); - if (ret_value != AT91C_CMD_SEND_OK) - return 0; - - // Ask the card to go into the requested mode. - - ret_value = MCI_SDCard_SendAppCommand(SDCARD_SET_BUS_WIDTH_CMD, - use4wire ? AT91C_BUS_WIDTH_4BITS : - AT91C_BUS_WIDTH_1BIT); - if (ret_value != AT91C_CMD_SEND_OK) - return 0; - - // Set the MCI device to match the mode we set in the card. - - if (use4wire) { - MCI_Device.SDCard_bus_width = AT91C_BUS_WIDTH_4BITS; - AT91C_BASE_MCI->MCI_SDCR |= AT91C_MCI_SCDBUS; - } else { - MCI_Device.SDCard_bus_width = AT91C_BUS_WIDTH_1BIT; - AT91C_BASE_MCI->MCI_SDCR &= ~AT91C_MCI_SCDBUS; - } - - return 1; -} - -//*---------------------------------------------------------------------------- -//* \fn sdcard_init -//* \brief get the mci device ready to read from an SD or SDHC card. -//* -//* Unlike most functions in this file, the return value from this one is -//* bool-ish; returns 0 on failure, 1 on success. -//*---------------------------------------------------------------------------- -int -sdcard_init(void) -{ - unsigned int tab_response[4]; - int i; - - // Init MCI for MMC and SDCard interface - AT91F_MCI_CfgPIO(); - AT91F_MCI_CfgPMC(); - AT91F_PDC_Open(AT91C_BASE_PDC_MCI); - - // Init Device Structure - MCI_Device.state = AT91C_MCI_IDLE; - MCI_Device.SDCard_bus_width = 0; - MCI_Device.IsSDv2 = 0; - MCI_Device.IsSDHC = 0; - - // Reset the MCI and set the bus speed. - // Using MCK/230 gives a legal (under 400khz) bus speed for the card id - // sequence for all reasonable master clock speeds. - - AT91C_BASE_MCI->MCI_CR = AT91C_MCI_MCIDIS | 0x80; - AT91C_BASE_MCI->MCI_IDR = 0xFFFFFFFF; - AT91C_BASE_MCI->MCI_DTOR = AT91C_MCI_DTOR_1MEGA_CYCLES; - AT91C_BASE_MCI->MCI_MR = AT91C_MCI_PDCMODE | 114; /* clkdiv 114 = MCK/230 */ - AT91C_BASE_MCI->MCI_SDCR = AT91C_MCI_MMC_SLOTA; - AT91C_BASE_MCI->MCI_CR = AT91C_MCI_MCIEN|AT91C_MCI_PWSEN; - - // Wait for the card to come out of power-up-busy state by repeatedly - // sending ACMD41. This also probes for SDHC versus standard cards. - - for (i = 0; i < 100; i++) { - if (MCI_SDCard_GetOCR() == 0) - break; - if ((i & 0x01) == 0) { - printf("."); - } - } - if (i >= 100) - return 0; - - if (MCI_SDCard_GetCID(tab_response)) - return 0; - - // Tell the card to set its address, and remember the result. - - if (MCI_SendCommand(SET_RELATIVE_ADDR_CMD, 0)) - return 0; - MCI_Device.RCA = (AT91C_BASE_MCI->MCI_RSPR[0] >> 16); - - // After sending CMD3 (set addr) we can increase the clock to full speed. - // Using MCK/4 gives a legal (under 25mhz) bus speed for all reasonable - // master clock speeds. - - AT91C_BASE_MCI->MCI_MR = AT91C_MCI_PDCMODE | 1; /* clkdiv 1 = MCK/4 */ - - if (MCI_GetCSD(MCI_Device.RCA,tab_response)) - return 0; - MCI_Device.READ_BL_LEN = (tab_response[1] >> CSD_1_RD_B_LEN_S) & - CSD_1_RD_B_LEN_M; - -#ifdef REPORT_SIZE - { - unsigned int mult,blocknr; - // compute MULT - mult = 1 << ( ((tab_response[2] >> CSD_2_C_SIZE_M_S) & - CSD_2_C_SIZE_M_M) + 2 ); - // compute MSB of C_SIZE - blocknr = ((tab_response[1] >> CSD_1_CSIZE_H_S) & - CSD_1_CSIZE_H_M) << 2; - // compute MULT * (LSB of C-SIZE + MSB already computed + 1) = BLOCKNR - blocknr = mult * ((blocknr + ((tab_response[2] >> CSD_2_CSIZE_L_S) & - CSD_2_CSIZE_L_M)) + 1); - MCI_Device.Memory_Capacity = (1 << MCI_Device.READ_BL_LEN) * blocknr; - printf("Found SD card %u bytes\n", MCI_Device.Memory_Capacity); - } -#endif - - // Select card and set block length for following transfers. - - if (MCI_SendCommand(SEL_DESEL_CARD_CMD, (MCI_Device.RCA)<<16)) - return 0; - if (MCI_SendCommand(SET_BLOCKLEN_CMD, SD_BLOCK_SIZE)) - return 0; - - return 1; -} Property changes on: stable/11/sys/boot/arm/at91/libat91/sd-card.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/arm/ixp425/Makefile.inc =================================================================== --- stable/11/sys/boot/arm/ixp425/Makefile.inc (revision 329139) +++ stable/11/sys/boot/arm/ixp425/Makefile.inc (nonexistent) @@ -1,42 +0,0 @@ -# $FreeBSD$ - -.if !target(__ixp425_boot_Makefile.inc__) -.PATH: ${.CURDIR}/../../../../libkern ${.CURDIR}/../../../../libkern/arm - -__ixp425_boot_Makefile.inc__: - -# Both Avila and Pronghorn Metro are supported by ixp425 -BOOT_FLAVOR=ixp425 - -CFLAGS+=-Os -ffreestanding \ - -I${.CURDIR}/../../../.. \ - -I${.CURDIR}/../../../../arm \ - -DCPU_XSCALE_IXP425 \ - -Wall -Waggregate-return \ - -Werror \ - -Wnested-externs \ - -Wpointer-arith -Wshadow -Wwrite-strings \ - -Wmissing-prototypes \ - -Wmissing-declarations - -# -Wstrict-prototypes - -CFLAGS+=-DBOOT_${BOOT_FLAVOR:tu} - -LD ?= ld -OBJCOPY ?= objcopy - -.if defined(P) -${P}: ${OBJS} - ${LD} ${LDFLAGS} -o ${.TARGET} ${OBJS} - -CLEANFILES+= ${P} -.endif - -.if defined(WITH_TAG_LIST) -MK_TAG_LIST:=yes -.else -MK_TAG_LIST:=no -.endif - -.endif Property changes on: stable/11/sys/boot/arm/ixp425/Makefile.inc ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/ixp425/boot2/arm_init.S =================================================================== --- stable/11/sys/boot/arm/ixp425/boot2/arm_init.S (revision 329139) +++ stable/11/sys/boot/arm/ixp425/boot2/arm_init.S (nonexistent) @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2008 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include - -ASENTRY_NP(start) -/* Initialise bss and sp */ - nop - adr r1, .Lstart - ldmia r1, {r1, r2, sp} /* Set initial stack and */ - sub r2, r2, r1 /* get zero init data */ - mov r3, #0 -.L1: - str r3, [r1], #0x0004 /* get zero init data */ - subs r2, r2, #4 - bgt .L1 - - .extern main - bl main -/* main should not return. If it does, spin forever */ -infiniteLoop: - b infiniteLoop -END(start) - -.Lstart: - .word _edata - .word _end - .word BOOT_STACK - -ENTRY(cpu_id) - mrc p15, 0, r0, c0, c0, 0 - RET -END(cpu_id) - -/* End */ Property changes on: stable/11/sys/boot/arm/ixp425/boot2/arm_init.S ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/ixp425/boot2/lib.h =================================================================== --- stable/11/sys/boot/arm/ixp425/boot2/lib.h (revision 329139) +++ stable/11/sys/boot/arm/ixp425/boot2/lib.h (nonexistent) @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 2008 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef ARM_BOOT_LIB_H -#define ARM_BOOT_LIB_H - -#include -#include - -int main(void); - -void DELAY(int); - -int getc(int); -void putchar(int); -void xputchar(int); -void putstr(const char *); -void puthex8(u_int8_t); -void puthexlist(const u_int8_t *, int); -void printf(const char *fmt,...); - -void bzero(void *, size_t); -char *strcpy(char *to, const char *from); -int strcmp(const char *to, const char *from); -int p_strlen(const char *); -int p_memcmp(const char *, const char *, unsigned); -void *memchr(const void *, int, size_t); -void memcpy(void *to, const void *from, unsigned size); -void *memmem(const void *, size_t, const void *, size_t); -void p_memset(char *buffer, char value, int size); - -#define strlen p_strlen -#define memcmp p_memcmp -#define memset p_memset - -u_int16_t swap16(u_int16_t); -u_int32_t swap32(u_int32_t); - -const char *board_init(void); -void clr_board(void); -int avila_read(char*, unsigned, unsigned); -u_int cpu_id(void); - -#endif /* !ARM_BOOT_LIB_H */ Property changes on: stable/11/sys/boot/arm/ixp425/boot2/lib.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/ixp425/boot2/ixp425_board.c =================================================================== --- stable/11/sys/boot/arm/ixp425/boot2/ixp425_board.c (revision 329139) +++ stable/11/sys/boot/arm/ixp425/boot2/ixp425_board.c (nonexistent) @@ -1,771 +0,0 @@ -/*- - * Copyright (c) 2008 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -__FBSDID("$FreeBSD$"); -#include -#include -#include - -#include - -#include "lib.h" -#include "cf_ata.h" - -#include -#include -#include - -struct board_config { - const char *desc; - int (*probe)(int boardtype_hint); - void (*init)(void); -}; -/* set of registered boards */ -SET_DECLARE(boards, struct board_config); -#define BOARD_CONFIG(name, _desc) \ -static struct board_config name##config = { \ - .desc = _desc, \ - .probe = name##_probe, \ - .init = name##_init, \ -}; \ -DATA_SET(boards, name##config) - -static u_int cputype; -#define cpu_is_ixp43x() (cputype == CPU_ID_IXP435) -static u_int8_t *ubase; - -static u_int8_t uart_getreg(u_int8_t *, int); -static void uart_setreg(u_int8_t *, int, u_int8_t); - -static void cf_init(void); -static void cf_clr(void); - -#ifdef DEBUG -#define DPRINTF(fmt, ...) printf(fmt, __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) -#endif - -const char * -board_init(void) -{ - struct board_config **pbp; - - cputype = cpu_id() & CPU_ID_CPU_MASK; - - SET_FOREACH(pbp, boards) - /* XXX pass down redboot board type */ - if ((*pbp)->probe(0)) { - (*pbp)->init(); - return (*pbp)->desc; - } - /* XXX panic, unknown board type */ - return "???"; -} - -/* - * This should be called just before starting the kernel. This is so - * that one can undo incompatible hardware settings. - */ -void -clr_board(void) -{ - cf_clr(); -} - -/* - * General support functions. - */ - -/* - * DELAY should delay for the number of microseconds. - * The idea is that the inner loop should take 1us, so val is the - * number of usecs to delay. - */ -void -DELAY(int val) -{ - volatile int sub; - volatile int subsub; - - sub = val; - while(sub) { - subsub = 3; - while(subsub) - subsub--; - sub--; - } -} - -u_int32_t -swap32(u_int32_t a) -{ - return (((a & 0xff) << 24) | ((a & 0xff00) << 8) | - ((a & 0xff0000) >> 8) | ((a & 0xff000000) >> 24)); -} - -u_int16_t -swap16(u_int16_t val) -{ - return (val << 8) | (val >> 8); -} - -/* - * uart related funcs - */ -static u_int8_t -uart_getreg(u_int8_t *bas, int off) -{ - return *((volatile u_int32_t *)(bas + (off << 2))) & 0xff; -} - -static void -uart_setreg(u_int8_t *bas, int off, u_int8_t val) -{ - *((volatile u_int32_t *)(bas + (off << 2))) = (u_int32_t)val; -} - -int -getc(int seconds) -{ - int c, delay, limit; - - c = 0; - delay = 10000; - limit = seconds * 1000000/10000; - while ((uart_getreg(ubase, REG_LSR) & LSR_RXRDY) == 0 && --limit) - DELAY(delay); - - if ((uart_getreg(ubase, REG_LSR) & LSR_RXRDY) == LSR_RXRDY) - c = uart_getreg(ubase, REG_DATA); - - return c; -} - -void -putchar(int ch) -{ - int delay, limit; - - delay = 500; - limit = 20; - while ((uart_getreg(ubase, REG_LSR) & LSR_THRE) == 0 && --limit) - DELAY(delay); - uart_setreg(ubase, REG_DATA, ch); - - limit = 40; - while ((uart_getreg(ubase, REG_LSR) & LSR_TEMT) == 0 && --limit) - DELAY(delay); -} - -void -xputchar(int ch) -{ - if (ch == '\n') - putchar('\r'); - putchar(ch); -} - -void -putstr(const char *str) -{ - while(*str) - xputchar(*str++); -} - -void -puthex8(u_int8_t ch) -{ - const char *hex = "0123456789abcdef"; - - putchar(hex[ch >> 4]); - putchar(hex[ch & 0xf]); -} - -void -puthexlist(const u_int8_t *str, int length) -{ - while(length) { - puthex8(*str); - putchar(' '); - str++; - length--; - } -} - -/* - * - * CF/IDE functions. - * - */ - -struct { - u_int64_t dsize; - u_int64_t total_secs; - u_int8_t heads; - u_int8_t sectors; - u_int32_t cylinders; - - u_int32_t *cs1to; - u_int32_t *cs2to; - - u_int8_t *cs1; - u_int8_t *cs2; - - u_int32_t use_lba; - u_int32_t use_stream8; - u_int32_t debug; - - u_int8_t status; - u_int8_t error; -} dskinf; - -static void cfenable16(void); -static void cfdisable16(void); -static u_int8_t cfread8(u_int32_t off); -static u_int16_t cfread16(u_int32_t off); -static void cfreadstream8(void *buf, int length); -static void cfreadstream16(void *buf, int length); -static void cfwrite8(u_int32_t off, u_int8_t val); -static u_int8_t cfaltread8(u_int32_t off); -static void cfaltwrite8(u_int32_t off, u_int8_t val); -static int cfwait(u_int8_t mask); -static int cfaltwait(u_int8_t mask); -static int cfcmd(u_int32_t cmd, u_int32_t cylinder, u_int32_t head, - u_int32_t sector, u_int32_t count, u_int32_t feature); -static void cfreset(void); -#ifdef DEBUG -static int cfgetparams(void); -#endif -static void cfprintregs(void); - -static void -cf_init(void) -{ - u_int8_t status; -#ifdef DEBUG - int rval; -#endif - - /* NB: board init routines setup other parts of dskinf */ - dskinf.use_stream8 = 0; - dskinf.use_lba = 0; - dskinf.debug = 1; - - DPRINTF("cs1 %x, cs2 %x\n", dskinf.cs1, dskinf.cs2); - - /* Setup the CF window */ - *dskinf.cs1to |= (EXP_BYTE_EN | EXP_WR_EN | EXP_BYTE_RD16 | EXP_CS_EN); - DPRINTF("t1 %x, ", *dskinf.cs1to); - - *dskinf.cs2to |= (EXP_BYTE_EN | EXP_WR_EN | EXP_BYTE_RD16 | EXP_CS_EN); - DPRINTF("t2 %x\n", *dskinf.cs2to); - - /* Detect if there is a disk. */ - cfwrite8(CF_DRV_HEAD, CF_D_IBM); - DELAY(1000); - status = cfread8(CF_STATUS); - if (status != 0x50) - printf("cf-ata0 %x\n", (u_int32_t)status); - if (status == 0xff) { - printf("cf_ata0: No disk!\n"); - return; - } - - cfreset(); - - if (dskinf.use_stream8) { - DPRINTF("setting %d bit mode.\n", 8); - cfwrite8(CF_FEATURE, 0x01); /* Enable 8 bit transfers */ - cfwrite8(CF_COMMAND, ATA_SETFEATURES); - cfaltwait(CF_S_READY); - } - -#ifdef DEBUG - rval = cfgetparams(); - if (rval) - return; -#endif - dskinf.use_lba = 1; - dskinf.debug = 0; -} - -static void -cf_clr(void) -{ - cfwrite8(CF_DRV_HEAD, CF_D_IBM); - cfaltwait(CF_S_READY); - cfwrite8(CF_FEATURE, 0x81); /* Enable 8 bit transfers */ - cfwrite8(CF_COMMAND, ATA_SETFEATURES); - cfaltwait(CF_S_READY); -} - -static void -cfenable16(void) -{ - u_int32_t val; - - val = *dskinf.cs1to; - *dskinf.cs1to = val &~ EXP_BYTE_EN; - DELAY(100); -#if 0 - DPRINTF("%s: cs1 timing reg %x\n", *dskinf.cs1to, __func__); -#endif -} - -static void -cfdisable16(void) -{ - u_int32_t val; - - DELAY(100); - val = *dskinf.cs1to; - *dskinf.cs1to = val | EXP_BYTE_EN; -#if 0 - DPRINTF("%s: cs1 timing reg %x\n", *dskinf.cs1to, __func__); -#endif -} - -static u_int8_t -cfread8(u_int32_t off) -{ - volatile u_int8_t *vp; - - vp = (volatile u_int8_t *)(dskinf.cs1 + off); - return *vp; -} - -static void -cfreadstream8(void *buf, int length) -{ - u_int8_t *lbuf; - u_int8_t tmp; - - lbuf = buf; - while (length) { - tmp = cfread8(CF_DATA); - *lbuf = tmp; -#ifdef DEBUG - if (dskinf.debug && (length > (512 - 32))) { - if ((length % 16) == 0) - xputchar('\n'); - puthex8(tmp); - putchar(' '); - } -#endif - lbuf++; - length--; - } -#ifdef DEBUG - if (dskinf.debug) - xputchar('\n'); -#endif -} - -static u_int16_t -cfread16(u_int32_t off) -{ - volatile u_int16_t *vp; - - vp = (volatile u_int16_t *)(dskinf.cs1 + off); - return swap16(*vp); -} - -static void -cfreadstream16(void *buf, int length) -{ - u_int16_t *lbuf; - - length = length / 2; - cfenable16(); - lbuf = buf; - while (length--) { - *lbuf = cfread16(CF_DATA); - lbuf++; - } - cfdisable16(); -} - -static void -cfwrite8(u_int32_t off, u_int8_t val) -{ - volatile u_int8_t *vp; - - vp = (volatile u_int8_t *)(dskinf.cs1 + off); - *vp = val; -} - -#if 0 -static void -cfwrite16(u_int32_t off, u_int16_t val) -{ - volatile u_int16_t *vp; - - vp = (volatile u_int16_t *)(dskinf.cs1 + off); - *vp = val; -} -#endif - -static u_int8_t -cfaltread8(u_int32_t off) -{ - volatile u_int8_t *vp; - - off &= 0x0f; - vp = (volatile u_int8_t *)(dskinf.cs2 + off); - return *vp; -} - -static void -cfaltwrite8(u_int32_t off, u_int8_t val) -{ - volatile u_int8_t *vp; - - /* - * This is documented in the Intel appnote 302456. - */ - off &= 0x0f; - vp = (volatile u_int8_t *)(dskinf.cs2 + off); - *vp = val; -} - -static int -cfwait(u_int8_t mask) -{ - u_int8_t status; - u_int32_t tout; - - tout = 0; - while (tout <= 5000000) { - status = cfread8(CF_STATUS); - if (status == 0xff) { - printf("%s: master: no status, reselecting\n", - __func__); - cfwrite8(CF_DRV_HEAD, CF_D_IBM); - DELAY(1); - status = cfread8(CF_STATUS); - } - if (status == 0xff) - return -1; - dskinf.status = status; - if (!(status & CF_S_BUSY)) { - if (status & CF_S_ERROR) { - dskinf.error = cfread8(CF_ERROR); - printf("%s: error, status 0x%x error 0x%x\n", - __func__, status, dskinf.error); - } - if ((status & mask) == mask) { - DPRINTF("%s: status 0x%x mask 0x%x tout %u\n", - __func__, status, mask, tout); - return (status & CF_S_ERROR); - } - } - if (tout > 1000) { - tout += 1000; - DELAY(1000); - } else { - tout += 10; - DELAY(10); - } - } - return -1; -} - -static int -cfaltwait(u_int8_t mask) -{ - u_int8_t status; - u_int32_t tout; - - tout = 0; - while (tout <= 5000000) { - status = cfaltread8(CF_ALT_STATUS); - if (status == 0xff) { - printf("cfaltwait: master: no status, reselecting\n"); - cfwrite8(CF_DRV_HEAD, CF_D_IBM); - DELAY(1); - status = cfread8(CF_STATUS); - } - if (status == 0xff) - return -1; - dskinf.status = status; - if (!(status & CF_S_BUSY)) { - if (status & CF_S_ERROR) - dskinf.error = cfread8(CF_ERROR); - if ((status & mask) == mask) { - DPRINTF("cfaltwait: tout %u\n", tout); - return (status & CF_S_ERROR); - } - } - if (tout > 1000) { - tout += 1000; - DELAY(1000); - } else { - tout += 10; - DELAY(10); - } - } - return -1; -} - -static int -cfcmd(u_int32_t cmd, u_int32_t cylinder, u_int32_t head, u_int32_t sector, - u_int32_t count, u_int32_t feature) -{ - if (cfwait(0) < 0) { - printf("cfcmd: timeout\n"); - return -1; - } - cfwrite8(CF_FEATURE, feature); - cfwrite8(CF_CYL_L, cylinder); - cfwrite8(CF_CYL_H, cylinder >> 8); - if (dskinf.use_lba) - cfwrite8(CF_DRV_HEAD, CF_D_IBM | CF_D_LBA | head); - else - cfwrite8(CF_DRV_HEAD, CF_D_IBM | head); - cfwrite8(CF_SECT_NUM, sector); - cfwrite8(CF_SECT_CNT, count); - cfwrite8(CF_COMMAND, cmd); - return 0; -} - -static void -cfreset(void) -{ - u_int8_t status; - u_int32_t tout; - - cfwrite8(CF_DRV_HEAD, CF_D_IBM); - DELAY(1); -#ifdef DEBUG - cfprintregs(); -#endif - cfread8(CF_STATUS); - cfaltwrite8(CF_ALT_DEV_CTR, CF_A_IDS | CF_A_RESET); - DELAY(10000); - cfaltwrite8(CF_ALT_DEV_CTR, CF_A_IDS); - DELAY(10000); - cfread8(CF_ERROR); - DELAY(3000); - - for (tout = 0; tout < 310000; tout++) { - cfwrite8(CF_DRV_HEAD, CF_D_IBM); - DELAY(1); - status = cfread8(CF_STATUS); - if (!(status & CF_S_BUSY)) - break; - DELAY(100); - } - DELAY(1); - if (status & CF_S_BUSY) { - cfprintregs(); - printf("cfreset: Status stayed busy after reset.\n"); - } - DPRINTF("cfreset: finished, tout %u\n", tout); -} - -#ifdef DEBUG -static int -cfgetparams(void) -{ - u_int8_t *buf; - - buf = (u_int8_t *)(0x170000); - p_memset((char *)buf, 0, 1024); - /* Select the drive. */ - cfwrite8(CF_DRV_HEAD, CF_D_IBM); - DELAY(1); - cfcmd(ATA_ATA_IDENTIFY, 0, 0, 0, 0, 0); - if (cfaltwait(CF_S_READY | CF_S_DSC | CF_S_DRQ)) { - printf("cfgetparams: ATA_IDENTIFY failed.\n"); - return -1; - } - if (dskinf.use_stream8) - cfreadstream8(buf, 512); - else - cfreadstream16(buf, 512); - if (dskinf.debug) - cfprintregs(); -#if 0 - memcpy(&dskinf.ata_params, buf, sizeof(struct ata_params)); - dskinf.cylinders = dskinf.ata_params.cylinders; - dskinf.heads = dskinf.ata_params.heads; - dskinf.sectors = dskinf.ata_params.sectors; - printf("dsk0: sec %x, hd %x, cyl %x, stat %x, err %x\n", - (u_int32_t)dskinf.ata_params.sectors, - (u_int32_t)dskinf.ata_params.heads, - (u_int32_t)dskinf.ata_params.cylinders, - (u_int32_t)dskinf.status, - (u_int32_t)dskinf.error); -#endif - dskinf.status = cfread8(CF_STATUS); - if (dskinf.debug) - printf("cfgetparams: ata_params * %x, stat %x\n", - (u_int32_t)buf, (u_int32_t)dskinf.status); - return 0; -} -#endif /* DEBUG */ - -static void -cfprintregs(void) -{ - u_int8_t rv; - - putstr("cfprintregs: regs error "); - rv = cfread8(CF_ERROR); - puthex8(rv); - putstr(", count "); - rv = cfread8(CF_SECT_CNT); - puthex8(rv); - putstr(", sect "); - rv = cfread8(CF_SECT_NUM); - puthex8(rv); - putstr(", cyl low "); - rv = cfread8(CF_CYL_L); - puthex8(rv); - putstr(", cyl high "); - rv = cfread8(CF_CYL_H); - puthex8(rv); - putstr(", drv head "); - rv = cfread8(CF_DRV_HEAD); - puthex8(rv); - putstr(", status "); - rv = cfread8(CF_STATUS); - puthex8(rv); - putstr("\n"); -} - -int -avila_read(char *dest, unsigned source, unsigned length) -{ - if (dskinf.use_lba == 0 && source == 0) - source++; - if (dskinf.debug) - printf("avila_read: 0x%x, sect %d num secs %d\n", - (u_int32_t)dest, source, length); - while (length) { - cfwait(CF_S_READY); - /* cmd, cyl, head, sect, count, feature */ - cfcmd(ATA_READ, (source >> 8) & 0xffff, source >> 24, - source & 0xff, 1, 0); - - cfwait(CF_S_READY | CF_S_DRQ | CF_S_DSC); - if (dskinf.use_stream8) - cfreadstream8(dest, 512); - else - cfreadstream16(dest, 512); - length--; - source++; - dest += 512; - } - return 0; -} - -/* - * Gateworks Avila Support. - */ -static int -avila_probe(int boardtype_hint) -{ - volatile u_int32_t *cs; - /* - * Redboot only configure the chip selects that are needed, so - * use that to figure out if it is an Avila or ADI board. The - * Avila boards use CS2 and ADI does not. - */ - cs = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS2_OFFSET); - return (*cs != 0); -} - -static void -avila_init(void) -{ - /* Config the serial port. RedBoot should do the rest. */ - ubase = (u_int8_t *)(IXP425_UART0_HWBASE); - - dskinf.cs1to = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS1_OFFSET); - dskinf.cs2to = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS2_OFFSET); - dskinf.cs1 = (u_int8_t *)IXP425_EXP_BUS_CS1_HWBASE; - dskinf.cs2 = (u_int8_t *)IXP425_EXP_BUS_CS2_HWBASE; - - cf_init(); -} -BOARD_CONFIG(avila, "Gateworks Avila"); - -/* - * Gateworks Cambria Support. - */ -static int -cambria_probe(int boardtype_hint) -{ - return cpu_is_ixp43x(); -} - -static void -cambria_init(void) -{ - /* Config the serial port. RedBoot should do the rest. */ - ubase = (u_int8_t *)(IXP425_UART0_HWBASE); - - dskinf.cs1to = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS3_OFFSET); - dskinf.cs2to = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS4_OFFSET); - dskinf.cs1 = (u_int8_t *)CAMBRIA_CFSEL0_HWBASE; - dskinf.cs2 = (u_int8_t *)CAMBRIA_CFSEL1_HWBASE; - - cf_init(); -} -BOARD_CONFIG(cambria, "Gateworks Cambria"); - -/* - * Pronghorn Metro Support. - */ -static int -pronghorn_probe(int boardtype_hint) -{ - volatile u_int32_t *cs; - /* - * Redboot only configure the chip selects that are needed, so - * use that to figure out if it is an Avila or ADI board. The - * Avila boards use CS2 and ADI does not. - */ - cs = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS2_OFFSET); - return (*cs == 0); -} - -static void -pronghorn_init(void) -{ - /* Config the serial port. RedBoot should do the rest. */ - ubase = (u_int8_t *)(IXP425_UART1_HWBASE); - - dskinf.cs1to = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS3_OFFSET); - dskinf.cs2to = (u_int32_t *)(IXP425_EXP_HWBASE + EXP_TIMING_CS4_OFFSET); - dskinf.cs1 = (u_int8_t *)IXP425_EXP_BUS_CS3_HWBASE; - dskinf.cs2 = (u_int8_t *)IXP425_EXP_BUS_CS4_HWBASE; - - cf_init(); -} -BOARD_CONFIG(pronghorn, "Pronghorn Metro"); Property changes on: stable/11/sys/boot/arm/ixp425/boot2/ixp425_board.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/ixp425/boot2/boot2.c =================================================================== --- stable/11/sys/boot/arm/ixp425/boot2/boot2.c (revision 329139) +++ stable/11/sys/boot/arm/ixp425/boot2/boot2.c (nonexistent) @@ -1,446 +0,0 @@ -/*- - * Copyright (c) 2008 John Hay - * Copyright (c) 1998 Robert Nordier - * All rights reserved. - * - * Redistribution and use in source and binary forms are freely - * permitted provided that the above copyright notice and this - * paragraph and the following disclaimer are duplicated in all - * such forms. - * - * This software is provided "AS IS" and without any express or - * implied warranties, including, without limitation, the implied - * warranties of merchantability and fitness for a particular - * purpose. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include - -#include - -#include "lib.h" -#include "paths.h" -#include "rbx.h" - -extern uint32_t _end; - -#define NOPT 6 - -static const char optstr[NOPT] = "agnrsv"; -static const unsigned char flags[NOPT] = { - RBX_ASKNAME, - RBX_GDB, - RBX_NOINTR, - RBX_DFLTROOT, - RBX_SINGLE, - RBX_VERBOSE -}; - -static unsigned dsk_start; -static char cmd[512]; -static char kname[1024]; -static uint32_t opts; -static uint8_t dsk_meta; -static int bootslice; -static int bootpart; -static int disk_layout; -#define DL_UNKNOWN 0 -#define DL_RAW 1 /* Dangerously dedicated */ -#define DL_SLICE 2 /* Use only slices (DOS partitions) */ -#define DL_SLICEPART 3 /* Use slices and partitions */ - -static void load(void); -static int parse(void); -static int dskread(void *, unsigned, unsigned); -static int drvread(void *, unsigned, unsigned); -#ifdef FIXUP_BOOT_DRV -static void fixup_boot_drv(caddr_t, int, int, int); -#endif - -#include "ufsread.c" - -#ifdef DEBUG -#define DPRINTF(fmt, ...) printf(fmt, __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) -#endif - -static inline int -xfsread(ufs_ino_t inode, void *buf, size_t nbyte) -{ - if ((size_t)fsread(inode, buf, nbyte) != nbyte) - return -1; - return 0; -} - -static inline void -getstr(int c) -{ - char *s; - - s = cmd; - if (c == 0) - c = getc(10000); - for (;;) { - switch (c) { - case 0: - break; - case '\177': - case '\b': - if (s > cmd) { - s--; - printf("\b \b"); - } - break; - case '\n': - case '\r': - *s = 0; - return; - default: - if (s - cmd < sizeof(cmd) - 1) - *s++ = c; - xputchar(c); - } - c = getc(10000); - } -} - -int -main(void) -{ - const char *bt; - int autoboot, c = 0; - ufs_ino_t ino; - - dmadat = (void *)(0x1c0000); - p_memset((char *)dmadat, 0, 32 * 1024); - bt = board_init(); - - printf("FreeBSD ARM (%s) boot2 v%d.%d\n", bt, 0, 4); - - autoboot = 1; - - /* Process configuration file */ - if ((ino = lookup(PATH_CONFIG)) || - (ino = lookup(PATH_DOTCONFIG))) - fsread(ino, cmd, sizeof(cmd)); - - if (*cmd) { - if (parse()) - autoboot = 0; - printf("%s: %s\n", PATH_CONFIG, cmd); - /* Do not process this command twice */ - *cmd = 0; - } - - if (*kname == '\0') - strcpy(kname, PATH_KERNEL); - - /* Present the user with the boot2 prompt. */ - for (;;) { - printf("\nDefault: %s\nboot: ", kname); - if (!autoboot || - (OPT_CHECK(RBX_NOINTR) == 0 && (c = getc(2)) != 0)) - getstr(c); - xputchar('\n'); - autoboot = 0; - c = 0; - DPRINTF("cmd is '%s'\n", cmd); - if (parse()) - xputchar('\a'); - else - load(); - } -} - -static void -load(void) -{ - Elf32_Ehdr eh; - static Elf32_Phdr ep[2]; - caddr_t p; - ufs_ino_t ino; - uint32_t addr; - int i, j; -#ifdef FIXUP_BOOT_DRV - caddr_t staddr; - int klen; - - staddr = (caddr_t)0xffffffff; - klen = 0; -#endif - if (!(ino = lookup(kname))) { - if (!ls) - printf("No %s\n", kname); - return; - } - DPRINTF("Found %s\n", kname); - if (xfsread(ino, &eh, sizeof(eh))) - return; - if (!IS_ELF(eh)) { - printf("Invalid %s\n", "format"); - return; - } - fs_off = eh.e_phoff; - for (j = i = 0; i < eh.e_phnum && j < 2; i++) { - if (xfsread(ino, ep + j, sizeof(ep[0]))) - return; - if (ep[j].p_type == PT_LOAD) - j++; - } - for (i = 0; i < 2; i++) { - p = (caddr_t)(ep[i].p_paddr & 0x0fffffff); - fs_off = ep[i].p_offset; -#ifdef FIXUP_BOOT_DRV - if (staddr == (caddr_t)0xffffffff) - staddr = p; - klen += ep[i].p_filesz; -#endif - if (xfsread(ino, p, ep[i].p_filesz)) - return; - } - addr = eh.e_entry & 0x0fffffff; - DPRINTF("Entry point %x for %s\n", addr, kname); - clr_board(); -#ifdef FIXUP_BOOT_DRV - fixup_boot_drv(staddr, klen, bootslice, bootpart); -#endif - ((void(*)(int))addr)(RB_BOOTINFO /* XXX | (opts & RBX_MASK) */); -} - -static int -parse() -{ - char *arg = cmd; - char *ep, *p; - int c, i; - - while ((c = *arg++)) { - if (c == ' ' || c == '\t' || c == '\n') - continue; - for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); - ep = p; - if (*p) - *p++ = 0; - if (c == '-') { - while ((c = *arg++)) { - for (i = 0; c != optstr[i]; i++) - if (i == NOPT - 1) - return -1; - opts ^= OPT_SET(flags[i]); - } - } else { - arg--; - /* look for ad0s1a:... | ad0s1:... */ - if (strlen(arg) > 6 && arg[0] == 'a' && - arg[1] == 'd' && arg[3] == 's' && - (arg[5] == ':' || arg[6] == ':')) { - /* XXX Should also handle disk. */ - bootslice = arg[4] - '0'; - if (bootslice < 1 || bootslice > 4) - return (-1); - bootpart = 0; - if (arg[5] != ':') - bootpart = arg[5] - 'a'; - if (bootpart < 0 || bootpart > 7) - return (-1); - dsk_meta = 0; - if (arg[5] == ':') - arg += 6; - else - arg += 7; - /* look for ad0a:... */ - } else if (strlen(arg) > 4 && arg[0] == 'a' && - arg[1] == 'd' && arg[2] == '0' && arg[4] == ':') { - bootslice = 0; - bootpart = arg[3] - 'a'; - if (bootpart < 0 || bootpart > 7) - return (-1); - dsk_meta = 0; - arg += 5; - } - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(kname)) - return -1; - memcpy(kname, arg, i + 1); - } - } - arg = p; - } - return 0; -} - -/* - * dskread() will try to handle the disk layouts that are typically - * encountered. - * - raw or "Dangerously Dedicated" mode. No real slice table, just the - * default one that is included with bsdlabel -B. Typically this is - * used with ROOTDEVNAME=\"ufs:ad0a\". - * - slice only. Only a slice table is installed with no bsd label or - * bsd partition table. This is typically used with - * ROOTDEVNAME=\"ufs:ad0s1\". - * - slice + bsd label + partition table. This is typically done with - * with fdisk + bsdlabel and is used with ROOTDEVNAME=\"ufs:ad0s1a\". - */ -static int -dskread(void *buf, unsigned lba, unsigned nblk) -{ - struct dos_partition *dp; - struct disklabel *d; - char *sec; - int i; - - if (!dsk_meta) { - sec = dmadat->secbuf; - dsk_start = 0; - if (drvread(sec, DOSBBSECTOR, 1)) - return -1; - dp = (void *)(sec + DOSPARTOFF); - if (bootslice != 0) { - i = bootslice - 1; - if (dp[i].dp_typ != DOSPTYP_386BSD) - return -1; - } else { - for (i = 0; i < NDOSPART; i++) { - if ((dp[i].dp_typ == DOSPTYP_386BSD) && - (dp[i].dp_flag == 0x80)) - break; - } - } - if (i != NDOSPART) { - bootslice = i + 1; - DPRINTF("Found an active fbsd slice. (%d)\n", i + 1); - /* - * Although dp_start is aligned within the disk - * partition structure, DOSPARTOFF is 446, which - * is only word (2) aligned, not longword (4) - * aligned. Cope by using memcpy to fetch the - * start of this partition. - */ - memcpy(&dsk_start, &dp[i].dp_start, 4); - dsk_start = swap32(dsk_start); - DPRINTF("dsk_start %x\n", dsk_start); - if ((bootslice == 4) && (dsk_start == 0)) { - disk_layout = DL_RAW; - bootslice = 0; - } - } - if (drvread(sec, dsk_start + LABELSECTOR, 1)) - return -1; - d = (void *)(sec + LABELOFFSET); - if ((d->d_magic == DISKMAGIC && d->d_magic2 == DISKMAGIC) || - (swap32(d->d_magic) == DISKMAGIC && - swap32(d->d_magic2) == DISKMAGIC)) { - DPRINTF("p_size = %x\n", - !d->d_partitions[bootpart].p_size); - if (!d->d_partitions[bootpart].p_size) { - printf("Invalid partition\n"); - return -1; - } - DPRINTF("p_offset %x, RAW %x\n", - swap32(d->d_partitions[bootpart].p_offset), - swap32(d->d_partitions[RAW_PART].p_offset)); - dsk_start += swap32(d->d_partitions[bootpart].p_offset); - dsk_start -= swap32(d->d_partitions[RAW_PART].p_offset); - if ((disk_layout == DL_UNKNOWN) && (bootslice == 0)) - disk_layout = DL_RAW; - else if (disk_layout == DL_UNKNOWN) - disk_layout = DL_SLICEPART; - } else { - disk_layout = DL_SLICE; - DPRINTF("Invalid %s\n", "label"); - } - DPRINTF("bootslice %d, bootpart %d, dsk_start %u\n", bootslice, - bootpart, dsk_start); - dsk_meta++; - } - return drvread(buf, dsk_start + lba, nblk); -} - -static int -drvread(void *buf, unsigned lba, unsigned nblk) -{ - static unsigned c = 0x2d5c7c2f; - - printf("%c\b", c = c << 8 | c >> 24); - return (avila_read((char *)buf, lba, nblk)); -} - -#ifdef FIXUP_BOOT_DRV -/* - * fixup_boot_drv() will try to find the ROOTDEVNAME spec in the kernel - * and change it to what was specified on the comandline or /boot.conf - * file or to what was encountered on the disk. It will try to handle 3 - * different disk layouts, raw (dangerously dedicated), slice only and - * slice + partition. It will look for the following strings in the - * kernel, but if it is one of the first three, the string in the kernel - * must use the correct form to match the actual disk layout: - * - ufs:ad0a - * - ufs:ad0s1 - * - ufs:ad0s1a - * - ufs:ROOTDEVNAME - * In the case of the first three strings, only the "a" at the end and - * the "1" after the "s" will be modified, if they exist. The string - * length will not be changed. In the case of the last string, the - * whole string will be built up and nul, '\0' terminated. - */ -static void -fixup_boot_drv(caddr_t addr, int klen, int bs, int bp) -{ - const u_int8_t op[] = "ufs:ROOTDEVNAME"; - const u_int8_t op2[] = "ufs:ad0"; - u_int8_t *p, *ps; - - DPRINTF("fixup_boot_drv: 0x%x, %d, slice %d, partition %d\n", - (int)addr, klen, bs, bp); - if (bs > 4) - return; - if (bp > 7) - return; - ps = memmem(addr, klen, op, sizeof(op)); - if (ps != NULL) { - p = ps + 4; /* past ufs: */ - DPRINTF("Found it at 0x%x\n", (int)ps); - p[0] = 'a'; p[1] = 'd'; p[2] = '0'; /* ad0 */ - p += 3; - if (bs > 0) { - /* append slice */ - *p++ = 's'; - *p++ = bs + '0'; - } - if (disk_layout != DL_SLICE) { - /* append partition */ - *p++ = bp + 'a'; - } - *p = '\0'; - } else { - ps = memmem(addr, klen, op2, sizeof(op2) - 1); - if (ps != NULL) { - p = ps + sizeof(op2) - 1; - DPRINTF("Found it at 0x%x\n", (int)ps); - if (*p == 's') { - /* fix slice */ - p++; - *p++ = bs + '0'; - } - if (*p == 'a') - *p = bp + 'a'; - } - } - if (ps == NULL) { - printf("Could not locate \"%s\" to fix kernel boot device, " - "check ROOTDEVNAME is set\n", op); - return; - } - DPRINTF("Changed boot device to %s\n", ps); -} -#endif Property changes on: stable/11/sys/boot/arm/ixp425/boot2/boot2.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/ixp425/boot2/cf_ata.h =================================================================== --- stable/11/sys/boot/arm/ixp425/boot2/cf_ata.h (revision 329139) +++ stable/11/sys/boot/arm/ixp425/boot2/cf_ata.h (nonexistent) @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 2008 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef ARM_BOOT_CF_ATA_H -#define ARM_BOOT_CF_ATA_H - -#define CF_DATA 0x00 -#define CF_ERROR 0x01 -#define CF_FEATURE 0x01 -#define CF_SECT_CNT 0x02 -#define CF_SECT_NUM 0x03 -#define CF_CYL_L 0x04 -#define CF_CYL_H 0x05 -#define CF_DRV_HEAD 0x06 -#define CF_D_MASTER 0x00 -#define CF_D_LBA 0x40 -#define CF_D_IBM 0xa0 -#define CF_STATUS 0x07 -#define CF_S_ERROR 0x01 -#define CF_S_INDEX 0x02 -#define CF_S_CORR 0x04 -#define CF_S_DRQ 0x08 -#define CF_S_DSC 0x10 -#define CF_S_DWF 0x20 -#define CF_S_READY 0x40 -#define CF_S_BUSY 0x80 -#define CF_COMMAND 0x07 - -/* This is according to the appnote, but Sam use 0x1e in avila_ata.c */ -#define CF_ALT_STATUS 0x16 -#define CF_ALT_DEV_CTR 0x16 -#define CF_ALT_DEV_CTR2 0x1e -#define CF_A_IDS 0x02 -#define CF_A_RESET 0x04 -#define CF_A_4BIT 0x08 - -#define AVILA_IDE_GPIN 12 - -#endif /* !ARM_BOOT_CF_ATA_H */ Property changes on: stable/11/sys/boot/arm/ixp425/boot2/cf_ata.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/ixp425/boot2/Makefile =================================================================== --- stable/11/sys/boot/arm/ixp425/boot2/Makefile (revision 329139) +++ stable/11/sys/boot/arm/ixp425/boot2/Makefile (nonexistent) @@ -1,78 +0,0 @@ -# $FreeBSD$ - -.include - -# We get a lot of the std lib functions from here. -.PATH: ${.CURDIR}/../../at91/libat91 - -# Enable to get debug msgs -#DEBUG=yes - -# Hack to search through the kernel for ufs:ad0s1a and replace it with -# the correct one for the active slice/partition. -FIXUP_BOOT_DRV=yes - -P=boot2 -FILES=${P} -SRCS=arm_init.S boot2.c ${BOOT_FLAVOR:tl}_board.c -SRCS+=memchr.c memcmp.c memcpy.c memmem.c memset.c printf.c strcmp.c strcpy.c -SRCS+=strlen.c ashldi3.c divsi3.S muldi3.c -SRCS+=aeabi_unwind.c -MAN= - -KERNPHYSADDR=0x180000 -KERNVIRTADDR=${KERNPHYSADDR} -BOOT_STACK=0x200000-4 -M=${MACHINE} -LDFLAGS=-e ${KERNPHYSADDR} -EB -T ldscript.${M} -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} -S=${.CURDIR}/../../../.. - -CFLAGS+= \ - -DBOOT_STACK=${BOOT_STACK} \ - -I${.CURDIR}/../../../common \ - -I${.CURDIR} - -.if defined(FIXUP_BOOT_DRV) -CFLAGS+=-DFIXUP_BOOT_DRV -.endif -.if defined(DEBUG) -CFLAGS+=-DDEBUG -.endif - -ldscript.$M: $S/conf/ldscript.$M - cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \ - sed s/KERNVIRTADDR/${KERNVIRTADDR}/g | \ - sed s/" + SIZEOF_HEADERS"// > ldscript.$M - -${P}: ldscript.$M - -CLEANFILES+=ldscript.$M - -memchr.c: $S/../lib/libc/string/memchr.c - sed -e 's/string\.h/lib.h/' < $S/../lib/libc/string/memchr.c > \ - ${.TARGET} - -memmem.c: $S/../lib/libc/string/memmem.c - sed -e 's/string\.h/lib.h/' < $S/../lib/libc/string/memmem.c > \ - ${.TARGET} - -CLEANFILES+=memchr.c memmem.c - -ashldi3.o: $S/libkern/ashldi3.c - ${CC} -c ${CFLAGS} -D_KERNEL -o ${.TARGET} ${.IMPSRC} - -divsi3.o: $S/libkern/${M}/divsi3.S - ${CC} -c ${CFLAGS} -D_KERNEL -o ${.TARGET} ${.IMPSRC} - -muldi3.o: $S/libkern/${M}/muldi3.c - ${CC} -c ${CFLAGS} -D_KERNEL -o ${.TARGET} ${.IMPSRC} - -inflate.c: $S/kern/inflate.c - sed -e 's/extern void putstr (char/extern void putstr (const char/' < \ - $S/kern/inflate.c > ${.TARGET} - -CLEANFILES+=inflate.c - -.include - Property changes on: stable/11/sys/boot/arm/ixp425/boot2/Makefile ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/loader/loader.conf =================================================================== --- stable/11/sys/boot/arm/loader/loader.conf (nonexistent) +++ stable/11/sys/boot/arm/loader/loader.conf (revision 329140) @@ -0,0 +1,13 @@ +# This is defaults/loader.conf for ARM, containing defaults for loader(8). +# Do not modify the contents of this file, instead put your customizations +# into /boot/loader.conf or /boot/loader.conf.local +# $FreeBSD$ + +autoboot_delay=10 +bootfile="kernel" # Kernel name (possibly absolute path) +kernel="kernel" # /boot sub-directory containing kernel and modules +loader_conf_files="/boot/loader.conf /boot/loader.conf.local" +module_path="/boot/kernel;/boot/modules;/boot/dtb;/boot/overlays" +nextboot_conf="/boot/nextboot.conf" +nextboot_enable="NO" +verbose_loading="NO" Property changes on: stable/11/sys/boot/arm/loader/loader.conf ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/uboot/loader.conf =================================================================== --- stable/11/sys/boot/arm/uboot/loader.conf (revision 329139) +++ stable/11/sys/boot/arm/uboot/loader.conf (nonexistent) @@ -1,13 +0,0 @@ -# This is defaults/loader.conf for ARM, containing defaults for loader(8). -# Do not modify the contents of this file, instead put your customizations -# into /boot/loader.conf or /boot/loader.conf.local -# $FreeBSD$ - -autoboot_delay=10 -bootfile="kernel" # Kernel name (possibly absolute path) -kernel="kernel" # /boot sub-directory containing kernel and modules -loader_conf_files="/boot/loader.conf /boot/loader.conf.local" -module_path="/boot/kernel;/boot/modules;/boot/dtb;/boot/overlays" -nextboot_conf="/boot/nextboot.conf" -nextboot_enable="NO" -verbose_loading="NO" Property changes on: stable/11/sys/boot/arm/uboot/loader.conf ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/arm/uboot/Makefile =================================================================== --- stable/11/sys/boot/arm/uboot/Makefile (revision 329139) +++ stable/11/sys/boot/arm/uboot/Makefile (revision 329140) @@ -1,159 +1,70 @@ # $FreeBSD$ -.include +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= no +LOADER_MSDOS_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= no +LOADER_BZIP2_SUPPORT?= no -FILES= ubldr ubldr.bin +.include +FILES+= ubldr ubldr.bin + NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} -BINDIR?= /boot INSTALLFLAGS= -b WARNS?= 1 # Address at which ubldr will be loaded. # This varies for different boards and SOCs. UBLDR_LOADADDR?= 0x1000000 # Architecture-specific loader code SRCS= start.S conf.c self_reloc.c vers.c .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized .endif -.if !defined(LOADER_NO_DISK_SUPPORT) -LOADER_DISK_SUPPORT?= yes -.else -LOADER_DISK_SUPPORT= no -.endif -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= no -LOADER_EXT2FS_SUPPORT?= no -.if ${MK_NAND} != "no" -LOADER_NANDFS_SUPPORT?= yes -.else -LOADER_NANDFS_SUPPORT?= no -.endif -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= no -LOADER_BZIP2_SUPPORT?= no -.if ${MK_FDT} != "no" -LOADER_FDT_SUPPORT= yes -.else -LOADER_FDT_SUPPORT= no -.endif +HELP_FILES+= help.uboot ${BOOTSRC}/fdt/help.fdt -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_EXT2FS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_EXT2FS_SUPPORT -.endif -.if ${LOADER_NANDFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NANDFS_SUPPORT -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${LOADER_FDT_SUPPORT} == "yes" -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt/libuboot_fdt.a -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a -.endif - -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/arm -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a -.endif - # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -CFLAGS+= -I. +.include "${BOOTSRC}/loader.mk" -CLEANFILES+= loader.help - CFLAGS+= -ffreestanding -msoft-float LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH} LDFLAGS+= -Wl,-znotext # Pull in common loader code -.PATH: ${.CURDIR}/../../uboot/common -.include "${.CURDIR}/../../uboot/common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../uboot/common +.include "${BOOTSRC}/uboot.mk" -# U-Boot standalone support library -LIBUBOOT= ${.OBJDIR}/../../uboot/lib/libuboot.a -CFLAGS+= -I${.CURDIR}/../../uboot/lib -CFLAGS+= -I${.OBJDIR}/../../uboot/lib - CFLAGS+= -fPIC -# clang doesn't understand %D as a specifier to printf -NO_WERROR.clang= - DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} OBJS+= ${SRCS:N*.h:R:S/$/.o/g} -loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - ldscript.abs: echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >${.TARGET} ldscript.pie: echo "UBLDR_LOADADDR = 0;" >${.TARGET} ubldr: ${OBJS} ldscript.abs ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD} ${CC} ${CFLAGS} -T ldscript.abs ${LDFLAGS} \ -o ${.TARGET} ${OBJS} ${LDADD} ubldr.pie: ${OBJS} ldscript.pie ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD} ${CC} ${CFLAGS} -T ldscript.pie ${LDFLAGS} -pie -Wl,-Bsymbolic \ -o ${.TARGET} ${OBJS} ${LDADD} ubldr.bin: ubldr.pie ${OBJCOPY} -S -O binary ubldr.pie ${.TARGET} CLEANFILES+= ldscript.abs ldscript.pie ubldr ubldr.pie ubldr.bin - -.if !defined(LOADER_ONLY) -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -# Install loader.rc. -FILES+= loader.rc -# Put sample menu.rc on disk but don't enable it by default. -FILES+= menu.rc -FILESNAME_menu.rc= menu.rc.sample -.endif .include Index: stable/11/sys/boot/common/Makefile.inc =================================================================== --- stable/11/sys/boot/common/Makefile.inc (revision 329139) +++ stable/11/sys/boot/common/Makefile.inc (nonexistent) @@ -1,87 +0,0 @@ -# $FreeBSD$ - -.PATH: ${SRCTOP}/sys/boot/common ${SRCTOP}/sys/boot/libsa - -SRCS+= boot.c commands.c console.c devopen.c interp.c -SRCS+= interp_backslash.c interp_parse.c ls.c misc.c -SRCS+= module.c - -.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64" -SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c -SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c -.elif ${MACHINE} == "pc98" -SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c -.elif ${MACHINE_CPUARCH} == "aarch64" -SRCS+= load_elf64.c reloc_elf64.c -.elif ${MACHINE_CPUARCH} == "arm" -SRCS+= load_elf32.c reloc_elf32.c -.elif ${MACHINE_CPUARCH} == "powerpc" -SRCS+= load_elf32.c reloc_elf32.c -SRCS+= load_elf64.c reloc_elf64.c -.elif ${MACHINE_CPUARCH} == "sparc64" -SRCS+= load_elf64.c reloc_elf64.c -.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" -SRCS+= load_elf64.c reloc_elf64.c -.elif ${MACHINE} == "mips" -SRCS+= load_elf32.c reloc_elf32.c -.endif - -.if defined(LOADER_NET_SUPPORT) -SRCS+= dev_net.c -.endif - -.if !defined(LOADER_NO_DISK_SUPPORT) -SRCS+= disk.c part.c -CFLAGS+= -DLOADER_DISK_SUPPORT -.if !defined(LOADER_NO_GPT_SUPPORT) -CFLAGS+= -DLOADER_GPT_SUPPORT -.endif -.if !defined(LOADER_NO_MBR_SUPPORT) -CFLAGS+= -DLOADER_MBR_SUPPORT -.endif -.endif -.if !defined(LOADER_NO_GELI_SUPPORT) -CFLAGS+= -DLOADER_GELI_SUPPORT -.endif - -.if defined(HAVE_BCACHE) -SRCS+= bcache.c -.endif - -.if defined(MD_IMAGE_SIZE) -CFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE} -SRCS+= md.c -.else -CLEANFILES+= md.o -.endif - -# Machine-independant ISA PnP -.if defined(HAVE_ISABUS) -SRCS+= isapnp.c -.endif -.if defined(HAVE_PNP) -SRCS+= pnp.c -.endif - -# Forth interpreter -.if defined(BOOT_FORTH) -SRCS+= interp_forth.c -.include "../ficl.mk" -.endif - -.if defined(BOOT_PROMPT_123) -CFLAGS+= -DBOOT_PROMPT_123 -.endif - -.if defined(LOADER_INSTALL_SUPPORT) -SRCS+= install.c -.endif - -CLEANFILES+= vers.c -VERSION_FILE?= ${.CURDIR}/version -.if ${MK_REPRODUCIBLE_BUILD} != no -REPRO_FLAG= -r -.endif -vers.c: ${SRCTOP}/sys/boot/common/newvers.sh ${VERSION_FILE} - sh ${SRCTOP}/sys/boot/common/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \ - ${NEWVERSWHAT} Property changes on: stable/11/sys/boot/common/Makefile.inc ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/common/disk.c =================================================================== --- stable/11/sys/boot/common/disk.c (revision 329139) +++ stable/11/sys/boot/common/disk.c (revision 329140) @@ -1,426 +1,432 @@ /*- * Copyright (c) 1998 Michael Smith * Copyright (c) 2012 Andrey V. Elsukov * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include "disk.h" #ifdef DISK_DEBUG # define DEBUG(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) #else # define DEBUG(fmt, args...) #endif struct open_disk { struct ptable *table; uint64_t mediasize; uint64_t entrysize; u_int sectorsize; }; struct print_args { struct disk_devdesc *dev; const char *prefix; int verbose; }; /* Convert size to a human-readable number. */ static char * display_size(uint64_t size, u_int sectorsize) { static char buf[80]; char unit; size = size * sectorsize / 1024; unit = 'K'; if (size >= 10485760000LL) { size /= 1073741824; unit = 'T'; } else if (size >= 10240000) { size /= 1048576; unit = 'G'; } else if (size >= 10000) { size /= 1024; unit = 'M'; } sprintf(buf, "%ld%cB", (long)size, unit); return (buf); } int ptblread(void *d, void *buf, size_t blocks, uint64_t offset) { struct disk_devdesc *dev; struct open_disk *od; dev = (struct disk_devdesc *)d; od = (struct open_disk *)dev->d_opendata; /* + * The strategy function assumes the offset is in units of 512 byte + * sectors. For larger sector sizes, we need to adjust the offset to + * match the actual sector size. + */ + offset *= (od->sectorsize / 512); + /* * As the GPT backup partition is located at the end of the disk, * to avoid reading past disk end, flag bcache not to use RA. */ return (dev->d_dev->dv_strategy(dev, F_READ | F_NORA, offset, blocks * od->sectorsize, (char *)buf, NULL)); } #define PWIDTH 35 static int ptable_print(void *arg, const char *pname, const struct ptable_entry *part) { struct disk_devdesc dev; struct print_args *pa, bsd; struct open_disk *od; struct ptable *table; char line[80]; int res; pa = (struct print_args *)arg; od = (struct open_disk *)pa->dev->d_opendata; sprintf(line, " %s%s: %s", pa->prefix, pname, parttype2str(part->type)); if (pa->verbose) sprintf(line, "%-*s%s", PWIDTH, line, display_size(part->end - part->start + 1, od->sectorsize)); strcat(line, "\n"); if (pager_output(line)) return 1; res = 0; if (part->type == PART_FREEBSD) { /* Open slice with BSD label */ dev.d_dev = pa->dev->d_dev; dev.d_unit = pa->dev->d_unit; dev.d_slice = part->index; dev.d_partition = -1; if (disk_open(&dev, part->end - part->start + 1, od->sectorsize) == 0) { table = ptable_open(&dev, part->end - part->start + 1, od->sectorsize, ptblread); if (table != NULL) { sprintf(line, " %s%s", pa->prefix, pname); bsd.dev = pa->dev; bsd.prefix = line; bsd.verbose = pa->verbose; res = ptable_iterate(table, &bsd, ptable_print); ptable_close(table); } disk_close(&dev); } } return (res); } #undef PWIDTH int disk_print(struct disk_devdesc *dev, char *prefix, int verbose) { struct open_disk *od; struct print_args pa; /* Disk should be opened */ od = (struct open_disk *)dev->d_opendata; pa.dev = dev; pa.prefix = prefix; pa.verbose = verbose; return (ptable_iterate(od->table, &pa, ptable_print)); } int disk_read(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks) { struct open_disk *od; int ret; od = (struct open_disk *)dev->d_opendata; ret = dev->d_dev->dv_strategy(dev, F_READ, dev->d_offset + offset, blocks * od->sectorsize, buf, NULL); return (ret); } int disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks) { struct open_disk *od; int ret; od = (struct open_disk *)dev->d_opendata; ret = dev->d_dev->dv_strategy(dev, F_WRITE, dev->d_offset + offset, blocks * od->sectorsize, buf, NULL); return (ret); } int disk_ioctl(struct disk_devdesc *dev, u_long cmd, void *data) { struct open_disk *od = dev->d_opendata; if (od == NULL) return (ENOTTY); switch (cmd) { case DIOCGSECTORSIZE: *(u_int *)data = od->sectorsize; break; case DIOCGMEDIASIZE: if (dev->d_offset == 0) *(uint64_t *)data = od->mediasize; else *(uint64_t *)data = od->entrysize * od->sectorsize; break; default: return (ENOTTY); } return (0); } int disk_open(struct disk_devdesc *dev, uint64_t mediasize, u_int sectorsize) { struct open_disk *od; struct ptable *table; struct ptable_entry part; int rc, slice, partition; rc = 0; /* * While we are reading disk metadata, make sure we do it relative * to the start of the disk */ dev->d_offset = 0; table = NULL; slice = dev->d_slice; partition = dev->d_partition; od = (struct open_disk *)malloc(sizeof(struct open_disk)); if (od == NULL) { DEBUG("no memory"); return (ENOMEM); } dev->d_opendata = od; od->entrysize = 0; od->mediasize = mediasize; od->sectorsize = sectorsize; DEBUG("%s unit %d, slice %d, partition %d => %p", disk_fmtdev(dev), dev->d_unit, dev->d_slice, dev->d_partition, od); /* Determine disk layout. */ od->table = ptable_open(dev, mediasize / sectorsize, sectorsize, ptblread); if (od->table == NULL) { DEBUG("Can't read partition table"); rc = ENXIO; goto out; } if (ptable_getsize(od->table, &mediasize) != 0) { rc = ENXIO; goto out; } if (mediasize > od->mediasize) { od->mediasize = mediasize; } if (ptable_gettype(od->table) == PTABLE_BSD && partition >= 0) { /* It doesn't matter what value has d_slice */ rc = ptable_getpart(od->table, &part, partition); if (rc == 0) { dev->d_offset = part.start; od->entrysize = part.end - part.start + 1; } } else if (slice >= 0) { /* Try to get information about partition */ if (slice == 0) rc = ptable_getbestpart(od->table, &part); else rc = ptable_getpart(od->table, &part, slice); if (rc != 0) /* Partition doesn't exist */ goto out; dev->d_offset = part.start; od->entrysize = part.end - part.start + 1; slice = part.index; if (ptable_gettype(od->table) == PTABLE_GPT) { partition = 255; goto out; /* Nothing more to do */ } else if (partition == 255) { /* * When we try to open GPT partition, but partition * table isn't GPT, reset d_partition value to -1 * and try to autodetect appropriate value. */ partition = -1; } /* * If d_partition < 0 and we are looking at a BSD slice, * then try to read BSD label, otherwise return the * whole MBR slice. */ if (partition == -1 && part.type != PART_FREEBSD) goto out; /* Try to read BSD label */ table = ptable_open(dev, part.end - part.start + 1, od->sectorsize, ptblread); if (table == NULL) { DEBUG("Can't read BSD label"); rc = ENXIO; goto out; } /* * If slice contains BSD label and d_partition < 0, then * assume the 'a' partition. Otherwise just return the * whole MBR slice, because it can contain ZFS. */ if (partition < 0) { if (ptable_gettype(table) != PTABLE_BSD) goto out; partition = 0; } rc = ptable_getpart(table, &part, partition); if (rc != 0) goto out; dev->d_offset += part.start; od->entrysize = part.end - part.start + 1; } out: if (table != NULL) ptable_close(table); if (rc != 0) { if (od->table != NULL) ptable_close(od->table); free(od); DEBUG("%s could not open", disk_fmtdev(dev)); } else { /* Save the slice and partition number to the dev */ dev->d_slice = slice; dev->d_partition = partition; DEBUG("%s offset %lld => %p", disk_fmtdev(dev), (long long)dev->d_offset, od); } return (rc); } int disk_close(struct disk_devdesc *dev) { struct open_disk *od; od = (struct open_disk *)dev->d_opendata; DEBUG("%s closed => %p", disk_fmtdev(dev), od); ptable_close(od->table); free(od); return (0); } char* disk_fmtdev(struct disk_devdesc *dev) { static char buf[128]; char *cp; cp = buf + sprintf(buf, "%s%d", dev->d_dev->dv_name, dev->d_unit); if (dev->d_slice >= 0) { #ifdef LOADER_GPT_SUPPORT if (dev->d_partition == 255) { sprintf(cp, "p%d:", dev->d_slice); return (buf); } else #endif #ifdef LOADER_MBR_SUPPORT cp += sprintf(cp, "s%d", dev->d_slice); #endif } if (dev->d_partition >= 0) cp += sprintf(cp, "%c", dev->d_partition + 'a'); strcat(cp, ":"); return (buf); } int disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path) { int unit, slice, partition; const char *np; char *cp; np = devspec; unit = slice = partition = -1; if (*np != '\0' && *np != ':') { unit = strtol(np, &cp, 10); if (cp == np) return (EUNIT); #ifdef LOADER_GPT_SUPPORT if (*cp == 'p') { np = cp + 1; slice = strtol(np, &cp, 10); if (np == cp) return (ESLICE); /* we don't support nested partitions on GPT */ if (*cp != '\0' && *cp != ':') return (EINVAL); partition = 255; } else #endif #ifdef LOADER_MBR_SUPPORT if (*cp == 's') { np = cp + 1; slice = strtol(np, &cp, 10); if (np == cp) return (ESLICE); } #endif if (*cp != '\0' && *cp != ':') { partition = *cp - 'a'; if (partition < 0) return (EPART); cp++; } } else return (EINVAL); if (*cp != '\0' && *cp != ':') return (EINVAL); dev->d_unit = unit; dev->d_slice = slice; dev->d_partition = partition; if (path != NULL) *path = (*cp == '\0') ? cp: cp + 1; return (0); } Index: stable/11/sys/boot/common/md.c =================================================================== --- stable/11/sys/boot/common/md.c (revision 329139) +++ stable/11/sys/boot/common/md.c (revision 329140) @@ -1,156 +1,157 @@ /*- * Copyright (c) 2009 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include "bootstrap.h" #define MD_BLOCK_SIZE 512 #ifndef MD_IMAGE_SIZE #error Must be compiled with MD_IMAGE_SIZE defined #endif #if (MD_IMAGE_SIZE == 0 || MD_IMAGE_SIZE % MD_BLOCK_SIZE) #error Image size must be a multiple of 512. #endif /* * Preloaded image gets put here. * Applications that patch the object with the image can determine * the size looking at the start and end markers (strings), * so we want them contiguous. */ static struct { u_char start[MD_IMAGE_SIZE]; u_char end[128]; } md_image = { .start = "MFS Filesystem goes here", .end = "MFS Filesystem had better STOP here", }; /* devsw I/F */ static int md_init(void); static int md_strategy(void *, int, daddr_t, size_t, char *, size_t *); static int md_open(struct open_file *, ...); static int md_close(struct open_file *); static int md_print(int); struct devsw md_dev = { "md", DEVT_DISK, md_init, md_strategy, md_open, md_close, noioctl, - md_print + md_print, + NULL }; static int md_init(void) { return (0); } static int md_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize) { struct devdesc *dev = (struct devdesc *)devdata; size_t ofs; if (dev->d_unit != 0) return (ENXIO); if (blk < 0 || blk >= (MD_IMAGE_SIZE / MD_BLOCK_SIZE)) return (EIO); if (size % MD_BLOCK_SIZE) return (EIO); ofs = blk * MD_BLOCK_SIZE; if ((ofs + size) > MD_IMAGE_SIZE) size = MD_IMAGE_SIZE - ofs; if (rsize != NULL) *rsize = size; switch (rw & F_MASK) { case F_READ: bcopy(md_image.start + ofs, buf, size); return (0); case F_WRITE: bcopy(buf, md_image.start + ofs, size); return (0); } return (ENODEV); } static int md_open(struct open_file *f, ...) { va_list ap; struct devdesc *dev; va_start(ap, f); dev = va_arg(ap, struct devdesc *); va_end(ap); if (dev->d_unit != 0) return (ENXIO); return (0); } static int md_close(struct open_file *f) { struct devdesc *dev; dev = (struct devdesc *)(f->f_devdata); return ((dev->d_unit != 0) ? ENXIO : 0); } static int md_print(int verbose) { printf("%s devices:", md_dev.dv_name); if (pager_output("\n") != 0) return (1); printf("MD (%u bytes)", MD_IMAGE_SIZE); return (pager_output("\n")); } Index: stable/11/sys/boot/defs.mk =================================================================== --- stable/11/sys/boot/defs.mk (nonexistent) +++ stable/11/sys/boot/defs.mk (revision 329140) @@ -0,0 +1,171 @@ +# $FreeBSD$ + +.include + +.if !defined(__BOOT_DEFS_MK__) +__BOOT_DEFS_MK__=${MFILE} + +BOOTSRC= ${SRCTOP}/sys/boot +EFISRC= ${BOOTSRC}/efi +EFIINC= ${EFISRC}/include +EFIINCMD= ${EFIINC}/${MACHINE} +FDTSRC= ${BOOTSRC}/fdt +FICLSRC= ${BOOTSRC}/ficl +LDRSRC= ${BOOTSRC}/common +SASRC= ${BOOTSRC}/libsa +SYSDIR= ${SRCTOP}/sys +UBOOTSRC= ${BOOTSRC}/uboot +ZFSSRC= ${BOOTSRC}/zfs + +BOOTOBJ= ${OBJTOP}/sys/boot + +# BINDIR is where we install +BINDIR?= /boot + +# NB: The makefiles depend on these being empty when we don't build forth. +.if ${MK_FORTH} != "no" +LIBFICL= ${BOOTOBJ}/ficl/libficl.a +.if ${MACHINE} == "i386" +LIBFICL32= ${LIBFICL} +.else +LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a +.endif +.endif +LIBSA= ${BOOTOBJ}/libsa/libsa.a +.if ${MACHINE} == "i386" +LIBSA32= ${LIBSA} +.else +LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a +.endif + +# Standard options: + +# Filesystem support +.if ${LOADER_CD9660_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_CD9660_SUPPORT +.endif +.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_EXT2FS_SUPPORT +.endif +.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_MSDOS_SUPPORT +.endif +.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes" +CFLAGS+= -DLOADER_NANDFS_SUPPORT +.endif +.if ${LOADER_UFS_SUPPORT:Uyes} == "yes" +CFLAGS+= -DLOADER_UFS_SUPPORT +.endif + +# Compression +.if ${LOADER_GZIP_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_GZIP_SUPPORT +.endif +.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_BZIP2_SUPPORT +.endif + +# Network related things +.if ${LOADER_NET_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_NET_SUPPORT +.endif +.if ${LOADER_NFS_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_NFS_SUPPORT +.endif +.if ${LOADER_TFTP_SUPPORT:Uno} == "yes" +CFLAGS+= -DLOADER_TFTP_SUPPORT +.endif + +# Disk and partition support +.if ${LOADER_DISK_SUPPORT:Uyes} == "yes" +CFLAGS+= -DLOADER_DISK_SUPPORT +.if ${LOADER_GPT_SUPPORT:Uyes} == "yes" +CFLAGS+= -DLOADER_GPT_SUPPORT +.endif +.if ${LOADER_MBR_SUPPORT:Uyes} == "yes" +CFLAGS+= -DLOADER_MBR_SUPPORT +.endif + +# GELI Support, with backward compat hooks +.if defined(HAVE_GELI) +.if defined(LOADER_NO_GELI_SUPPORT) +MK_LOADER_GELI=no +.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI" +.endif +.if defined(LOADER_GELI_SUPPORT) +MK_LOADER_GELI=yes +.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI" +.endif +.if ${MK_LOADER_GELI} == "yes" +CFLAGS+= -DLOADER_GELI_SUPPORT +CFLAGS+= -I${BOOTSRC}/geli +LIBGELIBOOT= ${BOOTOBJ}/geli/libgeliboot.a +.endif +.endif +.endif + +CFLAGS+= -I${SYSDIR} + +# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc +# or powerpc64. +.if ${MACHINE_ARCH} == "powerpc64" +CFLAGS+= -m32 -mcpu=powerpc +.endif + +# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is +# build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here +# and activate it when DO32 is explicitly defined to be 1. +.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 +CFLAGS+= -m32 -mcpu=i386 +# LD_FLAGS is passed directly to ${LD}, not via ${CC}: +LD_FLAGS+= -m elf_i386_fbsd +AFLAGS+= --32 +.endif + +# Make sure we use the machine link we're about to create +CFLAGS+=-I. + +_ILINKS=machine +.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" +_ILINKS+=${MACHINE_CPUARCH} +.endif +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +_ILINKS+=x86 +.endif +CLEANFILES+=${_ILINKS} + +all: ${PROG} + +beforedepend: ${_ILINKS} +beforebuild: ${_ILINKS} + +# Ensure that the links exist without depending on it when it exists which +# causes all the modules to be rebuilt when the directory pointed to changes. +.for _link in ${_ILINKS} +.if !exists(${.OBJDIR}/${_link}) +${OBJS}: ${_link} +.endif +.endfor + +.NOPATH: ${_ILINKS} + +${_ILINKS}: + @case ${.TARGET} in \ + machine) \ + if [ ${DO32:U0} -eq 0 ]; then \ + path=${SYSDIR}/${MACHINE}/include ; \ + else \ + path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ + fi ;; \ + *) \ + path=${SYSDIR}/${.TARGET:T}/include ;; \ + esac ; \ + path=`(cd $$path && /bin/pwd)` ; \ + ${ECHO} ${.TARGET:T} "->" $$path ; \ + ln -fhs $$path ${.TARGET:T} + +# For loader implementations, we generate a loader.help file. This can be suppressed by +# setting HELP_FILES to nothing. +HELP_FILES= ${LDRSRC}/help.common + +.endif # __BOOT_DEFS_MK__ Property changes on: stable/11/sys/boot/defs.mk ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/Makefile =================================================================== --- stable/11/sys/boot/efi/Makefile (revision 329139) +++ stable/11/sys/boot/efi/Makefile (revision 329140) @@ -1,23 +1,23 @@ # $FreeBSD$ -.include +.include # In-tree GCC does not support __attribute__((ms_abi)), but gcc newer # than 4.5 supports it. .if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" .if ${MK_FDT} != "no" SUBDIR+= fdt .endif .endif .if ${MACHINE_CPUARCH} == "aarch64" || \ ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "arm" SUBDIR+= libefi loader boot1 .endif .endif # ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 .include Index: stable/11/sys/boot/efi/Makefile.inc =================================================================== --- stable/11/sys/boot/efi/Makefile.inc (revision 329139) +++ stable/11/sys/boot/efi/Makefile.inc (revision 329140) @@ -1,34 +1,32 @@ # $FreeBSD$ -BINDIR?= /boot - .if ${MACHINE_CPUARCH} == "i386" CFLAGS+= -march=i386 CFLAGS+= -mno-aes .endif # Options used when building app-specific efi components # See conf/kern.mk for the correct set of these CFLAGS+= -ffreestanding -Wformat ${CFLAGS_NO_SIMD} LDFLAGS+= -nostdlib .if ${MACHINE_CPUARCH} != "aarch64" CFLAGS+= -msoft-float .endif .if ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -fshort-wchar CFLAGS+= -mno-red-zone CFLAGS+= -mno-aes .endif .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -fshort-wchar CFLAGS+= -fPIC .endif .if ${MACHINE_CPUARCH} == "arm" CFLAGS+= -fPIC .endif .include "../Makefile.inc" Index: stable/11/sys/boot/efi/boot1/Makefile =================================================================== --- stable/11/sys/boot/efi/boot1/Makefile (revision 329139) +++ stable/11/sys/boot/efi/boot1/Makefile (revision 329140) @@ -1,171 +1,129 @@ # $FreeBSD$ MAN= -.include "../Makefile.inc" +.include MK_SSP= no +MK_FORTH= no PROG= boot1.sym INTERNALPROG= -WARNS?= 3 +WARNS?= 6 -# Include bcache code. -HAVE_BCACHE= yes - # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead # of a short. There's no good cast to use here so just ignore the # warnings for now. CWARNFLAGS.boot1.c+= -Wno-format # Disable warnings that are currently incompatible with the zfs boot code -CWARNFLAGS.zfs.c += -Wno-incompatible-pointer-types-discards-qualifiers -CWARNFLAGS.zfs.c += -Wno-missing-variable-declarations -CWARNFLAGS.zfs.c += -Wno-array-bounds -CWARNFLAGS.zfs.c += -Wno-cast-align -CWARNFLAGS.zfs.c += -Wno-cast-qual -CWARNFLAGS.zfs.c += -Wno-missing-prototypes -CWARNFLAGS.zfs.c += -Wno-sign-compare -CWARNFLAGS.zfs.c += -Wno-unused-parameter -CWARNFLAGS.zfs.c += -Wno-unused-function -CWARNFLAGS.skein.c += -Wno-cast-align -.if ${COMPILER_TYPE} == "clang" -CWARNFLAGS.skein.c += -Wno-missing-variable-declarations -.else if ${COMPILER_TYPE} == "gcc" -CWARNFLAGS.skein.c += -Wno-missing-declarations -.endif +CWARNFLAGS.zfs_module.c += -Wno-array-bounds +CWARNFLAGS.zfs_module.c += -Wno-cast-align +CWARNFLAGS.zfs_module.c += -Wno-cast-qual +CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes +CWARNFLAGS.zfs_module.c += -Wno-sign-compare +CWARNFLAGS.zfs_module.c += -Wno-unused-parameter +CWARNFLAGS.zfs_module.c += -Wno-unused-function # architecture-specific loader code -SRCS= boot1.c self_reloc.c start.S +SRCS= boot1.c self_reloc.c start.S ufs_module.c .if ${MK_ZFS} != "no" -.PATH: ${.CURDIR}/../../../crypto/skein -SRCS+= skein.c skein_block.c -# Do not unroll skein loops, reduce code size -CFLAGS+= -DSKEIN_LOOP=111 -.PATH: ${.CURDIR}/../../zfs -SRCS+= zfs.c +SRCS+= zfs_module.c +CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SYSDIR}/cddl/boot/zfs +CFLAGS+= -DEFI_ZFS_BOOT +LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a .endif .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized .endif -# Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common - -.PATH: ${.CURDIR}/arch/${MACHINE} - -CFLAGS+= -I. -CFLAGS+= -I${.CURDIR}/../include -CFLAGS+= -I${.CURDIR}/../include/${MACHINE} -CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include -CFLAGS+= -I${.CURDIR}/../../.. +CFLAGS+= -I${EFIINC} +CFLAGS+= -I${EFIINCMD} +CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include CFLAGS+= -DEFI_UFS_BOOT .ifdef(EFI_DEBUG) CFLAGS+= -DEFI_DEBUG .endif -.if ${MK_ZFS} != "no" -CFLAGS+= -I${.CURDIR}/../../zfs/ -CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/ -CFLAGS+= -I${.CURDIR}/../../../crypto/skein -CFLAGS+= -DEFI_ZFS_BOOT -.endif - # Always add MI sources and REGULAR efi loader bits -.PATH: ${.CURDIR}/../loader/arch/${MACHINE} -.PATH: ${.CURDIR}/../loader -.PATH: ${.CURDIR}/../../common -CFLAGS+= -I${.CURDIR}/../../common +.PATH: ${EFISRC}/loader/arch/${MACHINE} +.PATH: ${EFISRC}/loader +.PATH: ${LDRSRC} +CFLAGS+= -I${LDRSRC} FILES= boot1.efi boot1.efifat FILESMODE_boot1.efi= ${BINMODE} -LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} +LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE} LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only .endif .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" CFLAGS+= -fPIC LDFLAGS+= -Wl,-znocombreloc .endif -LIBEFI= ${.OBJDIR}/../libefi/libefi.a +LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a # # Add libstand for the runtime functions used by the compiler - for example # __aeabi_* (arm) or __divdi3 (i386). # as well as required string and memory functions for all platforms. # -DPADD+= ${LIBEFI} ${LIBSA} -LDADD+= ${LIBEFI} ${LIBSA} +DPADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA} +LDADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA} DPADD+= ${LDSCRIPT} NM?= nm OBJCOPY?= objcopy .if ${MACHINE_CPUARCH} == "amd64" EFI_TARGET= efi-app-x86_64 .elif ${MACHINE_CPUARCH} == "i386" EFI_TARGET= efi-app-ia32 .else EFI_TARGET= binary .endif # Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00 # for build reproducibility. SOURCE_DATE_EPOCH?=1451606400 boot1.efi: ${PROG} if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ fi SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ - -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ + -j .rela.dyn -j .reloc -j .eh_frame \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} boot1.o: ${SASRC}/ufsread.c # The following inserts our objects into a template FAT file system # created by generate-fat.sh .include "${.CURDIR}/Makefile.fat" boot1.efifat: boot1.efi @set -- `ls -l ${.ALLSRC}`; \ x=$$(($$5-${BOOT1_MAXSIZE})); \ if [ $$x -ge 0 ]; then \ echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ exit 1; \ fi echo ${.OBJDIR} xz -d -c ${.CURDIR}/fat-${MACHINE}.tmpl.xz > ${.TARGET} ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc -CLEANFILES= boot1.efi boot1.efifat +CLEANFILES+= boot1.efi boot1.efifat .include - -beforedepend ${OBJS}: machine - -CLEANFILES+= machine - -machine: .NOMETA - ln -sf ${.CURDIR}/../../../${MACHINE}/include machine - -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" -beforedepend ${OBJS}: x86 -CLEANFILES+= x86 - -x86: .NOMETA - ln -sf ${.CURDIR}/../../../x86/include x86 -.endif Index: stable/11/sys/boot/efi/boot1/boot1.c =================================================================== --- stable/11/sys/boot/efi/boot1/boot1.c (revision 329139) +++ stable/11/sys/boot/efi/boot1/boot1.c (revision 329140) @@ -1,737 +1,583 @@ /*- * Copyright (c) 1998 Robert Nordier * All rights reserved. * Copyright (c) 2001 Robert Drehmel * All rights reserved. * Copyright (c) 2014 Nathan Whitehorn * All rights reserved. * Copyright (c) 2015 Eric McCorkle * All rights reserved. * * Redistribution and use in source and binary forms are freely * permitted provided that the above copyright notice and this * paragraph and the following disclaimer are duplicated in all * such forms. * * This software is provided "AS IS" and without any express or * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. */ #include __FBSDID("$FreeBSD$"); #include -#include #include #include #include -#include #include -#include -#include #include -#ifdef EFI_ZFS_BOOT -#include -#endif typedef CHAR16 efi_char; #include -#include - -#include "efi_drivers.h" -#include "efizfs.h" +#include "boot_module.h" #include "paths.h" static void efi_panic(EFI_STATUS s, const char *fmt, ...) __dead2 __printflike(2, 3); -#ifdef EFI_DEBUG -#define DPRINTF(fmt, args...) printf(fmt, ##args) -#define DSTALL(d) BS->Stall(d) -#else -#define DPRINTF(fmt, ...) {} -#define DSTALL(d) {} -#endif -struct arch_switch archsw; /* MI/MD interface boundary */ - -static const efi_driver_t *efi_drivers[] = { - NULL -}; - -extern struct console efi_console; -#if defined(__amd64__) || defined(__i386__) -extern struct console comconsole; -extern struct console nullconsole; -#endif - +static const boot_module_t *boot_modules[] = +{ #ifdef EFI_ZFS_BOOT -uint64_t pool_guid; + &zfs_module, #endif - -struct fs_ops *file_system[] = { -#ifdef EFI_ZFS_BOOT - &zfs_fsops, -#endif - &dosfs_fsops, #ifdef EFI_UFS_BOOT - &ufs_fsops, + &ufs_module #endif - &cd9660_fsops, - &nfs_fsops, - &gzipfs_fsops, - &bzipfs_fsops, - NULL }; -struct devsw *devsw[] = { - &efipart_hddev, - &efipart_fddev, - &efipart_cddev, -#ifdef EFI_ZFS_BOOT - &zfs_dev, -#endif - NULL -}; - -struct console *consoles[] = { - &efi_console, - NULL -}; - -static EFI_LOADED_IMAGE *boot_image; -static EFI_DEVICE_PATH *imgpath; -static EFI_DEVICE_PATH *imgprefix; - -/* Definitions we don't actually need for boot, but we need to define - * to make the linker happy. - */ -struct file_format *file_formats[] = { NULL }; - -struct netif_driver *netif_drivers[] = { NULL }; - -static int -efi_autoload(void) -{ - printf("******** Boot block should not call autoload\n"); - return (-1); -} - -static ssize_t -efi_copyin(const void *src __unused, vm_offset_t dest __unused, - const size_t len __unused) -{ - printf("******** Boot block should not call copyin\n"); - return (-1); -} - -static ssize_t -efi_copyout(vm_offset_t src __unused, void *dest __unused, - const size_t len __unused) -{ - printf("******** Boot block should not call copyout\n"); - return (-1); -} - -static ssize_t -efi_readin(int fd __unused, vm_offset_t dest __unused, - const size_t len __unused) -{ - printf("******** Boot block should not call readin\n"); - return (-1); -} - +#define NUM_BOOT_MODULES nitems(boot_modules) /* The initial number of handles used to query EFI for partitions. */ #define NUM_HANDLES_INIT 24 +static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; +static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID; static EFI_GUID FreeBSDBootVarGUID = FREEBSD_BOOT_VAR_GUID; -static EFI_STATUS -do_load(const char *filepath, void **bufp, size_t *bufsize) +/* + * Provide Malloc / Free backed by EFIs AllocatePool / FreePool which ensures + * memory is correctly aligned avoiding EFI_INVALID_PARAMETER returns from + * EFI methods. + */ +void * +Malloc(size_t len, const char *file __unused, int line __unused) { - struct stat st; - void *buf = NULL; - int fd, err; - size_t fsize, remaining; - ssize_t readsize; + void *out; - if ((fd = open(filepath, O_RDONLY)) < 0) { - return (ENOTSUP); - } + if (BS->AllocatePool(EfiLoaderData, len, &out) == EFI_SUCCESS) + return (out); - if ((err = fstat(fd, &st)) != 0) { - goto close_file; - } + return (NULL); +} - fsize = st.st_size; - - if ((buf = malloc(fsize)) == NULL) { - err = ENOMEM; - goto close_file; - } - - remaining = fsize; - - do { - if ((readsize = read(fd, buf, fsize)) < 0) { - err = (-readsize); - goto free_buf; - } - - remaining -= readsize; - } while(remaining != 0); - - close(fd); - *bufsize = st.st_size; - *bufp = buf; - - close_file: - close(fd); - - return errno_to_efi_status(err); - - free_buf: - free(buf); - goto close_file; +void +Free(void *buf, const char *file __unused, int line __unused) +{ + if (buf != NULL) + (void)BS->FreePool(buf); } static EFI_STATUS efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr) { CHAR16 *var = NULL; size_t len; EFI_STATUS rv; utf8_to_ucs2(varname, &var, &len); if (var == NULL) return (EFI_OUT_OF_RESOURCES); rv = RS->SetVariable(var, &FreeBSDBootVarGUID, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, (ucs2len(valstr) + 1) * sizeof(efi_char), valstr); free(var); return (rv); } -static int -probe_fs(const char *filepath) +/* + * nodes_match returns TRUE if the imgpath isn't NULL and the nodes match, + * FALSE otherwise. + */ +static BOOLEAN +nodes_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) { - int fd; + size_t len; - if ((fd = open(filepath, O_RDONLY)) < 0) { - return (ENOTSUP); - } + if (imgpath == NULL || imgpath->Type != devpath->Type || + imgpath->SubType != devpath->SubType) + return (FALSE); - close(fd); + len = DevicePathNodeLength(imgpath); + if (len != DevicePathNodeLength(devpath)) + return (FALSE); - return (0); + return (memcmp(imgpath, devpath, (size_t)len) == 0); } -static int -probe_dev(struct devsw *dev, int unit, const char *filepath) +/* + * device_paths_match returns TRUE if the imgpath isn't NULL and all nodes + * in imgpath and devpath match up to their respective occurrences of a + * media node, FALSE otherwise. + */ +static BOOLEAN +device_paths_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) { - struct devdesc currdev; - char *devname; - int err; - currdev.d_dev = dev; - currdev.d_type = currdev.d_dev->dv_type; - currdev.d_unit = unit; - currdev.d_opendata = NULL; - devname = efi_fmtdev(&currdev); + if (imgpath == NULL) + return (FALSE); - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, - env_nounset); + while (!IsDevicePathEnd(imgpath) && !IsDevicePathEnd(devpath)) { + if (IsDevicePathType(imgpath, MEDIA_DEVICE_PATH) && + IsDevicePathType(devpath, MEDIA_DEVICE_PATH)) + return (TRUE); - err = probe_fs(filepath); + if (!nodes_match(imgpath, devpath)) + return (FALSE); - return (err); -} + imgpath = NextDevicePathNode(imgpath); + devpath = NextDevicePathNode(devpath); + } -static bool -check_preferred(EFI_HANDLE *h) -{ - EFI_DEVICE_PATH *path = efi_lookup_devpath(h); - bool out; - - if ((path = efi_lookup_devpath(h)) == NULL) - return (false); - - out = efi_devpath_is_prefix(imgpath, path) || - efi_devpath_is_prefix(imgprefix, path); - - return (out); + return (FALSE); } -bool -efi_zfs_is_preferred(EFI_HANDLE *h) +/* + * devpath_last returns the last non-path end node in devpath. + */ +static EFI_DEVICE_PATH * +devpath_last(EFI_DEVICE_PATH *devpath) { - return (check_preferred(h)); -} -static int -load_preferred(EFI_LOADED_IMAGE *img, const char *filepath, void **bufp, - size_t *bufsize, EFI_HANDLE *handlep) -{ - pdinfo_list_t *pdi_list; - pdinfo_t *dp, *pp; - char *devname; + while (!IsDevicePathEnd(NextDevicePathNode(devpath))) + devpath = NextDevicePathNode(devpath); -#ifdef EFI_ZFS_BOOT - /* Did efi_zfs_probe() detect the boot pool? */ - if (pool_guid != 0) { - struct zfs_devdesc currdev; - - currdev.d_dev = &zfs_dev; - currdev.d_unit = 0; - currdev.d_type = currdev.d_dev->dv_type; - currdev.d_opendata = NULL; - currdev.pool_guid = pool_guid; - currdev.root_guid = 0; - devname = efi_fmtdev(&currdev); - - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, - env_nounset); - - if (probe_fs(filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = efizfs_get_handle_by_guid(pool_guid); - return (0); - } - } -#endif /* EFI_ZFS_BOOT */ - - /* We have device lists for hd, cd, fd, walk them all. */ - pdi_list = efiblk_get_pdinfo_list(&efipart_hddev); - STAILQ_FOREACH(dp, pdi_list, pd_link) { - struct disk_devdesc currdev; - - currdev.d_dev = &efipart_hddev; - currdev.d_type = currdev.d_dev->dv_type; - currdev.d_unit = dp->pd_unit; - currdev.d_opendata = NULL; - currdev.d_slice = -1; - currdev.d_partition = -1; - devname = efi_fmtdev(&currdev); - - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, - env_nounset); - - if (check_preferred(dp->pd_handle) && - probe_fs(filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = dp->pd_handle; - return (0); - } - - /* Assuming GPT partitioning. */ - STAILQ_FOREACH(pp, &dp->pd_part, pd_link) { - if (check_preferred(pp->pd_handle)) { - currdev.d_slice = pp->pd_unit; - currdev.d_partition = 255; - devname = efi_fmtdev(&currdev); - - env_setenv("currdev", EV_VOLATILE, devname, - efi_setcurrdev, env_nounset); - - if (probe_fs(filepath) == 0 && - do_load(filepath, bufp, bufsize) == - EFI_SUCCESS) { - *handlep = pp->pd_handle; - return (0); - } - } - } - } - - pdi_list = efiblk_get_pdinfo_list(&efipart_cddev); - STAILQ_FOREACH(dp, pdi_list, pd_link) { - if ((dp->pd_handle == img->DeviceHandle || - dp->pd_alias == img->DeviceHandle || - check_preferred(dp->pd_handle)) && - probe_dev(&efipart_cddev, dp->pd_unit, filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = dp->pd_handle; - return (0); - } - } - - pdi_list = efiblk_get_pdinfo_list(&efipart_fddev); - STAILQ_FOREACH(dp, pdi_list, pd_link) { - if ((dp->pd_handle == img->DeviceHandle || - check_preferred(dp->pd_handle)) && - probe_dev(&efipart_cddev, dp->pd_unit, filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = dp->pd_handle; - return (0); - } - } - - return (ENOENT); + return (devpath); } -static int -load_all(const char *filepath, void **bufp, size_t *bufsize, - EFI_HANDLE *handlep) +/* + * load_loader attempts to load the loader image data. + * + * It tries each module and its respective devices, identified by mod->probe, + * in order until a successful load occurs at which point it returns EFI_SUCCESS + * and EFI_NOT_FOUND otherwise. + * + * Only devices which have preferred matching the preferred parameter are tried. + */ +static EFI_STATUS +load_loader(const boot_module_t **modp, dev_info_t **devinfop, void **bufp, + size_t *bufsize, BOOLEAN preferred) { - pdinfo_list_t *pdi_list; - pdinfo_t *dp, *pp; - zfsinfo_list_t *zfsi_list; - zfsinfo_t *zi; - char *devname; + UINTN i; + dev_info_t *dev; + const boot_module_t *mod; -#ifdef EFI_ZFS_BOOT - zfsi_list = efizfs_get_zfsinfo_list(); - STAILQ_FOREACH(zi, zfsi_list, zi_link) { - struct zfs_devdesc currdev; + for (i = 0; i < NUM_BOOT_MODULES; i++) { + mod = boot_modules[i]; + for (dev = mod->devices(); dev != NULL; dev = dev->next) { + if (dev->preferred != preferred) + continue; - currdev.d_dev = &zfs_dev; - currdev.d_unit = 0; - currdev.d_type = currdev.d_dev->dv_type; - currdev.d_opendata = NULL; - currdev.pool_guid = zi->zi_pool_guid; - currdev.root_guid = 0; - devname = efi_fmtdev(&currdev); - - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, - env_nounset); - - if (probe_fs(filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = zi->zi_handle; - - return (0); - } - } -#endif /* EFI_ZFS_BOOT */ - - /* We have device lists for hd, cd, fd, walk them all. */ - pdi_list = efiblk_get_pdinfo_list(&efipart_hddev); - STAILQ_FOREACH(dp, pdi_list, pd_link) { - struct disk_devdesc currdev; - - currdev.d_dev = &efipart_hddev; - currdev.d_type = currdev.d_dev->dv_type; - currdev.d_unit = dp->pd_unit; - currdev.d_opendata = NULL; - currdev.d_slice = -1; - currdev.d_partition = -1; - devname = efi_fmtdev(&currdev); - - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, - env_nounset); - - if (probe_fs(filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = dp->pd_handle; - - return (0); - } - - /* Assuming GPT partitioning. */ - STAILQ_FOREACH(pp, &dp->pd_part, pd_link) { - currdev.d_slice = pp->pd_unit; - currdev.d_partition = 255; - devname = efi_fmtdev(&currdev); - - env_setenv("currdev", EV_VOLATILE, devname, - efi_setcurrdev, env_nounset); - - if (probe_fs(filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = pp->pd_handle; - - return (0); + if (mod->load(PATH_LOADER_EFI, dev, bufp, bufsize) == + EFI_SUCCESS) { + *devinfop = dev; + *modp = mod; + return (EFI_SUCCESS); } } } - pdi_list = efiblk_get_pdinfo_list(&efipart_cddev); - STAILQ_FOREACH(dp, pdi_list, pd_link) { - if (probe_dev(&efipart_cddev, dp->pd_unit, filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = dp->pd_handle; - - return (0); - } - } - - pdi_list = efiblk_get_pdinfo_list(&efipart_fddev); - STAILQ_FOREACH(dp, pdi_list, pd_link) { - if (probe_dev(&efipart_fddev, dp->pd_unit, filepath) == 0 && - do_load(filepath, bufp, bufsize) == EFI_SUCCESS) { - *handlep = dp->pd_handle; - - return (0); - } - } - - return (ENOENT); -} - -static EFI_STATUS -load_loader(EFI_HANDLE *handlep, void **bufp, size_t *bufsize) -{ - /* Try the preferred handles first, then all the handles */ - if (load_preferred(boot_image, PATH_LOADER_EFI, bufp, bufsize, - handlep) == 0) { - return (0); - } - - if (load_all(PATH_LOADER_EFI, bufp, bufsize, handlep) == 0) { - return (0); - } - return (EFI_NOT_FOUND); } /* * try_boot only returns if it fails to load the loader. If it succeeds * it simply boots, otherwise it returns the status of last EFI call. */ static EFI_STATUS try_boot(void) { size_t bufsize, loadersize, cmdsize; void *buf, *loaderbuf; char *cmd; - EFI_HANDLE fshandle; + dev_info_t *dev; + const boot_module_t *mod; EFI_HANDLE loaderhandle; EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; - EFI_DEVICE_PATH *fspath; - status = load_loader(&fshandle, &loaderbuf, &loadersize); - - if (status != EFI_SUCCESS) { - return (status); - } - - fspath = NULL; - if (status == EFI_SUCCESS) { - status = BS->OpenProtocol(fshandle, &DevicePathGUID, - (void **)&fspath, IH, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + status = load_loader(&mod, &dev, &loaderbuf, &loadersize, TRUE); + if (status != EFI_SUCCESS) { + status = load_loader(&mod, &dev, &loaderbuf, &loadersize, + FALSE); if (status != EFI_SUCCESS) { - DPRINTF("Failed to get image DevicePath (%lu)\n", - EFI_ERROR_CODE(status)); - } - DPRINTF("filesystem device path: %s\n", devpath_str(fspath)); + printf("Failed to load '%s'\n", PATH_LOADER_EFI); + return (status); + } } /* * Read in and parse the command line from /boot.config or /boot/config, * if present. We'll pass it the next stage via a simple ASCII * string. loader.efi has a hack for ASCII strings, so we'll use that to * keep the size down here. We only try to read the alternate file if * we get EFI_NOT_FOUND because all other errors mean that the boot_module * had troubles with the filesystem. We could return early, but we'll let * loading the actual kernel sort all that out. Since these files are * optional, we don't report errors in trying to read them. */ cmd = NULL; cmdsize = 0; - status = do_load(PATH_DOTCONFIG, &buf, &bufsize); + status = mod->load(PATH_DOTCONFIG, dev, &buf, &bufsize); if (status == EFI_NOT_FOUND) - status = do_load(PATH_CONFIG, &buf, &bufsize); + status = mod->load(PATH_CONFIG, dev, &buf, &bufsize); if (status == EFI_SUCCESS) { cmdsize = bufsize + 1; cmd = malloc(cmdsize); if (cmd == NULL) goto errout; memcpy(cmd, buf, bufsize); cmd[bufsize] = '\0'; free(buf); buf = NULL; } - if ((status = BS->LoadImage(TRUE, IH, efi_devpath_last_node(fspath), + if ((status = BS->LoadImage(TRUE, IH, devpath_last(dev->devpath), loaderbuf, loadersize, &loaderhandle)) != EFI_SUCCESS) { - printf("Failed to load image, size: %zu, (%lu)\n", - loadersize, EFI_ERROR_CODE(status)); + printf("Failed to load image provided by %s, size: %zu, (%lu)\n", + mod->name, loadersize, EFI_ERROR_CODE(status)); goto errout; } - if ((status = BS->OpenProtocol(loaderhandle, &LoadedImageGUID, - (VOID**)&loaded_image, IH, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)) != EFI_SUCCESS) { - printf("Failed to query LoadedImage (%lu)\n", - EFI_ERROR_CODE(status)); + if ((status = BS->HandleProtocol(loaderhandle, &LoadedImageGUID, + (VOID**)&loaded_image)) != EFI_SUCCESS) { + printf("Failed to query LoadedImage provided by %s (%lu)\n", + mod->name, EFI_ERROR_CODE(status)); goto errout; } if (cmd != NULL) printf(" command args: %s\n", cmd); - loaded_image->DeviceHandle = fshandle; + loaded_image->DeviceHandle = dev->devhandle; loaded_image->LoadOptionsSize = cmdsize; loaded_image->LoadOptions = cmd; DPRINTF("Starting '%s' in 5 seconds...", PATH_LOADER_EFI); DSTALL(1000000); DPRINTF("."); DSTALL(1000000); DPRINTF("."); DSTALL(1000000); DPRINTF("."); DSTALL(1000000); DPRINTF("."); DSTALL(1000000); DPRINTF(".\n"); if ((status = BS->StartImage(loaderhandle, NULL, NULL)) != EFI_SUCCESS) { - printf("Failed to start image (%lu)\n", - EFI_ERROR_CODE(status)); + printf("Failed to start image provided by %s (%lu)\n", + mod->name, EFI_ERROR_CODE(status)); loaded_image->LoadOptionsSize = 0; loaded_image->LoadOptions = NULL; } errout: if (cmd != NULL) free(cmd); if (buf != NULL) free(buf); if (loaderbuf != NULL) free(loaderbuf); return (status); } -EFI_STATUS -main(int argc __unused, CHAR16 *argv[] __unused) +/* + * probe_handle determines if the passed handle represents a logical partition + * if it does it uses each module in order to probe it and if successful it + * returns EFI_SUCCESS. + */ +static EFI_STATUS +probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, BOOLEAN *preferred) { - EFI_STATUS status; + dev_info_t *devinfo; + EFI_BLOCK_IO *blkio; + EFI_DEVICE_PATH *devpath; + EFI_STATUS status; + UINTN i; - SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL; - UINTN i, max_dim, best_mode, cols, rows; - CHAR16 *text; + /* Figure out if we're dealing with an actual partition. */ + status = BS->HandleProtocol(h, &DevicePathGUID, (void **)&devpath); + if (status == EFI_UNSUPPORTED) + return (status); - archsw.arch_autoload = efi_autoload; - archsw.arch_getdev = efi_getdev; - archsw.arch_copyin = efi_copyin; - archsw.arch_copyout = efi_copyout; - archsw.arch_readin = efi_readin; -#ifdef EFI_ZFS_BOOT - /* Note this needs to be set before ZFS init. */ - archsw.arch_zfs_probe = efi_zfs_probe; + if (status != EFI_SUCCESS) { + DPRINTF("\nFailed to query DevicePath (%lu)\n", + EFI_ERROR_CODE(status)); + return (status); + } +#ifdef EFI_DEBUG + { + CHAR16 *text = efi_devpath_name(devpath); + DPRINTF("probing: %S\n", text); + efi_free_devpath_name(text); + } #endif + status = BS->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio); + if (status == EFI_UNSUPPORTED) + return (status); - /* Init the time source */ - efi_time_init(); - cons_probe(); + if (status != EFI_SUCCESS) { + DPRINTF("\nFailed to query BlockIoProtocol (%lu)\n", + EFI_ERROR_CODE(status)); + return (status); + } + if (!blkio->Media->LogicalPartition) + return (EFI_UNSUPPORTED); + + *preferred = device_paths_match(imgpath, devpath); + + /* Run through each module, see if it can load this partition */ + for (i = 0; i < NUM_BOOT_MODULES; i++) { + devinfo = malloc(sizeof(*devinfo)); + if (devinfo == NULL) { + DPRINTF("\nFailed to allocate devinfo\n"); + continue; + } + devinfo->dev = blkio; + devinfo->devpath = devpath; + devinfo->devhandle = h; + devinfo->devdata = NULL; + devinfo->preferred = *preferred; + devinfo->next = NULL; + + status = boot_modules[i]->probe(devinfo); + if (status == EFI_SUCCESS) + return (EFI_SUCCESS); + free(devinfo); + } + + return (EFI_UNSUPPORTED); +} + +/* + * probe_handle_status calls probe_handle and outputs the returned status + * of the call. + */ +static void +probe_handle_status(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath) +{ + EFI_STATUS status; + BOOLEAN preferred; + + preferred = FALSE; + status = probe_handle(h, imgpath, &preferred); + + DPRINTF("probe: "); + switch (status) { + case EFI_UNSUPPORTED: + printf("."); + DPRINTF(" not supported\n"); + break; + case EFI_SUCCESS: + if (preferred) { + printf("%c", '*'); + DPRINTF(" supported (preferred)\n"); + } else { + printf("%c", '+'); + DPRINTF(" supported\n"); + } + break; + default: + printf("x"); + DPRINTF(" error (%lu)\n", EFI_ERROR_CODE(status)); + break; + } + DSTALL(500000); +} + +EFI_STATUS +efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) +{ + EFI_HANDLE *handles; + EFI_LOADED_IMAGE *img; + EFI_DEVICE_PATH *imgpath; + EFI_STATUS status; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; + SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL; + UINTN i, max_dim, best_mode, cols, rows, hsize, nhandles; + CHAR16 *text; + + /* Basic initialization*/ + ST = Xsystab; + IH = Ximage; + BS = ST->BootServices; + RS = ST->RuntimeServices; + + /* Set up the console, so printf works. */ + status = BS->LocateProtocol(&ConsoleControlGUID, NULL, + (VOID **)&ConsoleControl); + if (status == EFI_SUCCESS) + (void)ConsoleControl->SetMode(ConsoleControl, + EfiConsoleControlScreenText); /* * Reset the console and find the best text mode. */ conout = ST->ConOut; conout->Reset(conout, TRUE); max_dim = best_mode = 0; - - for (i = 0; ; i++) { + for (i = 0; ; i++) { status = conout->QueryMode(conout, i, &cols, &rows); if (EFI_ERROR(status)) break; if (cols * rows > max_dim) { max_dim = cols * rows; best_mode = i; } } - - if (max_dim > 0) + if (max_dim > 0) conout->SetMode(conout, best_mode); - conout->EnableCursor(conout, TRUE); conout->ClearScreen(conout); - /* Print this here, so people know it's at least starting. */ printf("\n>> FreeBSD EFI boot block\n"); printf(" Loader path: %s\n\n", PATH_LOADER_EFI); - - /* Get the image path and trim it to get the disk on which we - * found this loader. - */ - if ((status = BS->OpenProtocol(IH, &LoadedImageGUID, - (VOID**)&boot_image, IH, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)) != EFI_SUCCESS) { - panic("Failed to query LoadedImage (%lu)\n", - EFI_ERROR_CODE(status)); + printf(" Initializing modules:"); + for (i = 0; i < NUM_BOOT_MODULES; i++) { + printf(" %s", boot_modules[i]->name); + if (boot_modules[i]->init != NULL) + boot_modules[i]->init(); } + putchar('\n'); /* Determine the devpath of our image so we can prefer it. */ - status = BS->HandleProtocol(IH, &LoadedImageGUID, (VOID**)&boot_image); + status = BS->HandleProtocol(IH, &LoadedImageGUID, (VOID**)&img); imgpath = NULL; if (status == EFI_SUCCESS) { - text = efi_devpath_name(boot_image->FilePath); - printf(" Load Path: %S\n", text); - efi_setenv_freebsd_wcs("Boot1Path", text); - efi_free_devpath_name(text); + text = efi_devpath_name(img->FilePath); + if (text != NULL) { + printf(" Load Path: %S\n", text); + efi_setenv_freebsd_wcs("Boot1Path", text); + efi_free_devpath_name(text); + } - status = BS->HandleProtocol(boot_image->DeviceHandle, &DevicePathGUID, + status = BS->HandleProtocol(img->DeviceHandle, &DevicePathGUID, (void **)&imgpath); if (status != EFI_SUCCESS) { DPRINTF("Failed to get image DevicePath (%lu)\n", EFI_ERROR_CODE(status)); } else { text = efi_devpath_name(imgpath); - printf(" Load Device: %S\n", text); - efi_setenv_freebsd_wcs("Boot1Dev", text); - efi_free_devpath_name(text); + if (text != NULL) { + printf(" Load Device: %S\n", text); + efi_setenv_freebsd_wcs("Boot1Dev", text); + efi_free_devpath_name(text); + } } + } + /* Get all the device handles */ + hsize = (UINTN)NUM_HANDLES_INIT * sizeof(EFI_HANDLE); + handles = malloc(hsize); + if (handles == NULL) { + printf("Failed to allocate %d handles\n", NUM_HANDLES_INIT); } - /* The loaded image device path ends with a partition, then a - * file path. Trim them both to get the actual disk. - */ - if ((imgprefix = efi_devpath_trim(imgpath)) == NULL || - (imgprefix = efi_devpath_trim(imgprefix)) == NULL) { - panic("Couldn't trim device path"); - } + status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, + &hsize, handles); + switch (status) { + case EFI_SUCCESS: + break; + case EFI_BUFFER_TOO_SMALL: + free(handles); + handles = malloc(hsize); + if (handles == NULL) + efi_panic(EFI_OUT_OF_RESOURCES, "Failed to allocate %d handles\n", + NUM_HANDLES_INIT); + status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, + NULL, &hsize, handles); + if (status != EFI_SUCCESS) + efi_panic(status, "Failed to get device handles\n"); + break; + default: + efi_panic(status, "Failed to get device handles\n"); + break; + } - /* - * Initialize the block cache. Set the upper limit. - */ - bcache_init(32768, 512); + /* Scan all partitions, probing with all modules. */ + nhandles = hsize / sizeof(*handles); + printf(" Probing %zu block devices...", nhandles); + DPRINTF("\n"); - printf("\n Initializing modules:"); + for (i = 0; i < nhandles; i++) + probe_handle_status(handles[i], imgpath); + printf(" done\n"); - for (i = 0; efi_drivers[i] != NULL; i++) { - printf(" %s", efi_drivers[i]->name); - if (efi_drivers[i]->init != NULL) - efi_drivers[i]->init(); + /* Status summary. */ + for (i = 0; i < NUM_BOOT_MODULES; i++) { + printf(" "); + boot_modules[i]->status(); } - for (i = 0; devsw[i] != NULL; i++) { - if (devsw[i]->dv_init != NULL) { - printf(" %s", devsw[i]->dv_name); - (devsw[i]->dv_init)(); - } - } - - putchar('\n'); - try_boot(); /* If we get here, we're out of luck... */ efi_panic(EFI_LOAD_ERROR, "No bootable partitions found!"); } /* + * add_device adds a device to the passed devinfo list. + */ +void +add_device(dev_info_t **devinfop, dev_info_t *devinfo) +{ + dev_info_t *dev; + + if (*devinfop == NULL) { + *devinfop = devinfo; + return; + } + + for (dev = *devinfop; dev->next != NULL; dev = dev->next) + ; + + dev->next = devinfo; +} + +/* * OK. We totally give up. Exit back to EFI with a sensible status so * it can try the next option on the list. */ static void efi_panic(EFI_STATUS s, const char *fmt, ...) { - va_list ap; + va_list ap; - printf("panic: "); - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); - printf("\n"); + printf("panic: "); + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + printf("\n"); - BS->Exit(IH, s, 0, NULL); + BS->Exit(IH, s, 0, NULL); +} + +void +putchar(int c) +{ + CHAR16 buf[2]; + + if (c == '\n') { + buf[0] = '\r'; + buf[1] = 0; + ST->ConOut->OutputString(ST->ConOut, buf); + } + buf[0] = c; + buf[1] = 0; + ST->ConOut->OutputString(ST->ConOut, buf); } Index: stable/11/sys/boot/efi/boot1/boot_module.h =================================================================== --- stable/11/sys/boot/efi/boot1/boot_module.h (nonexistent) +++ stable/11/sys/boot/efi/boot1/boot_module.h (revision 329140) @@ -0,0 +1,109 @@ +/*- + * Copyright (c) 2015 Eric McCorkle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _BOOT_MODULE_H_ +#define _BOOT_MODULE_H_ + +#include + +#include +#include +#include + +#ifdef EFI_DEBUG +#define DPRINTF(fmt, args...) printf(fmt, ##args) +#define DSTALL(d) BS->Stall(d) +#else +#define DPRINTF(fmt, ...) {} +#define DSTALL(d) {} +#endif + +/* EFI device info */ +typedef struct dev_info +{ + EFI_BLOCK_IO *dev; + EFI_DEVICE_PATH *devpath; + EFI_HANDLE *devhandle; + void *devdata; + BOOLEAN preferred; + struct dev_info *next; +} dev_info_t; + +/* + * A boot loader module. + * + * This is a standard interface for filesystem modules in the EFI system. + */ +typedef struct boot_module_t +{ + const char *name; + + /* init is the optional initialiser for the module. */ + void (*init)(void); + + /* + * probe checks to see if the module can handle dev. + * + * Return codes: + * EFI_SUCCESS = The module can handle the device. + * EFI_NOT_FOUND = The module can not handle the device. + * Other = The module encountered an error. + */ + EFI_STATUS (*probe)(dev_info_t* dev); + + /* + * load should select the best out of a set of devices that probe + * indicated were loadable and load the specified file. + * + * Return codes: + * EFI_SUCCESS = The module can handle the device. + * EFI_NOT_FOUND = The module can not handle the device. + * Other = The module encountered an error. + */ + EFI_STATUS (*load)(const char *filepath, dev_info_t *devinfo, + void **buf, size_t *bufsize); + + /* status outputs information about the probed devices. */ + void (*status)(void); + + /* valid devices as found by probe. */ + dev_info_t *(*devices)(void); +} boot_module_t; + +/* Standard boot modules. */ +#ifdef EFI_UFS_BOOT +extern const boot_module_t ufs_module; +#endif +#ifdef EFI_ZFS_BOOT +extern const boot_module_t zfs_module; +#endif + +/* Functions available to modules. */ +extern void add_device(dev_info_t **devinfop, dev_info_t *devinfo); +extern int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); +#endif Property changes on: stable/11/sys/boot/efi/boot1/boot_module.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/boot1/ufs_module.c =================================================================== --- stable/11/sys/boot/efi/boot1/ufs_module.c (nonexistent) +++ stable/11/sys/boot/efi/boot1/ufs_module.c (revision 329140) @@ -0,0 +1,185 @@ +/*- + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * Copyright (c) 2001 Robert Drehmel + * All rights reserved. + * Copyright (c) 2014 Nathan Whitehorn + * All rights reserved. + * Copyright (c) 2015 Eric McCorkle + * All rights reverved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include + +#include "boot_module.h" + +static dev_info_t *devinfo; +static dev_info_t *devices; + +static int +dskread(void *buf, u_int64_t lba, int nblk) +{ + int size; + EFI_STATUS status; + + lba = lba / (devinfo->dev->Media->BlockSize / DEV_BSIZE); + size = nblk * DEV_BSIZE; + + status = devinfo->dev->ReadBlocks(devinfo->dev, + devinfo->dev->Media->MediaId, lba, size, buf); + + if (status != EFI_SUCCESS) { + DPRINTF("dskread: failed dev: %p, id: %u, lba: %ju, size: %d, " + "status: %lu\n", devinfo->dev, + devinfo->dev->Media->MediaId, (uintmax_t)lba, size, + EFI_ERROR_CODE(status)); + return (-1); + } + + return (0); +} + +#include "ufsread.c" + +static struct dmadat __dmadat; + +static int +init_dev(dev_info_t* dev) +{ + + devinfo = dev; + dmadat = &__dmadat; + + return fsread(0, NULL, 0); +} + +static EFI_STATUS +probe(dev_info_t* dev) +{ + + if (init_dev(dev) < 0) + return (EFI_UNSUPPORTED); + + add_device(&devices, dev); + + return (EFI_SUCCESS); +} + +static EFI_STATUS +load(const char *filepath, dev_info_t *dev, void **bufp, size_t *bufsize) +{ + ufs_ino_t ino; + EFI_STATUS status; + size_t size; + ssize_t read; + void *buf; + +#ifdef EFI_DEBUG + { + CHAR16 *text = efi_devpath_name(dev->devpath); + DPRINTF("Loading '%s' from %S\n", filepath, text); + efi_free_devpath_name(text); + } +#endif + if (init_dev(dev) < 0) { + DPRINTF("Failed to init device\n"); + return (EFI_UNSUPPORTED); + } + + if ((ino = lookup(filepath)) == 0) { + DPRINTF("Failed to lookup '%s' (file not found?)\n", filepath); + return (EFI_NOT_FOUND); + } + + if (fsread_size(ino, NULL, 0, &size) < 0 || size <= 0) { + printf("Failed to read size of '%s' ino: %d\n", filepath, ino); + return (EFI_INVALID_PARAMETER); + } + + if ((status = BS->AllocatePool(EfiLoaderData, size, &buf)) != + EFI_SUCCESS) { + printf("Failed to allocate read buffer %zu for '%s' (%lu)\n", + size, filepath, EFI_ERROR_CODE(status)); + return (status); + } + + read = fsread(ino, buf, size); + if ((size_t)read != size) { + printf("Failed to read '%s' (%zd != %zu)\n", filepath, read, + size); + (void)BS->FreePool(buf); + return (EFI_INVALID_PARAMETER); + } + + DPRINTF("Load complete\n"); + + *bufp = buf; + *bufsize = size; + + return (EFI_SUCCESS); +} + +static void +status(void) +{ + int i; + dev_info_t *dev; + + for (dev = devices, i = 0; dev != NULL; dev = dev->next, i++) + ; + + printf("%s found ", ufs_module.name); + switch (i) { + case 0: + printf("no partitions\n"); + break; + case 1: + printf("%d partition\n", i); + break; + default: + printf("%d partitions\n", i); + } +} + +static dev_info_t * +_devices(void) +{ + + return (devices); +} + +const boot_module_t ufs_module = +{ + .name = "UFS", + .probe = probe, + .load = load, + .status = status, + .devices = _devices +}; Property changes on: stable/11/sys/boot/efi/boot1/ufs_module.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/boot1/zfs_module.c =================================================================== --- stable/11/sys/boot/efi/boot1/zfs_module.c (nonexistent) +++ stable/11/sys/boot/efi/boot1/zfs_module.c (revision 329140) @@ -0,0 +1,248 @@ +/*- + * Copyright (c) 2015 Eric McCorkle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +#include +#include +#include +#include +#include +#include +#include + +#include "boot_module.h" + +#include "libzfs.h" +#include "zfsimpl.c" + +static dev_info_t *devices; + +uint64_t +ldi_get_size(void *priv) +{ + dev_info_t *devinfo = priv; + + return (devinfo->dev->Media->BlockSize * + (devinfo->dev->Media->LastBlock + 1)); +} + +static int +vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) +{ + dev_info_t *devinfo; + uint64_t lba; + size_t size, remainder, rb_size, blksz; + char *bouncebuf = NULL, *rb_buf; + EFI_STATUS status; + + devinfo = (dev_info_t *)priv; + lba = off / devinfo->dev->Media->BlockSize; + remainder = off % devinfo->dev->Media->BlockSize; + + rb_buf = buf; + rb_size = bytes; + + /* + * If we have remainder from off, we need to add remainder part. + * Since buffer must be multiple of the BlockSize, round it all up. + */ + size = roundup2(bytes + remainder, devinfo->dev->Media->BlockSize); + blksz = size; + if (remainder != 0 || size != bytes) { + rb_size = devinfo->dev->Media->BlockSize; + bouncebuf = malloc(rb_size); + if (bouncebuf == NULL) { + printf("vdev_read: out of memory\n"); + return (-1); + } + rb_buf = bouncebuf; + blksz = rb_size - remainder; + } + + while (bytes > 0) { + status = devinfo->dev->ReadBlocks(devinfo->dev, + devinfo->dev->Media->MediaId, lba, rb_size, rb_buf); + if (EFI_ERROR(status)) + goto error; + if (bytes < blksz) + blksz = bytes; + if (bouncebuf != NULL) + memcpy(buf, rb_buf + remainder, blksz); + buf = (void *)((uintptr_t)buf + blksz); + bytes -= blksz; + lba++; + remainder = 0; + blksz = rb_size; + } + + free(bouncebuf); + return (0); + +error: + free(bouncebuf); + DPRINTF("vdev_read: failed dev: %p, id: %u, lba: %ju, size: %zu," + " rb_size: %zu, status: %lu\n", devinfo->dev, + devinfo->dev->Media->MediaId, (uintmax_t)lba, bytes, rb_size, + EFI_ERROR_CODE(status)); + return (-1); +} + +static EFI_STATUS +probe(dev_info_t *dev) +{ + spa_t *spa; + dev_info_t *tdev; + EFI_STATUS status; + + /* ZFS consumes the dev on success so we need a copy. */ + if ((status = BS->AllocatePool(EfiLoaderData, sizeof(*dev), + (void**)&tdev)) != EFI_SUCCESS) { + DPRINTF("Failed to allocate tdev (%lu)\n", + EFI_ERROR_CODE(status)); + return (status); + } + memcpy(tdev, dev, sizeof(*dev)); + + if (vdev_probe(vdev_read, tdev, &spa) != 0) { + (void)BS->FreePool(tdev); + return (EFI_UNSUPPORTED); + } + + dev->devdata = spa; + add_device(&devices, dev); + + return (EFI_SUCCESS); +} + +static EFI_STATUS +load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize) +{ + spa_t *spa; + struct zfsmount zfsmount; + dnode_phys_t dn; + struct stat st; + int err; + void *buf; + EFI_STATUS status; + + spa = devinfo->devdata; + +#ifdef EFI_DEBUG + { + CHAR16 *text = efi_devpath_name(devinfo->devpath); + DPRINTF("load: '%s' spa: '%s', devpath: %S\n", filepath, + spa->spa_name, text); + efi_free_devpath_name(text); + } +#endif + if ((err = zfs_spa_init(spa)) != 0) { + DPRINTF("Failed to load pool '%s' (%d)\n", spa->spa_name, err); + return (EFI_NOT_FOUND); + } + + if ((err = zfs_mount(spa, 0, &zfsmount)) != 0) { + DPRINTF("Failed to mount pool '%s' (%d)\n", spa->spa_name, err); + return (EFI_NOT_FOUND); + } + + if ((err = zfs_lookup(&zfsmount, filepath, &dn)) != 0) { + if (err == ENOENT) { + DPRINTF("Failed to find '%s' on pool '%s' (%d)\n", + filepath, spa->spa_name, err); + return (EFI_NOT_FOUND); + } + printf("Failed to lookup '%s' on pool '%s' (%d)\n", filepath, + spa->spa_name, err); + return (EFI_INVALID_PARAMETER); + } + + if ((err = zfs_dnode_stat(spa, &dn, &st)) != 0) { + printf("Failed to stat '%s' on pool '%s' (%d)\n", filepath, + spa->spa_name, err); + return (EFI_INVALID_PARAMETER); + } + + if ((status = BS->AllocatePool(EfiLoaderData, (UINTN)st.st_size, &buf)) + != EFI_SUCCESS) { + printf("Failed to allocate load buffer %jd for pool '%s' for '%s' " + "(%lu)\n", (intmax_t)st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); + return (EFI_INVALID_PARAMETER); + } + + if ((err = dnode_read(spa, &dn, 0, buf, st.st_size)) != 0) { + printf("Failed to read node from %s (%d)\n", spa->spa_name, + err); + (void)BS->FreePool(buf); + return (EFI_INVALID_PARAMETER); + } + + *bufsize = st.st_size; + *bufp = buf; + + return (EFI_SUCCESS); +} + +static void +status(void) +{ + spa_t *spa; + + spa = STAILQ_FIRST(&zfs_pools); + if (spa == NULL) { + printf("%s found no pools\n", zfs_module.name); + return; + } + + printf("%s found the following pools:", zfs_module.name); + STAILQ_FOREACH(spa, &zfs_pools, spa_link) + printf(" %s", spa->spa_name); + + printf("\n"); +} + +static void +init(void) +{ + + zfs_init(); +} + +static dev_info_t * +_devices(void) +{ + + return (devices); +} + +const boot_module_t zfs_module = +{ + .name = "ZFS", + .init = init, + .probe = probe, + .load = load, + .status = status, + .devices = _devices +}; Property changes on: stable/11/sys/boot/efi/boot1/zfs_module.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/fdt/Makefile =================================================================== --- stable/11/sys/boot/efi/fdt/Makefile (revision 329139) +++ stable/11/sys/boot/efi/fdt/Makefile (revision 329140) @@ -1,37 +1,30 @@ # $FreeBSD$ -.include +.include -.PATH: ${.CURDIR}/../../common +.PATH: ${LDRSRC} LIB= efi_fdt INTERNALLIB= WARNS?= 6 SRCS= efi_fdt.c CFLAGS+= -ffreestanding .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only .else CFLAGS+= -msoft-float .endif # EFI library headers -CFLAGS+= -I${.CURDIR}/../include -CFLAGS+= -I${.CURDIR}/../include/${MACHINE} +CFLAGS+= -I${EFISRC}/include +CFLAGS+= -I${EFISRC}/include/${MACHINE} # libfdt headers -CFLAGS+= -I${.CURDIR}/../../fdt +CFLAGS+= -I${FDTSRC} # Pick up the bootstrap header for some interface items -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +CFLAGS+= -I${LDRSRC} -machine: .NOMETA - ln -sf ${.CURDIR}/../../../${MACHINE}/include machine - -CLEANFILES+= machine - .include - -beforedepend ${OBJS}: machine Index: stable/11/sys/boot/efi/include/efilib.h =================================================================== --- stable/11/sys/boot/efi/include/efilib.h (revision 329139) +++ stable/11/sys/boot/efi/include/efilib.h (revision 329140) @@ -1,109 +1,109 @@ /*- * Copyright (c) 2000 Doug Rabson * Copyright (c) 2006 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _LOADER_EFILIB_H #define _LOADER_EFILIB_H #include #include #include extern EFI_HANDLE IH; extern EFI_SYSTEM_TABLE *ST; extern EFI_BOOT_SERVICES *BS; extern EFI_RUNTIME_SERVICES *RS; extern struct devsw efipart_fddev; extern struct devsw efipart_cddev; extern struct devsw efipart_hddev; extern struct devsw efinet_dev; extern struct netif_driver efinetif; /* EFI block device data, included here to help efi_zfs_probe() */ typedef STAILQ_HEAD(pdinfo_list, pdinfo) pdinfo_list_t; typedef struct pdinfo { STAILQ_ENTRY(pdinfo) pd_link; /* link in device list */ pdinfo_list_t pd_part; /* list of partitions */ EFI_HANDLE pd_handle; EFI_HANDLE pd_alias; EFI_DEVICE_PATH *pd_devpath; EFI_BLOCK_IO *pd_blkio; uint32_t pd_unit; /* unit number */ uint32_t pd_open; /* reference counter */ void *pd_bcache; /* buffer cache data */ } pdinfo_t; pdinfo_list_t *efiblk_get_pdinfo_list(struct devsw *dev); pdinfo_t *efiblk_get_pdinfo(struct devdesc *dev); void *efi_get_table(EFI_GUID *tbl); int efi_getdev(void **vdev, const char *devspec, const char **path); char *efi_fmtdev(void *vdev); int efi_setcurrdev(struct env_var *ev, int flags, const void *value); int efi_register_handles(struct devsw *, EFI_HANDLE *, EFI_HANDLE *, int); EFI_HANDLE efi_find_handle(struct devsw *, int); int efi_handle_lookup(EFI_HANDLE, struct devsw **, int *, uint64_t *); int efi_handle_update_dev(EFI_HANDLE, struct devsw *, int, uint64_t); EFI_DEVICE_PATH *efi_lookup_image_devpath(EFI_HANDLE); EFI_DEVICE_PATH *efi_lookup_devpath(EFI_HANDLE); EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *); bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); -int efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); +bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *); void efi_free_devpath_name(CHAR16 *); int efi_status_to_errno(EFI_STATUS); EFI_STATUS errno_to_efi_status(int errno); void efi_time_init(void); void efi_time_fini(void); EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab); EFI_STATUS main(int argc, CHAR16 *argv[]); void efi_exit(EFI_STATUS status) __dead2; void delay(int usecs); /* EFI environment initialization. */ void efi_init_environment(void); /* CHAR16 utility functions. */ int wcscmp(CHAR16 *, CHAR16 *); void cpy8to16(const char *, CHAR16 *, size_t); void cpy16to8(const CHAR16 *, char *, size_t); #endif /* _LOADER_EFILIB_H */ Index: stable/11/sys/boot/efi/libefi/efi_main.c =================================================================== --- stable/11/sys/boot/efi/libefi/efi_main.c (revision 329139) +++ stable/11/sys/boot/efi/libefi/efi_main.c (nonexistent) @@ -1,188 +0,0 @@ -/*- - * Copyright (c) 2000 Doug Rabson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -static EFI_PHYSICAL_ADDRESS heap; -static UINTN heapsize; - -void -efi_exit(EFI_STATUS exit_code) -{ - - BS->FreePages(heap, EFI_SIZE_TO_PAGES(heapsize)); - BS->Exit(IH, exit_code, 0, NULL); -} - -void -exit(int status) -{ - - efi_exit(EFI_LOAD_ERROR); -} - -static CHAR16 * -arg_skipsep(CHAR16 *argp) -{ - - while (*argp == ' ' || *argp == '\t' || *argp == '\n') - argp++; - return (argp); -} - -static CHAR16 * -arg_skipword(CHAR16 *argp) -{ - - while (*argp && *argp != ' ' && *argp != '\t' && *argp != '\n') - argp++; - return (argp); -} - -EFI_STATUS -efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) -{ - static EFI_GUID image_protocol = LOADED_IMAGE_PROTOCOL; - static EFI_GUID console_control_protocol = - EFI_CONSOLE_CONTROL_PROTOCOL_GUID; - EFI_CONSOLE_CONTROL_PROTOCOL *console_control = NULL; - EFI_LOADED_IMAGE *img; - CHAR16 *argp, *args, **argv; - EFI_STATUS status; - int argc, addprog; - - IH = image_handle; - ST = system_table; - BS = ST->BootServices; - RS = ST->RuntimeServices; - - status = BS->LocateProtocol(&console_control_protocol, NULL, - (VOID **)&console_control); - if (status == EFI_SUCCESS) - (void)console_control->SetMode(console_control, - EfiConsoleControlScreenText); - - heapsize = 64 * 1024 * 1024; - status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, - EFI_SIZE_TO_PAGES(heapsize), &heap); - if (status != EFI_SUCCESS) - BS->Exit(IH, status, 0, NULL); - - setheap((void *)(uintptr_t)heap, (void *)(uintptr_t)(heap + heapsize)); - - /* Use efi_exit() from here on... */ - - status = BS->HandleProtocol(IH, &image_protocol, (VOID**)&img); - if (status != EFI_SUCCESS) - efi_exit(status); - - /* - * Pre-process the (optional) load options. If the option string - * is given as an ASCII string, we use a poor man's ASCII to - * Unicode-16 translation. The size of the option string as given - * to us includes the terminating null character. We assume the - * string is an ASCII string if strlen() plus the terminating - * '\0' is less than LoadOptionsSize. Even if all Unicode-16 - * characters have the upper 8 bits non-zero, the terminating - * null character will cause a one-off. - * If the string is already in Unicode-16, we make a copy so that - * we know we can always modify the string. - */ - if (img->LoadOptionsSize > 0 && img->LoadOptions != NULL) { - if (img->LoadOptionsSize == strlen(img->LoadOptions) + 1) { - args = malloc(img->LoadOptionsSize << 1); - for (argc = 0; argc < (int)img->LoadOptionsSize; argc++) - args[argc] = ((char*)img->LoadOptions)[argc]; - } else { - args = malloc(img->LoadOptionsSize); - memcpy(args, img->LoadOptions, img->LoadOptionsSize); - } - } else - args = NULL; - - /* - * Use a quick and dirty algorithm to build the argv vector. We - * first count the number of words. Then, after allocating the - * vector, we split the string up. We don't deal with quotes or - * other more advanced shell features. - * The EFI shell will pass the name of the image as the first - * word in the argument list. This does not happen if we're - * loaded by the boot manager. This is not so easy to figure - * out though. The ParentHandle is not always NULL, because - * there can be a function (=image) that will perform the task - * for the boot manager. - */ - /* Part 1: Figure out if we need to add our program name. */ - addprog = (args == NULL || img->ParentHandle == NULL || - img->FilePath == NULL) ? 1 : 0; - if (!addprog) { - addprog = - (DevicePathType(img->FilePath) != MEDIA_DEVICE_PATH || - DevicePathSubType(img->FilePath) != MEDIA_FILEPATH_DP || - DevicePathNodeLength(img->FilePath) <= - sizeof(FILEPATH_DEVICE_PATH)) ? 1 : 0; - if (!addprog) { - /* XXX todo. */ - } - } - /* Part 2: count words. */ - argc = (addprog) ? 1 : 0; - argp = args; - while (argp != NULL && *argp != 0) { - argp = arg_skipsep(argp); - if (*argp == 0) - break; - argc++; - argp = arg_skipword(argp); - } - /* Part 3: build vector. */ - argv = malloc((argc + 1) * sizeof(CHAR16*)); - argc = 0; - if (addprog) - argv[argc++] = (CHAR16 *)L"loader.efi"; - argp = args; - while (argp != NULL && *argp != 0) { - argp = arg_skipsep(argp); - if (*argp == 0) - break; - argv[argc++] = argp; - argp = arg_skipword(argp); - /* Terminate the words. */ - if (*argp != 0) - *argp++ = 0; - } - argv[argc] = NULL; - - status = main(argc, argv); - efi_exit(status); - return (status); -} Property changes on: stable/11/sys/boot/efi/libefi/efi_main.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/libefi/Makefile =================================================================== --- stable/11/sys/boot/efi/libefi/Makefile (revision 329139) +++ stable/11/sys/boot/efi/libefi/Makefile (revision 329140) @@ -1,61 +1,57 @@ # $FreeBSD$ -.include +.include .if ${MK_FORTH} != "no" -CFLAGS+= -DBOOT_FORTH -.include "../../ficl.mk" +.include "${BOOTSRC}/ficl.mk" .endif LIB= efi INTERNALLIB= WARNS?= 2 -SRCS= delay.c devpath.c efi_console.c efichar.c efinet.c efipart.c env.c \ - errno.c handles.c wchar.c libefi.c efi_driver_utils.c efizfs.c \ - devicename.c efi_main.c +SRCS= delay.c devpath.c efi_console.c efichar.c efinet.c efipart.c env.c errno.c \ + handles.c wchar.c libefi.c efi_driver_utils.c efizfs.c devicename.c .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" SRCS+= time.c .elif ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" SRCS+= time_event.c .endif # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead # of a short. There's no good cast to use here so just ignore the # warnings for now. CWARNFLAGS.efinet.c+= -Wno-format CWARNFLAGS.efipart.c+= -Wno-format CWARNFLAGS.env.c+= -Wno-format .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only .endif .if ${MACHINE_ARCH} == "amd64" CFLAGS+= -fPIC -mno-red-zone .endif -CFLAGS+= -I${.CURDIR}/../include -CFLAGS+= -I${.CURDIR}/../include/${MACHINE} +CFLAGS+= -I${EFIINC} +CFLAGS+= -I${EFIINCMD} .if ${MK_ZFS} != "no" -CFLAGS+= -I${.CURDIR}/../../zfs -CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs -CFLAGS+= -I${.CURDIR}/../../../crypto/skein +CFLAGS+= -I${ZFSSRC} CFLAGS+= -DEFI_ZFS_BOOT .endif # Pick up the bootstrap header for some interface items -CFLAGS+= -I${.CURDIR}/../../common +CFLAGS+= -I${LDRSRC} # Handle FreeBSD specific %b and %D printf format specifiers CFLAGS+= ${FORMAT_EXTENSIONS} # Do not use TERM_EMU on arm and arm64 as it doesn't behave well with serial console .if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "aarch64" CFLAGS+= -DTERM_EMU .endif CFLAGS+= -DLIBEFI .include Index: stable/11/sys/boot/efi/libefi/devpath.c =================================================================== --- stable/11/sys/boot/efi/libefi/devpath.c (revision 329139) +++ stable/11/sys/boot/efi/libefi/devpath.c (revision 329140) @@ -1,197 +1,197 @@ /*- * Copyright (c) 2016 John Baldwin * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include static EFI_GUID ImageDevicePathGUID = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID DevicePathToTextGUID = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *textProtocol; EFI_DEVICE_PATH * efi_lookup_image_devpath(EFI_HANDLE handle) { EFI_DEVICE_PATH *devpath; EFI_STATUS status; status = BS->HandleProtocol(handle, &ImageDevicePathGUID, (VOID **)&devpath); if (EFI_ERROR(status)) devpath = NULL; return (devpath); } EFI_DEVICE_PATH * efi_lookup_devpath(EFI_HANDLE handle) { EFI_DEVICE_PATH *devpath; EFI_STATUS status; status = BS->HandleProtocol(handle, &DevicePathGUID, (VOID **)&devpath); if (EFI_ERROR(status)) devpath = NULL; return (devpath); } CHAR16 * efi_devpath_name(EFI_DEVICE_PATH *devpath) { static int once = 1; EFI_STATUS status; if (devpath == NULL) return (NULL); if (once) { status = BS->LocateProtocol(&DevicePathToTextGUID, NULL, (VOID **)&textProtocol); if (EFI_ERROR(status)) textProtocol = NULL; once = 0; } if (textProtocol == NULL) return (NULL); return (textProtocol->ConvertDevicePathToText(devpath, TRUE, TRUE)); } void efi_free_devpath_name(CHAR16 *text) { BS->FreePool(text); } EFI_DEVICE_PATH * efi_devpath_last_node(EFI_DEVICE_PATH *devpath) { if (IsDevicePathEnd(devpath)) return (NULL); while (!IsDevicePathEnd(NextDevicePathNode(devpath))) devpath = NextDevicePathNode(devpath); return (devpath); } EFI_DEVICE_PATH * efi_devpath_trim(EFI_DEVICE_PATH *devpath) { EFI_DEVICE_PATH *node, *copy; size_t prefix, len; if ((node = efi_devpath_last_node(devpath)) == NULL) return (NULL); prefix = (UINT8 *)node - (UINT8 *)devpath; if (prefix == 0) return (NULL); len = prefix + DevicePathNodeLength(NextDevicePathNode(node)); copy = malloc(len); if (copy != NULL) { memcpy(copy, devpath, prefix); node = (EFI_DEVICE_PATH *)((UINT8 *)copy + prefix); SetDevicePathEndNode(node); } return (copy); } EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *devpath) { EFI_STATUS status; EFI_HANDLE h; /* * There isn't a standard way to locate a handle for a given * device path. However, querying the EFI_DEVICE_PATH protocol * for a given device path should give us a handle for the * closest node in the path to the end that is valid. */ status = BS->LocateDevicePath(&DevicePathGUID, &devpath, &h); if (EFI_ERROR(status)) return (NULL); return (h); } bool efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) { size_t len; if (devpath1 == NULL || devpath2 == NULL) return (false); while (true) { if (DevicePathType(devpath1) != DevicePathType(devpath2) || DevicePathSubType(devpath1) != DevicePathSubType(devpath2)) return (false); len = DevicePathNodeLength(devpath1); if (len != DevicePathNodeLength(devpath2)) return (false); if (memcmp(devpath1, devpath2, len) != 0) return (false); if (IsDevicePathEnd(devpath1)) break; devpath1 = NextDevicePathNode(devpath1); devpath2 = NextDevicePathNode(devpath2); } return (true); } -int +bool efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path) { - int len; + size_t len; if (prefix == NULL || path == NULL) - return (0); + return (false); while (1) { if (IsDevicePathEnd(prefix)) break; if (DevicePathType(prefix) != DevicePathType(path) || DevicePathSubType(prefix) != DevicePathSubType(path)) - return (0); + return (false); len = DevicePathNodeLength(prefix); if (len != DevicePathNodeLength(path)) - return (0); + return (false); - if (memcmp(prefix, path, (size_t)len) != 0) - return (0); + if (memcmp(prefix, path, len) != 0) + return (false); prefix = NextDevicePathNode(prefix); path = NextDevicePathNode(path); } - return (1); + return (true); } Index: stable/11/sys/boot/efi/libefi/efipart.c =================================================================== --- stable/11/sys/boot/efi/libefi/efipart.c (revision 329139) +++ stable/11/sys/boot/efi/libefi/efipart.c (revision 329140) @@ -1,980 +1,984 @@ /*- * Copyright (c) 2010 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL; static int efipart_initfd(void); static int efipart_initcd(void); static int efipart_inithd(void); static int efipart_strategy(void *, int, daddr_t, size_t, char *, size_t *); static int efipart_realstrategy(void *, int, daddr_t, size_t, char *, size_t *); static int efipart_open(struct open_file *, ...); static int efipart_close(struct open_file *); static int efipart_ioctl(struct open_file *, u_long, void *); static int efipart_printfd(int); static int efipart_printcd(int); static int efipart_printhd(int); /* EISA PNP ID's for floppy controllers */ #define PNP0604 0x604 #define PNP0700 0x700 #define PNP0701 0x701 struct devsw efipart_fddev = { .dv_name = "fd", .dv_type = DEVT_FD, .dv_init = efipart_initfd, .dv_strategy = efipart_strategy, .dv_open = efipart_open, .dv_close = efipart_close, .dv_ioctl = efipart_ioctl, .dv_print = efipart_printfd, .dv_cleanup = NULL }; struct devsw efipart_cddev = { .dv_name = "cd", .dv_type = DEVT_CD, .dv_init = efipart_initcd, .dv_strategy = efipart_strategy, .dv_open = efipart_open, .dv_close = efipart_close, .dv_ioctl = efipart_ioctl, .dv_print = efipart_printcd, .dv_cleanup = NULL }; struct devsw efipart_hddev = { .dv_name = "disk", .dv_type = DEVT_DISK, .dv_init = efipart_inithd, .dv_strategy = efipart_strategy, .dv_open = efipart_open, .dv_close = efipart_close, .dv_ioctl = efipart_ioctl, .dv_print = efipart_printhd, .dv_cleanup = NULL }; static pdinfo_list_t fdinfo; static pdinfo_list_t cdinfo; static pdinfo_list_t hdinfo; static EFI_HANDLE *efipart_handles = NULL; static UINTN efipart_nhandles = 0; pdinfo_list_t * efiblk_get_pdinfo_list(struct devsw *dev) { if (dev->dv_type == DEVT_DISK) return (&hdinfo); if (dev->dv_type == DEVT_CD) return (&cdinfo); if (dev->dv_type == DEVT_FD) return (&fdinfo); return (NULL); } pdinfo_t * efiblk_get_pdinfo(struct devdesc *dev) { pdinfo_list_t *pdi; pdinfo_t *pd = NULL; pdi = efiblk_get_pdinfo_list(dev->d_dev); if (pdi == NULL) return (pd); STAILQ_FOREACH(pd, pdi, pd_link) { if (pd->pd_unit == dev->d_unit) return (pd); } return (pd); } static int efiblk_pdinfo_count(pdinfo_list_t *pdi) { pdinfo_t *pd; int i = 0; STAILQ_FOREACH(pd, pdi, pd_link) { i++; } return (i); } static int efipart_inithandles(void) { UINTN sz; EFI_HANDLE *hin; EFI_STATUS status; if (efipart_nhandles != 0) { free(efipart_handles); efipart_handles = NULL; efipart_nhandles = 0; } sz = 0; hin = NULL; status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, hin); if (status == EFI_BUFFER_TOO_SMALL) { hin = malloc(sz); status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, hin); if (EFI_ERROR(status)) free(hin); } if (EFI_ERROR(status)) return (efi_status_to_errno(status)); efipart_handles = hin; efipart_nhandles = sz; return (0); } static ACPI_HID_DEVICE_PATH * efipart_floppy(EFI_DEVICE_PATH *node) { ACPI_HID_DEVICE_PATH *acpi; if (DevicePathType(node) == ACPI_DEVICE_PATH && DevicePathSubType(node) == ACPI_DP) { acpi = (ACPI_HID_DEVICE_PATH *) node; if (acpi->HID == EISA_PNP_ID(PNP0604) || acpi->HID == EISA_PNP_ID(PNP0700) || acpi->HID == EISA_PNP_ID(PNP0701)) { return (acpi); } } return (NULL); } /* * Add or update entries with new handle data. */ static int efipart_fdinfo_add(EFI_HANDLE handle, uint32_t uid, EFI_DEVICE_PATH *devpath) { pdinfo_t *fd; fd = calloc(1, sizeof(pdinfo_t)); if (fd == NULL) { printf("Failed to register floppy %d, out of memory\n", uid); return (ENOMEM); } STAILQ_INIT(&fd->pd_part); fd->pd_unit = uid; fd->pd_handle = handle; fd->pd_devpath = devpath; STAILQ_INSERT_TAIL(&fdinfo, fd, pd_link); return (0); } static void efipart_updatefd(void) { EFI_DEVICE_PATH *devpath, *node; ACPI_HID_DEVICE_PATH *acpi; int i, nin; nin = efipart_nhandles / sizeof (*efipart_handles); for (i = 0; i < nin; i++) { devpath = efi_lookup_devpath(efipart_handles[i]); if (devpath == NULL) continue; if ((node = efi_devpath_last_node(devpath)) == NULL) continue; if ((acpi = efipart_floppy(node)) != NULL) { efipart_fdinfo_add(efipart_handles[i], acpi->UID, devpath); } } } static int efipart_initfd(void) { int rv; rv = efipart_inithandles(); if (rv != 0) return (rv); STAILQ_INIT(&fdinfo); efipart_updatefd(); bcache_add_dev(efiblk_pdinfo_count(&fdinfo)); return (0); } /* * Add or update entries with new handle data. */ static int efipart_cdinfo_add(EFI_HANDLE handle, EFI_HANDLE alias, EFI_DEVICE_PATH *devpath) { int unit; pdinfo_t *cd; pdinfo_t *pd; unit = 0; STAILQ_FOREACH(pd, &cdinfo, pd_link) { if (efi_devpath_match(pd->pd_devpath, devpath) == true) { pd->pd_handle = handle; pd->pd_alias = alias; return (0); } unit++; } cd = calloc(1, sizeof(pdinfo_t)); if (cd == NULL) { printf("Failed to add cd %d, out of memory\n", unit); return (ENOMEM); } STAILQ_INIT(&cd->pd_part); cd->pd_handle = handle; cd->pd_unit = unit; cd->pd_alias = alias; cd->pd_devpath = devpath; STAILQ_INSERT_TAIL(&cdinfo, cd, pd_link); return (0); } static void efipart_updatecd(void) { int i, nin; EFI_DEVICE_PATH *devpath, *devpathcpy, *tmpdevpath, *node; EFI_HANDLE handle; EFI_BLOCK_IO *blkio; EFI_STATUS status; nin = efipart_nhandles / sizeof (*efipart_handles); for (i = 0; i < nin; i++) { devpath = efi_lookup_devpath(efipart_handles[i]); if (devpath == NULL) continue; if ((node = efi_devpath_last_node(devpath)) == NULL) continue; if (efipart_floppy(node) != NULL) continue; status = BS->HandleProtocol(efipart_handles[i], &blkio_guid, (void **)&blkio); if (EFI_ERROR(status)) continue; /* * If we come across a logical partition of subtype CDROM * it doesn't refer to the CD filesystem itself, but rather * to any usable El Torito boot image on it. In this case * we try to find the parent device and add that instead as * that will be the CD filesystem. */ if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_CDROM_DP) { devpathcpy = efi_devpath_trim(devpath); if (devpathcpy == NULL) continue; tmpdevpath = devpathcpy; status = BS->LocateDevicePath(&blkio_guid, &tmpdevpath, &handle); free(devpathcpy); if (EFI_ERROR(status)) continue; devpath = efi_lookup_devpath(handle); efipart_cdinfo_add(handle, efipart_handles[i], devpath); continue; } if (DevicePathType(node) == MESSAGING_DEVICE_PATH && DevicePathSubType(node) == MSG_ATAPI_DP) { efipart_cdinfo_add(efipart_handles[i], NULL, devpath); continue; } /* USB or SATA cd without the media. */ if (blkio->Media->RemovableMedia && !blkio->Media->MediaPresent) { efipart_cdinfo_add(efipart_handles[i], NULL, devpath); } } } static int efipart_initcd(void) { int rv; rv = efipart_inithandles(); if (rv != 0) return (rv); STAILQ_INIT(&cdinfo); efipart_updatecd(); bcache_add_dev(efiblk_pdinfo_count(&cdinfo)); return (0); } static int efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle) { EFI_DEVICE_PATH *disk_devpath, *part_devpath; HARDDRIVE_DEVICE_PATH *node; int unit; pdinfo_t *hd, *pd, *last; disk_devpath = efi_lookup_devpath(disk_handle); part_devpath = efi_lookup_devpath(part_handle); if (disk_devpath == NULL || part_devpath == NULL) { return (ENOENT); } node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath); if (node == NULL) return (ENOENT); /* This should not happen. */ pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { printf("Failed to add disk, out of memory\n"); return (ENOMEM); } STAILQ_INIT(&pd->pd_part); STAILQ_FOREACH(hd, &hdinfo, pd_link) { if (efi_devpath_match(hd->pd_devpath, disk_devpath) == true) { /* Add the partition. */ pd->pd_handle = part_handle; pd->pd_unit = node->PartitionNumber; pd->pd_devpath = part_devpath; STAILQ_INSERT_TAIL(&hd->pd_part, pd, pd_link); return (0); } } last = STAILQ_LAST(&hdinfo, pdinfo, pd_link); if (last != NULL) unit = last->pd_unit + 1; else unit = 0; /* Add the disk. */ hd = pd; hd->pd_handle = disk_handle; hd->pd_unit = unit; hd->pd_devpath = disk_devpath; STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link); pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { printf("Failed to add partition, out of memory\n"); return (ENOMEM); } STAILQ_INIT(&pd->pd_part); /* Add the partition. */ pd->pd_handle = part_handle; pd->pd_unit = node->PartitionNumber; pd->pd_devpath = part_devpath; STAILQ_INSERT_TAIL(&hd->pd_part, pd, pd_link); return (0); } /* * The MEDIA_FILEPATH_DP has device name. * From U-Boot sources it looks like names are in the form * of typeN:M, where type is interface type, N is disk id * and M is partition id. */ static int efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle) { EFI_DEVICE_PATH *devpath; FILEPATH_DEVICE_PATH *node; char *pathname, *p; int unit, len; pdinfo_t *pd, *last; /* First collect and verify all the data */ if ((devpath = efi_lookup_devpath(disk_handle)) == NULL) return (ENOENT); node = (FILEPATH_DEVICE_PATH *)efi_devpath_last_node(devpath); if (node == NULL) return (ENOENT); /* This should not happen. */ pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { printf("Failed to add disk, out of memory\n"); return (ENOMEM); } STAILQ_INIT(&pd->pd_part); last = STAILQ_LAST(&hdinfo, pdinfo, pd_link); if (last != NULL) unit = last->pd_unit + 1; else unit = 0; /* FILEPATH_DEVICE_PATH has 0 terminated string */ for (len = 0; node->PathName[len] != 0; len++) ; if ((pathname = malloc(len + 1)) == NULL) { printf("Failed to add disk, out of memory\n"); free(pd); return (ENOMEM); } cpy16to8(node->PathName, pathname, len + 1); p = strchr(pathname, ':'); /* * Assume we are receiving handles in order, first disk handle, * then partitions for this disk. If this assumption proves * false, this code would need update. */ if (p == NULL) { /* no colon, add the disk */ pd->pd_handle = disk_handle; pd->pd_unit = unit; pd->pd_devpath = devpath; STAILQ_INSERT_TAIL(&hdinfo, pd, pd_link); free(pathname); return (0); } p++; /* skip the colon */ errno = 0; unit = (int)strtol(p, NULL, 0); if (errno != 0) { printf("Bad unit number for partition \"%s\"\n", pathname); free(pathname); free(pd); return (EUNIT); } /* * We should have disk registered, if not, we are receiving * handles out of order, and this code should be reworked * to create "blank" disk for partition, and to find the * disk based on PathName compares. */ if (last == NULL) { printf("BUG: No disk for partition \"%s\"\n", pathname); free(pathname); free(pd); return (EINVAL); } /* Add the partition. */ pd->pd_handle = disk_handle; pd->pd_unit = unit; pd->pd_devpath = devpath; STAILQ_INSERT_TAIL(&last->pd_part, pd, pd_link); free(pathname); return (0); } static void efipart_updatehd(void) { int i, nin; EFI_DEVICE_PATH *devpath, *devpathcpy, *tmpdevpath, *node; EFI_HANDLE handle; EFI_BLOCK_IO *blkio; EFI_STATUS status; nin = efipart_nhandles / sizeof (*efipart_handles); for (i = 0; i < nin; i++) { devpath = efi_lookup_devpath(efipart_handles[i]); if (devpath == NULL) continue; if ((node = efi_devpath_last_node(devpath)) == NULL) continue; if (efipart_floppy(node) != NULL) continue; status = BS->HandleProtocol(efipart_handles[i], &blkio_guid, (void **)&blkio); if (EFI_ERROR(status)) continue; if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) { devpathcpy = efi_devpath_trim(devpath); if (devpathcpy == NULL) continue; tmpdevpath = devpathcpy; status = BS->LocateDevicePath(&blkio_guid, &tmpdevpath, &handle); free(devpathcpy); if (EFI_ERROR(status)) continue; /* * We do not support nested partitions. */ devpathcpy = efi_lookup_devpath(handle); if (devpathcpy == NULL) continue; if ((node = efi_devpath_last_node(devpathcpy)) == NULL) continue; if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) continue; efipart_hdinfo_add(handle, efipart_handles[i]); continue; } if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_FILEPATH_DP) { efipart_hdinfo_add_filepath(efipart_handles[i]); continue; } } } static int efipart_inithd(void) { int rv; rv = efipart_inithandles(); if (rv != 0) return (rv); STAILQ_INIT(&hdinfo); efipart_updatehd(); bcache_add_dev(efiblk_pdinfo_count(&hdinfo)); return (0); } static int efipart_print_common(struct devsw *dev, pdinfo_list_t *pdlist, int verbose) { int ret = 0; EFI_BLOCK_IO *blkio; EFI_STATUS status; EFI_HANDLE h; pdinfo_t *pd; CHAR16 *text; struct disk_devdesc pd_dev; char line[80]; if (STAILQ_EMPTY(pdlist)) return (0); printf("%s devices:", dev->dv_name); if ((ret = pager_output("\n")) != 0) return (ret); STAILQ_FOREACH(pd, pdlist, pd_link) { h = pd->pd_handle; if (verbose) { /* Output the device path. */ text = efi_devpath_name(efi_lookup_devpath(h)); if (text != NULL) { printf(" %S", text); efi_free_devpath_name(text); if ((ret = pager_output("\n")) != 0) break; } } snprintf(line, sizeof(line), " %s%d", dev->dv_name, pd->pd_unit); printf("%s:", line); status = BS->HandleProtocol(h, &blkio_guid, (void **)&blkio); if (!EFI_ERROR(status)) { printf(" %llu", blkio->Media->LastBlock == 0? 0: (unsigned long long) (blkio->Media->LastBlock + 1)); if (blkio->Media->LastBlock != 0) { printf(" X %u", blkio->Media->BlockSize); } printf(" blocks"); if (blkio->Media->MediaPresent) { if (blkio->Media->RemovableMedia) printf(" (removable)"); } else { printf(" (no media)"); } if ((ret = pager_output("\n")) != 0) break; if (!blkio->Media->MediaPresent) continue; pd->pd_blkio = blkio; pd_dev.d_dev = dev; pd_dev.d_unit = pd->pd_unit; pd_dev.d_slice = -1; pd_dev.d_partition = -1; pd_dev.d_opendata = blkio; ret = disk_open(&pd_dev, blkio->Media->BlockSize * (blkio->Media->LastBlock + 1), blkio->Media->BlockSize); if (ret == 0) { ret = disk_print(&pd_dev, line, verbose); disk_close(&pd_dev); if (ret != 0) return (ret); } else { /* Do not fail from disk_open() */ ret = 0; } } else { if ((ret = pager_output("\n")) != 0) break; } } return (ret); } static int efipart_printfd(int verbose) { return (efipart_print_common(&efipart_fddev, &fdinfo, verbose)); } static int efipart_printcd(int verbose) { return (efipart_print_common(&efipart_cddev, &cdinfo, verbose)); } static int efipart_printhd(int verbose) { return (efipart_print_common(&efipart_hddev, &hdinfo, verbose)); } static int efipart_open(struct open_file *f, ...) { va_list args; struct disk_devdesc *dev; pdinfo_t *pd; EFI_BLOCK_IO *blkio; EFI_STATUS status; va_start(args, f); dev = va_arg(args, struct disk_devdesc*); va_end(args); if (dev == NULL) return (EINVAL); pd = efiblk_get_pdinfo((struct devdesc *)dev); if (pd == NULL) return (EIO); if (pd->pd_blkio == NULL) { status = BS->HandleProtocol(pd->pd_handle, &blkio_guid, (void **)&pd->pd_blkio); if (EFI_ERROR(status)) return (efi_status_to_errno(status)); } blkio = pd->pd_blkio; if (!blkio->Media->MediaPresent) return (EAGAIN); pd->pd_open++; if (pd->pd_bcache == NULL) pd->pd_bcache = bcache_allocate(); if (dev->d_dev->dv_type == DEVT_DISK) { int rc; rc = disk_open(dev, blkio->Media->BlockSize * (blkio->Media->LastBlock + 1), blkio->Media->BlockSize); if (rc != 0) { pd->pd_open--; if (pd->pd_open == 0) { pd->pd_blkio = NULL; bcache_free(pd->pd_bcache); pd->pd_bcache = NULL; } } return (rc); } return (0); } static int efipart_close(struct open_file *f) { struct disk_devdesc *dev; pdinfo_t *pd; dev = (struct disk_devdesc *)(f->f_devdata); if (dev == NULL) return (EINVAL); pd = efiblk_get_pdinfo((struct devdesc *)dev); if (pd == NULL) return (EINVAL); pd->pd_open--; if (pd->pd_open == 0) { pd->pd_blkio = NULL; bcache_free(pd->pd_bcache); pd->pd_bcache = NULL; } if (dev->d_dev->dv_type == DEVT_DISK) return (disk_close(dev)); return (0); } static int efipart_ioctl(struct open_file *f, u_long cmd, void *data) { struct disk_devdesc *dev; pdinfo_t *pd; int rc; dev = (struct disk_devdesc *)(f->f_devdata); if (dev == NULL) return (EINVAL); pd = efiblk_get_pdinfo((struct devdesc *)dev); if (pd == NULL) return (EINVAL); if (dev->d_dev->dv_type == DEVT_DISK) { rc = disk_ioctl(dev, cmd, data); if (rc != ENOTTY) return (rc); } switch (cmd) { case DIOCGSECTORSIZE: *(u_int *)data = pd->pd_blkio->Media->BlockSize; break; case DIOCGMEDIASIZE: *(uint64_t *)data = pd->pd_blkio->Media->BlockSize * (pd->pd_blkio->Media->LastBlock + 1); break; default: return (ENOTTY); } return (0); } /* * efipart_readwrite() * Internal equivalent of efipart_strategy(), which operates on the * media-native block size. This function expects all I/O requests * to be within the media size and returns an error if such is not * the case. */ static int efipart_readwrite(EFI_BLOCK_IO *blkio, int rw, daddr_t blk, daddr_t nblks, char *buf) { EFI_STATUS status; if (blkio == NULL) return (ENXIO); if (blk < 0 || blk > blkio->Media->LastBlock) return (EIO); if ((blk + nblks - 1) > blkio->Media->LastBlock) return (EIO); switch (rw & F_MASK) { case F_READ: status = blkio->ReadBlocks(blkio, blkio->Media->MediaId, blk, nblks * blkio->Media->BlockSize, buf); break; case F_WRITE: if (blkio->Media->ReadOnly) return (EROFS); status = blkio->WriteBlocks(blkio, blkio->Media->MediaId, blk, nblks * blkio->Media->BlockSize, buf); break; default: return (ENOSYS); } if (EFI_ERROR(status)) { printf("%s: rw=%d, blk=%ju size=%ju status=%lu\n", __func__, rw, blk, nblks, EFI_ERROR_CODE(status)); } return (efi_status_to_errno(status)); } static int efipart_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize) { struct bcache_devdata bcd; struct disk_devdesc *dev; pdinfo_t *pd; dev = (struct disk_devdesc *)devdata; if (dev == NULL) return (EINVAL); pd = efiblk_get_pdinfo((struct devdesc *)dev); if (pd == NULL) return (EINVAL); if (pd->pd_blkio->Media->RemovableMedia && !pd->pd_blkio->Media->MediaPresent) return (ENXIO); bcd.dv_strategy = efipart_realstrategy; bcd.dv_devdata = devdata; bcd.dv_cache = pd->pd_bcache; if (dev->d_dev->dv_type == DEVT_DISK) { - return (bcache_strategy(&bcd, rw, blk + dev->d_offset, + daddr_t offset; + + offset = dev->d_offset * pd->pd_blkio->Media->BlockSize; + offset /= 512; + return (bcache_strategy(&bcd, rw, blk + offset, size, buf, rsize)); } return (bcache_strategy(&bcd, rw, blk, size, buf, rsize)); } static int efipart_realstrategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize) { struct disk_devdesc *dev = (struct disk_devdesc *)devdata; pdinfo_t *pd; EFI_BLOCK_IO *blkio; uint64_t off, disk_blocks, d_offset = 0; char *blkbuf; size_t blkoff, blksz; int error; size_t diskend, readstart; if (dev == NULL || blk < 0) return (EINVAL); pd = efiblk_get_pdinfo((struct devdesc *)dev); if (pd == NULL) return (EINVAL); blkio = pd->pd_blkio; if (blkio == NULL) return (ENXIO); if (size == 0 || (size % 512) != 0) return (EIO); off = blk * 512; /* * Get disk blocks, this value is either for whole disk or for * partition. */ disk_blocks = 0; if (dev->d_dev->dv_type == DEVT_DISK) { if (disk_ioctl(dev, DIOCGMEDIASIZE, &disk_blocks) == 0) { /* DIOCGMEDIASIZE does return bytes. */ disk_blocks /= blkio->Media->BlockSize; } d_offset = dev->d_offset; } if (disk_blocks == 0) disk_blocks = blkio->Media->LastBlock + 1 - d_offset; /* make sure we don't read past disk end */ if ((off + size) / blkio->Media->BlockSize > d_offset + disk_blocks) { diskend = d_offset + disk_blocks; readstart = off / blkio->Media->BlockSize; if (diskend <= readstart) { if (rsize != NULL) *rsize = 0; return (EIO); } size = diskend - readstart; size = size * blkio->Media->BlockSize; } if (rsize != NULL) *rsize = size; if ((size % blkio->Media->BlockSize == 0) && (off % blkio->Media->BlockSize == 0)) return (efipart_readwrite(blkio, rw, off / blkio->Media->BlockSize, size / blkio->Media->BlockSize, buf)); /* * The block size of the media is not a multiple of I/O. */ blkbuf = malloc(blkio->Media->BlockSize); if (blkbuf == NULL) return (ENOMEM); error = 0; blk = off / blkio->Media->BlockSize; blkoff = off % blkio->Media->BlockSize; blksz = blkio->Media->BlockSize - blkoff; while (size > 0) { error = efipart_readwrite(blkio, rw, blk, 1, blkbuf); if (error) break; if (size < blksz) blksz = size; bcopy(blkbuf + blkoff, buf, blksz); buf += blksz; size -= blksz; blk++; blkoff = 0; blksz = blkio->Media->BlockSize; } free(blkbuf); return (error); } Index: stable/11/sys/boot/efi/loader/Makefile =================================================================== --- stable/11/sys/boot/efi/loader/Makefile (revision 329139) +++ stable/11/sys/boot/efi/loader/Makefile (revision 329140) @@ -1,173 +1,137 @@ # $FreeBSD$ MAN= -.include +LOADER_NET_SUPPORT?= yes +LOADER_MSDOS_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no +.include + MK_SSP= no PROG= loader.sym INTERNALPROG= WARNS?= 3 -LOADER_NET_SUPPORT?= yes # architecture-specific loader code SRCS= autoload.c \ bootinfo.c \ conf.c \ copy.c \ + efi_main.c \ + framebuffer.c \ main.c \ self_reloc.c \ smbios.c \ vers.c .if ${MK_ZFS} != "no" -SRCS+= zfs.c -.PATH: ${.CURDIR}/../../zfs -SRCS+= skein.c skein_block.c -# Do not unroll skein loops, reduce code size -CFLAGS+= -DSKEIN_LOOP=111 -.PATH: ${.CURDIR}/../../../crypto/skein - -# Disable warnings that are currently incompatible with the zfs boot code -CWARNFLAGS.zfs.c+= -Wno-sign-compare -CWARNFLAGS.zfs.c+= -Wno-array-bounds -CWARNFLAGS.zfs.c+= -Wno-missing-prototypes +LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a +CFLAGS+= -I${ZFSSRC} +CFLAGS+= -DEFI_ZFS_BOOT .endif .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized .endif # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead # of a short. There's no good cast to use here so just ignore the # warnings for now. CWARNFLAGS.main.c+= -Wno-format .PATH: ${.CURDIR}/arch/${MACHINE} # For smbios.c -.PATH: ${.CURDIR}/../../i386/libi386 +.PATH: ${BOOTSRC}/i386/libi386 .include "${.CURDIR}/arch/${MACHINE}/Makefile.inc" CFLAGS+= -I${.CURDIR} CFLAGS+= -I${.CURDIR}/arch/${MACHINE} -CFLAGS+= -I${.CURDIR}/../include -CFLAGS+= -I${.CURDIR}/../include/${MACHINE} -CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include -CFLAGS+= -I${.CURDIR}/../../.. -CFLAGS+= -I${.CURDIR}/../../i386/libi386 -.if ${MK_ZFS} != "no" -CFLAGS+= -I${.CURDIR}/../../zfs -CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs -CFLAGS+= -I${.CURDIR}/../../../crypto/skein -CFLAGS+= -DEFI_ZFS_BOOT -.endif +CFLAGS+= -I${EFISRC}/include +CFLAGS+= -I${EFISRC}/include/${MACHINE} +CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include +CFLAGS+= -I${BOOTSRC}/i386/libi386 CFLAGS+= -DNO_PCI -DEFI # make buildenv doesn't set DESTDIR, this means LIBSTAND # will be wrong when crossbuilding. .if exists(${.OBJDIR}/../../../../lib/libstand/libstand.a) LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a .endif .if !defined(BOOT_HIDE_SERIAL_NUMBERS) # Export serial numbers, UUID, and asset tag from loader. CFLAGS+= -DSMBIOS_SERIAL_NUMBERS .if defined(BOOT_LITTLE_ENDIAN_UUID) # Use little-endian UUID format as defined in SMBIOS 2.6. CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID .elif defined(BOOT_NETWORK_ENDIAN_UUID) # Use network-endian UUID format for backward compatibility. CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID .endif .endif -.if ${MK_FORTH} != "no" -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -CFLAGS+= -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/${MACHINE_CPUARCH} -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a +.if defined(HAVE_FDT) && ${MK_FDT} != "no" +.include "${BOOTSRC}/fdt.mk" +LIBEFI_FDT= ${BOOTOBJ}/efi/fdt/libefi_fdt.a .endif -LOADER_FDT_SUPPORT?= no -.if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no" -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBEFI_FDT= ${.OBJDIR}/../../efi/fdt/libefi_fdt.a -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a -.endif - # Include bcache code. HAVE_BCACHE= yes .if defined(EFI_STAGING_SIZE) CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE} .endif # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common +HELP_FILES= +.include "${BOOTSRC}/loader.mk" FILES+= loader.efi FILESMODE_loader.efi= ${BINMODE} LDSCRIPT= ${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE} LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared CLEANFILES+= loader.efi NEWVERSWHAT= "EFI loader" ${MACHINE} NM?= nm OBJCOPY?= objcopy .if ${MACHINE_CPUARCH} == "amd64" EFI_TARGET= efi-app-x86_64 .elif ${MACHINE_CPUARCH} == "i386" EFI_TARGET= efi-app-ia32 .else EFI_TARGET= binary .endif # Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00 # for build reproducibility. SOURCE_DATE_EPOCH?=1451606400 loader.efi: ${PROG} if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ fi SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ -j set_Xficl_compile_set \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} -LIBEFI= ${.OBJDIR}/../libefi/libefi.a +LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a -DPADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} \ +DPADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBZFSBOOT} ${LIBSA} \ ${LDSCRIPT} -LDADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} +LDADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBZFSBOOT} ${LIBSA} .include - -beforedepend ${OBJS}: machine - -CLEANFILES+= machine - -machine: .NOMETA - ln -sf ${.CURDIR}/../../../${MACHINE}/include machine - -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" -beforedepend ${OBJS}: x86 -CLEANFILES+= x86 - -x86: .NOMETA - ln -sf ${.CURDIR}/../../../x86/include x86 -.endif Index: stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c =================================================================== --- stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c (revision 329139) +++ stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c (nonexistent) @@ -1,568 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Benno Rice under sponsorship from - * the FreeBSD Foundation. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "framebuffer.h" - -static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; -static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID; -static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID; - -static u_int -efifb_color_depth(struct efi_fb *efifb) -{ - uint32_t mask; - u_int depth; - - mask = efifb->fb_mask_red | efifb->fb_mask_green | - efifb->fb_mask_blue | efifb->fb_mask_reserved; - if (mask == 0) - return (0); - for (depth = 1; mask != 1; depth++) - mask >>= 1; - return (depth); -} - -static int -efifb_mask_from_pixfmt(struct efi_fb *efifb, EFI_GRAPHICS_PIXEL_FORMAT pixfmt, - EFI_PIXEL_BITMASK *pixinfo) -{ - int result; - - result = 0; - switch (pixfmt) { - case PixelRedGreenBlueReserved8BitPerColor: - efifb->fb_mask_red = 0x000000ff; - efifb->fb_mask_green = 0x0000ff00; - efifb->fb_mask_blue = 0x00ff0000; - efifb->fb_mask_reserved = 0xff000000; - break; - case PixelBlueGreenRedReserved8BitPerColor: - efifb->fb_mask_red = 0x00ff0000; - efifb->fb_mask_green = 0x0000ff00; - efifb->fb_mask_blue = 0x000000ff; - efifb->fb_mask_reserved = 0xff000000; - break; - case PixelBitMask: - efifb->fb_mask_red = pixinfo->RedMask; - efifb->fb_mask_green = pixinfo->GreenMask; - efifb->fb_mask_blue = pixinfo->BlueMask; - efifb->fb_mask_reserved = pixinfo->ReservedMask; - break; - default: - result = 1; - break; - } - return (result); -} - -static int -efifb_from_gop(struct efi_fb *efifb, EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *mode, - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info) -{ - int result; - - efifb->fb_addr = mode->FrameBufferBase; - efifb->fb_size = mode->FrameBufferSize; - efifb->fb_height = info->VerticalResolution; - efifb->fb_width = info->HorizontalResolution; - efifb->fb_stride = info->PixelsPerScanLine; - result = efifb_mask_from_pixfmt(efifb, info->PixelFormat, - &info->PixelInformation); - return (result); -} - -static ssize_t -efifb_uga_find_pixel(EFI_UGA_DRAW_PROTOCOL *uga, u_int line, - EFI_PCI_IO_PROTOCOL *pciio, uint64_t addr, uint64_t size) -{ - EFI_UGA_PIXEL pix0, pix1; - uint8_t *data1, *data2; - size_t count, maxcount = 1024; - ssize_t ofs; - EFI_STATUS status; - u_int idx; - - status = uga->Blt(uga, &pix0, EfiUgaVideoToBltBuffer, - 0, line, 0, 0, 1, 1, 0); - if (EFI_ERROR(status)) { - printf("UGA BLT operation failed (video->buffer)"); - return (-1); - } - pix1.Red = ~pix0.Red; - pix1.Green = ~pix0.Green; - pix1.Blue = ~pix0.Blue; - pix1.Reserved = 0; - - data1 = calloc(maxcount, 2); - if (data1 == NULL) { - printf("Unable to allocate memory"); - return (-1); - } - data2 = data1 + maxcount; - - ofs = 0; - while (size > 0) { - count = min(size, maxcount); - - status = pciio->Mem.Read(pciio, EfiPciIoWidthUint32, - EFI_PCI_IO_PASS_THROUGH_BAR, addr + ofs, count >> 2, - data1); - if (EFI_ERROR(status)) { - printf("Error reading frame buffer (before)"); - goto fail; - } - status = uga->Blt(uga, &pix1, EfiUgaBltBufferToVideo, - 0, 0, 0, line, 1, 1, 0); - if (EFI_ERROR(status)) { - printf("UGA BLT operation failed (modify)"); - goto fail; - } - status = pciio->Mem.Read(pciio, EfiPciIoWidthUint32, - EFI_PCI_IO_PASS_THROUGH_BAR, addr + ofs, count >> 2, - data2); - if (EFI_ERROR(status)) { - printf("Error reading frame buffer (after)"); - goto fail; - } - status = uga->Blt(uga, &pix0, EfiUgaBltBufferToVideo, - 0, 0, 0, line, 1, 1, 0); - if (EFI_ERROR(status)) { - printf("UGA BLT operation failed (restore)"); - goto fail; - } - for (idx = 0; idx < count; idx++) { - if (data1[idx] != data2[idx]) { - free(data1); - return (ofs + (idx & ~3)); - } - } - ofs += count; - size -= count; - } - printf("No change detected in frame buffer"); - - fail: - printf(" -- error %lu\n", EFI_ERROR_CODE(status)); - free(data1); - return (-1); -} - -static EFI_PCI_IO_PROTOCOL * -efifb_uga_get_pciio(void) -{ - EFI_PCI_IO_PROTOCOL *pciio; - EFI_HANDLE *buf, *hp; - EFI_STATUS status; - UINTN bufsz; - - /* Get all handles that support the UGA protocol. */ - bufsz = 0; - status = BS->LocateHandle(ByProtocol, &uga_guid, NULL, &bufsz, NULL); - if (status != EFI_BUFFER_TOO_SMALL) - return (NULL); - buf = malloc(bufsz); - status = BS->LocateHandle(ByProtocol, &uga_guid, NULL, &bufsz, buf); - if (status != EFI_SUCCESS) { - free(buf); - return (NULL); - } - bufsz /= sizeof(EFI_HANDLE); - - /* Get the PCI I/O interface of the first handle that supports it. */ - pciio = NULL; - for (hp = buf; hp < buf + bufsz; hp++) { - status = BS->HandleProtocol(*hp, &pciio_guid, (void **)&pciio); - if (status == EFI_SUCCESS) { - free(buf); - return (pciio); - } - } - free(buf); - return (NULL); -} - -static EFI_STATUS -efifb_uga_locate_framebuffer(EFI_PCI_IO_PROTOCOL *pciio, uint64_t *addrp, - uint64_t *sizep) -{ - uint8_t *resattr; - uint64_t addr, size; - EFI_STATUS status; - u_int bar; - - if (pciio == NULL) - return (EFI_DEVICE_ERROR); - - /* Attempt to get the frame buffer address (imprecise). */ - *addrp = 0; - *sizep = 0; - for (bar = 0; bar < 6; bar++) { - status = pciio->GetBarAttributes(pciio, bar, NULL, - (void **)&resattr); - if (status != EFI_SUCCESS) - continue; - /* XXX magic offsets and constants. */ - if (resattr[0] == 0x87 && resattr[3] == 0) { - /* 32-bit address space descriptor (MEMIO) */ - addr = le32dec(resattr + 10); - size = le32dec(resattr + 22); - } else if (resattr[0] == 0x8a && resattr[3] == 0) { - /* 64-bit address space descriptor (MEMIO) */ - addr = le64dec(resattr + 14); - size = le64dec(resattr + 38); - } else { - addr = 0; - size = 0; - } - BS->FreePool(resattr); - if (addr == 0 || size == 0) - continue; - - /* We assume the largest BAR is the frame buffer. */ - if (size > *sizep) { - *addrp = addr; - *sizep = size; - } - } - return ((*addrp == 0 || *sizep == 0) ? EFI_DEVICE_ERROR : 0); -} - -static int -efifb_from_uga(struct efi_fb *efifb, EFI_UGA_DRAW_PROTOCOL *uga) -{ - EFI_PCI_IO_PROTOCOL *pciio; - char *ev, *p; - EFI_STATUS status; - ssize_t offset; - uint64_t fbaddr; - uint32_t horiz, vert, stride; - uint32_t np, depth, refresh; - - status = uga->GetMode(uga, &horiz, &vert, &depth, &refresh); - if (EFI_ERROR(status)) - return (1); - efifb->fb_height = vert; - efifb->fb_width = horiz; - /* Paranoia... */ - if (efifb->fb_height == 0 || efifb->fb_width == 0) - return (1); - - /* The color masks are fixed AFAICT. */ - efifb_mask_from_pixfmt(efifb, PixelBlueGreenRedReserved8BitPerColor, - NULL); - - /* pciio can be NULL on return! */ - pciio = efifb_uga_get_pciio(); - - /* Try to find the frame buffer. */ - status = efifb_uga_locate_framebuffer(pciio, &efifb->fb_addr, - &efifb->fb_size); - if (EFI_ERROR(status)) { - efifb->fb_addr = 0; - efifb->fb_size = 0; - } - - /* - * There's no reliable way to detect the frame buffer or the - * offset within the frame buffer of the visible region, nor - * the stride. Our only option is to look at the system and - * fill in the blanks based on that. Luckily, UGA was mostly - * only used on Apple hardware. - */ - offset = -1; - ev = getenv("smbios.system.maker"); - if (ev != NULL && !strcmp(ev, "Apple Inc.")) { - ev = getenv("smbios.system.product"); - if (ev != NULL && !strcmp(ev, "iMac7,1")) { - /* These are the expected values we should have. */ - horiz = 1680; - vert = 1050; - fbaddr = 0xc0000000; - /* These are the missing bits. */ - offset = 0x10000; - stride = 1728; - } else if (ev != NULL && !strcmp(ev, "MacBook3,1")) { - /* These are the expected values we should have. */ - horiz = 1280; - vert = 800; - fbaddr = 0xc0000000; - /* These are the missing bits. */ - offset = 0x0; - stride = 2048; - } - } - - /* - * If this is hardware we know, make sure that it looks familiar - * before we accept our hardcoded values. - */ - if (offset >= 0 && efifb->fb_width == horiz && - efifb->fb_height == vert && efifb->fb_addr == fbaddr) { - efifb->fb_addr += offset; - efifb->fb_size -= offset; - efifb->fb_stride = stride; - return (0); - } else if (offset >= 0) { - printf("Hardware make/model known, but graphics not " - "as expected.\n"); - printf("Console may not work!\n"); - } - - /* - * The stride is equal or larger to the width. Often it's the - * next larger power of two. We'll start with that... - */ - efifb->fb_stride = efifb->fb_width; - do { - np = efifb->fb_stride & (efifb->fb_stride - 1); - if (np) { - efifb->fb_stride |= (np - 1); - efifb->fb_stride++; - } - } while (np); - - ev = getenv("hw.efifb.address"); - if (ev == NULL) { - if (efifb->fb_addr == 0) { - printf("Please set hw.efifb.address and " - "hw.efifb.stride.\n"); - return (1); - } - - /* - * The visible part of the frame buffer may not start at - * offset 0, so try to detect it. Note that we may not - * always be able to read from the frame buffer, which - * means that we may not be able to detect anything. In - * that case, we would take a long time scanning for a - * pixel change in the frame buffer, which would have it - * appear that we're hanging, so we limit the scan to - * 1/256th of the frame buffer. This number is mostly - * based on PR 202730 and the fact that on a MacBoook, - * where we can't read from the frame buffer the offset - * of the visible region is 0. In short: we want to scan - * enough to handle all adapters that have an offset - * larger than 0 and we want to scan as little as we can - * to not appear to hang when we can't read from the - * frame buffer. - */ - offset = efifb_uga_find_pixel(uga, 0, pciio, efifb->fb_addr, - efifb->fb_size >> 8); - if (offset == -1) { - printf("Unable to reliably detect frame buffer.\n"); - } else if (offset > 0) { - efifb->fb_addr += offset; - efifb->fb_size -= offset; - } - } else { - offset = 0; - efifb->fb_size = efifb->fb_height * efifb->fb_stride * 4; - efifb->fb_addr = strtoul(ev, &p, 0); - if (*p != '\0') - return (1); - } - - ev = getenv("hw.efifb.stride"); - if (ev == NULL) { - if (pciio != NULL && offset != -1) { - /* Determine the stride. */ - offset = efifb_uga_find_pixel(uga, 1, pciio, - efifb->fb_addr, horiz * 8); - if (offset != -1) - efifb->fb_stride = offset >> 2; - } else { - printf("Unable to reliably detect the stride.\n"); - } - } else { - efifb->fb_stride = strtoul(ev, &p, 0); - if (*p != '\0') - return (1); - } - - /* - * We finalized on the stride, so recalculate the size of the - * frame buffer. - */ - efifb->fb_size = efifb->fb_height * efifb->fb_stride * 4; - return (0); -} - -int -efi_find_framebuffer(struct efi_fb *efifb) -{ - EFI_GRAPHICS_OUTPUT *gop; - EFI_UGA_DRAW_PROTOCOL *uga; - EFI_STATUS status; - - status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); - if (status == EFI_SUCCESS) - return (efifb_from_gop(efifb, gop->Mode, gop->Mode->Info)); - - status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); - if (status == EFI_SUCCESS) - return (efifb_from_uga(efifb, uga)); - - return (1); -} - -static void -print_efifb(int mode, struct efi_fb *efifb, int verbose) -{ - u_int depth; - - if (mode >= 0) - printf("mode %d: ", mode); - depth = efifb_color_depth(efifb); - printf("%ux%ux%u, stride=%u", efifb->fb_width, efifb->fb_height, - depth, efifb->fb_stride); - if (verbose) { - printf("\n frame buffer: address=%jx, size=%jx", - (uintmax_t)efifb->fb_addr, (uintmax_t)efifb->fb_size); - printf("\n color mask: R=%08x, G=%08x, B=%08x\n", - efifb->fb_mask_red, efifb->fb_mask_green, - efifb->fb_mask_blue); - } -} - -COMMAND_SET(gop, "gop", "graphics output protocol", command_gop); - -static int -command_gop(int argc, char *argv[]) -{ - struct efi_fb efifb; - EFI_GRAPHICS_OUTPUT *gop; - EFI_STATUS status; - u_int mode; - - status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); - if (EFI_ERROR(status)) { - snprintf(command_errbuf, sizeof(command_errbuf), - "%s: Graphics Output Protocol not present (error=%lu)", - argv[0], EFI_ERROR_CODE(status)); - return (CMD_ERROR); - } - - if (argc < 2) - goto usage; - - if (!strcmp(argv[1], "set")) { - char *cp; - - if (argc != 3) - goto usage; - mode = strtol(argv[2], &cp, 0); - if (cp[0] != '\0') { - sprintf(command_errbuf, "mode is an integer"); - return (CMD_ERROR); - } - status = gop->SetMode(gop, mode); - if (EFI_ERROR(status)) { - snprintf(command_errbuf, sizeof(command_errbuf), - "%s: Unable to set mode to %u (error=%lu)", - argv[0], mode, EFI_ERROR_CODE(status)); - return (CMD_ERROR); - } - } else if (!strcmp(argv[1], "get")) { - if (argc != 2) - goto usage; - efifb_from_gop(&efifb, gop->Mode, gop->Mode->Info); - print_efifb(gop->Mode->Mode, &efifb, 1); - printf("\n"); - } else if (!strcmp(argv[1], "list")) { - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; - UINTN infosz; - - if (argc != 2) - goto usage; - pager_open(); - for (mode = 0; mode < gop->Mode->MaxMode; mode++) { - status = gop->QueryMode(gop, mode, &infosz, &info); - if (EFI_ERROR(status)) - continue; - efifb_from_gop(&efifb, gop->Mode, info); - print_efifb(mode, &efifb, 0); - if (pager_output("\n")) - break; - } - pager_close(); - } - return (CMD_OK); - - usage: - snprintf(command_errbuf, sizeof(command_errbuf), - "usage: %s [list | get | set ]", argv[0]); - return (CMD_ERROR); -} - -COMMAND_SET(uga, "uga", "universal graphics adapter", command_uga); - -static int -command_uga(int argc, char *argv[]) -{ - struct efi_fb efifb; - EFI_UGA_DRAW_PROTOCOL *uga; - EFI_STATUS status; - - status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); - if (EFI_ERROR(status)) { - snprintf(command_errbuf, sizeof(command_errbuf), - "%s: UGA Protocol not present (error=%lu)", - argv[0], EFI_ERROR_CODE(status)); - return (CMD_ERROR); - } - - if (argc != 1) - goto usage; - - if (efifb_from_uga(&efifb, uga) != CMD_OK) { - snprintf(command_errbuf, sizeof(command_errbuf), - "%s: Unable to get UGA information", argv[0]); - return (CMD_ERROR); - } - - print_efifb(-1, &efifb, 1); - printf("\n"); - return (CMD_OK); - - usage: - snprintf(command_errbuf, sizeof(command_errbuf), "usage: %s", argv[0]); - return (CMD_ERROR); -} Property changes on: stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.h =================================================================== --- stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.h (revision 329139) +++ stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.h (nonexistent) @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Benno Rice under sponsorship from - * the FreeBSD Foundation. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _EFIFB_H_ -#define _EFIFB_H_ - -int efi_find_framebuffer(struct efi_fb *efifb); - -#endif /* _EFIFB_H_ */ Property changes on: stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/loader/arch/amd64/Makefile.inc =================================================================== --- stable/11/sys/boot/efi/loader/arch/amd64/Makefile.inc (revision 329139) +++ stable/11/sys/boot/efi/loader/arch/amd64/Makefile.inc (revision 329140) @@ -1,16 +1,15 @@ # $FreeBSD$ SRCS+= amd64_tramp.S \ start.S \ - framebuffer.c \ elf64_freebsd.c \ trap.c \ exc.S -.PATH: ${.CURDIR}/../../i386/libi386 +.PATH: ${BOOTSRC}/i386/libi386 SRCS+= nullconsole.c \ comconsole.c \ spinconsole.c CFLAGS+= -fPIC -DTERM_EMU LDFLAGS+= -Wl,-znocombreloc Index: stable/11/sys/boot/efi/loader/arch/arm/Makefile.inc =================================================================== --- stable/11/sys/boot/efi/loader/arch/arm/Makefile.inc (revision 329139) +++ stable/11/sys/boot/efi/loader/arch/arm/Makefile.inc (revision 329140) @@ -1,6 +1,6 @@ # $FreeBSD$ SRCS+= exec.c \ start.S -LOADER_FDT_SUPPORT=yes +HAVE_FDT=yes Index: stable/11/sys/boot/efi/loader/arch/arm64/Makefile.inc =================================================================== --- stable/11/sys/boot/efi/loader/arch/arm64/Makefile.inc (revision 329139) +++ stable/11/sys/boot/efi/loader/arch/arm64/Makefile.inc (revision 329140) @@ -1,24 +1,12 @@ # $FreeBSD$ -LOADER_FDT_SUPPORT=yes +HAVE_FDT=yes + SRCS+= exec.c \ start.S -.PATH: ${.CURDIR}/../../arm64/libarm64 -CFLAGS+=-I${.CURDIR}/../../arm64/libarm64 +.PATH: ${BOOTSRC}/arm64/libarm64 +CFLAGS+=-I${BOOTSRC}/arm64/libarm64 SRCS+= cache.c CFLAGS+= -mgeneral-regs-only - -CLEANFILES+= loader.help - -loader.help: help.common - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - -.if !defined(LOADER_ONLY) -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -FILES+= loader.rc -.endif Index: stable/11/sys/boot/efi/loader/arch/i386/Makefile.inc =================================================================== --- stable/11/sys/boot/efi/loader/arch/i386/Makefile.inc (revision 329139) +++ stable/11/sys/boot/efi/loader/arch/i386/Makefile.inc (revision 329140) @@ -1,14 +1,14 @@ # $FreeBSD$ SRCS+= start.S \ efimd.c \ elf32_freebsd.c \ exec.c -.PATH: ${.CURDIR}/../../i386/libi386 +.PATH: ${BOOTSRC}/i386/libi386 SRCS+= nullconsole.c \ comconsole.c \ spinconsole.c CFLAGS+= -fPIC -DTERM_EMU LDFLAGS+= -Wl,-znocombreloc Index: stable/11/sys/boot/efi/loader/bootinfo.c =================================================================== --- stable/11/sys/boot/efi/loader/bootinfo.c (revision 329139) +++ stable/11/sys/boot/efi/loader/bootinfo.c (revision 329140) @@ -1,470 +1,471 @@ /*- * Copyright (c) 1998 Michael Smith * Copyright (c) 2004, 2006 Marcel Moolenaar * Copyright (c) 2014 The FreeBSD Foundation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include "bootstrap.h" #include "loader_efi.h" #if defined(__amd64__) #include -#include "framebuffer.h" #endif +#include "framebuffer.h" + #if defined(LOADER_FDT_SUPPORT) #include #endif int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); extern EFI_SYSTEM_TABLE *ST; static const char howto_switches[] = "aCdrgDmphsv"; static int howto_masks[] = { RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE, RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE }; static int bi_getboothowto(char *kargs) { const char *sw; char *opts; char *console; int howto, i; howto = 0; /* Get the boot options from the environment first. */ for (i = 0; howto_names[i].ev != NULL; i++) { if (getenv(howto_names[i].ev) != NULL) howto |= howto_names[i].mask; } console = getenv("console"); if (console != NULL) { if (strcmp(console, "comconsole") == 0) howto |= RB_SERIAL; if (strcmp(console, "nullconsole") == 0) howto |= RB_MUTE; } /* Parse kargs */ if (kargs == NULL) return (howto); opts = strchr(kargs, '-'); while (opts != NULL) { while (*(++opts) != '\0') { sw = strchr(howto_switches, *opts); if (sw == NULL) break; howto |= howto_masks[sw - howto_switches]; } opts = strchr(opts, '-'); } return (howto); } /* * Copy the environment into the load area starting at (addr). * Each variable is formatted as =, with a single nul * separating each variable, and a double nul terminating the environment. */ static vm_offset_t bi_copyenv(vm_offset_t start) { struct env_var *ep; vm_offset_t addr, last; size_t len; addr = last = start; /* Traverse the environment. */ for (ep = environ; ep != NULL; ep = ep->ev_next) { len = strlen(ep->ev_name); if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len) break; addr += len; if (archsw.arch_copyin("=", addr, 1) != 1) break; addr++; if (ep->ev_value != NULL) { len = strlen(ep->ev_value); if ((size_t)archsw.arch_copyin(ep->ev_value, addr, len) != len) break; addr += len; } if (archsw.arch_copyin("", addr, 1) != 1) break; last = ++addr; } if (archsw.arch_copyin("", last++, 1) != 1) last = start; return(last); } /* * Copy module-related data into the load area, where it can be * used as a directory for loaded modules. * * Module data is presented in a self-describing format. Each datum * is preceded by a 32-bit identifier and a 32-bit size field. * * Currently, the following data are saved: * * MOD_NAME (variable) module name (string) * MOD_TYPE (variable) module type (string) * MOD_ARGS (variable) module parameters (string) * MOD_ADDR sizeof(vm_offset_t) module load address * MOD_SIZE sizeof(size_t) module size * MOD_METADATA (variable) type-specific metadata */ #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ archsw.arch_copyin(&x, a, sizeof(x)); \ a += sizeof(x); \ } #define MOD_STR(t, a, s, c) { \ COPY32(t, a, c); \ COPY32(strlen(s) + 1, a, c); \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1); \ a += roundup(strlen(s) + 1, sizeof(u_long)); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) #define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) #define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) #define MOD_VAR(t, a, s, c) { \ COPY32(t, a, c); \ COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ a += roundup(sizeof(s), sizeof(u_long)); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) #define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) #define MOD_METADATA(a, mm, c) { \ COPY32(MODINFO_METADATA | mm->md_type, a, c); \ COPY32(mm->md_size, a, c); \ if (c) \ archsw.arch_copyin(mm->md_data, a, mm->md_size); \ a += roundup(mm->md_size, sizeof(u_long)); \ } #define MOD_END(a, c) { \ COPY32(MODINFO_END, a, c); \ COPY32(0, a, c); \ } static vm_offset_t bi_copymodules(vm_offset_t addr) { struct preloaded_file *fp; struct file_metadata *md; int c; uint64_t v; c = addr != 0; /* Start with the first module on the list, should be the kernel. */ for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { MOD_NAME(addr, fp->f_name, c); /* This must come first. */ MOD_TYPE(addr, fp->f_type, c); if (fp->f_args) MOD_ARGS(addr, fp->f_args, c); v = fp->f_addr; #if defined(__arm__) v -= __elfN(relocation_offset); #endif MOD_ADDR(addr, v, c); v = fp->f_size; MOD_SIZE(addr, v, c); for (md = fp->f_metadata; md != NULL; md = md->md_next) if (!(md->md_type & MODINFOMD_NOCOPY)) MOD_METADATA(addr, md, c); } MOD_END(addr, c); return(addr); } static int bi_load_efi_data(struct preloaded_file *kfp) { EFI_MEMORY_DESCRIPTOR *mm; EFI_PHYSICAL_ADDRESS addr; EFI_STATUS status; size_t efisz; UINTN efi_mapkey; UINTN mmsz, pages, retry, sz; UINT32 mmver; struct efi_map_header *efihdr; -#if defined(__amd64__) +#if defined(__amd64__) || defined(__aarch64__) struct efi_fb efifb; if (efi_find_framebuffer(&efifb) == 0) { printf("EFI framebuffer information:\n"); - printf("addr, size 0x%lx, 0x%lx\n", efifb.fb_addr, + printf("addr, size 0x%jx, 0x%jx\n", efifb.fb_addr, efifb.fb_size); printf("dimensions %d x %d\n", efifb.fb_width, efifb.fb_height); printf("stride %d\n", efifb.fb_stride); printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue, efifb.fb_mask_reserved); file_addmetadata(kfp, MODINFOMD_EFI_FB, sizeof(efifb), &efifb); } #endif efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf; /* * Assgin size of EFI_MEMORY_DESCRIPTOR to keep compatible with * u-boot which doesn't fill this value when buffer for memory * descriptors is too small (eg. 0 to obtain memory map size) */ mmsz = sizeof(EFI_MEMORY_DESCRIPTOR); /* * It is possible that the first call to ExitBootServices may change * the map key. Fetch a new map key and retry ExitBootServices in that * case. */ for (retry = 2; retry > 0; retry--) { /* * Allocate enough pages to hold the bootinfo block and the * memory map EFI will return to us. The memory map has an * unknown size, so we have to determine that first. Note that * the AllocatePages call can itself modify the memory map, so * we have to take that into account as well. The changes to * the memory map are caused by splitting a range of free * memory into two (AFAICT), so that one is marked as being * loader data. */ sz = 0; BS->GetMemoryMap(&sz, NULL, &efi_mapkey, &mmsz, &mmver); sz += mmsz; sz = (sz + 0xf) & ~0xf; pages = EFI_SIZE_TO_PAGES(sz + efisz); status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, pages, &addr); if (EFI_ERROR(status)) { printf("%s: AllocatePages error %lu\n", __func__, EFI_ERROR_CODE(status)); return (ENOMEM); } /* * Read the memory map and stash it after bootinfo. Align the * memory map on a 16-byte boundary (the bootinfo block is page * aligned). */ efihdr = (struct efi_map_header *)addr; mm = (void *)((uint8_t *)efihdr + efisz); sz = (EFI_PAGE_SIZE * pages) - efisz; status = BS->GetMemoryMap(&sz, mm, &efi_mapkey, &mmsz, &mmver); if (EFI_ERROR(status)) { printf("%s: GetMemoryMap error %lu\n", __func__, EFI_ERROR_CODE(status)); return (EINVAL); } status = BS->ExitBootServices(IH, efi_mapkey); if (EFI_ERROR(status) == 0) { efihdr->memory_size = sz; efihdr->descriptor_size = mmsz; efihdr->descriptor_version = mmver; file_addmetadata(kfp, MODINFOMD_EFI_MAP, efisz + sz, efihdr); return (0); } BS->FreePages(addr, pages); } printf("ExitBootServices error %lu\n", EFI_ERROR_CODE(status)); return (EINVAL); } /* * Load the information expected by an amd64 kernel. * * - The 'boothowto' argument is constructed. * - The 'bootdev' argument is constructed. * - The 'bootinfo' struct is constructed, and copied into the kernel space. * - The kernel environment is copied into kernel space. * - Module metadata are formatted and placed in kernel space. */ int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) { struct preloaded_file *xp, *kfp; struct devdesc *rootdev; struct file_metadata *md; vm_offset_t addr; uint64_t kernend; uint64_t envp; vm_offset_t size; char *rootdevname; int howto; #if defined(LOADER_FDT_SUPPORT) vm_offset_t dtbp; int dtb_size; #endif #if defined(__arm__) vm_offset_t vaddr; size_t i; /* * These metadata addreses must be converted for kernel after * relocation. */ uint32_t mdt[] = { MODINFOMD_SSYM, MODINFOMD_ESYM, MODINFOMD_KERNEND, MODINFOMD_ENVP, #if defined(LOADER_FDT_SUPPORT) MODINFOMD_DTBP #endif }; #endif howto = bi_getboothowto(args); /* * Allow the environment variable 'rootdev' to override the supplied * device. This should perhaps go to MI code and/or have $rootdev * tested/set by MI code before launching the kernel. */ rootdevname = getenv("rootdev"); archsw.arch_getdev((void**)(&rootdev), rootdevname, NULL); if (rootdev == NULL) { printf("Can't determine root device.\n"); return(EINVAL); } /* Try reading the /etc/fstab file to select the root device */ getrootmount(efi_fmtdev((void *)rootdev)); addr = 0; for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) { if (addr < (xp->f_addr + xp->f_size)) addr = xp->f_addr + xp->f_size; } /* Pad to a page boundary. */ addr = roundup(addr, PAGE_SIZE); /* Copy our environment. */ envp = addr; addr = bi_copyenv(addr); /* Pad to a page boundary. */ addr = roundup(addr, PAGE_SIZE); #if defined(LOADER_FDT_SUPPORT) /* Handle device tree blob */ dtbp = addr; dtb_size = fdt_copy(addr); /* Pad to a page boundary */ if (dtb_size) addr += roundup(dtb_size, PAGE_SIZE); #endif kfp = file_findfile(NULL, "elf kernel"); if (kfp == NULL) kfp = file_findfile(NULL, "elf64 kernel"); if (kfp == NULL) panic("can't find kernel file"); kernend = 0; /* fill it in later */ file_addmetadata(kfp, MODINFOMD_HOWTO, sizeof howto, &howto); file_addmetadata(kfp, MODINFOMD_ENVP, sizeof envp, &envp); #if defined(LOADER_FDT_SUPPORT) if (dtb_size) file_addmetadata(kfp, MODINFOMD_DTBP, sizeof dtbp, &dtbp); else printf("WARNING! Trying to fire up the kernel, but no " "device tree blob found!\n"); #endif file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend); file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof ST, &ST); bi_load_efi_data(kfp); /* Figure out the size and location of the metadata. */ *modulep = addr; size = bi_copymodules(0); kernend = roundup(addr + size, PAGE_SIZE); *kernendp = kernend; /* patch MODINFOMD_KERNEND */ md = file_findmetadata(kfp, MODINFOMD_KERNEND); bcopy(&kernend, md->md_data, sizeof kernend); #if defined(__arm__) *modulep -= __elfN(relocation_offset); /* Do relocation fixup on metadata of each module. */ for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) { for (i = 0; i < nitems(mdt); i++) { md = file_findmetadata(xp, mdt[i]); if (md) { bcopy(md->md_data, &vaddr, sizeof vaddr); vaddr -= __elfN(relocation_offset); bcopy(&vaddr, md->md_data, sizeof vaddr); } } } #endif /* Copy module list and metadata. */ (void)bi_copymodules(addr); return (0); } Index: stable/11/sys/boot/efi/loader/efi_main.c =================================================================== --- stable/11/sys/boot/efi/loader/efi_main.c (nonexistent) +++ stable/11/sys/boot/efi/loader/efi_main.c (revision 329140) @@ -0,0 +1,188 @@ +/*- + * Copyright (c) 2000 Doug Rabson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +static EFI_PHYSICAL_ADDRESS heap; +static UINTN heapsize; + +void +efi_exit(EFI_STATUS exit_code) +{ + + BS->FreePages(heap, EFI_SIZE_TO_PAGES(heapsize)); + BS->Exit(IH, exit_code, 0, NULL); +} + +void +exit(int status) +{ + + efi_exit(EFI_LOAD_ERROR); +} + +static CHAR16 * +arg_skipsep(CHAR16 *argp) +{ + + while (*argp == ' ' || *argp == '\t' || *argp == '\n') + argp++; + return (argp); +} + +static CHAR16 * +arg_skipword(CHAR16 *argp) +{ + + while (*argp && *argp != ' ' && *argp != '\t' && *argp != '\n') + argp++; + return (argp); +} + +EFI_STATUS +efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) +{ + static EFI_GUID image_protocol = LOADED_IMAGE_PROTOCOL; + static EFI_GUID console_control_protocol = + EFI_CONSOLE_CONTROL_PROTOCOL_GUID; + EFI_CONSOLE_CONTROL_PROTOCOL *console_control = NULL; + EFI_LOADED_IMAGE *img; + CHAR16 *argp, *args, **argv; + EFI_STATUS status; + int argc, addprog; + + IH = image_handle; + ST = system_table; + BS = ST->BootServices; + RS = ST->RuntimeServices; + + status = BS->LocateProtocol(&console_control_protocol, NULL, + (VOID **)&console_control); + if (status == EFI_SUCCESS) + (void)console_control->SetMode(console_control, + EfiConsoleControlScreenText); + + heapsize = 64 * 1024 * 1024; + status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, + EFI_SIZE_TO_PAGES(heapsize), &heap); + if (status != EFI_SUCCESS) + BS->Exit(IH, status, 0, NULL); + + setheap((void *)(uintptr_t)heap, (void *)(uintptr_t)(heap + heapsize)); + + /* Use efi_exit() from here on... */ + + status = BS->HandleProtocol(IH, &image_protocol, (VOID**)&img); + if (status != EFI_SUCCESS) + efi_exit(status); + + /* + * Pre-process the (optional) load options. If the option string + * is given as an ASCII string, we use a poor man's ASCII to + * Unicode-16 translation. The size of the option string as given + * to us includes the terminating null character. We assume the + * string is an ASCII string if strlen() plus the terminating + * '\0' is less than LoadOptionsSize. Even if all Unicode-16 + * characters have the upper 8 bits non-zero, the terminating + * null character will cause a one-off. + * If the string is already in Unicode-16, we make a copy so that + * we know we can always modify the string. + */ + if (img->LoadOptionsSize > 0 && img->LoadOptions != NULL) { + if (img->LoadOptionsSize == strlen(img->LoadOptions) + 1) { + args = malloc(img->LoadOptionsSize << 1); + for (argc = 0; argc < (int)img->LoadOptionsSize; argc++) + args[argc] = ((char*)img->LoadOptions)[argc]; + } else { + args = malloc(img->LoadOptionsSize); + memcpy(args, img->LoadOptions, img->LoadOptionsSize); + } + } else + args = NULL; + + /* + * Use a quick and dirty algorithm to build the argv vector. We + * first count the number of words. Then, after allocating the + * vector, we split the string up. We don't deal with quotes or + * other more advanced shell features. + * The EFI shell will pass the name of the image as the first + * word in the argument list. This does not happen if we're + * loaded by the boot manager. This is not so easy to figure + * out though. The ParentHandle is not always NULL, because + * there can be a function (=image) that will perform the task + * for the boot manager. + */ + /* Part 1: Figure out if we need to add our program name. */ + addprog = (args == NULL || img->ParentHandle == NULL || + img->FilePath == NULL) ? 1 : 0; + if (!addprog) { + addprog = + (DevicePathType(img->FilePath) != MEDIA_DEVICE_PATH || + DevicePathSubType(img->FilePath) != MEDIA_FILEPATH_DP || + DevicePathNodeLength(img->FilePath) <= + sizeof(FILEPATH_DEVICE_PATH)) ? 1 : 0; + if (!addprog) { + /* XXX todo. */ + } + } + /* Part 2: count words. */ + argc = (addprog) ? 1 : 0; + argp = args; + while (argp != NULL && *argp != 0) { + argp = arg_skipsep(argp); + if (*argp == 0) + break; + argc++; + argp = arg_skipword(argp); + } + /* Part 3: build vector. */ + argv = malloc((argc + 1) * sizeof(CHAR16*)); + argc = 0; + if (addprog) + argv[argc++] = (CHAR16 *)L"loader.efi"; + argp = args; + while (argp != NULL && *argp != 0) { + argp = arg_skipsep(argp); + if (*argp == 0) + break; + argv[argc++] = argp; + argp = arg_skipword(argp); + /* Terminate the words. */ + if (*argp != 0) + *argp++ = 0; + } + argv[argc] = NULL; + + status = main(argc, argv); + efi_exit(status); + return (status); +} Property changes on: stable/11/sys/boot/efi/loader/efi_main.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/loader/framebuffer.c =================================================================== --- stable/11/sys/boot/efi/loader/framebuffer.c (nonexistent) +++ stable/11/sys/boot/efi/loader/framebuffer.c (revision 329140) @@ -0,0 +1,568 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Benno Rice under sponsorship from + * the FreeBSD Foundation. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "framebuffer.h" + +static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; +static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID; +static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID; + +static u_int +efifb_color_depth(struct efi_fb *efifb) +{ + uint32_t mask; + u_int depth; + + mask = efifb->fb_mask_red | efifb->fb_mask_green | + efifb->fb_mask_blue | efifb->fb_mask_reserved; + if (mask == 0) + return (0); + for (depth = 1; mask != 1; depth++) + mask >>= 1; + return (depth); +} + +static int +efifb_mask_from_pixfmt(struct efi_fb *efifb, EFI_GRAPHICS_PIXEL_FORMAT pixfmt, + EFI_PIXEL_BITMASK *pixinfo) +{ + int result; + + result = 0; + switch (pixfmt) { + case PixelRedGreenBlueReserved8BitPerColor: + efifb->fb_mask_red = 0x000000ff; + efifb->fb_mask_green = 0x0000ff00; + efifb->fb_mask_blue = 0x00ff0000; + efifb->fb_mask_reserved = 0xff000000; + break; + case PixelBlueGreenRedReserved8BitPerColor: + efifb->fb_mask_red = 0x00ff0000; + efifb->fb_mask_green = 0x0000ff00; + efifb->fb_mask_blue = 0x000000ff; + efifb->fb_mask_reserved = 0xff000000; + break; + case PixelBitMask: + efifb->fb_mask_red = pixinfo->RedMask; + efifb->fb_mask_green = pixinfo->GreenMask; + efifb->fb_mask_blue = pixinfo->BlueMask; + efifb->fb_mask_reserved = pixinfo->ReservedMask; + break; + default: + result = 1; + break; + } + return (result); +} + +static int +efifb_from_gop(struct efi_fb *efifb, EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *mode, + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info) +{ + int result; + + efifb->fb_addr = mode->FrameBufferBase; + efifb->fb_size = mode->FrameBufferSize; + efifb->fb_height = info->VerticalResolution; + efifb->fb_width = info->HorizontalResolution; + efifb->fb_stride = info->PixelsPerScanLine; + result = efifb_mask_from_pixfmt(efifb, info->PixelFormat, + &info->PixelInformation); + return (result); +} + +static ssize_t +efifb_uga_find_pixel(EFI_UGA_DRAW_PROTOCOL *uga, u_int line, + EFI_PCI_IO_PROTOCOL *pciio, uint64_t addr, uint64_t size) +{ + EFI_UGA_PIXEL pix0, pix1; + uint8_t *data1, *data2; + size_t count, maxcount = 1024; + ssize_t ofs; + EFI_STATUS status; + u_int idx; + + status = uga->Blt(uga, &pix0, EfiUgaVideoToBltBuffer, + 0, line, 0, 0, 1, 1, 0); + if (EFI_ERROR(status)) { + printf("UGA BLT operation failed (video->buffer)"); + return (-1); + } + pix1.Red = ~pix0.Red; + pix1.Green = ~pix0.Green; + pix1.Blue = ~pix0.Blue; + pix1.Reserved = 0; + + data1 = calloc(maxcount, 2); + if (data1 == NULL) { + printf("Unable to allocate memory"); + return (-1); + } + data2 = data1 + maxcount; + + ofs = 0; + while (size > 0) { + count = min(size, maxcount); + + status = pciio->Mem.Read(pciio, EfiPciIoWidthUint32, + EFI_PCI_IO_PASS_THROUGH_BAR, addr + ofs, count >> 2, + data1); + if (EFI_ERROR(status)) { + printf("Error reading frame buffer (before)"); + goto fail; + } + status = uga->Blt(uga, &pix1, EfiUgaBltBufferToVideo, + 0, 0, 0, line, 1, 1, 0); + if (EFI_ERROR(status)) { + printf("UGA BLT operation failed (modify)"); + goto fail; + } + status = pciio->Mem.Read(pciio, EfiPciIoWidthUint32, + EFI_PCI_IO_PASS_THROUGH_BAR, addr + ofs, count >> 2, + data2); + if (EFI_ERROR(status)) { + printf("Error reading frame buffer (after)"); + goto fail; + } + status = uga->Blt(uga, &pix0, EfiUgaBltBufferToVideo, + 0, 0, 0, line, 1, 1, 0); + if (EFI_ERROR(status)) { + printf("UGA BLT operation failed (restore)"); + goto fail; + } + for (idx = 0; idx < count; idx++) { + if (data1[idx] != data2[idx]) { + free(data1); + return (ofs + (idx & ~3)); + } + } + ofs += count; + size -= count; + } + printf("No change detected in frame buffer"); + + fail: + printf(" -- error %lu\n", EFI_ERROR_CODE(status)); + free(data1); + return (-1); +} + +static EFI_PCI_IO_PROTOCOL * +efifb_uga_get_pciio(void) +{ + EFI_PCI_IO_PROTOCOL *pciio; + EFI_HANDLE *buf, *hp; + EFI_STATUS status; + UINTN bufsz; + + /* Get all handles that support the UGA protocol. */ + bufsz = 0; + status = BS->LocateHandle(ByProtocol, &uga_guid, NULL, &bufsz, NULL); + if (status != EFI_BUFFER_TOO_SMALL) + return (NULL); + buf = malloc(bufsz); + status = BS->LocateHandle(ByProtocol, &uga_guid, NULL, &bufsz, buf); + if (status != EFI_SUCCESS) { + free(buf); + return (NULL); + } + bufsz /= sizeof(EFI_HANDLE); + + /* Get the PCI I/O interface of the first handle that supports it. */ + pciio = NULL; + for (hp = buf; hp < buf + bufsz; hp++) { + status = BS->HandleProtocol(*hp, &pciio_guid, (void **)&pciio); + if (status == EFI_SUCCESS) { + free(buf); + return (pciio); + } + } + free(buf); + return (NULL); +} + +static EFI_STATUS +efifb_uga_locate_framebuffer(EFI_PCI_IO_PROTOCOL *pciio, uint64_t *addrp, + uint64_t *sizep) +{ + uint8_t *resattr; + uint64_t addr, size; + EFI_STATUS status; + u_int bar; + + if (pciio == NULL) + return (EFI_DEVICE_ERROR); + + /* Attempt to get the frame buffer address (imprecise). */ + *addrp = 0; + *sizep = 0; + for (bar = 0; bar < 6; bar++) { + status = pciio->GetBarAttributes(pciio, bar, NULL, + (void **)&resattr); + if (status != EFI_SUCCESS) + continue; + /* XXX magic offsets and constants. */ + if (resattr[0] == 0x87 && resattr[3] == 0) { + /* 32-bit address space descriptor (MEMIO) */ + addr = le32dec(resattr + 10); + size = le32dec(resattr + 22); + } else if (resattr[0] == 0x8a && resattr[3] == 0) { + /* 64-bit address space descriptor (MEMIO) */ + addr = le64dec(resattr + 14); + size = le64dec(resattr + 38); + } else { + addr = 0; + size = 0; + } + BS->FreePool(resattr); + if (addr == 0 || size == 0) + continue; + + /* We assume the largest BAR is the frame buffer. */ + if (size > *sizep) { + *addrp = addr; + *sizep = size; + } + } + return ((*addrp == 0 || *sizep == 0) ? EFI_DEVICE_ERROR : 0); +} + +static int +efifb_from_uga(struct efi_fb *efifb, EFI_UGA_DRAW_PROTOCOL *uga) +{ + EFI_PCI_IO_PROTOCOL *pciio; + char *ev, *p; + EFI_STATUS status; + ssize_t offset; + uint64_t fbaddr; + uint32_t horiz, vert, stride; + uint32_t np, depth, refresh; + + status = uga->GetMode(uga, &horiz, &vert, &depth, &refresh); + if (EFI_ERROR(status)) + return (1); + efifb->fb_height = vert; + efifb->fb_width = horiz; + /* Paranoia... */ + if (efifb->fb_height == 0 || efifb->fb_width == 0) + return (1); + + /* The color masks are fixed AFAICT. */ + efifb_mask_from_pixfmt(efifb, PixelBlueGreenRedReserved8BitPerColor, + NULL); + + /* pciio can be NULL on return! */ + pciio = efifb_uga_get_pciio(); + + /* Try to find the frame buffer. */ + status = efifb_uga_locate_framebuffer(pciio, &efifb->fb_addr, + &efifb->fb_size); + if (EFI_ERROR(status)) { + efifb->fb_addr = 0; + efifb->fb_size = 0; + } + + /* + * There's no reliable way to detect the frame buffer or the + * offset within the frame buffer of the visible region, nor + * the stride. Our only option is to look at the system and + * fill in the blanks based on that. Luckily, UGA was mostly + * only used on Apple hardware. + */ + offset = -1; + ev = getenv("smbios.system.maker"); + if (ev != NULL && !strcmp(ev, "Apple Inc.")) { + ev = getenv("smbios.system.product"); + if (ev != NULL && !strcmp(ev, "iMac7,1")) { + /* These are the expected values we should have. */ + horiz = 1680; + vert = 1050; + fbaddr = 0xc0000000; + /* These are the missing bits. */ + offset = 0x10000; + stride = 1728; + } else if (ev != NULL && !strcmp(ev, "MacBook3,1")) { + /* These are the expected values we should have. */ + horiz = 1280; + vert = 800; + fbaddr = 0xc0000000; + /* These are the missing bits. */ + offset = 0x0; + stride = 2048; + } + } + + /* + * If this is hardware we know, make sure that it looks familiar + * before we accept our hardcoded values. + */ + if (offset >= 0 && efifb->fb_width == horiz && + efifb->fb_height == vert && efifb->fb_addr == fbaddr) { + efifb->fb_addr += offset; + efifb->fb_size -= offset; + efifb->fb_stride = stride; + return (0); + } else if (offset >= 0) { + printf("Hardware make/model known, but graphics not " + "as expected.\n"); + printf("Console may not work!\n"); + } + + /* + * The stride is equal or larger to the width. Often it's the + * next larger power of two. We'll start with that... + */ + efifb->fb_stride = efifb->fb_width; + do { + np = efifb->fb_stride & (efifb->fb_stride - 1); + if (np) { + efifb->fb_stride |= (np - 1); + efifb->fb_stride++; + } + } while (np); + + ev = getenv("hw.efifb.address"); + if (ev == NULL) { + if (efifb->fb_addr == 0) { + printf("Please set hw.efifb.address and " + "hw.efifb.stride.\n"); + return (1); + } + + /* + * The visible part of the frame buffer may not start at + * offset 0, so try to detect it. Note that we may not + * always be able to read from the frame buffer, which + * means that we may not be able to detect anything. In + * that case, we would take a long time scanning for a + * pixel change in the frame buffer, which would have it + * appear that we're hanging, so we limit the scan to + * 1/256th of the frame buffer. This number is mostly + * based on PR 202730 and the fact that on a MacBoook, + * where we can't read from the frame buffer the offset + * of the visible region is 0. In short: we want to scan + * enough to handle all adapters that have an offset + * larger than 0 and we want to scan as little as we can + * to not appear to hang when we can't read from the + * frame buffer. + */ + offset = efifb_uga_find_pixel(uga, 0, pciio, efifb->fb_addr, + efifb->fb_size >> 8); + if (offset == -1) { + printf("Unable to reliably detect frame buffer.\n"); + } else if (offset > 0) { + efifb->fb_addr += offset; + efifb->fb_size -= offset; + } + } else { + offset = 0; + efifb->fb_size = efifb->fb_height * efifb->fb_stride * 4; + efifb->fb_addr = strtoul(ev, &p, 0); + if (*p != '\0') + return (1); + } + + ev = getenv("hw.efifb.stride"); + if (ev == NULL) { + if (pciio != NULL && offset != -1) { + /* Determine the stride. */ + offset = efifb_uga_find_pixel(uga, 1, pciio, + efifb->fb_addr, horiz * 8); + if (offset != -1) + efifb->fb_stride = offset >> 2; + } else { + printf("Unable to reliably detect the stride.\n"); + } + } else { + efifb->fb_stride = strtoul(ev, &p, 0); + if (*p != '\0') + return (1); + } + + /* + * We finalized on the stride, so recalculate the size of the + * frame buffer. + */ + efifb->fb_size = efifb->fb_height * efifb->fb_stride * 4; + return (0); +} + +int +efi_find_framebuffer(struct efi_fb *efifb) +{ + EFI_GRAPHICS_OUTPUT *gop; + EFI_UGA_DRAW_PROTOCOL *uga; + EFI_STATUS status; + + status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); + if (status == EFI_SUCCESS) + return (efifb_from_gop(efifb, gop->Mode, gop->Mode->Info)); + + status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); + if (status == EFI_SUCCESS) + return (efifb_from_uga(efifb, uga)); + + return (1); +} + +static void +print_efifb(int mode, struct efi_fb *efifb, int verbose) +{ + u_int depth; + + if (mode >= 0) + printf("mode %d: ", mode); + depth = efifb_color_depth(efifb); + printf("%ux%ux%u, stride=%u", efifb->fb_width, efifb->fb_height, + depth, efifb->fb_stride); + if (verbose) { + printf("\n frame buffer: address=%jx, size=%jx", + (uintmax_t)efifb->fb_addr, (uintmax_t)efifb->fb_size); + printf("\n color mask: R=%08x, G=%08x, B=%08x\n", + efifb->fb_mask_red, efifb->fb_mask_green, + efifb->fb_mask_blue); + } +} + +COMMAND_SET(gop, "gop", "graphics output protocol", command_gop); + +static int +command_gop(int argc, char *argv[]) +{ + struct efi_fb efifb; + EFI_GRAPHICS_OUTPUT *gop; + EFI_STATUS status; + u_int mode; + + status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); + if (EFI_ERROR(status)) { + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: Graphics Output Protocol not present (error=%lu)", + argv[0], EFI_ERROR_CODE(status)); + return (CMD_ERROR); + } + + if (argc < 2) + goto usage; + + if (!strcmp(argv[1], "set")) { + char *cp; + + if (argc != 3) + goto usage; + mode = strtol(argv[2], &cp, 0); + if (cp[0] != '\0') { + sprintf(command_errbuf, "mode is an integer"); + return (CMD_ERROR); + } + status = gop->SetMode(gop, mode); + if (EFI_ERROR(status)) { + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: Unable to set mode to %u (error=%lu)", + argv[0], mode, EFI_ERROR_CODE(status)); + return (CMD_ERROR); + } + } else if (!strcmp(argv[1], "get")) { + if (argc != 2) + goto usage; + efifb_from_gop(&efifb, gop->Mode, gop->Mode->Info); + print_efifb(gop->Mode->Mode, &efifb, 1); + printf("\n"); + } else if (!strcmp(argv[1], "list")) { + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; + UINTN infosz; + + if (argc != 2) + goto usage; + pager_open(); + for (mode = 0; mode < gop->Mode->MaxMode; mode++) { + status = gop->QueryMode(gop, mode, &infosz, &info); + if (EFI_ERROR(status)) + continue; + efifb_from_gop(&efifb, gop->Mode, info); + print_efifb(mode, &efifb, 0); + if (pager_output("\n")) + break; + } + pager_close(); + } + return (CMD_OK); + + usage: + snprintf(command_errbuf, sizeof(command_errbuf), + "usage: %s [list | get | set ]", argv[0]); + return (CMD_ERROR); +} + +COMMAND_SET(uga, "uga", "universal graphics adapter", command_uga); + +static int +command_uga(int argc, char *argv[]) +{ + struct efi_fb efifb; + EFI_UGA_DRAW_PROTOCOL *uga; + EFI_STATUS status; + + status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); + if (EFI_ERROR(status)) { + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: UGA Protocol not present (error=%lu)", + argv[0], EFI_ERROR_CODE(status)); + return (CMD_ERROR); + } + + if (argc != 1) + goto usage; + + if (efifb_from_uga(&efifb, uga) != CMD_OK) { + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: Unable to get UGA information", argv[0]); + return (CMD_ERROR); + } + + print_efifb(-1, &efifb, 1); + printf("\n"); + return (CMD_OK); + + usage: + snprintf(command_errbuf, sizeof(command_errbuf), "usage: %s", argv[0]); + return (CMD_ERROR); +} Property changes on: stable/11/sys/boot/efi/loader/framebuffer.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/efi/loader/framebuffer.h =================================================================== --- stable/11/sys/boot/efi/loader/framebuffer.h (nonexistent) +++ stable/11/sys/boot/efi/loader/framebuffer.h (revision 329140) @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Benno Rice under sponsorship from + * the FreeBSD Foundation. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _EFIFB_H_ +#define _EFIFB_H_ + +int efi_find_framebuffer(struct efi_fb *efifb); + +#endif /* _EFIFB_H_ */ Property changes on: stable/11/sys/boot/efi/loader/framebuffer.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/fdt/Makefile =================================================================== --- stable/11/sys/boot/fdt/Makefile (revision 329139) +++ stable/11/sys/boot/fdt/Makefile (revision 329140) @@ -1,30 +1,28 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../contrib/libfdt/ +.include +.PATH: ${SYSDIR}/contrib/libfdt/ + LIB= fdt INTERNALLIB= # Vendor sources of libfdt. SRCS+= fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \ fdt_empty_tree.c fdt_addresses.c fdt_overlay.c # Loader's fdt commands extension sources. SRCS+= fdt_loader_cmd.c -CFLAGS+= -I${.CURDIR}/../../contrib/libfdt/ -I${.CURDIR}/../common/ +CFLAGS+= -I${SYSDIR}/contrib/libfdt/ -I${LDRSRC} CFLAGS+= -ffreestanding .if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" CFLAGS+= -msoft-float -.endif - -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 .endif CFLAGS+= -Wformat -Wall .include .include Index: stable/11/sys/boot/fdt.mk =================================================================== --- stable/11/sys/boot/fdt.mk (nonexistent) +++ stable/11/sys/boot/fdt.mk (revision 329140) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.if ${MK_FDT} == "yes" +CFLAGS+= -I${FDTSRC} +CFLAGS+= -I${BOOTOBJ}/fdt +CFLAGS+= -I${SYSDIR}/contrib/libfdt +CFLAGS+= -DLOADER_FDT_SUPPORT +LIBFDT= ${BOOTOBJ}/fdt/libfdt.a +.endif Property changes on: stable/11/sys/boot/fdt.mk ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/ficl/Makefile =================================================================== --- stable/11/sys/boot/ficl/Makefile (revision 329139) +++ stable/11/sys/boot/ficl/Makefile (revision 329140) @@ -1,39 +1,32 @@ # $FreeBSD$ # -.include "../ficl.mk" +.include +.include "${BOOTSRC}/ficl.mk" BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c math64.c \ prefix.c search.c stack.c tools.c vm.c words.c SRCS= ${BASE_SRCS} sysdep.c softcore.c -CLEANFILES= softcore.c testmain testmain.o -.if ${MACHINE_CPUARCH} == "i386" || \ - (${MACHINE_CPUARCH} == "amd64" && defined(FICL32)) -CFLAGS+= -march=i386 -.endif -.if HAVE_PNP -CFLAGS+= -DHAVE_PNP -.endif +CLEANFILES+= softcore.c testmain testmain.o + .include .ifmake testmain CFLAGS+= -DTESTMAIN -D_TESTMAIN SRCS+= testmain.c PROG= testmain .include .else LIB= ficl INTERNALLIB= .include .endif # Standard softwords -.PATH: ${FICLDIR}/softwords +.PATH: ${FICLSRC}/softwords SOFTWORDS= softcore.fr jhlocal.fr marker.fr freebsd.fr ficllocal.fr \ ifbrack.fr -# Optional OO extension softwords -#SOFTWORDS+= oo.fr classes.fr softcore.c: ${SOFTWORDS} softcore.awk - (cd ${FICLDIR}/softwords; cat ${SOFTWORDS} \ + (cd ${FICLSRC}/softwords; cat ${SOFTWORDS} \ | awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET} Index: stable/11/sys/boot/ficl.mk =================================================================== --- stable/11/sys/boot/ficl.mk (revision 329139) +++ stable/11/sys/boot/ficl.mk (revision 329140) @@ -1,43 +1,23 @@ # $FreeBSD$ # Common flags to build FICL related files -FICLDIR?= ${SRCTOP}/sys/boot/ficl +.include "defs.mk" -.if ${MACHINE_CPUARCH} == "amd64" && defined(FICL32) +.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1 FICL_CPUARCH= i386 .elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" FICL_CPUARCH= mips64 .else FICL_CPUARCH= ${MACHINE_CPUARCH} .endif -.PATH: ${FICLDIR} ${FICLDIR}/${FICL_CPUARCH} +.PATH: ${FICLSRC} ${FICLSRC}/${FICL_CPUARCH} -.if ${MACHINE_CPUARCH} == "amd64" -.if defined(FICL32) -CFLAGS+= -m32 -I. -.else +.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0 CFLAGS+= -fPIC .endif -.endif -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -I. -.endif - -CFLAGS+= -I${FICLDIR} -I${FICLDIR}/${FICL_CPUARCH} \ - -I${FICLDIR}/../common - -.if ${MACHINE_CPUARCH} == "amd64" && defined(FICL32) -.if !exists(machine) -${SRCS:M*.c:R:S/$/.o/g}: machine - -beforedepend ${OBJS}: machine -.endif - -machine: .NOMETA - ln -sf ${.CURDIR}/../../i386/include machine - -CLEANFILES+= machine -.endif +CFLAGS+= -I${FICLSRC} -I${FICLSRC}/${FICL_CPUARCH} -I${LDRSRC} +CFLAGS+= -DBOOT_FORTH +CFLAGS+= -DBF_DICTSIZE=15000 Index: stable/11/sys/boot/ficl32/Makefile =================================================================== --- stable/11/sys/boot/ficl32/Makefile (revision 329139) +++ stable/11/sys/boot/ficl32/Makefile (revision 329140) @@ -1,5 +1,5 @@ # $FreeBSD$ -FICL32= +DO32=1 .include "${.CURDIR}/../ficl/Makefile" Index: stable/11/sys/boot/forth/Makefile.inc =================================================================== --- stable/11/sys/boot/forth/Makefile.inc (revision 329139) +++ stable/11/sys/boot/forth/Makefile.inc (nonexistent) @@ -1,26 +0,0 @@ -# $FreeBSD$ - -FILES+= beastie.4th -FILES+= brand.4th -FILES+= brand-fbsd.4th -FILES+= check-password.4th -FILES+= color.4th -FILES+= delay.4th -FILES+= efi.4th -FILES+= frames.4th -FILES+= loader.4th -FILES+= loader.conf -FILES+= loader.help -FILES+= logo-beastie.4th -FILES+= logo-beastiebw.4th -FILES+= logo-fbsdbw.4th -FILES+= logo-orb.4th -FILES+= logo-orbbw.4th -FILES+= menu.4th -FILES+= menu-commands.4th -FILES+= menusets.4th -FILES+= screen.4th -FILES+= shortcuts.4th -FILES+= support.4th -FILES+= version.4th -FILESDIR_loader.conf= /boot/defaults Property changes on: stable/11/sys/boot/forth/Makefile.inc ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/forth/Makefile =================================================================== --- stable/11/sys/boot/forth/Makefile (revision 329139) +++ stable/11/sys/boot/forth/Makefile (revision 329140) @@ -1,14 +1,49 @@ # $FreeBSD$ +.include + MAN+= beastie.4th.8 \ brand.4th.8 \ check-password.4th.8 \ color.4th.8 \ delay.4th.8 \ loader.conf.5 \ loader.4th.8 \ menu.4th.8 \ menusets.4th.8 \ version.4th.8 + +FILES+= beastie.4th +FILES+= brand.4th +FILES+= brand-fbsd.4th +FILES+= check-password.4th +FILES+= color.4th +FILES+= delay.4th +FILES+= efi.4th +FILES+= frames.4th +FILES+= loader.4th +FILES+= logo-beastie.4th +FILES+= logo-beastiebw.4th +FILES+= logo-fbsdbw.4th +FILES+= logo-orb.4th +FILES+= logo-orbbw.4th +FILES+= menu.4th +FILES+= menu-commands.4th +FILES+= menusets.4th +FILES+= pcibios.4th +FILES+= screen.4th +FILES+= shortcuts.4th +FILES+= support.4th +FILES+= version.4th +FILESDIR_loader.conf= /boot/defaults + +# Allow machine specific loader.rc to be installed. +.for f in loader.rc menu.rc loader.conf +.if exists(${BOOTSRC}/${MACHINE:C/amd64/i386/}/loader/${f}) +FILES+= ${BOOTSRC}/${MACHINE:C/amd64/i386/}/loader/${f} +.else +FILES+= ${f} +.endif +.endfor .include Index: stable/11/sys/boot/forth/loader.conf =================================================================== --- stable/11/sys/boot/forth/loader.conf (revision 329139) +++ stable/11/sys/boot/forth/loader.conf (revision 329140) @@ -1,575 +1,575 @@ # This is loader.conf - a file full of useful variables that you can # set to change the default load behavior of your system. You should # not edit this file! Put any overrides into one of the # loader_conf_files instead and you will be able to update these # defaults later without spamming your local configuration information. # # All arguments must be in double quotes. # # $FreeBSD$ ############################################################## ### Basic configuration options ############################ ############################################################## exec="echo Loading /boot/defaults/loader.conf" kernel="kernel" # /boot sub-directory containing kernel and modules bootfile="kernel" # Kernel name (possibly absolute path) kernel_options="" # Flags to be passed to the kernel loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local" nextboot_conf="/boot/nextboot.conf" nextboot_enable="NO" verbose_loading="NO" # Set to YES for verbose loader output ############################################################## ### Splash screen configuration ############################ ############################################################## splash_bmp_load="NO" # Set this to YES for bmp splash screen! splash_pcx_load="NO" # Set this to YES for pcx splash screen! splash_txt_load="NO" # Set this to YES for TheDraw splash screen! vesa_load="NO" # Set this to YES to load the vesa module bitmap_load="NO" # Set this to YES if you want splash screen! bitmap_name="splash.bmp" # Set this to the name of the file bitmap_type="splash_image_data" # and place it on the module_path ############################################################## ### Random number generator configuration ################## ############################################################## # See rc.conf(5). The entropy_boot_file config variable must agree with the # settings below. entropy_cache_load="YES" # Set this to NO to disable loading # entropy at boot time entropy_cache_name="/boot/entropy" # Set this to the name of the file entropy_cache_type="/boot/entropy" # Required for the kernel to find # the boot-time entropy cache. This # must not change value even if the # _name above does change! ############################################################## ### RAM Blacklist configuration ############################ ############################################################## ram_blacklist_load="NO" # Set this to YES to load a file # containing a list of addresses to # exclude from the running system. ram_blacklist_name="/boot/blacklist.txt" # Set this to the name of the file ram_blacklist_type="ram_blacklist" # Required for the kernel to find # the blacklist module ############################################################## ### Initial memory disk settings ########################### ############################################################## #mdroot_load="YES" # The "mdroot" prefix is arbitrary. #mdroot_type="md_image" # Create md(4) disk at boot. #mdroot_name="/boot/root.img" # Path to a file containing the image. #rootdev="ufs:/dev/md0" # Set the root filesystem to md(4) device. ############################################################## ### Loader settings ######################################## ############################################################## #loader_delay="3" # Delay in seconds before loading anything. # Default is unset and disabled (no delay). #autoboot_delay="10" # Delay in seconds before autobooting, # set to -1 if you don't want user to be # allowed to interrupt autoboot process and # escape to the loader prompt, set to # "NO" to disable autobooting #password="" # Prevent changes to boot options #bootlock_password="" # Prevent booting (see check-password.4th(8)) #geom_eli_passphrase_prompt="NO" # Prompt for geli(8) passphrase to mount root bootenv_autolist="YES" # Auto populate the list of ZFS Boot Environments #beastie_disable="NO" # Turn the beastie boot menu on and off #kernels="kernel kernel.old" # Kernels to display in the boot menu #loader_logo="orbbw" # Desired logo: orbbw, orb, fbsdbw, beastiebw, beastie, none #comconsole_speed="9600" # Set the current serial console speed #console="vidconsole" # A comma separated list of console(s) #currdev="disk1s1a" # Set the current device -module_path="/boot/modules" # Set the module search path +module_path="/boot/modules;/boot/dtb" # Set the module search path #prompt="\\${interpret}" # Set the command prompt #root_disk_unit="0" # Force the root disk unit number #rootdev="disk1s1a" # Set the root filesystem #dumpdev="disk1s1b" # Set a dump device early in the boot process #tftp.blksize="1428" # Set the RFC 2348 TFTP block size. # If the TFTP server does not support RFC 2348, # the block size is set to 512. If the value # is out of range ( < 8 || > 9008 ) an error is # returned. #twiddle_divisor="1" # >1 means slow down the progress indicator. ############################################################## ### Kernel settings ######################################## ############################################################## # The following boot_ variables are enabled by setting them to any value. # Their presence in the kernel environment (see kenv(1)) has the same # effect as setting the given boot flag (see boot(8)). #boot_askname="" # -a: Prompt the user for the name of the root device #boot_cdrom="" # -C: Attempt to mount root file system from CD-ROM #boot_ddb="" # -d: Instructs the kernel to start in the DDB debugger #boot_dfltroot="" # -r: Use the statically configured root file system #boot_gdb="" # -g: Selects gdb-remote mode for the kernel debugger #boot_multicons="" # -D: Use multiple consoles #boot_mute="" # -m: Mute the console #boot_pause="" # -p: Pause after each line during device probing #boot_serial="" # -h: Use serial console #boot_single="" # -s: Start system in single-user mode #boot_verbose="" # -v: Causes extra debugging information to be printed #init_path="/sbin/init:/sbin/oinit:/sbin/init.bak:/rescue/init" # Sets the list of init candidates #init_shell="/bin/sh" # The shell binary used by init(8). #init_script="" # Initial script to run by init(8) before chrooting. #init_chroot="" # Directory for init(8) to chroot into. ############################################################## ### Kernel tunables ######################################## ############################################################## #hw.physmem="1G" # Limit physical memory. See loader(8) #kern.dfldsiz="" # Set the initial data size limit #kern.dflssiz="" # Set the initial stack size limit #kern.hz="100" # Set the kernel interval timer rate #kern.maxbcache="" # Set the max buffer cache KVA storage #kern.maxdsiz="" # Set the max data size #kern.maxfiles="" # Set the sys. wide open files limit #kern.maxproc="" # Set the maximum # of processes #kern.maxssiz="" # Set the max stack size #kern.maxswzone="" # Set the max swmeta KVA storage #kern.maxtsiz="" # Set the max text size #kern.maxusers="32" # Set size of various static tables #kern.msgbufsize="65536" # Set size of kernel message buffer #kern.nbuf="" # Set the number of buffer headers #kern.ncallout="" # Set the maximum # of timer events #kern.ngroups="1023" # Set the maximum # of supplemental groups #kern.sgrowsiz="" # Set the amount to grow stack #kern.cam.boot_delay="10000" # Delay (in ms) of root mount for CAM bus # registration, useful for USB sticks as root #kern.cam.scsi_delay="2000" # Delay (in ms) before probing SCSI #kern.ipc.maxsockets="" # Set the maximum number of sockets available #kern.ipc.nmbclusters="" # Set the number of mbuf clusters #kern.ipc.nsfbufs="" # Set the number of sendfile(2) bufs #net.inet.tcp.tcbhashsize="" # Set the value of TCBHASHSIZE #vfs.root.mountfrom="" # Specify root partition in a way the # kernel understands #vm.kmem_size="" # Sets the size of kernel memory (bytes) #debug.kdb.break_to_debugger="0" # Allow console to break into debugger. #debug.ktr.cpumask="0xf" # Bitmask of CPUs to enable KTR on #debug.ktr.mask="0x1200" # Bitmask of KTR events to enable #debug.ktr.verbose="1" # Enable console dump of KTR events #net.graph.maxalloc="128" # Maximum number of queue items to allocate ############################################################## ### ATA modules ############################################ ############################################################## ataacard_load="NO" # ACARD ataacerlabs_load="NO" # Acer Labs Inc. (ALI) ataamd_load="NO" # American Micro Devices (AMD) ataati_load="NO" # ATI atacenatek_load="NO" # Cenatek atacypress_load="NO" # Cypress atacyrix_load="NO" # Cyrix atahighpoint_load="NO" # HighPoint ataintel_load="NO" # Intel ataite_load="NO" # Integrated Technology Inc. (ITE) atajmicron_load="NO" # JMicron atamarvell_load="NO" # Marvell atamicron_load="NO" # Micron atanational_load="NO" # National atanetcell_load="NO" # NetCell atanvidia_load="NO" # nVidia atapromise_load="NO" # Promise ataserverworks_load="NO" # ServerWorks atasiliconimage_load="NO" # Silicon Image Inc. (SiI) (formerly CMD) atasis_load="NO" # Silicon Integrated Systems Corp.(SiS) atavia_load="NO" # VIA Technologies Inc. ############################################################## ### Filesystem and related modules ######################### ############################################################## # Filesystems cd9660_load="NO" # ISO 9660 filesystem fdescfs_load="NO" # Filedescriptors filesystem linprocfs_load="NO" # Linux compatibility process filesystem linsysfs_load="NO" # Linux compatibility system filesystem msdosfs_load="NO" # FAT-12/16/32 nfsclient_load="NO" # NFS client nfsserver_load="NO" # NFS server nullfs_load="NO" # Null filesystem procfs_load="NO" # Process filesystem unionfs_load="NO" # Union filesystem zfs_load="NO" # ZFS # Related stuff geom_bde_load="NO" # Disk encryption driver (see gbde(4,8)) geom_ccd_load="NO" # Concatenated disk driver (see ccd(4), # ccdconfig(8)) geom_concat_load="NO" # Concatenated disk driver (see gconcat(8)) geom_eli_load="NO" # Disk encryption driver (see geli(8)) geom_gate_load="NO" # Userland disk driver (see geom_gate(4), # ggatec(8), ggated(8), ggatel(8)) geom_journal_load="NO" # Journaled filesystem driver (see gjournal(8)) geom_label_load="NO" # File system labels (see glabel(8)) geom_md_load="NO" # Memory disk driver (vnode/swap/malloc) (see # md(4), mdconfig(8)) geom_mirror_load="NO" # RAID1 disk driver (see gmirror(8)) geom_mountver_load="NO" # Mount verification disk driver geom_nop_load="NO" # Transparent disk driver (see gnop(8)) geom_raid3_load="NO" # RAID3 disk driver (see graid3(8)) geom_shsec_load="NO" # Shared secret disk driver (see gshsec(8)) geom_stripe_load="NO" # RAID0 disk driver (see gstripe(8)) geom_uzip_load="NO" # Compressed disk images driver (see mkuzip(8)) geom_vinum_load="NO" # Concatenated/mirror/raid driver (see vinum(4)) ############################################################## ### FireWire modules ####################################### ############################################################## firewire_load="NO" # IEEE1394 High-performance Serial Bus fwe_load="NO" # Ethernet emulation driver for FireWire fwip_load="NO" # IP over FireWire driver fwohci_load="NO" # OHCI FireWire chipset device driver sbp_load="NO" # SBP-2 Mass Storage Devices driver sbp_targ_load="NO" # SBP-2 Target mode ############################################################## ### Screen saver modules ################################### ############################################################## # This is best done in rc.conf screensave_load="NO" # Set to YES to load a screensaver module screensave_name="green_saver" # Set to the name of the screensaver module ############################################################## ### Emulation modules ###################################### ############################################################## cloudabi_load="NO" # Platform independent CloudABI support cloudabi64_load="NO" # 64-bit CloudABI executables support ibcs2_load="NO" # IBCS2 (SCO) emulation ibcs2_coff_load="NO" linux_load="NO" # Linux emulation svr4_load="NO" # SystemV R4 emulation streams_load="NO" # System V streams module ############################################################## ### Networking modules ##################################### ############################################################## if_disc_load="NO" # Discard device if_ef_load="NO" # pseudo-device providing support for multiple # ethernet frame types if_epair_load="NO" # Virtual b-t-b Ethernet-like interface pair if_gif_load="NO" # generic tunnel interface if_gre_load="NO" # encapsulating network device if_stf_load="NO" # 6to4 tunnel interface if_tap_load="NO" # Ethernet tunnel software network interface if_tun_load="NO" # Tunnel driver (user process ppp) if_vlan_load="NO" # IEEE 802.1Q VLAN network interface ipfw_load="NO" # Firewall pf_load="NO" # packet filter ############################################################## ### Networking drivers ##################################### ############################################################## bridgestp_load="NO" # if_bridge(4) support miibus_load="NO" # miibus support, needed for some drivers carp_load="NO" # carp(4) protocol if_ae_load="NO" # Attansic/Atheros L2 FastEthernet if_age_load="NO" # Attansic/Atheros L1 Gigabit Ethernet if_alc_load="NO" # Atheros AR8131/AR8132 Ethernet if_ale_load="NO" # Atheros AR8121/AR8113/AR8114 Ethernet if_an_load="NO" # Aironet 4500/4800 802.11 wireless NICs if_ath_load="NO" # Atheros IEEE 802.11 wireless NICs if_aue_load="NO" # ADMtek AN986 Pegasus USB Ethernet if_axe_load="NO" # ASIX Electronics AX88172 USB Ethernet if_bce_load="NO" # Broadcom NetXtreme II Gigabit Ethernet if_bfe_load="NO" # Broadcom BCM4401 if_bge_load="NO" # Broadcom BCM570x PCI Gigabit Ethernet if_bnxt_load="NO" # Broadcom NetXtreme-C/NetXtreme-E if_bridge_load="NO" # if_bridge(4) devices if_bwi_load="NO" # Broadcom BCM53xx IEEE 802.11b/g wireness NICs if_bwn_load="NO" # Broadcom BCM43xx IEEE 802.11 wireless NICs if_bxe_load="NO" # Broadcom NetXtreme II 10Gb Ethernet if_cas_load="NO" # Sun Cassini/Cassini+ and NS DP83065 Saturn if_cm_load="NO" # SMC (90c26, 90c56, 90c66) if_cs_load="NO" # Crystal Semiconductor CS8920 if_cue_load="NO" # CATC USB-EL1210A USB Ethernet if_cxgb_load="NO" # Chelsio T3 10 Gigabit Ethernet if_cxgbe_load="NO" # Chelsio T4/T5/T6 1/10/25/40/100 Gigabit Ethernet if_dc_load="NO" # DEC/Intel 21143 and various workalikes if_de_load="NO" # DEC DC21x4x Ethernet if_ed_load="NO" # National Semiconductor DS8390/WD83C690 # Ethernet if_em_load="NO" # Intel(R) PRO/1000 Gigabit Ethernet if_en_load="NO" # Midway-based ATM interfaces if_ep_load="NO" # 3Com Etherlink III (3c5x9) if_et_load="NO" # Agere ET1310 10/100/Gigabit Ethernet if_ex_load="NO" # Intel EtherExpress Pro/10 Ethernet if_fatm_load="NO" # Fore PCA200E ATM if_fe_load="NO" # Fujitsu MB86960A/MB86965A based Ethernet # adapters if_fxp_load="NO" # Intel EtherExpress PRO/100B (82557, 82558) if_gem_load="NO" # Sun GEM/Sun ERI/Apple GMAC if_hatm_load="NO" # Fore/Marconi HE155 and HE622 if_hme_load="NO" # Sun Microelectronics STP2002-STQ Ethernet if_ie_load="NO" # Intel 82586 if_igb_load="NO" # Intel(R) PRO/1000 Gigabit Ethernet if_ipw_load="NO" # Intel PRO/Wireless 2100 wireless if_iwi_load="NO" # Intel PRO/Wireless 2200BG/2225BG/2915ABG # wireless if_iwn_load="NO" # Intel Wireless WiFi Link 802.11n wireless if_ixgb_load="NO" # Intel PRO/10Gb Ethernet if_ixgbe_load="NO" # Intel PRO/10Gb Ethernet PCI Express if_ixl_load="NO" # Intel XL710 Ethernet 40Gb Base driver if_ixlv_load="NO" # Intel XL710 Ethernet 40Gb VF driver if_jme_load="NO" # JMicron JMC250 Gigabit/JMC260 Fast Ethernet if_lagg_load="NO" # lagg(4) devices if_le_load="NO" # AMD Am7900 LANCE and Am79C9xx PCnet if_lge_load="NO" # Level 1 LXT1001 NetCellerator PCI Gigabit # Ethernet if_malo_load="NO" # Marvell Libertas 88W8335 802.11 wireless # adapter if_msk_load="NO" # Marvell/SysKonnect Yukon II Gigabit Ethernet if_mxge_load="NO" # Myricom Myri10GE 10Gb Ethernet if_my_load="NO" # Myson PCI Fast Ethernet if_nfe_load="NO" # NVIDIA nForce MCP Networking Adapter if_nge_load="NO" # National Semiconductor PCI Gigabit Ethernet if_nxge_load="NO" # Neterion Xframe 10Gb Ethernet if_patm_load="NO" # IDT77252 ATM if_pcn_load="NO" # AMD PCnet PCI if_ral_load="NO" # Ralink Technology wireless if_re_load="NO" # RealTek 8139C+/8169/8169S/8110S if_rl_load="NO" # RealTek 8129/8139 if_rue_load="NO" # RealTek RTL8150 USB to Fast Ethernet if_rum_load="NO" # Ralink Technology USB 802.11a/b/g wireless if_run_load="NO" # Ralink Technology USB 802.11a/g/n wireless if_sbni_load="NO" # Granch SBNI12 leased line adapters if_sf_load="NO" # Adaptec Duralink PCI (AIC-6915 "starfire") if_sge_load="NO" # Silicon Integrated Systems SiS 190/191 if_sis_load="NO" # Silicon Integrated Systems SiS 900/7016 if_sk_load="NO" # SysKonnect SK-984x series PCI Gigabit Ethernet if_sn_load="NO" # SMC 91Cxx if_ste_load="NO" # Sundance Technologies ST201 Fast Ethernet if_stge_load="NO" # Sundance/Tamarack TC9021 Gigabit Ethernet if_ti_load="NO" # Alteon Networks Tigon 1 and Tigon 2 if_tl_load="NO" # Texas Instruments TNETE100 ("ThunderLAN") if_tx_load="NO" # SMC 83c17x Fast Ethernet if_txp_load="NO" # 3Com 3XP Typhoon/Sidewinder (3CR990) if_vge_load="NO" # VIA VT6122 PCI Gigabit Ethernet if_vte_load="NO" # DM&P Vortex86 RDC R6040 Fast Ethernet if_uath_load="NO" # Atheros USB wireless for AR5005UG & AR5005UX if_udav_load="NO" # Davicom DM9601 USB Ethernet if_upgt_load="NO" # Conexant/Intersil PrismGT USB wireless if_ural_load="NO" # Ralink Technology USB wireless if_urtw_load="NO" # Realtek 8187L USB wireless if_vr_load="NO" # VIA Rhine I and Rhine II if_vx_load="NO" # 3Com 3C590 family if_wb_load="NO" # Winbond W89C840F if_wi_load="NO" # WaveLAN/IEEE 802.11 wireless NICs if_wpi_load="NO" # Intel 3945ABG Wireless LAN IEEE 802.11 if_xe_load="NO" # Xircom CreditCard PCMCIA if_xl_load="NO" # 3Com Etherlink XL (3c900, 3c905, 3c905B) sfxge_load="NO" # Solarflare 10Gb Ethernet adapter driver utopia_load="NO" # ATM PHY driver ############################################################## ### Netgraph modules ####################################### ############################################################## ng_UI_load="NO" # UI netgraph node type ng_async_load="NO" # asynchronous framing netgraph node type ng_bpf_load="NO" # Berkeley packet filter netgraph node type ng_bridge_load="NO" # Ethernet bridging netgraph node type ng_cisco_load="NO" # Cisco HDLC protocol netgraph node type ng_echo_load="NO" # Netgraph echo node type ng_eiface_load="NO" # generic Ethernet interface netgraph node type ng_etf_load="NO" # Ethertype filtering netgraph node type ng_ether_load="NO" # Ethernet netgraph node type ng_frame_relay_load="NO" # frame relay netgraph node type ng_gif_load="NO" # generic tunnel interface netgraph node type ng_gif_demux_load="NO" # demultiplexer for packets from ng_gif(4) nodes ng_hole_load="NO" # Netgraph discard node type ng_hub_load="NO" # packet distribution netgraph node type ng_iface_load="NO" # interface Netgraph node type ng_ip_input_load="NO" # netgraph IP input node type ng_ksocket_load="NO" # kernel socket netgraph node type ng_l2tp_load="NO" # L2TP protocol netgraph node type ng_lmi_load="NO" # frame relay LMI protocol netgraph node type ng_mppc_load="NO" # Microsoft MPPC/MPPE compression and # encryption netgraph node type ng_netflow_load="NO" # Cisco's NetFlow netgraph node type ng_one2many_load="NO" # packet multiplexing netgraph node type ng_ppp_load="NO" # PPP protocol netgraph node type ng_pppoe_load="NO" # RFC 2516 PPPOE protocol netgraph node type ng_pptpgre_load="NO" # PPTP GRE protocol netgraph node type ng_rfc1490_load="NO" # RFC 1490 netgraph node type ng_socket_load="NO" # Netgraph socket node type ng_split_load="NO" # netgraph node to separate incoming and # outgoing flows ng_sppp_load="NO" # sppp netgraph node type ng_tee_load="NO" # Netgraph ``tee'' node type ng_tty_load="NO" # Netgraph node type that is also a line # discipline ng_vjc_load="NO" # Van Jacobsen compression netgraph node type ng_vlan_load="NO" # IEEE 802.1Q VLAN tagging netgraph node type ############################################################## ### Sound modules ########################################## ############################################################## sound_load="NO" # Digital sound subsystem snd_ad1816_load="NO" # ad1816 snd_als4000_load="NO" # als4000 snd_atiixp_load="NO" # atiixp snd_cmi_load="NO" # cmi snd_cs4281_load="NO" # cs4281 snd_csa_load="NO" # csa snd_ds1_load="NO" # ds1 snd_emu10k1_load="NO" # Creative Sound Blaster Live snd_emu10kx_load="NO" # Creative SoundBlaster Live! and Audigy snd_envy24_load="NO" # VIA Envy24 snd_envy24ht_load="NO" # VIA Envy24HT snd_es137x_load="NO" # es137x snd_ess_load="NO" # ess snd_fm801_load="NO" # fm801 snd_hda_load="NO" # Intel High Definition Audio (Controller) snd_ich_load="NO" # Intel ICH snd_maestro_load="NO" # Maestro snd_maestro3_load="NO" # Maestro3 snd_mss_load="NO" # Mss snd_neomagic_load="NO" # Neomagic snd_sb16_load="NO" # Sound Blaster 16 snd_sb8_load="NO" # Sound Blaster Pro snd_sbc_load="NO" # Sbc snd_solo_load="NO" # Solo snd_spicds_load="NO" # SPI codecs snd_t4dwave_load="NO" # t4dwave snd_via8233_load="NO" # via8233 snd_via82c686_load="NO" # via82c686 snd_vibes_load="NO" # vibes snd_driver_load="NO" # All sound drivers ############################################################## ### USB modules ############################################ ############################################################## usb_load="NO" # USB subsystem udbp_load="NO" # USB double bulk pipe host 2 host cables ugen_load="NO" # USB generic device, if all else fails ... ucycom_load="NO" # Cyprus USB serial adapters ufm_load="NO" # Fm Radio uhid_load="NO" # Human Interface Devices ukbd_load="NO" # Keyboard ulpt_load="NO" # Printer ums_load="NO" # Mouse umass_load="NO" # Mass Storage Devices umct_load="NO" # Magic Control Technology USB-RS232 umodem_load="NO" # Modems uplcom_load="NO" # Prolific USB serial adapters urio_load="NO" # Rio MP3 players uvisor_load="NO" # PalmOS based PDAs if_aue_load="NO" # ADMtek USB ethernet if_axe_load="NO" # ASIX Electronics AX88172 USB ethernet if_cdce_load="NO" # Ethernet over USB (CDC) if_cue_load="NO" # CATC USB ethernet if_kue_load="NO" # Kawasaki LSI USB ethernet if_rae_load="NO" # Realtek RTL8150 USB adapter. if_rum_load="NO" # Ralink USB 802.11 wireless adapter if_uath_load="NO" # Atheros AR5523 wireless adapter if_run_load="NO" # Ralink USB 802.11 wireless adapter if_ural_load="NO" # Ralink RT2500USB 802.11 wireless adapter if_zyd_load="NO" # ZyDAS ZD1211(B) USB 802.11 wireless adapter snd_uaudio_load="NO" # USB audio ############################################################## ### Other modules ########################################## ############################################################## aio_load="NO" # Asynchronous I/O bktr_load="NO" # Brooktree Bt848/Bt878 TV/Video Capture Card ispfw_load="NO" # Qlogic ISP Firmware agp_load="NO" # agp module accf_data_load="NO" # Wait for data accept filter accf_dns_load="NO" # Wait for full DNS request accept filter accf_http_load="NO" # Wait for full HTTP request accept filter ppi_load="NO" # Interface to ppbus parallel 'geek' port pps_load="NO" # Pulse per second devices puc_load="NO" # PCI "Universal" Communications driver random_load="NO" # Random device speaker_load="NO" # AT speaker module coretemp_load="NO" # Intel Core CPU temperature monitor vkbd_load="NO" # Virtual AT keyboard interface vpd_load="NO" # Vital Product Data kernel interface vpo_load="NO" # Parallel to SCSI interface driver amdtemp_load="NO" # AMD K8/K10/K11 temperature monitor tpm_load="NO" # Trusted Platform Module wbwd_load="NO" # Winbond watchdog ############################################################## ### ACPI settings ########################################## ############################################################## acpi_dsdt_load="NO" # DSDT Overriding acpi_dsdt_type="acpi_dsdt" # Don't change this acpi_dsdt_name="/boot/acpi_dsdt.aml" # Override DSDT in BIOS by this file acpi_video_load="NO" # Load the ACPI video extension driver ############################################################## ### TrustedBSD MAC settings ################################ ############################################################## mac_biba_load="NO" # Biba MAC policy mac_bsdextended_load="NO" # BSD/extended MAC policy mac_ifoff="NO" # Interface silencing policy mac_mls_load="NO" # MLS MAC policy mac_none_load="NO" # Null MAC policy mac_partition_load="NO" # Partition MAC policy mac_seeotheruids_load="NO" # UID visbility MAC policy ############################################################## ### Module loading syntax example ########################## ############################################################## #module_load="YES" # loads module "module" #module_name="realname" # uses "realname" instead of "module" #module_type="type" # passes "-t type" to load #module_flags="flags" # passes "flags" to the module #module_before="cmd" # executes "cmd" before loading the module #module_after="cmd" # executes "cmd" after loading the module #module_error="cmd" # executes "cmd" if load fails Index: stable/11/sys/boot/geli/Makefile =================================================================== --- stable/11/sys/boot/geli/Makefile (revision 329139) +++ stable/11/sys/boot/geli/Makefile (revision 329140) @@ -1,53 +1,56 @@ # $FreeBSD$ # libgeliboot MAN= -.include +.include MK_SSP= no LIB= geliboot INTERNALLIB= MK_PROFILE= no NO_PIC= .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -march=i386 .endif -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64" +.if ${MACHINE_ARCH} == "amd64" CFLAGS+= -m32 .endif WARNS?= 0 # string functions from libc -.PATH: ${.CURDIR}/../../../lib/libc/string +.PATH: ${SRCTOP}/lib/libc/string SRCS+= bcmp.c bcopy.c bzero.c # Our password input method SRCS+= pwgets.c # sha256 and sha512 from sys/crypto -.PATH: ${SRCTOP}/sys/crypto/sha2 +.PATH: ${SYSDIR}/crypto/sha2 CFLAGS+= -DWEAK_REFS SRCS+= sha256c.c sha512c.c # md5 from libmd .PATH: ${SRCTOP}/lib/libmd SRCS+= md5c.c # AES implementation from sys/crypto -.PATH: ${SRCTOP}/sys/crypto/rijndael -CFLAGS+= -I${.CURDIR}/../../ -CFLAGS+= -I${.CURDIR}/../common/ +.PATH: ${SYSDIR}/crypto/rijndael +CFLAGS+= -I${LDRSRC} # Remove asserts CFLAGS+= -DNDEBUG SRCS+= rijndael-alg-fst.c rijndael-api-fst.c rijndael-api.c # local GELI Implementation -.PATH: ${SRCTOP}/sys/geom/eli +.PATH: ${SYSDIR}/geom/eli CFLAGS+= -D_STAND SRCS+= geliboot_crypto.c g_eli_hmac.c g_eli_key.c g_eli_key_cache.c pkcs5v2.c + +# aes +.PATH: ${SYSDIR}/opencrypto +SRCS+= xform_aes_xts.c .include .include Index: stable/11/sys/boot/i386/Makefile =================================================================== --- stable/11/sys/boot/i386/Makefile (revision 329139) +++ stable/11/sys/boot/i386/Makefile (revision 329140) @@ -1,19 +1,25 @@ # $FreeBSD$ -.include +.include SUBDIR= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot \ - libi386 libfirewire loader + libi386 + +.if ${MK_LOADER_FIREWIRE} == "yes" +SUBDIR+= libfirewire +.endif + +SUBDIR+= loader # special boot programs, 'self-extracting boot2+loader' SUBDIR+= pxeldr .if ${MACHINE_CPUARCH} == "i386" SUBDIR+= kgzldr .endif .if ${MK_ZFS} != "no" SUBDIR+= zfsboot gptzfsboot zfsloader .endif .include Index: stable/11/sys/boot/i386/Makefile.inc =================================================================== --- stable/11/sys/boot/i386/Makefile.inc (revision 329139) +++ stable/11/sys/boot/i386/Makefile.inc (revision 329140) @@ -1,38 +1,36 @@ # Common defines for all of /sys/boot/i386/ # # $FreeBSD$ -BINDIR?= /boot - LOADER_ADDRESS?=0x200000 CFLAGS+= -march=i386 -ffreestanding CFLAGS.gcc+= -mpreferred-stack-boundary=2 CFLAGS+= ${CFLAGS_NO_SIMD} -msoft-float LDFLAGS+= -nostdlib -.if ${MACHINE_CPUARCH} == "amd64" -CFLAGS+= -m32 -ACFLAGS+= -m32 -# LD_FLAGS is passed directly to ${LD}, not via ${CC}: -LD_FLAGS+= -m elf_i386_fbsd -AFLAGS+= --32 -.endif - # BTX components -.if exists(${.OBJDIR}/../btx) -BTXDIR= ${.OBJDIR}/../btx -.else -BTXDIR= ${.CURDIR}/../btx -.endif +BTXDIR= ${BOOTOBJ}/i386/btx BTXLDR= ${BTXDIR}/btxldr/btxldr BTXKERN= ${BTXDIR}/btx/btx BTXCRT= ${BTXDIR}/lib/crt0.o +BTXSRC= ${BOOTSRC}/i386/btx +BTXLIB= ${BTXSRC}/lib + # compact binary with no padding between text, data, bss -LDSCRIPT= ${SRCTOP}/sys/boot/i386/boot.ldscript +LDSCRIPT= ${BOOTSRC}/i386/boot.ldscript # LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-T,${LDSCRIPT},-S,--oformat,binary # LD_FLAGS_BIN=-static -T ${LDSCRIPT} --gc-sections LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary LD_FLAGS_BIN=-static -N --gc-sections + +.if ${MACHINE_CPUARCH} == "amd64" +DO32=1 +.endif + +.if defined(LOADER_FIREWIRE_SUPPORT) +MK_LOADER_FIREWIRE=yes +.warning "LOADER_FIREWIRE_SUPPORT deprecated, please move to WITH_LOADER_FIREWIRE" +.endif .include "../Makefile.inc" Index: stable/11/sys/boot/i386/boot0/Makefile =================================================================== --- stable/11/sys/boot/i386/boot0/Makefile (revision 329139) +++ stable/11/sys/boot/i386/boot0/Makefile (revision 329140) @@ -1,80 +1,80 @@ # $FreeBSD$ PROG?= boot0 STRIP= BINMODE=${NOBINMODE} MAN= SRCS= ${PROG}.S # Additional options that you can specify with make OPTS="..." # (these only apply to boot0.S) # # -DVOLUME_SERIAL support volume serial number (NT, XP, Vista) # -DSIO do I/O using COM1: # -DPXE fallback to INT18/PXE with F6 # -DCHECK_DRIVE enable checking drive number # -DONLY_F_KEYS accept only Fx keys in console # -DTEST print drive number on entry # OPTS ?= -DVOLUME_SERIAL -DPXE CFLAGS += ${OPTS} # Flags used in the boot0.S code: # 0x0f all valid partitions enabled. # 0x80 'packet', use BIOS EDD (LBA) extensions instead of CHS # to read from disk. boot0.S does not check that the extensions # are supported, but all modern BIOSes should have them. # 0x40 'noupdate', disable writing boot0 back to disk so that # the current selection is not preserved across reboots. # 0x20 'setdrv', override the drive number supplied by the bios # with the one in the boot sector. # Default boot flags: BOOT_BOOT0_FLAGS?= 0x8f # The number of timer ticks to wait for a keypress before assuming the default # selection. Since there are 18.2 ticks per second, the default value of # 0xb6 (182d) corresponds to 10 seconds. BOOT_BOOT0_TICKS?= 0xb6 # The base address that we the boot0 code to to run it. Don't change this # unless you are glutton for punishment. BOOT_BOOT0_ORG?= 0x600 ORG=${BOOT_BOOT0_ORG} # Comm settings for boot0sio. # Bit(s) Description # 7-5 data rate (110,150,300,600,1200,2400,4800,9600 bps) # 4-3 parity (00 or 10 = none, 01 = odd, 11 = even) # 2 stop bits (set = 2, clear = 1) # 1-0 data bits (00 = 5, 01 = 6, 10 = 7, 11 = 8) .if !defined(BOOT_BOOT0_COMCONSOLE_SPEED) BOOT_COMCONSOLE_SPEED?= 9600 .if ${BOOT_COMCONSOLE_SPEED} == 9600 BOOT_BOOT0_COMCONSOLE_SPEED= "7 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 4800 BOOT_BOOT0_COMCONSOLE_SPEED= "6 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 2400 BOOT_BOOT0_COMCONSOLE_SPEED= "5 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 1200 BOOT_BOOT0_COMCONSOLE_SPEED= "4 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 600 BOOT_BOOT0_COMCONSOLE_SPEED= "3 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 300 BOOT_BOOT0_COMCONSOLE_SPEED= "2 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 150 BOOT_BOOT0_COMCONSOLE_SPEED= "1 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 110 BOOT_BOOT0_COMCONSOLE_SPEED= "0 << 5 + 3" .else BOOT_BOOT0_COMCONSOLE_SPEED= "7 << 5 + 3" .endif .endif CFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \ -DTICKS=${BOOT_BOOT0_TICKS} \ -DCOMSPEED=${BOOT_BOOT0_COMCONSOLE_SPEED} -LDFLAGS=${LDFLAGS_BIN} +LDFLAGS+=${LDFLAGS_BIN} .include Index: stable/11/sys/boot/i386/boot2/Makefile =================================================================== --- stable/11/sys/boot/i386/boot2/Makefile (revision 329139) +++ stable/11/sys/boot/i386/boot2/Makefile (revision 329140) @@ -1,109 +1,99 @@ # $FreeBSD$ -.include +.include FILES= boot boot1 boot2 NM?= nm # A value of 0x80 enables LBA support. BOOT_BOOT1_FLAGS?= 0x80 BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 REL1= 0x700 ORG1= 0x7c00 ORG2= 0x2000 # Decide level of UFS support. BOOT2_UFS?= UFS1_AND_UFS2 #BOOT2_UFS?= UFS2_ONLY #BOOT2_UFS?= UFS1_ONLY -CFLAGS= -fomit-frame-pointer \ +CFLAGS+=-fomit-frame-pointer \ -mrtd \ -mregparm=3 \ -D${BOOT2_UFS} \ -DFLAGS=${BOOT_BOOT1_FLAGS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ - -I${.CURDIR}/../../common \ - -I${.CURDIR}/../btx/lib -I. \ + -I${LDRSRC} \ + -I${BTXLIB} \ -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline CFLAGS.gcc+= -Os \ -fno-asynchronous-unwind-tables \ --param max-inline-insns-single=100 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201 CFLAGS.gcc+= -mno-align-long-strings .endif CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} -LD_FLAGS=${LD_FLAGS_BIN} +LD_FLAGS+=${LD_FLAGS_BIN} -# Pick up ../Makefile.inc early. -.include +CLEANFILES+= boot -CLEANFILES= boot - boot: boot1 boot2 cat boot1 boot2 > boot CLEANFILES+= boot1 boot1.out boot1.o boot1: boot1.out ${OBJCOPY} -S -O binary boot1.out ${.TARGET} boot1.out: boot1.o ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ boot2.h sio.o BOOT2SIZE= 7680 boot2: boot2.ld @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 ${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync boot2.ld: boot2.ldr boot2.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ -o ${.TARGET} -P 1 boot2.bin boot2.ldr: ${DD} if=/dev/zero of=${.TARGET} bs=512 count=1 boot2.bin: boot2.out ${OBJCOPY} -S -O binary boot2.out ${.TARGET} boot2.out: ${BTXCRT} boot2.o sio.o ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} SRCS= boot2.c boot2.h boot2.h: boot1.out ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ { x = $$1 - ORG1; \ printf("#define XREADORG %#x\n", REL1 + x) }' \ ORG1=`printf "%d" ${ORG1}` \ REL1=`printf "%d" ${REL1}` > ${.TARGET} - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend boot2.s: machine -CLEANFILES+= machine -machine: ${.CURDIR}/../../../i386/include .NOMETA - ln -sf ${.ALLSRC} ${.TARGET} -.endif .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.boot1.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/btx/btx/Makefile =================================================================== --- stable/11/sys/boot/i386/btx/btx/Makefile (revision 329139) +++ stable/11/sys/boot/i386/btx/btx/Makefile (revision 329140) @@ -1,33 +1,35 @@ # $FreeBSD$ +.include + PROG= btx INTERNALPROG= MAN= SRCS= btx.S .if defined(BOOT_BTX_NOHANG) BOOT_BTX_FLAGS=0x1 .else BOOT_BTX_FLAGS=0x0 .endif CFLAGS+=-DBTX_FLAGS=${BOOT_BTX_FLAGS} -CFLAGS+=-I${.CURDIR}/../../common +CFLAGS+=-I${BOOTSRC}/i386/common .if defined(BTX_SERIAL) BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 CFLAGS+=-DBTX_SERIAL -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} -DSIOSPD=${BOOT_COMCONSOLE_SPEED} .endif ORG= 0x9000 -LDFLAGS=${LDFLAGS_BIN} +LDFLAGS+=${LDFLAGS_BIN} .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.btx.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/btx/btxldr/Makefile =================================================================== --- stable/11/sys/boot/i386/btx/btxldr/Makefile (revision 329139) +++ stable/11/sys/boot/i386/btx/btxldr/Makefile (revision 329140) @@ -1,21 +1,23 @@ # $FreeBSD$ +.include + PROG= btxldr INTERNALPROG= MAN= SRCS= btxldr.S CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} -CFLAGS+=-I${.CURDIR}/../../common +CFLAGS+=-I${BOOTSRC}/i386/common .if defined(BTXLDR_VERBOSE) CFLAGS+=-DBTXLDR_VERBOSE .endif ORG=${LOADER_ADDRESS} -LDFLAGS=${LDFLAGS_BIN} +LDFLAGS+=${LDFLAGS_BIN} .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.btxldr.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/btx/lib/Makefile =================================================================== --- stable/11/sys/boot/i386/btx/lib/Makefile (revision 329139) +++ stable/11/sys/boot/i386/btx/lib/Makefile (revision 329140) @@ -1,10 +1,12 @@ # $FreeBSD$ +.include + PROG= crt0.o INTERNALPROG= MAN= SRCS= btxcsu.S btxsys.s btxv86.s -CFLAGS+=-I${.CURDIR}/../../common -LDFLAGS=-Wl,-r +CFLAGS+=-I${BOOTSRC}/i386/common +LDFLAGS+=-Wl,-r .include Index: stable/11/sys/boot/i386/cdboot/Makefile =================================================================== --- stable/11/sys/boot/i386/cdboot/Makefile (revision 329139) +++ stable/11/sys/boot/i386/cdboot/Makefile (revision 329140) @@ -1,18 +1,20 @@ # $FreeBSD$ +.include + PROG= cdboot STRIP= BINMODE=${NOBINMODE} MAN= SRCS= ${PROG}.S -CFLAGS+=-I${.CURDIR}/../common +CFLAGS+=-I${BOOTSRC}/i386/common ORG= 0x7c00 -LDFLAGS=${LDFLAGS_BIN} +LDFLAGS+=${LDFLAGS_BIN} .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.cdboot.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/gptboot/Makefile =================================================================== --- stable/11/sys/boot/i386/gptboot/Makefile (revision 329139) +++ stable/11/sys/boot/i386/gptboot/Makefile (revision 329140) @@ -1,93 +1,75 @@ # $FreeBSD$ -.include "../Makefile.inc" +HAVE_GELI= yes -.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${SASRC} +.include +.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC} + FILES= gptboot MAN= gptboot.8 NM?= nm BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 REL1= 0x700 ORG1= 0x7c00 ORG2= 0x0 # Decide level of UFS support. GPTBOOT_UFS?= UFS1_AND_UFS2 #GPTBOOT_UFS?= UFS2_ONLY #GPTBOOT_UFS?= UFS1_ONLY CFLAGS+=-DBOOTPROG=\"gptboot\" \ -O1 \ -DGPT \ -D${GPTBOOT_UFS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ - -I${.CURDIR}/../../common \ - -I${.CURDIR}/../common \ - -I${.CURDIR}/../btx/lib -I. \ - -I${.CURDIR}/../boot2 \ - -I${.CURDIR}/../../.. \ + -I${LDRSRC} \ + -I${BOOTSRC}/i386/common \ + -I${BTXLIB} \ + -I${BOOTSRC}/i386/boot2 \ -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline -Wno-pointer-sign CFLAGS.gcc+= --param max-inline-insns-single=100 -.if !defined(LOADER_NO_GELI_SUPPORT) -CFLAGS+= -DLOADER_GELI_SUPPORT -CFLAGS+= -I${.CURDIR}/../../geli -CFLAGS+= -I${.CURDIR}/../../.. -LIBGELIBOOT= ${.OBJDIR}/../../geli/libgeliboot.a -.PATH: ${.CURDIR}/../../../opencrypto -OPENCRYPTO_XTS= xform_aes_xts.o -.endif +LD_FLAGS+=${LD_FLAGS_BIN} -LD_FLAGS=${LD_FLAGS_BIN} +CLEANFILES+= gptboot -# Pick up ../Makefile.inc early. -.include - -CLEANFILES= gptboot - gptboot: gptldr.bin gptboot.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \ -o ${.TARGET} gptboot.bin CLEANFILES+= gptldr.bin gptldr.out gptldr.o gptldr.bin: gptldr.out ${OBJCOPY} -S -O binary gptldr.out ${.TARGET} gptldr.out: gptldr.o ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o CLEANFILES+= gptboot.bin gptboot.out gptboot.o sio.o crc32.o drv.o \ - cons.o util.o ${OPENCRYPTO_XTS} + cons.o ${OPENCRYPTO_XTS} gptboot.bin: gptboot.out ${OBJCOPY} -S -O binary gptboot.out ${.TARGET} -gptboot.out: ${BTXCRT} gptboot.o sio.o crc32.o drv.o cons.o util.o ${OPENCRYPTO_XTS} +gptboot.out: ${BTXCRT} gptboot.o sio.o crc32.o drv.o cons.o ${OPENCRYPTO_XTS} ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBGELIBOOT} ${LIBSA32} gptboot.o: ${SASRC}/ufsread.c - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend gptboot.o: machine -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${.CURDIR}/../../../i386/include machine -.endif .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.gptldr.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/gptzfsboot/Makefile =================================================================== --- stable/11/sys/boot/i386/gptzfsboot/Makefile (revision 329139) +++ stable/11/sys/boot/i386/gptzfsboot/Makefile (revision 329140) @@ -1,102 +1,87 @@ # $FreeBSD$ -.include "../Makefile.inc" +HAVE_GPT= yes -.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../gptboot \ - ${.CURDIR}/../zfsboot ${.CURDIR}/../common \ - ${.CURDIR}/../../../crypto/skein ${SASRC} +.include +.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/gptboot \ + ${BOOTSRC}/i386/zfsboot ${BOOTSRC}/i386/common \ + ${SASRC} + FILES= gptzfsboot MAN= gptzfsboot.8 NM?= nm BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 REL1= 0x700 ORG1= 0x7c00 ORG2= 0x0 CFLAGS+=-DBOOTPROG=\"gptzfsboot\" \ -O1 \ -DGPT -DZFS -DBOOT2 \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ - -I${.CURDIR}/../../common \ - -I${.CURDIR}/../common \ - -I${.CURDIR}/../../zfs \ - -I${.CURDIR}/../../../cddl/boot/zfs \ - -I${.CURDIR}/../../../crypto/skein \ - -I${.CURDIR}/../btx/lib -I. \ - -I${.CURDIR}/../boot2 \ - -I${.CURDIR}/../../.. \ + -I${LDRSRC} \ + -I${BOOTSRC}/i386/common \ + -I${ZFSSRC} \ + -I${SYSDIR}/cddl/boot/zfs \ + -I${BOOTSRC}/i386/btx/lib \ + -I${BOOTSRC}/i386/boot2 \ -Wall -Waggregate-return -Wbad-function-cast \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline -Wno-pointer-sign NO_WCAST_ALIGN= .if ${COMPILER_TYPE} == "clang" || \ (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201) CFLAGS+= -Wno-tentative-definition-incomplete-type .endif -# Do not unroll skein loops, reduce code size -CFLAGS+= -DSKEIN_LOOP=111 - -.if !defined(LOADER_NO_GELI_SUPPORT) -CFLAGS+= -DLOADER_GELI_SUPPORT -CFLAGS+= -I${.CURDIR}/../../geli -LIBGELIBOOT= ${.OBJDIR}/../../geli/libgeliboot.a -.PATH: ${.CURDIR}/../../../opencrypto -OPENCRYPTO_XTS= xform_aes_xts.o +.if ${MACHINE} == "amd64" +LIBZFSBOOT=${BOOTOBJ}/zfs32/libzfsboot.a +.else +LIBZFSBOOT=${BOOTOBJ}/zfs/libzfsboot.a .endif CFLAGS.gcc+= --param max-inline-insns-single=100 -LD_FLAGS=${LD_FLAGS_BIN} +LD_FLAGS+=${LD_FLAGS_BIN} -# Pick up ../Makefile.inc early. -.include +CLEANFILES+= gptzfsboot -CLEANFILES= gptzfsboot - gptzfsboot: gptldr.bin gptzfsboot.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \ -o ${.TARGET} gptzfsboot.bin CLEANFILES+= gptldr.bin gptldr.out gptldr.o gptldr.bin: gptldr.out ${OBJCOPY} -S -O binary gptldr.out ${.TARGET} gptldr.out: gptldr.o ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o CLEANFILES+= gptzfsboot.bin gptzfsboot.out zfsboot.o sio.o cons.o \ - drv.o gpt.o util.o skein.o skein_block.o ${OPENCRYPTO_XTS} + drv.o gpt.o util.o ${OPENCRYPTO_XTS} gptzfsboot.bin: gptzfsboot.out ${OBJCOPY} -S -O binary gptzfsboot.out ${.TARGET} gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o \ - skein.o skein_block.o ${OPENCRYPTO_XTS} - ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBGELIBOOT} ${LIBSA32} + ${OPENCRYPTO_XTS} + ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBGELIBOOT} ${LIBZFSBOOT} ${LIBSA32} -zfsboot.o: ${.CURDIR}/../../zfs/zfsimpl.c - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend zfsboot.o: machine -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${.CURDIR}/../../../i386/include machine -.endif +zfsboot.o: ${ZFSSRC}/zfsimpl.c .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.gptldr.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/kgzldr/Makefile =================================================================== --- stable/11/sys/boot/i386/kgzldr/Makefile (revision 329139) +++ stable/11/sys/boot/i386/kgzldr/Makefile (revision 329140) @@ -1,19 +1,21 @@ # $FreeBSD$ +.include + PROG= kgzldr.o STRIP= BINMODE=${LIBMODE} BINDIR= ${LIBDIR} MAN= SRCS= start.s boot.c inflate.c lib.c crt.s sio.s CFLAGS= -Os CFLAGS+=-DKZIP NO_SHARED= -LDFLAGS=-Wl,-r -.PATH: ${.CURDIR}/../../../kern +LDFLAGS+=-Wl,-r +.PATH: ${SYSDIR}/kern BOOT_COMCONSOLE_PORT?= 0x3f8 AFLAGS+=--defsym SIO_PRT=${BOOT_COMCONSOLE_PORT} .include Index: stable/11/sys/boot/i386/libfirewire/Makefile =================================================================== --- stable/11/sys/boot/i386/libfirewire/Makefile (revision 329139) +++ stable/11/sys/boot/i386/libfirewire/Makefile (revision 329140) @@ -1,29 +1,20 @@ # $FreeBSD$ +.include + LIB= firewire INTERNALLIB= -.PATH: ${.CURDIR}/../../../dev/dcons ${.CURDIR}/../../../dev/firewire +.PATH: ${SYSDIR}/dev/dcons ${SYSDIR}/dev/firewire SRCS+= firewire.c fwohci.c dconsole.c SRCS+= dcons.c fwcrom.c CFLAGS+= -D_BOOT -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. -CFLAGS+= -I${.CURDIR}/../btx/lib -CFLAGS+= -I${.CURDIR}/../libi386 +CFLAGS+= -I${LDRSRC} +CFLAGS+= -I${BTXLIB} +CFLAGS+= -I${BOOTSRC}/i386/libi386 CFLAGS+= -Wformat -Wall -.if ${MACHINE_CPUARCH} == "amd64" -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${.CURDIR}/../../../i386/include machine -.endif - .include - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend ${OBJS}: machine -.endif - Index: stable/11/sys/boot/i386/libi386/Makefile =================================================================== --- stable/11/sys/boot/i386/libi386/Makefile (revision 329139) +++ stable/11/sys/boot/i386/libi386/Makefile (revision 329140) @@ -1,80 +1,61 @@ # $FreeBSD$ -# + +HAVE_GPT= yes +HAVE_GELI= yes + +.include + LIB= i386 INTERNALLIB= SRCS= biosacpi.c bioscd.c biosdisk.c biosmem.c biospnp.c \ biospci.c biossmap.c bootinfo.c bootinfo32.c bootinfo64.c \ comconsole.c devicename.c elf32_freebsd.c \ elf64_freebsd.c multiboot.c multiboot_tramp.S relocater_tramp.S \ i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \ smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c -.PATH: ${.CURDIR}/../../zfs -SRCS+= devicename_stubs.c +.PATH: ${ZFSSRC} +SRCS+= devicename_stubs.c -.if defined(LOADER_TFTP_SUPPORT) -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if defined(LOADER_NFS_SUPPORT) -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif - BOOT_COMCONSOLE_PORT?= 0x3f8 CFLAGS+= -DCOMPORT=${BOOT_COMCONSOLE_PORT} BOOT_COMCONSOLE_SPEED?= 9600 CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED} .ifdef(BOOT_BIOSDISK_DEBUG) # Make the disk code more talkative CFLAGS+= -DDISK_DEBUG .endif -.if !defined(LOADER_NO_GELI_SUPPORT) -# Decrypt encrypted drives -CFLAGS+= -DLOADER_GELI_SUPPORT -CFLAGS+= -I${.CURDIR}/../../geli -.endif - .if !defined(BOOT_HIDE_SERIAL_NUMBERS) # Export serial numbers, UUID, and asset tag from loader. CFLAGS+= -DSMBIOS_SERIAL_NUMBERS .if defined(BOOT_LITTLE_ENDIAN_UUID) # Use little-endian UUID format as defined in SMBIOS 2.6. CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID .elif defined(BOOT_NETWORK_ENDIAN_UUID) # Use network-endian UUID format for backward compatibility. CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID .endif .endif # Include simple terminal emulation (cons25-compatible) CFLAGS+= -DTERM_EMU # XXX: make alloca() useable CFLAGS+= -Dalloca=__builtin_alloca -CFLAGS+= -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 \ - -I${.CURDIR}/../../common -I${.CURDIR}/../common \ - -I${.CURDIR}/../btx/lib \ - -I${.CURDIR}/../../../contrib/dev/acpica/include \ - -I${.CURDIR}/../../.. -I. +CFLAGS+= -I${BOOTSRC}/ficl -I${BOOTSRC}/ficl/i386 \ + -I${LDRSRC} -I${BOOTSRC}/i386/common \ + -I${BTXLIB} \ + -I${SYSDIR}/contrib/dev/acpica/include # Handle FreeBSD specific %b and %D printf format specifiers CFLAGS+= ${FORMAT_EXTENSIONS} -.if ${MACHINE_CPUARCH} == "amd64" -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${.CURDIR}/../../../i386/include machine -.endif - .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.amd64_tramp.S= ${CLANG_NO_IAS} CFLAGS.multiboot_tramp.S= ${CLANG_NO_IAS} - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend ${OBJS}: machine -.endif Index: stable/11/sys/boot/i386/loader/Makefile =================================================================== --- stable/11/sys/boot/i386/loader/Makefile (revision 329139) +++ stable/11/sys/boot/i386/loader/Makefile (revision 329140) @@ -1,135 +1,89 @@ # $FreeBSD$ -.include +HAVE_GELI= yes + +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no +LOADER_MSDOS_SUPPORT?= no +LOADER_UFS_SUPPORT?= yes +LOADER_GZIP_SUPPORT?= yes +LOADER_BZIP2_SUPPORT?= yes + +.include + MK_SSP= no LOADER?= loader PROG= ${LOADER}.sym MAN= INTERNALPROG= NEWVERSWHAT?= "bootstrap loader" x86 VERSION_FILE= ${.CURDIR}/../loader/version -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= yes +.PATH: ${BOOTSRC}/i386/loader + # architecture-specific loader code SRCS= main.c conf.c vers.c chain.c -# Put LOADER_FIREWIRE_SUPPORT=yes in /etc/make.conf for FireWire/dcons support -.if defined(LOADER_FIREWIRE_SUPPORT) -CFLAGS+= -DLOADER_FIREWIRE_SUPPORT -LIBFIREWIRE= ${.OBJDIR}/../libfirewire/libfirewire.a -.endif - -# Set by zfsloader Makefile -.if defined(LOADER_ZFS_SUPPORT) -CFLAGS+= -DLOADER_ZFS_SUPPORT -LIBZFSBOOT= ${.OBJDIR}/../../zfs/libzfsboot.a -.endif - -.if defined(LOADER_TFTP_SUPPORT) -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if defined(LOADER_NFS_SUPPORT) -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif - # Include bcache code. HAVE_BCACHE= yes # Enable PnP and ISA-PnP code. HAVE_PNP= yes HAVE_ISABUS= yes -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 -.if ${MACHINE_CPUARCH} == "amd64" -LIBFICL= ${.OBJDIR}/../../ficl32/libficl.a -.else -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a +.if ${MK_LOADER_FIREWIRE} == "yes" +CFLAGS+= -DLOADER_FIREWIRE_SUPPORT +LIBFIREWIRE= ${BOOTOBJ}/i386/libfirewire/libfirewire.a .endif -.endif -.if defined(LOADER_BZIP2_SUPPORT) -CFLAGS+= -DLOADER_BZIP2_SUPPORT +.if exists(${.CURDIR}/help.i386) +HELP_FILES+= help.i386 +.else +HELP_FILES= .endif -.if !defined(LOADER_NO_GZIP_SUPPORT) -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if defined(LOADER_NANDFS_SUPPORT) -CFLAGS+= -DLOADER_NANDFS_SUPPORT -.endif -.if !defined(LOADER_NO_GELI_SUPPORT) -CFLAGS+= -DLOADER_GELI_SUPPORT -CFLAGS+= -I${.CURDIR}/../../geli -LIBGELIBOOT= ${.OBJDIR}/../../geli/libgeliboot.a -.PATH: ${.CURDIR}/../../../opencrypto -SRCS+= xform_aes_xts.c -CFLAGS+= -I${.CURDIR}/../../.. -D_STAND -.endif # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -CFLAGS+= -I. +.include "${BOOTSRC}/loader.mk" -CLEANFILES= ${LOADER} ${LOADER}.bin loader.help +CLEANFILES+= ${LOADER} ${LOADER}.bin CFLAGS+= -Wall -LDFLAGS= -static -Ttext 0x0 +LDFLAGS+= -static -Ttext 0x0 # i386 standalone support library -LIBI386= ${.OBJDIR}/../libi386/libi386.a -CFLAGS+= -I${.CURDIR}/.. +LIBI386= ${BOOTOBJ}/i386/libi386/libi386.a +CFLAGS+= -I${BOOTSRC}/i386 # BTX components -CFLAGS+= -I${.CURDIR}/../btx/lib +CFLAGS+= -I${BTXLIB} # Debug me! #CFLAGS+= -g #LDFLAGS+= -g -# Pick up ../Makefile.inc early. -.include - ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ -b ${BTXKERN} ${LOADER}.bin ${LOADER}.bin: ${LOADER}.sym strip -R .comment -R .note -o ${.TARGET} ${.ALLSRC} -loader.help: help.common help.i386 - cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - -FILES= ${LOADER} +FILES+= ${LOADER} # XXX INSTALLFLAGS_loader= -b FILESMODE_${LOADER}= ${BINMODE} -b -.if !defined(LOADER_ONLY) -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" -FILES+= pcibios.4th - -FILES+= loader.rc menu.rc -.endif - # XXX crt0.o needs to be first for pxeboot(8) to work OBJS= ${BTXCRT} -DPADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32} -LDADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32} +DPADD= ${LIBFICL32} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32} +LDADD= ${LIBFICL32} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32} -.include - .if ${MACHINE_CPUARCH} == "amd64" -beforedepend ${OBJS}: machine -CLEANFILES+= machine CFLAGS+= -DLOADER_PREFER_AMD64 -machine: .NOMETA - ln -sf ${.CURDIR}/../../../i386/include machine .endif + +.include Index: stable/11/sys/boot/i386/mbr/Makefile =================================================================== --- stable/11/sys/boot/i386/mbr/Makefile (revision 329139) +++ stable/11/sys/boot/i386/mbr/Makefile (revision 329140) @@ -1,17 +1,17 @@ # $FreeBSD$ PROG= mbr STRIP= BINMODE=${NOBINMODE} MAN= SRCS= ${PROG}.s # MBR flags: 0x80 -- try packet interface (also known as EDD or LBA) BOOT_MBR_FLAGS?= 0x80 ORG= 0x600 AFLAGS+=--defsym FLAGS=${BOOT_MBR_FLAGS} -LDFLAGS=${LDFLAGS_BIN} +LDFLAGS+=${LDFLAGS_BIN} .include Index: stable/11/sys/boot/i386/pmbr/Makefile =================================================================== --- stable/11/sys/boot/i386/pmbr/Makefile (revision 329139) +++ stable/11/sys/boot/i386/pmbr/Makefile (revision 329140) @@ -1,14 +1,14 @@ # $FreeBSD$ PROG= pmbr STRIP= BINMODE=${NOBINMODE} MAN= SRCS= ${PROG}.s ORG= 0x600 AFLAGS+=--defsym FLAGS=${BOOT_MBR_FLAGS} -LDFLAGS=${LDFLAGS_BIN} +LDFLAGS+=${LDFLAGS_BIN} .include Index: stable/11/sys/boot/i386/pxeldr/Makefile =================================================================== --- stable/11/sys/boot/i386/pxeldr/Makefile (revision 329139) +++ stable/11/sys/boot/i386/pxeldr/Makefile (revision 329140) @@ -1,48 +1,47 @@ # $FreeBSD$ -# Pick up ../Makefile.inc early. .include PROG= ${LDR} INTERNALPROG= FILES= ${BOOT} MAN= ${BOOT}.8 SRCS= ${LDR}.S -CLEANFILES= ${BOOT} +CLEANFILES+= ${BOOT} BOOT= pxeboot LDR= pxeldr ORG= 0x7c00 LOADER= loader .if defined(BOOT_PXELDR_PROBE_KEYBOARD) CFLAGS+=-DPROBE_KEYBOARD .endif .if defined(BOOT_PXELDR_ALWAYS_SERIAL) CFLAGS+=-DALWAYS_SERIAL .endif -CFLAGS+=-I${.CURDIR}/../common +CFLAGS+=-I${BOOTSRC}/i386/common -LOADERBIN= ${.OBJDIR}/../loader/loader.bin +LOADERBIN= ${BOOTOBJ}/i386/loader/loader.bin CLEANFILES+= ${BOOT}.tmp ${BOOT}: ${LDR} ${LOADER} cat ${LDR} ${LOADER} > ${.TARGET}.tmp ${DD} if=${.TARGET}.tmp of=${.TARGET} obs=2k conv=osync rm ${.TARGET}.tmp LDFLAGS+=${LDFLAGS_BIN} CLEANFILES+= ${LOADER} ${LOADER}: ${LOADERBIN} ${BTXLDR} ${BTXKERN} btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ -b ${BTXKERN} ${LOADERBIN} .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.pxeldr.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/zfsboot/Makefile =================================================================== --- stable/11/sys/boot/i386/zfsboot/Makefile (revision 329139) +++ stable/11/sys/boot/i386/zfsboot/Makefile (revision 329140) @@ -1,100 +1,93 @@ # $FreeBSD$ -.include "../Makefile.inc" +HAVE_GELI=yes -.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common \ - ${.CURDIR}/../../../crypto/skein ${SASRC} +.include +.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC} + FILES= zfsboot MAN= zfsboot.8 NM?= nm BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 REL1= 0x700 ORG1= 0x7c00 ORG2= 0x2000 CFLAGS+=-DBOOTPROG=\"zfsboot\" \ -O1 \ -DZFS -DBOOT2 \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ - -I${.CURDIR}/../../common \ - -I${.CURDIR}/../common \ - -I${.CURDIR}/../../zfs \ - -I${.CURDIR}/../../../cddl/boot/zfs \ - -I${.CURDIR}/../../../crypto/skein \ - -I${.CURDIR}/../btx/lib -I. \ - -I${.CURDIR}/../boot2 \ + -I${LDRSRC} \ + -I${BOOTSRC}/i386/common \ + -I${BOOTSRC}/i386 \ + -I${ZFSSRC} \ + -I${SYSDIR}/cddl/boot/zfs \ + -I${BTXLIB} \ + -I${BOOTSRC}/i386/boot2 \ -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline CFLAGS.gcc+= --param max-inline-insns-single=100 -# Do not unroll skein loops, reduce code size -CFLAGS+= -DSKEIN_LOOP=111 +.if ${MACHINE} == "amd64" +LIBZFSBOOT=${BOOTOBJ}/zfs32/libzfsboot.a +.else +LIBZFSBOOT=${BOOTOBJ}/zfs/libzfsboot.a +.endif -LD_FLAGS=${LD_FLAGS_BIN} +LD_FLAGS+=${LD_FLAGS_BIN} -# Pick up ../Makefile.inc early. -.include +CLEANFILES+= zfsboot -CLEANFILES= zfsboot - zfsboot: zfsboot1 zfsboot2 cat zfsboot1 zfsboot2 > zfsboot CLEANFILES+= zfsboot1 zfsldr.out zfsldr.o zfsboot1: zfsldr.out ${OBJCOPY} -S -O binary zfsldr.out ${.TARGET} zfsldr.out: zfsldr.o ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ - zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o \ - skein.o skein_block.o + zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o # We currently allow 128k bytes for zfsboot - in practice it could be # any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. # BOOT2SIZE= 131072 zfsboot2: zfsboot.ld @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 ${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \ -o ${.TARGET} -P 1 zfsboot.bin zfsboot.ldr: cp /dev/null ${.TARGET} zfsboot.bin: zfsboot.out ${OBJCOPY} -S -O binary zfsboot.out ${.TARGET} -zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o skein.o skein_block.o - ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSA32} +zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o + ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBZFSBOOT} ${LIBGELIBOOT} ${LIBSA32} SRCS= zfsboot.c - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend zfsboot.o: machine -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${.CURDIR}/../../../i386/include machine -.endif .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.zfsldr.S= ${CLANG_NO_IAS} Index: stable/11/sys/boot/i386/zfsloader/Makefile =================================================================== --- stable/11/sys/boot/i386/zfsloader/Makefile (revision 329139) +++ stable/11/sys/boot/i386/zfsloader/Makefile (revision 329140) @@ -1,12 +1,7 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../loader - LOADER= zfsloader NEWVERSWHAT= "ZFS enabled bootstrap loader" x86 -LOADER_ZFS_SUPPORT=yes -LOADER_ONLY= yes -MAN= +HAVE_ZFS= yes .include "${.CURDIR}/../loader/Makefile" - Index: stable/11/sys/boot/libsa/Makefile =================================================================== --- stable/11/sys/boot/libsa/Makefile (revision 329139) +++ stable/11/sys/boot/libsa/Makefile (revision 329140) @@ -1,160 +1,160 @@ # $FreeBSD$ # Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $ # # Notes: # - We don't use the libc strerror/sys_errlist because the string table is # quite large. # PACKAGE=lib${LIB} MK_PROFILE= no MK_SSP= no -.include +.include -LIBSTAND_SRC?= ${.CURDIR} -LIBSTAND_CPUARCH?=${MACHINE_CPUARCH} -LIBC_SRC= ${SRCTOP_LIBC}/../libc +INTERNALLIB= +LIBSA_CPUARCH?=${MACHINE_CPUARCH} +LIBC_SRC= ${SRCTOP}/lib/libc LIB?= sa NO_PIC= WARNS?= 0 -CFLAGS+= -I${LIBSTAND_SRC} +CFLAGS+= -I${SASRC} # standalone components and stuff we have modified locally SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \ globals.c pager.c panic.c printf.c strdup.c strerror.c strtol.c strtoul.c \ random.c sbrk.c twiddle.c zalloc.c zalloc_malloc.c # private (pruned) versions of libc string functions SRCS+= strcasecmp.c .PATH: ${LIBC_SRC}/net SRCS+= ntoh.c # string functions from libc .PATH: ${LIBC_SRC}/string SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \ memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \ qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c .if ${MACHINE_CPUARCH} == "arm" .PATH: ${LIBC_SRC}/arm/gen # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). # Also, the fpu is not available in a standalone environment. .if ${COMPILER_VERSION} < 30800 CFLAGS.clang+= -mllvm -arm-use-movt=0 .else CFLAGS.clang+= -mno-movt .endif CFLAGS.clang+= -mfpu=none # Compiler support functions .PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/ # __clzsi2 and ctzsi2 for various builtin functions SRCS+= clzsi2.c ctzsi2.c # Divide and modulus functions called by the compiler SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c .PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/arm/ SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S .endif .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" .PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen .endif .if ${MACHINE_CPUARCH} == "powerpc" .PATH: ${LIBC_SRC}/quad SRCS+= ashldi3.c ashrdi3.c SRCS+= syncicache.c .endif # uuid functions from libc .PATH: ${LIBC_SRC}/uuid SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c # _setjmp/_longjmp -.PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH} +.PATH: ${SASRC}/${LIBSA_CPUARCH} SRCS+= _setjmp.S # decompression functionality from libbz2 # NOTE: to actually test this functionality after libbz2 upgrade compile # loader(8) with LOADER_BZIP2_SUPPORT defined .PATH: ${SRCTOP}/contrib/bzip2 CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS -SRCS+= libstand_bzlib_private.h +SRCS+= libsa_bzlib_private.h .for file in bzlib.c crctable.c decompress.c huffman.c randtable.c SRCS+= _${file} CLEANFILES+= _${file} _${file}: ${file} - sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \ + sed "s|bzlib_private\.h|libsa_bzlib_private.h|" \ ${.ALLSRC} > ${.TARGET} .endfor -CLEANFILES+= libstand_bzlib_private.h -libstand_bzlib_private.h: bzlib_private.h +CLEANFILES+= libsa_bzlib_private.h +libsa_bzlib_private.h: bzlib_private.h sed -e 's||"stand.h"|' \ ${.ALLSRC} > ${.TARGET} # decompression functionality from zlib .PATH: ${SRCTOP}/contrib/zlib -CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../../contrib/zlib -SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h +CFLAGS+=-DHAVE_MEMCPY -I${SRCTOP}/contrib/zlib +SRCS+= adler32.c crc32.c libsa_zutil.h libsa_gzguts.h .for file in infback.c inffast.c inflate.c inftrees.c zutil.c SRCS+= _${file} CLEANFILES+= _${file} _${file}: ${file} - sed -e "s|zutil\.h|libstand_zutil.h|" \ - -e "s|gzguts\.h|libstand_gzguts.h|" \ + sed -e "s|zutil\.h|libsa_zutil.h|" \ + -e "s|gzguts\.h|libsa_gzguts.h|" \ ${.ALLSRC} > ${.TARGET} .endfor # depend on stand.h being able to be included multiple times .for file in zutil.h gzguts.h -CLEANFILES+= libstand_${file} -libstand_${file}: ${file} +CLEANFILES+= libsa_${file} +libsa_${file}: ${file} sed -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ ${.ALLSRC} > ${.TARGET} .endfor # io routines SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ fstat.c close.c lseek.c open.c read.c write.c readdir.c # network routines SRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c # network info services: SRCS+= bootp.c rarp.c bootparam.c # boot filesystems SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c SRCS+= dosfs.c ext2fs.c SRCS+= splitfs.c SRCS+= pkgfs.c .if ${MK_NAND} != "no" SRCS+= nandfs.c .endif # explicit_bzero -.PATH: ${SRCTOP}/sys/libkern +.PATH: ${SYSDIR}/libkern SRCS+= explicit_bzero.c .include .include Index: stable/11/sys/boot/libsa/ip.c =================================================================== --- stable/11/sys/boot/libsa/ip.c (revision 329139) +++ stable/11/sys/boot/libsa/ip.c (revision 329140) @@ -1,422 +1,423 @@ /* * Copyright (c) 1992 Regents of the University of California. * All rights reserved. * * This software was developed by the Computer Systems Engineering group * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and * contributed to Berkeley. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * The send and receive functions were originally implemented in udp.c and * moved here. Also it is likely some more cleanup can be done, especially * once we will implement the support for tcp. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include "stand.h" #include "net.h" typedef STAILQ_HEAD(ipqueue, ip_queue) ip_queue_t; struct ip_queue { void *ipq_pkt; struct ip *ipq_hdr; STAILQ_ENTRY(ip_queue) ipq_next; }; /* * Fragment re-assembly queue. */ struct ip_reasm { struct in_addr ip_src; struct in_addr ip_dst; uint16_t ip_id; uint8_t ip_proto; uint8_t ip_ttl; size_t ip_total_size; ip_queue_t ip_queue; void *ip_pkt; struct ip *ip_hdr; STAILQ_ENTRY(ip_reasm) ip_next; }; STAILQ_HEAD(ire_list, ip_reasm) ire_list = STAILQ_HEAD_INITIALIZER(ire_list); /* Caller must leave room for ethernet and ip headers in front!! */ ssize_t sendip(struct iodesc *d, void *pkt, size_t len, uint8_t proto) { ssize_t cc; struct ip *ip; u_char *ea; #ifdef NET_DEBUG if (debug) { printf("sendip: proto: %x d=%p called.\n", proto, (void *)d); if (d) { printf("saddr: %s:%d", inet_ntoa(d->myip), ntohs(d->myport)); printf(" daddr: %s:%d\n", inet_ntoa(d->destip), ntohs(d->destport)); } } #endif ip = (struct ip *)pkt - 1; len += sizeof(*ip); bzero(ip, sizeof(*ip)); ip->ip_v = IPVERSION; /* half-char */ ip->ip_hl = sizeof(*ip) >> 2; /* half-char */ ip->ip_len = htons(len); ip->ip_p = proto; /* char */ ip->ip_ttl = IPDEFTTL; /* char */ ip->ip_src = d->myip; ip->ip_dst = d->destip; ip->ip_sum = in_cksum(ip, sizeof(*ip)); /* short, but special */ if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 || netmask == 0 || SAMENET(ip->ip_src, ip->ip_dst, netmask)) ea = arpwhohas(d, ip->ip_dst); else ea = arpwhohas(d, gateip); cc = sendether(d, ip, len, ea, ETHERTYPE_IP); if (cc == -1) return (-1); if (cc != len) panic("sendip: bad write (%zd != %zd)", cc, len); return (cc - sizeof(*ip)); } static void ip_reasm_free(struct ip_reasm *ipr) { struct ip_queue *ipq; while ((ipq = STAILQ_FIRST(&ipr->ip_queue)) != NULL) { STAILQ_REMOVE_HEAD(&ipr->ip_queue, ipq_next); free(ipq->ipq_pkt); free(ipq); } free(ipr->ip_pkt); free(ipr); } static int ip_reasm_add(struct ip_reasm *ipr, void *pkt, struct ip *ip) { struct ip_queue *ipq, *prev, *p; if ((ipq = calloc(1, sizeof (*ipq))) == NULL) return (1); ipq->ipq_pkt = pkt; ipq->ipq_hdr = ip; prev = NULL; STAILQ_FOREACH(p, &ipr->ip_queue, ipq_next) { if ((ntohs(p->ipq_hdr->ip_off) & IP_OFFMASK) < (ntohs(ip->ip_off) & IP_OFFMASK)) { prev = p; continue; } if (prev == NULL) break; STAILQ_INSERT_AFTER(&ipr->ip_queue, prev, ipq, ipq_next); return (0); } STAILQ_INSERT_HEAD(&ipr->ip_queue, ipq, ipq_next); return (0); } /* * Receive a IP packet and validate it is for us. */ static ssize_t readipv4(struct iodesc *d, void **pkt, void **payload, time_t tleft, uint8_t proto) { ssize_t n; size_t hlen; struct ether_header *eh; struct ip *ip; struct udphdr *uh; uint16_t etype; /* host order */ char *ptr; struct ip_reasm *ipr; struct ip_queue *ipq, *last; #ifdef NET_DEBUG if (debug) printf("readip: called\n"); #endif ip = NULL; ptr = NULL; n = readether(d, (void **)&ptr, (void **)&ip, tleft, &etype); if (n == -1 || n < sizeof(*ip) + sizeof(*uh)) { free(ptr); return (-1); } /* Ethernet address checks now in readether() */ /* Need to respond to ARP requests. */ if (etype == ETHERTYPE_ARP) { struct arphdr *ah = (void *)ip; if (ah->ar_op == htons(ARPOP_REQUEST)) { /* Send ARP reply */ arp_reply(d, ah); } free(ptr); errno = EAGAIN; /* Call me again. */ return (-1); } if (etype != ETHERTYPE_IP) { #ifdef NET_DEBUG if (debug) printf("readip: not IP. ether_type=%x\n", etype); #endif free(ptr); return (-1); } /* Check ip header */ - if (ip->ip_v != IPVERSION || - ip->ip_p != proto) { /* half char */ + if (ip->ip_v != IPVERSION || /* half char */ + ip->ip_p != proto) { #ifdef NET_DEBUG if (debug) { printf("readip: IP version or proto. ip_v=%d ip_p=%d\n", ip->ip_v, ip->ip_p); } #endif free(ptr); return (-1); } hlen = ip->ip_hl << 2; if (hlen < sizeof(*ip) || in_cksum(ip, hlen) != 0) { #ifdef NET_DEBUG if (debug) printf("readip: short hdr or bad cksum.\n"); #endif free(ptr); return (-1); } if (n < ntohs(ip->ip_len)) { #ifdef NET_DEBUG if (debug) printf("readip: bad length %d < %d.\n", (int)n, ntohs(ip->ip_len)); #endif free(ptr); return (-1); } if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) { #ifdef NET_DEBUG if (debug) { printf("readip: bad saddr %s != ", inet_ntoa(d->myip)); printf("%s\n", inet_ntoa(ip->ip_dst)); } #endif free(ptr); return (-1); } /* Unfragmented packet. */ if ((ntohs(ip->ip_off) & IP_MF) == 0 && (ntohs(ip->ip_off) & IP_OFFMASK) == 0) { uh = (struct udphdr *)((uintptr_t)ip + sizeof (*ip)); /* If there were ip options, make them go away */ if (hlen != sizeof(*ip)) { bcopy(((u_char *)ip) + hlen, uh, uh->uh_ulen - hlen); ip->ip_len = htons(sizeof(*ip)); n -= hlen - sizeof(*ip); } n = (n > (ntohs(ip->ip_len) - sizeof(*ip))) ? ntohs(ip->ip_len) - sizeof(*ip) : n; *pkt = ptr; *payload = (void *)((uintptr_t)ip + sizeof(*ip)); return (n); } STAILQ_FOREACH(ipr, &ire_list, ip_next) { if (ipr->ip_src.s_addr == ip->ip_src.s_addr && ipr->ip_dst.s_addr == ip->ip_dst.s_addr && ipr->ip_id == ip->ip_id && ipr->ip_proto == ip->ip_p) break; } /* Allocate new reassembly entry */ if (ipr == NULL) { if ((ipr = calloc(1, sizeof (*ipr))) == NULL) { free(ptr); return (-1); } ipr->ip_src = ip->ip_src; ipr->ip_dst = ip->ip_dst; ipr->ip_id = ip->ip_id; ipr->ip_proto = ip->ip_p; ipr->ip_ttl = MAXTTL; STAILQ_INIT(&ipr->ip_queue); STAILQ_INSERT_TAIL(&ire_list, ipr, ip_next); } if (ip_reasm_add(ipr, ptr, ip) != 0) { STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next); free(ipr); free(ptr); return (-1); } if ((ntohs(ip->ip_off) & IP_MF) == 0) { ipr->ip_total_size = (8 * (ntohs(ip->ip_off) & IP_OFFMASK)); ipr->ip_total_size += n + sizeof (*ip); ipr->ip_total_size += sizeof (struct ether_header); ipr->ip_pkt = malloc(ipr->ip_total_size + 2); if (ipr->ip_pkt == NULL) { STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next); ip_reasm_free(ipr); return (-1); } } /* * If we do not have re-assembly buffer ipr->ip_pkt, we are still * missing fragments, so just restart the read. */ if (ipr->ip_pkt == NULL) { errno = EAGAIN; return (-1); } /* * Walk the packet list in reassembly queue, if we got all the * fragments, build the packet. */ n = 0; last = NULL; STAILQ_FOREACH(ipq, &ipr->ip_queue, ipq_next) { if ((ntohs(ipq->ipq_hdr->ip_off) & IP_OFFMASK) != n / 8) { - errno = EAGAIN; + STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next); + ip_reasm_free(ipr); return (-1); } n += ntohs(ipq->ipq_hdr->ip_len) - (ipq->ipq_hdr->ip_hl << 2); last = ipq; } if ((ntohs(last->ipq_hdr->ip_off) & IP_MF) != 0) { errno = EAGAIN; return (-1); } ipq = STAILQ_FIRST(&ipr->ip_queue); /* Fabricate ethernet header */ eh = (struct ether_header *)((uintptr_t)ipr->ip_pkt + 2); bcopy((void *)((uintptr_t)ipq->ipq_pkt + 2), eh, sizeof (*eh)); /* Fabricate IP header */ ipr->ip_hdr = (struct ip *)((uintptr_t)eh + sizeof (*eh)); bcopy(ipq->ipq_hdr, ipr->ip_hdr, sizeof (*ipr->ip_hdr)); ipr->ip_hdr->ip_hl = sizeof (*ipr->ip_hdr) >> 2; ipr->ip_hdr->ip_len = htons(n); ipr->ip_hdr->ip_sum = 0; ipr->ip_hdr->ip_sum = in_cksum(ipr->ip_hdr, sizeof (*ipr->ip_hdr)); n = 0; ptr = (char *)((uintptr_t)ipr->ip_hdr + sizeof (*ipr->ip_hdr)); STAILQ_FOREACH(ipq, &ipr->ip_queue, ipq_next) { char *data; size_t len; hlen = ipq->ipq_hdr->ip_hl << 2; len = ntohs(ipq->ipq_hdr->ip_len) - hlen; data = (char *)((uintptr_t)ipq->ipq_hdr + hlen); bcopy(data, ptr + n, len); n += len; } *pkt = ipr->ip_pkt; ipr->ip_pkt = NULL; /* Avoid free from ip_reasm_free() */ *payload = ptr; /* Clean up the reassembly list */ while ((ipr = STAILQ_FIRST(&ire_list)) != NULL) { STAILQ_REMOVE_HEAD(&ire_list, ip_next); ip_reasm_free(ipr); } return (n); } /* * Receive a IP packet. */ ssize_t readip(struct iodesc *d, void **pkt, void **payload, time_t tleft, uint8_t proto) { time_t t; ssize_t ret = -1; t = getsecs(); while ((getsecs() - t) < tleft) { errno = 0; ret = readipv4(d, pkt, payload, tleft, proto); if (errno != EAGAIN) break; } return (ret); } Index: stable/11/sys/boot/libsa32/Makefile =================================================================== --- stable/11/sys/boot/libsa32/Makefile (revision 329139) +++ stable/11/sys/boot/libsa32/Makefile (revision 329140) @@ -1,26 +1,11 @@ # $FreeBSD$ -.include +DO32=1 -.include "../Makefile.inc" +.include LIB=sa32 -.if ${MACHINE_CPUARCH} == "amd64" -LIBSTAND_CPUARCH=i386 -.else -LIBSTAND_CPUARCH=${MACHINE_CPUARCH} -.endif +LIBSA_CPUARCH=${MACHINE_CPUARCH:C/amd64/i386/} -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -I. -.endif - .PATH: ${SASRC} .include "${SASRC}/Makefile" - -.if ${MACHINE_CPUARCH} == "amd64" -CLEANFILES+= machine -beforedepend ${OBJS}: machine -machine: .NOMETA - ln -fs ${.CURDIR}/../../i386/include machine -.endif Index: stable/11/sys/boot/loader.mk =================================================================== --- stable/11/sys/boot/loader.mk (nonexistent) +++ stable/11/sys/boot/loader.mk (revision 329140) @@ -0,0 +1,112 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/boot/common ${SRCTOP}/sys/boot/libsa + +.PATH: ${LDRSRC} ${BOOTSRC}/libsa + +CFLAGS+=-I${LDRSRC} + +SRCS+= boot.c commands.c console.c devopen.c interp.c +SRCS+= interp_backslash.c interp_parse.c ls.c misc.c +SRCS+= module.c + +.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64" +SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c +SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c +.elif ${MACHINE} == "pc98" +SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c +.elif ${MACHINE_CPUARCH} == "aarch64" +SRCS+= load_elf64.c reloc_elf64.c +.elif ${MACHINE_CPUARCH} == "arm" +SRCS+= load_elf32.c reloc_elf32.c +.elif ${MACHINE_CPUARCH} == "powerpc" +SRCS+= load_elf32.c reloc_elf32.c +SRCS+= load_elf64.c reloc_elf64.c +.elif ${MACHINE_CPUARCH} == "sparc64" +SRCS+= load_elf64.c reloc_elf64.c +.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" +SRCS+= load_elf64.c reloc_elf64.c +.elif ${MACHINE} == "mips" +SRCS+= load_elf32.c reloc_elf32.c +.endif + +.if defined(LOADER_NET_SUPPORT) +SRCS+= dev_net.c +.endif + +.if !defined(LOADER_NO_DISK_SUPPORT) +SRCS+= disk.c part.c +CFLAGS+= -DLOADER_DISK_SUPPORT +.if !defined(LOADER_NO_GPT_SUPPORT) +CFLAGS+= -DLOADER_GPT_SUPPORT +.endif +.if !defined(LOADER_NO_MBR_SUPPORT) +CFLAGS+= -DLOADER_MBR_SUPPORT +.endif +.endif +.if !defined(LOADER_NO_GELI_SUPPORT) +CFLAGS+= -DLOADER_GELI_SUPPORT +.endif + +.if defined(HAVE_BCACHE) +SRCS+= bcache.c +.endif + +.if defined(MD_IMAGE_SIZE) +CFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE} +SRCS+= md.c +.else +CLEANFILES+= md.o +.endif + +# Machine-independant ISA PnP +.if defined(HAVE_ISABUS) +SRCS+= isapnp.c +.endif +.if defined(HAVE_PNP) +SRCS+= pnp.c +.endif + +# Forth interpreter +.if defined(BOOT_FORTH) +SRCS+= interp_forth.c +.include "${BOOTSRC}/ficl.mk" +.endif + +.if defined(BOOT_PROMPT_123) +CFLAGS+= -DBOOT_PROMPT_123 +.endif + +.if defined(LOADER_INSTALL_SUPPORT) +SRCS+= install.c +.endif + +.if defined(HAVE_ZFS) +CFLAGS+= -DLOADER_ZFS_SUPPORT +CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SYSDIR}/cddl/boot/zfs +.if ${MACHINE} == "amd64" +# Have to override to use 32-bit version of zfs library... +# kinda lame to select that there XXX +LIBZFSBOOT= ${BOOTOBJ}/zfs32/libzfsboot.a +.else +LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a +.endif +.endif + +CLEANFILES+= vers.c +VERSION_FILE?= ${.CURDIR}/version +.if ${MK_REPRODUCIBLE_BUILD} != no +REPRO_FLAG= -r +.endif +vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE} + sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \ + ${NEWVERSWHAT} + +.if !empty(HELP_FILES) +CLEANFILES+= loader.help +FILES+= loader.help + +loader.help: ${HELP_FILES} + cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET} +.endif Property changes on: stable/11/sys/boot/loader.mk ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/man/Makefile =================================================================== --- stable/11/sys/boot/man/Makefile (revision 329139) +++ stable/11/sys/boot/man/Makefile (revision 329140) @@ -1,10 +1,10 @@ # $FreeBSD$ -.include +.include MAN+= loader.8 .if ${MK_ZFS} != "no" MAN+= zfsloader.8 .endif .include Index: stable/11/sys/boot/mips/beri/Makefile.inc =================================================================== --- stable/11/sys/boot/mips/beri/Makefile.inc (revision 329139) +++ stable/11/sys/boot/mips/beri/Makefile.inc (revision 329140) @@ -1,7 +1,6 @@ # $FreeBSD$ -BINDIR?= /boot CFLAGS+= -ffreestanding LDFLAGS+= -nostdlib .include "../Makefile.inc" Index: stable/11/sys/boot/mips/beri/boot2/Makefile =================================================================== --- stable/11/sys/boot/mips/beri/boot2/Makefile (revision 329139) +++ stable/11/sys/boot/mips/beri/boot2/Makefile (revision 329140) @@ -1,85 +1,86 @@ #- # Copyright (c) 2013-2014 Robert N. M. Watson # All rights reserved. # # This software was developed by SRI International and the University of # Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) # ("CTSRD"), as part of the DARPA CRASH research programme. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ -BINDIR?= /boot +.include + INSTALLFLAGS= -b LOADERS= flashboot jtagboot FILES= ${LOADERS} ${LOADERS:S/$/.md5/} SRCS= relocate.S \ start.S \ boot2.c \ altera_jtag_uart.c \ cfi.c \ sdcard.c MAN= AFLAGS= -G0 CFLAGS= -ffreestanding \ -I${.CURDIR} \ - -I${.CURDIR}/../../../common \ - -I${.CURDIR}/../../../.. \ + -I${SASRC} \ + -I${LDRSRC} \ -D_KERNEL \ -Wall \ -G0 \ -fno-pic -mno-abicalls \ -msoft-float \ -g LDFLAGS= -nostdlib \ -static \ -Wl,-N \ -G0 \ -L${.CURDIR} -.PATH: ${.CURDIR}/../common -CFLAGS+= -I${.CURDIR}/../common +.PATH: ${BOOTSRC}/mips/beri/common +CFLAGS+= -I${BOOTSRC}/mips/beri/common flashboot.elf: relocate.o start.o boot2.o altera_jtag_uart.o cfi.o sdcard.o ${CC} ${LDFLAGS} -T ${.CURDIR}/flashboot.ldscript -o ${.TARGET} \ ${.ALLSRC} ${LIBSA} flashboot: flashboot.elf ${OBJCOPY} -S -O binary ${.TARGET}.elf ${.TARGET} flashboot.md5: flashboot md5 flashboot > flashboot.md5 jtagboot: start.o boot2.o altera_jtag_uart.o cfi.o sdcard.o ${CC} ${LDFLAGS} -T ${.CURDIR}/jtagboot.ldscript -o ${.TARGET} \ ${.ALLSRC} ${LIBSA} jtagboot.md5: jtagboot md5 jtagboot > jtagboot.md5 CLEANFILES+= flashboot.elf .include Index: stable/11/sys/boot/mips/beri/loader/Makefile =================================================================== --- stable/11/sys/boot/mips/beri/loader/Makefile (revision 329139) +++ stable/11/sys/boot/mips/beri/loader/Makefile (revision 329140) @@ -1,135 +1,111 @@ #- # Copyright (c) 2013-2014 Robert N. M. Watson # All rights reserved. # # This software was developed by SRI International and the University of # Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) # ("CTSRD"), as part of the DARPA CRASH research programme. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ -.include +LOADER_MSDOS_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no +LOADER_GZIP_SUPPORT?= yes +LOADER_BZIP2_SUPPORT?= yes + +.include + MK_SSP= no MAN= PROG?= loader NEWVERSWHAT= "BERI loader" ${MACHINE_CPUARCH} INSTALLFLAGS= -b # Architecture-specific loader code SRCS= start.S \ main.c \ devicename.c \ exec.c \ metadata.c \ vers.c \ arch.c # libstand front-ends for shared driver code SRCS+= beri_console.c \ beri_disk_cfi.c \ beri_disk_sdcard.c # Common code with boot2 SRCS+= altera_jtag_uart.c \ cfi.c \ sdcard.c # Since we don't have a backward compatibility issue, default to this on BERI. CFLAGS+= -DBOOT_PROMPT_123 -CFLAGS+= -DLOADER_DISK_SUPPORT -CFLAGS+= -DLOADER_UFS_SUPPORT -CFLAGS+= -DLOADER_GZIP_SUPPORT -CFLAGS+= -DLOADER_BZIP2_SUPPORT +HELP_FILES+= help.mips -#CFLAGS+= -DLOADER_NET_SUPPORT -#CFLAGS+= -DLOADER_NFS_SUPPORT -#CFLAGS+= -DLOADER_TFTP_SUPPORT - -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../../ficl -CFLAGS+= -I${.CURDIR}/../../../ficl/mips64 -LIBFICL= ${.OBJDIR}/../../../ficl/libficl.a -.endif - -# Common code across BERI boot loader parts -.PATH: ${.CURDIR}/../common -CFLAGS+= -I${.CURDIR}/../common - # Always add MI sources -.PATH: ${.CURDIR}/../../../common -.include "${.CURDIR}/../../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../../common +.include "${BOOTSRC}/loader.mk" # BERI files common to boot2 and loader -.PATH: ${.CURDIR}/../common -CFLAGS+= -I${.CURDIR}/../common +.PATH: ${BOOTSRC}/mips/beri/common +CFLAGS+= -I${BOOTSRC}/mips/beri/common # Loader-specific MD headers CFLAGS+= -I${.CURDIR} -CLEANFILES+= loader.help - # Generate code appropriate for the loader environment CFLAGS+= -G0 \ -fno-pic \ -mno-abicalls \ -msoft-float \ -g LDFLAGS= -nostdlib \ -static \ -T ${.CURDIR}/loader.ldscript \ -L${.CURDIR} \ -e __start DPADD= ${LIBFICL} ${LIBSA} LDADD= ${LIBFICL} ${LIBSA} -loader.help: help.common help.mips - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../../common/merge_help.awk > ${.TARGET} - -.PATH: ${.CURDIR}/../../../forth -.include "${.CURDIR}/../../../forth/Makefile.inc" - -FILES+= loader.rc menu.rc - .if defined(LOADER_USB_SUPPORT) # Do garbage collection CFLAGS+= -ffunction-sections -fdata-sections CFLAGS+= -Wl,--gc-sections # Link USB BOOT library -LDADD+= ${.OBJDIR}/../../../usb/libusbboot.a -CFLAGS+= -I${.CURDIR}/../../../usb +LDADD+= ${BOOTOBJ}/usb/libusbboot.a +CFLAGS+= -I${BOOTSRC}/usb # Define USB SUPPORT CFLAGS+= -DLOADER_USB_SUPPORT .endif all: loader .include Index: stable/11/sys/boot/mips/uboot/Makefile =================================================================== --- stable/11/sys/boot/mips/uboot/Makefile (revision 329139) +++ stable/11/sys/boot/mips/uboot/Makefile (revision 329140) @@ -1,156 +1,57 @@ # $FreeBSD$ -.include +LOADER_CD9660_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no +LOADER_MSDOS_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= no +LOADER_BZIP2_SUPPORT?= no -FILES= ubldr +.include +FILES+= ubldr + NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} -BINDIR?= /boot INSTALLFLAGS= -b WARNS?= 1 # Address at which ubldr will be loaded. # This varies for different boards and SOCs. UBLDR_LOADADDR?= 0xffffffff80800000 # Architecture-specific loader code SRCS= start.S conf.c vers.c -.if !defined(LOADER_NO_DISK_SUPPORT) -LOADER_DISK_SUPPORT?= yes -.else -LOADER_DISK_SUPPORT= no -.endif -LOADER_MSDOS_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= no -LOADER_EXT2FS_SUPPORT?= no -.if ${MK_NAND} != "no" -LOADER_NANDFS_SUPPORT?= yes -.else -LOADER_NANDFS_SUPPORT?= no -.endif -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= no -LOADER_BZIP2_SUPPORT?= no -.if ${MK_FDT} != "no" -LOADER_FDT_SUPPORT= yes -.else -LOADER_FDT_SUPPORT= no -.endif +HELP_FILES+= help.uboot ${BOOTSRC}/fdt/help.fdt -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_MSDOS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_MSDOS_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_EXT2FS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_EXT2FS_SUPPORT -.endif -.if ${LOADER_NANDFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NANDFS_SUPPORT -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${LOADER_FDT_SUPPORT} == "yes" -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt/libuboot_fdt.a -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a -.endif - -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -.if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" -CFLAGS+= -I${.CURDIR}/../../ficl/mips64 -.else -CFLAGS+= -I${.CURDIR}/../../ficl/mips -.endif -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a -.endif - # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -CFLAGS+= -I. +.include "${BOOTSRC}/loader.mk" -CLEANFILES+= loader.help - CFLAGS+= -ffreestanding -msoft-float -g LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH} -# Pull in common loader code -.PATH: ${.CURDIR}/../../uboot/common -.include "${.CURDIR}/../../uboot/common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../uboot/common +.include "${BOOTSRC}/uboot.mk" -# U-Boot standalone support library -LIBUBOOT= ${.OBJDIR}/../../uboot/lib/libuboot.a -CFLAGS+= -I${.CURDIR}/../../uboot/lib -CFLAGS+= -I${.OBJDIR}/../../uboot/lib - -# clang doesn't understand %D as a specifier to printf -#NO_WERROR.clang= -#NO_WERROR= - DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} OBJS+= ${SRCS:N*.h:R:S/$/.o/g} -loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - ldscript.abs: echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >${.TARGET} ldscript.pie: echo "UBLDR_LOADADDR = 0;" >${.TARGET} ubldr: ${OBJS} ldscript.abs ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD} ${CC} ${CFLAGS} -T ldscript.abs ${LDFLAGS} \ -o ${.TARGET} ${OBJS} ${LDADD} ${OBJCOPY} -S -O binary ubldr ubldr.bin CLEANFILES+= ldscript.abs ldscript.pie ubldr ubldr.pie ubldr.bin - -.if !defined(LOADER_ONLY) -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -# Install loader.rc. -FILES+= loader.rc -# Put sample menu.rc on disk but don't enable it by default. -FILES+= menu.rc -FILESNAME_menu.rc= menu.rc.sample -.endif .include .include Index: stable/11/sys/boot/ofw/Makefile.inc =================================================================== --- stable/11/sys/boot/ofw/Makefile.inc (revision 329139) +++ stable/11/sys/boot/ofw/Makefile.inc (revision 329140) @@ -1,8 +1,3 @@ # $FreeBSD$ -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -LDFLAGS+= -m elf32ppc_fbsd -.endif - .include "../Makefile.inc" Index: stable/11/sys/boot/ofw/libofw/Makefile =================================================================== --- stable/11/sys/boot/ofw/libofw/Makefile (revision 329139) +++ stable/11/sys/boot/ofw/libofw/Makefile (revision 329140) @@ -1,33 +1,28 @@ # $FreeBSD$ +.include + LIB= ofw INTERNALLIB= SRCS= devicename.c elf_freebsd.c ofw_console.c ofw_copy.c ofw_disk.c \ ofw_memory.c ofw_module.c ofw_net.c ofw_reboot.c \ ofw_time.c openfirm.c -.PATH: ${.CURDIR}/../../zfs +.PATH: ${ZFSSRC} SRCS+= devicename_stubs.c # Pick up the bootstrap header for some interface items -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +CFLAGS+= -I${LDRSRC} CFLAGS+= -ffreestanding .if ${MACHINE_CPUARCH} == "powerpc" CFLAGS+= -msoft-float SRCS+= ppc64_elf_freebsd.c .endif .ifdef(BOOT_DISK_DEBUG) # Make the disk code more talkative CFLAGS+= -DDISK_DEBUG .endif -machine: .NOMETA - ln -sf ${.CURDIR}/../../../${MACHINE_CPUARCH}/include machine - -CLEANFILES+= machine - .include - -beforedepend ${OBJS}: machine Index: stable/11/sys/boot/powerpc/Makefile =================================================================== --- stable/11/sys/boot/powerpc/Makefile (revision 329139) +++ stable/11/sys/boot/powerpc/Makefile (revision 329140) @@ -1,5 +1,13 @@ # $FreeBSD$ -SUBDIR= boot1.chrp kboot ofw ps3 uboot +.include + +SUBDIR= boot1.chrp ofw uboot +.if ${MACHINE_ARCH} != "powerpcspe" +SUBDIR+= ps3 +.endif +.if ${MK_FDT} == "yes" +SUBDIR+= kboot +.endif .include Index: stable/11/sys/boot/powerpc/Makefile.inc =================================================================== --- stable/11/sys/boot/powerpc/Makefile.inc (revision 329139) +++ stable/11/sys/boot/powerpc/Makefile.inc (revision 329140) @@ -1,7 +1,3 @@ # $FreeBSD$ -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -.endif - .include "../Makefile.inc" Index: stable/11/sys/boot/powerpc/boot1.chrp/Makefile =================================================================== --- stable/11/sys/boot/powerpc/boot1.chrp/Makefile (revision 329139) +++ stable/11/sys/boot/powerpc/boot1.chrp/Makefile (revision 329140) @@ -1,43 +1,42 @@ # $FreeBSD$ +.include + SSP_CFLAGS= PROG= boot1.elf NEWVERSWHAT= "Open Firmware boot block" ${MACHINE_ARCH} -BINDIR?= /boot INSTALLFLAGS= -b FILES= boot1.hfs SRCS= boot1.c ashldi3.c syncicache.c MAN= CFLAGS= -ffreestanding -msoft-float \ - -I${.CURDIR}/../../common -I${.CURDIR}/../../../ \ + -I${LDRSRC} -I${SYSDIR} -I${SASRC} \ -D_STANDALONE LDFLAGS=-nostdlib -static -Wl,-N -.include "../Makefile.inc" +.PATH: ${SYSDIR}/libkern ${SRCTOP}/lib/libc/powerpc/gen ${.CURDIR} -.PATH: ${.CURDIR}/../../../libkern ${.CURDIR}/../../../../lib/libc/powerpc/gen ${.CURDIR} - # The following inserts out objects into a template HFS # created by generate-hfs.sh .include "${.CURDIR}/Makefile.hfs" boot1.hfs: boot1.elf bootinfo.txt echo ${.OBJDIR} uudecode ${.CURDIR}/hfs.tmpl.bz2.uu mv hfs.tmpl.bz2 ${.TARGET}.bz2 bzip2 -f -d ${.TARGET}.bz2 ${DD} if=boot1.elf of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc ${DD} if=${.CURDIR}/bootinfo.txt of=${.TARGET} seek=${BOOTINFO_OFFSET} \ conv=notrunc -CLEANFILES= boot1.hfs +CLEANFILES+= boot1.hfs boot1.o: ${SASRC}/ufsread.c .include Index: stable/11/sys/boot/powerpc/kboot/help.kboot =================================================================== --- stable/11/sys/boot/powerpc/kboot/help.kboot (revision 329139) +++ stable/11/sys/boot/powerpc/kboot/help.kboot (nonexistent) @@ -1 +0,0 @@ -$FreeBSD: user/nwhitehorn/kboot/powerpc/kboot/help.kboot 217044 2011-01-06 04:12:29Z nwhitehorn $ Index: stable/11/sys/boot/powerpc/kboot/Makefile =================================================================== --- stable/11/sys/boot/powerpc/kboot/Makefile (revision 329139) +++ stable/11/sys/boot/powerpc/kboot/Makefile (revision 329140) @@ -1,108 +1,50 @@ # $FreeBSD$ -.include +LOADER_CD9660_SUPPORT?= yes +LOADER_MSDOS_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= yes +LOADER_BZIP2_SUPPORT?= no + +.include MK_SSP= no MAN= PROG= loader.kboot NEWVERSWHAT= "kboot loader" ${MACHINE_ARCH} -BINDIR?= /boot INSTALLFLAGS= -b # Architecture-specific loader code SRCS= conf.c metadata.c vers.c main.c ppc64_elf_freebsd.c SRCS+= host_syscall.S hostcons.c hostdisk.c kerneltramp.S kbootfdt.c SRCS+= ucmpdi2.c -LOADER_DISK_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= yes -LOADER_EXT2FS_SUPPORT?= yes -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= yes -LOADER_FDT_SUPPORT= yes -LOADER_BZIP2_SUPPORT?= no +.include "${BOOTSRC}/fdt.mk" -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_EXT2FS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_EXT2FS_SUPPORT -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${LOADER_FDT_SUPPORT} == "yes" -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -I${.CURDIR}/../../../contrib/libfdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a -.endif - - -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/powerpc -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a -.endif - CFLAGS+= -mcpu=powerpc64 # Always add MI sources -.PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -CFLAGS+= -I. +HELP_FILES= # Disable +.include "${BOOTSRC}/loader.mk" +.PATH: ${SYSDIR}/libkern -CLEANFILES+= loader.help - CFLAGS+= -Wall -ffreestanding -msoft-float -DAIM # load address. set in linker script RELOC?= 0x0 CFLAGS+= -DRELOC=${RELOC} LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc # 64-bit bridge extensions CFLAGS+= -Wa,-mppc64bridge -# Pull in common loader code -#.PATH: ${.CURDIR}/../../ofw/common -#.include "${.CURDIR}/../../ofw/common/Makefile.inc" +DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA} +LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA} -DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA32} -LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA32} - -loader.help: help.common help.kboot ${.CURDIR}/../../fdt/help.fdt - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -FILES+= loader.rc menu.rc +HELP_FILES+= ${FDTSRC}/help.fdt .include Index: stable/11/sys/boot/powerpc/ofw/help.ofw =================================================================== --- stable/11/sys/boot/powerpc/ofw/help.ofw (revision 329139) +++ stable/11/sys/boot/powerpc/ofw/help.ofw (nonexistent) @@ -1 +0,0 @@ -$FreeBSD$ Property changes on: stable/11/sys/boot/powerpc/ofw/help.ofw ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/powerpc/ofw/Makefile =================================================================== --- stable/11/sys/boot/powerpc/ofw/Makefile (revision 329139) +++ stable/11/sys/boot/powerpc/ofw/Makefile (revision 329140) @@ -1,106 +1,55 @@ # $FreeBSD$ -.include +LOADER_CD9660_SUPPORT?= yes +LOADER_EXT2FS_SUPPORT?= no +LOADER_MSDOS_SUPPORT?= no +LOADER_UFS_SUPPORT?= yes +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= yes +LOADER_BZIP2_SUPPORT?= no + +.include MK_SSP= no MAN= PROG= loader NEWVERSWHAT= "Open Firmware loader" ${MACHINE_ARCH} -BINDIR?= /boot INSTALLFLAGS= -b # Architecture-specific loader code SRCS= conf.c metadata.c vers.c start.c SRCS+= ucmpdi2.c -LOADER_DISK_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= yes -LOADER_EXT2FS_SUPPORT?= no -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= yes -LOADER_BZIP2_SUPPORT?= no -LOADER_FDT_SUPPORT?= yes - -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_EXT2FS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_EXT2FS_SUPPORT -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${LOADER_FDT_SUPPORT} == "yes" +.include "${BOOTSRC}/fdt.mk" +.if ${MK_FDT} == "yes" SRCS+= ofwfdt.c -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -I${.CURDIR}/../../../contrib/libfdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a .endif -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/powerpc -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a -.endif +HELP_FILES+= ${FDTSRC}/help.fdt # Always add MI sources -.PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -CFLAGS+= -I. +.include "${BOOTSRC}/loader.mk" -CLEANFILES+= loader.help +.PATH: ${SYSDIR}/libkern CFLAGS+= -ffreestanding -msoft-float # load address. set in linker script RELOC?= 0x1C00000 CFLAGS+= -DRELOC=${RELOC} LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc # Pull in common loader code -.PATH: ${.CURDIR}/../../ofw/common -.include "${.CURDIR}/../../ofw/common/Makefile.inc" +.PATH: ${BOOTSRC}/ofw/common +.include "${BOOTSRC}/ofw/common/Makefile.inc" # Open Firmware standalone support library -LIBOFW= ${.OBJDIR}/../../ofw/libofw/libofw.a -CFLAGS+= -I${.CURDIR}/../../ofw/libofw +LIBOFW= ${BOOTOBJ}/ofw/libofw/libofw.a +CFLAGS+= -I${BOOTSRC}/ofw/libofw -DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA32} -LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA32} - -loader.help: help.common help.ofw ${.CURDIR}/../../fdt/help.fdt - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -FILES+= loader.rc menu.rc +DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA} +LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA} .include Index: stable/11/sys/boot/powerpc/ps3/help.ps3 =================================================================== --- stable/11/sys/boot/powerpc/ps3/help.ps3 (revision 329139) +++ stable/11/sys/boot/powerpc/ps3/help.ps3 (nonexistent) @@ -1 +0,0 @@ -$FreeBSD$ Property changes on: stable/11/sys/boot/powerpc/ps3/help.ps3 ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/powerpc/ps3/Makefile =================================================================== --- stable/11/sys/boot/powerpc/ps3/Makefile (revision 329139) +++ stable/11/sys/boot/powerpc/ps3/Makefile (revision 329140) @@ -1,110 +1,48 @@ # $FreeBSD$ -.include +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= yes +LOADER_EXT2FS_SUPPORT?= yes +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= yes +LOADER_BZIP2_SUPPORT?= no + +.include MK_SSP= no MAN= PROG= loader.ps3 NEWVERSWHAT= "Playstation 3 loader" ${MACHINE_ARCH} -BINDIR?= /boot INSTALLFLAGS= -b # Architecture-specific loader code SRCS= start.S conf.c metadata.c vers.c main.c devicename.c ppc64_elf_freebsd.c SRCS+= lv1call.S ps3cons.c font.h ps3mmu.c ps3net.c ps3repo.c \ ps3stor.c ps3disk.c ps3cdrom.c SRCS+= ucmpdi2.c -LOADER_DISK_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= yes -LOADER_EXT2FS_SUPPORT?= yes -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= yes -LOADER_FDT_SUPPORT?= no -LOADER_BZIP2_SUPPORT?= no - -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_EXT2FS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_EXT2FS_SUPPORT -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${LOADER_FDT_SUPPORT} == "yes" -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a -.endif - - -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/powerpc -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a -.endif - CFLAGS+= -mcpu=powerpc64 # Always add MI sources -.PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -CFLAGS+= -I. +HELP_FILES= # Disable +.include "${BOOTSRC}/loader.mk" +.PATH: ${SYSDIR}/libkern -CLEANFILES+= loader.help - CFLAGS+= -Wall -ffreestanding -msoft-float -DAIM # load address. set in linker script RELOC?= 0x0 CFLAGS+= -DRELOC=${RELOC} LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc -# Pull in common loader code -#.PATH: ${.CURDIR}/../../ofw/common -#.include "${.CURDIR}/../../ofw/common/Makefile.inc" +DPADD= ${LIBFICL} ${LIBOFW} ${LIBSA} +LDADD= ${LIBFICL} ${LIBOFW} ${LIBSA} -DPADD= ${LIBFICL} ${LIBOFW} ${LIBSA32} -LDADD= ${LIBFICL} ${LIBOFW} ${LIBSA32} - SC_DFLT_FONT=cp437 font.h: uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h - -loader.help: help.common help.ps3 ${.CURDIR}/../../fdt/help.fdt - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -FILES+= loader.rc menu.rc .include Index: stable/11/sys/boot/powerpc/uboot/help.uboot =================================================================== --- stable/11/sys/boot/powerpc/uboot/help.uboot (revision 329139) +++ stable/11/sys/boot/powerpc/uboot/help.uboot (nonexistent) @@ -1 +0,0 @@ -$FreeBSD$ Property changes on: stable/11/sys/boot/powerpc/uboot/help.uboot ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/powerpc/uboot/Makefile =================================================================== --- stable/11/sys/boot/powerpc/uboot/Makefile (revision 329139) +++ stable/11/sys/boot/powerpc/uboot/Makefile (revision 329140) @@ -1,109 +1,37 @@ # $FreeBSD$ -.include - -PROG= ubldr -NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} -BINDIR?= /boot -INSTALLFLAGS= -b -MAN= - -# Architecture-specific loader code -SRCS= start.S conf.c vers.c -SRCS+= ucmpdi2.c - -.if !defined(LOADER_NO_DISK_SUPPORT) -LOADER_DISK_SUPPORT?= yes -.else -LOADER_DISK_SUPPORT= no -.endif LOADER_UFS_SUPPORT?= yes LOADER_CD9660_SUPPORT?= no LOADER_EXT2FS_SUPPORT?= no LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= no LOADER_GZIP_SUPPORT?= no LOADER_BZIP2_SUPPORT?= no -.if ${MK_FDT} != "no" -LOADER_FDT_SUPPORT= yes -.else -LOADER_FDT_SUPPORT= no -.endif -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_EXT2FS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_EXT2FS_SUPPORT -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${LOADER_FDT_SUPPORT} == "yes" -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt/libuboot_fdt.a -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a -.endif +.include -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/powerpc -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a -.endif +PROG= ubldr +NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} +INSTALLFLAGS= -b +MAN= +# Architecture-specific loader code +SRCS= start.S conf.c vers.c +SRCS+= ucmpdi2.c + # Always add MI sources -.PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -CFLAGS+= -I. +HELP_FILES= # Disable +.include "${BOOTSRC}/loader.mk" +.PATH: ${SYSDIR}/libkern -CLEANFILES+= ${PROG}.help - CFLAGS+= -ffreestanding LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc -# Pull in common loader code -.PATH: ${.CURDIR}/../../uboot/common -.include "${.CURDIR}/../../uboot/common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../uboot/common +.include "${BOOTSRC}/uboot.mk" -# U-Boot standalone support library -LIBUBOOT= ${.OBJDIR}/../../uboot/lib/libuboot.a -CFLAGS+= -I${.CURDIR}/../../uboot/lib -CFLAGS+= -I${.OBJDIR}/../../uboot/lib - -DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA32} -LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA32} - -loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - -.PATH: ${.CURDIR}/../../forth -FILES= loader.help +DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} +LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} .include Index: stable/11/sys/boot/sparc64/Makefile =================================================================== --- stable/11/sys/boot/sparc64/Makefile (revision 329139) +++ stable/11/sys/boot/sparc64/Makefile (revision 329140) @@ -1,5 +1,10 @@ # $FreeBSD$ -SUBDIR= boot1 loader zfsboot zfsloader +.include + +SUBDIR= boot1 loader +.if ${MK_ZFS} != "no" +SUBDIR+=zfsboot zfsloader +.endif .include Index: stable/11/sys/boot/sparc64/Makefile.inc =================================================================== --- stable/11/sys/boot/sparc64/Makefile.inc (revision 329139) +++ stable/11/sys/boot/sparc64/Makefile.inc (revision 329140) @@ -1,7 +1,6 @@ # $FreeBSD$ -BINDIR?= /boot CFLAGS+= -ffreestanding LDFLAGS+= -nostdlib .include "../Makefile.inc" Index: stable/11/sys/boot/sparc64/boot1/Makefile =================================================================== --- stable/11/sys/boot/sparc64/boot1/Makefile (revision 329139) +++ stable/11/sys/boot/sparc64/boot1/Makefile (revision 329140) @@ -1,32 +1,32 @@ # $FreeBSD$ -.include "../Makefile.inc" +.include PROG= boot1.elf INTERNALPROG= MAN= FILES?= boot1 SRCS= _start.s boot1.c -CLEANFILES=${FILES} boot1.aout +CLEANFILES+=${FILES} boot1.aout BOOTBLOCKBASE= 0x4000 CFLAGS.clang+=-mcmodel=small CFLAGS.gcc+=-mcmodel=medlow -CFLAGS+=-Os -I${.CURDIR}/../../common -LDFLAGS=-Ttext ${BOOTBLOCKBASE} -Wl,-N +CFLAGS+=-Os -I${LDRSRC} +LDFLAGS+=-Ttext ${BOOTBLOCKBASE} -Wl,-N # Construct boot1. sunlabel expects it to contain zeroed-out space for the # label, and to be of the correct size. ${FILES}: boot1.aout @set -- `ls -l ${.ALLSRC}`; x=$$((7680-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 ${DD} if=/dev/zero of=${.TARGET} bs=512 count=16 ${DD} if=${.ALLSRC} of=${.TARGET} bs=512 oseek=1 conv=notrunc boot1.aout: boot1.elf elf2aout -o ${.TARGET} ${.ALLSRC} boot1.o: ${SASRC}/ufsread.c .include Index: stable/11/sys/boot/sparc64/loader/Makefile =================================================================== --- stable/11/sys/boot/sparc64/loader/Makefile (revision 329139) +++ stable/11/sys/boot/sparc64/loader/Makefile (revision 329140) @@ -1,97 +1,50 @@ # $FreeBSD$ -.include +LOADER_DISK_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= yes +LOADER_EXT2FS_SUPPORT?= no +LOADER_MSDOS_SUPPORT?= no +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= yes +LOADER_GZIP_SUPPORT?= yes +LOADER_BZIP2_SUPPORT?= no +LOADER_DEBUG?= no + +.include MK_SSP= no MAN= PROG?= loader NEWVERSWHAT?= "bootstrap loader" sparc64 VERSION_FILE= ${.CURDIR}/../loader/version INSTALLFLAGS= -b # Architecture-specific loader code +.PATH: ${BOOTSRC}/sparc64/loader SRCS= locore.S main.c metadata.c vers.c -LOADER_DISK_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= yes -LOADER_ZFS_SUPPORT?= no -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= yes -LOADER_GZIP_SUPPORT?= yes -LOADER_BZIP2_SUPPORT?= no -LOADER_DEBUG?= no - .if ${LOADER_DEBUG} == "yes" CFLAGS+= -DLOADER_DEBUG .endif -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_ZFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_ZFS_SUPPORT -CFLAGS+= -I${.CURDIR}/../../zfs -CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs -LIBZFSBOOT= ${.OBJDIR}/../../zfs/libzfsboot.a -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/sparc64 -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a +.if exists(${.CURDIR}/help.sparc64) +HELP_FILES+= help.sparc64 +.else +HELP_FILES= .endif # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -CFLAGS+= -I. +.include "${BOOTSRC}/loader.mk" -CLEANFILES+= loader.help +LDFLAGS+= -static -LDFLAGS= -static - # Open Firmware standalone support library -LIBOFW= ${.OBJDIR}/../../ofw/libofw/libofw.a -CFLAGS+= -I${.CURDIR}/../../ofw/libofw/ +LIBOFW= ${BOOTOBJ}/ofw/libofw/libofw.a +CFLAGS+= -I${BOOTSRC}/ofw/libofw/ -# Need sys/ for crypto/intake.h -CFLAGS+= -I${SRCTOP}/sys - DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBOFW} ${LIBSA} LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBOFW} ${LIBSA} - -loader.help: help.common help.sparc64 - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -FILES+= loader.rc menu.rc .include Index: stable/11/sys/boot/sparc64/zfsloader/Makefile =================================================================== --- stable/11/sys/boot/sparc64/zfsloader/Makefile (revision 329139) +++ stable/11/sys/boot/sparc64/zfsloader/Makefile (revision 329140) @@ -1,9 +1,7 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../loader - PROG= zfsloader NEWVERSWHAT= "ZFS enabled bootstrap loader" sparc64 -LOADER_ZFS_SUPPORT=yes +HAVE_ZFS= yes .include "${.CURDIR}/../loader/Makefile" Index: stable/11/sys/boot/uboot/Makefile =================================================================== --- stable/11/sys/boot/uboot/Makefile (revision 329139) +++ stable/11/sys/boot/uboot/Makefile (revision 329140) @@ -1,11 +1,11 @@ # $FreeBSD$ -.include +.include SUBDIR= lib .if ${MK_FDT} != "no" SUBDIR+=fdt .endif .include Index: stable/11/sys/boot/uboot/Makefile.inc =================================================================== --- stable/11/sys/boot/uboot/Makefile.inc (revision 329139) +++ stable/11/sys/boot/uboot/Makefile.inc (revision 329140) @@ -1,8 +1,3 @@ # $FreeBSD$ -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -LDFLAGS+= -m elf32ppc_fbsd -.endif - .include "../Makefile.inc" Index: stable/11/sys/boot/uboot/common/Makefile.inc =================================================================== --- stable/11/sys/boot/uboot/common/Makefile.inc (revision 329139) +++ stable/11/sys/boot/uboot/common/Makefile.inc (nonexistent) @@ -1,3 +0,0 @@ -# $FreeBSD$ - -SRCS+= main.c metadata.c Property changes on: stable/11/sys/boot/uboot/common/Makefile.inc ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/uboot/fdt/Makefile =================================================================== --- stable/11/sys/boot/uboot/fdt/Makefile (revision 329139) +++ stable/11/sys/boot/uboot/fdt/Makefile (revision 329140) @@ -1,32 +1,25 @@ # $FreeBSD$ -.include +.include -.PATH: ${.CURDIR}/../../common +.PATH: ${LDRSRC} LIB= uboot_fdt INTERNALLIB= WARNS?= 2 SRCS= uboot_fdt.c CFLAGS+= -ffreestanding -msoft-float # U-Boot library headers -CFLAGS+= -I${.CURDIR}/../lib +CFLAGS+= -I${UBOOTSRC}/lib # libfdt headers -CFLAGS+= -I${.CURDIR}/../../fdt +CFLAGS+= -I${FDTSRC} # Pick up the bootstrap header for some interface items -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +CFLAGS+= -I${LDRSRC} -machine: .NOMETA - ln -sf ${.CURDIR}/../../../${MACHINE_CPUARCH}/include machine - -CLEANFILES+= machine - .include .include - -beforedepend ${OBJS}: machine Index: stable/11/sys/boot/uboot/lib/Makefile =================================================================== --- stable/11/sys/boot/uboot/lib/Makefile (revision 329139) +++ stable/11/sys/boot/uboot/lib/Makefile (revision 329140) @@ -1,50 +1,31 @@ # $FreeBSD$ -.include +.include -.PATH: ${.CURDIR}/../../common +.PATH: ${LDRSRC} LIB= uboot INTERNALLIB= WARNS?= 2 SRCS= console.c copy.c devicename.c elf_freebsd.c glue.c SRCS+= module.c net.c reboot.c time.c CFLAGS+= -ffreestanding -msoft-float -.if !defined(LOADER_NO_DISK_SUPPORT) -SRCS+= disk.c -CFLAGS+= -DLOADER_DISK_SUPPORT +.if ${LOADER_DISK_SUPPORT:Uyes} == "yes" +SRCS+= disk.c .endif -.if ${MK_FDT} != "no" -LOADER_FDT_SUPPORT= yes -.else -LOADER_FDT_SUPPORT= no -.endif +.include "${BOOTSRC}/fdt.mk" -.if ${LOADER_FDT_SUPPORT} == "yes" -CFLAGS+= -DLOADER_FDT_SUPPORT -I${.CURDIR}/../../fdt -.endif - -# Pick up FDT includes -CFLAGS+= -I${.CURDIR}/../../../../sys/contrib/libfdt/ - # Pick up the bootstrap header for some interface items -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +CFLAGS+= -I${LDRSRC} .ifdef(BOOT_DISK_DEBUG) # Make the disk code more talkative CFLAGS+= -DDISK_DEBUG .endif -machine: .NOMETA - ln -sf ${.CURDIR}/../../../${MACHINE_CPUARCH}/include machine - -CLEANFILES+= machine - .include .include - -beforedepend ${OBJS}: machine Index: stable/11/sys/boot/uboot.mk =================================================================== --- stable/11/sys/boot/uboot.mk (nonexistent) +++ stable/11/sys/boot/uboot.mk (revision 329140) @@ -0,0 +1,18 @@ +# $FreeBSD$ + +SRCS+= main.c metadata.c + +.PATH: ${UBOOTSRC}/common + +CFLAGS+= -I${UBOOTSRC}/common + +# U-Boot standalone support library +LIBUBOOT= ${BOOTOBJ}/uboot/lib/libuboot.a +CFLAGS+= -I${UBOOTSRC}/lib +CFLAGS+= -I${BOOTOBJ}/uboot/lib + +.include "${BOOTSRC}/fdt.mk" + +.if ${MK_FDT} == "yes" +LIBUBOOT_FDT= ${BOOTOBJ}/uboot/fdt/libuboot_fdt.a +.endif Property changes on: stable/11/sys/boot/uboot.mk ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/sys/boot/userboot/Makefile =================================================================== --- stable/11/sys/boot/userboot/Makefile (revision 329139) +++ stable/11/sys/boot/userboot/Makefile (revision 329140) @@ -1,8 +1,8 @@ # $FreeBSD$ .include -SUBDIR= ficl test zfs userboot +SUBDIR= test userboot .include Index: stable/11/sys/boot/userboot/ficl/Makefile.depend =================================================================== --- stable/11/sys/boot/userboot/ficl/Makefile.depend (revision 329139) +++ stable/11/sys/boot/userboot/ficl/Makefile.depend (nonexistent) @@ -1,15 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - lib/libstand \ - lib/msun \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif Property changes on: stable/11/sys/boot/userboot/ficl/Makefile.depend ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/userboot/ficl/Makefile =================================================================== --- stable/11/sys/boot/userboot/ficl/Makefile (revision 329139) +++ stable/11/sys/boot/userboot/ficl/Makefile (nonexistent) @@ -1,63 +0,0 @@ -# $FreeBSD$ -# -.include -MK_SSP= no - -.PATH: ${.CURDIR}/../../ficl -.PATH: ${.CURDIR}/../../ficl/${MACHINE_CPUARCH} -BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c math64.c \ - prefix.c search.c stack.c tools.c vm.c words.c - -SRCS= ${BASE_SRCS} sysdep.c softcore.c -CLEANFILES= softcore.c testmain testmain.o - -CWARNFLAGS.loader.c.c += -Wno-implicit-function-declaration - -.if HAVE_PNP -CFLAGS+= -DHAVE_PNP -.endif -.include -.ifmake testmain -CFLAGS+= -DTESTMAIN -D_TESTMAIN -SRCS+= testmain.c -PROG= testmain -.include -.else -LIB= ficl -INTERNALLIB= -.include -.endif - -# Standard softwords -.PATH: ${.CURDIR}/../../ficl/softwords -SOFTWORDS= softcore.fr jhlocal.fr marker.fr freebsd.fr ficllocal.fr \ - ifbrack.fr -# Optional OO extension softwords -#SOFTWORDS+= oo.fr classes.fr - -#.if ${MACHINE_CPUARCH} == "amd64" -#CFLAGS+= -m32 -I. -#.endif - -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -I. -.endif - -CFLAGS+= -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/${MACHINE_CPUARCH} -CFLAGS+= -I${.CURDIR}/../../common - -softcore.c: ${SOFTWORDS} softcore.awk - (cd ${.CURDIR}/../../ficl/softwords; cat ${SOFTWORDS} \ - | awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET} - -#.if ${MACHINE_CPUARCH} == "amd64" -#${SRCS:M*.c:R:S/$/.o/g}: machine -# -#beforedepend ${OBJS}: machine -# -#machine: .NOMETA -# ln -sf ${.CURDIR}/../../i386/include machine -# -#CLEANFILES+= machine -#.endif Property changes on: stable/11/sys/boot/userboot/ficl/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: stable/11/sys/boot/userboot/test/Makefile =================================================================== --- stable/11/sys/boot/userboot/test/Makefile (revision 329139) +++ stable/11/sys/boot/userboot/test/Makefile (revision 329140) @@ -1,15 +1,14 @@ # $FreeBSD$ MAN= -.include +.include MK_SSP= no PROG= test INTERNALPROG= -CFLAGS+= -I${.CURDIR}/.. -CFLAGS+= -I${.CURDIR}/../../.. +CFLAGS+= -I${BOOTSRC}/userboot .include Index: stable/11/sys/boot/userboot/test/test.c =================================================================== --- stable/11/sys/boot/userboot/test/test.c (revision 329139) +++ stable/11/sys/boot/userboot/test/test.c (revision 329140) @@ -1,475 +1,475 @@ /*- * Copyright (c) 2011 Google, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include +#include char *host_base = NULL; struct termios term, oldterm; char *image; size_t image_size; int disk_fd = -1; uint64_t regs[16]; uint64_t pc; void test_exit(void *arg, int v); /* * Console i/o */ void test_putc(void *arg, int ch) { char c = ch; write(1, &c, 1); } int test_getc(void *arg) { char c; if (read(0, &c, 1) == 1) return c; return -1; } int test_poll(void *arg) { int n; if (ioctl(0, FIONREAD, &n) >= 0) return (n > 0); return (0); } /* * Host filesystem i/o */ struct test_file { int tf_isdir; size_t tf_size; struct stat tf_stat; union { int fd; DIR *dir; } tf_u; }; int test_open(void *arg, const char *filename, void **h_return) { struct stat st; struct test_file *tf; char path[PATH_MAX]; if (!host_base) return (ENOENT); strlcpy(path, host_base, PATH_MAX); if (path[strlen(path) - 1] == '/') path[strlen(path) - 1] = 0; strlcat(path, filename, PATH_MAX); tf = malloc(sizeof(struct test_file)); if (stat(path, &tf->tf_stat) < 0) { free(tf); return (errno); } tf->tf_size = st.st_size; if (S_ISDIR(tf->tf_stat.st_mode)) { tf->tf_isdir = 1; tf->tf_u.dir = opendir(path); if (!tf->tf_u.dir) goto out; *h_return = tf; return (0); } if (S_ISREG(tf->tf_stat.st_mode)) { tf->tf_isdir = 0; tf->tf_u.fd = open(path, O_RDONLY); if (tf->tf_u.fd < 0) goto out; *h_return = tf; return (0); } out: free(tf); return (EINVAL); } int test_close(void *arg, void *h) { struct test_file *tf = h; if (tf->tf_isdir) closedir(tf->tf_u.dir); else close(tf->tf_u.fd); free(tf); return (0); } int test_isdir(void *arg, void *h) { struct test_file *tf = h; return (tf->tf_isdir); } int test_read(void *arg, void *h, void *dst, size_t size, size_t *resid_return) { struct test_file *tf = h; ssize_t sz; if (tf->tf_isdir) return (EINVAL); sz = read(tf->tf_u.fd, dst, size); if (sz < 0) return (EINVAL); *resid_return = size - sz; return (0); } int test_readdir(void *arg, void *h, uint32_t *fileno_return, uint8_t *type_return, size_t *namelen_return, char *name) { struct test_file *tf = h; struct dirent *dp; if (!tf->tf_isdir) return (EINVAL); dp = readdir(tf->tf_u.dir); if (!dp) return (ENOENT); /* * Note: d_namlen is in the range 0..255 and therefore less * than PATH_MAX so we don't need to test before copying. */ *fileno_return = dp->d_fileno; *type_return = dp->d_type; *namelen_return = dp->d_namlen; memcpy(name, dp->d_name, dp->d_namlen); name[dp->d_namlen] = 0; return (0); } int test_seek(void *arg, void *h, uint64_t offset, int whence) { struct test_file *tf = h; if (tf->tf_isdir) return (EINVAL); if (lseek(tf->tf_u.fd, offset, whence) < 0) return (errno); return (0); } int test_stat(void *arg, void *h, int *mode_return, int *uid_return, int *gid_return, uint64_t *size_return) { struct test_file *tf = h; *mode_return = tf->tf_stat.st_mode; *uid_return = tf->tf_stat.st_uid; *gid_return = tf->tf_stat.st_gid; *size_return = tf->tf_stat.st_size; return (0); } /* * Disk image i/o */ int test_diskread(void *arg, int unit, uint64_t offset, void *dst, size_t size, size_t *resid_return) { ssize_t n; if (unit != 0 || disk_fd == -1) return (EIO); n = pread(disk_fd, dst, size, offset); if (n < 0) return (errno); *resid_return = size - n; return (0); } int test_diskioctl(void *arg, int unit, u_long cmd, void *data) { struct stat sb; if (unit != 0 || disk_fd == -1) return (EBADF); switch (cmd) { case DIOCGSECTORSIZE: *(u_int *)data = 512; break; case DIOCGMEDIASIZE: if (fstat(disk_fd, &sb) == 0) *(off_t *)data = sb.st_size; else return (ENOTTY); break; default: return (ENOTTY); } return (0); } /* * Guest virtual machine i/o * * Note: guest addresses are kernel virtual */ int test_copyin(void *arg, const void *from, uint64_t to, size_t size) { to &= 0x7fffffff; if (to > image_size) return (EFAULT); if (to + size > image_size) size = image_size - to; memcpy(&image[to], from, size); return(0); } int test_copyout(void *arg, uint64_t from, void *to, size_t size) { from &= 0x7fffffff; if (from > image_size) return (EFAULT); if (from + size > image_size) size = image_size - from; memcpy(to, &image[from], size); return(0); } void test_setreg(void *arg, int r, uint64_t v) { if (r < 0 || r >= 16) return; regs[r] = v; } void test_setmsr(void *arg, int r, uint64_t v) { } void test_setcr(void *arg, int r, uint64_t v) { } void test_setgdt(void *arg, uint64_t v, size_t sz) { } void test_exec(void *arg, uint64_t pc) { printf("Execute at 0x%"PRIu64"\n", pc); test_exit(arg, 0); } /* * Misc */ void test_delay(void *arg, int usec) { usleep(usec); } void test_exit(void *arg, int v) { tcsetattr(0, TCSAFLUSH, &oldterm); exit(v); } void test_getmem(void *arg, uint64_t *lowmem, uint64_t *highmem) { *lowmem = 128*1024*1024; *highmem = 0; } char * test_getenv(void *arg, int idx) { static char *vars[] = { "foo=bar", "bar=barbar", NULL }; return (vars[idx]); } struct loader_callbacks cb = { .putc = test_putc, .getc = test_getc, .poll = test_poll, .open = test_open, .close = test_close, .isdir = test_isdir, .read = test_read, .readdir = test_readdir, .seek = test_seek, .stat = test_stat, .diskread = test_diskread, .diskioctl = test_diskioctl, .copyin = test_copyin, .copyout = test_copyout, .setreg = test_setreg, .setmsr = test_setmsr, .setcr = test_setcr, .setgdt = test_setgdt, .exec = test_exec, .delay = test_delay, .exit = test_exit, .getmem = test_getmem, .getenv = test_getenv, }; void usage() { printf("usage: [-b ] [-d ] [-h \n"); exit(1); } int main(int argc, char** argv) { void *h; void (*func)(struct loader_callbacks *, void *, int, int); int opt; char *disk_image = NULL; const char *userboot_obj = "/boot/userboot.so"; while ((opt = getopt(argc, argv, "b:d:h:")) != -1) { switch (opt) { case 'b': userboot_obj = optarg; break; case 'd': disk_image = optarg; break; case 'h': host_base = optarg; break; case '?': usage(); } } h = dlopen(userboot_obj, RTLD_LOCAL); if (!h) { printf("%s\n", dlerror()); return (1); } func = dlsym(h, "loader_main"); if (!func) { printf("%s\n", dlerror()); return (1); } image_size = 128*1024*1024; image = malloc(image_size); if (disk_image) { disk_fd = open(disk_image, O_RDONLY); if (disk_fd < 0) err(1, "Can't open disk image '%s'", disk_image); } tcgetattr(0, &term); oldterm = term; term.c_iflag &= ~(ICRNL); term.c_lflag &= ~(ICANON|ECHO); tcsetattr(0, TCSAFLUSH, &term); func(&cb, NULL, USERBOOT_VERSION_3, disk_fd >= 0); } Index: stable/11/sys/boot/userboot/userboot/Makefile =================================================================== --- stable/11/sys/boot/userboot/userboot/Makefile (revision 329139) +++ stable/11/sys/boot/userboot/userboot/Makefile (revision 329140) @@ -1,64 +1,59 @@ # $FreeBSD$ MAN= -.include +LOADER_MSDOS_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no + +.include + MK_SSP= no SHLIB_NAME= userboot.so MK_CTF= no STRIP= LIBDIR= /boot SRCS= autoload.c SRCS+= bcache.c SRCS+= biossmap.c SRCS+= bootinfo.c SRCS+= bootinfo32.c SRCS+= bootinfo64.c SRCS+= conf.c SRCS+= console.c SRCS+= copy.c SRCS+= devicename.c SRCS+= elf32_freebsd.c SRCS+= elf64_freebsd.c SRCS+= host.c SRCS+= main.c SRCS+= userboot_cons.c SRCS+= userboot_disk.c SRCS+= vers.c CFLAGS+= -Wall -CFLAGS+= -I${.CURDIR}/.. -CFLAGS+= -I${.CURDIR}/../../common -CFLAGS+= -I${.CURDIR}/../../.. -CFLAGS+= -ffreestanding -I. +CFLAGS+= -I${BOOTSRC}/userboot +CFLAGS+= -ffreestanding CWARNFLAGS.main.c += -Wno-implicit-function-declaration LDFLAGS+= -nostdlib -Wl,-Bsymbolic NEWVERSWHAT= "User boot" ${MACHINE_CPUARCH} -.if ${MK_FORTH} != "no" -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/i386 -CFLAGS+= -DBF_DICTSIZE=15000 -LIBFICL= ${.OBJDIR}/../ficl/libficl.a -.endif - .if ${MK_ZFS} != "no" CFLAGS+= -DUSERBOOT_ZFS_SUPPORT -LIBZFSBOOT= ${.OBJDIR}/../zfs/libzfsboot.a +LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a .endif # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common +HELP_FILES= # Disable +.include "${BOOTSRC}/loader.mk" CFLAGS+= -I. DPADD+= ${LIBFICL} ${LIBZFSBOOT} ${LIBSA} LDADD+= ${LIBFICL} ${LIBZFSBOOT} ${LIBSA} .include Index: stable/11/sys/boot/userboot/zfs/Makefile.depend =================================================================== --- stable/11/sys/boot/userboot/zfs/Makefile.depend (revision 329139) +++ stable/11/sys/boot/userboot/zfs/Makefile.depend (nonexistent) @@ -1,13 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif Property changes on: stable/11/sys/boot/userboot/zfs/Makefile.depend ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/userboot/zfs/Makefile =================================================================== --- stable/11/sys/boot/userboot/zfs/Makefile (revision 329139) +++ stable/11/sys/boot/userboot/zfs/Makefile (nonexistent) @@ -1,22 +0,0 @@ -# $FreeBSD$ - -S= ${.CURDIR}/../../zfs - -.PATH: ${S} ${.CURDIR}/../../../crypto/skein -LIB= zfsboot -INTERNALLIB= - -SRCS+= zfs.c skein.c skein_block.c - -# Do not unroll skein loops, reduce code size -CFLAGS+= -DSKEIN_LOOP=111 - -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. -CFLAGS+= -I${SASRC} -CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs -CFLAGS+= -I${.CURDIR}/../../../crypto/skein - -CFLAGS+= -ffreestanding -fPIC -CFLAGS+= -Wformat -Wall - -.include Property changes on: stable/11/sys/boot/userboot/zfs/Makefile ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: stable/11/sys/boot/zfs/Makefile =================================================================== --- stable/11/sys/boot/zfs/Makefile (revision 329139) +++ stable/11/sys/boot/zfs/Makefile (revision 329140) @@ -1,40 +1,22 @@ # $FreeBSD$ +.include + LIB= zfsboot INTERNALLIB= -SRCS+= zfs.c - -SRCS+= skein.c skein_block.c +.PATH: ${ZFSSRC} +SRCS+= zfs.c skein.c skein_block.c # Do not unroll skein loops, reduce code size CFLAGS+= -DSKEIN_LOOP=111 -.PATH: ${.CURDIR}/../../crypto/skein +.PATH: ${SYSDIR}/crypto/skein CFLAGS+= -DBOOTPROG=\"zfsloader\" -CFLAGS+= -I${.CURDIR}/../common -I${.CURDIR}/../.. -I. -CFLAGS+= -I${.CURDIR}/../../cddl/boot/zfs -CFLAGS+= -I${.CURDIR}/../../crypto/skein +CFLAGS+= -I${LDRSRC} +CFLAGS+= -I${SYSDIR}/cddl/boot/zfs +CFLAGS+= -I${SYSDIR}/crypto/skein -.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" -CFLAGS+= -march=i386 -.endif -.if ${MACHINE_CPUARCH} == "amd64" -CFLAGS+= -m32 -.endif - CFLAGS+= -Wformat -Wall -.if ${MACHINE_CPUARCH} == "amd64" -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${.CURDIR}/../../i386/include machine -.endif - .include .include - -.if ${MACHINE_CPUARCH} == "amd64" -.if !exists(machine) -beforedepend ${OBJS}: machine -.endif -.endif Index: stable/11/sys/boot/zfs/zfs.c =================================================================== --- stable/11/sys/boot/zfs/zfs.c (revision 329139) +++ stable/11/sys/boot/zfs/zfs.c (revision 329140) @@ -1,912 +1,956 @@ /*- * Copyright (c) 2007 Doug Rabson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include __FBSDID("$FreeBSD$"); /* * Stand-alone file reading package. */ #include #include #include #include #include #include #include #include #include #include #include "libzfs.h" #include "zfsimpl.c" /* Define the range of indexes to be populated with ZFS Boot Environments */ #define ZFS_BE_FIRST 4 #define ZFS_BE_LAST 8 static int zfs_open(const char *path, struct open_file *f); static int zfs_write(struct open_file *f, void *buf, size_t size, size_t *resid); static int zfs_close(struct open_file *f); static int zfs_read(struct open_file *f, void *buf, size_t size, size_t *resid); static off_t zfs_seek(struct open_file *f, off_t offset, int where); static int zfs_stat(struct open_file *f, struct stat *sb); static int zfs_readdir(struct open_file *f, struct dirent *d); struct devsw zfs_dev; struct fs_ops zfs_fsops = { "zfs", zfs_open, zfs_close, zfs_read, zfs_write, zfs_seek, zfs_stat, zfs_readdir }; /* * In-core open file. */ struct file { off_t f_seekp; /* seek pointer */ dnode_phys_t f_dnode; uint64_t f_zap_type; /* zap type for readdir */ uint64_t f_num_leafs; /* number of fzap leaf blocks */ zap_leaf_phys_t *f_zap_leaf; /* zap leaf buffer */ }; static int zfs_env_index; static int zfs_env_count; SLIST_HEAD(zfs_be_list, zfs_be_entry) zfs_be_head = SLIST_HEAD_INITIALIZER(zfs_be_head); struct zfs_be_list *zfs_be_headp; struct zfs_be_entry { const char *name; SLIST_ENTRY(zfs_be_entry) entries; } *zfs_be, *zfs_be_tmp; /* * Open a file. */ static int zfs_open(const char *upath, struct open_file *f) { struct zfsmount *mount = (struct zfsmount *)f->f_devdata; struct file *fp; int rc; if (f->f_dev != &zfs_dev) return (EINVAL); /* allocate file system specific data structure */ fp = malloc(sizeof(struct file)); bzero(fp, sizeof(struct file)); f->f_fsdata = (void *)fp; rc = zfs_lookup(mount, upath, &fp->f_dnode); fp->f_seekp = 0; if (rc) { f->f_fsdata = NULL; free(fp); } return (rc); } static int zfs_close(struct open_file *f) { struct file *fp = (struct file *)f->f_fsdata; dnode_cache_obj = NULL; f->f_fsdata = (void *)0; if (fp == (struct file *)0) return (0); free(fp); return (0); } /* * Copy a portion of a file into kernel memory. * Cross block boundaries when necessary. */ static int zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */) { const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; struct stat sb; size_t n; int rc; rc = zfs_stat(f, &sb); if (rc) return (rc); n = size; if (fp->f_seekp + n > sb.st_size) n = sb.st_size - fp->f_seekp; rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, start, n); if (rc) return (rc); if (0) { int i; for (i = 0; i < n; i++) putchar(((char*) start)[i]); } fp->f_seekp += n; if (resid) *resid = size - n; return (0); } /* * Don't be silly - the bootstrap has no business writing anything. */ static int zfs_write(struct open_file *f, void *start, size_t size, size_t *resid /* out */) { return (EROFS); } static off_t zfs_seek(struct open_file *f, off_t offset, int where) { struct file *fp = (struct file *)f->f_fsdata; switch (where) { case SEEK_SET: fp->f_seekp = offset; break; case SEEK_CUR: fp->f_seekp += offset; break; case SEEK_END: { struct stat sb; int error; error = zfs_stat(f, &sb); if (error != 0) { errno = error; return (-1); } fp->f_seekp = sb.st_size - offset; break; } default: errno = EINVAL; return (-1); } return (fp->f_seekp); } static int zfs_stat(struct open_file *f, struct stat *sb) { const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; return (zfs_dnode_stat(spa, &fp->f_dnode, sb)); } static int zfs_readdir(struct open_file *f, struct dirent *d) { const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; mzap_ent_phys_t mze; struct stat sb; size_t bsize = fp->f_dnode.dn_datablkszsec << SPA_MINBLOCKSHIFT; int rc; rc = zfs_stat(f, &sb); if (rc) return (rc); if (!S_ISDIR(sb.st_mode)) return (ENOTDIR); /* * If this is the first read, get the zap type. */ if (fp->f_seekp == 0) { rc = dnode_read(spa, &fp->f_dnode, 0, &fp->f_zap_type, sizeof(fp->f_zap_type)); if (rc) return (rc); if (fp->f_zap_type == ZBT_MICRO) { fp->f_seekp = offsetof(mzap_phys_t, mz_chunk); } else { rc = dnode_read(spa, &fp->f_dnode, offsetof(zap_phys_t, zap_num_leafs), &fp->f_num_leafs, sizeof(fp->f_num_leafs)); if (rc) return (rc); fp->f_seekp = bsize; fp->f_zap_leaf = (zap_leaf_phys_t *)malloc(bsize); rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, fp->f_zap_leaf, bsize); if (rc) return (rc); } } if (fp->f_zap_type == ZBT_MICRO) { mzap_next: if (fp->f_seekp >= bsize) return (ENOENT); rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, &mze, sizeof(mze)); if (rc) return (rc); fp->f_seekp += sizeof(mze); if (!mze.mze_name[0]) goto mzap_next; d->d_fileno = ZFS_DIRENT_OBJ(mze.mze_value); d->d_type = ZFS_DIRENT_TYPE(mze.mze_value); strcpy(d->d_name, mze.mze_name); d->d_namlen = strlen(d->d_name); return (0); } else { zap_leaf_t zl; zap_leaf_chunk_t *zc, *nc; int chunk; size_t namelen; char *p; uint64_t value; /* * Initialise this so we can use the ZAP size * calculating macros. */ zl.l_bs = ilog2(bsize); zl.l_phys = fp->f_zap_leaf; /* * Figure out which chunk we are currently looking at * and consider seeking to the next leaf. We use the * low bits of f_seekp as a simple chunk index. */ fzap_next: chunk = fp->f_seekp & (bsize - 1); if (chunk == ZAP_LEAF_NUMCHUNKS(&zl)) { fp->f_seekp = rounddown2(fp->f_seekp, bsize) + bsize; chunk = 0; /* * Check for EOF and read the new leaf. */ if (fp->f_seekp >= bsize * fp->f_num_leafs) return (ENOENT); rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, fp->f_zap_leaf, bsize); if (rc) return (rc); } zc = &ZAP_LEAF_CHUNK(&zl, chunk); fp->f_seekp++; if (zc->l_entry.le_type != ZAP_CHUNK_ENTRY) goto fzap_next; namelen = zc->l_entry.le_name_numints; if (namelen > sizeof(d->d_name)) namelen = sizeof(d->d_name); /* * Paste the name back together. */ nc = &ZAP_LEAF_CHUNK(&zl, zc->l_entry.le_name_chunk); p = d->d_name; while (namelen > 0) { int len; len = namelen; if (len > ZAP_LEAF_ARRAY_BYTES) len = ZAP_LEAF_ARRAY_BYTES; memcpy(p, nc->l_array.la_array, len); p += len; namelen -= len; nc = &ZAP_LEAF_CHUNK(&zl, nc->l_array.la_next); } d->d_name[sizeof(d->d_name) - 1] = 0; /* * Assume the first eight bytes of the value are * a uint64_t. */ value = fzap_leaf_value(&zl, zc); d->d_fileno = ZFS_DIRENT_OBJ(value); d->d_type = ZFS_DIRENT_TYPE(value); d->d_namlen = strlen(d->d_name); return (0); } } static int -vdev_read(vdev_t *vdev, void *priv, off_t offset, void *buf, size_t size) +vdev_read(vdev_t *vdev, void *priv, off_t offset, void *buf, size_t bytes) { - int fd; + int fd, ret; + size_t res, size, remainder, rb_size, blksz; + unsigned secsz; + off_t off; + char *bouncebuf, *rb_buf; fd = (uintptr_t) priv; - lseek(fd, offset, SEEK_SET); - if (read(fd, buf, size) == size) { - return 0; - } else { - return (EIO); + bouncebuf = NULL; + + ret = ioctl(fd, DIOCGSECTORSIZE, &secsz); + if (ret != 0) + return (ret); + + off = offset / secsz; + remainder = offset % secsz; + if (lseek(fd, off * secsz, SEEK_SET) == -1) + return (errno); + + rb_buf = buf; + rb_size = bytes; + size = roundup2(bytes + remainder, secsz); + blksz = size; + if (remainder != 0 || size != bytes) { + bouncebuf = zfs_alloc(secsz); + if (bouncebuf == NULL) { + printf("vdev_read: out of memory\n"); + return (ENOMEM); + } + rb_buf = bouncebuf; + blksz = rb_size - remainder; } + + while (bytes > 0) { + res = read(fd, rb_buf, rb_size); + if (res != rb_size) { + ret = EIO; + goto error; + } + if (bytes < blksz) + blksz = bytes; + if (bouncebuf != NULL) + memcpy(buf, rb_buf + remainder, blksz); + buf = (void *)((uintptr_t)buf + blksz); + bytes -= blksz; + remainder = 0; + blksz = rb_size; + } + + ret = 0; +error: + if (bouncebuf != NULL) + zfs_free(bouncebuf, secsz); + return (ret); } static int zfs_dev_init(void) { spa_t *spa; spa_t *next; spa_t *prev; zfs_init(); if (archsw.arch_zfs_probe == NULL) return (ENXIO); archsw.arch_zfs_probe(); prev = NULL; spa = STAILQ_FIRST(&zfs_pools); while (spa != NULL) { next = STAILQ_NEXT(spa, spa_link); if (zfs_spa_init(spa)) { if (prev == NULL) STAILQ_REMOVE_HEAD(&zfs_pools, spa_link); else STAILQ_REMOVE_AFTER(&zfs_pools, prev, spa_link); } else prev = spa; spa = next; } return (0); } struct zfs_probe_args { int fd; const char *devname; uint64_t *pool_guid; u_int secsz; }; static int zfs_diskread(void *arg, void *buf, size_t blocks, uint64_t offset) { struct zfs_probe_args *ppa; ppa = (struct zfs_probe_args *)arg; return (vdev_read(NULL, (void *)(uintptr_t)ppa->fd, offset * ppa->secsz, buf, blocks * ppa->secsz)); } static int zfs_probe(int fd, uint64_t *pool_guid) { spa_t *spa; int ret; ret = vdev_probe(vdev_read, (void *)(uintptr_t)fd, &spa); if (ret == 0 && pool_guid != NULL) *pool_guid = spa->spa_guid; return (ret); } static int zfs_probe_partition(void *arg, const char *partname, const struct ptable_entry *part) { struct zfs_probe_args *ppa, pa; struct ptable *table; char devname[32]; int ret; /* Probe only freebsd-zfs and freebsd partitions */ if (part->type != PART_FREEBSD && part->type != PART_FREEBSD_ZFS) return (0); ppa = (struct zfs_probe_args *)arg; strncpy(devname, ppa->devname, strlen(ppa->devname) - 1); devname[strlen(ppa->devname) - 1] = '\0'; sprintf(devname, "%s%s:", devname, partname); pa.fd = open(devname, O_RDONLY); if (pa.fd == -1) return (0); ret = zfs_probe(pa.fd, ppa->pool_guid); if (ret == 0) return (0); /* Do we have BSD label here? */ if (part->type == PART_FREEBSD) { pa.devname = devname; pa.pool_guid = ppa->pool_guid; pa.secsz = ppa->secsz; table = ptable_open(&pa, part->end - part->start + 1, ppa->secsz, zfs_diskread); if (table != NULL) { ptable_iterate(table, &pa, zfs_probe_partition); ptable_close(table); } } close(pa.fd); return (0); } int zfs_probe_dev(const char *devname, uint64_t *pool_guid) { struct ptable *table; struct zfs_probe_args pa; uint64_t mediasz; int ret; if (pool_guid) *pool_guid = 0; pa.fd = open(devname, O_RDONLY); if (pa.fd == -1) return (ENXIO); /* Probe the whole disk */ ret = zfs_probe(pa.fd, pool_guid); if (ret == 0) return (0); /* Probe each partition */ ret = ioctl(pa.fd, DIOCGMEDIASIZE, &mediasz); if (ret == 0) ret = ioctl(pa.fd, DIOCGSECTORSIZE, &pa.secsz); if (ret == 0) { pa.devname = devname; pa.pool_guid = pool_guid; table = ptable_open(&pa, mediasz / pa.secsz, pa.secsz, zfs_diskread); if (table != NULL) { ptable_iterate(table, &pa, zfs_probe_partition); ptable_close(table); } } close(pa.fd); if (pool_guid && *pool_guid == 0) ret = ENXIO; return (ret); } /* * Print information about ZFS pools */ static int zfs_dev_print(int verbose) { spa_t *spa; char line[80]; int ret = 0; if (STAILQ_EMPTY(&zfs_pools)) return (0); printf("%s devices:", zfs_dev.dv_name); if ((ret = pager_output("\n")) != 0) return (ret); if (verbose) { return (spa_all_status()); } STAILQ_FOREACH(spa, &zfs_pools, spa_link) { snprintf(line, sizeof(line), " zfs:%s\n", spa->spa_name); ret = pager_output(line); if (ret != 0) break; } return (ret); } /* * Attempt to open the pool described by (dev) for use by (f). */ static int zfs_dev_open(struct open_file *f, ...) { va_list args; struct zfs_devdesc *dev; struct zfsmount *mount; spa_t *spa; int rv; va_start(args, f); dev = va_arg(args, struct zfs_devdesc *); va_end(args); if (dev->pool_guid == 0) spa = STAILQ_FIRST(&zfs_pools); else spa = spa_find_by_guid(dev->pool_guid); if (!spa) return (ENXIO); mount = malloc(sizeof(*mount)); rv = zfs_mount(spa, dev->root_guid, mount); if (rv != 0) { free(mount); return (rv); } if (mount->objset.os_type != DMU_OST_ZFS) { printf("Unexpected object set type %ju\n", (uintmax_t)mount->objset.os_type); free(mount); return (EIO); } f->f_devdata = mount; free(dev); return (0); } static int zfs_dev_close(struct open_file *f) { free(f->f_devdata); f->f_devdata = NULL; return (0); } static int zfs_dev_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf, size_t *rsize) { return (ENOSYS); } struct devsw zfs_dev = { .dv_name = "zfs", .dv_type = DEVT_ZFS, .dv_init = zfs_dev_init, .dv_strategy = zfs_dev_strategy, .dv_open = zfs_dev_open, .dv_close = zfs_dev_close, .dv_ioctl = noioctl, .dv_print = zfs_dev_print, .dv_cleanup = NULL }; int zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path) { static char rootname[ZFS_MAXNAMELEN]; static char poolname[ZFS_MAXNAMELEN]; spa_t *spa; const char *end; const char *np; const char *sep; int rv; np = devspec; if (*np != ':') return (EINVAL); np++; end = strchr(np, ':'); if (end == NULL) return (EINVAL); sep = strchr(np, '/'); if (sep == NULL || sep >= end) sep = end; memcpy(poolname, np, sep - np); poolname[sep - np] = '\0'; if (sep < end) { sep++; memcpy(rootname, sep, end - sep); rootname[end - sep] = '\0'; } else rootname[0] = '\0'; spa = spa_find_by_name(poolname); if (!spa) return (ENXIO); dev->pool_guid = spa->spa_guid; rv = zfs_lookup_dataset(spa, rootname, &dev->root_guid); if (rv != 0) return (rv); if (path != NULL) *path = (*end == '\0') ? end : end + 1; dev->d_dev = &zfs_dev; dev->d_type = zfs_dev.dv_type; return (0); } char * zfs_fmtdev(void *vdev) { static char rootname[ZFS_MAXNAMELEN]; static char buf[2 * ZFS_MAXNAMELEN + 8]; struct zfs_devdesc *dev = (struct zfs_devdesc *)vdev; spa_t *spa; buf[0] = '\0'; if (dev->d_type != DEVT_ZFS) return (buf); if (dev->pool_guid == 0) { spa = STAILQ_FIRST(&zfs_pools); dev->pool_guid = spa->spa_guid; } else spa = spa_find_by_guid(dev->pool_guid); if (spa == NULL) { printf("ZFS: can't find pool by guid\n"); return (buf); } if (dev->root_guid == 0 && zfs_get_root(spa, &dev->root_guid)) { printf("ZFS: can't find root filesystem\n"); return (buf); } if (zfs_rlookup(spa, dev->root_guid, rootname)) { printf("ZFS: can't find filesystem by guid\n"); return (buf); } if (rootname[0] == '\0') sprintf(buf, "%s:%s:", dev->d_dev->dv_name, spa->spa_name); else sprintf(buf, "%s:%s/%s:", dev->d_dev->dv_name, spa->spa_name, rootname); return (buf); } int zfs_list(const char *name) { static char poolname[ZFS_MAXNAMELEN]; uint64_t objid; spa_t *spa; const char *dsname; int len; int rv; len = strlen(name); dsname = strchr(name, '/'); if (dsname != NULL) { len = dsname - name; dsname++; } else dsname = ""; memcpy(poolname, name, len); poolname[len] = '\0'; spa = spa_find_by_name(poolname); if (!spa) return (ENXIO); rv = zfs_lookup_dataset(spa, dsname, &objid); if (rv != 0) return (rv); return (zfs_list_dataset(spa, objid)); } void init_zfs_bootenv(char *currdev) { char *beroot; if (strlen(currdev) == 0) return; if(strncmp(currdev, "zfs:", 4) != 0) return; /* Remove the trailing : */ currdev[strlen(currdev) - 1] = '\0'; setenv("zfs_be_active", currdev, 1); setenv("zfs_be_currpage", "1", 1); /* Forward past zfs: */ currdev = strchr(currdev, ':'); currdev++; /* Remove the last element (current bootenv) */ beroot = strrchr(currdev, '/'); if (beroot != NULL) beroot[0] = '\0'; beroot = currdev; setenv("zfs_be_root", beroot, 1); } int zfs_bootenv(const char *name) { static char poolname[ZFS_MAXNAMELEN], *dsname, *root; char becount[4]; uint64_t objid; spa_t *spa; int len, rv, pages, perpage, currpage; if (name == NULL) return (EINVAL); if ((root = getenv("zfs_be_root")) == NULL) return (EINVAL); if (strcmp(name, root) != 0) { if (setenv("zfs_be_root", name, 1) != 0) return (ENOMEM); } SLIST_INIT(&zfs_be_head); zfs_env_count = 0; len = strlen(name); dsname = strchr(name, '/'); if (dsname != NULL) { len = dsname - name; dsname++; } else dsname = ""; memcpy(poolname, name, len); poolname[len] = '\0'; spa = spa_find_by_name(poolname); if (!spa) return (ENXIO); rv = zfs_lookup_dataset(spa, dsname, &objid); if (rv != 0) return (rv); rv = zfs_callback_dataset(spa, objid, zfs_belist_add); /* Calculate and store the number of pages of BEs */ perpage = (ZFS_BE_LAST - ZFS_BE_FIRST + 1); pages = (zfs_env_count / perpage) + ((zfs_env_count % perpage) > 0 ? 1 : 0); snprintf(becount, 4, "%d", pages); if (setenv("zfs_be_pages", becount, 1) != 0) return (ENOMEM); /* Roll over the page counter if it has exceeded the maximum */ currpage = strtol(getenv("zfs_be_currpage"), NULL, 10); if (currpage > pages) { if (setenv("zfs_be_currpage", "1", 1) != 0) return (ENOMEM); } /* Populate the menu environment variables */ zfs_set_env(); /* Clean up the SLIST of ZFS BEs */ while (!SLIST_EMPTY(&zfs_be_head)) { zfs_be = SLIST_FIRST(&zfs_be_head); SLIST_REMOVE_HEAD(&zfs_be_head, entries); free(zfs_be); } return (rv); } int zfs_belist_add(const char *name, uint64_t value __unused) { /* Skip special datasets that start with a $ character */ if (strncmp(name, "$", 1) == 0) { return (0); } /* Add the boot environment to the head of the SLIST */ zfs_be = malloc(sizeof(struct zfs_be_entry)); if (zfs_be == NULL) { return (ENOMEM); } zfs_be->name = name; SLIST_INSERT_HEAD(&zfs_be_head, zfs_be, entries); zfs_env_count++; return (0); } int zfs_set_env(void) { char envname[32], envval[256]; char *beroot, *pagenum; int rv, page, ctr; beroot = getenv("zfs_be_root"); if (beroot == NULL) { return (1); } pagenum = getenv("zfs_be_currpage"); if (pagenum != NULL) { page = strtol(pagenum, NULL, 10); } else { page = 1; } ctr = 1; rv = 0; zfs_env_index = ZFS_BE_FIRST; SLIST_FOREACH_SAFE(zfs_be, &zfs_be_head, entries, zfs_be_tmp) { /* Skip to the requested page number */ if (ctr <= ((ZFS_BE_LAST - ZFS_BE_FIRST + 1) * (page - 1))) { ctr++; continue; } snprintf(envname, sizeof(envname), "bootenvmenu_caption[%d]", zfs_env_index); snprintf(envval, sizeof(envval), "%s", zfs_be->name); rv = setenv(envname, envval, 1); if (rv != 0) { break; } snprintf(envname, sizeof(envname), "bootenvansi_caption[%d]", zfs_env_index); rv = setenv(envname, envval, 1); if (rv != 0){ break; } snprintf(envname, sizeof(envname), "bootenvmenu_command[%d]", zfs_env_index); rv = setenv(envname, "set_bootenv", 1); if (rv != 0){ break; } snprintf(envname, sizeof(envname), "bootenv_root[%d]", zfs_env_index); snprintf(envval, sizeof(envval), "zfs:%s/%s", beroot, zfs_be->name); rv = setenv(envname, envval, 1); if (rv != 0){ break; } zfs_env_index++; if (zfs_env_index > ZFS_BE_LAST) { break; } } for (; zfs_env_index <= ZFS_BE_LAST; zfs_env_index++) { snprintf(envname, sizeof(envname), "bootenvmenu_caption[%d]", zfs_env_index); (void)unsetenv(envname); snprintf(envname, sizeof(envname), "bootenvansi_caption[%d]", zfs_env_index); (void)unsetenv(envname); snprintf(envname, sizeof(envname), "bootenvmenu_command[%d]", zfs_env_index); (void)unsetenv(envname); snprintf(envname, sizeof(envname), "bootenv_root[%d]", zfs_env_index); (void)unsetenv(envname); } return (rv); } Index: stable/11/sys/boot/zfs32/Makefile =================================================================== --- stable/11/sys/boot/zfs32/Makefile (nonexistent) +++ stable/11/sys/boot/zfs32/Makefile (revision 329140) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +DO32=1 + +.include "${.CURDIR}/../zfs/Makefile" Property changes on: stable/11/sys/boot/zfs32/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/tools/boot/universe.sh =================================================================== --- stable/11/tools/boot/universe.sh (revision 329139) +++ stable/11/tools/boot/universe.sh (revision 329140) @@ -1,65 +1,85 @@ #!/bin/sh # $FreeBSD$ # # Full list of all arches, but we only build a subset. All different mips add any # value, and there's a few others we just don't support. # # mips/mipsel mips/mips mips/mips64el mips/mips64 mips/mipsn32 \ # mips/mipselhf mips/mipshf mips/mips64elhf mips/mips64hf \ # powerpc/powerpc powerpc/powerpc64 powerpc/powerpcspe \ # riscv/riscv64 riscv/riscv64sf # # This script is expected to be run in sys/boot (though you could run it anywhere # in the tree). It does a full clean build. For sys/boot you can do all the archs in # about a minute or two on a fast machine. It's also possible that you need a full # make universe for this to work completely. # # Output is put into _.boot.$TARGET_ARCH.log in sys.boot. # +dobuild() +{ + local ta=$1 + local lf=$2 + local opt=$3 + + echo -n "Building $ta ${opt} ... " + if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make clean cleandepend cleandir obj depend" \ + > $lf 2>&1; then + echo "Fail (cleanup)" + continue + fi + if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make ${opt} -j 20 all" \ + >> $lf 2>&1; then + echo "Fail (build)" + continue + fi + echo "Success" +} + top=$(make -V SRCTOP) cd $top/sys/boot +# Default build for a goodly selection of architectures for i in \ amd64/amd64 \ arm/arm arm/armeb \ arm64/aarch64 \ i386/i386 \ mips/mips mips/mips64 \ powerpc/powerpc powerpc/powerpc64 \ sparc64/sparc64 \ ; do ta=${i##*/} - echo -n "Building $ta..." - if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make clean cleandepend cleandir obj depend" \ - > _.boot.${ta}.log 2>&1; then - echo "Fail (cleanup)" - continue - fi - if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make -j 20 all" \ - >> _.boot.${ta}.log 2>&1; then - echo "Fail (build)" - continue - fi - echo "Success" + dobuild $ta _.boot.${ta}.log "" done + +# Build w/o ZFS for i in \ amd64/amd64 \ i386/i386 \ + sparc64/sparc64 \ ; do ta=${i##*/} - echo -n "Building $ta MK_ZFS=no..." - if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make clean cleandepend cleandir obj depend" \ - > _.boot.${ta}.noZFS.log 2>&1; then - echo "Fail (cleanup)" - continue - fi - if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make MK_ZFS=no -j 20 all" \ - >> _.boot.${ta}.noZFS.log 2>&1; then - echo "Fail (build)" - continue - fi - echo "Success" + dobuild $ta _.boot.${ta}.no_zfs.log "MK_ZFS=no" +done + +# Build with firewire +for i in \ + amd64/amd64 \ + i386/i386 \ + ; do + ta=${i##*/} + dobuild $ta _.boot.${ta}.firewire.log "MK_LOADER_FIREWIRE=yes" +done + +# Build without GELI +for i in \ + amd64/amd64 \ + i386/i386 \ + ; do + ta=${i##*/} + dobuild $ta _.boot.${ta}.no_geli.log "MK_LOADER_GELI=no" done Index: stable/11/tools/build/options/WITHOUT_LOADER_GEIL =================================================================== --- stable/11/tools/build/options/WITHOUT_LOADER_GEIL (nonexistent) +++ stable/11/tools/build/options/WITHOUT_LOADER_GEIL (revision 329140) @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Disable inclusion of GELI crypto support in the boot chain binaries. Property changes on: stable/11/tools/build/options/WITHOUT_LOADER_GEIL ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/tools/build/options/WITH_LOADER_FIREWIRE =================================================================== --- stable/11/tools/build/options/WITH_LOADER_FIREWIRE (nonexistent) +++ stable/11/tools/build/options/WITH_LOADER_FIREWIRE (revision 329140) @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Enable firewire support in /boot/loader and /boot/zfsloader on x86. +This option is a nop on all other platforms. Property changes on: stable/11/tools/build/options/WITH_LOADER_FIREWIRE ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11 =================================================================== --- stable/11 (revision 329139) +++ stable/11 (revision 329140) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r324649-324654,324700,324702,324709,324717,324719,324841-324843,324845,324850,324876-324881,324883,324980-324982,324995,325014,325093-325094,325114,325170-325176,325248,325286,325310,325332,325338-325339,325376-325377,325379-325380,325382,325478-325485,325556,325641,325681,325685-325694,325743-325744,325748,325775,325779-325780