From: Durgesh Pattamatta Date: Thu, 15 Jul 2010 22:32:28 +0000 (-0700) Subject: Apex 1.6.8 baseline source code. X-Git-Url: http://git.lpclinux.com/?p=apex-1.6.8-lpc313x.git;a=commitdiff_plain;h=e010db6b6bf84930c38a023036ad6c0ad6d63ae6 Apex 1.6.8 baseline source code. --- e010db6b6bf84930c38a023036ad6c0ad6d63ae6 diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d511905 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..3807c75 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,2089 @@ +2009-01-23 Marc Singer + + * Makefile (SUBLEVEL): v1.6.8 + +2009-01-23 Marc Singer + + * src/mach-lh7a40x/initialize.c (target_init): Added code to the + target initialization for Companion that initializes the modem. + +2009-01-21 Marc Singer + + * Makefile (SUBLEVEL): v1.6.7 for push of new features. + + * src/drivers-lh/drv-mmc.c (mmc_report): Revised reporting to make + it easier to troubleshoot cards. + +2009-01-20 Marc Singer + + * include/mmc.h (mmc_card_acquired): Revised the card acquisition + code so that we don't assume that the first byte of the CID + register is non-zero. IMHO, our assumption was correct based on + the SD association's documentation, but we found that the Eye-FI + card has a bogus looking card ID (CID) register and we have to be + lenient to see it. + + * Makefile (SUBLEVEL): v1.6.6 for Companion fixes so it can use a + 1.6.x version of APEX. + + * src/drivers/relocate-nand.c: Revised NAND relocator to work with + the LPD7A404. Considering that the only other user of the code is + a test implemented for the LH79524, this should be safe to + rework. The key difference is that the relocator will address + each page in turn instead of depending on an unreliable feature of + NAND flash that automatically loads successive sectors. + + * src/arch-arm/Kconfig: Changed the Companion bootstrap to use the + NAND relocator. This allows us to have a loader that is larger + than 80KiB, the size of SRAM. + Added a page size configuration option for relocation from NAND + flash. + + * src/apex/cmd-version.c (cmd_version): Fixed display of + environment variables s.t. the >64KiB length is properly shown in + the version command output. + +2009-01-11 Marc Singer + + * src/apex/cmd-image.c (cmd_image): Added an option to relocate + the ramdisk image s.t. the uBoot image format can be loaded with + "image load" and then used to boot the system. + +2009-01-05 Marc Singer + + * src/mach-orion5x/mv2120_config: Moving to the CodeSourcery + compiler for thumb support. + + * src/arch-arm/lib/cp15-invalidate-dcache-va.c + (invalidate_dcache_va): Conditionally compiling the + invalidate-dcache-va function based on the presence of the macro + and, therefore, the CP15 feature. + + * Makefile (SUBLEVEL): 1.6.5 for orion5x merge. + +2009-01-04 Marc Singer + + * src/apex/cmd-flashusage.c (cmd_flashusage): New command to scan + eraseblocks of a flash device for the presence of data. + + * src/mach-lh7952x/memory.h (RAM_BANK0_LENGTH): Fixed the + declarations of the extents for the memory regions in the + LH7952x. The macros were correct for the LH79524 but not the + LH79520. This is now fixed. + + * src/drivers/drv-ext2.c (ext2_identify): Revised EXT2 driver to + look for extended partitions and to cope with 64 bit IO. + + * include/driver.h: Support for 64 bit IO sizes. This is only + necessary for large devices like those accessible via ATA/SATA. + It is optional and somewhat expensive. Even the EXT2 driver will + function without it, but it won't be able to see partitions past + 2GiB. This change trickled into lots of areas of APEX because of + the change of types in the descriptor structure. However, there + should be no size or performance impact when the system is + compiled without CONFIG_DRIVER_LONG_LONG_SIZE. + + * src/arch-arm/lib/muldi3.S: Inclusion of another kernel function + for handling aeabi entry points. This was required by drv-ata + when we compiled it with THUMB. + + * src/arch-arm/lib/cp15-wait.c: This and other cp15 functions so + that cp15 operations can be invoked from THUMB code without THUMB2 + support and without specialized code to detect the operation + mode. These functions allow all code that lacks __asm's to be + compiled with THUMB. + +2008-12-30 Marc Singer + + * src/drivers/drv-fat.c (fat_open): Adding greater specificity + to the region construction from the block_driver(). + + * src/drivers/drv-ext2.c (ext2_open): Adding greater specificity + to the region construction from the block_driver(). + + * src/drivers/driver.c (parse_descriptor): Fix to disambiguate + regions that could have path elements. The parser would not + interpret driver:10k as having a start address of 10k when the + driver could accept a path. Now, parser will interpret driver:bin + as having a path of 'bin', but driver:10k as having a starting + offset as 10k. The region can be unambiguously constructed using + '@' and '/' appropriately. + +2008-12-22 Marc Singer + + * src/mach-mx3/drv-i2c.c: New I2C driver for MX3x. Not complete, + but working for writes to the I2C#1 controller. + + * src/mach-mx3/cmd-wm8955.c: New command for sending control + messages to the WM8955L on the PSJL Karma. + +2008-12-21 Marc Singer + + * src/drivers/driver.c (parse_descriptor): Fix for the parsing of + FS descriptors such that the start address and length parameters + may be set. + (parse_descriptor): Added the '%' special character for combining + one or more descriptors. This is used by the drivers that have a + basis driver defined in an environment variable, s.t. the driver + can specify a starting address and/or length without knowing the + exact form specified by the + +2008-12-18 Marc Singer + + * Makefile (SUBLEVEL): Rolling revision for PSJL implementation. 1.6.4. + +2008-12-14 Marc Singer + + * src/drivers/drv-nor-cfi.c (nor_probe_chip): Support for broken + AMD/Spansion NOR flash that does not properly report top-boot + vs. bottom-boot. + * src/drivers/drv-nor-cfi.c: In order to support the Micronix + (Spansion compatible) NOR flash in the HP MediaVault 2120, we + needed to completely fill out the Spansion support. There is + support for a single byte wide bus and a 16 bit internal logic as + is the case on the MV2120. + +2008-12-13 Marc Singer + + * src/drivers/drv-nor-cfi.c (ReadArray): Changed the ReadArray + command for Spansion to 0xf0. +2008-12-11 Marc Singer + + * src/arch-arm/lib/cp15.c (cp15_ctrl): Enhanced the cp15 report on + the control register to be more readable and to show more + bits (ARMv6). + +2008-11-25 Marc Singer + + * src/apex/cmd-image.c (cmd_image): Adding descriptor_open() call + to image load so that we can read from tftp. + +2008-11-20 Marc Singer + + * src/drivers/drv-nor-cfi.c (nor_report): Cleanup of the nor flash + driver report. Added start address and length that match the mem + driver. + +2008-11-19 Marc Singer + + * Makefile: Thumb support restored, required a little work to the + src/arch-arm/lib code to guarantee interwork compatibility. + + * src/mach-mx3/exception_vectors.c: Implementation of exception + vectors on MX31, primarily in support of debugging THUMB. + + * src/arch-arm/lib/div64.S: Slight recoding of platform + implementations of basic functions to be interwork compatible. + +2008-11-18 Marc Singer + + * src/net/tftp.c (tftp_receiver): Reporting on TFTP errors + s.t. we properly detect file-not-found problems. + +2008-11-13 Marc Singer + + * Makefile (SUBLEVEL): Version 1.6.3 for dm9000. The initial + orion patches are in as well, but not yet supported. + + * src/drivers/drv-dm9000.c (dm9000_read): Implementation of + dm9000_{read,write} to round out support for dm9000 as a complete + Ethernet MAC/PHY driver. + +2008-09-16 Marc Singer + + * src/lib/strtol.c: Adding strtol as a separate library function, + in case it is needed. The memlimit command will use this function. + + * src/mach-mx3/rosencrantz.h (CCM_PDR0_V): Override for the PDR0 + so that the CSI clock scalar is non-default. + + * src/mach-mx3/mx31.h (CCM_UPCTL_266_V): Fixed the UPCTL + initialization values. This PLL is based on the CKIH, so it + doesn't need to change when the CPU clock speed changes. + (CCM_PDR0_V): Allowing this value to be overridden by the board + specific header. + + * src/drivers/drv-mem.c (cmd_memlimit): Revised memlimit to permit + a negative offset which is then subtracted from the total system + memory. + +2008-09-15 Marc Singer + + * debian/rules (binary-arch): Adding apex-image to the tools + installed in the debian package. + +2008-09-12 Marc Singer + + * src/apex/cmd-image-uboot.c: Documentation for UBOOT image + format. + (verify_uboot_image): Added support for multi-images. Now loading + UBOOT images the same way that UBOOT does. + + * src/apex/region-checksum.c (region_checksum): Fixed the checksum + to account for incoming CRC value as is necessary for UBOOT image + CRC computation. + + * src/apex/cmd-image-uboot.c: Added uboot image support. No + multi-images, but the rest works OK. + + * src/apex/region-checksum.c (region_checksum): Added neglected + check for whether or not the caller wants the length added to the + checksum + + * src/apex/cmd-image-apex.c (handle_apex_image): Factored out the + APEX image code so we can implement UBOOT in separate file with + optional compilation. + +2008-09-11 Marc Singer + + * scripts/Makefile.build (modorder-target): Removed build of the + module.order files. + + * src/apex/cmd-copy.c (cmd_copy): Fixed the return value so copy + doesn't stop startup. + + * src/apex/cmd-image.c (handle_load_apex_image): Cleaned up the + output and make the check and load functions look similar in + output. + + * src/apex/region-checksum.c (region_checksum): Fixed checksumming + so that we can sum over a defined range instead of being limited + to summing the whole region. + +2008-09-10 Marc Singer + + * src/apex/cmd-image.c (apex_image): Refactored cmd-image code to + support a single driver for parsing through the header data. + +2008-09-10 Marc Singer + + * src/apex/cmd-image.c (cmd_image): Fixed cascade testing of + options. + + * src/lib/gmtime.c (gmtime_r): Fixed year calc (typo). + (gmtime_r): Fixed month calc, off by one. + (convert_two_digits): Fixed representation of numbers; digits + swapped. + + * src/lib/strimatch.c (strimatch): Fixed this function to properly + match when the case is identical. + +2008-08-28 Marc Singer + + * src/apex/cmd-help.c (compare_commands): Righted command sort + order. + (cmd_help): Eliminated a possible overflow of command listing + array. + +2008-08-27 Marc Singer + + * src/drivers/drv-mem.c (memory_write): Fixed un-aligned write + code. The original test used were allowing invalid unaligned + accesses. + +2008-08-26 Marc Singer + + * src/mach-mx3/nor-cfi.h: Removed bogus override of the NOR flash + memory command type. + + * src/mach-mx3/initialize.c (target_init): New initialization of + the DM9000 memory region for MX31. The timing is much tighter and + the OE and R_Wn timing has a better guarantee of accuracy. + + * src/drivers/drv-dm9000.c (cmd_eth): New 'r' and 'w' subcommands + for inspecting registers of the DM9000. Renamed the 're' command + to eeprom since that's what it does. + + * src/apex/services.c (init_services): More clear output from + service startup in LL mode. + + * Makefile (SUBLEVEL): New version for changes to DM9000 code and + for new KarmaV configuration. + +2008-07-09 Marc Singer + + * src/drivers/drv-ext2.c: Added support for the inode_size field + in the first revision of the second-extended filesystem's + superblock. + +2008-05-20 Marc Singer + + * debian/postinst: Fixed the postinst script to only run on the + NSLU2. + +2007-10-16 Marc Singer + + * Makefile: The help make target now shows the configurations and + the descriptions of them. + (SUBLEVEL): 1.5.13. + + * src/drivers/relocate-nand.c: Fixed the basic NAND relocator. + The code was previously broken as there was no configuration that + used it. + + * src/drivers-lh/Kconfig: Added 565 option for LCD panel. Odd, + that we'd never implemented this before, but it is important to + note that the NXP LCD controller doesn't cope with 565 as well as + 555. + + * src/mach-mx3/ipu.c: Inverted sense of LED outputs for testing + Rosencrantz. + + * src/mach-lh7a40x/clcdc-karma.c: Added adapter code for Karam LCD + panel. + + * src/mach-lh7a40x/cmd-karmaaccel.c: Added accelerometer test code + for Karma. + + * src/mach-lh7a40x/cmd-karmatouch.c: Added touch controller test + code for Karma. + + * Removed a lot of cruft associated with older NAND flash + implementations. NAND code is moved to the drivers directory. + +2007-08-06 Marc Singer + + * Makefile (SUBLEVEL): Rolling to 1.5.11 just to make sure we got + all of the timing parameter changes in a unique version. + +2007-07-24 Marc Singer + + * Makefile (SUBLEVEL): rolling to 1.5.10 for fix to CPU timing on + lh7a404. + +2007-07-24 Marc Singer + + * src/mach-lh7a40x/initialize.c: Moved the clock speed setup to + the early initialization routine so that it is properly + configured. + +2007-06-27 Marc Singer + + * usr/apex-env.cc (arg_parser): Added force option to the apex-env + command. + (main): Added partial command support so that 'apex-env rel' shows + the release version. + +2007-06-26 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Removed Companion section from + the general build. + +2007-06-25 Marc Singer + + * Makefile (SUBLEVEL): 1.5.8: Releasing for Debian package. + + * usr/apex-env.cc: Added release and region commands for probing + the APEX environment. + + * src/apex/env.c: Added prefix option to the startup command. + Removed crufty old ENV_STARTUP option that was mach specific. + +2007-06-03 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Renamed some of the sections to + make the meanings clear. Preemtively fixed a vulnerability to + section reordering. Fixed the setting of fSDRAMBoot so that it + works for INLINE init mode and for the older form. + + * src/mach-ixp42x/initialize.c (bootstrap_sdram_pre): Revamped the + initialization code for ixp42x to use inline mode. Took the + opportunity to elide a lot of cruft from the routines. It isn't + yet tested as written to flash as this requires setup of one of + the wigglers. None of the typical uses of APEX on the ixp42x + install APEX as the primary boot loader, so this can wait. + + * src/arch-arm/Kconfig: Configuration option to override the + default SDRAM execution detection code. Most platforms can use + the execution address to detect whether or not APEX is running in + SDRAM. Some, like the ixp42x map flash over SDRAM, so we have to + use a custom piece of code to detect this circumstance. + +2007-06-03 Marc Singer + + * src/arch-arm/Kconfig: Added AEABI configuration option so that + we can link APEX with an AEABI toolchain. Really, the only + difference is the inclusion of a couple of math functions. + + * src/arch-arm/lib/lib1funcs.S: Added config.h to build of + lib1funcs so that the configuration dependencies are checked. + +2007-06-02 Marc Singer + + * Makefile (SUBLEVEL): 1.5.6: Releasing version with fix section + ordering. + +2007-06-01 Marc Singer + + * src/arch-arm/entry/reset.c: Fixed a problem in the ordering of + the reset sections that was illuminated by rwhitby's default + compiler. + +2007-06-01 Marc Singer + + * Makefile (SUBLEVEL): 1.5.5 for the SAVEATONCE option, very + necessary for OneNAND stored environment. + + * src/lib/env.c: New option, CONFIG_ENV_SAVEATONCE implements a + cached environment that is saved at one time to non-volatile + storage instead of through incremental updates. This is necessary + for some types of NAND flash where multiple writes to the same + page are limited. + + * src/apex/*.c: Groomed error reporting for opening regions. + + * src/lib/env.c: Changed the environment region descriptor name to + d_env so that it is easier to remember. + +2007-05-30 Marc Singer + + * Makefile (SUBLEVEL): 1.5.4. Rolling revision for the sake of + the xscale fixes. + + * src/mach-mx3/cmd-sleep.c (cmd_sleep): Test code for MX31 sleep + modes. + + * src/mach-mx3/cmd-reset.c (cmd_reset): Command verified. + + * src/arch-arm/entry/reset.c: Added a jump to reset_exit() from + reset() in the event that we disable the MMU at startup. The + ixp42x needs this because the xscale MMU flush code allocates data + in the text section. + + * src/mach-ixp42x/initialize-sdram.c (cmd_initialize_sdram): Fixed + the scan of 256Mib SDRAM chips. A small change to the algorithm + and we seem to be able to detect 64MiB of memory just fine. + + * src/drivers/drv-mem.c (cmd_memscan): Error detection for region + too small. + +2007-05-24 Marc Singer + + * src/drivers/driver.c (parse_descriptor): Unparseable regions + will now generate an error. + + * src/apex/cmd-version.c (cmd_version): Added a message about the + currently set variation. + +2007-05-24 Marc Singer + + * Makefile (SUBLEVEL): 1.5.3. Rolling rev for the sake of working + IPU code, working sensor capture, and turing off of the + illumination LEDs. + + * src/mach-mx3/ipu.c (cmd_ipu): Fixed the shutter width to + increase frame rate. + + * src/mach-mx3/ipu.c (ipu_setup): Fixed the burst width to memory + through the IPU DMAC. + +2007-05-22 Marc Singer + + * src/drivers/drv-dm9000.c: Fixed failed probe code path. If the + dm9000 isn't found, there will be no report. + + * src/mach-mx3/ipu.c: Adding view finder DMA task. + + * src/lib/env.c (env_check_magic): Fixed empty/broken environment + region case. + +2007-05-18 Marc Singer + + * Makefile (ARCH): Releasing 1.5.2. + + * src/arch-arm/Kconfig: Fixed companion boot by explicitly + enabling the simple/NOR flash relocator as the primary relocator. + + * src/drivers/drv-nand.c (nand_sequential_input): Fixed the NAND + driver to R/W on ST NAND parts. + +2007-05-17 Marc Singer + + * src/mach-lh7952x/debug_ll.h: Fixed UART declarations. + + * src/mach-lh7952x/init-motoedge.c: Converted to inline + platform initialization. + + * src/arch-arm/entry/relocate-simple.c: fixed relocate-simple() + because we changed the way we handle offsets. + +2007-05-16 Marc Singer + + * Makefile (SUBLEVEL): Rolled to 1.5.2 so that we can keep track + of this interim release. + + * src/apex/command.c (exec_monitor): Eliminated representation of + empty commands in startup command list. + +2007-05-15 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Reorganized the sections and the + section names to be more readable and consistent. + +2007-05-12 Marc Singer + + * src/arch-arm/entry/reset.c: Restructured to allow for cleaner + startup code. Legacy implementations are still OK, but the new + plumbing permits seamless transitions between various + initialization elements to handle constrained boot situations. + Also removed an onerous constraint on register usage in the + relocate_apex() function. The caller is now forced to assume that + no registers are saved. + + * src/arch-arm/linux/atag.c (atag_header): Eliminated the core tag. + +2007-05-10 Marc Singer + + * Releasing 1.5.0 with iMX31 and OneNAND. + +2007-05-10 Marc Singer + + * src/drivers/relocate-onenand.c: Groomed the relocation for + OneNAND to remove unneeded return address calculation. + + * src/drivers/drv-dm9000.c: Added code to help select the proper + default interface when there could be two and only one is present. + + * src/mach-mx3/initialize.c: Groomed the startup code to remove + much cruft. + + * src/apex/env.c: Fixed typo in the default environment startup + command that was including the ramdisk startup even though there + was none needed. + +2007-05-10 Marc Singer + + * src/apex/command.c (call_command): Reorganized command + invocation to report bogus command requests. + +2007-05-09 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Start of reorganization of the + bootstrap so that we don't need to use function calls to handle + early setup *and* we don't depend on macros. + +2007-05-07 Marc Singer + + * src/drivers/relocate-onenand.c: Implementation of OneNAND + APEX relocation for bootstrap. + + * src/apex/env.c: Improved the environment link so that it can + exist even if there is no user-modifiable environment. This is to + allow user-land to browse environment variables even if they + cannot set them. + + * src/mach-lh7a40x/preinitialization-companion.c: Comment on + preinitialization. + +2007-05-04 Marc Singer + + * src/mach-mx3/ipu.c (cmd_ipu): Fixed the i2c code and added hooks + to enable camera test patterns. + + * src/mach-mx3/initialize.c: Substantially enhanced the system + setup. The IPU test code is now able to write to memory. + + * src/apex/cmd-version.c (cmd_version): Added target board + description string. + +2007-04-30 Marc Singer + + * src/mach-mx3/initialize.c: Extra check in the initialization + routine so that we don't alter the timing registers if the CPU is + already in the target mode. It looks like the CPU doesn't like + the PLLs being changed once it has booted. It may be the SDRAM + that doesn't like the timing change. + + * src/arch-arm/entry/reset.c: Restored setting of the CPSR mode in + the loader. The CPU boots in the undefined mode. We move to + supervisor mode, though this doesn't appear to be necessary for + the kernel to boot. + + * src/mach-mx3/ipu.c (ipu_report): Improved clarity of IPU report + to break out fields and to describe the formats in English. + +2007-04-27 Marc Singer + + * include/asm/cp15-armv6.h: Fixed the cache control macros for the + ARMV6. + +2007-04-27 Marc Singer + + * src/mach-mx3/ipu.c: More IPU debug code. The report function + has a clean rendering of the registers. + + * src/mach-mx3/mx31.h (CCM_PDR0_533_V): Switched to 533MHz CPU + clock. + + * src/mach-mx3/uart.h (INITIALIZE_CONSOLE_UART): extended the + FIFOS to 16 bytes. + + * src/mach-mx3/initialize.c: Added initialization of COSR even + though we don't use it. + + * src/mach-mx3/Kconfig: New architecture number for Rosencrantz. + +2007-04-24 Marc Singer + + * src/apex/services.c: Created this file to hold service + init/release code. + + * src/apex/env.c: Added a "" to the startup command so that we can + have an empty startup command. + +2007-04-09 Marc Singer + + * 1.4.18 for mx31 changes. + +2007-04-06 Marc Singer + + * src/drivers/drv-mem.c (memory_read): Fixed the memory read + function so that it properly reads from word width regions. + + * src/mach-mx3/initialize.c: Fixed the usleep timer programming. + There were two problems. First, the base frequency is not as + advertized. The CPU can only use the IPG clock as the basis. + Second, our programming of the timer was wrong and needed to be + reworked so that we properly detected the timer expiration. + (__section): Added DM9000 region initialization. + +2007-03-01 Marc Singer + + * src/drivers/drv-mem.c (memory_write): Revised the drv-mem write + function so that it does it's best to match the requested IO width + when we're writing from the fill command. Other users should be + unaffected. + +2007-02-25 Marc Singer + + * 1.4.17 + + * src/drivers/drv-nor-cfi.c (nor_read): Fixed the nor-cfi driver + cache support. It wasn't properly purging cache entries so the + write and erase code was failing. Now, we invalidate entries for + the area we've read. We still see the significant improvement in + read throughput. + + * src/arch-arm/entry/mmu.c: Added comment about how it is the + called who must purge the cache on marking a block uncacheable. + This also removes a bit of code that did nothing. + + * src/mach-ixp42x/initialize-sdram.c (cmd_initialize_sdram): SDRAM + initialization code for the ixp42x so that we can initialize SDRAM + even though we're not the primary boot loader. It *looks* OK, but + I haven't been able to test it with multi-chip slugs. + +2007-02-15 Marc Singer + + * src/drivers/drv-nand.c: Revised the NAND flash initialization + code to allow for better/more flexible detection of NAND chip + organizations. Without a comprehensive directory of chip IDs, + we're looking for an easy way represent the ID->organization + mapping. + +2007-02-14 Marc Singer + + * Makefile (SUBLEVEL): 1.4.16. Rev for fat-slug support. + + * src/drivers/drv-mem.c (memory_scan): Fixed error in memory scan + that wasn't accoounting for the last block in a region. This + probably would never have been a problem, but was noticed while + testing the memscan function. + (cmd_memscan): New command that scans a region of memory as if + we're scanning memory when APEX starts. This is useful when + debugging memory initialization issues. + (cmd_memscan): Added -u switch to memscan so that we can update + the memory map passed to the kernel after APEX has made it's pass + at initialization time. + +2007-02-13 Marc Singer + + * src/drivers/drv-nor-cfi.c: Added Spansion command support to the + nor-cfi driver. This is a configuration time option. Only one + command set/protocol may be selected at a time. + +2007-02-12 Marc Singer + + * src/drivers/drv-nand.c: Augmented NAND driver to allow for both + Toshiba style command and ST style commands. The ST stuff is + incomplete, but reading ought to be OK. + +2007-02-05 Marc Singer + + * Makefile (SUBLEVEL): 1.4.15, allows a wait of 0 for a check for + ^C before continuing. Mainly done to release to debian. + +2007-02-05 + + * debian/rules: Dumb typo when I revised the rules. The name of + the output file changed and I didn't want it to. + +2007-02-02 Marc Singer + + * src/apex/cmd-wait.c: Allowing a zero TIMEOUT. + + * src/apex/command.c (TIMECMD_INIT): Added command execution timer. + +2007-01-31 Marc Singer + + * debian/rules: Cross-building support. + + * src/mach-ixp42x/serial.c: Minor change to the ixp42x serial + driver to raise RTS for the same of systems that use it. + +2007-01-30 Marc Singer + + * src/arch-arm/lib/lib1funcs.S: New version of lib1funcs so that + armel is happy. This code was pulled directly from the Linux + kernel source. + +2007-01-29 Marc Singer + + * Added alternatives to Debian configs. + +2007-01-29 Marc Singer + + * Makefile (SUBLEVEL): Rolled rev for block cache fix. + + * src/drivers/drv-ext2.c: inode/block cache flush was broken. + Now, it is not. + +2007-01-27 Marc Singer + + * usr/apex-env.8: Man page. + + * usr/link.h: Added cleanup code to Link object. It isn't + strictly necessary, but it is good hygiene. + +2007-01-27 Marc Singer + + * Makefile: 1.4.12 for new environment program and to prepare for + publishing a new release. + + * usr/apex-env.cc: New user-mode program for updating the APEX + environment once the system is booted. It replaces the printenv + program that was only able to print the environment as it stood, + combining the flash data with the defaults from APEX. This + program is smart enough to be able to set/unset variables and + erase the whole environment. + +2007-01-25 Marc Singer + + * src/mach-lh7a40x/clcdc-companion.c: Removed the DDS hack form + the LCD init on Companion. No DDS circuit present anymore. + +2007-01-23 Marc Singer + + * src/lib/memtest.c (memory_test_0): Revised the memory test + walking bit loop on advice from a collegue. Made the full memory + test an option on top of the basic memory test. + +2007-01-23 Marc Singer + + * src/mach-lh7a40x/variation-companion.c (variation_init): Added + variation support to the Companion. Pressing three keys at + power-on will activate the variation boot. + +2007-01-13 Marc Singer + + * src/arch-arm/entry/reset.c (__section): Slight change to MMU + disabling code. + + * src/arch-arm/entry/mmu-xscale.h (CACHE_CLEAN_D): Revised cache + clean code to match Nicolas Pitre's work in the Linux kernel. + +2007-01-09 Marc Singer + + * src/drivers/drv-fis.c (end_of_table): Added back the + end-of-table check. We're now checking the same way that the + kernel checks. + +2007-01-09 Marc Singer + + * Makefile (SUBLEVEL): 1.4.11, to fix partition table swapped-ness + check. + + * src/drivers/drv-fis.c (prescan_directory): Fixed the partition + table swapped-ness check to a more robust comparison of the + partition table entry's erase block with the erase block from + which the table is being read. + +2007-01-08 Marc Singer + + * 1.4.10. + + * src/drivers/drv-fis.c (deleted_entry): Replaced the + end_of_table() checks with deleted_entry checks. Really, we + cannot be sure that we've seen the end of the table since a 0xff + in the first byte indicates a deleted entry and we have to check + for that first. We previously thought that (u32)~0 was the end of + the table, but we cannot now be sure. Argh. + + * Applyied nas100d and dsmg600 patches as well as a slew of config + file patches courtesy of rwhitby. + + * src/drivers/drv-nor-cfi.c (SWAP_ONE): Fixed the nor flash driver + to properly write when in an endian mismatched mode. This may be + peculiar to the nslu2 (and other ixp4xx systems) where flash is + assumed to be written in one endian-ness while the system is + executing in the opposite endian-ness. + + * src/mach-ixp42x/variation-nslu2.c (variation_init): Variation + now uses the fact that the power button is depressed (instead of + the reset button). + + * src/lib/dump.c (dumpw): Fixed the printability check on dump so + that we don't write non-ascii characters. + + * src/lib/env.c (env_check_magic): Streamlined the environment + magic number check. + +2007-01-06 Marc Singer + + * src/apex/env.c: Many more environment variables may be defined. + + * src/apex/cmd-boot.c (atag_commandline): boot command performs + lookup of the default command line that allows for alternatives. + + * src/arch-arm/Kconfig: Reworking of the environment configuration + section. We now have options to set alternative kernel command + line, kernel source region, and ramdisk region. Default variation + suffix is a config parameter. The default startup command is more + clearly controlled. + + * src/mach-ixp42x/variation-nslu2.c (variation_init): Added + variation for nslu2. Holding the reset button while booting will + select the alternative boot and set the variation to the + configured value. + + * src/apex/command.c (expand_variables): Added '-' to the list of + acceptable characters when scanning a command for variables to + expand. This is helpful for variations. + + * src/lib/lookup.c (lookup_alias_or_env): Variation support added + to the standard lookup function. + +2006-12-13 Marc Singer + + * src/apex/command.c (parse_command): Added '-' command prefix + that tells APEX to ignore the return value of a command. This is + helpful in the startup command. + +2006-11-07 Marc Singer + + * Makefile (SUBLEVEL): Rolling rev for memory test. + + * src/lib/memtest.c (memory_test_0): memory test for system setup. + It checks SDRAM before copying the loader post-bootstrap. Works + generally on any target, but requires that the + initialize_bootstrap () function return TRUE when it initializes + SDRAM. + +2006-10-25 Marc Singer + + * src/drivers/drv-nand.c (cmd_nand): NAND commands moved to a + configurable option. + (nand_report): Fixed the display of the NAND status. + +2006-10-23 Marc Singer + + * src/drivers/drv-fis.c (prescan_directory): Modified the check + for swapped partitions to compare the address of the directory + partition with the address being scanned. Should be more robust + than the original test. Also added a further limit to directory + scanning using the length of the directory partition. + +2006-10-23 Marc Singer + + * src/arch-arm/entry/mmu-alloc.c (alloc_uncached_top_retain): + Function returns a block of memory from the top of scanned RAM. + It also removes the memory from the pool passed to the kernel. + + * src/drivers-lh/drv-clcdc.c (clcdc_init): New configuration + option to allocate the frame buffer from the top of memory and + remove it from the pool given the kernel. It also prevents the + LCD display from being shut down when the loader passes control to + the boot or go application. + +2006-10-18 Marc Singer + + * Makefile: v1.4.7 + + * src/mach-lh7a40x/preinitialization-companion.c: + Preinitialization support to work-around limitation in Sharp Boot + ROM. The ROM only loads 512 bytes from modern NAND parts. We + need to pull more of this down in order to properly initialize the + system and copy the loader to SDRAM. + + * src/drivers/drv-nand.c: Genericized NAND driver. + + * src/drivers-lh/drv-clcdc.c: New panels. Reorganized the panel + setup code to better conform to standard nomenclature. + + * src/drivers/drv-dm9000.c: Support for more than one DM9000 + chip. It can write to both mac address roms as well. + +2006-08-18 + + * src/drivers/drv-fis.c (compare_skips): Fixed the comparison + function. The sign sense was wrong and it sorted to the wrong + order. + +2006-08-12 + + * Makefile (SUBLEVEL): v1.4.3 + + * src/drivers/drv-fis.c (fis_report): Added skips to the report. + + * debian/rules: Removed headerization so that slugimage can be + responsible for it. + + * src/drivers/drv-fis.c: Added skip descriptor handling. This + means that partitions may include 'skips' where some data + physically located in the partition is ignored when performing IO + on the partition. This feature was added for the slug with a dumb + version of Redboot that ignores the partition table when looking + for the data it must copy to SDRAM. + + * src/apex/cmd-fill.c (cmd_fill): Removed unwanted printf. + + * src/lib/sort.c (sort): Check for degenerate cases of sorting 0 + or 1 element. + + * debian/*: Fixed the control file and and changelog to properly + reflect this release. + +2006-07-30 Marc Singer + + * Makefile (SUBLEVEL): Rolling revision in preparation for release + of the BSP. apex-1.4.2 + + * src/mach-lh7952x/env.c: Moved all lh7952x's to use the + amba-pl011 serial driver in the kernel. + +2006-07-29 Marc Singer + + * src/drivers-lh/drv-clcdc.c (clcdc_release): Revised the order of + the clcdc driver release so it works on the lh79520 which will + disable the controller clock. + + * src/drivers/drv-cf.c (ready_wait): Recoded ready_wait to use the + attribute pin replacement register. This doesn't really have an + impact on performance, but it does require that the driver is + properly configured in the drv_cf.h header. + +2006-07-27 Marc Singer + + * src/drivers/drv-cf.c (cf_identify): Fixed attribute reading for + some cards that return the value in the high and low bytes. + Attribute memory is really only byte addressable. This fixes a + problem with recognizing some brands of CF cards. + +2006-07-25 Marc Singer + + * usr/printenv.cc: Rewritten printenv program to support the new + environment memory format. + + * README_environment: New README about the environment. + + * Makefile: Removed envmagic.h and it's computation. The new + environment is free-standing and removal of envmagic makes the + build much quicker. + +2006-07-25 Marc Singer + + * src/lib/env.c (_env_locate): New environment implementation is + self-contained for both reading and writing. + +2006-07-25 + + * src/mach-ixp42x/debian-nslu2-arm_config: Moved the start of the + kernel and ramdisk regions to skip the 16 byte sercomm header. + + * include/atag.h: Fixed atag section macros. + +2006-07-23 + + * src/mach-ixp42x/cpuinfo.c (cpuinfo_report): Alignment change to + the cpuinfo function. + + * include/driver.h: Added query function to the driver jump table. + + * src/drivers/drv-nor-cfi.c (nor_query): New query function allows + a driver to return information about the device. NOR flash is the + only implementer because it's the one that needs this most. + (copy_from): Implementation of a byte swapping copy routine for + the sake of BE/LE conversion. + + * src/drivers/drv-fis.c (prescan_directory): New directory prescan + detemines if the flash directory has a different endian-ness from + APEX. + (map_region): New function to map the directory entry to a + region. Now, the region use the underlying flash driver. + + * src/apex/cmd-copy.c (cmd_copy): Added -s option to copy for byte + swapping data where the source is a different ending from APEX. + +2006-07-22 + + * src/drivers/drv-mem.c (memory_read): Checks the width field and + performs IO accordingly. + + * src/apex/cmd-help.c: Revised command line help. + + * include/driver.h: New descriptor field specifies the IO width. + This allows, in particular, the memory driver to tailor the I/O to + a specific width. Some regions must be read as words (CPU + registers), others as bytes (CF). + + * src/apex/cmd-dump.c (cmd_dump): Here, and elsewhere, added + alignment attributes so that byte arrays on the stack are word + aligned. I had thought that this was a given but the 4.x + compilers no longer make this true. + + * src/drivers/drv-nor-cfi.c (nor_report): Code to detect endian + mismatch. A debugging aid for nslu2. + +2006-07-21 Marc Singer + + * Many: Modified several source files to cope with GCC 4.1. Found + a bug detected by GCC's null statement detection. Mostly warning + fixes dues to signed/unsigned coercion. + +2006-07-20 Marc Singer + + * Makefile: Release 1.3.30. Debianized. New FIS driver. + + * src/apex/command.c (expand_variables): Using new lookup function + to resolve variable/macro references in command expansion. + + * src/lib/lookup.c: New lookup function to handle checks to + aliases as well as environment without explicitly including + ifdefs. + + * src/drivers/drv-jffs2.c (block_driver): Replacing static block + driver string with a function that looks at aliases and the + environment. + + * src/drivers/drv-fat.c (block_driver): Replacing static block + driver string with a function that looks at aliases and the + environment. + + * src/drivers/drv-ext2.c (block_driver): Replacing static block + driver string with a function that looks at aliases and the + environment. + + * src/drivers/drv-fis.c: New FIS partition driver. + +2006-07-18 Marc Singer + + * src/arch-arm/entry/reset.c: Added code to support forcing the + CPU into LITTLEENDIAN mode. This is necessary for running the + NSLU2 is LE mode for Debian without replacing the Redboot loader. + +2006-07-14 Marc Singer + + * Makefile: added logic to the build to archive prebuilt binaries + for each configuration. + +2006-07-11 Marc Singer + + * src/arch-arm/entry/reset.c: Fix for register being clobbered in + apex_relocate() and messing with PUTC_LL(). + +2006-07-10 Marc Singer + + * src/apex/cmd-help.c (cmd_help): Added option to suppress the + short help descriptions. It saves a little bit on memory. + + * src/arch-arm/entry/apex.lds.S: Optimized the RAM memory + footprint, especially in the xbss section. Added stack_size + configuration parameter. + + * src/apex/cmd-boot.c (cmd_boot): Boot address may not come from + the environment. + (atag_commandline): Simplified the command line from environment + code such that there is no code to read from environment when + there is no environment. + +2006-06-02 Marc Singer + + * Makefile: Release 1.3.28. Added dm9000 mac address programming. + +2006-06-02 Marc Singer + + * Makefile: Release 1.3.27. Version for companion as well. + +2006-06-01 Marc Singer + + * src/mach-lh7a40x/relocate-companion.c: Fixed the section of the + relocation function. Added console feedback for the bootstrap. + + * src/drivers-lh/drv-mmc.c: Added proper configuration checks for + the companion relocation. + + * Many changes to the environment handling so that the environment + is present, and usable, even if the commands to manipulate it are + not. + + * src/apex/cmd-env.c: Fixed a stupid error in the environment + command code that required the setenv command in order to use the + printenv command. + +2006-05-29 Marc Singer + + * src/drivers/drv-ext2.c (ext2_info): Fixed the way that + partitions are detected so that changing partitions will properly + flush cached information about the filesystem. + +2006-05-28 Marc Singer + + * Makefile (SUBLEVEL): Rolled to 1.3.25 for the MMC driver fixes. + + * src/arch-arm/entry/apex.lds.S: The bootstrap data location is + properly calculated. + + * src/drivers-lh/drv-mmc.c: MMC driver can read multiple blocks. + Well, two to be precise, but at least we know it works. The + status returned from wait_for_status it more than 16 bits because + of the timeout. All of the reference to status are widened to + int's to make this easier. + (execute_command): Default wait_for status is not better tuned to + the command being executed. The driver gets a nice, smooth data + stream from the card. + +2006-05-27 Marc Singer + + * Makefile (SUBLEVEL): New sub-level for the companion changes. + This will roll to a new patchlevel when we get the drivers going + for sure. + + * src/mach-lh7a40x/relocate-companion.c: relocate-apex () + implementation for the synapse companion. + + * src/arch-arm/Kconfig: Added more configuration options for + compiler optimizations. + + * src/drivers-lh/drv-i2c.c: i2c driver for reading/writing + EEPROM. + + * src/drivers-lh/drv-mmc.c: Mmc driver, SD capable, bootstrap + capable + + * include/mmc.h: Factored out the mmc header for the sake of + relocation from SD/MMC. + + * src/arch-arm/entry/apex.lds.S: Special section for bootstrap + stack and bootstrap data. + + * include/apex.h: Aide functions for mdelay and msleep. + +2006-05-04 Marc Singer + + * src/drivers-lh/drv-clcdc.c: Added support for BGR color format + in the frame buffer. This is really for the benefit of testing, + but may also be important when we support a splash screen being + visible through the kernel boot process. + +2006-04-03 Marc Singer + + * Makefile: 1.3.23 + * Additions to the kconfig directory so that make menuconfig + works again. + +2006-04-01 Marc Singer + + * Makefile: 1.3.22 + + * src/mach-lh7952x/drv-emac.c (cmd_emac): Moved static structure + to .rodata. + + * src/drivers/drv-smc91x.c (cmd_eth): Moved static structure to + .rodata. + + * src/apex/command.c (expand_variables): Allowing '\' escape of + '$' to prevent expansion of variables for the sake of storing them + in other environment strings, e.g. startup. + + * include/attributes.h: Grooming. + + * src/apex/console.c: Added (optional) command + editing...finally...no kidding. + +2006-03-31 Marc Singer + + * src/apex/console.c (read_command): Added (optional) support for + ANSI key sequences. + + * src/apex/command-history.c: Added (optional) command history + recall. + +2006-03-30 Marc Singer + + * src/mach-lh7952x/drv-emac.c (emac_release): added a release + function to the emac driver. We were having problems with + spurrious corruption of kernel memory and it looks like the + problem was that the emac was in an indeterminate state as it was + being initialized. + +2006-03-23 Marc Singer + + * src/apex/cmd-version.c (cmd_version): Fixed the presentation of + the apex region for the case when the length is greater than four + hex digits. + + * src/apex/console.c (read_command): Configuration option allows + DEL to be interpreted as BS. + + * Makefile: 1.3.21 + + * usr/printenv.cc (main): Application that reads APEX environment + from user-land. + + * src/apex/env.c: added environment link support so that user-land + applications can read the APEX environment. + +2006-03-22 Marc Singer + + * src/drivers-lh/drv-clcdc.c (VSW): Fixed error in the VSW macro. + + * src/drivers/drv-ext2.c (ext2_find_inode): Fixed the computation + of the first block where the group descriptors are found. This + allows APEX to read cards with block sizes other than 1K. + +2006-03-16 Marc Singer + + * src/mach-lh7a40x/freq: Perl script that aids in finding clock + frequency dividers. + + * src/mach-lh7a40x/Kconfig: Added more overclocking frequencies to + the lh7a40x configuration. + + * Brought Kconfig sources up to date. + +2006-03-15 Marc Singer + + * Makefile: 1.3.20 + + * src/mach-lh7a40x/initialize.c: Adjusted the SMC controller + timing setup to be sensitive to HCLK as configured. + + * src/mach-lh7a40x/lh7a40x.h: Kconfig selectable operating + frequencies. + + * Adding support for new architecture, s3c2410, and new machine + m7200. + +2006-03-02 Marc Singer + + * Makefile: 1.3.19 + + * src/mach-lh7952x/lh79524.h (RCPC_CPUCLKPRE_V): Added support for + faster clocking of the LH79524. It isn't, yet, compatible with + the Linux kernel. However, this may help someone who is looking + for a little more speed. + + * src/mach-lh7a40x/initialize.c (target_init): Added support for + the LPD7A404-10, PN 80000258, USB_PWR_EN. The sense of this line + changed between the -10 and the -11 releases of the LPD7A404 + CardEngine. + +2006-02-23 Marc Singer + + * Makefile: 1.3.18 + + * src/mach-lh7952x/init-lpd79524.c: Tighetened the CF region + timing as is done for the other targets. + + * src/mach-lh7952x/init-lpd79520.c: Adjusted to the CompactFlash + region timing to meet the CF spec. + + * src/mach-lh7a40x/initialize.c (SMC_BCR6_V): Tightened the CF + region timing to be closer to the specified minimums. The + original WST1 delay was 320ns which may interfere with the LCD + controller FIFO. + +2006-02-22 Marc Singer + + * src/mach-lh7a40x/initialize.c (SMC_BCR1_V): Tightened the + IOBARRIER region timing to see if we can get access to NOR flash + without causing display flicker. + +2006-02-17 Marc Singer + + * src/lib/zlib-heap.c (CB_HEAP): Increased the size of the heap so + I can decompress very large PNG images. + + * Makefile: 1.3.17 + + * src/drivers-lh/drv-clcdc.c: New timings for the 6.4" display. + The vertical front porch is one less than the spec. + + * src/mach-lh7a40x/initialize.c (SDRAM_RAS): Relaxed memory + timings on the lh7a40x's. This seems to eliminate display + glitching as long as we don't use the CF. + +2006-02-07 Marc Singer + + * Makefile: 1.3.16 + + * src/mach-lh7952x/init-lpd79524.c: Reworked SDRAM initialization. + Now, we can init the CPU with a 16 bit SDRAM bus even if the SDRAM + chips are configured in a 32 bit bus. Half of the SDRAM will idle + in this configuration, but we can test CPU performance with the 16 + bit bus. + + * src/mach-lh7a40x/cmd-cp15test.c: Added a cp15 test register + manipulation function. + +2006-02-06 Marc Singer + + * lh7a404_config: Setting default memory mode to SROM_LL. + +2006-01-20 Marc Singer + + * src/lib/pngr.c (read_pngr_plte): When found, a palette is read + from the PNG file and stored for the decoder. + + * src/drivers-lh/drv-clcdc.c (cmd_splash): Added support for + palettized images, but only at 8 bits per pel. Other pel sizes + require unpacking of the image data. + +2006-01-13 Marc Singer + + * src/mach-ixp42x/openslug_config: Openslug 3.1 no longer puts the + kernel in the jffs2 partition. We default to reading the kernel + from flash. + + * src/arch-arm/entry/mmu.c (mmu_release): In order to support + XScale MMU (and caches) we need to customize the MMU disabling + code to cope with a different method of cleaning the data cache. + This is done for the sake of faster loading of a JFFS2 filesystem + image. The kernel is stored in a JFFS2 filesystem in flash for + compactness. The faster we can read this data, the better. Also, + reads from flash of ramdisk images benefits from caching. + +2005-12-27 Marc Singer + + * src/arch-arm/lib/relocate.c (relocate_apex): Improved the scarce + register version of the system copy routine. It's now using the + same form as the fastest version. + + * src/mach-lh7a40x/cmd-reset.c (cmd_reset): Added reset command + for the lh7a40x targets. It used the watchdog timer to perform + the system reset. + + * src/arch-arm/entry/entry.c (setup_c): Added code for clearing + stacks to a known value. + + * src/mach-lh7952x/exception_vectors.c: The exception handling + code works. APEX can use interrupts. + + * src/arch-arm/lib/relocate.c (relocate_apex) :recoded + relocation test to reduce the number of registers and to update + the syntax for __asm constraints. This code was substantially + modified to reflect some minor optimizations. + + * src/mach-lh7952x/relocate-nand.c (relocate_apex): recoded + relocation test to reduce the number of registers and to update + the syntax for __asm constraints. + + * src/mach-lh7a40x/initialize.c (usleep): recoded timer to + update the syntax for __asm constraints. + + * src/mach-lh7952x/init-kev79524.c (usleep): recoded timer to + update the syntax for __asm constraints. + + * src/mach-lh7952x/init-lpd79520.c (usleep): recoded timer to + update the syntax for __asm constraints. + + * src/mach-lh7952x/init-lnode80.c (usleep): recoded timer to + update the syntax for __asm constraints. + + * src/mach-lh7952x/init-lpd79524.c (usleep): recoded timer to + update the syntax for __asm constraints. + +2005-12-22 Marc Singer + + * src/lib/pngr.c (open_pngr): Function modified to allow for + reading from TFTP where we don't know the length of the stream + a priori. + + * src/net/tftp.c (tftp_seek): Rudimentary seek function + implemented for the sake of splash decoding. We needed to be able + to seek over the CRC (or unused portion of any chunk) in order to + decode PNG images over the network. + + * src/lib/zlib-heap.c: Makde the zlib heap larger since the + decompressor was choking on the decode of a large splash image. + Also moved the memory to xbss. We're still using a stupid null + free heap which has to be as large as all of the allocated memory. + RAM is cheap, at the moment. Perhaps we should switch to the + kernel's zlib decompressor instead of the uboot version. + + * src/drivers-lh/drv-clcdc.c: Common LCD driver for Sharp LH + parts. + + * src/arch-arm/entry/mmu-alloc.c (alloc_uncached): Function to + allocate memory that won't be cached even when the MMU is enabled. + +2005-12-19 Marc Singer + + * src/arch-arm/entry/mmu.c: Service to enable and disable the MMU. + This makes the boot loader execute much faster than without. + + * src/mach-lh7952x/serial.c (lh7952x_serial_release): Added a + release function so that serial data in the FIFO is flushed. + + * src/mach-lh7a40x/serial.c (lh7a40x_serial_release): Added a + release function so that serial data in the FIFO is flushed. + +2005-12-16 Marc Singer + + * src/mach-lh7a40x/lh7a40x.h: Added an overclocking mode. + + * src/mach-lh7a40x/initialize.c: Added more explicit macros to + handle bus clocking modes. Also, we've switched to the + synchronous bus mode as the default. + + * src/mach-lh7a40x/lh7a40x.h: Added more explicit macros to handle + bus clocking modes. + + * src/drivers/drv-mem.c: Added memlimit command so that we can + constrain the amount of memory that the Linux kernel sees. It's a + handy debug feature. + +2005-11-18 Marc Singer + + * src/drivers/drv-nor-cfi.c: Added option to inhibit the NOR CFI + buffered write code, for lnode80. + + * src/mach-lh7952x/Kconfig: Added lnode80, patch from Dave Anders. + +2005-11-07 Marc Singer + + * Makefile: Rolling release for 79525 and for a fix to the + emac79524 driver. + +2005-10-08 Marc Singer + + * src/net/ethernet.c (arp_terminate): Added a check for ^C in the + ARP termination function. + + * src/net/tftp.c (tftp_open): Reorganized the tftp open sequence + in case ARP for the TFTP server has yet to be achieved. This was + a crash bug. + +2005-10-07 Marc Singer + + * src/mach-lh7952x/Kconfig: Start of changes for the kev79525. + + * src/arch-arm/entry/apex.lds.S: Fixed the drv-mem probe code to + be reliable and safe. + +2005-09-30 Marc Singer + + * src/mach-lh7a40x/initialize.c: Slowed the timing down for the + IOBARRIER. Now, we're using the slowest timing because that's all + that seems to work. + + * src/arch-arm/entry/sdramboot.c (sdramboot_report): Unified + support for reporting when APEX is booted from SDRAM. While only + informational, this will help explain to new users the difference + between booting from flash or SRAM and from SDRAM. + +2005-09-29 Marc Singer + + * src/apex/env.c: Updated autoboot cancellation message to be more + correct. Only ^C cancels now. + +2005-09-28 Marc Singer + + * src/arch-arm/Makefile: architecture and tune features. This + fixes a build problem with native compilers. + + * src/arch-arm/Kconfig: New configuration features to select the + right architecture. Lack of this was the source of a nasty build + error having to do with the fact that the default CPU type on ARM + doesn't support the half-word load. + +2005-09-27 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Enlarged the stacks. We were + crashing from a stack overflow in the jffs2 decompression path. + + * src/lib/zlib.c: Changes so that we can use the debug option. + + * src/drivers/drv-jffs2.c (jffs2_load_cache): Fixed bug in jffs2 + filesystem cache. Cancelled cache operation which was restarted + would create duplicate entries in the cache. + +2005-09-18 Marc Singer + + * include/attributes.h (__xbss): New attribute macro for easy xbss + spec. + +2005-09-15 Marc Singer + + * src/lib/env.c (_env_check_magic): Modified the environment check + before writing to look for a large block of 0xff's before + declaring the area blank. + +2005-09-02 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Needed to set the xbss section to + NOLOAD so that the loader image wouldn't bloat with BSS areas + +2005-08-22 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Reorganized the BSS sections. + Needed to put the BSS outside of the protected region so that the + memory scan finds all of memory correctly. This change also + prevents some of the BSS memory from being zeroed. + +2005-08-15 Marc Singer + + * src/mach-lh7a40x/initialize.c (target_init): Modified the target + init for lpd7a404 so that the SMC91x controller works properly on + the latest lpd7a404 CardEngines; PCN-285 2005.5.4. + +2005-08-11 Marc Singer + + * src/mach-lh7a40x/lpd7a40x.h (CPLD_CONTROL_WLPEN): Changed + constant name to match that used by the driver and the LPD79520. + + * src/mach-lh7a40x/timer.c (timer_delta): The interval timer was + wrong, too. + + * src/mach-lh7a40x/initialize.c: The usleep timer setup was wrong. + Don't know how this ever worked. ;-) Had to move it to timer2 so + that it didn't conflict with the interval timer. + +2005-08-10 Marc Singer + + * src/drivers/drv-mem.c (memory_report): Groomed the memory report + to eliminate first blank line. + + * src/apex/command.c (exec_monitor): Removed leading whitespace in + startup command reports. + +2005-08-08 Marc Singer + + * src/apex/cmd-copy.c (cmd_copy): Detecting copy errors and + returning appropriate error code. + + * src/apex/command.c (exec_monitor): Fixed parser for startup + command so that semicolon no longer needed at the end of the + command. Fixed a bug in the routine that writes to address zero + on startup. + + * src/apex/console.c (console_poll): Improved methods for + detecting user break condition. Injected a meta-driver between + the serial driver and the functions that communicate with the + user. + +2005-08-03 Marc Singer + + * src/mach-lh7952x/ads7843.c: ads7843 test command. + +2005-08-01 Marc Singer + + * src/net/ipconfig.c (cmd_ipconfig): IP configuration via RARP or + manual configuration. + + * src/mach-lh7952x/drv-emac.c (cmd_emac): Some grooming of the + diagnostic outputs. + + * src/net/tftp.c (ping_terminate): Fixed abort of tftp by + keystroke. + + * src/mach-lh7952x/drv-emac.c (eth_read): Check for buffer looping + on read. This is untested. + +2005-07-29 Marc Singer + + * src/net/tftp.c: fixed the tftp state machine and tested that + retries work correctly. it seems to be stable and reliable in + light of packet losses. + + * src/apex/cmd-copy.c (cmd_copy): Fixed a long-standing bug in the + copy command where the din descriptor was being opened twice. + +2005-07-28 Marc Singer + + * src/drivers/drv-smc91x.c: Implemented smc91x driver which is + available to both the lpd79520 and the lpd7a40x boards. + + * src/mach-lh7952x/init-lpd79520.c: Fixed the initialization of + the memory region where CF is found. CF driver working again. + +2005-07-11 Marc Singer + + * src/apex/cmd-dump.c (cmd_dump): Added dump display width to make + it easier to read registers and machine code. + +2005-07-07 Marc Singer + + * src/net/rarp.c (cmd_rarp): RARP implemented. + + * src/apex/cmd-help.c (cmd_help): Changed the way that commands + are sorted such that there is no change to the R/O portion of the + file. Now, sorting is done only when displaying the help text. + + * src/mach-lh7952x/drv-emac.c (eth_open): Basis of ethernet driver + is working. + + * src/arch-arm/entry/apex.lds.S: Neglected alignment caused a + crash when the data segment wasn't aligned. The service data was + misaligned such that the service start addresses were wrong. + +2005-07-06 Marc Singer + + * src/apex/cmd-dump.c (cmd_dump): Added more mode to the dump + command. + + * src/apex/command.c (expand_variables): Alias and environment + expansion in the command line. This will make some people's lives + easier. + +2005-06-15 Marc Singer + + * src/apex/command.c (exec_monitor): Adding configuration option + to sort commands for the sake of better help. + + * src/apex/cmd-xreceive.c: Revising help text. + +2005-06-14 Marc Singer + + * src/drivers/driver.c (parse_descriptor): Fixed the driver parser + dependency on the filesystem drivers. + + * src/drivers/drv-fat.c (fat_read): Region length calc, again. + + * src/drivers/drv-ext2.c (ext2_read): Fixed the region length + calcs. + + * src/drivers/drv-jffs2.c (jffs2_open): Fixed some of the region + length calcs. + +2005-06-13 Marc Singer + + * src/drivers/drv-jffs2.c (jffs2_path_to_inode): Needed to + invalidate the cached block after chasing links. + (find_cached_inode): Enhanced find_cached_inode() to accept an + offset within the file. This may improve the performance of + reading since it doesn't have to scan the inode list from the top + every time. Moreover, the algorithm of the find_cached_inode + function is more efficient for larget files. + (jffs2_load_cache): Changed the logic for handling reversed + markers. The previous code would prematurely terminate if a + reversed marker was found among the filesystem detritus. + (jffs2_load_cache): Added a CRC check for inodes. + (jffs2_path_to_inode): Added a CRC check for filenames. + +2005-06-12 Marc Singer + + * src/apex/cmd-info.c: New command to query information about a + region from a driver. It's used by the jffs2 driver to show the + contents of a directory. Other filesystems ought to follow suit. + + * src/drivers/drv-jffs2.c: New jffs2 reading filesystem driver. + +2005-05-15 Marc Singer + + * src/mach-ixp42x/pci.c (pci_init): Added IRQ setup for all of the + PCI interrupt pins. + +2005-05-15 Marc Singer + + * src/lib/spinner.c (spinner_clear): clearing LED spinner when the + user enters a command prompt. + + * src/mach-ixp42x/pci.c (pci_init): Proper PCI initialization + brings USB and ethernet online. Woot. + + * src/mach-ixp42x/nslu2.h: GPIO constants and macros for init. + + * src/mach-ixp42x/ixp42x.h: GPIO constants and macros for init. + + * src/mach-ixp42x/initialize.c (target_init): Addition of dead + code to initialize GPIO for the Intel dev board. + + * src/mach-ixp42x/serial.c (ixp42x_serial_init): Enabled the + serial FIFO. + +2005-05-04 Marc Singer + + * src/mach-lh7952x/drv-emac.c: Diagnostic code can be enabled from + the configuration. + + * src/apex/cmd-version.c (cmd_version): Display the length of apex + in bytes as well as hex. + +2005-04-14 Marc Singer + + * src/arch-arm/Kconfig: New option to let the user configure a + default commandline to override the target's default. + + * src/mach-ixp42x/initialize.c (target_init): Added neglected EXP + controller initializations for the nslu2. + +2005-04-13 Marc Singer + + * src/drivers/drv-ext2.c: Added configuration option to set the + block device for both (fat & ext2) filesystem drivers. + + * src/apex/env.c: Fixed errors in the autoboot macros left over + from the transition to Kconfig. + +2005-04-08 Marc Singer + + * src/mach-lh7952x/drv-emac.c (emac_init): Fixed detection of the + PHY. Needed to setup MUX to get the PHY to enable. + + * src/mach-ixp42x/coprocessor.h (COPROCESSOR_WAIT\): New headers + to define an instruction sequence to let the MMU/coprocessor catch + up when there are changes to the setup. + + * src/arch-arm/entry/entry.c (__section): New options for + disabling MMU at startup. + + * Makefile (every): Fixed every target for the sake of adding new + configuration options. + +2005-04-07 Marc Singer + + * src/mach-lh7952x/Makefile (obj-$(CONFIG_DRIVER_EMAC_LH79524)): + Same as below. + + * src/mach-lh7952x/drv-emac.c: Corrected configuration references + for the new configurator. Macros were wrong for EMAC. + +2005-03-22 Marc Singer + + * src/apex/env.c (_s): Fixed references to CONFIG_ macros that may + already be quoted. + +2005-03-20 Marc Singer + + * src/mach-lh7a40x/initialize.c (__section): initializing the SMC + control so that flash works correctly. + + * Makefile (SUBLEVEL): Fixed the reset of the config hooks so that + the build is now optimal with respect to the configuration. + + * Fixed menuconfig. Still, I've never been able to edit strings, + hex's, or int's in menuconfig. It's there for the folks who want it. + + * Makefile (SUBLEVEL): Rolling revision for integration of new + configuration support. This is a big deal because it means that + configurations are easier to build and more robust. + + * scripts/configtoh: Stripping the quotes from config options. + We're using the kernel configurator, so we have less control over + the user's actions. This may prove to be overly zealous in + situations where the configuration option needs quotes. + ...Now it is really fixed. Needed it and there was no way around it. + +2005-03-17 Marc Singer + + * src/mach-lh7a40x/cpuinfo.c (cpuinfo_report): Fixed the CPUID + reporting for the lh7a404. + + * src/mach-lh7a40x/initialize.c: Added hack to the lpd7a40x + initialization to enable PCMCIA. May be a work-around for a NOR + flash problem. + + * src/drivers/drv-nor-cfi.c (nor_read): Eliminated (most) + references to nor chip length except when necessary. + +2005-03-16 Marc Singer + + * src/mach-lh7952x/timer-lh79520.c (lh79520_timer_init): Fixed the + initialization of the boot loader timer. + + * src/mach-lh7952x/lpd79520_config (CONFIG_NOR_BANK0_START): Fixed + the starting address of the NOR flash so that the REMAP register + doesn't make a difference. + + * src/apex/cmd-boot.c: Making sure that the ATAG pointer is valid. + +2005-03-15 Marc Singer + + * src/arch-arm/entry/apex.lds.S: Added new START identifier for + the sake of the memory scan function. + + * src/drivers/drv-mem.c (memory_scan): The memory scan function + needed to make sure not to write to BSS. It now avoids the entire + memory image of APEX. + +2005-03-10 Marc Singer + + * src/mach-lh7a40x/initialize.c: SDRAM initialization was + completely broken since 1.1.0. It works again. + + * src/drivers/drv-cf.c: Moved Compact Flash code to live among + generic drivers. Implemented CF for the 79520's. Wrote code for + the 7a40x's, but it isn't working. + + * src/drivers/drv-ext2.c (ext2_path_to_inode): Fixed dumb error in + the symlink traversal code. + + * src/drivers/drv-nor-cfi.c: Improved TALK for troubleshooting + flash. + +2005-03-09 Marc Singer + + * src/drivers/drv-nor-cfi.c: Moved the cfi driver into the generic + driver directory. There is a machine specific header to handle + the target controlled constants. + + * Makefile (ENV_CROSS_COMPILE): Fixed the selection of the cross + compiler so that the environment will override the configured + value. + +2005-03-07 Marc Singer + + * src/drivers/drv-ext2.c: ext2 driver is working. It supports + paths and following symlinks. + + * scripts/envmagic: Grooming. Properly fixed. + + * src/mach-ixp42x/serial.c (ixp42x_serial_write): Waiting for all + data to write before returning. + + * src/mach-ixp42x/cmd-reset.c (cmd_reset): Resetting services + before reset so that the nor flash has a chance to enter + array-read mode. + + * src/mach-lh7952x/cmd-reset.c (cmd_reset): Resetting services + before reset so that the nor flash has a chance to enter + array-read mode. + + * src/mach-lh7952x/drv-nor-cfi.c (nor_release): Release function + added so that cmd-reset will reliably perform. + + * src/drivers/drv-fat.c (fat_find): Fat filename comparisions are + not case insensitive without requiring the descriptor parser to + lower-case the path elements. + +2005-03-06 Marc Singer + + * src/drivers/drv-ext2.c: A rudimentary ext2 driver is + implemented. It has not received much testing. + + * src/apex/command.c (call_command): Added strings to error + reporting when not CONFIG_SMALL and a string has not yet been set. + +2005-03-04 Marc Singer + + * scripts/envmagic: Removed undesirable paths from the find. + +2005-03-03 Marc Singer + + * src/lib/png.c (read_png_row): Decoder working properly with the + logo and with cc. + + * src/lib/zlib.c: Fixed the zlib declarations s.t. there is no + initialized, mutable data. + + * src/lib/png.c: Added png interpreter for the sake of splash + screen images. + + * src/lib/zlib.c: Added zlib decompressor. Modified code to + comply with data section standards of APEX. + +2005-02-24 Marc Singer + + * src/mach-ixp42x/initialize.c: detection of the chip size from + the config parameters. All fat slugs should be simple settings in + the config. + +2005-02-23 Marc Singer + + * src/mach-lh7952x/drv-emac.c, src/apex/cmd-copy.c: Work-around + for gcc-2.95 preprocessor bug. + +2005-02-22 Marc Singer + + * src/drivers/drv-fat.c (fat_open): Typo prevented reading from + any partition other than 1. + + * src/drivers/drv-mem.c (memory_init): Reorganized the + configuration of SDRAM s.t. it is cleaner in the configuration + file and controlled by a mach- specific header. This make it + easier to make sure the initialization is correct. + +2005-02-21 Marc Singer + + * Makefile (SUBLEVEL): rolled to 1.1.0 for release with + Milestone2. Yipee! + + * src/mach-lh7952x/drv-emac.c: Cleanup of the driver. Better + control over compile options. Added help and report features. + +2005-02-20 Marc Singer + + * Makefile Revision in preparation for milestone2 release. + + * src/mach-lh7952x/drv-nor-cfi.c (NOR_1_LENGTH): added logic + necessary to support the double bank of NOR flash on the LPD79524 + boards. + (nor_init_chip): Changed initialization to properly cope with two + banks (or a pair of identical chips). + +2005-02-19 Marc Singer + + * src/arch-arm/lib/lib1funcs.S: Imported this file from kernel in + order to get general purpose integer divide and modulo functions. + +2005-02-18 Marc Singer + + * src/mach-lh7952x/init-lpd79520.c: Fixed SDRAM init to comply + with Sharp recommendations in their SDRAM application note. + Thanks to prplague :-). + +2005-02-17 Marc Singer + + * src/arch-arm/lib/relocate.c: Implemented a simpler + copy loop to help some platforms along. + +2005-02-16 Marc Singer + + * src/mach-ixp42x/nslu2_config (CONFIG_ENV_REGION): Changed the + environment region for the nslu2 so that it can be written without + clobbering the second redboot block. + + * src/apex/cmd-copy.c (cmd_copy): Added a -v switch to copy which + performs a double read of the source and a read after write of the + destination to make sure the copy is correct. + + * src/mach-ixp42x/initialize.c (__section): Added DEBUG_LL + support. + + * src/apex/cmd-compare.c (cmd_compare): Added -c switch to compare + so we can see more than one difference in a block. + +2005-02-15 Marc Singer + + * src/mach-lh7952x/serial.c Errors in the UART macros prevented + serial output on the 79520. + +2005-02-14 Marc Singer + + * Makefile 1.0.25: for good measure + +2005-02-12 Marc Singer + + * Makefile 1.0.24 for debug_ll changes + +2005-02-12 Marc Singer + + * Makefile: Moved the compiler declarations to the config files. + + * include/debug_ll.h: Added low-level debug support via the serial + console. + +2005-02-11 Marc Singer + + * src/lib/spinner.c (spinner_step): Smoothed out the spinner. + +2005-02-11 Marc Singer + + * Makefile 1.0.23 for the nslu2 spinner. + +2005-02-11 Marc Singer + + * src/mach-ixp42x/spinner-nslu2.c (nslu2_spinner): Implemented a + spinner for the platform. It uses the LEDs to show progress. + + * Makefile: 1.0.22 for NSLU2 updates. + + * src/mach-ixp42x/nslu2.h: Adding header specific to this target. + + * src/mach-ixp42x/initialize.c (initialize_bootstrap): + Initializing the GPIO lines. Adding more LED changes. + + * src/mach-ixp42x/nslu2_config (CONFIG_SPINNER): Adding + configuration options for more. + +2005-02-10 Marc Singer + + * include/attributes.h (__attribute__): Builds with 2.95.3. Not + yet tested. + +2005-01-26 Marc Singer + + * src/mach-lh7952x/adc.c (cmd_adc): Basic adc code working. + + * src/apex/console-printf.c (printf): Automatic insertion of + carriage-returns before newlines. + +2005-01-21 Marc Singer + + * src/mach-lh7952x/drv-nor-cfi.c (nor_report): Added report + function to nor driver. + + * src/mach-lh7a40x/drv-nor.c (nor_report): Added report funtion to + nor driver. + +2005-01-13 Marc Singer + + * src/apex/cmd-version.c (cmd_version): Rewording signon. + + * src/mach-lh7952x/Makefile (obj-$(CONFIG_MACH_LPD79524)): Moved + adc to 79524 specific build. + + * scripts/configtoh: Fixed the script to properly elide comments. + +2005-01-12 Marc Singer + + * README_config: Editing the documentation. + + * Makefile (include/config.h): Fixed the script that generates the + configuration file. + (tidy): New target to remove debris. + +2004-12-05 Marc Singer + + * src/lib/env.c (_env_check_magic): Magic number inserted at the + start of the environment to protect user from bogus data. + + * src/mach-lh7a40x/drv-nor.c (nor_write): LPD7A40X targets + completely supported though buffered writes to NOR flash not yet + implemented. + +2004-12-01 Marc Singer + + * README: New README(s) in preparation to release the source. + +2004-11-17 Marc Singer + + * src/mach-lh7952x/drv-nor.c (nor_write): Fixed a buglet in + buffered writes where the size of the write was incorrect in some + edge cases. + + * src/mach-lh7952x/drv-cpld-spi.c: Added cpld-spi drivers for + configuration EEPROM and for the MAC EEPROM. + + * src/mach-lh7952x/drv-emac.c (emac_read_mac): Fixed the EEPROM + code. + (cmd_emac): Removed eeprom specifics into another driver. + + * src/lib/dump.c (dump): Correct bug offset to rgb. + +2004-11-16 Marc Singer + + * src/mach-lh7952x/drv-emac.c (cmd_emac): Ethernet MAC maintenance + function as well as interface initialization. + + * src/lib/dump.c (dump): Factored the dump code into a library + function. + +2004-11-15 Marc Singer + + * src/mach-lh7952x/drv-nor.c (nor_write): Implementing buffered + write. It's about 16 times as fast. Will leave other code for + the time being since it is smaller by about 260 bytes. + + * First release, 1.0. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2380995 --- /dev/null +++ b/Makefile @@ -0,0 +1,1652 @@ +# APEX top-level Makefile +# based on Linux Kernel Makefile 2.6.26-rc8 + +VERSION = 1 +PATCHLEVEL = 6 +SUBLEVEL = 8 +#EXTRAVERSION = -$(shell date "+%j.%R:%S") +ARCH ?= arm + +BUILDDATE = $(shell date "+%Y.%b.%d-%R:%S") +export BUILDDATE + +# Preserve environment for the cross-compiler +ENV_CROSS_COMPILE:=$(CROSS_COMPILE) + +# *DOCUMENTATION* +# To see a list of typical targets execute "make help" +# More info can be located in ./README +# Comments in this file are targeted only to the developer, do not +# expect to learn how to build the kernel reading this file. + +# Do not: +# o use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour); +# o print "Entering directory ..."; +MAKEFLAGS += -rR --no-print-directory + +# We are using a recursive build, so we need to do a little thinking +# to get the ordering right. +# +# Most importantly: sub-Makefiles should only ever modify files in +# their own directory. If in some directory we have a dependency on +# a file in another dir (which doesn't happen often, but it's often +# unavoidable when linking the built-in.o targets which finally +# turn into apex), we will call a sub make in that other dir, and +# after that we are sure that everything which is in that other dir +# is now up to date. +# +# The only cases where we need to modify files which have global +# effects are thus separated out and done before the recursive +# descending is started. They are now explicitly listed as the +# prepare rule. + +# To put more focus on warnings, be less verbose as default +# Use 'make V=1' to see the full commands + +ifdef V + ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE = $(V) + endif +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 +endif + +# Call a source code checker (by default, "sparse") as part of the +# C compilation. +# +# Use 'make C=1' to enable checking of only re-compiled files. +# Use 'make C=2' to enable checking of *all* source files, regardless +# of whether they are re-compiled or not. +# +# See the file "Documentation/sparse.txt" for more details, including +# where to get the "sparse" utility. + +ifdef C + ifeq ("$(origin C)", "command line") + KBUILD_CHECKSRC = $(C) + endif +endif +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC = 0 +endif + +# Use make M=dir to specify directory of external module to build +# Old syntax make ... SUBDIRS=$PWD is still supported +# Setting the environment variable KBUILD_EXTMOD take precedence +ifdef SUBDIRS + KBUILD_EXTMOD ?= $(SUBDIRS) +endif +ifdef M + ifeq ("$(origin M)", "command line") + KBUILD_EXTMOD := $(M) + endif +endif + + +# kbuild supports saving output files in a separate directory. +# To locate output files in a separate directory two syntaxes are supported. +# In both cases the working directory must be the root of the kernel src. +# 1) O= +# Use "make O=dir/to/store/output/files/" +# +# 2) Set KBUILD_OUTPUT +# Set the environment variable KBUILD_OUTPUT to point to the directory +# where the output files shall be placed. +# export KBUILD_OUTPUT=dir/to/store/output/files/ +# make +# +# The O= assignment takes precedence over the KBUILD_OUTPUT environment +# variable. + + +# KBUILD_SRC is set on invocation of make in OBJ directory +# KBUILD_SRC is not intended to be used by the regular user (for now) +ifeq ($(KBUILD_SRC),) + +# OK, Make called in directory where kernel src resides +# Do we want to locate output files in a separate directory? +ifdef O + ifeq ("$(origin O)", "command line") + KBUILD_OUTPUT := $(O) + endif +endif + +# That's our default target when none is given on the command line +PHONY := _all +_all: + +# Cancel implicit rules on top Makefile +$(CURDIR)/Makefile Makefile: ; + +ifneq ($(KBUILD_OUTPUT),) +# Invoke a second make in the output directory, passing relevant variables +# check that the output directory actually exists +saved-output := $(KBUILD_OUTPUT) +KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) +$(if $(KBUILD_OUTPUT),, \ + $(error output directory "$(saved-output)" does not exist)) + +PHONY += $(MAKECMDGOALS) sub-make + +$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make + $(Q)@: + +sub-make: FORCE + $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ + KBUILD_SRC=$(CURDIR) \ + KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ + $(filter-out _all sub-make,$(MAKECMDGOALS)) + +# Leave processing to above invocation of make +skip-makefile := 1 +endif # ifneq ($(KBUILD_OUTPUT),) +endif # ifeq ($(KBUILD_SRC),) + +# We process the rest of the Makefile if this is the final invocation of make +ifeq ($(skip-makefile),) + +# If building an external module we do not care about the all: rule +# but instead _all depend on modules +PHONY += all +ifeq ($(KBUILD_EXTMOD),) +_all: all +else +_all: modules +endif + +srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) +TOPDIR := $(srctree) +# FIXME - TOPDIR is obsolete, use srctree/objtree +objtree := $(CURDIR) +src := $(srctree) +obj := $(objtree) + +VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) + +export srctree objtree VPATH TOPDIR + + +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh.*/sh/ ) + +# Cross compiling and selecting different set of gcc/bin-utils +# --------------------------------------------------------------------------- +# +# When performing cross compilation for other architectures ARCH shall be set +# to the target architecture. (See arch/* for the possibilities). +# ARCH can be set during invocation of make: +# make ARCH=ia64 +# Another way is to have ARCH set in the environment. +# The default ARCH is the host where make is executed. + +# CROSS_COMPILE specify the prefix used for all executables used +# during compilation. Only gcc and related bin-utils executables +# are prefixed with $(CROSS_COMPILE). +# CROSS_COMPILE can be set on the command line +# make CROSS_COMPILE=ia64-linux- +# Alternatively CROSS_COMPILE can be set in the environment. +# Default value for CROSS_COMPILE is not to prefix executables +# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile +export KBUILD_BUILDHOST := $(SUBARCH) +ARCH ?= $(SUBARCH) +# *** elf: removed +#CROSS_COMPILE ?= + +# Architecture as present in compile.h +UTS_MACHINE := $(ARCH) +SRCARCH := $(ARCH) + +# Additional ARCH settings for x86 +ifeq ($(ARCH),i386) + SRCARCH := x86 +endif +ifeq ($(ARCH),x86_64) + SRCARCH := x86 +endif + +KCONFIG_CONFIG ?= .config + +# SHELL used by kbuild +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) + +HOSTCC = gcc +HOSTCXX = g++ +HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer +HOSTCXXFLAGS = -O2 + +# Decide whether to build built-in, modular, or both. +# Normally, just do built-in. + +KBUILD_MODULES := +KBUILD_BUILTIN := 1 + +# If we have only "make modules", don't compile built-in objects. +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are up to date before we record them. + +ifeq ($(MAKECMDGOALS),modules) + KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) +endif + +# If we have "make modules", compile modules +# in addition to whatever we do anyway. +# Just "make" or "make all" shall build modules as well + +ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) + KBUILD_MODULES := 1 +endif + +ifeq ($(MAKECMDGOALS),) + KBUILD_MODULES := 1 +endif + +export KBUILD_MODULES KBUILD_BUILTIN +export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD + +# Beautify output +# --------------------------------------------------------------------------- +# +# Normally, we echo the whole command before executing it. By making +# that echo $($(quiet)$(cmd)), we now have the possibility to set +# $(quiet) to choose other forms of output instead, e.g. +# +# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ +# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +# +# If $(quiet) is empty, the whole command will be printed. +# If it is set to "quiet_", only the short version will be printed. +# If it is set to "silent_", nothing will be printed at all, since +# the variable $(silent_cmd_cc_o_c) doesn't exist. +# +# A simple variant is to prefix commands with $(Q) - that's useful +# for commands that shall be hidden in non-verbose mode. +# +# $(Q)ln $@ :< +# +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. +# If KBUILD_VERBOSE equals 1 then the above command is displayed. + +ifeq ($(KBUILD_VERBOSE),1) + quiet = + Q = +else + quiet=quiet_ + Q = @ +endif + +# If the user is running make -s (silent mode), suppress echoing of +# commands + +ifneq ($(findstring s,$(MAKEFLAGS)),) + quiet=silent_ +endif + +export quiet Q KBUILD_VERBOSE + + +# Look for make include files relative to root of kernel src +MAKEFLAGS += --include-dir=$(srctree) + +# We need some generic definitions (do not try to remake the file). +$(srctree)/scripts/Kbuild.include: ; +include $(srctree)/scripts/Kbuild.include + +# Make variables (CC, etc...) + +AS = $(CROSS_COMPILE_)as +LD = $(CROSS_COMPILE_)ld +CC = $(CROSS_COMPILE_)gcc +CPP = $(CC) -E +AR = $(CROSS_COMPILE_)ar +NM = $(CROSS_COMPILE_)nm +STRIP = $(CROSS_COMPILE_)strip +OBJCOPY = $(CROSS_COMPILE_)objcopy +OBJDUMP = $(CROSS_COMPILE_)objdump +AWK = awk +GENKSYMS = scripts/genksyms/genksyms +DEPMOD = /sbin/depmod +KALLSYMS = scripts/kallsyms +PERL = perl +CHECK = sparse + +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF) +MODFLAGS = -DMODULE +CFLAGS_MODULE = $(MODFLAGS) +AFLAGS_MODULE = $(MODFLAGS) +LDFLAGS_MODULE = +CFLAGS_KERNEL = +AFLAGS_KERNEL = + + +# Use LINUXINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O= option +LINUXINCLUDE := -Iinclude \ + $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ + -include include/linux/autoconf.h + +KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) + +KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration \ + -fno-builtin-printf +KBUILD_AFLAGS := -D__ASSEMBLY__ + +# Read KERNELRELEASE from include/config/kernel.release (if it exists) +#KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +#KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) +APEXVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + +export VERSION PATCHLEVEL SUBLEVEL APEXVERSION +export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC +export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE +export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS + +export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS +export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE +export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE + +# When compiling out-of-tree modules, put MODVERDIR in the module +# tree rather than in the kernel tree. The kernel tree might +# even be read-only. +export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions + +# Files to ignore in find ... statements + +RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o +export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git + +# =========================================================================== +# Rules shared between *config targets and build targets + +# Basic helpers built in scripts/ +PHONY += scripts_basic +scripts_basic: + $(Q)$(MAKE) $(build)=scripts/basic + +# To avoid any implicit rule to kick in, define an empty command. +scripts/basic/%: scripts_basic ; + +PHONY += outputmakefile +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +outputmakefile: +ifneq ($(KBUILD_SRC),) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ + $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) +endif + +# To make sure we do not include .config for any of the *config targets +# catch them early, and hand them over to scripts/kconfig/Makefile +# It is allowed to specify more targets when calling make, including +# mixing *config targets and build targets. +# For example 'make oldconfig all'. +# Detect when mixed targets is specified, and make a second invocation +# of make so .config is not included in this case either (for *config). + +no-dot-config-targets := clean mrproper distclean \ + cscope TAGS tags help %docs check% \ + include/linux/version.h headers_% \ + kernelrelease kernelversion +no-dot-config-targets += tgz every update-every complete-release tgz + +config-targets := 0 +mixed-targets := 0 +dot-config := 1 + +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) + dot-config := 0 + endif +endif + +ifeq ($(KBUILD_EXTMOD),) + ifneq ($(filter config %config,$(MAKECMDGOALS)),) + config-targets := 1 + ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) + mixed-targets := 1 + endif + endif +endif + +ifeq ($(mixed-targets),1) +# =========================================================================== +# We're called with mixed targets (*config and build targets). +# Handle them one by one. + +%:: FORCE + $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ + +else +ifeq ($(config-targets),1) +# =========================================================================== +# *config targets only - make sure prerequisites are updated, and descend +# in scripts/kconfig to make the *config target + +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration +# used for 'make defconfig' +include $(srctree)/src/arch-$(SRCARCH)/Makefile +export KBUILD_DEFCONFIG + +config %config: scripts_basic outputmakefile FORCE + $(Q)mkdir -p include/linux include/config + $(Q)$(MAKE) $(build)=scripts/kconfig $@ + +else +# =========================================================================== +# Build targets only - this includes apex, arch specific targets, clean +# targets and others. In general all targets except *config targets. + +ifeq ($(KBUILD_EXTMOD),) +# Additional helpers built in scripts/ +# Carefully list dependencies so we do not try to build scripts twice +# in parallel +PHONY += scripts +scripts: scripts_basic include/config/auto.conf + $(Q)$(MAKE) $(build)=$(@) + +# Objects we will link into apex / subdirs we need to visit +init-y := # init/ +drivers-y := # drivers/ sound/ +net-y := # net/ +libs-y := src/lib/ +core-y := # usr/ +endif # KBUILD_EXTMOD + +ifeq ($(dot-config),1) +# Read in config +-include include/config/auto.conf + +# *** We need to do some extra work to get the CROSS_COMPILE macro +# *** from our configuration file while allowing for command line or +# *** environment overrides. + +ifeq ($(CROSS_COMPILE_),) + CROSS_COMPILE_=$(ENV_CROSS_COMPILE) +endif + +ifeq ($(CROSS_COMPILE_),) + CROSS_COMPILE_=$(CROSS_COMPILE) +endif + +dquote:=" +# " + +ifeq ($(CROSS_COMPILE_),) + CROSS_COMPILE_=$(subst $(dquote),,$(CONFIG_CROSS_COMPILE)) +endif + + +ifeq ($(KBUILD_EXTMOD),) +# Read in dependencies to all Kconfig* files, make sure to run +# oldconfig if changes are detected. +-include include/config/auto.conf.cmd + +# To avoid any implicit rule to kick in, define an empty command +$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; + +# If .config is newer than include/config/auto.conf, someone tinkered +# with it and forgot to run make oldconfig. +# if auto.conf.cmd is missing then we are probably in a cleaned tree so +# we execute the config step to be sure to catch updated Kconfig files +include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd + $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig +else +# external modules needs include/linux/autoconf.h and include/config/auto.conf +# but do not care if they are up-to-date. Use auto.conf to trigger the test +PHONY += include/config/auto.conf + +include/config/auto.conf: + $(Q)test -e include/linux/autoconf.h -a -e $@ || ( \ + echo; \ + echo " ERROR: Kernel configuration is invalid."; \ + echo " include/linux/autoconf.h or $@ are missing."; \ + echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ + echo; \ + /bin/false) + +endif # KBUILD_EXTMOD + +else +# Dummy target needed, because used as prerequisite +include/config/auto.conf: ; +endif # $(dot-config) + +# The all: target is the default when no target is given on the +# command line. +# This allow a user to issue only 'make' to build a kernel including modules +# Defaults apex but it is usually overridden in the arch makefile +#all: apex +all: apex apex.bin + +ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE +KBUILD_CFLAGS += -Os +else +KBUILD_CFLAGS += -O2 +endif + +ifneq (CONFIG_FRAME_WARN,0) +KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) +endif + +# Force gcc to behave correct even for buggy distributions +# Arch Makefiles may override this setting +KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) + +include $(srctree)/src/arch-$(SRCARCH)/Makefile + +ifdef CONFIG_FRAME_POINTER +KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else +KBUILD_CFLAGS += -fomit-frame-pointer +endif + +#ifdef CONFIG_DEBUG_INFO +KBUILD_CFLAGS += -g +KBUILD_AFLAGS += -gdwarf-2 +#endif + +# We trigger additional mismatches with less inlining +ifdef CONFIG_DEBUG_SECTION_MISMATCH +KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) +endif + +# arch Makefile may override CC so keep this after arch Makefile is included +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +CHECKFLAGS += $(NOSTDINC_FLAGS) + +# warn about C99 declaration after statement +KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) + +# disable pointer signed / unsigned warnings in gcc 4.0 +KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,) + +# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments +# But warn user when we do so +warn-assign = \ +$(warning "WARNING: Appending $$K$(1) ($(K$(1))) from $(origin K$(1)) to kernel $$$(1)") + +ifneq ($(KCPPFLAGS),) + $(call warn-assign,CPPFLAGS) + KBUILD_CPPFLAGS += $(KCPPFLAGS) +endif +ifneq ($(KAFLAGS),) + $(call warn-assign,AFLAGS) + KBUILD_AFLAGS += $(KAFLAGS) +endif +ifneq ($(KCFLAGS),) + $(call warn-assign,CFLAGS) + KBUILD_CFLAGS += $(KCFLAGS) +endif + +# Use --build-id when available. +LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ + $(call ld-option, -Wl$(comma)--build-id,)) +LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) +LDFLAGS_APEX += $(LDFLAGS_BUILD_ID) + +# Default kernel image to build when no specific target is given. +# KBUILD_IMAGE may be overruled on the command line or +# set in the environment +# Also any assignments in src/arch-$(ARCH)/Makefile take precedence over +# this default value +export KBUILD_IMAGE ?= apex + +# +# INSTALL_PATH specifies where to place the updated kernel and system map +# images. Default is /boot, but you can set it to other values +export INSTALL_PATH ?= /boot + +# +# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory +# relocations required by build roots. This is not defined in the +# makefile but the argument can be passed to make if needed. +# + +MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) +export MODLIB + +# +# INSTALL_MOD_STRIP, if defined, will cause modules to be +# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then +# the default option --strip-debug will be used. Otherwise, +# INSTALL_MOD_STRIP will used as the options to the strip command. + +ifdef INSTALL_MOD_STRIP +ifeq ($(INSTALL_MOD_STRIP),1) +mod_strip_cmd = $(STRIP) --strip-debug +else +mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) +endif # INSTALL_MOD_STRIP=1 +else +mod_strip_cmd = true +endif # INSTALL_MOD_STRIP +export mod_strip_cmd + + +ifeq ($(KBUILD_EXTMOD),) +core-y += src/apex/ # kernel/ mm/ fs/ ipc/ security/ crypto/ block/ + +apex-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ + $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ + $(net-y) $(net-m) $(libs-y) $(libs-m))) + +apex-alldirs := $(sort $(apex-dirs) $(patsubst %/,%,$(filter %/, \ + $(init-n) $(init-) \ + $(core-n) $(core-) $(drivers-n) $(drivers-) \ + $(net-n) $(net-) $(libs-n) $(libs-)))) + +init-y := $(patsubst %/, %/built-in.o, $(init-y)) +core-y := $(patsubst %/, %/built-in.o, $(core-y)) +drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) +net-y := $(patsubst %/, %/built-in.o, $(net-y)) +libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) +libs-y := $(libs-y1) $(libs-y2) + +# Build apex +# --------------------------------------------------------------------------- +# apex is built from the objects selected by $(apex-init) and +# $(apex-main). Most are built-in.o files from top-level directories +# in the kernel tree, others are specified in src/arch-$(ARCH)/Makefile. +# Ordering when linking is important, and $(apex-init) must be first. +# +# apex +# ^ +# | +# +-< $(apex-init) +# | +--< init/version.o + more +# | +# +--< $(apex-main) +# | +--< driver/built-in.o mm/built-in.o + more +# | +# +-< kallsyms.o (see description in CONFIG_KALLSYMS section) +# +# apex version (uname -v) cannot be updated during normal +# descending-into-subdirs phase since we do not yet know if we need to +# update apex. +# Therefore this step is delayed until just before final link of apex - +# except in the kallsyms case where it is done just before adding the +# symbols to the kernel. +# +# System.map is generated to document addresses of all kernel symbols + +apex-init := $(head-y) $(init-y) +apex-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) +apex-all := $(apex-init) $(apex-main) +apex-lds := src/arch-$(SRCARCH)/entry/apex.lds +export KBUILD_APEX_OBJS := $(apex-all) + +# Rule to link apex - also used during CONFIG_KALLSYMS +# May be overridden by src/arch-$(ARCH)/Makefile +quiet_cmd_apex__ ?= LD $@ + cmd_apex__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_apex) -o $@ \ + -T $(apex-lds) $(apex-init) \ + --start-group $(apex-main) --end-group \ + $(filter-out $(apex-lds) $(apex-init) $(apex-main) apex.o FORCE ,$^) + +# # Generate new apex version +# quiet_cmd_apex_version = GEN .version +# cmd_apex_version = set -e; \ +# if [ ! -r .version ]; then \ +# rm -f .version; \ +# echo 1 >.version; \ +# else \ +# mv .version .old_version; \ +# expr 0$$(cat .old_version) + 1 >.version; \ +# fi; \ +# $(MAKE) $(build)=init + +# Generate System.map +quiet_cmd_sysmap = SYSMAP + cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap + +# Link of apex +# If CONFIG_KALLSYMS is set .version is already updated +# Generate System.map and verify that the content is consistent +# Use + in front of the apex_version rule to silent warning with make -j2 +# First command is ':' to allow us to use + in front of the rule +define rule_apex__ + : + $(if $(CONFIG_KALLSYMS),,+$(call cmd,apex_version)) + + $(call cmd,apex__) + $(Q)echo 'cmd_$@ := $(cmd_apex__)' > $(@D)/.$(@F).cmd + + $(Q)$(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap) System.map' &&) \ + $(cmd_sysmap) $@ System.map; \ + if [ $$? -ne 0 ]; then \ + rm -f $@; \ + /bin/false; \ + fi; + $(verify_kallsyms) +endef + + +ifdef CONFIG_KALLSYMS +# Generate section listing all symbols and add it into apex $(kallsyms.o) +# It's a three stage process: +# o .tmp_apex1 has all symbols and sections, but __kallsyms is +# empty +# Running kallsyms on that gives us .tmp_kallsyms1.o with +# the right size - apex version (uname -v) is updated during this step +# o .tmp_apex2 now has a __kallsyms section of the right size, +# but due to the added section, some addresses have shifted. +# From here, we generate a correct .tmp_kallsyms2.o +# o The correct .tmp_kallsyms2.o is linked into the final apex. +# o Verify that the System.map from apex matches the map from +# .tmp_apex2, just in case we did not generate kallsyms correctly. +# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using +# .tmp_apex3 and .tmp_kallsyms3.o. This is only meant as a +# temporary bypass to allow the kernel to be built while the +# maintainers work out what went wrong with kallsyms. + +ifdef CONFIG_KALLSYMS_EXTRA_PASS +last_kallsyms := 3 +else +last_kallsyms := 2 +endif + +kallsyms.o := .tmp_kallsyms$(last_kallsyms).o + +define verify_kallsyms + $(Q)$(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \ + $(cmd_sysmap) .tmp_apex$(last_kallsyms) .tmp_System.map + $(Q)cmp -s System.map .tmp_System.map || \ + (echo Inconsistent kallsyms data; \ + echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \ + rm .tmp_kallsyms* ; /bin/false ) +endef + +# Update apex version before link +# Use + in front of this rule to silent warning about make -j1 +# First command is ':' to allow us to use + in front of this rule +cmd_ksym_ld = $(cmd_apex__) +define rule_ksym_ld + : + +$(call cmd,apex_version) + $(call cmd,apex__) + $(Q)echo 'cmd_$@ := $(cmd_apex__)' > $(@D)/.$(@F).cmd +endef + +# Generate .S file with all kernel symbols +quiet_cmd_kallsyms = KSYM $@ + cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \ + $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@ + +.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE + $(call if_changed_dep,as_o_S) + +.tmp_kallsyms%.S: .tmp_apex% $(KALLSYMS) + $(call cmd,kallsyms) + +# .tmp_apex1 must be complete except kallsyms, so update apex version +.tmp_apex1: $(apex-lds) $(apex-all) FORCE + $(call if_changed_rule,ksym_ld) + +.tmp_apex2: $(apex-lds) $(apex-all) .tmp_kallsyms1.o FORCE + $(call if_changed,apex__) + +.tmp_apex3: $(apex-lds) $(apex-all) .tmp_kallsyms2.o FORCE + $(call if_changed,apex__) + +# Needs to visit scripts/ before $(KALLSYMS) can be used. +$(KALLSYMS): scripts ; + +# Generate some data for debugging strange kallsyms problems +debug_kallsyms: .tmp_map$(last_kallsyms) + +.tmp_map%: .tmp_apex% FORCE + ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@ + +.tmp_map3: .tmp_map2 + +.tmp_map2: .tmp_map1 + +endif # ifdef CONFIG_KALLSYMS + +# Do modpost on a prelinked apex. The finally linked apex has +# relevant sections renamed as per the linker script. +quiet_cmd_apex-modpost = LD $@ + cmd_apex-modpost = $(LD) $(LDFLAGS) -r -o $@ \ + $(apex-init) --start-group $(apex-main) --end-group \ + $(filter-out $(apex-init) $(apex-main) FORCE ,$^) +define rule_apex-modpost + : + +$(call cmd,apex-modpost) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@ + $(Q)echo 'cmd_$@ := $(cmd_apex-modpost)' > $(dot-target).cmd +endef + +# apex image - including updated kernel symbols +apex: $(apex-lds) $(apex-init) $(apex-main) $(kallsyms.o) FORCE +ifdef CONFIG_HEADERS_CHECK + $(Q)$(MAKE) -f $(srctree)/Makefile headers_check +endif +ifdef CONFIG_SAMPLES + $(Q)$(MAKE) $(build)=samples +endif + $(call apex-modpost) + $(call if_changed_rule,apex__) + $(Q)rm -f .old_version + +# build apex.o first to catch section mismatch errors early +ifdef CONFIG_KALLSYMS +.tmp_apex1: apex.o +endif + +modpost-init := $(filter-out init/built-in.o, $(apex-init)) +apex.o: $(modpost-init) $(apex-main) FORCE + $(call if_changed_rule,apex-modpost) + +# The actual objects are generated when descending, +# make sure no implicit rule kicks in +$(sort $(apex-init) $(apex-main)) $(apex-lds): $(apex-dirs) ; + +# Handle descending into subdirectories listed in $(apex-dirs) +# Preset locale variables to speed up the build process. Limit locale +# tweaks to this spot to avoid wrong language settings when running +# make menuconfig etc. +# Error messages still appears in the original language + +PHONY += $(apex-dirs) +$(apex-dirs): prepare scripts + $(Q)$(MAKE) $(build)=$@ + +# Build the kernel release string +# +# The KERNELRELEASE value built here is stored in the file +# include/config/kernel.release, and is used when executing several +# make targets, such as "make install" or "make modules_install." +# +# The eventual kernel release string consists of the following fields, +# shown in a hierarchical format to show how smaller parts are concatenated +# to form the larger and final value, with values coming from places like +# the Makefile, kernel config options, make command line options and/or +# SCM tag information. +# +# $(KERNELVERSION) +# $(VERSION) eg, 2 +# $(PATCHLEVEL) eg, 6 +# $(SUBLEVEL) eg, 18 +# $(EXTRAVERSION) eg, -rc6 +# $(localver-full) +# $(localver) +# localversion* (files without backups, containing '~') +# $(CONFIG_LOCALVERSION) (from kernel config setting) +# $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set) +# ./scripts/setlocalversion (SCM tag, if one exists) +# $(LOCALVERSION) (from make command line if provided) +# +# Note how the final $(localver-auto) string is included *only* if the +# kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the +# moment, only git is supported but other SCMs can edit the script +# scripts/setlocalversion and add the appropriate checks as needed. + +pattern = ".*/localversion[^~]*" +string = $(shell cat /dev/null \ + `find $(objtree) $(srctree) -maxdepth 1 -regex $(pattern) | sort -u`) + +localver = $(subst $(space),, $(string) \ + $(patsubst "%",%,$(CONFIG_LOCALVERSION))) + +# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called +# and if the SCM is know a tag from the SCM is appended. +# The appended tag is determined by the SCM used. +# +# Currently, only git is supported. +# Other SCMs can edit scripts/setlocalversion and add the appropriate +# checks as needed. +ifdef CONFIG_LOCALVERSION_AUTO + _localver-auto = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/setlocalversion $(srctree)) + localver-auto = $(LOCALVERSION)$(_localver-auto) +endif + +localver-full = $(localver)$(localver-auto) + +# Store (new) KERNELRELASE string in include/config/kernel.release +kernelrelease = $(KERNELVERSION)$(localver-full) +include/config/kernel.release: include/config/auto.conf FORCE + $(Q)rm -f $@ + $(Q)echo $(kernelrelease) > $@ + + +# Things we need to do before we recursively start building the kernel +# or the modules are listed in "prepare". +# A multi level approach is used. prepareN is processed before prepareN-1. +# archprepare is used in arch Makefiles and when processed asm symlink, +# version.h and scripts_basic is processed / created. + +# Listed in dependency order +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 + +# prepare3 is used to check if we are building in a separate output directory, +# and if so do: +# 1) Check that make has not been executed in the kernel src $(srctree) +# 2) Create the include2 directory, used for the second asm symlink +prepare3: include/config/kernel.release +ifneq ($(KBUILD_SRC),) + @echo ' Using $(srctree) as source for kernel' + $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ + echo " $(srctree) is not clean, please run 'make mrproper'";\ + echo " in the '$(srctree)' directory.";\ + /bin/false; \ + fi; + $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; + $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm +endif + +# prepare2 creates a makefile if using a separate output directory +prepare2: prepare3 outputmakefile + +prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \ + include/asm include/config/auto.conf \ + include/mach + $(cmd_crmodverdir) + +archprepare: prepare1 scripts_basic + +prepare0: archprepare FORCE + $(Q)$(MAKE) $(build)=. +# $(Q)$(MAKE) $(build)=. missing-syscalls + +# All the preparing.. +prepare: prepare0 + +# Leave this as default for preprocessing apex.lds.S, which is now +# done in src/arch-$(ARCH)/kernel/Makefile + +export CPPFLAGS_apex.lds += -P -C -U$(ARCH) + +# The asm symlink changes when $(ARCH) changes. +# Detect this and ask user to run make mrproper + +include/asm: FORCE + $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ + if [ -L include/asm ]; then \ + if [ "$$asmlink" != "$(SRCARCH)" ]; then \ + echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ + echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ + exit 1; \ + fi; \ + else \ + echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ + if [ ! -d include ]; then \ + mkdir -p include; \ + fi; \ + ln -fsn asm-$(SRCARCH) $@; \ + fi + +# Generate some files +# --------------------------------------------------------------------------- + +# KERNELRELEASE can change from a few different places, meaning version.h +# needs to be updated, so this check is forced on all builds + +uts_len := 64 +define filechk_utsrelease.h + if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ + echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ + exit 1; \ + fi; \ + (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";) +endef + +define filechk_version.h + (echo \#define LINUX_VERSION_CODE $(shell \ + expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) +endef + +include/linux/version.h: $(srctree)/Makefile FORCE + $(call filechk,version.h) + +include/linux/utsrelease.h: include/config/kernel.release FORCE + $(call filechk,utsrelease.h) + +# --------------------------------------------------------------------------- + +PHONY += depend dep +depend dep: + @echo '*** Warning: make $@ is unnecessary now.' + +# --------------------------------------------------------------------------- +# Kernel headers +INSTALL_HDR_PATH=$(objtree)/usr +export INSTALL_HDR_PATH + +HDRFILTER=generic i386 x86_64 +HDRARCHES=$(filter-out $(HDRFILTER),$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) + +PHONY += headers_install_all +headers_install_all: include/linux/version.h scripts_basic FORCE + $(Q)$(MAKE) $(build)=scripts scripts/unifdef + $(Q)for arch in $(HDRARCHES); do \ + $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch ;\ + done + +PHONY += headers_install +headers_install: include/linux/version.h scripts_basic FORCE + @if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ + echo '*** Error: Headers not exportable for this architecture ($(SRCARCH))'; \ + exit 1 ; fi + $(Q)$(MAKE) $(build)=scripts scripts/unifdef + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include + +PHONY += headers_check_all +headers_check_all: headers_install_all + $(Q)for arch in $(HDRARCHES); do \ + $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ + done + +PHONY += headers_check +headers_check: headers_install + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include HDRCHECK=1 + +# --------------------------------------------------------------------------- +# Modules + +ifdef CONFIG_MODULES + +# By default, build modules as well + +all: # modules + +# Build modules +# +# A module can be listed more than once in obj-m resulting in +# duplicate lines in modules.order files. Those are removed +# using awk while concatenating to the final file. + +PHONY += modules +modules: $(apex-dirs) $(if $(KBUILD_BUILTIN),apex) + $(Q)$(AWK) '!x[$$0]++' $(apex-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + + +# Target to prepare building external modules +PHONY += modules_prepare +modules_prepare: prepare scripts + +# Target to install modules +PHONY += modules_install +modules_install: _modinst_ _modinst_post + +PHONY += _modinst_ +_modinst_: + @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ + echo "Warning: you may need to install module-init-tools"; \ + echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\ + sleep 1; \ + fi + @rm -rf $(MODLIB)/kernel + @rm -f $(MODLIB)/source + @mkdir -p $(MODLIB)/kernel + @ln -s $(srctree) $(MODLIB)/source + @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ + rm -f $(MODLIB)/build ; \ + ln -s $(objtree) $(MODLIB)/build ; \ + fi + @cp -f $(objtree)/modules.order $(MODLIB)/ + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst + +# This depmod is only for convenience to give the initial +# boot a modules.dep even before / is mounted read-write. However the +# boot script depmod is the master version. +PHONY += _modinst_post +_modinst_post: _modinst_ + $(call cmd,depmod) + +else # CONFIG_MODULES + +# Modules not configured +# --------------------------------------------------------------------------- + +modules modules_install: FORCE + @echo + @echo "The present kernel configuration has modules disabled." + @echo "Type 'make config' and enable loadable module support." + @echo "Then build a kernel with module support enabled." + @echo + @exit 1 + +endif # CONFIG_MODULES + +### +# Cleaning is done on three levels. +# make clean Delete most generated files +# Leave enough to build external modules +# make mrproper Delete the current configuration, and all generated files +# make distclean Remove editor backup files, patch leftover files and the like + +# Directories & files removed with 'make clean' +CLEAN_DIRS += $(MODVERDIR) +CLEAN_FILES += apex System.map \ + .tmp_kallsyms* .tmp_version .tmp_apex* .tmp_System.map + +# Directories & files removed with 'make mrproper' +MRPROPER_DIRS += include/config include2 usr/include +MRPROPER_FILES += .config .config.old include/asm .version .old_version \ + include/linux/autoconf.h include/linux/version.h \ + include/linux/utsrelease.h \ + include/linux/bounds.h include/asm*/asm-offsets.h \ + Module.symvers tags TAGS cscope* +CLEAN_FILES += include/asm +CLEAN_FILES += include/mach + +# clean - Delete most, but leave enough to build external modules +# +clean: rm-dirs := $(CLEAN_DIRS) +clean: rm-files := $(CLEAN_FILES) +clean-dirs := $(addprefix _clean_,$(srctree) $(apex-alldirs)) + +PHONY += $(clean-dirs) clean archclean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: archclean $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find . $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ + -o -name '*.symtypes' -o -name 'modules.order' \) \ + -type f -print | xargs rm -f + +# mrproper - Delete all generated files, including .config +# +mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) +mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) +mrproper-dirs := $(addprefix _mrproper_,scripts) + +PHONY += $(mrproper-dirs) mrproper archmrproper +$(mrproper-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) + +mrproper: clean archmrproper $(mrproper-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + +# distclean +# +PHONY += distclean + +distclean: mrproper + @find $(srctree) $(RCS_FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -size 0 \ + -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ + -type f -print | xargs rm -f + + +# Packaging of the kernel to various formats +# --------------------------------------------------------------------------- +# rpm target kept for backward compatibility +package-dir := $(srctree)/scripts/package + +%pkg: FORCE + $(Q)$(MAKE) -f $(package-dir)/Makefile $@ +rpm: FORCE + $(Q)$(MAKE) -f $(package-dir)/Makefile $@ +#tgz: FORCE +# $(Q)$(MAKE) -f $(package-dir)/Makefile $@ + +# Brief documentation of the typical targets used +# --------------------------------------------------------------------------- + +boards := $(wildcard $(srctree)/src/mach-*/*_config) +boards := $(notdir $(boards)) +board-dirs := $(dir $(wildcard $(srctree)/src/mach-*/*_config)) +board-dirs := $(sort $(notdir $(board-dirs:/=))) + +help: + @echo 'Cleaning targets:' + @echo ' clean - Remove most generated files but keep the config and' + @echo ' enough build support to build external modules' + @echo ' mrproper - Remove all generated files + config + various backup files' + @echo ' distclean - mrproper + remove editor backup and patch files' + @echo '' + @echo 'Configuration targets:' + @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help + @echo '' + @echo 'Other generic targets:' + @echo ' all - Build all targets marked with [*]' + @echo '* apex - Build the bare kernel' + @echo '* modules - Build all modules' + @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' + @echo ' dir/ - Build all files in dir and below' + @echo ' dir/file.[ois] - Build specified target only' + @echo ' dir/file.ko - Build module including final link' + @echo ' prepare - Set up for building external modules' + @echo ' tags/TAGS - Generate tags file for editors' + @echo ' cscope - Generate cscope index' + @echo ' kernelrelease - Output the release version string' + @echo ' kernelversion - Output the version stored in Makefile' + @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ + echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ + echo ' (default: $(INSTALL_HDR_PATH))'; \ + fi + @echo '' + @echo 'Static analysers' + @echo ' checkstack - Generate a list of stack hogs' + @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' versioncheck - Sanity check on version.h usage' + @echo ' includecheck - Check for duplicate included header files' + @echo ' export_report - List the usages of all exported symbols' + @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ + echo ' headers_check - Sanity check on exported headers'; \ + fi + @echo '' + @echo 'Kernel packaging:' + @$(MAKE) $(build)=$(package-dir) help + @echo '' +# @echo 'Documentation targets:' +# @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp + @echo '' + @echo 'Architecture specific targets ($(SRCARCH)):' + @$(if $(archhelp),$(archhelp),\ + echo ' No architecture specific help defined for $(SRCARCH)') + @echo '' + @$(if $(boards), \ + $(foreach b, $(boards), \ + printf " %-32s - Build for %s\\n" $(b) $(subst _config,,$(b));) \ + echo '') + @$(if $(board-dirs), \ + $(foreach b, $(board-dirs), \ + printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ + printf " %-16s - Show all of the above\\n" help-boards; \ + echo '') + + @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' + @echo ' make V=2 [targets] 2 => give reason for rebuild of target' + @echo ' make O=dir [targets] Locate all output files in "dir", including .config' + @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' + @echo ' make C=2 [targets] Force check of all c source with $$CHECK' + @echo '' + @echo 'Execute "make" or "make all" to build all targets marked with [*] ' + @echo 'For further info see the ./README file' + + +help-board-dirs := $(addprefix help-,$(board-dirs)) + +help-boards: $(help-board-dirs) + +boards-per-dir = $(notdir $(wildcard $(srctree)/src/mach-*/*_config)) + +$(help-board-dirs): help-%: + @echo 'Architecture specific targets ($(SRCARCH) $*):' + @$(if $(boards-per-dir), \ + $(foreach b, $(boards-per-dir), \ + printf " %-24s - Build for %s\\n" $*/$(b) $(subst _config,,$(b));) \ + echo '') + + +# Documentation targets +# --------------------------------------------------------------------------- +%docs: scripts_basic FORCE +# $(Q)$(MAKE) $(build)=Documentation/DocBook $@ + +else # KBUILD_EXTMOD + +### +# External module support. +# When building external modules the kernel used as basis is considered +# read-only, and no consistency checks are made and the make +# system is not used on the basis kernel. If updates are required +# in the basis kernel ordinary make commands (without M=...) must +# be used. +# +# The following are the only valid targets when building external +# modules. +# make M=dir clean Delete all automatically generated files +# make M=dir modules Make all modules in specified dir +# make M=dir Same as 'make M=dir modules' +# make M=dir modules_install +# Install the modules built in the module directory +# Assumes install directory is already created + +# We are always building modules +KBUILD_MODULES := 1 +PHONY += crmodverdir +crmodverdir: + $(cmd_crmodverdir) + +PHONY += $(objtree)/Module.symvers +$(objtree)/Module.symvers: + @test -e $(objtree)/Module.symvers || ( \ + echo; \ + echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ + echo " is missing; modules will have no dependencies and modversions."; \ + echo ) + +module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) +PHONY += $(module-dirs) modules +$(module-dirs): crmodverdir $(objtree)/Module.symvers + $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) + +modules: $(module-dirs) + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +PHONY += modules_install +modules_install: _emodinst_ _emodinst_post + +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) +PHONY += _emodinst_ +_emodinst_: + $(Q)mkdir -p $(MODLIB)/$(install-dir) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst + +PHONY += _emodinst_post +_emodinst_post: _emodinst_ + $(call cmd,depmod) + +clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) + +PHONY += $(clean-dirs) clean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: rm-dirs := $(MODVERDIR) +clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers +clean: $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ + -type f -print | xargs rm -f + +help: + @echo ' Building external modules.' + @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' + @echo '' + @echo ' modules - default target, build the module(s)' + @echo ' modules_install - install the module' + @echo ' clean - remove generated files in module directory only' + @echo '' + +# Dummies... +PHONY += prepare scripts +prepare: ; +scripts: ; +endif # KBUILD_EXTMOD + +# Generate tags for editors +# --------------------------------------------------------------------------- + +#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set +#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file. +#Adding $(srctree) adds about 20M on i386 to the size of the output file! + +ifeq ($(src),$(obj)) +__srctree = +else +__srctree = $(srctree)/ +endif + +ifeq ($(ALLSOURCE_ARCHS),) +ifeq ($(ARCH),um) +ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH) +else +ALLINCLUDE_ARCHS := $(SRCARCH) +endif +else +#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour. +ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS) +endif + +ALLSOURCE_ARCHS := $(SRCARCH) + +define find-sources + ( for arch in $(ALLSOURCE_ARCHS) ; do \ + find $(__srctree)src/arch-$${arch} $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + done ; \ + find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + find $(__srctree)include $(RCS_FIND_IGNORE) \ + \( -name config -o -name 'asm-*' \) -prune \ + -o -name $1 -print; \ + for arch in $(ALLINCLUDE_ARCHS) ; do \ + find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + done ; \ + find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + find $(__srctree) $(RCS_FIND_IGNORE) \ + \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ + -name $1 -print; \ + ) +endef + +define all-sources + $(call find-sources,'*.[chS]') +endef +define all-kconfigs + $(call find-sources,'Kconfig*') +endef +define all-defconfigs + $(call find-sources,'defconfig') +endef + +define xtags + if $1 --version 2>&1 | grep -iq exuberant; then \ + $(all-sources) | xargs $1 -a \ + -I __initdata,__exitdata,__acquires,__releases \ + -I __read_mostly,____cacheline_aligned,____cacheline_aligned_in_smp,____cacheline_internodealigned_in_smp \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px \ + --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \ + $(all-kconfigs) | xargs $1 -a \ + --langdef=kconfig \ + --language-force=kconfig \ + --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'; \ + $(all-defconfigs) | xargs -r $1 -a \ + --langdef=dotconfig \ + --language-force=dotconfig \ + --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \ + elif $1 --version 2>&1 | grep -iq emacs; then \ + $(all-sources) | xargs $1 -a; \ + $(all-kconfigs) | xargs $1 -a \ + --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'; \ + $(all-defconfigs) | xargs -r $1 -a \ + --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \ + else \ + $(all-sources) | xargs $1 -a; \ + fi +endef + +quiet_cmd_cscope-file = FILELST cscope.files + cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files + +quiet_cmd_cscope = MAKE cscope.out + cmd_cscope = cscope -b + +cscope: FORCE + $(call cmd,cscope-file) + $(call cmd,cscope) + +quiet_cmd_TAGS = MAKE $@ +define cmd_TAGS + rm -f $@; \ + $(call xtags,etags) +endef + +TAGS: FORCE + $(call cmd,TAGS) + +quiet_cmd_tags = MAKE $@ +define cmd_tags + rm -f $@; \ + $(call xtags,ctags) +endef + +tags: FORCE + $(call cmd,tags) + + +# Scripts to check various things for consistency +# --------------------------------------------------------------------------- + +includecheck: + find * $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl + +versioncheck: + find * $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl + +namespacecheck: + $(PERL) $(srctree)/scripts/namespace.pl + +export_report: + $(PERL) $(srctree)/scripts/export_report.pl + +endif #ifeq ($(config-targets),1) +endif #ifeq ($(mixed-targets),1) + +PHONY += checkstack kernelrelease kernelversion + +# UML needs a little special treatment here. It wants to use the host +# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone +# else wants $(ARCH), including people doing cross-builds, which means +# that $(SUBARCH) doesn't work here. +ifeq ($(ARCH), um) +CHECKSTACK_ARCH := $(SUBARCH) +else +CHECKSTACK_ARCH := $(ARCH) +endif +checkstack: + $(OBJDUMP) -d apex $$(find . -name '*.ko') | \ + $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) + +kernelrelease: + $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \ + $(error kernelrelease not valid - run 'make prepare' to update it)) +kernelversion: + @echo $(KERNELVERSION) + +# Single targets +# --------------------------------------------------------------------------- +# Single targets are compatible with: +# - build with mixed source and output +# - build with separate output dir 'make O=...' +# - external modules +# +# target-dir => where to store outputfile +# build-dir => directory in kernel source tree to use + +ifeq ($(KBUILD_EXTMOD),) + build-dir = $(patsubst %/,%,$(dir $@)) + target-dir = $(dir $@) +else + zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) + build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) + target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) +endif + +%.s: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.i: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.lst: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.s: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.symtypes: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) + +# Modules +/ %/: prepare scripts FORCE + $(cmd_crmodverdir) + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) +%.ko: prepare scripts FORCE + $(cmd_crmodverdir) + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) $(@:.ko=.o) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +# FIXME Should go into a make.lib or something +# =========================================================================== + +quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) + cmd_rmdirs = rm -rf $(rm-dirs) + +quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) + cmd_rmfiles = rm -f $(rm-files) + +# Run depmod only if we have System.map and depmod is executable +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = \ + if [ -r System.map -a -x $(DEPMOD) ]; then \ + $(DEPMOD) -ae -F System.map \ + $(if $(strip $(INSTALL_MOD_PATH)), -b $(INSTALL_MOD_PATH) -r) \ + $(KERNELRELEASE); \ + fi + +# Create temporary dir for module support files +# clean it up only when building all modules +cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ + $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) + +a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ + $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ + $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) + +quiet_cmd_as_o_S = AS $@ +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +# read all saved command lines + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + $(cmd_files): ; # Do not try to update included dependency files + include $(cmd_files) +endif + +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir +# Usage: +# $(Q)$(MAKE) $(clean)=dir +clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj + +endif # skip-makefile + +-include Makefile.apex + +PHONY += FORCE +FORCE: + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. +.PHONY: $(PHONY) diff --git a/Makefile-linux b/Makefile-linux new file mode 100644 index 0000000..6aff5f4 --- /dev/null +++ b/Makefile-linux @@ -0,0 +1,1612 @@ +VERSION = 2 +PATCHLEVEL = 6 +SUBLEVEL = 26 +EXTRAVERSION = -rc8 +NAME = Rotary Wombat + +# *DOCUMENTATION* +# To see a list of typical targets execute "make help" +# More info can be located in ./README +# Comments in this file are targeted only to the developer, do not +# expect to learn how to build the kernel reading this file. + +# Do not: +# o use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour); +# o print "Entering directory ..."; +MAKEFLAGS += -rR --no-print-directory + +# We are using a recursive build, so we need to do a little thinking +# to get the ordering right. +# +# Most importantly: sub-Makefiles should only ever modify files in +# their own directory. If in some directory we have a dependency on +# a file in another dir (which doesn't happen often, but it's often +# unavoidable when linking the built-in.o targets which finally +# turn into vmlinux), we will call a sub make in that other dir, and +# after that we are sure that everything which is in that other dir +# is now up to date. +# +# The only cases where we need to modify files which have global +# effects are thus separated out and done before the recursive +# descending is started. They are now explicitly listed as the +# prepare rule. + +# To put more focus on warnings, be less verbose as default +# Use 'make V=1' to see the full commands + +ifdef V + ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE = $(V) + endif +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 +endif + +# Call a source code checker (by default, "sparse") as part of the +# C compilation. +# +# Use 'make C=1' to enable checking of only re-compiled files. +# Use 'make C=2' to enable checking of *all* source files, regardless +# of whether they are re-compiled or not. +# +# See the file "Documentation/sparse.txt" for more details, including +# where to get the "sparse" utility. + +ifdef C + ifeq ("$(origin C)", "command line") + KBUILD_CHECKSRC = $(C) + endif +endif +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC = 0 +endif + +# Use make M=dir to specify directory of external module to build +# Old syntax make ... SUBDIRS=$PWD is still supported +# Setting the environment variable KBUILD_EXTMOD take precedence +ifdef SUBDIRS + KBUILD_EXTMOD ?= $(SUBDIRS) +endif +ifdef M + ifeq ("$(origin M)", "command line") + KBUILD_EXTMOD := $(M) + endif +endif + + +# kbuild supports saving output files in a separate directory. +# To locate output files in a separate directory two syntaxes are supported. +# In both cases the working directory must be the root of the kernel src. +# 1) O= +# Use "make O=dir/to/store/output/files/" +# +# 2) Set KBUILD_OUTPUT +# Set the environment variable KBUILD_OUTPUT to point to the directory +# where the output files shall be placed. +# export KBUILD_OUTPUT=dir/to/store/output/files/ +# make +# +# The O= assignment takes precedence over the KBUILD_OUTPUT environment +# variable. + + +# KBUILD_SRC is set on invocation of make in OBJ directory +# KBUILD_SRC is not intended to be used by the regular user (for now) +ifeq ($(KBUILD_SRC),) + +# OK, Make called in directory where kernel src resides +# Do we want to locate output files in a separate directory? +ifdef O + ifeq ("$(origin O)", "command line") + KBUILD_OUTPUT := $(O) + endif +endif + +# That's our default target when none is given on the command line +PHONY := _all +_all: + +# Cancel implicit rules on top Makefile +$(CURDIR)/Makefile Makefile: ; + +ifneq ($(KBUILD_OUTPUT),) +# Invoke a second make in the output directory, passing relevant variables +# check that the output directory actually exists +saved-output := $(KBUILD_OUTPUT) +KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) +$(if $(KBUILD_OUTPUT),, \ + $(error output directory "$(saved-output)" does not exist)) + +PHONY += $(MAKECMDGOALS) sub-make + +$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make + $(Q)@: + +sub-make: FORCE + $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ + KBUILD_SRC=$(CURDIR) \ + KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ + $(filter-out _all sub-make,$(MAKECMDGOALS)) + +# Leave processing to above invocation of make +skip-makefile := 1 +endif # ifneq ($(KBUILD_OUTPUT),) +endif # ifeq ($(KBUILD_SRC),) + +# We process the rest of the Makefile if this is the final invocation of make +ifeq ($(skip-makefile),) + +# If building an external module we do not care about the all: rule +# but instead _all depend on modules +PHONY += all +ifeq ($(KBUILD_EXTMOD),) +_all: all +else +_all: modules +endif + +srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) +TOPDIR := $(srctree) +# FIXME - TOPDIR is obsolete, use srctree/objtree +objtree := $(CURDIR) +src := $(srctree) +obj := $(objtree) + +VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) + +export srctree objtree VPATH TOPDIR + + +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh.*/sh/ ) + +# Cross compiling and selecting different set of gcc/bin-utils +# --------------------------------------------------------------------------- +# +# When performing cross compilation for other architectures ARCH shall be set +# to the target architecture. (See arch/* for the possibilities). +# ARCH can be set during invocation of make: +# make ARCH=ia64 +# Another way is to have ARCH set in the environment. +# The default ARCH is the host where make is executed. + +# CROSS_COMPILE specify the prefix used for all executables used +# during compilation. Only gcc and related bin-utils executables +# are prefixed with $(CROSS_COMPILE). +# CROSS_COMPILE can be set on the command line +# make CROSS_COMPILE=ia64-linux- +# Alternatively CROSS_COMPILE can be set in the environment. +# Default value for CROSS_COMPILE is not to prefix executables +# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile +export KBUILD_BUILDHOST := $(SUBARCH) +ARCH ?= $(SUBARCH) +CROSS_COMPILE ?= + +# Architecture as present in compile.h +UTS_MACHINE := $(ARCH) +SRCARCH := $(ARCH) + +# Additional ARCH settings for x86 +ifeq ($(ARCH),i386) + SRCARCH := x86 +endif +ifeq ($(ARCH),x86_64) + SRCARCH := x86 +endif + +KCONFIG_CONFIG ?= .config + +# SHELL used by kbuild +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) + +HOSTCC = gcc +HOSTCXX = g++ +HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer +HOSTCXXFLAGS = -O2 + +# Decide whether to build built-in, modular, or both. +# Normally, just do built-in. + +KBUILD_MODULES := +KBUILD_BUILTIN := 1 + +# If we have only "make modules", don't compile built-in objects. +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are up to date before we record them. + +ifeq ($(MAKECMDGOALS),modules) + KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) +endif + +# If we have "make modules", compile modules +# in addition to whatever we do anyway. +# Just "make" or "make all" shall build modules as well + +ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) + KBUILD_MODULES := 1 +endif + +ifeq ($(MAKECMDGOALS),) + KBUILD_MODULES := 1 +endif + +export KBUILD_MODULES KBUILD_BUILTIN +export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD + +# Beautify output +# --------------------------------------------------------------------------- +# +# Normally, we echo the whole command before executing it. By making +# that echo $($(quiet)$(cmd)), we now have the possibility to set +# $(quiet) to choose other forms of output instead, e.g. +# +# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ +# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +# +# If $(quiet) is empty, the whole command will be printed. +# If it is set to "quiet_", only the short version will be printed. +# If it is set to "silent_", nothing will be printed at all, since +# the variable $(silent_cmd_cc_o_c) doesn't exist. +# +# A simple variant is to prefix commands with $(Q) - that's useful +# for commands that shall be hidden in non-verbose mode. +# +# $(Q)ln $@ :< +# +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. +# If KBUILD_VERBOSE equals 1 then the above command is displayed. + +ifeq ($(KBUILD_VERBOSE),1) + quiet = + Q = +else + quiet=quiet_ + Q = @ +endif + +# If the user is running make -s (silent mode), suppress echoing of +# commands + +ifneq ($(findstring s,$(MAKEFLAGS)),) + quiet=silent_ +endif + +export quiet Q KBUILD_VERBOSE + + +# Look for make include files relative to root of kernel src +MAKEFLAGS += --include-dir=$(srctree) + +# We need some generic definitions (do not try to remake the file). +$(srctree)/scripts/Kbuild.include: ; +include $(srctree)/scripts/Kbuild.include + +# Make variables (CC, etc...) + +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +AWK = awk +GENKSYMS = scripts/genksyms/genksyms +DEPMOD = /sbin/depmod +KALLSYMS = scripts/kallsyms +PERL = perl +CHECK = sparse + +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF) +MODFLAGS = -DMODULE +CFLAGS_MODULE = $(MODFLAGS) +AFLAGS_MODULE = $(MODFLAGS) +LDFLAGS_MODULE = +CFLAGS_KERNEL = +AFLAGS_KERNEL = + + +# Use LINUXINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O= option +LINUXINCLUDE := -Iinclude \ + $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ + -include include/linux/autoconf.h + +KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) + +KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration +KBUILD_AFLAGS := -D__ASSEMBLY__ + +# Read KERNELRELEASE from include/config/kernel.release (if it exists) +KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION +export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC +export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE +export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS + +export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS +export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE +export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE + +# When compiling out-of-tree modules, put MODVERDIR in the module +# tree rather than in the kernel tree. The kernel tree might +# even be read-only. +export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions + +# Files to ignore in find ... statements + +RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o +export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git + +# =========================================================================== +# Rules shared between *config targets and build targets + +# Basic helpers built in scripts/ +PHONY += scripts_basic +scripts_basic: + $(Q)$(MAKE) $(build)=scripts/basic + +# To avoid any implicit rule to kick in, define an empty command. +scripts/basic/%: scripts_basic ; + +PHONY += outputmakefile +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +outputmakefile: +ifneq ($(KBUILD_SRC),) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ + $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) +endif + +# To make sure we do not include .config for any of the *config targets +# catch them early, and hand them over to scripts/kconfig/Makefile +# It is allowed to specify more targets when calling make, including +# mixing *config targets and build targets. +# For example 'make oldconfig all'. +# Detect when mixed targets is specified, and make a second invocation +# of make so .config is not included in this case either (for *config). + +no-dot-config-targets := clean mrproper distclean \ + cscope TAGS tags help %docs check% \ + include/linux/version.h headers_% \ + kernelrelease kernelversion + +config-targets := 0 +mixed-targets := 0 +dot-config := 1 + +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) + dot-config := 0 + endif +endif + +ifeq ($(KBUILD_EXTMOD),) + ifneq ($(filter config %config,$(MAKECMDGOALS)),) + config-targets := 1 + ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) + mixed-targets := 1 + endif + endif +endif + +ifeq ($(mixed-targets),1) +# =========================================================================== +# We're called with mixed targets (*config and build targets). +# Handle them one by one. + +%:: FORCE + $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ + +else +ifeq ($(config-targets),1) +# =========================================================================== +# *config targets only - make sure prerequisites are updated, and descend +# in scripts/kconfig to make the *config target + +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration +# used for 'make defconfig' +include $(srctree)/arch/$(SRCARCH)/Makefile +export KBUILD_DEFCONFIG + +config %config: scripts_basic outputmakefile FORCE + $(Q)mkdir -p include/linux include/config + $(Q)$(MAKE) $(build)=scripts/kconfig $@ + +else +# =========================================================================== +# Build targets only - this includes vmlinux, arch specific targets, clean +# targets and others. In general all targets except *config targets. + +ifeq ($(KBUILD_EXTMOD),) +# Additional helpers built in scripts/ +# Carefully list dependencies so we do not try to build scripts twice +# in parallel +PHONY += scripts +scripts: scripts_basic include/config/auto.conf + $(Q)$(MAKE) $(build)=$(@) + +# Objects we will link into vmlinux / subdirs we need to visit +init-y := init/ +drivers-y := drivers/ sound/ +net-y := net/ +libs-y := lib/ +core-y := usr/ +endif # KBUILD_EXTMOD + +ifeq ($(dot-config),1) +# Read in config +-include include/config/auto.conf + +ifeq ($(KBUILD_EXTMOD),) +# Read in dependencies to all Kconfig* files, make sure to run +# oldconfig if changes are detected. +-include include/config/auto.conf.cmd + +# To avoid any implicit rule to kick in, define an empty command +$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; + +# If .config is newer than include/config/auto.conf, someone tinkered +# with it and forgot to run make oldconfig. +# if auto.conf.cmd is missing then we are probably in a cleaned tree so +# we execute the config step to be sure to catch updated Kconfig files +include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd + $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig +else +# external modules needs include/linux/autoconf.h and include/config/auto.conf +# but do not care if they are up-to-date. Use auto.conf to trigger the test +PHONY += include/config/auto.conf + +include/config/auto.conf: + $(Q)test -e include/linux/autoconf.h -a -e $@ || ( \ + echo; \ + echo " ERROR: Kernel configuration is invalid."; \ + echo " include/linux/autoconf.h or $@ are missing."; \ + echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ + echo; \ + /bin/false) + +endif # KBUILD_EXTMOD + +else +# Dummy target needed, because used as prerequisite +include/config/auto.conf: ; +endif # $(dot-config) + +# The all: target is the default when no target is given on the +# command line. +# This allow a user to issue only 'make' to build a kernel including modules +# Defaults vmlinux but it is usually overridden in the arch makefile +all: vmlinux + +ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE +KBUILD_CFLAGS += -Os +else +KBUILD_CFLAGS += -O2 +endif + +ifneq (CONFIG_FRAME_WARN,0) +KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) +endif + +# Force gcc to behave correct even for buggy distributions +# Arch Makefiles may override this setting +KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) + +include $(srctree)/arch/$(SRCARCH)/Makefile + +ifdef CONFIG_FRAME_POINTER +KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else +KBUILD_CFLAGS += -fomit-frame-pointer +endif + +ifdef CONFIG_DEBUG_INFO +KBUILD_CFLAGS += -g +KBUILD_AFLAGS += -gdwarf-2 +endif + +# We trigger additional mismatches with less inlining +ifdef CONFIG_DEBUG_SECTION_MISMATCH +KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) +endif + +# arch Makefile may override CC so keep this after arch Makefile is included +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +CHECKFLAGS += $(NOSTDINC_FLAGS) + +# warn about C99 declaration after statement +KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) + +# disable pointer signed / unsigned warnings in gcc 4.0 +KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,) + +# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments +# But warn user when we do so +warn-assign = \ +$(warning "WARNING: Appending $$K$(1) ($(K$(1))) from $(origin K$(1)) to kernel $$$(1)") + +ifneq ($(KCPPFLAGS),) + $(call warn-assign,CPPFLAGS) + KBUILD_CPPFLAGS += $(KCPPFLAGS) +endif +ifneq ($(KAFLAGS),) + $(call warn-assign,AFLAGS) + KBUILD_AFLAGS += $(KAFLAGS) +endif +ifneq ($(KCFLAGS),) + $(call warn-assign,CFLAGS) + KBUILD_CFLAGS += $(KCFLAGS) +endif + +# Use --build-id when available. +LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ + $(call ld-option, -Wl$(comma)--build-id,)) +LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) +LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) + +# Default kernel image to build when no specific target is given. +# KBUILD_IMAGE may be overruled on the command line or +# set in the environment +# Also any assignments in arch/$(ARCH)/Makefile take precedence over +# this default value +export KBUILD_IMAGE ?= vmlinux + +# +# INSTALL_PATH specifies where to place the updated kernel and system map +# images. Default is /boot, but you can set it to other values +export INSTALL_PATH ?= /boot + +# +# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory +# relocations required by build roots. This is not defined in the +# makefile but the argument can be passed to make if needed. +# + +MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) +export MODLIB + +# +# INSTALL_MOD_STRIP, if defined, will cause modules to be +# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then +# the default option --strip-debug will be used. Otherwise, +# INSTALL_MOD_STRIP will used as the options to the strip command. + +ifdef INSTALL_MOD_STRIP +ifeq ($(INSTALL_MOD_STRIP),1) +mod_strip_cmd = $(STRIP) --strip-debug +else +mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) +endif # INSTALL_MOD_STRIP=1 +else +mod_strip_cmd = true +endif # INSTALL_MOD_STRIP +export mod_strip_cmd + + +ifeq ($(KBUILD_EXTMOD),) +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ + +vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ + $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ + $(net-y) $(net-m) $(libs-y) $(libs-m))) + +vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ + $(init-n) $(init-) \ + $(core-n) $(core-) $(drivers-n) $(drivers-) \ + $(net-n) $(net-) $(libs-n) $(libs-)))) + +init-y := $(patsubst %/, %/built-in.o, $(init-y)) +core-y := $(patsubst %/, %/built-in.o, $(core-y)) +drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) +net-y := $(patsubst %/, %/built-in.o, $(net-y)) +libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) +libs-y := $(libs-y1) $(libs-y2) + +# Build vmlinux +# --------------------------------------------------------------------------- +# vmlinux is built from the objects selected by $(vmlinux-init) and +# $(vmlinux-main). Most are built-in.o files from top-level directories +# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. +# Ordering when linking is important, and $(vmlinux-init) must be first. +# +# vmlinux +# ^ +# | +# +-< $(vmlinux-init) +# | +--< init/version.o + more +# | +# +--< $(vmlinux-main) +# | +--< driver/built-in.o mm/built-in.o + more +# | +# +-< kallsyms.o (see description in CONFIG_KALLSYMS section) +# +# vmlinux version (uname -v) cannot be updated during normal +# descending-into-subdirs phase since we do not yet know if we need to +# update vmlinux. +# Therefore this step is delayed until just before final link of vmlinux - +# except in the kallsyms case where it is done just before adding the +# symbols to the kernel. +# +# System.map is generated to document addresses of all kernel symbols + +vmlinux-init := $(head-y) $(init-y) +vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) +vmlinux-all := $(vmlinux-init) $(vmlinux-main) +vmlinux-lds := arch/$(SRCARCH)/kernel/vmlinux.lds +export KBUILD_VMLINUX_OBJS := $(vmlinux-all) + +# Rule to link vmlinux - also used during CONFIG_KALLSYMS +# May be overridden by arch/$(ARCH)/Makefile +quiet_cmd_vmlinux__ ?= LD $@ + cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \ + -T $(vmlinux-lds) $(vmlinux-init) \ + --start-group $(vmlinux-main) --end-group \ + $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o FORCE ,$^) + +# Generate new vmlinux version +quiet_cmd_vmlinux_version = GEN .version + cmd_vmlinux_version = set -e; \ + if [ ! -r .version ]; then \ + rm -f .version; \ + echo 1 >.version; \ + else \ + mv .version .old_version; \ + expr 0$$(cat .old_version) + 1 >.version; \ + fi; \ + $(MAKE) $(build)=init + +# Generate System.map +quiet_cmd_sysmap = SYSMAP + cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap + +# Link of vmlinux +# If CONFIG_KALLSYMS is set .version is already updated +# Generate System.map and verify that the content is consistent +# Use + in front of the vmlinux_version rule to silent warning with make -j2 +# First command is ':' to allow us to use + in front of the rule +define rule_vmlinux__ + : + $(if $(CONFIG_KALLSYMS),,+$(call cmd,vmlinux_version)) + + $(call cmd,vmlinux__) + $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd + + $(Q)$(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap) System.map' &&) \ + $(cmd_sysmap) $@ System.map; \ + if [ $$? -ne 0 ]; then \ + rm -f $@; \ + /bin/false; \ + fi; + $(verify_kallsyms) +endef + + +ifdef CONFIG_KALLSYMS +# Generate section listing all symbols and add it into vmlinux $(kallsyms.o) +# It's a three stage process: +# o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is +# empty +# Running kallsyms on that gives us .tmp_kallsyms1.o with +# the right size - vmlinux version (uname -v) is updated during this step +# o .tmp_vmlinux2 now has a __kallsyms section of the right size, +# but due to the added section, some addresses have shifted. +# From here, we generate a correct .tmp_kallsyms2.o +# o The correct .tmp_kallsyms2.o is linked into the final vmlinux. +# o Verify that the System.map from vmlinux matches the map from +# .tmp_vmlinux2, just in case we did not generate kallsyms correctly. +# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using +# .tmp_vmlinux3 and .tmp_kallsyms3.o. This is only meant as a +# temporary bypass to allow the kernel to be built while the +# maintainers work out what went wrong with kallsyms. + +ifdef CONFIG_KALLSYMS_EXTRA_PASS +last_kallsyms := 3 +else +last_kallsyms := 2 +endif + +kallsyms.o := .tmp_kallsyms$(last_kallsyms).o + +define verify_kallsyms + $(Q)$(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \ + $(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map + $(Q)cmp -s System.map .tmp_System.map || \ + (echo Inconsistent kallsyms data; \ + echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \ + rm .tmp_kallsyms* ; /bin/false ) +endef + +# Update vmlinux version before link +# Use + in front of this rule to silent warning about make -j1 +# First command is ':' to allow us to use + in front of this rule +cmd_ksym_ld = $(cmd_vmlinux__) +define rule_ksym_ld + : + +$(call cmd,vmlinux_version) + $(call cmd,vmlinux__) + $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd +endef + +# Generate .S file with all kernel symbols +quiet_cmd_kallsyms = KSYM $@ + cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \ + $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@ + +.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE + $(call if_changed_dep,as_o_S) + +.tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS) + $(call cmd,kallsyms) + +# .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version +.tmp_vmlinux1: $(vmlinux-lds) $(vmlinux-all) FORCE + $(call if_changed_rule,ksym_ld) + +.tmp_vmlinux2: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms1.o FORCE + $(call if_changed,vmlinux__) + +.tmp_vmlinux3: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms2.o FORCE + $(call if_changed,vmlinux__) + +# Needs to visit scripts/ before $(KALLSYMS) can be used. +$(KALLSYMS): scripts ; + +# Generate some data for debugging strange kallsyms problems +debug_kallsyms: .tmp_map$(last_kallsyms) + +.tmp_map%: .tmp_vmlinux% FORCE + ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@ + +.tmp_map3: .tmp_map2 + +.tmp_map2: .tmp_map1 + +endif # ifdef CONFIG_KALLSYMS + +# Do modpost on a prelinked vmlinux. The finally linked vmlinux has +# relevant sections renamed as per the linker script. +quiet_cmd_vmlinux-modpost = LD $@ + cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \ + $(vmlinux-init) --start-group $(vmlinux-main) --end-group \ + $(filter-out $(vmlinux-init) $(vmlinux-main) FORCE ,$^) +define rule_vmlinux-modpost + : + +$(call cmd,vmlinux-modpost) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@ + $(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd +endef + +# vmlinux image - including updated kernel symbols +vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCE +ifdef CONFIG_HEADERS_CHECK + $(Q)$(MAKE) -f $(srctree)/Makefile headers_check +endif +ifdef CONFIG_SAMPLES + $(Q)$(MAKE) $(build)=samples +endif + $(call vmlinux-modpost) + $(call if_changed_rule,vmlinux__) + $(Q)rm -f .old_version + +# build vmlinux.o first to catch section mismatch errors early +ifdef CONFIG_KALLSYMS +.tmp_vmlinux1: vmlinux.o +endif + +modpost-init := $(filter-out init/built-in.o, $(vmlinux-init)) +vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE + $(call if_changed_rule,vmlinux-modpost) + +# The actual objects are generated when descending, +# make sure no implicit rule kicks in +$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; + +# Handle descending into subdirectories listed in $(vmlinux-dirs) +# Preset locale variables to speed up the build process. Limit locale +# tweaks to this spot to avoid wrong language settings when running +# make menuconfig etc. +# Error messages still appears in the original language + +PHONY += $(vmlinux-dirs) +$(vmlinux-dirs): prepare scripts + $(Q)$(MAKE) $(build)=$@ + +# Build the kernel release string +# +# The KERNELRELEASE value built here is stored in the file +# include/config/kernel.release, and is used when executing several +# make targets, such as "make install" or "make modules_install." +# +# The eventual kernel release string consists of the following fields, +# shown in a hierarchical format to show how smaller parts are concatenated +# to form the larger and final value, with values coming from places like +# the Makefile, kernel config options, make command line options and/or +# SCM tag information. +# +# $(KERNELVERSION) +# $(VERSION) eg, 2 +# $(PATCHLEVEL) eg, 6 +# $(SUBLEVEL) eg, 18 +# $(EXTRAVERSION) eg, -rc6 +# $(localver-full) +# $(localver) +# localversion* (files without backups, containing '~') +# $(CONFIG_LOCALVERSION) (from kernel config setting) +# $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set) +# ./scripts/setlocalversion (SCM tag, if one exists) +# $(LOCALVERSION) (from make command line if provided) +# +# Note how the final $(localver-auto) string is included *only* if the +# kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the +# moment, only git is supported but other SCMs can edit the script +# scripts/setlocalversion and add the appropriate checks as needed. + +pattern = ".*/localversion[^~]*" +string = $(shell cat /dev/null \ + `find $(objtree) $(srctree) -maxdepth 1 -regex $(pattern) | sort -u`) + +localver = $(subst $(space),, $(string) \ + $(patsubst "%",%,$(CONFIG_LOCALVERSION))) + +# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called +# and if the SCM is know a tag from the SCM is appended. +# The appended tag is determined by the SCM used. +# +# Currently, only git is supported. +# Other SCMs can edit scripts/setlocalversion and add the appropriate +# checks as needed. +ifdef CONFIG_LOCALVERSION_AUTO + _localver-auto = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/setlocalversion $(srctree)) + localver-auto = $(LOCALVERSION)$(_localver-auto) +endif + +localver-full = $(localver)$(localver-auto) + +# Store (new) KERNELRELASE string in include/config/kernel.release +kernelrelease = $(KERNELVERSION)$(localver-full) +include/config/kernel.release: include/config/auto.conf FORCE + $(Q)rm -f $@ + $(Q)echo $(kernelrelease) > $@ + + +# Things we need to do before we recursively start building the kernel +# or the modules are listed in "prepare". +# A multi level approach is used. prepareN is processed before prepareN-1. +# archprepare is used in arch Makefiles and when processed asm symlink, +# version.h and scripts_basic is processed / created. + +# Listed in dependency order +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 + +# prepare3 is used to check if we are building in a separate output directory, +# and if so do: +# 1) Check that make has not been executed in the kernel src $(srctree) +# 2) Create the include2 directory, used for the second asm symlink +prepare3: include/config/kernel.release +ifneq ($(KBUILD_SRC),) + @echo ' Using $(srctree) as source for kernel' + $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ + echo " $(srctree) is not clean, please run 'make mrproper'";\ + echo " in the '$(srctree)' directory.";\ + /bin/false; \ + fi; + $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; + $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm +endif + +# prepare2 creates a makefile if using a separate output directory +prepare2: prepare3 outputmakefile + +prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \ + include/asm include/config/auto.conf + $(cmd_crmodverdir) + +archprepare: prepare1 scripts_basic + +prepare0: archprepare FORCE + $(Q)$(MAKE) $(build)=. + $(Q)$(MAKE) $(build)=. missing-syscalls + +# All the preparing.. +prepare: prepare0 + +# Leave this as default for preprocessing vmlinux.lds.S, which is now +# done in arch/$(ARCH)/kernel/Makefile + +export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) + +# The asm symlink changes when $(ARCH) changes. +# Detect this and ask user to run make mrproper + +include/asm: FORCE + $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ + if [ -L include/asm ]; then \ + if [ "$$asmlink" != "$(SRCARCH)" ]; then \ + echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ + echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ + exit 1; \ + fi; \ + else \ + echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ + if [ ! -d include ]; then \ + mkdir -p include; \ + fi; \ + ln -fsn asm-$(SRCARCH) $@; \ + fi + +# Generate some files +# --------------------------------------------------------------------------- + +# KERNELRELEASE can change from a few different places, meaning version.h +# needs to be updated, so this check is forced on all builds + +uts_len := 64 +define filechk_utsrelease.h + if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ + echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ + exit 1; \ + fi; \ + (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";) +endef + +define filechk_version.h + (echo \#define LINUX_VERSION_CODE $(shell \ + expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) +endef + +include/linux/version.h: $(srctree)/Makefile FORCE + $(call filechk,version.h) + +include/linux/utsrelease.h: include/config/kernel.release FORCE + $(call filechk,utsrelease.h) + +# --------------------------------------------------------------------------- + +PHONY += depend dep +depend dep: + @echo '*** Warning: make $@ is unnecessary now.' + +# --------------------------------------------------------------------------- +# Kernel headers +INSTALL_HDR_PATH=$(objtree)/usr +export INSTALL_HDR_PATH + +HDRFILTER=generic i386 x86_64 +HDRARCHES=$(filter-out $(HDRFILTER),$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) + +PHONY += headers_install_all +headers_install_all: include/linux/version.h scripts_basic FORCE + $(Q)$(MAKE) $(build)=scripts scripts/unifdef + $(Q)for arch in $(HDRARCHES); do \ + $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch ;\ + done + +PHONY += headers_install +headers_install: include/linux/version.h scripts_basic FORCE + @if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ + echo '*** Error: Headers not exportable for this architecture ($(SRCARCH))'; \ + exit 1 ; fi + $(Q)$(MAKE) $(build)=scripts scripts/unifdef + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include + +PHONY += headers_check_all +headers_check_all: headers_install_all + $(Q)for arch in $(HDRARCHES); do \ + $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ + done + +PHONY += headers_check +headers_check: headers_install + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include HDRCHECK=1 + +# --------------------------------------------------------------------------- +# Modules + +ifdef CONFIG_MODULES + +# By default, build modules as well + +all: modules + +# Build modules +# +# A module can be listed more than once in obj-m resulting in +# duplicate lines in modules.order files. Those are removed +# using awk while concatenating to the final file. + +PHONY += modules +modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) + $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + + +# Target to prepare building external modules +PHONY += modules_prepare +modules_prepare: prepare scripts + +# Target to install modules +PHONY += modules_install +modules_install: _modinst_ _modinst_post + +PHONY += _modinst_ +_modinst_: + @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ + echo "Warning: you may need to install module-init-tools"; \ + echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\ + sleep 1; \ + fi + @rm -rf $(MODLIB)/kernel + @rm -f $(MODLIB)/source + @mkdir -p $(MODLIB)/kernel + @ln -s $(srctree) $(MODLIB)/source + @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ + rm -f $(MODLIB)/build ; \ + ln -s $(objtree) $(MODLIB)/build ; \ + fi + @cp -f $(objtree)/modules.order $(MODLIB)/ + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst + +# This depmod is only for convenience to give the initial +# boot a modules.dep even before / is mounted read-write. However the +# boot script depmod is the master version. +PHONY += _modinst_post +_modinst_post: _modinst_ + $(call cmd,depmod) + +else # CONFIG_MODULES + +# Modules not configured +# --------------------------------------------------------------------------- + +modules modules_install: FORCE + @echo + @echo "The present kernel configuration has modules disabled." + @echo "Type 'make config' and enable loadable module support." + @echo "Then build a kernel with module support enabled." + @echo + @exit 1 + +endif # CONFIG_MODULES + +### +# Cleaning is done on three levels. +# make clean Delete most generated files +# Leave enough to build external modules +# make mrproper Delete the current configuration, and all generated files +# make distclean Remove editor backup files, patch leftover files and the like + +# Directories & files removed with 'make clean' +CLEAN_DIRS += $(MODVERDIR) +CLEAN_FILES += vmlinux System.map \ + .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map + +# Directories & files removed with 'make mrproper' +MRPROPER_DIRS += include/config include2 usr/include +MRPROPER_FILES += .config .config.old include/asm .version .old_version \ + include/linux/autoconf.h include/linux/version.h \ + include/linux/utsrelease.h \ + include/linux/bounds.h include/asm*/asm-offsets.h \ + Module.symvers tags TAGS cscope* + +# clean - Delete most, but leave enough to build external modules +# +clean: rm-dirs := $(CLEAN_DIRS) +clean: rm-files := $(CLEAN_FILES) +clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) + +PHONY += $(clean-dirs) clean archclean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: archclean $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find . $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ + -o -name '*.symtypes' -o -name 'modules.order' \) \ + -type f -print | xargs rm -f + +# mrproper - Delete all generated files, including .config +# +mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) +mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) +mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) + +PHONY += $(mrproper-dirs) mrproper archmrproper +$(mrproper-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) + +mrproper: clean archmrproper $(mrproper-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + +# distclean +# +PHONY += distclean + +distclean: mrproper + @find $(srctree) $(RCS_FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -size 0 \ + -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ + -type f -print | xargs rm -f + + +# Packaging of the kernel to various formats +# --------------------------------------------------------------------------- +# rpm target kept for backward compatibility +package-dir := $(srctree)/scripts/package + +%pkg: include/config/kernel.release FORCE + $(Q)$(MAKE) $(build)=$(package-dir) $@ +rpm: include/config/kernel.release FORCE + $(Q)$(MAKE) $(build)=$(package-dir) $@ + + +# Brief documentation of the typical targets used +# --------------------------------------------------------------------------- + +boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig) +boards := $(notdir $(boards)) +board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig)) +board-dirs := $(sort $(notdir $(board-dirs:/=))) + +help: + @echo 'Cleaning targets:' + @echo ' clean - Remove most generated files but keep the config and' + @echo ' enough build support to build external modules' + @echo ' mrproper - Remove all generated files + config + various backup files' + @echo ' distclean - mrproper + remove editor backup and patch files' + @echo '' + @echo 'Configuration targets:' + @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help + @echo '' + @echo 'Other generic targets:' + @echo ' all - Build all targets marked with [*]' + @echo '* vmlinux - Build the bare kernel' + @echo '* modules - Build all modules' + @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' + @echo ' dir/ - Build all files in dir and below' + @echo ' dir/file.[ois] - Build specified target only' + @echo ' dir/file.ko - Build module including final link' + @echo ' prepare - Set up for building external modules' + @echo ' tags/TAGS - Generate tags file for editors' + @echo ' cscope - Generate cscope index' + @echo ' kernelrelease - Output the release version string' + @echo ' kernelversion - Output the version stored in Makefile' + @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ + echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ + echo ' (default: $(INSTALL_HDR_PATH))'; \ + fi + @echo '' + @echo 'Static analysers' + @echo ' checkstack - Generate a list of stack hogs' + @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' versioncheck - Sanity check on version.h usage' + @echo ' includecheck - Check for duplicate included header files' + @echo ' export_report - List the usages of all exported symbols' + @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ + echo ' headers_check - Sanity check on exported headers'; \ + fi + @echo '' + @echo 'Kernel packaging:' + @$(MAKE) $(build)=$(package-dir) help + @echo '' + @echo 'Documentation targets:' + @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp + @echo '' + @echo 'Architecture specific targets ($(SRCARCH)):' + @$(if $(archhelp),$(archhelp),\ + echo ' No architecture specific help defined for $(SRCARCH)') + @echo '' + @$(if $(boards), \ + $(foreach b, $(boards), \ + printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ + echo '') + @$(if $(board-dirs), \ + $(foreach b, $(board-dirs), \ + printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ + printf " %-16s - Show all of the above\\n" help-boards; \ + echo '') + + @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' + @echo ' make V=2 [targets] 2 => give reason for rebuild of target' + @echo ' make O=dir [targets] Locate all output files in "dir", including .config' + @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' + @echo ' make C=2 [targets] Force check of all c source with $$CHECK' + @echo '' + @echo 'Execute "make" or "make all" to build all targets marked with [*] ' + @echo 'For further info see the ./README file' + + +help-board-dirs := $(addprefix help-,$(board-dirs)) + +help-boards: $(help-board-dirs) + +boards-per-dir = $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)) + +$(help-board-dirs): help-%: + @echo 'Architecture specific targets ($(SRCARCH) $*):' + @$(if $(boards-per-dir), \ + $(foreach b, $(boards-per-dir), \ + printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ + echo '') + + +# Documentation targets +# --------------------------------------------------------------------------- +%docs: scripts_basic FORCE + $(Q)$(MAKE) $(build)=Documentation/DocBook $@ + +else # KBUILD_EXTMOD + +### +# External module support. +# When building external modules the kernel used as basis is considered +# read-only, and no consistency checks are made and the make +# system is not used on the basis kernel. If updates are required +# in the basis kernel ordinary make commands (without M=...) must +# be used. +# +# The following are the only valid targets when building external +# modules. +# make M=dir clean Delete all automatically generated files +# make M=dir modules Make all modules in specified dir +# make M=dir Same as 'make M=dir modules' +# make M=dir modules_install +# Install the modules built in the module directory +# Assumes install directory is already created + +# We are always building modules +KBUILD_MODULES := 1 +PHONY += crmodverdir +crmodverdir: + $(cmd_crmodverdir) + +PHONY += $(objtree)/Module.symvers +$(objtree)/Module.symvers: + @test -e $(objtree)/Module.symvers || ( \ + echo; \ + echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ + echo " is missing; modules will have no dependencies and modversions."; \ + echo ) + +module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) +PHONY += $(module-dirs) modules +$(module-dirs): crmodverdir $(objtree)/Module.symvers + $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) + +modules: $(module-dirs) + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +PHONY += modules_install +modules_install: _emodinst_ _emodinst_post + +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) +PHONY += _emodinst_ +_emodinst_: + $(Q)mkdir -p $(MODLIB)/$(install-dir) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst + +PHONY += _emodinst_post +_emodinst_post: _emodinst_ + $(call cmd,depmod) + +clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) + +PHONY += $(clean-dirs) clean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: rm-dirs := $(MODVERDIR) +clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers +clean: $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ + -type f -print | xargs rm -f + +help: + @echo ' Building external modules.' + @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' + @echo '' + @echo ' modules - default target, build the module(s)' + @echo ' modules_install - install the module' + @echo ' clean - remove generated files in module directory only' + @echo '' + +# Dummies... +PHONY += prepare scripts +prepare: ; +scripts: ; +endif # KBUILD_EXTMOD + +# Generate tags for editors +# --------------------------------------------------------------------------- + +#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set +#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file. +#Adding $(srctree) adds about 20M on i386 to the size of the output file! + +ifeq ($(src),$(obj)) +__srctree = +else +__srctree = $(srctree)/ +endif + +ifeq ($(ALLSOURCE_ARCHS),) +ifeq ($(ARCH),um) +ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH) +else +ALLINCLUDE_ARCHS := $(SRCARCH) +endif +else +#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour. +ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS) +endif + +ALLSOURCE_ARCHS := $(SRCARCH) + +define find-sources + ( for arch in $(ALLSOURCE_ARCHS) ; do \ + find $(__srctree)arch/$${arch} $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + done ; \ + find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + find $(__srctree)include $(RCS_FIND_IGNORE) \ + \( -name config -o -name 'asm-*' \) -prune \ + -o -name $1 -print; \ + for arch in $(ALLINCLUDE_ARCHS) ; do \ + find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + done ; \ + find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ + -name $1 -print; \ + find $(__srctree) $(RCS_FIND_IGNORE) \ + \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ + -name $1 -print; \ + ) +endef + +define all-sources + $(call find-sources,'*.[chS]') +endef +define all-kconfigs + $(call find-sources,'Kconfig*') +endef +define all-defconfigs + $(call find-sources,'defconfig') +endef + +define xtags + if $1 --version 2>&1 | grep -iq exuberant; then \ + $(all-sources) | xargs $1 -a \ + -I __initdata,__exitdata,__acquires,__releases \ + -I __read_mostly,____cacheline_aligned,____cacheline_aligned_in_smp,____cacheline_internodealigned_in_smp \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px \ + --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \ + $(all-kconfigs) | xargs $1 -a \ + --langdef=kconfig \ + --language-force=kconfig \ + --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'; \ + $(all-defconfigs) | xargs -r $1 -a \ + --langdef=dotconfig \ + --language-force=dotconfig \ + --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \ + elif $1 --version 2>&1 | grep -iq emacs; then \ + $(all-sources) | xargs $1 -a; \ + $(all-kconfigs) | xargs $1 -a \ + --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'; \ + $(all-defconfigs) | xargs -r $1 -a \ + --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \ + else \ + $(all-sources) | xargs $1 -a; \ + fi +endef + +quiet_cmd_cscope-file = FILELST cscope.files + cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files + +quiet_cmd_cscope = MAKE cscope.out + cmd_cscope = cscope -b + +cscope: FORCE + $(call cmd,cscope-file) + $(call cmd,cscope) + +quiet_cmd_TAGS = MAKE $@ +define cmd_TAGS + rm -f $@; \ + $(call xtags,etags) +endef + +TAGS: FORCE + $(call cmd,TAGS) + +quiet_cmd_tags = MAKE $@ +define cmd_tags + rm -f $@; \ + $(call xtags,ctags) +endef + +tags: FORCE + $(call cmd,tags) + + +# Scripts to check various things for consistency +# --------------------------------------------------------------------------- + +includecheck: + find * $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl + +versioncheck: + find * $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl + +namespacecheck: + $(PERL) $(srctree)/scripts/namespace.pl + +export_report: + $(PERL) $(srctree)/scripts/export_report.pl + +endif #ifeq ($(config-targets),1) +endif #ifeq ($(mixed-targets),1) + +PHONY += checkstack kernelrelease kernelversion + +# UML needs a little special treatment here. It wants to use the host +# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone +# else wants $(ARCH), including people doing cross-builds, which means +# that $(SUBARCH) doesn't work here. +ifeq ($(ARCH), um) +CHECKSTACK_ARCH := $(SUBARCH) +else +CHECKSTACK_ARCH := $(ARCH) +endif +checkstack: + $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ + $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) + +kernelrelease: + $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \ + $(error kernelrelease not valid - run 'make prepare' to update it)) +kernelversion: + @echo $(KERNELVERSION) + +# Single targets +# --------------------------------------------------------------------------- +# Single targets are compatible with: +# - build with mixed source and output +# - build with separate output dir 'make O=...' +# - external modules +# +# target-dir => where to store outputfile +# build-dir => directory in kernel source tree to use + +ifeq ($(KBUILD_EXTMOD),) + build-dir = $(patsubst %/,%,$(dir $@)) + target-dir = $(dir $@) +else + zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) + build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) + target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) +endif + +%.s: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.i: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.lst: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.s: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.symtypes: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) + +# Modules +/ %/: prepare scripts FORCE + $(cmd_crmodverdir) + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) +%.ko: prepare scripts FORCE + $(cmd_crmodverdir) + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) $(@:.ko=.o) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +# FIXME Should go into a make.lib or something +# =========================================================================== + +quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) + cmd_rmdirs = rm -rf $(rm-dirs) + +quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) + cmd_rmfiles = rm -f $(rm-files) + +# Run depmod only if we have System.map and depmod is executable +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = \ + if [ -r System.map -a -x $(DEPMOD) ]; then \ + $(DEPMOD) -ae -F System.map \ + $(if $(strip $(INSTALL_MOD_PATH)), -b $(INSTALL_MOD_PATH) -r) \ + $(KERNELRELEASE); \ + fi + +# Create temporary dir for module support files +# clean it up only when building all modules +cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ + $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) + +a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ + $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ + $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) + +quiet_cmd_as_o_S = AS $@ +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +# read all saved command lines + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + $(cmd_files): ; # Do not try to update included dependency files + include $(cmd_files) +endif + +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir +# Usage: +# $(Q)$(MAKE) $(clean)=dir +clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj + +endif # skip-makefile + +PHONY += FORCE +FORCE: + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. +.PHONY: $(PHONY) diff --git a/Makefile.apex b/Makefile.apex new file mode 100644 index 0000000..78203cd --- /dev/null +++ b/Makefile.apex @@ -0,0 +1,101 @@ +# -*- Makefile -*- +# Makefile.apex, extra APEX specific targets for top-level directory of APEX +# + +include/mach: FORCE + $(Q)set -e; machlink=`readlink include/mach | cut -d '-' -f 2`; \ + if [ -L include/mach ]; then \ + if [ "$$machlink" != "$(CONFIG_MACH)" ]; then \ + echo "ERROR: the symlink $@ points to mach-$$machlink but mach-$(CONFIG_MACH) was expected"; \ + exit 1; \ + fi; \ + else \ + echo ' SYMLINK $@ -> include/mach-$(CONFIG_MACH)'; \ + if [ ! -d include ]; then \ + mkdir -p include; \ + fi; \ + ln -fsn ../src/mach-$(CONFIG_MACH) $@; \ + fi + + +#include/mach: include/.mach FORCE +#include/.mach: include/config/MARKER +# @echo ' SYMLINK include/mach -> src/mach-$(CONFIG_MACH)' +# @ln -fsn ../src/mach-$(CONFIG_MACH) include/mach +# @touch include/.mach + + +# every target builds all of the available configurations +# NOTE: We drop building debian configs because we use this target to +# build viable binaries and forcing the compiler to ARM +# littleendian won't build vaild binaries. The debian configs +# don't include an explicit compiler reference. + +PHONY += every +every: #distclean + @if [ -e .config ]; then rm .config ; fi + @[ ! -d every ] || rm -rf every + @mkdir every + @for i in `find src/mach-*/ \ + -name '*_config' -printf ' %f'` ; do \ + o=apex-$(APEXVERSION)-`echo $$i | sed -s 's/_config//'`; \ + [ ! -f makelog ] || rm makelog ;\ + printf " BUILD %-32s ($$o)\n" $$i;\ + $(MAKE) clean >> makelog 2>&1 || exit 1 ; \ + $(MAKE) $$i >> makelog 2>&1 || exit 1 ; \ + $(MAKE) oldconfig < /dev/null >> makelog 2>&1 || exit 1 ; \ + $(MAKE) `scripts/overrides $$i` \ + apex.srec apex.elf apex.bin >> makelog 2>&1 || exit 1 ; \ + mkdir every/$$o ; \ + mv src/arch-arm/rom/apex.{elf,bin,srec} makelog every/$$o ; \ + cp .config every/$$o/config ; \ + echo $(APEXVERSION) > every/$$o/APEXVERSION ; \ + cp docs/Every every/$$o/README ; \ + (cd every ; zip -rq $$o.zip $$o ) ; \ + done + @rm .config + +# every target builds all of the available configurations +PHONY += update-every +update-every: + @for i in `find src/mach-*/ -name '*_config'` ; do \ + echo -- $$i;\ + cp $$i .config; \ + $(MAKE) oldconfig; \ + cp .config $$i; \ + done + +PHONY += release-every +release-every: every + mkdir -p ~ftp/pub/apex/apex-$(APEXVERSION) + cp every/*.zip ~ftp/pub/apex/apex-$(APEXVERSION) + + +#PHONY += tgz +#tgz: FORCE +# $(Q)$(MAKE) -f $(package-dir)/Makefile $@ + +PKGBASE := apex-$(APEXVERSION) + +PHONY += tgz.pkg +tgz.pkg tgz: +ifneq "$(wildcard $(PKGBASE))" "" + -rm -rf $(PKGBASE) +endif + @git-clone -l ./ $(PKGBASE) + find $(PKGBASE) -depth -type d -name '_intel' -exec rm -rf \{\} \; + rm -rf $(PKGBASE)/include/splash + tar zc\ + --exclude='.git'\ + --exclude='cc-png.h'\ + --exclude='pcm*-*.h'\ + --exclude='colorbars*.png'\ + -f $(PKGBASE).tar.gz $(PKGBASE) + @rm -rf $(PKGBASE) + +PHONY += complete-release +complete-release: tgz release-every FORCE + cp apex-$(APEXVERSION).tar.gz ~ftp/pub/apex + git-tag -a $(APEXVERSION) -m "Release $(APEXVERSION)" + -(cd ~ftp/pub/apex ; rm LATEST_IS* ; touch LATEST_IS_$(APEXVERSION) ) + diff --git a/NOTES b/NOTES new file mode 100644 index 0000000..32ea5a3 --- /dev/null +++ b/NOTES @@ -0,0 +1,1445 @@ +================ +APEX Boot Loader + NOTES +================ + +TODO: + + o 2009.jan.4 + + o Handling extended partitions and large drivers. The problems of + a couple of days ago are no longer present. Upgraded the + compiler and now there is no sign that the 64 bit support is + broken. + + o THUMB. There is better support for thumb in that there are + functions to handle some of the cp15 calls that were always + inlined. For code tha must inline, the macros are still + present. + + o NOR flash scanner. It would be helpful to have a function to + scan nor flash and determine which blocks are in use. Also, it + would be handy to have a notation for flash that allows + specification of erase blocks or pages (NAND only). For example, + "nor:/N" where N is the block number, even when the blocks are + of differing sizes. + + o 2009.jan.2 + + o Handling extended partitions and large drivers. The extended + partition scanning code (in drv-ext2) properly reads each of the + extended partition descriptors. For the MV2120 platform, this + requires the CONFIG_DRIVER_LONG_LONG_SIZE option because the + seek function cannot otherwise distinguish between a large + positive offset or a negative one. However, there is a catch in + that the 64 bit length option appears to be unstable is some + cases. The program doesn't crash, but it does perform + improperly. A "du ata:0s+1s" doesn't end with a single sector. + The ext2_identify() function won't read any partitions. + + One of the catches is that the starting offset for an extended + partition is the accumulation of the starting offsets for the + extended partition records plus the starting LBA for the + partition. This can be seen in the way that the sector_start is + adjusted for each extended partition record. + + o 2008.dec.30 + + o Handling extended partitions. While adding features for the + MV2120 we found support for extended partitions in of itself is + reasonably simple to implement. However, the extended partition + is past a 2GiB offset. This offset is manageable, but we really + need to be able to handle extended partitions beyond 4GiBs. The + internals of the descriptor need to be extended to 48 or 64 bits + in order to handle this. Ay, carumba. I never thought that the + boot loader would have to be 64 bit filesystem compliant. + + o 2008.dec.16 + + o The drv-ata driver needs to support multiple drives and the + absence of either or both. The orion5x controller ought to be + able to determine when a drive is present, so we should not have + to depend on a ready_wait timeout. + + o 2008.nov.25 + o Alias/environment variable references. Presently, variable + substitutions only traverse a single level. It is necessary to + support indefinite recursion. If kernelsrc refers to another + variable and it is used in the startup variable, we should be + able to dereference it. + o Startup that doesn't use copy. Originally, we only supported a + copy when loading data into memory. With aImages, there could + be an "im load" instead. How should this be integrated into + APEX? + + o 2008.nov.18 + + o Thumb and GCC4.3. Support for thumb has been added back into + the build, but it doesn't appear to work. The failure has been + traced to the snprintf code being compiled for ARM. It may be + the first code executed in THUMB, so perhaps this is simply + something wrong with the thumb code in general. + + o Exception vectors. It would be helpful to enable exception + vectors on the platform so that we can debug some conditions + that trap. This may require that we put those vectors into the + first portion of the APEX image and use the MMU to map them into + the proper place in RAM. Alternatively, we could put the + exception vectors (aligned) anywhere in the APEX image and map + those. The advantage of the first is that we *can* have + exception vectors without the MMU if NOR flash maps to 0. + + o 2008.nov.9 + + o Detecting SATA. Absent SATA drives must not break the ATA + driver. + + o dump command. The ASCII output doesn't change byte order with + the hex output data. So, in the case of a little-endian dump, + the ASCII ordering doesn't change when displaying words. This + may be incorrect. It should be compared with other kinds of hex + dumps. + + o 2008.nov.2 + + o Feroceon. The ARM site claims that the 88F5182 is an ARMV5TE + which is true, sort of. It is really an ARM926EJS and is better + described by that reference when attempting to locate the + correct CP15 instructions to use. + + o Revising the CP15 commands. It might be better to organize the + cp15 commands such that each ARM processor class has a header. + So, we'd have one each for the arm720, arm920, arm926, xscale, + feroceon, and so on. There seem to be some differences at this + level that aren't well categorized by the armv4, armv5, and so + on. The best thing would be to allow for stable implementations + of routines that *could* be the same, but could also change per + ARM implementation. If for no other reason than the Linux + kernel has organized the code that way. + + The primary reason to look at it this way is to define + functions, as Linux does, to perform specific operations instead + of giving macros for every CP15 operation. In this way, we can + maintain the necessary balance between flexibility and accurate + implementation. + + o 2008.nov.1 + + o mv2120 + + o Kernel wont' boot. Need to look at the booting code in uboot + to see what they're doing before the pass control to the kernel. + o Environment. Need to place an environment for APEX into flash + so that we can customize it once the system is running. We + can probably get away with a simple default, but I know we'll + want to be able to modify it once the system is running. + o MMU makes the IO much faster, but the cmd-reset doesn't work + any more. Not sure why since none of the peripherals would + work if the caching were broken...I thought. + + o Timing with newly formatted ext3 partition. The second set of + numbers in parenthesis comes from enabling the MMU and cache + in APEX. + uboot ext2load apex copy apex im lo + uImage 35s 4s (2s) 8s (2s) + uImage-big 111s 9s (3s) 22s (3s) + + + o generic ata driver. + + There are a lot of details to get right in order to let this + driver be sufficiently generic to be useful. The old CF driver + has a lot of LH7 specific hacks to deal with the peculiar + interface of the Logic brand dev boards. + + We'll have to let the platform customize the accessor functions + adequately to enable alignment of the IO and to deal with the odd + cases such as device select. + + There needs to be an is_present() function call that will + identify whether or not the drive is present. The read call may + need to be able to error out if the device is absent. + + The region/path code needs to permit an extra indicator of the + channel and, god forbid, the controller. I don't want to get + too crazy with this, but it could be helpful. + + The driver should support an info call so that report code can + say something about the underlying device support. This may be + too much to ask, however. + + o 2008.sep.14 + o Zero-length region. It may be useful to add state to the + descriptor_d that annotates a region that had no defined + length. The image handling code passes a flag to this effect + and some of the commands check for zero-length regions before + modifying the length to ... + + o 2008.sep.11 + o Images are working. There is an open issue dealing with a source + image that overlaps the target memory region. At the moment, we + don't handle this case at all. Relocating the source image is a + substantial task and may not very general purpose considering + that APEX doesn't attempt to grasp the overall memory map of the + system. Finally, APEX is designed to not require that images be + copied to RAM before being loaded. It much more efficient to + load/check images as they are being read from the source. + + o 2008.aug.27 + o The setenv command should be able to cope with a bad flash + environment region by letting the user set variables in the + memory copy. The user wouldn't be able to save, but variables + could be set. The trouble is that erasing the flash doesn't + clear the error in the environment being unwritable. Perhaps we + need a status which is unsaveable. + + o 2008.aug.18 + o Memtest would be nice to protect the user from testing invalid + memory. We could add a -f switch to force any address, but + normally protect the user from invalid RAM addresses. + o It would be handy if we could add a check to the build process + to make sure that a particular symbol is smaller than a known + value. This would make it possible to detect when the bootstrap + is too long, and therefore, unable to execute because it will + not be available in RAM when it needs to be. + + o 2008.jul.9 + o Fixed ext2 to use inode_size. + o BUG: found that the region ext2://3/file@100 doesn't work. + + o 2008.aug.24 + o We have added environment variables for the ramdisk, but there + is a redundancy. The length is represented in the source region + as well as the variable for the size. It would be ideal if the + source region simple referred to the size and it was expanded when + the region is referenced. We may live with the redundance for a + while. + o It would be good to merge the environment and the aliases into a + single environment. Doing so requires that we allow the program + and user to distinguish between immediately saved environment + variables and the transient ones, like aliases. Moreover, it + should be possible to distinguish which variables cannot be + saved, e.g. the $apex or the $variation. Also, we should start + allowing the user to save to the environment even if there isn't + a environment variable struct. + + o 2008.jun.27 + + o New Kbuild + o basic operation works + o Need packaging and _config target support + o Ian asked for a background task (service ()) invocation implementation + o Ian asked for peek/poke + - Need to fix ext2 driver bug (done) + o Should look into orion port to fix performance issue on boot + o Should add u-boot image support, probably as a driver + + o 2008.mar.19 + + o Discovered that there is a bug in the ext2 driver. A filesystem + with deletect files and directories doesn't show up correctly. + + o 2007.jul.23 + o UBOOT annoyances + o flash info shows addresses; flash erase uses block numbers, WTF + o No type ahead, command line editing, or history + o units conversion is vague, hex numbers don't need 0x prefix + o No measurable progress long-running commands, just spinner + o help is vague. bootm, for example, claims that there could be + more than two arguments, but that isn't really the case. + o Allowing enter to redo a previous command is dangerous and + annoying since there is no ability to cancel a command while + it executes. + o Multiple code paths for common functions. e.g. booting linux + has more than one code path and the ARM path doesn't include a + ramdisk + o image format has data in it that doesn't belong there. The + load address for a ramdisk isn't really the purview of the + ramdisk creator but the boot loader. Moreover, since uboot + won't load a ramdisk as part of the bootm command, we have to + do it by hand. what is the point of the header? + o Rampant #ifdef's based on the targets. There is code in the + arm specific Linux command for several different targets to + copy the ramdisk to RAM. This makes for very poor + maintainability. + + o 2007.jul.22 + o Slug is having problems at 128MiB of RAM + o we could use a memory test command, just for grins. The code + is there but there is no command. This also requires us to + have a way to determine where APEX memory resides. + o Fix the memscan command to not be destructive. + + o 2007.jun.5 + o checksum verification. + o Use cases include copy to flash with checksum. + copy from xmodem to memory and then to flash. + Copy from running version to flash. + o What do we do if there is already a checksum? Can we detect + it? Should this be automatic in the copy? Probably a good + idea because we make sure there are no errors anywhere. Note + that we would need to leave space after the binary for this, + for APEX. + o One of the problems is that we need to have a checksum on the + checksum block if there is anything more than a simple + checksum and length there. We don't want data that cannot be + verified. For example, if there is a date, we want to know + that the date is correct. + o If a checksum is appended to APEX, it will be stored as part + of any load, xreceive or tftp, but it won't be included as + part of the $apex variable. + o If the block is aligned, we should make this alignment + relatively small. + + | CRC-PAYLOAD | LENGTH-PAYLOAD | CRC-DATA | TIMESTAMP | DESCRIPTION | + + o Seems like this block should be aligned to a 16 byte + boundary. The timestamp is a 32 bit UNIX date. CRC-DATA is + the same CRC algorithm run on the timestamp and description. + o What happens when we have a file with a checksum and we want + to verify it with cksum? We cannot verify an image if there + is our trailer already there. Perhaps not a problem. + o The above format gives 16 bytes for a description, not null + terminated. + o The version can be determined by the size of the block for + which the the CRC matches. Clumsy, but we don't waste bits on + something redundant. + + o 2007.jun.3 + o GCC 4.x and EABI. The missing function is __aeabi_uidivmod. + Check the kernel. + o Fixed. We can link with AEABI. + + o 2007.jun.1 + o It is possible to modify the environment s.t. the startup + commands prevent the system from booting. Very bad. We may + want a way out, e.g. ^C at startup (or another key) to disable + startup commands. + + o 2007.may.26 + o CRC revisited + o I've discovered why the CRC code is having problems. + o The apparently popular implementation isn't exactly compliant + with the standards. It does compute a CRC, but it doesn't do + it in the same manner as the cksum program. + o there is likely to be little reason to stick with their + implementation as it doesn't yield smaller or faster code. + o We need to decide if we want to + a) use a header for the CRC, or at a minimum, a header to + define that there is a CRC. + b) this header couple include room for a jump, 1 ARM instruction + c) or we can use a trailer. Trouble with a trailer is that + the cksum program cannot be used directly to append this. + d) use a magic number anywhere to cope with finding the + checksum. + e) trailer/header could be a 16 byte structure. Perhaps more. + f) could fall back on uboot header, but disinclined due to + excessive complexity. + + o 2007.may.19 + + o Would be neato to support uImages. I don't *like* the idea, but + it could be kinda handy. + + o Need to implement multiple checksum algorithms so that we can + compare easily. For example, the chksum algorithm, while + inappropriate for our stream checksum needs, is good for + comparing with an offline copy. + + o Need to revise the CRC algorithm to comply with POSIX.2 + standard. Here's the text from a web page describing the + algorithm. Note that the polynomial is the same as the CRC32 + polynomial used by Ethernet. ... on second thought, I cannot use + this algorithm because it depends on the length of the message + and there is no way for me to compute this in a stream. + Perhaps, I'm better off using the exact algorithm in the Ethernet + standard. + + The default CRC used is based on the polynomial used for CRC error + check-checking ing in the networking standard ISO/IEC + 8802-3:1989. The CRC checksum encoding is defined by the + generating polynomial: + + G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1 + + Mathematically, the CRC value corresponding to a given file is + defined by the following procedure: + + The n bits to be evaluated are considered to be the + coefficients of a mod 2 polynomial M(x) of degree n-1. + These n bits are the bits from the file, with the most + significant bit being the most significant bit + of the first octet of the file and the last bit being the + least significant bit of the last octet, padded with zero + bits (if necessary) to achieve an integral number of + octets, followed by one or more octets representing the + length of the file as a binary value, least significant + octet first. The smallest number of octets capable of + representing this integer are used. + + M(x) is multiplied by x^32 (i.e., shifted left 32 bits) and + divided by G(x) using mod 2 division, producing a remainder + R(x) of degree <= 31. + + The coefficients of R(x) are considered to be a 32-bit + sequence. + + The bit sequence is complemented and the result is the CRC. + + o 2007.may.17 + + o NAND flash driver rectification + o Need to resolve how we determine page size and addressing when + we are relocating + o Need to determine how best to handle early relocation wrt page + size and addressing. + o The lookup table is nice, I suppose, but I'd rather work out + either a config method or a way to decode the size that is + uniform. + o CRC on copies + o It should be possible to compute the CRC of a block of data + s.t. we store the image followed by the CRC and we are safe to + copy until the crc goes to zero. + o This was confirmed by Abdul as he's done it. + o This would allow us to do something like + copy nand:0+* $bootaddr + where the * means copy until we find that the CRC has been + met. + o May need to revise the syntax so that we know the upper limit. + copy nand:0+2m* $bootaddr + This way we know to copy no more than 2m, but report an error + if we get to the end of the block and the CRC fails. + + o 2007.may.13 + + o Need to regularize the configuration options. For example, the + VMA is an APEX parameters, not a platform parameter. We want + the configuration options to relfect the most logical placement + so that we don't have redundant entries. + o Thus, APEX_VMA, KERNEL_LMA, USE_RAMDISK... + o We want to support SRAM or other early RAM access. The most + logical way to do this is to have a region where this can + happen. Trouble is, it either needs to be required, or not. + Moreover, it could be SDRAM once SDRAM is initialized. Need to + think more about this. Perhaps the best way is to locate the + stack at the 'correct' location after SDRAM is available. + o We should move APEX up some in memory so that we can support + larger kernels, 4 MiB, at least. + + o 2007.may.12 + o We want to make it a requirement that there be a stack when we + call apex_relocate(). These functions are notoriously finicky + and we'd be well served to allow for a stack to accomodate + register spills and more complex code. It would also normalize + the MMC boot process where we needed to allocate a boot stack + for exactly that purpose. It could even be the case that this + is a configuration time parameter and that it is setup + automatically just before the relocation routine begins. In + this case, it may be desirable to explain to the user how this + stack is used and how it must be in a region of memory that + cannot be clobbered. + o APEX has gotten kinda large. Even when the small option is + selected, the loader seems to be swollen. It could be that this + is partially due to the explicitly large initialization code for + the mx31 target (which gave an APEX of 27k at the smallest). It + seems reasonable that an APEX, free of any drivers, be less than + 16K. It may be the case that thumb support will be the only way + to get a truly small loader. + o It would be good to have a way to generate a BDI init code-let + so that we can initialize SDRAM (and such) for the user using + the BDI capability for running code directly on startup. In + fact, it may be possible to do this with a special build. Whoa. + + o 2007.may.11 + o Need to move *all* configurable parameters to the Kconfig. + o Need to move bootstrap into segments so that we can properly + initialize when we don't have access to a stack. + o Should allow the initialization code, after SDRAM init, to setup + an early stack. It could even be the _correct_ stack address + since we don't really care. This may make some portions of the + code *much* easier to handle. + + o RedBoot and APEX + + In debugging an update to APEX, I found that the startup copy + commands would tend to fail. The copy would have some garbage + in the middle of the destination: 0x632b0, 0x63f00, 0x638c0 when + copying the kernel to 0x8000. + + Changing the kernel command line to *not* use variables for the + copy source and destination appeared to fix the problem, but that + wasn't a very satisfying solution. Looking at those memory + location from RedBoot revealed that the contents of memory at thos + locations appeared to come from the contents that were there when + RedBoot was running. It was easy to detect the error by + performing a checksum. Oddly, a second copy of the data was + always successful. I suspected the cache. + + Revising the cache flush code to more closely match that which the + kernel implemented didn't seem to fix the problem. What did + seem to fix the problem was disconnecting the Ethernet cable from + the Slug while booting. Thus, I suspect that the problem is + caused by the NPE still thinking it can write to memory. + + Really, this is probably never going to be a problem since RedBoot + ought to normally disable the MMU and caches before executing the + second stage boot loader (or kernel) and I suspect that this + oddity won't occur under normal use. + + o Support for non-ARM + + o The biggest hurdle to supporting non-ARM architectures will be + the implicit dependence on stack-free procedure calls. + o Some platforms, such as PowerPC, may have SRAM that can be used + for a stack until SDRAM is initialized. + o It may be feasible to rework the initialize_platform code to run + inline instead of using calls. Really, there isn't much that + must be done from the standpoint of execution. + o x86 is the real bear, but I don't think we really care about + that. + o *** Note that these considerations should be accomodated once we + change a) to a single code stream for the initialization (which + is nearly there in May 2007) and b) to add an early stack to the + configuration. Even x86 ought to work under these + circumstances. + + o Enviroinment/alias variations. The default state is to use the + simply named version of each variable, aliases before environment + variables. If 'variation' is defined among the aliases, it is + appended to the variable name and that one is checked first. If + that one is found, it is used. Otherwise, the default is used. + + For example, when variation is "-1", "boot-1" would be used to + boot the kernel. + + This new feature requires support in two ways. First, we need + another standard environment variable to hold the boot preparation + commands, "setup". So, "startup" is called first. It may set + "variation". Then APEX calls "setup". Setting the variation will + can change *all* variable references including driver regions. + So, for example, the variation can be used to set the underlying + partition for booting simply by changing the base device. This + can also be used to change some other environment variable used as + a reference elsewhere. + + Now, we need a command, platform specific, that determine the + variation and sets the appropriate alias. It would be put into + the startup command: "check-variation", "query-variation", + "select", "survey". On nslu2, for example, it would check whether + or not the reset button is pressed. If so, it would set variation + to '-alt'. Perhaps the suffix is part of the command. At this + point, the boot would proceeed normally. + + o Very slow environment region means that an empty environment makes + the boot-time very slow. So, we should check it once and if it is + empty we can assume it is still empty when the first word is + 0xffffffff. + + o Add option to change the write throughput spinner for the NOR + driver. The lh7a404 is much faster that the lh7952x's and the + spinner should reflect this. + + o Alignment trap handler would be a good thing. + o We could catch errors instead of failing completely. + o Not worth too much code. + + o descriptor_d.width + o annotates a descriptor, telling the driver what width the caller + would like used. + o Force 1 byte width for CF interfaces. + o Force 2 byte width for 16 bit only access + o Force 4 byte width for unforgiving CPU registers, e.g. IXP + o This needs to propagate to dump and fill so that we can control + the access to some regions. + o We could annotate memory, for a given target, so that the memory + driver does the right thing. + + o Need to fix the envmagic script because it it a significant + portion of the time it takes to build on the nslu2. + + o Driver enhacements + + o Query infrastructure. There presently isn't a way to ask a + driver anything. A query infrastructure could help, but it must + be very light weight. + o Query for the base address. This would be used to convert FIS + regions into nor: regions. At the moment, FIS regions are + mapped to mem: regions which means two things. First, it is + possible that the flash is not in READARRAY state. This turns + out not to be true, but it *could* be. Second, we cannot write + or erase the FIS partition which would be a convenience. Having + a way to query the start of flash would mean that we could + return a valid nor: region. + o Query for block size. This would allow us to detect erases + operations that don't request erasure of the whole block. This + would allow a safe environment erase function, or perhaps a flag + to the erase function to handle this case. + + o Must implement safe flash region erase. Must must must. (see above) + + o We've implemented alias/environment variables for the block + drivers for the filesystem and partition drivers. This may mean + that we need to move these drivers such that the init's follow the + environment initialization. At the moment, this isn't the case + since none of them do anything at init time. + + o Implement uniform driver basis in environment. There is no reason + not to use an environment variable for the default driver for each + of the higher level drivers. This means we can, for now, + circumvent the need for layering drivers with regions. Also, this + will make it more obvious to the user how to change the underlying + driver for each of those systems. *And* we can then create a DOS + partition driver....maybe. + o Environment/alias part is done. + + o Document that the initrd= command line option can be used to setup + the ramdisk location. Unfortunately, the parser may not handle + hexadecimal. Need to check on that. It's 'initrd=start,size'. + + o SD/MMC driver doesn't have timer_fetch() function because it + hasn't been initialized and the functions aren't in .bootstrap. + It might be worthwhile making this work. + o Add a 'show' function so that we can 'show drivers' and 'show + services' and maybe other things. + + o Support for arrow keys + o I believe that the only hitch is that we need to cope with the + multi-byte-ness of the codes. + o Perhaps a simple state machine will do. + ESC [ A + o The [ will be suppressed as will the next character. + + o If the loader is small, the relocation code performs adequately. + I haven't measured the performance, but it seem to be reasonably + quick to start. + + However, if the loader were substantially larger because, say, it + included a splash image, we would probably want to do something + about the relocation routine. + + The easiest thing to do is to allow for the instruction cache to + be enabled early, before there are MMU tables. This is OK for the + ARM7/ARM9 AFAICT because it assumes linear memory mapping *and* + the relocate inner loop is a simple four (or so) instruction + fragment. + + There is more, though. It may be desirable to enable the + instruction cache while uncompressing the kernel. I suspect that + the gzip decompression would be noticeably faster with the + instruction cache. However, we don't know if the kernel will + tolerate the presence of the I-cache once it boots. + + o There is now code to do so, but it doesn't appear to make a + different on the ARM9. + + o Copying from TFTP doesn't reliably finish. The transfer tends to + halt, either after no blocks, or one block. We need to diagnose + the nature of the failure and either implement a retry, or come up + with a method to restart the operation. For example, it could be + that we restart transparently so that we can see to the place + where we are attempting to read. + + o The envmagic is weak. If a variable isn't defined for a given + configuration, but it exists elsewhere in the code, the magic + number will be the same when thay variable is added to the + configuration. So, either we insert the string into the + environment, or ... I don't have another plan except to ignore the + problem. + + o arp_resolve returns a string. It should be able to return an + error condition. This means that a ^C will terminate the ARP, but + it won't tell the user that that is the reason. + + o Command history. + + o Should be easy to implement + o Ring buffer of strings. + o Say, 4k + o Each line is entered as a null terminated line of text followed + by a word aligned length. + o There is a pointer to the next available position in the buffer. + o Previous command is found by back tracing until the length of + the previous command is zero or the length bypasses the pointer + to the next available space in the buffer. + + Implemented + + o There is an error in the dump code. It doesn't dump the CLCD + registers correctly. This is not excusable. + + o Improving network responsiveness + + o Since there is a limited number of receive buffers, we may need + to change the structure of the network protocol drivers + o Need a flush function to flush receive buffers. + o RARP is a good example. The response from the server is nearly + immediate. If we don't clear the buffer, it may take a timeout + and retransmission to see the reply + o Still, need to inspect the network traffic to make sure this is + the reason for the delay on rarp. + + o May need to wait for the link to come up before sending the + network configuration packets. Don't know, but we've added the + flush before sending the rarp packets and it still takes a while + for rarp to respond. + + o Interrupt key + + o There are places, especially in the network code, where console + activity will cancel the operation. Trouble is that we don't + want it to be overly sensitive. It would be good to have some + defined keystrokes for for break and cancel. ESC isn't a good + choice because we're like to be able to use arrows at some + point. ^C is better. + + Implemented in the console code. + o We can probably get away with a Kconfig option and no UI to + change it. + + o emac-lh79524 + o Looks like there is a problem transmitting when packets are + received. + o Need to get a better picture of the network traffic. ethereal + shows that tftp is fine in a full-duplex switch situation. + o In half-duplex as I have, there are lots of problems + transmitting when there is traffic on the wire. Need to + instrument. + o BTW, the SMC91x has no problem with this. In fact, as far as I + can tell it always handles retransmits flawlessly. + o Actually, the problem appears to be that the emac is easily + overwhelmed by packets when in promiscuous mode. By eliminating + the CPYFRM bit, it seems to be stable with tftp receives. + + o Network traffic, continued + o I've created an ethernet_service function with a user supplied + termination function. + o The user can let the receives continue until an arbtrary set of + conditions are met. + o The only pieces missing is a way to hook the receive so that the + user's function can gain access to inbound packets. + o Simplicity. Needs to work for internal features as well as + external ones. For example, rarp packats should not be in the + core since the user may never care about them. + o We can simplify by eliminating the interface, for now. + o register_ethernet_frame_receiver(receiver, priority) Either a + static array (which I like) of limited length, or a linked list. + Latter requires some sort of memory management, ew. + o int frame_receiver (frame), returns zero if the packet should + continue to be checked, non-zero if the packet has been + received and there is no reason to continue processing. + o There can be receivers for icmp, rarp, and arp built in. We can + hook dhcp. + o The receivers must agree to be efficient. + o We may want to engineer the drivers to be able to cache a couple + of packets. + o Here's what we need to do. Ethernet receive should do some + cursory checks, verify that the MAC address is interesting and + the IP address is relevent when there is an IP header. After + that, the receivers can be used to handle the rest of the + verification. + o We need a port allocator with a somewhat random initial value. + If that isn't possible, we should at least be able to count up. + + o Note that none of this really helps with multiple consoles. We + still need to eliminate statics and there must be a want to + efficiently execute more than one thread. Remember that the + SSEM did this, but it has select. Perhaps we should do the + same. Hmm. + + o Network traffic state machine + o We've been able to keep this application simple since there has + been only one thread of execution and one task + o Network changes all of that + o telnet sessions will also make it necessary to be more flexible + o Need to have threads of execution + o Network packets can be queued to a thread + o I think we can have a function that handles network traffic in a + polled fashion, dispatching ICMP and ARP, if we choose, and has + a couple of terminating conditions: receipt of a relevent packet + or a timeout. + o Trouble is that we may receive a packet and be busy elsewhere. + o We can service the network connection in some fashion while we + do other work, but we may need to queue packets for processing + since the network interface has limited capability for buffering. + o Perhaps this packet queue can be limited to the network, for + now. + o It would be good to think ahead here. Can we add logic to the + network layer so that we can queue packets intelligently and + process them when the time comes. For instance, we register + discriminator functions for each task that can deal with network + traffic. Discriminators perform the queuing themselves. There + comes a time, later, when the discriminator can do what it likes + with the packets. It may even be the case that we do the + network logic immediately. For example, the tftp driver + registers a discriminator that can receive data packets, but it + will automatically stop when its queue is filled. The core + routine that is using the data will call the service function + when it can. If the tftp_read call is entered and there is no + data available, it will block until there is some. Essentially, + it will enter a special form of the service loop that terminates + on a timer instead of returning immediately when there is + nothing to do. + o *** How can this be generalized to handle multiple console + streams? Can it be? Can we do a round-robin for console + streams such that the separate threads of execution each get a + chance to handle command, process input, and so on? This seems + like it may be overkill for a simple monitor, but we will need + something if we start to be able to handle telnet sessions as + well as a USB console. + + o tftp write requires that we know if a descriptor is for reading or + for writing. There is nothing in the interfaces to support this at + the moment. Either we cache the file-open data, or we let it all + be lazy and perform the open when the first read or write call is + made. + + Reading works fine at the moment. + + o descriptors really need to allow drivers to define a + context. tftp is probably the most compelling case for + this...especially once we've opened the connection and we need to + keep track of the open file. Alternatively, we can continue to do + as we've pleased which is to use a driver global. Ho hum. + + o The filesystem drivers don't say enough about where they get their + source devices. Perhaps it would be best to use aliases so that + we can control it at runtime. + + o The adc test driver needs to be able to check for touch events. + + o Do we want to be able to show all variables, env and aliases in + the same command? + + o ipconf command + o ipconf rarp + o ipconf dhcp + o ipconf boot + o ipconf 192.168.8.203/24 + o ipconf clear + + This will make it clearer to users how to clobber the + configuration. Also, we may be able to enforce reconfiguration + this way. + + * There are two copies of the adc driver, one in the 7952x directory + and another in the 7a40x directory. I'd like to reduce the + redundancy, but that would require moving the driver to be outside + of mach-*/. Either make a mach-lh/ or put them in drivers/. The + trouble is that I need a way to make sure that...Perhaps I should + have a drivers-lh/ for shared drivers specific to Sharp products. + That way, I can make it clear. + * Done and it's nice. + + o We've added RARP which can configure the IP address. There is a + problem, tho. The user can get the IP address from the alias + list. If the user clobbers it, the host_ip_address isn't + clobbered. The user might think that erasing the alias removes + the IP address setting. We need to either detect the loss of the + alias, or we need to no store the IP address in an array. + + o Need a default command line setting in the config file. It should + completely override the platform default, when present. + + o Pipes should work for streaming between drivers. [g2] wants to be + able to specify a list of drivers/regions to try. This may mean + I'll have to combine the parse and the open methods so that the + open can continue until it succeeds. + E.g. nor:128k+1m|(ext2,vfat):/boot/zImage + Trouble ensues when the options are more complex, NxM. + * Aliases can be simple text substitutions. + alias flpart nor:128k+1m + alias kernel /boot/zImage + flpart|(ext2,vfat):kernel + * Done. Substitution is with $. + o The splashscreen should be able to be read from a filesystem + copy ext2:/boot/splash fb: + This will also require that we be able to store an image in the + loader and copy it out. Aliases make this possible + alias splashimage ... + + We have a splash command that reads from a region but doesn't + write to one. In other words, we *could* do as suggested, but + there isn't much reason for it from the POV of simplicity. + o Aliases mean we can have references to + alias env nor:128k+32k + alias apex mem:... + aliases must match exactly. Always. I'd like to make the + environment alias be environment, but partial alias matches might be + too much of a strain. Perhaps near matches are OK if there are + no other near matches. + o It looks like there is a conflict with using the name ./config for + the configuration file and all of the config targets. I believe + this to be due to hidden dependencies within make. Bad make. So, + we're going to go back to the .config files for now. I'd use + conf, but that is the name of the configuration program. It may + take some time to sort this out and make it neat. + + o There is a need to be able to control the access width in the + memory driver. Sometimes, for the purpose of debugging, it is + helpful to be able to read different widths. The memcpy command + is probably too coarse in some cases as is evidenced by the fact + that dumping from the CF flash region on the 79520 does the wrong + thing. + o I believe the problem really has to do with the chip select + issue. Without reads from system memory, the chip select + doesn't toggle and the CF fails to return a different memory + location. Thus the real problem is that the memcpy performs too + many transfers at one time. + o Finally, I don't know what the right solution to the problem + should be. + o Dump could be made to do the right thing with a switch to read + only one byte (or word) at a time. This is probably desirable + anyway since we could use a mode to display words or + half-words instead of just bytes. + + o It might be helpful to make the envmagic script more repeatable. + Need to look into this. Seems like it changes when there are no + changes to the environment variables. + + o An erase confirmation might be helpful, but it requires that the + driver participate. It would be helpful to tell the user exactly + what will be erased. Note that BDI doesn't, and I don't think + that other bootloaders do. Still, it would be helpful to let the + user know what the erase is going to do. + + o Separate the string functions so that the linker can include only + those that are needed. + + Done. + + o I think that the partition logic needs to move to the CF driver + (and other block-level drivers) so that the filesystem code can be + cleaner. It allows us to read from unpartitioned devices as well + as any other random-access, byte stream. + o This change will require that the spec strings are filled out to + handle chaining. We would do fatfs->dospart->cf. Might seem + heavy-weight, but it means reasonable flexibility. It ought not + be much code and the calls can be handled with simple + pass-through in the case of read(). + + o Looks like the ADC test driver may interfere with the kernel + booting properly. First I've seen of it. It's OK, though, since + we don't need it. + + o Might be good to have a paranoid setting that lets us require + confirmation before clobbering flash or eeproms or whatever. This + could be a list of important regions. The region list could be + bothersome since there is aliasing unless it is specific to the + driver that can clobber it. Then again, not. Since writing has + to go through the driver that understands the true addressing. It + means that we have to protect nor:#+# for flash and cannot depend + on mem:#+# to be recognized as being the same. + + o Buried region strings must be revealed. The emac driver has one + for the MAC address EEPROM. The fatfs driver has one for the + underlying block device. The latter may be best revealed with an + environment variable...or not. Don't know about the emac one. + I intend thay the user specify the fatfs support driver via the + specification string. fatfs:cf: or something. + + o Need to rectify the vpen_enable code in the flash drivers. It + ought to be something defined in the hardware file s.t. it is not + compiled unless needed. IIRC, it was smaller to put the vpen code + into functions than to put it inline. However, it is easier to + code if it can be inlined. Hmm. + + o Would be nice if ^C could break into long-running functions. + Could be dangerous, though, e.g. writing to flash. More thought + needed. + + Supported and implemented in several places. + + o I am suspicious that the nor-cfi erase code isn't quite right. + When asked to erase nor:0+120k, I think it erased the block at + nor:120k. + + o Checksum function doesn't appear to work over FAT read files. It + needs to clever about summing in the case that the descriptor + itself knows the length. + + I believe this is fixed. + + o Wonder if I need to do a shutdown before performing reset s.t. I + can put the NOR flash in the right state. This might be why reset + sometimes fails. + + o Add a -v option to copy to make sure the copy is successful. + + o There ought to be a target to release that increments the version + number, makes an SVN copy, and pushed the code to the ftp server. + o Part of this is done. + + o I'd like to mode the CROSS_COMPILER assignment to the + configuration file *and* allow the user to override it. The ?= + operator isn't working for some reason. I'll leave it for now. + + o Again, need to add an info function. It can be used to get info + from a driver or to look at a directory listing from FAT. This + idea isn't quite complete. It would be good to combine the driver + info stuff with this function in a way that the command + 'describes' a descriptor. Thus, a descriptor for an exact file + shows the file info. A descriptor for a directory lists the + directory. A descriptor for a driver describes that driver. + + Implemented the ability to read directory contents...except for + fatfs. + + o The default length for descriptors needs to be thought out. If we + set the default length to the greatest length available, then we + run into trouble with dump. We could communicate something about + the use to the open call such that the driver knows if it needs to + set a default length. Or we could let the user do something + interesting such as giving a @+. to indicate that the maximum + length should be used. The problem is one of use. In files, the + default length is usually going to be the whole file. In memory + regions, the default length is OK where it is. I think it is best + to add a more mode to dump and let lengths be maximal on files. + Also, we might need a way to cancel some commands that run awry + because of the (possibly) excessive elength. + + o It would be good to add a checksum function that can be compared + to a command line tool. MD5 or SHA1. We want something that can + be small, though. Grrr. We could also write a utility that can + do the same checksum on the UNIX command line. + o Yipee! The cksfv program does the right thing. + o Add to the documentation that the cksfv program can be used to + compare checksums. + + o Need a function like ls or info that can list the contents of a + directory or give data on a device. Perhaps we can overload the + info function to allow a complete descriptor instead of just a + driver. Not a bad idea. This, then because a function of a + driver to allow a describe, info, catalog, or whatever on a + descriptor. + + Implemented as info + + o It would be nice if the fat/cf interface could be smart about + detecting device changes. Trouble is, CIS info doesn't appear to + be enough. It may be possible to use the hardware to detect a + device change and propagate that upward. + o This would probably require an extra hook in the driver. + o And, it isn't necessary since we read all of the device + structures every time we perform IO. + o Although an interrupt timer could make this possible. + + o APEX prints an error when the startup command doesn't have a trailing ';' + + o We can write an erase function that can cope with erasing a + portion of a flash block. Actually, not really too hard. + o This could be used to erase the environment when it follows the + loader in the same flash block. + o This might be dangerous and, therefore, require some + precautionary words for the user. + + o Dump command needs a MORE mode. Or, we need to limit the extent + of the dump. + + o Let's add a driver alias function. + o once we get into the thick of driver-land, we may have some + cumbersome driver specs + o ls fat.mmc.spi:/ + o copy tftp.emac-1:vmlinuz mem:0x2000 + o The cascade of drivers will be necessary for the sake of + interoperation, but it might make things difficult for the user. + o So, alias fat.mmc.spi mc + o Then ls mc:/ will do the right thing. + o Cake + o Also, we may need to pass parameters to a driver. + o ls fat(1).mmc.spi:/ might be a reference to the first partition + o ls mc(1):/ would be equivalent + o I can imagine that some aliases might be generated at runtime as + defaults. I don't have specifics right now. + o This also suggests that region spec's will have a qualifier + about the compatible formats. Filespecs and memory region specs + may not be compatible. Or not. :-) + o This aliasing could be used to refer to regions. + o alias apex: is the region of memory where apex is executing + o alias env: is the region where the environment is stored. + + o The MASK_AND_SET macro I'm using used to be commented out. Well, + it was similar. I changed it a little and put it back because the + two step version make the ADC_PC register setup break. Don't know + why. Need to make sure that all of the other code is still + working. + + o driver info functions, especially memory + o I think this should be done with a service hook instead of a + driver hook so that the environment can report describe it's + descriptor. + o started. + o hook removed, switched to a service entry point + o Completed, except that it displays through the version command. + o look for more unused symbols + o Doc on XIP kernel? We *can* linux run completely from flash + o command history + + o lh7a40x + o buffered NOR write...oh boy is this needed + o Should be little else since there is only one memory device + o Not much incentive to be small with 80k of SRAM + o CONFIG_ENV_SAFE_ERASE to allow user to erase whole + environment...there is already a configuration option for this. + + o Exception vectors at the start of the loader probably don't make + sense. + o If we every enable interrupts, we won't be running this loader + from the start of addressable memory. I suppose we could, but + that hasn't been the way. The kernel needs to load at + 0xc0008000 or 32K from the start, and the parameters load at + 0xc0000100 which is even worse. Just not a good plan with + linux. + o Instead, we'll map some kind of RAM at 0, tell the CPU to map + exceptions to zero, and well write vectors there. + o This way, we can have interrupts in the loader without the MMU. + o Simple interrupts + o 32 entry function table + o irq disabled if the function is empty. + o no priorities + o partially implemented, but non-functional + + o Need to regularize the sdram and nor flash config parameters. The + arch determines some of these parameters. Config should only + enable. For example, CONFIG_SDRAM_BANK0=y and the rest comes from + the platform. Perhaps the config should specify info on the SDRAM + chip(s). + o The SDRAM part has been done. + o Problem with flash is that we probably needto continue letting + the config specify the base address. The arch does know where + flash can be, and there is one bank that is likely to always be + there if any are there (boot flash), the flash organization may + still require that we know the base addresses. Lengths really + aren't needed for CFI compliant banks. + +Goals + + o Simple structure + o Memory image may be directly written to flash + o This may be challenged by structures that have defaults and are + later modified. If we can avoid doing this, then all will be + well. + o Use of tables of pointers to handle features, commands, drivers + o Driver self-discovery when relevent + o Small image, less than 16K for basic loader + o This will be hard when using the kernel's printf + o CONFIG_SMALL helps + o Reasonably configurable at ./configure time + o Good command line support + o Code sharing among targets is *not* of the highest priority + o No assembler files + o There is some hand assembly in the start-up, but that's probably + unavoidable. + o Still, no .s files + o No external dependencies aside from a tool chain + o Staged execution (see below) + o Support for over-the-wire and NAND booting--teeny tiny bootstrap + o relocate function + o Presently, there is only one relocate supported. We may want to + let it be flexible so that the loader can be common for several + configurations. + o Multiple targets + o May execute from FLASH, XIP + o Stack storage will be required + o Automatically relocating + o This is done in the relocate_apex() routine. It's position + independent up to the point that this function executes. + Afterward, absolute symbols may be used. Note that weak + symbols, at the moment, cannot be used until after relocation. + + o IO descriptor (region): "device:path" + o "nor:@0x44000000#0x20000" + o "nand:@0#0x20000" + o "serial:xmodem", "serial:binary" + o "eeprom:" + o allows drivers to handle details of transfers + o copy "nor:@0x44000000#0x20000" to "mem:@0x20000000" + o copy "tftp://192.168.8.1/zImage" to "mem:@0x20000000" + o copy "http://192.168.8.1/zImage" to "nor:@0" + o erase "nor:@0#0x200000" + o Should support for suffixes, m,k + o Relaxed the @ requirement. memory driver is the default which + means that 1m#1k specifies 1KiB from the 1MiB boundary + + o devices are self descriptive to the extent that they can be in + terms of erase block sizes and so on + +Staged Execution + + o Essential initialization, SDRAM, memory controller, IO multiplexing + o Move loader into storage for execution, if necessary. May involve + transfer from secondary medium: serial, NAND flash, serial eeprom + o Finish hardware initialization + o Setup stack + o Clear BSS + o Command loop + +Configuration parameters + + o Initial base address (turns out not to be necessary on ARM) + o Execution base address + o Base RAM address for 4K stack, data, BSS + o Layout of SDRAM memory + +Parameters + + o APEX_STACK - Linker calculated top of stack + o APEX_VMA_START - Execution (virtual) memory address for image + o APEX_VMA_END - Linker calculated end of the execution memory image + o APEX_BSS_START - Linker calculated start of BSS region + o APEX_BSS_END - Linker calculated End of BSS region + +Symbols + + o init () - driver initialization and then loader exec () + o reset () - initial entry point + o exception_error () - function called for unused exceptions + o relocate_apex () - move loader into RAM from...whereever + o initialize_bootstrap () - pre-relocate initialization + o initialize_target () - completion of target (non-driver) initialization + o setup_c () - prepare C exection environment + o after setup_c() we can use traditional C code for the rest of + initialization + +Drivers + + o read/write, block/byte + o erase + o status/info + o init/detect -> probe() + o exit -> release() + +Basic commands + + o display + o verify + o checksum + o copy + o boot (linux kernel) + o go (arbitrary execution) + o printenv/setenv + +Sections + + o .entry - guaranteed first section. Should contain only one symbol + o .bootstrap - guaranteed to follow .entry. Smallest possible + section of code to handle bootstrap into RAM, if necessary + o .text - rest of loader code + o .init - initialization hooks, especially drivers + o .env - environment hooks + o .exit - hooks to call before leaving loader + o .cmd - command functions + o .bss - BSS + o .data - initialized data + +Configuration + + CONFIG_ARM - ARM target + CONFIG_LH7952X + CONFIG_LH79520 + CONFIG_LH79524 + CONFIG_LPD79520 + CONFIG_LPD79524 + CONFIG_LH7A40X + CONFIG_LH7A400 + CONFIG_LH7A404 + CONFIG_LPD7A400 + CONFIG_LPD7A404 + CONFIG_CONSOLE_DEVICE - Defines which serial (or other) device is console + +Kernel Build Scripts + + o The directory Makefiles may be invoked in two different situations. + Actually, only the primary one, for the architecture, is like that. + It may be included in the top-level Makefile in which case it is + used to configure how the kernel will be built. It may then be + invoked as a Makefile used to build targets in that directory. This + can be confusing when it needs to define targets that must not + override the default for the top-level Makefile. The kernel doesn't + need to worry about this, I believe, because it does not depend on + the arch/$(ARCH) directory to build a target necessary for the + vmlinux file. Instead, it only calls arch/$(ARCH)/Makefile to build + boot targets. + +Weak Symbols + + o Using weak symbols in the entry code would make it easy to replace + startup features with a platform specific implementation. Trouble + is, weak symbols cannot be called with a simple "bl" because the + compiler and linker are not going to know where the code is and may + not be confident that it will be nearby. I wonder if I can hint + that the routine must be close? + o Libraries solve this problem as can be seen with the + relocate_apex () function (NAND version). + +Code Size + + o The printf code is really big. We could probably use a smaller + printf function and save some code. It's about 4K right now. + There is a smaller version online. I'd like to review uClib before + depending on code found on the net. + +Toolchain + + o The 3.3 compiler that has worked so well for so long, seems to have + a problem with the printf() function. The call + + printf ("read done\r\n"); + + is automatically translated as puts which should be OK, except that + it doesn't copy the string correctly. The final \n is truncated + from the constant pool. Adding -fno-builtin-printf fixes the + problem. + +Glitches + + o Every now and then, the NOR flash gets wedged. Power cycling is + not enough. In this most recent case, it because corrupt and would + not accept erase commands. I sent a couple of commands to the + device, switched to the other bank, and finally unlock/erase + worked. I think it might be wise to operate the VPEN line in the + flash driver. + o I think that this might be part of a problem with writing to + flash when VPEN is enabled as we don't intend to do so. + +NOR + + o Driver is kinda big and there isn't even a write function. + o Can we aggregate some of the common driver logic, descriptors and all? + o some of this has been done with good effect + o Available and start address calc can be handled by a function for + all cases...maybe. There is a difference between blocking and + banking. Perhaps it would be good to limit all operations to + blocks so that the code can be identical in all cases. + +Environment and Startup + + o There is a single environment variable that contains a startup + command. This will be executed when the loader starts. + o done + o There is a timed delay function that will wait the specified number + of seconds (tenths) before continuing to execute the script + command line. + + copy nor:0x400000#0x100000 0x20008000 ; \ + wait 50 Automatic boot in 5 seconds ; \ + boot + + o Pressing a key will discontinue the script execution + +Spinner/Progress + + o would be nice to have a standard UI call to emit progress + feedback. Erasing, for example, takes quite a bit of time. + o done + o The performance of each driver varies. It might be handy to have a + stepping value for each driver when writing so that we can properly + scale them. Or, we could add code to insert the current byte count + into the spinner code and let it determine when to write. + +NAND Flash Drivers + + o There is a need to support the LPD method of controlling the NAND + flash as well as the Sharp method. + o The LPD method is implemented and tested. + o The Sharp method should be OK as long as we don't want to use + CompactFlash or large NOR flash. CF would be OK as long as the + implementation didn't require the A23 line as Logic does. + Refer to CONFIG_NAND_LPD. + o I am unable to erase the second flash block. I don't know if this + is a new problem, or if this has always been the case. The + datasheet gives me the impression that this is a problem with the + chip enable. + o This was a problem with the math + o relocate_apex for NAND flash + o This is finally working reliably. It really won't work without + the CPLD, but it close. + o At this point, the relocate_nand function (should) work regardless + of whether or not the board is running with a Logic style CPLD. + Kurt is not coming to my way of thinking which is that there is a + boot-up mode that mimics the Sharp method and a CPLD configurable + mode that is faster. + o Latest CPLD from Kurt works correctly in both modes. We can now + perform IO in the Sharp way and in the Logic way. Relocator + tested in both as is the drv-nand. Kernel driver is likely to be + Logic mode only for now. + +Errors + + o It might be handy to have some form of debug output available. We + have situations where the system cannot get to the prompt, but it + might be helpful to know why. For example, a system is booted + from NAND, but there is not NAND aware relocation function. + Generally, I'm OK with little error handling since it is usually + wasted space. + o DEBUG_LL + +Relocation + + o The relocation code now checks to see if it is already executing + from the target location. If so, it will return immediately. + o The relocation code, too, will not restart the loader, but must + always continue with a proper return. If we only have the NAND + relocator, then we have no way of moving the loader in SDRAM if it + has been put in SRAM or SDRAM at some random location. This may + be a shortcoming. + +Performance + + o The load time from flash to SDRAM is partially goverened by the + EMC controller setup. It may be desirable to make sure that the + EMC is optimally configured before relocate_apex. + +UART Initialization + + o It is OK to defer critical UART initializations to the serial + driver. + o However, the kernel usually expects that the UART is available + during startup and it may be possible to disable the serial driver + in APEX in order to save space. + +Interrupt Handling + + o It should be possible to catch interrupts in the boot loader. + o Most of the code is implemented (for one platform) and enabled + with CONFIG_INTERRUPTS. + o The key piece missing is that the interrupt vectors must either be + written to flash, or the MMU must be enabled so that the page with + the vectors is available at address zero. + o Untrue, we can use the RCPC to put SDRAM (or SRAM) at 0x00000000. + +Console + + o Document how to setup console on the LCD device as well as the + serial: + + console=tty0 console=ttyAM0,115200 + +Ethernet + + o There is an underlying driver interface + o send/receive ... poll? + o prefer not to have to implement interrupts for the sake of + complexity + o Protocol handler will have a discriminator? Or will there be only + one available at a time. + o Need to support multiple streams since we will eventually support + telnet. + o Select style interface will be best to handle console as well as + network streams. + o Handler will bind with some sort of discriminator. Could be a + port or protocol or perhaps a frame interpretation function. + o UI will need to support ip command + o Model after ip route + o ip addr ... + o ip link for mac addresses and replace emac? Hmm. + o Need to support DHCP at least. RARP is desirable. Bootp should + come with dhcp. + o Really, this should be simple. + + o The challenge is making something sufficiently flexible to + integrate will into apex and to give reasonable operability. + + o Telnet server + o TFTP download + o TFTP server for accessing system data, would accept descriptors + o Descriptor flow, tftp receive to a descriptor + o HTTP/FTP server should also be possible to retrieve information + about the running system. + o TCP state engine is more difficult and may be too much + + o I prefer a very simple dispatch so that there is little admin. + -> slow call structure for packet dispatch + -> polling for packets + diff --git a/README b/README new file mode 100644 index 0000000..378ff74 --- /dev/null +++ b/README @@ -0,0 +1,140 @@ +=========================== + APEX Boot Loader + Release Notes & Quickstart +=========================== + +The APEX boot loader has been designed to be small, efficient, and +easy to extend. It uses some code and the build system from the Linux +kernel. There are pieces of code taken from BLOB and UBoot as well. + + + Newer Versions of APEX + ---------------------- + +There is an ftp archive of APEX releases. + + + +There is also a wiki with information about APEX. + + + + + Supported Targets + ----------------- + +The loader is fully functional for the LPD79524, LPD7A400, LPD7A404, +IXP42X. It builds for the LPD79520, but there is presently no version +of the Linux kernel that recognizes the correct architecture number. +APEX also builds for the MX31 and the S3C2410. + + + Building APEX + ------------- + +The config file has an option to define cross-compiler prefix. It +must be set unless you are building on an ARM host platform. For +example, + + CROSS_COMPILE=/usr/arm-linux/gcc-3.4.1-glibc-2.3.3/bin/arm-linux- + +The cross compiler may also be set in the environment or on the make +command line. Doing so will override the value set in the +configuration file. + + make CROSS_COMPILE=/usr/arm-linux/gcc-3.4.1-glibc-2.3.3/bin/arm-linux- + +Development proceeds with the 3.x compilers. GCC 2.95.3 does build +APEX at a slight penalty in code size. + +Beware of GCC 2.95.3. It does not properly honor the naked function +-------------------- attribute which means that it may improperly +handle register allocation. The relocate_apex() function is +vulnerable to the problem and may cause APEX to fail. If you must use +GCC 2.95.3, make sure that there are no DEBUG_LL calls in +relocate_apex(). + +Like the Linux kernel, building APEX requires a configuration file +called '.config'. To build using the default configuration for the +LPD79524: + + # make lpd79524_config + +To change the default configuration, use one of the configuration +programs. + + # make xconfig + +APEX uses the Linux kernel build scripts so that rebuilding is as +optimal as the kernel. Changes to the configuration are automatically +propagated such that only affected source files are rebuilt. + + # make + +The ELF format binary, apex, as well as a link to the dumped apex.bin +will be put into the root directory. + + + Running APEX + ------------ + +APEX is designed to start from any address and to relocate itself when +necessary. If the binary is small enough (less than 16KiB), it may be +copied to the internal SRAM of the LH79524 and executed from there. + +Once you see the apex> prompt, the loader may be copied to flash and +the environment edited. Below is the signon message. It may be +reprinted with the 'version' command. + + apex> ver + APEX Boot Loader 1.0.6 -- Copyright (c) 2004 Marc Singer + + APEX comes with ABSOLUTELY NO WARRANTY. It is free software and you + are welcome to redistribute it under certain circumstances. + Refer to the source the COPYING for details. + + apex => mem:0x20200000#0x4a94 + env => nor:128k#64k + CPLD revision 0x5 + +The apex and env region specifications are important. The apex spec +describes where in RAM apex has been relocated as well as the exact +length of the program. The env spec describes where in flash the +environment is stored. + +Assuming that APEX needs to be the first program in NOR flash, writing +APEX to flash looks like this. + + apex> erase nor:0 + apex> copy mem:0x20200000#0x4a94 nor:0 + +The source of the copy command is the descriptor from the signon +message. Preparing the environment area is even simpler. + + apex> erase nor:128k#64k + +Again, using the information in the signon to erase the proper portion +of flash. The environment allows APEX to be customized at runtime. + + + o Bootstraping APEX with LOLO or a JTAG emulator + o Downloading the kernel using XMODEM + o Changing the startup command to copy the kernel to RAM + o Changing the kernel command line + o Changing the startup command to automatically boot the kernel + + + Checksum Compatibility + ---------------------- + +The checksum command built into APEX conforms to the POSIX.2 standard +algorithm which is also used by GNU cksum. This is not compatible +with the BSD sum command or with md5sum. + + + Getting Help + ------------ + +Beyond what is here, you can send mail directly to me, the author. + + Marc Singer diff --git a/arm-kernel-shim/ChangeLog b/arm-kernel-shim/ChangeLog new file mode 100644 index 0000000..0fa8579 --- /dev/null +++ b/arm-kernel-shim/ChangeLog @@ -0,0 +1,24 @@ +2007-02-17 Marc Singer + + * Makefile (VERSION): Rolled to 1.4 for SDR_CONFIG. + + * config.h: Suport for SDR_CONFIG change (fat slg). + +2007-02-10 Marc Singer + + * main.c (start): Added offset calc so we can copy the command + line string to the tags area. + (start): Simplified the linking and section bits so that the + program links correctly with 3.4 and 4.x compilers. + + * Makefile: Added tagging support + +2007-01-30 Marc Singer + + * Added support for BE/LE switching. + +2006-06-23 Marc Singer + + * Initial release of the shim code. It isn't tested, but it + compiles and the assembler code looks correct. + diff --git a/arm-kernel-shim/Makefile b/arm-kernel-shim/Makefile new file mode 100644 index 0000000..7c049a8 --- /dev/null +++ b/arm-kernel-shim/Makefile @@ -0,0 +1,64 @@ +# Makefile +# +# Copyright (C) 2008 Marc Singer +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# Please refer to the file debian/copyright for further details. +# + +PACKAGE:=arm-kernel-shim +VERSION:=1.5 + +CROSS_COMPILE:=/usr/arm-linux/gcc3/arm-linux- +CC=$(CROSS_COMPILE)gcc +LD=$(CROSS_COMPILE)ld +OBJCOPY=$(CROSS_COMPILE)objcopy + +CFLAGS:=-g -Os -nostartfiles -nostdlib +LDFLAGS:= -g -Ttext 0 -X -Map shim.map + +SRCS:= shim.lds main.c +OBJS:=$(SRCS:.c=.o) + +all: $(PACKAGE).bin $(PACKAGE).bin-swapped + +$(PACKAGE).bin: $(PACKAGE) + $(OBJCOPY) -O binary -R .bss -R .comment $< $@ + +$(PACKAGE).bin-swapped: $(PACKAGE).bin + cat $< | ./wordswap > $@ + +$(PACKAGE): $(OBJS) + $(LD) $(LDFLAGS) $(OBJS) -o $@ + +%.o: %.c + $(CC) -c $(CFLAGS) $< -o $@ + +%.s: %.c + $(CC) -S $(CFLAGS) $< -o $@ + + +.PHONY: clean +clean: + -rm *.o $(PACKAGE) $(PACKAGE).bin *~ *.map + +.PHONY: tag +tag: + svn cp file:///svn/tools/trunk/apex/$(PACKAGE)\ + file:///svn/tools/tags/$(PACKAGE)/$(VERSION) + +.PHONY: remove-tag +remove-tag: + svn rm file:///svn/tools/tags/$(PACKAGE)/$(VERSION) + +.PHONY: package +package: $(PACKAGE)-$(VERSION).tar.gz + +$(PACKAGE)-$(VERSION).tar.gz: + [ ! -d $(PACKAGE)-$(VERSION) ] || rm -rf $(PACKAGE)-$(VERSION) + svn export -q file:///svn/tools/tags/$(PACKAGE)/$(VERSION)\ + $(PACKAGE)-$(VERSION) + tar zcvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) + rm -rf $(PACKAGE)-$(VERSION) diff --git a/arm-kernel-shim/config.h b/arm-kernel-shim/config.h new file mode 100644 index 0000000..59a7bb0 --- /dev/null +++ b/arm-kernel-shim/config.h @@ -0,0 +1,62 @@ +/* config.h + + written by Marc Singer + 23 Jun 2006 + + Copyright (C) 2006 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + +*/ + +#if !defined (__CONFIG_H__) +# define __CONFIG_H__ + + /* CREATE_ATAGS indicates that the shim ought to build the + ATAGS list. If it is not defined, the ATAGS may be passed + by another piece of code, e.g. a boot loader. */ +#define CREATE_ATAGS /* Construct ATAGS from fields herein */ + + /* GUARANTEE_ATAG_CMDLINE makes sure that a command line is + present in the ATAGS list. If none is found, the + COMMANDLINE below is added appended to the end of the + ATAGS. */ +#define GUARANTEE_ATAG_CMDLINE + +#define PHYS_PARAMS 0x00000100 /* Address for the parameter list */ + +#define RAM_BANK0_START 0x00000000 +#define RAM_BANK0_LENGTH (32*1024*1024) + +//#define RAM_BANK1_START 0xd0000000 +//#define RAM_BANK1_LENGTH 0x10000000 + +#define INITRD_START (0x01000000) +#define INITRD_LENGTH (0x00400000) + +#define COMMANDLINE\ + "console=ttyS0,115200 rtc-x1205,probe0,0x6f noirqdebug" + +#define MACH_TYPE 999 + +/* Uncomment one of these if you need to switch the CPU into a + specific mode. */ +#define FORCE_LITTLEENDIAN +//#define FORCE_BIGENDIAN + +/* Uncomment on of these if you want to reprogram the SDRAM controller + to take advantage of memory installed, but not detected by the + primary boot loader. Also, make sure to se the RAM_BANK0_LENGTH + appropriately */ + +//#define IXP4XX_SDR_CONFIG 0x18 /* 64MiB */ +//#define IXP4XX_SDR_CONFIG 0x1c /* 128MiB */ + +#endif /* __CONFIG_H__ */ diff --git a/arm-kernel-shim/main.c b/arm-kernel-shim/main.c new file mode 100644 index 0000000..c592f34 --- /dev/null +++ b/arm-kernel-shim/main.c @@ -0,0 +1,194 @@ +/* main.c + + written by Marc Singer + 23 Jun 2006 + + Copyright (C) 2006 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + + ARM kernel bootstrap shim. + + This code may be prepended to a 2.6 Linux kernel in order to setup + the ATAGS and the machine type in the EXTREME circumstance that the + platform bootloader cannot be replaced. + + Offset + ------ + + Because we don't know where we're going to be executing, we do a + little shenanigans to figure out the execution offset. With it, we + can reference data that was fixed-up with an absolute address even + though we are not executing from that address. + + Endianness + ---------- + + This code can be used with either big or little endian kernels, and + it can be used to switch the endan-ness of the system from the + boot-up default to the desired orientation for the kernel. + However, you must swap the bytes of this file and the kernel if you + are going to write this data to flash. + +*/ + +#define __KERNEL__ + +#include "config.h" +#include "types.h" /* include/asm-arm/types.h */ +#include "setup.h" /* include/asm-arm/setup.h */ + +#define NAKED __attribute__((naked)) +#define BOOT __attribute__((section(".boot"))) + +#if defined (COMMANDLINE) +const char cmdline[] = COMMANDLINE; +#endif + + +void NAKED BOOT boot (u32 r0, u32 r1, u32 r2) +{ + __asm volatile ("nop"); /* Require to get compiler to jump here */ +} + +int NAKED start (void) +{ + struct tag* p; + extern unsigned long reloc; + unsigned long offset = (unsigned long) &reloc; + +#if defined (FORCE_BIGENDIAN) + + { + unsigned long v; + __asm volatile ("mrc p15, 0, %0, c1, c0, 0\n\t" + "orr %0, %0, #(1<<7)\n\t" /* Switch to bigendian */ + "mcr p15, 0, %0, c1, c0, 0" : "=&r" (v)); + } +#endif + +#if defined (FORCE_LITTLEENDIAN) + + { + unsigned long v; + __asm volatile ("mrc p15, 0, %0, c1, c0, 0\n\t" + "bic %0, %0, #(1<<7)\n\t" /* Switch to littleendian */ + "mcr p15, 0, %0, c1, c0, 0" : "=&r" (v)); + } +#endif + + __asm volatile ("bl reloc\n\t" + "reloc: sub %0, lr, %0\n\t" + ".globl reloc\n\t" + : "+r" (offset) + :: "lr", "cc"); + +#if defined (IXP4XX_SDR_CONFIG) + *(volatile unsigned long*) 0xcc000000 = IXP4XX_SDR_CONFIG; +#endif + +#if defined (CREATE_ATAGS) && defined (PHYS_PARAMS) + p = (struct tag*) PHYS_PARAMS; + + /* Always start with the CORE tag */ + p->hdr.tag = ATAG_CORE; + p->hdr.size = tag_size (tag_core); + p->u.core.flags = 0; + p->u.core.pagesize = 0; + p->u.core.rootdev = 0; + p = tag_next (p); + + /* Memory tags are always second */ + p->hdr.tag = ATAG_MEM; + p->hdr.size = tag_size (tag_mem32); + p->u.mem.size = RAM_BANK0_LENGTH; + p->u.mem.start = RAM_BANK0_START; + p = tag_next (p); + +# if defined (RAM_BANK1_START) + p->hdr.tag = ATAG_MEM; + p->hdr.size = tag_size (tag_mem32); + p->u.mem.size = RAM_BANK1_LENGTH; + p->u.mem.start = RAM_BANK1_START; + p = tag_next (p); +# endif + +# if defined (INITRD_START) + p->hdr.tag = ATAG_INITRD2; + p->hdr.size = tag_size (tag_initrd); + p->u.initrd.start = INITRD_START; + p->u.initrd.size = INITRD_LENGTH; + p = tag_next (p); +# endif + + /* Command line */ +# if defined (COMMANDLINE) + p->hdr.tag = ATAG_CMDLINE; + p->hdr.size = tag_size (tag_cmdline) + + (sizeof (cmdline)+3)/4 - 1; + { + const char* sz = cmdline + offset; + int i; + for (i = 0; i < sizeof (cmdline); ++i) + p->u.cmdline.cmdline[i] = sz[i]; + } + p = tag_next (p); +# endif + + /* End */ + p->hdr.tag = ATAG_NONE; + p->hdr.size = 0; + +#endif + +#if !defined (CREATE_ATAGS) && defined (GUARANTEE_ATAG_CMDLINE)\ + && defined (PHYS_PARAMS) && defined (COMMANDLINE) + + { + char* cmdlineFound = 0; + for_each_tag (p, (struct tag*) PHYS_PARAMS) + if (p->hdr.tag == ATAG_CMDLINE) + cmdlineFound = p->u.cmdline.cmdline; + + /* The pointer p is left at the start of the terminating + ATAG_NONE. If cmdlineFound is non-null, we've found an + instance of the ATAG_CMDLINE. If not, we append the default + command line and a new ATAG_NONE. + + The original author was concerned about the possibility that + there may be more than one ATAG_CMDLINE record. There is no + stipulation in the documentation for the cmdline tags, but it + makes sense that there would be only one. Even if there were + more than one, I'm not sure it would matter since we won't + append one if we find any. */ + + if (!cmdlineFound || !*cmdlineFound) { + p->hdr.tag = ATAG_CMDLINE; + p->hdr.size = tag_size (tag_cmdline) + + (sizeof (cmdline)+3)/4 - 1; + { + const char* sz = cmdline + offset; + int i; + for (i = 0; i < sizeof (cmdline); ++i) + p->u.cmdline.cmdline[i] = sz[i]; + } + p = tag_next (p); + p->hdr.tag = ATAG_NONE; + p->hdr.size = 0; + } + } + +#endif + + /* Pass control to the kernel. The compile ought to optimize + this to a branch (instead of a branch-link), but it doesn't + matter if it doesn't. */ + boot (0, MACH_TYPE, PHYS_PARAMS); +} diff --git a/arm-kernel-shim/setup.h b/arm-kernel-shim/setup.h new file mode 100644 index 0000000..ac311c5 --- /dev/null +++ b/arm-kernel-shim/setup.h @@ -0,0 +1,220 @@ +/* + * linux/include/asm/setup.h + * + * Copyright (C) 1997-1999 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Structure passed to kernel to tell it about the + * hardware it's running on. See Documentation/arm/Setup + * for more info. + */ +#ifndef __ASMARM_SETUP_H +#define __ASMARM_SETUP_H + +#define COMMAND_LINE_SIZE 1024 + +/* The list ends with an ATAG_NONE node. */ +#define ATAG_NONE 0x00000000 + +struct tag_header { + u32 size; + u32 tag; +}; + +/* The list must start with an ATAG_CORE node */ +#define ATAG_CORE 0x54410001 + +struct tag_core { + u32 flags; /* bit 0 = read-only */ + u32 pagesize; + u32 rootdev; +}; + +/* it is allowed to have multiple ATAG_MEM nodes */ +#define ATAG_MEM 0x54410002 + +struct tag_mem32 { + u32 size; + u32 start; /* physical start address */ +}; + +/* VGA text type displays */ +#define ATAG_VIDEOTEXT 0x54410003 + +struct tag_videotext { + u8 x; + u8 y; + u16 video_page; + u8 video_mode; + u8 video_cols; + u16 video_ega_bx; + u8 video_lines; + u8 video_isvga; + u16 video_points; +}; + +/* describes how the ramdisk will be used in kernel */ +#define ATAG_RAMDISK 0x54410004 + +struct tag_ramdisk { + u32 flags; /* bit 0 = load, bit 1 = prompt */ + u32 size; /* decompressed ramdisk size in _kilo_ bytes */ + u32 start; /* starting block of floppy-based RAM disk image */ +}; + +/* describes where the compressed ramdisk image lives (virtual address) */ +/* + * this one accidentally used virtual addresses - as such, + * it's deprecated. + */ +#define ATAG_INITRD 0x54410005 + +/* describes where the compressed ramdisk image lives (physical address) */ +#define ATAG_INITRD2 0x54420005 + +struct tag_initrd { + u32 start; /* physical start address */ + u32 size; /* size of compressed ramdisk image in bytes */ +}; + +/* board serial number. "64 bits should be enough for everybody" */ +#define ATAG_SERIAL 0x54410006 + +struct tag_serialnr { + u32 low; + u32 high; +}; + +/* board revision */ +#define ATAG_REVISION 0x54410007 + +struct tag_revision { + u32 rev; +}; + +/* initial values for vesafb-type framebuffers. see struct screen_info + * in include/linux/tty.h + */ +#define ATAG_VIDEOLFB 0x54410008 + +struct tag_videolfb { + u16 lfb_width; + u16 lfb_height; + u16 lfb_depth; + u16 lfb_linelength; + u32 lfb_base; + u32 lfb_size; + u8 red_size; + u8 red_pos; + u8 green_size; + u8 green_pos; + u8 blue_size; + u8 blue_pos; + u8 rsvd_size; + u8 rsvd_pos; +}; + +/* command line: \0 terminated string */ +#define ATAG_CMDLINE 0x54410009 + +struct tag_cmdline { + char cmdline[1]; /* this is the minimum size */ +}; + +/* acorn RiscPC specific information */ +#define ATAG_ACORN 0x41000101 + +struct tag_acorn { + u32 memc_control_reg; + u32 vram_pages; + u8 sounddefault; + u8 adfsdrives; +}; + +/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ +#define ATAG_MEMCLK 0x41000402 + +struct tag_memclk { + u32 fmemclk; +}; + +struct tag { + struct tag_header hdr; + union { + struct tag_core core; + struct tag_mem32 mem; + struct tag_videotext videotext; + struct tag_ramdisk ramdisk; + struct tag_initrd initrd; + struct tag_serialnr serialnr; + struct tag_revision revision; + struct tag_videolfb videolfb; + struct tag_cmdline cmdline; + + /* + * Acorn specific + */ + struct tag_acorn acorn; + + /* + * DC21285 specific + */ + struct tag_memclk memclk; + } u; +}; + +struct tagtable { + u32 tag; + int (*parse)(const struct tag *); +}; + +#define __tag __attribute_used__ __attribute__((__section__(".taglist"))) +#define __tagtable(tag, fn) \ +static struct tagtable __tagtable_##fn __tag = { tag, fn } + +#define tag_member_present(tag,member) \ + ((unsigned long)(&((struct tag *)0L)->member + 1) \ + <= (tag)->hdr.size * 4) + +#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) +#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) + +#define for_each_tag(t,base) \ + for (t = base; t->hdr.size; t = tag_next(t)) + +/* + * Memory map description + */ +#ifdef CONFIG_ARCH_LH7A40X +# define NR_BANKS 16 +#else +# define NR_BANKS 8 +#endif + +struct meminfo { + int nr_banks; + struct { + unsigned long start; + unsigned long size; + int node; + } bank[NR_BANKS]; +}; + +extern struct meminfo meminfo; + +/* + * Early command line parameters. + */ +struct early_params { + const char *arg; + void (*fn)(char **p); +}; + +#define __early_param(name,fn) \ +static struct early_params __early_##fn __attribute_used__ \ +__attribute__((__section__("__early_param"))) = { name, fn } + +#endif diff --git a/arm-kernel-shim/types.h b/arm-kernel-shim/types.h new file mode 100644 index 0000000..f4c92e4 --- /dev/null +++ b/arm-kernel-shim/types.h @@ -0,0 +1,62 @@ +#ifndef __ASM_ARM_TYPES_H +#define __ASM_ARM_TYPES_H + +#ifndef __ASSEMBLY__ + +typedef unsigned short umode_t; + +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +#endif /* __ASSEMBLY__ */ + +/* + * These aren't exported outside the kernel to avoid name space clashes + */ +#ifdef __KERNEL__ + +#define BITS_PER_LONG 32 + +#ifndef __ASSEMBLY__ + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +/* Dma addresses are 32-bits wide. */ + +typedef u32 dma_addr_t; +typedef u32 dma64_addr_t; + +typedef unsigned int kmem_bufctl_t; + +#endif /* __ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif + diff --git a/arm-kernel-shim/wordswap b/arm-kernel-shim/wordswap new file mode 100755 index 0000000..0cc12fe --- /dev/null +++ b/arm-kernel-shim/wordswap @@ -0,0 +1,11 @@ +#!/usr/bin/perl +# +# Filter that swaps STDIN and writes it to STDOUT + +while (sysread(STDIN,$d,4)) { + print pack("N",unpack("V",$d)) +} + +0; + + diff --git a/crc/crc32.c b/crc/crc32.c new file mode 100644 index 0000000..ea18584 --- /dev/null +++ b/crc/crc32.c @@ -0,0 +1,325 @@ +/* crc32.cc + + written by Marc Singer + 6 November 2004 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + + An original reference for information about implementating CRC32 is + a document written by Ross Williams in 1993, "A Painless Guide to + CRC Error Detection Algorithms." Using his nomenclature, the CRC + algorithm implemented by Ethernet and Zip compression has the + following features: + + Width : 32 + Poly : 04C11DB7 + iPoly : EDB88320 // reverse bit order + Init : FFFFFFFF + RefIn : True + RefOut : True + XorOut : FFFFFFFF + Check : CBF43926 + + Width parameter is the length, in bits, of the polynomial. The + Poly is a bit mask indicating which terms have non-zero + coefficients. In this case, + + g(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + + x^7 + x^5 + x^4 + x^2 + x + 1 + + Init is value used to initialize the CRC function. RefIn and + RefOut, being true, indicate that the algorithm interprets the MSB + of each byte as an MSB. XorOut is the XOR mask applied to the CRC + on completion. Check is the CRC for the sequence "123456789". + + The implementation used herein comes from BLOB and was the work of + several people, Erik Muow, Jan-Derk Bakker, and Russell King. It + was found to be faster than the table algorithm though a little + larger, ~124 bytes. + +*/ + +#include +#include +#include +#include +#include + +#define POLY (0x04c11db7) +#define IPOLY (0xedb88320) + +#include "crctable.out" + +#if 0 + +/* Allegedly faster version, we want the smallest code possible */ + +unsigned long compute_crc32_x (unsigned long crc, const void* pv, int cb) +{ + unsigned char* pb = (unsigned char*) pv; + unsigned long poly = IPOLY; // Hack to get a register allocated + + crc = crc ^ 0xffffffff; // Invert because we're continuing + +#define DO_CRC\ + if (crc & 1) { \ + crc >>= 1; crc ^= poly; }\ + else { crc >>= 1; } + + while (cb--) { + crc ^= *pb++; + + DO_CRC; + DO_CRC; + DO_CRC; + DO_CRC; + DO_CRC; + DO_CRC; + DO_CRC; + DO_CRC; + } + + return crc ^ 0xffffffff; +} + +#endif + + +/* compute_crc32 + + calculates a standard 32 bit CRC checksum over a sequence of bytes. + This implementation is optimized for the ARM architecture. Other + architectures, e.g. i386 will probably not be well served by this + version as it depends on excellent optimization by the compiler as + well as a adequate number of registers. + +*/ + +unsigned long compute_crc32 (unsigned long crc, const void *pv, int cb) +{ + const unsigned char* pb = (const unsigned char *) pv; + + // crc ^= 0xffffffff; + + while (cb--) { + int i; + crc ^= *pb++; + + for (i = 8; i--; ) { + if (crc & 1) { + crc >>= 1; + crc ^= IPOLY; + } + else + crc >>= 1; + } + } + + // return crc ^ 0xffffffff; + return crc; +} + +/* compute_crc32_0 + + is the first version of the CRC computation that appears to + generate the same CRC as the GNU cksum. It doesn't seem to produce + the same check value as the "Painless Guide to CRC" does, but it's + a start. + + In order for this routine to produce a correct CRC, it must have a + word of zeros shifted in. Unlike the byte oriented versions, this + one does not implicitly shift in zeros at the end of the input. + +*/ + +unsigned long compute_crc32_0 (unsigned long crc, const void *pv, int cb) +{ + const unsigned char* pb = (const unsigned char *) pv; + + for (; cb--; ++pb) { + int i; + unsigned char mask; + + for (mask = 1<<7; mask; mask >>= 1) { + int f = (crc & (1<<31)); + crc = crc << 1; + if (*pb & mask) + crc |= 1; + if (f) + crc ^=POLY; + } + } + + return crc; +} + +/* compute_crc32_1 + +*/ + +unsigned long compute_crc32_1 (unsigned long crc, const void *pv, int cb) +{ + const unsigned char* pb = (const unsigned char *) pv; + + for (; cb--; ++pb) { + int i; + unsigned char mask; + + unsigned char b = (crc >> 24); + crc <<= 8; + b ^= *pb; + + for (mask = 1<<7; mask; mask >>= 1) { + int f = (b & mask); + crc = crc << 1; + if (f) + crc ^=POLY; + } + } + + // return crc ^ 0xffffffff; + return crc; +} + + +/* compute_crc32_2 + + implements the un-reversed table lookup version of the algorithm. + Note that this version does not need to have zeros shifted in at + the end in order to compute the remainder on the augmented message. + Instead, that aspect is implicit. + +*/ + +unsigned long compute_crc32_2 (unsigned long crc, const void *pv, int cb) +{ + unsigned char *blk_adr; + unsigned long blk_len; + + const char* pb = (const char*) pv; + + while (cb--) + crc = crctable[((crc >> 24) ^ *pb++) & 0xff] ^ (crc << 8); + return crc; +} + + +/* compute_crc32_3 + + is a working, byte oriented version of the crc computation routine + that does not require zero shifting. It is suitable for APEX, + though I wonder if it isn't worthwhile to use the table + implementation even though the latter is much longer, due to the + lookup table. I suppose we can use CONFIG_SMALL to select one or + the other. + +*/ + +unsigned long compute_crc32_3 (unsigned long crc, const void *pv, int cb) +{ + const unsigned char* pb = (const unsigned char *) pv; + + while (cb--) { + int i; + crc ^= *pb++ << 24; + + for (i = 8; i--; ) { + if (crc & (1<<31)) + crc = (crc << 1) ^ POLY; + else + crc <<= 1; + } + } + + return crc; +} + + +#define CALC compute_crc32_3 + +inline unsigned long cksum (unsigned long (*p)(unsigned long, + const void*, int), + const void* pv, int cb) +{ + unsigned long crc = p (0,pv,cb); + unsigned long v; + for (v = cb; v; v >>= 8) + crc = p (crc, &v, 1); + return ~crc; +} + +int main (int argc, char** argv) +{ + unsigned long crc = 0; + unsigned long zero = 0; + int fh; + void* pv; + size_t cb; + + if (argc < 2) { + printf ("usage: foo FILE\n"); + exit (1); + } + + fh = open (argv[1], O_RDONLY); + if (fh == -1) { + printf ("unable to open file\n"); + exit (1); + } + cb = lseek (fh, 0, SEEK_END); + lseek (fh, 0, SEEK_SET); + pv = mmap (NULL, cb, PROT_READ, MAP_PRIVATE, fh, 0); + + printf ("check 0x%08x\n", CALC (~0, "123456789", 9) ^ 0xffffffff); + + crc = CALC (crc, pv, cb); + printf ("crc %x\n", crc); + + { + unsigned long v = CALC (crc, &zero, 4); + unsigned long y = htonl (crc); +// unsigned long x = CALC (v, &v, 4); + unsigned long x = CALC (crc, &y, 4); + printf ("crc w/zero %x (%u) w/zero&crc %x (%u)\n", v, v, x, x); + } + +//printf ("crc w/zeros %x (%u)\n", CALC (crc, &zero, 4), CALC (crc, &zero, 4)); + + { + unsigned long v = cb; + while (v) { + printf (" length byte 0x%x\n", ((char*)&v)[0]); + crc = CALC (crc, &v, 1); + v >>= 8; + } + } + + printf ("crc w/len 0x%x (%u %u)\n", crc, crc, ~crc); + + crc = CALC (crc, &zero, 4); + + printf ("crc w/len&zeros 0x%x (%u)\n", crc, crc); + + printf ("checksum 0x%x (%u) 0x%x (%u) %d %s\n", + crc, crc, ~crc, ~crc, cb, argv[1]); + + printf ("3/2 %u %u\n", + cksum(compute_crc32_3,pv,cb), + cksum(compute_crc32_2,pv,cb)); + +#if 0 + printf ("rev/1/2 0x%08x 0x%08x 0x%08x\n", + compute_crc32 (0, pv, cb), + compute_crc32_1 (0, pv, cb), + compute_crc32_2 (0, pv, cb)); +#endif + + return 0; +} diff --git a/crc/crcmodel.c b/crc/crcmodel.c new file mode 100644 index 0000000..e985fe3 --- /dev/null +++ b/crc/crcmodel.c @@ -0,0 +1,150 @@ + +/******************************************************************************/ +/* Start of crcmodel.c */ +/******************************************************************************/ +/* */ +/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */ +/* Date : 3 June 1993. */ +/* Status : Public domain. */ +/* */ +/* Description : This is the implementation (.c) file for the reference */ +/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */ +/* information on the Rocksoft^tm Model CRC Algorithm, see the document */ +/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */ +/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */ +/* "ftp.adelaide.edu.au/pub/rocksoft". */ +/* */ +/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */ +/* */ +/******************************************************************************/ +/* */ +/* Implementation Notes */ +/* -------------------- */ +/* To avoid inconsistencies, the specification of each function is not echoed */ +/* here. See the header file for a description of these functions. */ +/* This package is light on checking because I want to keep it short and */ +/* simple and portable (i.e. it would be too messy to distribute my entire */ +/* C culture (e.g. assertions package) with this package. */ +/* */ +/******************************************************************************/ + +#include "crcmodel.h" + +/******************************************************************************/ + +/* The following definitions make the code more readable. */ + +#define BITMASK(X) (1L << (X)) +#define MASK32 0xFFFFFFFFL +#define LOCAL static + +/******************************************************************************/ + +LOCAL ulong reflect P_((ulong v,int b)); +LOCAL ulong reflect (v,b) +/* Returns the value v with the bottom b [0,32] bits reflected. */ +/* Example: reflect(0x3e23L,3) == 0x3e26 */ +ulong v; +int b; +{ + int i; + ulong t = v; + for (i=0; i>=1; + } + return v; +} + +/******************************************************************************/ + +LOCAL ulong widmask P_((p_cm_t)); +LOCAL ulong widmask (p_cm) +/* Returns a longword whose value is (2^p_cm->cm_width)-1. */ +/* The trick is to do this portably (e.g. without doing <<32). */ +p_cm_t p_cm; +{ + return (((1L<<(p_cm->cm_width-1))-1L)<<1)|1L; +} + +/******************************************************************************/ + +void cm_ini (p_cm) +p_cm_t p_cm; +{ + p_cm->cm_reg = p_cm->cm_init; +} + +/******************************************************************************/ + +void cm_nxt (p_cm,ch) +p_cm_t p_cm; +int ch; +{ + int i; + ulong uch = (ulong) ch; + ulong topbit = BITMASK(p_cm->cm_width-1); + + if (p_cm->cm_refin) uch = reflect(uch,8); + p_cm->cm_reg ^= (uch << (p_cm->cm_width-8)); + for (i=0; i<8; i++) + { + if (p_cm->cm_reg & topbit) + p_cm->cm_reg = (p_cm->cm_reg << 1) ^ p_cm->cm_poly; + else + p_cm->cm_reg <<= 1; + p_cm->cm_reg &= widmask(p_cm); + } +} + +/******************************************************************************/ + +void cm_blk (p_cm,blk_adr,blk_len) +p_cm_t p_cm; +p_ubyte_ blk_adr; +ulong blk_len; +{ + while (blk_len--) cm_nxt(p_cm,*blk_adr++); +} + +/******************************************************************************/ + +ulong cm_crc (p_cm) +p_cm_t p_cm; +{ + if (p_cm->cm_refot) + return p_cm->cm_xorot ^ reflect(p_cm->cm_reg,p_cm->cm_width); + else + return p_cm->cm_xorot ^ p_cm->cm_reg; +} + +/******************************************************************************/ + +ulong cm_tab (p_cm,index) +p_cm_t p_cm; +int index; +{ + int i; + ulong r; + ulong topbit = BITMASK(p_cm->cm_width-1); + ulong inbyte = (ulong) index; + + if (p_cm->cm_refin) inbyte = reflect(inbyte,8); + r = inbyte << (p_cm->cm_width-8); + for (i=0; i<8; i++) + if (r & topbit) + r = (r << 1) ^ p_cm->cm_poly; + else + r<<=1; + if (p_cm->cm_refin) r = reflect(r,p_cm->cm_width); + return r & widmask(p_cm); +} + +/******************************************************************************/ +/* End of crcmodel.c */ +/******************************************************************************/ + diff --git a/crc/crcmodel.h b/crc/crcmodel.h new file mode 100644 index 0000000..371faba --- /dev/null +++ b/crc/crcmodel.h @@ -0,0 +1,157 @@ +/******************************************************************************/ +/* Start of crcmodel.h */ +/******************************************************************************/ +/* */ +/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */ +/* Date : 3 June 1993. */ +/* Status : Public domain. */ +/* */ +/* Description : This is the header (.h) file for the reference */ +/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */ +/* information on the Rocksoft^tm Model CRC Algorithm, see the document */ +/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */ +/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */ +/* "ftp.adelaide.edu.au/pub/rocksoft". */ +/* */ +/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */ +/* */ +/******************************************************************************/ +/* */ +/* How to Use This Package */ +/* ----------------------- */ +/* Step 1: Declare a variable of type cm_t. Declare another variable */ +/* (p_cm say) of type p_cm_t and initialize it to point to the first */ +/* variable (e.g. p_cm_t p_cm = &cm_t). */ +/* */ +/* Step 2: Assign values to the parameter fields of the structure. */ +/* If you don't know what to assign, see the document cited earlier. */ +/* For example: */ +/* p_cm->cm_width = 16; */ +/* p_cm->cm_poly = 0x8005L; */ +/* p_cm->cm_init = 0L; */ +/* p_cm->cm_refin = TRUE; */ +/* p_cm->cm_refot = TRUE; */ +/* p_cm->cm_xorot = 0L; */ +/* Note: Poly is specified without its top bit (18005 becomes 8005). */ +/* Note: Width is one bit less than the raw poly width. */ +/* */ +/* Step 3: Initialize the instance with a call cm_ini(p_cm); */ +/* */ +/* Step 4: Process zero or more message bytes by placing zero or more */ +/* successive calls to cm_nxt. Example: cm_nxt(p_cm,ch); */ +/* */ +/* Step 5: Extract the CRC value at any time by calling crc = cm_crc(p_cm); */ +/* If the CRC is a 16-bit value, it will be in the bottom 16 bits. */ +/* */ +/******************************************************************************/ +/* */ +/* Design Notes */ +/* ------------ */ +/* PORTABILITY: This package has been coded very conservatively so that */ +/* it will run on as many machines as possible. For example, all external */ +/* identifiers have been restricted to 6 characters and all internal ones to */ +/* 8 characters. The prefix cm (for Crc Model) is used as an attempt to avoid */ +/* namespace collisions. This package is endian independent. */ +/* */ +/* EFFICIENCY: This package (and its interface) is not designed for */ +/* speed. The purpose of this package is to act as a well-defined reference */ +/* model for the specification of CRC algorithms. If you want speed, cook up */ +/* a specific table-driven implementation as described in the document cited */ +/* above. This package is designed for validation only; if you have found or */ +/* implemented a CRC algorithm and wish to describe it as a set of parameters */ +/* to the Rocksoft^tm Model CRC Algorithm, your CRC algorithm implementation */ +/* should behave identically to this package under those parameters. */ +/* */ +/******************************************************************************/ + +/* The following #ifndef encloses this entire */ +/* header file, rendering it indempotent. */ +#ifndef CM_DONE +#define CM_DONE + +/******************************************************************************/ + +/* The following definitions are extracted from my style header file which */ +/* would be cumbersome to distribute with this package. The DONE_STYLE is the */ +/* idempotence symbol used in my style header file. */ + +#ifndef DONE_STYLE + +typedef unsigned long ulong; +typedef unsigned bool; +typedef unsigned char * p_ubyte_; + +#ifndef TRUE +#define FALSE 0 +#define TRUE 1 +#endif + +/* Change to the second definition if you don't have prototypes. */ +#define P_(A) A +/* #define P_(A) () */ + +/* Uncomment this definition if you don't have void. */ +/* typedef int void; */ + +#endif + +/******************************************************************************/ + +/* CRC Model Abstract Type */ +/* ----------------------- */ +/* The following type stores the context of an executing instance of the */ +/* model algorithm. Most of the fields are model parameters which must be */ +/* set before the first initializing call to cm_ini. */ +typedef struct + { + int cm_width; /* Parameter: Width in bits [8,32]. */ + ulong cm_poly; /* Parameter: The algorithm's polynomial. */ + ulong cm_init; /* Parameter: Initial register value. */ + bool cm_refin; /* Parameter: Reflect input bytes? */ + bool cm_refot; /* Parameter: Reflect output CRC? */ + ulong cm_xorot; /* Parameter: XOR this to output CRC. */ + + ulong cm_reg; /* Context: Context during execution. */ + } cm_t; +typedef cm_t *p_cm_t; + +/******************************************************************************/ + +/* Functions That Implement The Model */ +/* ---------------------------------- */ +/* The following functions animate the cm_t abstraction. */ + +void cm_ini P_((p_cm_t p_cm)); +/* Initializes the argument CRC model instance. */ +/* All parameter fields must be set before calling this. */ + +void cm_nxt P_((p_cm_t p_cm,int ch)); +/* Processes a single message byte [0,255]. */ + +void cm_blk P_((p_cm_t p_cm,p_ubyte_ blk_adr,ulong blk_len)); +/* Processes a block of message bytes. */ + +ulong cm_crc P_((p_cm_t p_cm)); +/* Returns the CRC value for the message bytes processed so far. */ + +/******************************************************************************/ + +/* Functions For Table Calculation */ +/* ------------------------------- */ +/* The following function can be used to calculate a CRC lookup table. */ +/* It can also be used at run-time to create or check static tables. */ + +ulong cm_tab P_((p_cm_t p_cm,int index)); +/* Returns the i'th entry for the lookup table for the specified algorithm. */ +/* The function examines the fields cm_width, cm_poly, cm_refin, and the */ +/* argument table index in the range [0,255] and returns the table entry in */ +/* the bottom cm_width bytes of the return value. */ + +/******************************************************************************/ + +/* End of the header file idempotence #ifndef */ +#endif + +/******************************************************************************/ +/* End of crcmodel.h */ +/******************************************************************************/ diff --git a/crc/crctable.out b/crc/crctable.out new file mode 100644 index 0000000..0cafedd --- /dev/null +++ b/crc/crctable.out @@ -0,0 +1,91 @@ +/*****************************************************************/ +/* */ +/* CRC LOOKUP TABLE */ +/* ================ */ +/* The following CRC lookup table was generated automagically */ +/* by the Rocksoft^tm Model CRC Algorithm Table Generation */ +/* Program V1.0 using the following model parameters: */ +/* */ +/* Width : 4 bytes. */ +/* Poly : 0x04C11DB7L */ +/* Reverse : FALSE. */ +/* */ +/* For more information on the Rocksoft^tm Model CRC Algorithm, */ +/* see the document titled "A Painless Guide to CRC Error */ +/* Detection Algorithms" by Ross Williams */ +/* (ross@guest.adelaide.edu.au.). This document is likely to be */ +/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ +/* */ +/*****************************************************************/ + +unsigned long crctable[256] = +{ + 0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L, + 0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L, + 0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L, + 0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL, + 0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L, + 0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L, + 0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L, + 0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL, + 0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L, + 0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L, + 0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L, + 0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL, + 0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L, + 0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L, + 0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L, + 0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL, + 0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL, + 0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L, + 0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L, + 0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL, + 0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL, + 0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L, + 0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L, + 0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL, + 0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL, + 0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L, + 0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L, + 0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL, + 0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL, + 0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L, + 0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L, + 0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL, + 0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L, + 0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL, + 0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL, + 0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L, + 0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L, + 0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL, + 0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL, + 0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L, + 0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L, + 0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL, + 0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL, + 0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L, + 0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L, + 0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL, + 0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL, + 0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L, + 0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L, + 0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL, + 0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L, + 0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L, + 0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L, + 0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL, + 0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L, + 0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L, + 0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L, + 0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL, + 0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L, + 0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L, + 0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L, + 0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL, + 0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L, + 0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L +}; + +/*****************************************************************/ +/* End of CRC Lookup Table */ +/*****************************************************************/ diff --git a/crc/table.c b/crc/table.c new file mode 100644 index 0000000..818edfe --- /dev/null +++ b/crc/table.c @@ -0,0 +1,174 @@ +/******************************************************************************/ +/* Start of crctable.c */ +/******************************************************************************/ +/* */ +/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */ +/* Date : 3 June 1993. */ +/* Version : 1.0. */ +/* Status : Public domain. */ +/* */ +/* Description : This program writes a CRC lookup table (suitable for */ +/* inclusion in a C program) to a designated output file. The program can be */ +/* statically configured to produce any table covered by the Rocksoft^tm */ +/* Model CRC Algorithm. For more information on the Rocksoft^tm Model CRC */ +/* Algorithm, see the document titled "A Painless Guide to CRC Error */ +/* Detection Algorithms" by Ross Williams (ross@guest.adelaide.edu.au.). This */ +/* document is likely to be in "ftp.adelaide.edu.au/pub/rocksoft". */ +/* */ +/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */ +/* */ +/******************************************************************************/ + +#include +#include +#include "crcmodel.h" + +/******************************************************************************/ + +/* TABLE PARAMETERS */ +/* ================ */ +/* The following parameters entirely determine the table to be generated. You */ +/* should need to modify only the definitions in this section before running */ +/* this program. */ +/* */ +/* TB_FILE is the name of the output file. */ +/* TB_WIDTH is the table width in bytes (either 2 or 4). */ +/* TB_POLY is the "polynomial", which must be TB_WIDTH bytes wide. */ +/* TB_REVER indicates whether the table is to be reversed (reflected). */ +/* */ +/* Example: */ +/* */ +/* #define TB_FILE "crctable.out" */ +/* #define TB_WIDTH 2 */ +/* #define TB_POLY 0x8005L */ +/* #define TB_REVER TRUE */ + +#define TB_FILE "crctable.out" +#define TB_WIDTH 4 +#define TB_POLY 0x04C11DB7L +#define TB_REVER FALSE + +/******************************************************************************/ + +/* Miscellaneous definitions. */ + +#define LOCAL static +FILE *outfile; +#define WR(X) fprintf(outfile,(X)) +#define WP(X,Y) fprintf(outfile,(X),(Y)) + +/******************************************************************************/ + +LOCAL void chk_err P_((char *)); +LOCAL void chk_err (mess) +/* If mess is non-empty, write it out and abort. Otherwise, check the error */ +/* status of outfile and abort if an error has occurred. */ +char *mess; +{ + if (mess[0] != 0 ) {printf("%s\n",mess); exit(EXIT_FAILURE);} + if (ferror(outfile)) {perror("chk_err"); exit(EXIT_FAILURE);} +} + +/******************************************************************************/ + +LOCAL void chkparam P_((void)); +LOCAL void chkparam () +{ + if ((TB_WIDTH != 2) && (TB_WIDTH != 4)) + chk_err("chkparam: Width parameter is illegal."); + if ((TB_WIDTH == 2) && (TB_POLY & 0xFFFF0000L)) + chk_err("chkparam: Poly parameter is too wide."); + if ((TB_REVER != FALSE) && (TB_REVER != TRUE)) + chk_err("chkparam: Reverse parameter is not boolean."); +} + +/******************************************************************************/ + +LOCAL void gentable P_((void)); +LOCAL void gentable () +{ + WR("/*****************************************************************/\n"); + WR("/* */\n"); + WR("/* CRC LOOKUP TABLE */\n"); + WR("/* ================ */\n"); + WR("/* The following CRC lookup table was generated automagically */\n"); + WR("/* by the Rocksoft^tm Model CRC Algorithm Table Generation */\n"); + WR("/* Program V1.0 using the following model parameters: */\n"); + WR("/* */\n"); + WP("/* Width : %1lu bytes. */\n", + (ulong) TB_WIDTH); + if (TB_WIDTH == 2) + WP("/* Poly : 0x%04lX */\n", + (ulong) TB_POLY); + else + WP("/* Poly : 0x%08lXL */\n", + (ulong) TB_POLY); + if (TB_REVER) + WR("/* Reverse : TRUE. */\n"); + else + WR("/* Reverse : FALSE. */\n"); + WR("/* */\n"); + WR("/* For more information on the Rocksoft^tm Model CRC Algorithm, */\n"); + WR("/* see the document titled \"A Painless Guide to CRC Error */\n"); + WR("/* Detection Algorithms\" by Ross Williams */\n"); + WR("/* (ross@guest.adelaide.edu.au.). This document is likely to be */\n"); + WR("/* in the FTP archive \"ftp.adelaide.edu.au/pub/rocksoft\". */\n"); + WR("/* */\n"); + WR("/*****************************************************************/\n"); + WR("\n"); + switch (TB_WIDTH) + { + case 2: WR("unsigned short crctable[256] =\n{\n"); break; + case 4: WR("unsigned long crctable[256] =\n{\n"); break; + default: chk_err("gentable: TB_WIDTH is invalid."); + } + chk_err(""); + + { + int i; + cm_t cm; + char *form = (TB_WIDTH==2) ? "0x%04lX" : "0x%08lXL"; + int perline = (TB_WIDTH==2) ? 8 : 4; + + cm.cm_width = TB_WIDTH*8; + cm.cm_poly = TB_POLY; + cm.cm_refin = TB_REVER; + + for (i=0; i<256; i++) + { + WR(" "); + WP(form,(ulong) cm_tab(&cm,i)); + if (i != 255) WR(","); + if (((i+1) % perline) == 0) WR("\n"); + chk_err(""); + } + + WR("};\n"); + WR("\n"); + WR("/*****************************************************************/\n"); + WR("/* End of CRC Lookup Table */\n"); + WR("/*****************************************************************/\n"); + WR(""); + chk_err(""); +} +} + +/******************************************************************************/ + +main () +{ + printf("\n"); + printf("Rocksoft^tm Model CRC Algorithm Table Generation Program V1.0\n"); + printf("-------------------------------------------------------------\n"); + printf("Output file is \"%s\".\n",TB_FILE); + chkparam(); + outfile = fopen(TB_FILE,"w"); chk_err(""); + gentable(); + if (fclose(outfile) != 0) + chk_err("main: Couldn't close output file."); + printf("\nSUCCESS: The table has been successfully written.\n"); +} + +/******************************************************************************/ +/* End of crctable.c */ +/******************************************************************************/ diff --git a/crc/x b/crc/x new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/crc/x @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/crc/xx b/crc/xx new file mode 100644 index 0000000..40fdece --- /dev/null +++ b/crc/xx @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..8d9ef9c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,130 @@ +apex (1.5.14) unstable; urgency=low + + * Added CONFIG_AEABI=y to armel. (closes: #481848) + * Added shlib dependencies for the sake of apex-env. (closes: #481846) + * Revised copyright messages, again, to remove all references to the FSF + address. + * debian/postinst: Fixed the postinst script to only run on the NSLU2. + (closes: #482000) + * The --force option to apex-env was fixed in a previous release. + (closes: #417757) + * Fixed the debian/copyright file to reflect the new wiki URL + syntax. (closes: #481736) + * Many upstream changes since last release, though most were not visible + to nslu2. There was a bug fixed in the envronment handling where a + broken environment region could cause unexpected boot-time problems. + * Included Kevin Price's patch for flash-apex. + o Added shlib dependencies for apex-env + o Updated FSF address in copyright + o Added manpage flash-apex(8) + o Removed boot option `rtc-x1205.probe=0,0x6f' from kernel command + line (closes: #471476) + o -- Kevin Price Tue, 16 May 2008 17:52:00 +0200 + o Bumped new upstream version + o Enabled CONFIG_AEABI=y + o [ Gordon Farquharson ] + o CONFIG_RAMDISK_SIZE=0x005FFFF0 (closes: #451882) + o Add flash-apex script. (closes: #421359) + o Add postinst script to run flash-apex on installation. + * Applied patches from rwhitby for Debian and slugos targets. + * Added overrides support to allow 'every' target really build every + configuration. + + -- Marc Singer Tue, 27 May 2008 19:58:03 -0700 + +apex (1.5.8) unstable; urgency=low + + * Added 'release' comand to the apex-env. + * Defaults for debian configs will detect all memory. + + -- Marc Singer Mon, 25 Jun 2007 15:53:22 -0700 + +apex (1.5.7) unstable; urgency=low + + * Since last official release, fixes to the memory detection, AEABI + support, OneNAND environment support with ENV_SAVEATONCE, lots of mx31 + changes, completely restructured the reset vector to avoid function + calls, and lots of other stuff documented in the package ChangeLog. + + -- Marc Singer Sun, 24 Jun 2007 18:41:27 -0700 + +apex (1.4.15) unstable; urgency=low + + * Modified the rules file to support cross-building. + * Closes bug#409189 + * Fixed the output file name. It was inadvertently changed to /boot/apex.bin + from /boot/apex.flash. + * Closes bug#409747 + -- Marc Singer Mon, 5 Feb 2007 18:35:11 -0800 + +apex (1.4.14) unstable; urgency=low + + * Revised the libfuncs1.S file for arm so that armel can build. + * Closes bug#408443 + * Changed the rules file to drop the executble bit on the apex.flash + file written to /boot. + * Closes bug#396447 + + -- Marc Singer Tue, 30 Jan 2007 19:19:55 -0800 + +apex (1.4.13) unstable; urgency=low + + * Fixed ext2 driver caching s.t. multiple partitions work correctly. + * New user-mode application for modifying the APEX environment. + * Revisions to Companion setup. + * Revision to the memory test based on advice about what is useful and + what is not. + * Fixes to the FIS driver for swapped-ness and end-of-table detection. + * Applied rwhitby's patches for a couple of ixp4xx devices as well as + some other minor patches. + * Added variation support for alternative boot modes. + * Enhanced NAND support and made it more generic. + + -- Marc Singer Sat, 27 Jan 2007 17:38:49 -0800 + +apex (1.4.7) unstable; urgency=low + + * New command line starts RTC. + * Moved the environment to the same block as the loader. + + -- Marc Singer Sun, 22 Oct 2006 14:20:13 -0700 + +apex (1.4.5) unstable; urgency=low + + * Fixed the sort comparison function in the fis driver so that the skips + are ordered by offset address. + * Changed the default startup to copy from fis://kernel and + fis://ramdisk. We no longer expect there to be SERCOMM headers on the + kernel or ramdisk images. Freedom. + + -- Marc Singer Fri, 18 Aug 2006 09:44:34 -0700 + +apex (1.4.4) unstable; urgency=low + + * Small changes to the configurations for debian builds: noirqdebug + added command line, removed root= from command line. + * Revised copyright file to conform to approved practices. + + -- Marc Singer Mon, 14 Aug 2006 17:06:58 -0700 + +apex (1.4.3) unstable; urgency=low + + * Added fis_skip_descriptor interpretation to the FIS driver. This + allows for loading the kernel from FIS partitions that are broken-up + by SERCOMM headers to cope with RedBoot shortcomings. + + -- Marc Singer Sun, 13 Aug 2006 17:28:55 -0700 + +apex (1.4.0) unstable; urgency=low + + * Revised several key systems for the sake of running APEX in LE mode on + a BE system. APEX now functions as a second-stage boot loader on the + nslu2. + + -- Marc Singer Wed, 26 Jul 2006 00:57:13 -0700 + +apex (1.3.30) unstable; urgency=low + + * Initial release for configuration debian-nslu2-arm_config (and armeb). + + -- Marc Singer Thu, 20 Jul 2006 11:36:21 -0700 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..a6b8494 --- /dev/null +++ b/debian/control @@ -0,0 +1,23 @@ +Source: apex +Section: admin +Priority: optional +Maintainer: Marc Singer +Standards-Version: 3.7.2 +Build-Depends: perl, debhelper (>= 5) + +Package: apex-nslu2 +Architecture: arm armeb armel +Depends: devio, ${shlibs:Depends} +Description: APEX Boot Loader for Linksys NSLU2 + The APEX Boot Loader is a modular and retargetable firmware loader + suitable for embedded systems. + . + This package is a version of APEX configured for the Linksys NSLU2 + network appliance. In this case, APEX is used as a second stage + loader so that Redboot, as installed by the manufacturer, may remain. + . + The APEX command line offers a comfortable (e.g. command line editing + and history) and extensible platform for development and production + uses. + . + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..708cc48 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,25 @@ +This program is written, maintained, and packaged for Debian by Marc +Singer . The upstream source may be found on this web +site http://wiki.buici.com/wiki/Apex_Bootloader. + + Copyright (C) 2004,2005,2006.2007 Marc Singer + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +The full text of the GPL copyright may be found in the original source +tarball in the COPYING file file, or on your Debian system here: + + file:///usr/share/common-licenses/GPL diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..d888f45 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +#DEBHELPER# + +# Install on NSLU2, only +unset h +if cat /proc/cpuinfo | grep -iq "Linksys NSLU2" ; then h=1 ; fi + +if [ "$1" = configure -a x"$h" = x"1" ]; then + flash-apex +fi diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..b89ad3a --- /dev/null +++ b/debian/rules @@ -0,0 +1,86 @@ +#!/usr/bin/make -f + +package = apex-nslu2 +docdir = debian/tmp/usr/share/doc/$(package) + +DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) +CONFIG := debian-nslu2-$(DEB_HOST_ARCH)_config + +CC = gcc +CFLAGS = -g -Wall +INSTALL_PROGRAM = install + + +ifeq (arm,$(DEB_HOST_ARCH)) + ENDIAN:=l +endif +ifeq (armel,$(DEB_HOST_ARCH)) + ENDIAN:=l +endif +ifeq (armeb,$(DEB_HOST_ARCH)) + ENDIAN:=b +endif + +# We must not change the build options. +#ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) +# CFLAGS += -O2 +#endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +build: + $(checkdir) + $(MAKE) $(CONFIG) + $(MAKE) + $(MAKE) -C usr CROSS_COMPILE= + touch build + +clean: + $(checkdir) + rm -f build + -$(MAKE) -i distclean + rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars + +binary-indep: checkroot build + $(checkdir) +# There are no architecture-independent files to be uploaded +# generated by this package. If there were any they would be +# made here. + +binary-arch: checkroot build + $(checkdir) + rm -rf debian/$(package) + dh_testroot -a + dh_installdirs + install -d debian/$(package)/boot + install -d debian/$(package)/usr/sbin + install -m 0644 src/arch-arm/rom/apex.bin\ + debian/$(package)/boot/apex.flash + install -m 0755 usr/apex-env debian/$(package)/usr/sbin + install -m 0755 usr/flash-apex debian/$(package)/usr/sbin + install -m 0755 usr/apex-image debian/$(package)/usr/sbin + dh_strip + dh_installchangelogs ChangeLog + dh_installdocs -a + dh_installman usr/apex-env.8 + dh_installman usr/flash-apex.8 + dh_compress -a + dh_fixperms -a + dh_installdeb -a + dh_shlibdeps + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +define checkdir + test -f src/apex/init.c -a -f debian/rules +endef + +binary: binary-indep binary-arch + +checkroot: + $(checkdir) + test $$(id -u) = 0 + +.PHONY: binary binary-arch binary-indep clean checkroot diff --git a/docs/00-Overview b/docs/00-Overview new file mode 100644 index 0000000..d9aa4c1 --- /dev/null +++ b/docs/00-Overview @@ -0,0 +1,66 @@ +=========================== + APEX Boot Loader + Overview +=========================== + +When browsing the code, it is helpful to have an overview of the +program organization. + +Linker Script +------------- + +APEX is designed to be easy to extend and port. Much of the heavy +lifting is done by the linker. Code and data are assigned section +names to coerce them to link in the correctl place. To understand how +the program is assembled, start by reading the linker script. + + src/arch-*/entry/apex.lds.S + +The whole program is linked at the target virtual memory address, VMA, +which is a misnomer in this case since APEX doesn't enable the MMU. + +Bootstrap +--------- + +Execution begin at the start of the .entry section which uses the +.bootstrap section to initialize SDRAM and move the program from +nonvolatile storage to the place where it can execute. None of this +code uses the stack. + +The whole bootstrap may be customized for a particular target. This +is discouraged and should be unnecessary on ARM targets. The +relocate_apex () function, for example, may be defined by the target +to replace the default relocator. This technique is used by NAND +flash implementations since the relocation is hardware specific. + + +Exception Vectors +----------------- + +Some rudimentary work has gone into enabling exception vectors. The +framework is in place, but it is not know to work. Unlike other +loaders, these vectors do *not* live at the top of the program. +Instead, APEX relocates SDRAM to 0x0 and copies the vectors there. + +Services and Drivers +-------------------- + +Instead of using a single piece of code to call initialization +functions, APEX uses a linker section to aggregate control structures +for each service and driver. At various times such as initialization +and cleanup, APEX scans these structures from start the finish. + +Initialization ordering is guaranteed by assiging each object an +appropriate index within the group. Drivers in the .driver.0 +sub-section are guaranteed to be initialized before drivers in the +.driver.1 sub-section. Drivers within a section are initialized in an +unpredictable order. + +Memory Image +------------ + +APEX copies the whole of itself from non-volatile storage to SDRAM. +It depends on strings being immutable and it does not use static +variables other than those in BSS. These assumptions allow the loader +to be copied from SDRAM directly to non-volatile storage. + diff --git a/docs/Build b/docs/Build new file mode 100644 index 0000000..9231a25 --- /dev/null +++ b/docs/Build @@ -0,0 +1,23 @@ +=========================== + APEX Boot Loader + Building +=========================== + +This README contains some notes about the build process. + + + Recursing Directories + --------------------- + +One of the scripts, envmagic, recurses all of the files in the tree +before building the project. Since we allow code to be imported into +APEX, built and linked with the loader, we don't want the normal build +scripts to descend these potentially deep directory structures. +Moreover, source control files may also tend to impact the speed of +the build. + +So, the envmagic script and other components of the build process will +ignore directories that are called .svn or begin with an underscore. +It also ignores files that begin with '.#' which are created by emacs. + + diff --git a/docs/Config b/docs/Config new file mode 100644 index 0000000..08541ea --- /dev/null +++ b/docs/Config @@ -0,0 +1,12 @@ +=========================== + APEX Boot Loader + Config +=========================== + +The descriptions in this file are superceeded by the help strings in +the config scripts. Configuration of APEX is now done with one of the +configuration programs, just like the Linux kernel 2.6. + +The defaults in the Kconfig files may be overriden by user selected +values. The safest way to create a new configuration is to remove the +.config file and start from scratch. diff --git a/docs/Environment b/docs/Environment new file mode 100644 index 0000000..079003c --- /dev/null +++ b/docs/Environment @@ -0,0 +1,140 @@ +=========================== + APEX Boot Loader + Environment +=========================== + +There is support for an environment in APEX. The environment stores +key/value pairs as part of the configuration of the boot loader in +non-volatile storage. The only configuration option that can never be +stored in the environment is the location of the environment itself. + +Aliases +------- + +APEX also supports aliases which are key/value pairs, but there are +several important differences. Aliases are not stored in non-volatile +memory. Aliases resolve before environment variables, thus overriding +the environment. Aliases have no default value. When unset, aliases +are empty whereas undefined environment variables will have the +default that is compiled into APEX. Finally, aliases may be assigned +to any key. The environment can only store keys that are compiled +into APEX. + + +The Environment Region +---------------------- + +The region containing the environment is defined at compile time. It +is usually in NOR flash, but can be in any non-volatile storage +medium. If APEX cannot open the environment region, it will not allow +run-time changes to the compiled in defaults. + +Typically, this region is assigned so that it doesn't occupy the same +erase block as other valuable data. For example, on a system where +NOR flash has 128KiB erase blocks, the environment could occupy the +upper 16KiB of the same block as APEX. Trouble arises if this region +fills erased values since erasing the region will erase the boot +loader as well. + +The region can be stored in a small EEPROM. Even 256 bytes may be +enough to be useful. The memory format was designed to be compact +enough to fit into this sort of medium. + +The size of the region does not need to be large. Setting it to 16KiB +is probably sufficient for any common usage considering that most +entries will be less than 40 characters. As entries are erased and +replaced, the environment will fill with erased entried which can take +some time to scan if the medium is very slow. + + +Environment Memory Format +------------------------- + +The environment format has evolved such that it is self-contained for +both reading and writing, and is reasonably compact. + + +-------+-------+-------+------+ + | MAGIC | Entry | ... | 0xff | + +-------+-------+-------+------+ + +The MAGIC number is two bytes, stored in the MSB or network order, 'A' +followed by 'e'. The same environment data may be read from either +little or big endian CPU. The environment is terminated with a single +0xff byte. + +Entries are key/value pairs of two forms. + + +------+-----+-------+ + | Flag | Key | Value | + +------+-----+-------+ + +In this form, the Key and Value are each NULL terminated ASCII +strings. The Flag field is a single byte where the high bit is 1 for +an active entry, and 0 for a deleted entry. The low seven bits are an +id which is identifies the key. Valid ids are zero through 0x7e since +0x7f would mark the end of the environment if it were an active entry. + + +------+-------+ + | Flag | Value | + +------+-------+ + +This is the second form that does not include the Key string. It only +exists when an environment variable is written more than once to the +environment. The first time a given Key is stored, an unused id is +allocated for it. The second time it is stored, that id is reused and +the Key field is omitted. + +The ids are unique within a given environment instance, and are +allocated as entries are written. For example, if the user performs +these commands on an empty environment: + + apex> setenv cmdline console=ttyS0 + apex> setenv bootaddr 0x8000 + apex> setenv cmdline console=ttyS0,115200 + +the environment will contain three entries, cmdline with a flag of 0x0 +(deleted id=0), bootaddr with a flag of 0x81 (active id=1), and +cmdline with a flag of 0x80 (active id=0). + + +Writing an Environment from User Space +-------------------------------------- + +There is a user-mode application in the usr/ directory called +apex-env. It works in concert with the CONFIG_ENV_LINK option to +allow safe and reliable modifications to the APEX environment once the +system is booted. There further discussion of the environment format +in the usr/link.cc file. + +More on the Environment in Flash +-------------------------------- + +It would be easiest to re-write the whole environment without +including deleted entries. apex-env doesn't do this because it is +careful to properly manage the data structures. + +IDs must be allocated consecutively as new variables are added the the +flash environment. If the flash environment contains three Keys they +must have ids 0, 1 and 2. A new key must have the id of 3. Deleting +values doesn't affect this ordering. Unsetting a variable and then +setting it again will reuse the id used the first time it was set. +Only when the whole environment is erased can the id's be recycled. + +The magic number must be written to the first two bytes of the +environment region. The first bytes address must contain 'A' and the +second mus contain 'e' regardless of the endian-ness of the CPU. + +If you write an entry with a Key that is not recognized by APEX, it +will be harmlessly ignored. This may be helpful if you want to +construct an environment with all possible Keys that could be used by +APEX, or if you need to upgrade APEX without modifying the +environment. + +APEX interprets environment Keys without regard for case. Thus, +'cmdline' will be recognized as the same Key as 'cmdLine' and +'CMDLINE'. The APEX command line only stores Key names as they are +defined in the code, so that when the user executes + + apex> setenv CMDLINE console=ttyS0 + +APEX stores 'cmdline'. diff --git a/docs/Every b/docs/Every new file mode 100644 index 0000000..6bb48d0 --- /dev/null +++ b/docs/Every @@ -0,0 +1,23 @@ +=========================== + APEX Boot Loader + Prebuilt Binaries +=========================== + +This README is included in the prebuilt APEX binary archives. + +The files in this archive are build for the version of APEX +indentified by the APEXVERSION file. The configuration file, config, +is the one used to build these files. + + apex.bin - binary dump of APEX + apex.elf - stripped ELF executable + apex.srec - SREC text format + +The ELF and SREC format files are defined to put the loader at it's +final VMA in SDRAM. However, APEX may be loaded at any address and +executed there. The binary format file may be written directly to +flash, SRAM, or SDRAM and executed there. + +For more information about loading APEX onto your target, refer to +. + diff --git a/docs/FIS b/docs/FIS new file mode 100644 index 0000000..2a0649e --- /dev/null +++ b/docs/FIS @@ -0,0 +1,84 @@ +=========================== + APEX Boot Loader + FIS Driver +=========================== + +This README explains some of the features and implementation details +of the FIS driver. FIS is also sometimes called the RedBoot partition +format. This driver supports the flash partition format with an +extension that allows targets to more easily be upgraded. + + +Using FIS Partitions +-------------------- + +The form of fis partition regions is + + fis://PARTITION@OFFSET+LENGTH + +Offset defaults to 0 and the length defaults to the whole length of +the partition. Partition names are case insensitive. The names of +the partitions may be shown with the version command. + + +Underlying Region +----------------- + +The CONFIG_DRIVER_FIS_BLOCKDEVICE region describes the underlying +region for the FIS partitioned data. Due to the way that the +partitions map onto flash, this region may only include the driver. +No offset or extent will be used. + +As far as I know, FIS is only used on NOR flash, but there is no +reason it couldn't be used on NAND flash. As such, there is little +reason for the underlying driver to be anything but "nor:". + + +Skip Descriptors +---------------- + +APEX supports an extension to the partition format that describes +portions of flash to be skipped over during IO. The FIS partition +table entries are each 256 bytes long, but only 44 bytes of each is +in-use. APEX scans the padding area for fis_skip_descriptors + + struct fis_skip_descriptor { + char magic[4]; /* 's' 'k' 'i' 'p' */ + unsigned long offset; /* Offset from partition start */ + unsigned long length; /* Size of skip in bytes */ + }; + +The driver supports up to 4 skip descriptors per partition and they +may appear in any order and any aligned location within the padding +area. A skip offset of zero indicates that the skip is at the +beginning of the partition. + +Skip descriptors were introduced to allow one partition to overlay two +others and where the start of the second partition has bytes that are +not part of the valid data in the whole. In the example below, the +sercomm header at the start of kernel2 is necessary to mollify RedBoot +which thinks that that address is the start of the ramdisk partition. +Essentially, RedBoot ignores the partition table and uses hard-coded +addresses for the partitions, but we want to use a kernel that is +larger than the partition size defined in RedBoot. + + + +----------------+ + kernel1 ^ | sercomm header | ^ kernel + | |----------------| | + | | First part of | | + v | kernel | | + +----------------+ | + kernel2 ^ | sercomm header | | + | |----------------| | + | | Second part of | | + v | kernel | v + +----------------+ + +The kernel partition will have a skip descriptor that skips the +SERCOMM header that appears at the start of kernel2 and allows the +following command to properly copy the whole kernel to SDRAM, skipping +both of the SERCOMM headers. + + apex> copy fis://kernel@16 $bootaddr + diff --git a/docs/Images b/docs/Images new file mode 100644 index 0000000..f408cca --- /dev/null +++ b/docs/Images @@ -0,0 +1,213 @@ +=========================== + APEX Boot Loader + Boot Images +=========================== + +This README explains some of the features and implementation details +of handling boot image formats. From the start, APEX has worked with +raw, binary data for kernels and ramdisk images. Around the 1.6.x +versions, support for U-BOOT and an APEX image format were added to +improve interoperability and error detection. + + +Image Formats and APEX Commands +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The supported image formats are handled uniformly. Whether it is a +U-BOOT image or an APEX image, the NEW 'image' command will +transparently process either format. The standard copy and checksum +commands will operate on the raw data of the image without attempting +to comprehend the image format iteslf. The new image command performs +operations on images that interpret the header. + + load - load the data of an imate into memory to the addresses + specified in the image header + checksum - verify header and data checksums + show - display information about an image + + +APEX Image Format +~~~~~~~~~~~~~~~~~ + +This is a tagged image format designed to be easy to load, extensible, +and compatible with stream IO. APEX images have the following form: + + IMAGE + +--------+-----+---------+-----+---------+---------+-----+-----+ + | HEADER | CRC | PAYLOAD | CRC | PADDING | PAYLOAD | CRC | ... | + +--------+-----+---------+-----+---------+---------+-----+-----+ + +The HEADER, and the first CRC are required. The PAYLOADs are optional +and there may be more than one. The header must specify the length of +each PAYLOAD. The CRC immediately following the header protects whole +header including the SIGNATURE. Each PAYLOAD is protected by the CRC +that follows it. + +The CRC polynomial is the same for the header and the PAYLOADs, but +the computation of the CRC values is slightly different between them. +The header CRC is computed over the whole HEADER, from signature to +the last padding byte before the CRC such that computing the CRC of +every byte in the header including the CRC will yield a zero. + +The CRC computation for each PAYLOAD is compatible with the POSIX +cksum program. It is the CRC over the data bytes in the PAYLOAD +followed by the significant bytes of the binary integer for the +PAYLOAD length in LSB order. The CRC is the one's complement of this +result which will match the CRC value returned by the cksum command +over the PAYLOAD data. The image file is padded between the PAYLOAD +CRC to force the next PAYLOAD to begin on an even 16 byte boundary. + +The header begins with a four byte SIGNATURE and a single byte +HEADER_SIZE that, when multiplied by 16, specifies the size of the +HEADER including the SIGNATURE, HEADER_SIZE and the CRC. A +HEADER_SIZE value of zero is reserved and invalid. The rest of the +header is a sequence of tagged fields followed by the CRC32 checksum +in the last four bytes. The HEADER is padded between the last FIELD +and the CRC32 to round the HEADER to an even multiple of 16 bytes. + + + HEADER + +-----------+-------------+-------+-----+---------+-------+ + | SIGNATURE | HEADER_SIZE | FIELD | ... | PADDING | CRC32 | + +-----------+-------------+-------+-----+---------+-------+ + + +The signature identifies that the file is an APEX image as well as +specifying the version number of the format; in this case, '0'. The +format is designed such that there ought not be a reason to revise it, +but the option is left open. + + SIGNATURE (4B) + +------+------+------+------+ + | 0x41 | 0x69 | 0x30 | 0xb9 | + +------+------+------+------+ + + +FIELDs begin with a one byte TAG that is a combination of a field ID +and a two bit encoding of the field SIZE. + + TAG (1B) + +---+---+---+---+---+---+---+---+ + | FIELD_ID | SIZE | + +---+---+---+---+---+---+---+---+ + 7 6 5 4 3 2 1 0 + +The SIZE field encodes as follows: + + 1 1 - Field has no bytes following the TAG. + 1 0 - Field has one data byte following the TAG. + 0 1 - Field has 4 bytes of data following the TAG. + 0 0 - First byte after the TAG defines the length of data + following the TAG. + +Four byte DATA usually carry 32 bit integers. These values must be +stored in MSB order. To be more precise, multi-byte values in the +header are always stored in network order, MSB first. + +Variable length fields are often UTF-8 strings. These strings must be +null terminated even though doing so is redundant. Thus, the string +field "Awesome" would require nine DATA bytes. + +The length byte for variable length fields has a range from 0 to 127. +Values above 127 are reserved and invalid. A zero length byte value +is valid and may be used for FIELDs that usually have variable length +data, but are empty in a particular cases. + +FIELD_ID's have a range from 0x0 to 0xfc where the lowest two bits are +set to zero. IDs 0x00 - 0x0c and 0xe0 - 0xf8 are reserved. ID 0xfc +is a NOP field and a TAG of 0xff must be used as padding in the +header. + + Field IDs + ~~~~~~~~~ + + 0x10 | 0 - Image description (V) + 0x14 | 1 - Image creation date (4B) + 0x30 | 1 - Payload length in bytes, must be first for each payload (4B) + 0x34 | 1 - Payload load address (4B) + 0x38 | 1 - Payload entry point (4B) + 0x3c | 2 - Payload type (1B) + 0x01 Linux Kernel + 0x02 Linux Kernel Initrd + 0x40 | 0 - Payload description (V) + 0x44 | 3 - Payload compression (0B) + 0x80 | 1 - Linux Kernel architecture ID (4B) + 0xfc | 3 - NOP; padding (0B) + +As a matter of practical implementation, there shall be only one size +encoding for each TAG. This is both a convention, to make the +generation and parsing of FIELDs easier, and a standardization of the +header data format. For example, even though a succinct payload +description field, e.g. "One", would require just four bytes, the TAG +is defined as 0x00 such that it always bears a length byte. + + +U-BOOT Image Format +~~~~~~~~~~~~~~~~~~~ + +The UBOOT image format was originally designed to carry a single payload. +The file begins with a fixed-length header, 64 bytes followed by the +payload. + + IMAGE + +--------+---------+ + | HEADER | PAYLOAD | + +--------+---------+ + +There is a multi-image format that modifies the basic format with an +NULL terminated array of payload lengths immediately after the header +and followed by the payload data. + + MULTI-IMAGE + +--------+--------+-----+---+---------+ + | HEADER | LENGTH | ... | 0 | PAYLOAD | + +--------+--------+-----+---+---------+ + +In this case, the header is identical, so there is only one CRC for +all payloads, the data_size field of the header refers to the size of +all payloads, there is only one entry point, and there is only one +load address for all payloads. All payload data is loaded starting at +the load address in the header. When booting Linux, UBOOT interprets +the first two payloads of a multi-image as a kernel and initrd. The +load address and length of the initrd will be recorded and passed to +the kernel. APEX performs the same steps. + +The U-BOOT header is a fixed size record with several enumerated +fields. For the most part, these fields are ignored and are +unimportant when this format is being used to load Linux kernels and +initial ramdisk images. + + struct header { + uint32_t magic; // 0x27 0x05 0x19 0x56 + uint32_t header_crc; + uint32_t time; + uint32_t size; + uint32_t load_address; + uint32_t entry_point; + uint32_t crc; // CRC for all payloads + uint8_t os; + uint8_t architecture; + uint8_t image_type; + uint8_t compression; + char image_name[32]; + }; + +Part of the design of the APEX image format is aimed to address some +of the awkward design choices present in the U-BOOT design. + + o The U-BOOT header checksum field is in the middle of the header. + It must be zeroed when computing the header CRC. + o The U-BOOT CRC is LSB ordered which makes it incompatible with + cksum. It also does not compute to zero when the CRC is appended + to the end of the calculation. + o The header is fixed size which illicited the multi-image hack used + to load the kernel and initrd from a single image. + o There are several fields in the header that don't pertain to + loading images for Linux. These fields cannot be removed. + o Even with a multi-image format, there is no way to change the load + address of successive payloads. All payloads are loaded + sequentially and the loader must assume that the first payload is + the kernel and the second is an initrd. There is an option to the + image command that will relocate the initrd of a uBoot image which + *must* not follow the kernel where the kernel is loaded for + execution. diff --git a/docs/MemoryMap b/docs/MemoryMap new file mode 100644 index 0000000..f8b1ebe --- /dev/null +++ b/docs/MemoryMap @@ -0,0 +1,44 @@ +=========================== + APEX Boot Loader + MemoryMap +=========================== + +It may be helpful to understand where pieces go in RAM and why. It is +easy for these numbers to change, so be careful about depending on +them. Always check the compiled programs to be sure. + +The numbers herin reflect an ARM system where SDRAM starts at +0xc0000000. The base address for SDRAM varies from chip to chip and +from architecture to architecture. + + +APEX +---- + +The loader copies itself from wherever it start execution to +0xc0200000. It only copies the code and read-only data portions. +BSS, stacks, and some buffers follow the code in memory. In some +configurations, this image may be 300KiB or more in total. + + +Kernel +------ + +Most kernels execute at 0xc0008000. Compressed kernels are preceeded +by a decompression header that will move the kernel if necessary after +decompressing it. APEX runs at the 2MiB boundary. The kernel must be +smaller than 2MiB - 32KiB for it to start execution at 0xc0008000. +This is a safe assumption since most compressed kernels a megabyte or +less. + + +ATAGS +----- + +In the 2.6 kernel series, information about the running system as well +as the command line is passed in an ATAG structure list. This list is +begins at 0xc0000100. There has been some effort applied to make this +base address available in a register when the kernel receives +execution control. That work is incomplete. + + diff --git a/docs/Network b/docs/Network new file mode 100644 index 0000000..8f7adce --- /dev/null +++ b/docs/Network @@ -0,0 +1,14 @@ +=========================== + APEX Boot Loader + Network +=========================== + +There is some support for networking in APEX. Where there are +Ethernet drivers, support exists for RARP and TFTP as well as ICMP +ping. + +The UDP code does not generate checksums by default. Reportedly, this +may cause problems with some inet daemons. The UDP code sets the +checksum to zero to indicate that there is no checksum. If the TFTP +requests are being ignored, try a different daemon or eliminate the +inetd startup for the daemon. diff --git a/docs/Porting b/docs/Porting new file mode 100644 index 0000000..972822a --- /dev/null +++ b/docs/Porting @@ -0,0 +1,65 @@ +=========================== + APEX Boot Loader + Porting +=========================== + +This README gives a very coarse overview of the process for porting +APEX to an unsupported machine. + + Machine Directory + ----------------- + +Machine/board specific code goes into a machine directory, src/mach-*. +Generally, these are organized by the specific CPU implementation and +not the board as there tends to be a lot of shared code among targets +with the same CPU. + +Each build requires a configuation file, src/mach-*/*_config. Refer +to the README_config for details on the configuration parameters. + + Target Initialization + --------------------- + +Assuming that the CPU architecture is already supported, src/arch-*, +the first piece to implement is the initialization code. When APEX is +first executed, it executes initialize_bootstrap () to prepare SDRAM +before copying APEX out of flash. It is wise to do only what must be +done before relocating APEX in this function. + +usleep(), necessary to pace SDRAM initialization, is required to +support APEX. + +On returning from initialize_bootstrap (), APEX relocates to SDRAM and +calls the service initializations. Targets that need some +initializatons that were not performed in initialize_bootstrap () and +will not be performed by device drivers may implement a service_0. + + + Serial Driver + ------------- + +All platforms should implement a console service. This code is +implemented in the machine directory because it tends to be small and, +so far, none are similar enough to benefit from a generic serial +driver. + + + Timer Driver + ------------ + +There is a handful of places in the code that rely on a long-term +delay to give the user a chance to perform an action, or to control +timeouts (e.g. XMODEM). The timer driver returns an opaque 32 bit +value and must support a delta function to compute elapsed time in +milliseconds. The timer driver must support ranges of time of at +least 15 seconds. + + + NOR Flash Driver + ---------------- + +All platforms should implement a flash driver. The LH7A40X NOR driver +is nearly generic for CFI compliant devices. Eventually, this code +will be put into a library. + + diff --git a/docs/Regions b/docs/Regions new file mode 100644 index 0000000..2d88106 --- /dev/null +++ b/docs/Regions @@ -0,0 +1,113 @@ +=========================== + APEX Boot Loader + Regions +=========================== + +APEX uses a common notation when describing regions of memory, data +sources, and data sinks. While similar to the way that the kernel +refers to regions of memory, the APEX notation is not compatible with +the kernel form. + + REGION := [DRIVER:][@]START[+LENGTH] + REGION := [DRIVER:][[//LOCATION][/PATH]][[@START][+LENGTH]] + REGION := REGION%REGION[%REGION...] + +The DRIVER is the name of an IO driver that handles the requests. +Without an explicit driver, the 'memory:' driver is the default. +Driver names may be shortened to any unambiguous prefix. If there is +only one driver that begins with the letter 'm', then 'm:' uniquely +identifies that driver. If there are two 'nor' drivers, APEX will +require a driver name long enough to distinguish which one to use. +The command 'drvinfo' lists the available drivers. + +The START address is the beginning of the region relative to the +driver's domain. In the case of the memory driver, this is the start +of addressable memory. For other devices such as flash memory, the +first memory location in the device is zero. Thus, for a flash part +mapped at 0x40000000, nor:0 to the first byte at physical address +0x40000000. + +The LENGTH is a count of bytes. It may be omitted when the length is +either self-evident or when there is a reasonable default. For +example, when dumping a region, the default length is 64. When +erasing flash, the default length is 1. The marker '+' replaces the +original '#' which is deprecated though still supported. The # +character is more useful as a comment character. + +START and LENGTH may be specifed as a decimal number, a hexadecimal +number, and may followed by a suffix 'm' for for megabytes (1024*1024), +'k' for kilobytes (1024) or 's' for sectors (512). + + nor:16k+4k - 4096 bytes, 16384 bytes from the start of NOR flash + nand:0 - Starting with the first byte using the only NAND driver + nand-eb501:0 - Starting with the first byte using a specific NAND driver + +Drivers that accept pathnames, such as fat:, have an extended syntax +to allow selection of a LOCATION and a PATH. The form of the LOCATION +depends on the driver. The fat: driver accepts a partition number +from 1 to 4. The PATH is a valid filesystem path. Note that because +the descriptor may still be modified by a @START or +LENGTH modifier, +filenames may not contain '@' or '+'. + +There is a further ambiguity in the region syntax where a PATH may be +present. In the absence of either a leading '/' or '@', the parser +must choose to interpret the first word as either a path, or a +starting offset. It does so by inspecting the first character of the +field. If it is a number, the field is assumed to be a START value. +Otherwise, it is assumed to be a PATH. + +The % special character allows merging of two or more REGION +specifiers. This is a convenience for situations where a REGION is +composed by combining a driver with an offset and extent. Drivers +that define a driver basis, e.g. fat and ext2, work this way. +Appending these REGION strings would require that the syntax of the +REGIONs be properly matched. The % operator forms a REGION specifier +where the first portion is parsed and then the second. Elements of +the region defined in the second and successive REGIONs override those +of the first. Appending "ata://1" to "+1s" requires an intervening +"/". Appending "ata" to "+1s" requires an intervening ":". The '%' +operator smooths over this difference such that inserting it between +either set of REGIONSs produces a proper result, "ata://1%+1s" or +"ata%+1s". + + +Filesystem Drivers +------------------ + +The filesystem drivers such as ext2 and fat support the pathname +region form. + + [DRIVER:][[//LOCATION][/PATH]][[@START][+LENGTH]] + +The LOCATION field is the MSDOS partition number, numbered from 1. +Typical usage looks like the following: + + ext2://1/boot/zImage + +The START and LENGTH fields are optional and may be used to qualify +the region. Without them, the region describes the whole file. + + ext2://1/boot/zImage@1k+32k + +This refers to 32KiB of the file /boot/zImage in the first partition +starting 1KiB from the start of the file. + + +Partition Drivers +----------------- + +The partition drivers, of which there is only the fis driver, +translate a partition name or number into a region on the source +medium. These drivers make this translation when the region is +opened. + +The FIS driver takes an underlying region covering the FIS partition +table. The LOCATION field of an fis region is the case insensitive +name of the partition. + + fis://kernel + +Like the filesystem drivers, the START and LENGTH fields are optional +and may be used to qualify the region. Without then, the region +describes the whole partition. + diff --git a/docs/Sections b/docs/Sections new file mode 100644 index 0000000..2c586c3 --- /dev/null +++ b/docs/Sections @@ -0,0 +1,139 @@ +=========================== + APEX Boot Loader + Sections +=========================== + +Much of the organization of the APEX binary image is controlled by the +linker script and sections therein. This has become sufficiently +complex such that documentation specific to the linker sections is +necessary to make sense of it. + +Section names always begin with a period in order to isolate the +section symbols from other globals in the link. No section may begin +with the string '.rel' because the linker will complain that it is a +relocation section. + +The primary hurdles that the loader encounters, before it can execute +as a bonafide C program are: + + o No RAM (SDRAM, DDR) + o No stack + o No function calls + o In some instances, very little of the loader is available for execution + +When the processor leaves RESET and begins executing code, the loader +must initialize SDRAM, put the kernel into SDRAM, and then jump to the +kernel with appropriate supporting data structures. Sometimes, it is +that easy, but there are many times when it is not. + + o Without RAM for a stack, some architectures can make no procedure + calls. Some CPUs have SRAM and some architectures can be coerced + into using cache as RAM. It is safest to eliminate procedure + calls until system RAM + o Booting from NAND flash or I2C, for example, may only give us 512 + bytes or a 1k of code to execute before we have to copy the reset + of the loader to RAM. Constrained boot modes provide a direct + challenge to writing a single, loader program. + +There are several popular solutions to these problems, C macros to +eliminate procedure calls, using cache as RAM for a stack, and writing +a separate program to handle the bootstrap from NAND and other +constrained boot modes. APEX takes a different approach. + +The linker script defines a sequence of sections. Each section is +owned by a particular type of code, platform, architecture, +relocation. The linker script collates these sections, allowing the +startup code to be interleaved without requiring function calls. This +interleaving also guarantees that important code is placed at the top +of the APEX binary image. + +The result is that a single APEX image can be used to perform a +complete startup for a platform. If the hardware *can* be booted, +APEX can do it. + +Some sections include subsections with suffixes .func and .exit. +These force an order on the code within the section should it be +necessary. + +The sections are as follows. If this list doesn't match the linker +script, please contact the author. + + .entry + +is the first code to execute. On ARM, it is either empty, or it is a +jump over the section that follows it (.envlink) which is used to +identify APEX in flash. + + .envlink + +is a data structure used to identify APEX from user-mode programs by +scanning flash for the signature. + + .reset + +performs the first, architecture specific startups. As little as is +possible should be in .reset. + + .bootstrap.early + +is the first opportunity for the target to perform some +initialzations. This code should be as small as possible, just enough +to support early relocation, perhaps a UART, and the RAM +initialization. + + .rlocate.early + +is an opportunity to perform an early relocation, before RAM has been +initialized, in order to get access to enough of the loader to perform +the RAM setup. Early relocation is often necessary when booting from +NAND flash or I2C EEPROM. + + .reset.pre + +checks whether or not APEX is already running in RAM. It depends on +data from the platform to determine the range of RAM addresses. This +code is factored out of the RAM initialization code in order to +simplify platform adaptations and to make sure that all targets +function the same way. + + .bootstrap.sdram + +is the code to initialize RAM, SDRAM or otherwise. It should 'return' +a zero in the register that the architecture expects to find return +values. This zero tells the .reset.post code that the RAM was +initialized. + +On ARM platforms, the SDRAM initialization usually implements a +udelay() function that is used elsewhere in the application. This +function should be placed in section .bootstrap.sdram.func and the RAM +initialization must jump over this code to a symbol in section +.bootstrap.sdram.exit. + + .reset.post + +checks the 'return' value from the RAM initialization to determine +whether or not initialization occurred. If it was initialized, it may +run a memory test. + + .rlocate + +performs the final relocation of APEX to RAM and to the final linked +executation address. The specifics of where APEX is sourced depends +on the boot mode. For NOR flash and running from RAM, the relocator +is a simple copy. For NAND flash, all of APEX is pulled from the NAND +flash array. + + .reset.finish + +This section is for architecture pickups, in case something special +needs to be done after the loader is moved or relocated. It also +performs the C setups before jumping to init() and beginning the +standard C portion of APEX. + + .bootstrap + +is a pickup segment to hold bootstrap code that wasn't included in the +previous segments. Legacy platforms will have their initialization +code here as a function call from .reset.post. New platforms should +put nothing in the .bootstrap section. + diff --git a/docs/Variations b/docs/Variations new file mode 100644 index 0000000..bd7d86e --- /dev/null +++ b/docs/Variations @@ -0,0 +1,63 @@ +=========================== + APEX Boot Loader + Variations +=========================== + +This README gives background and some guidance for implementing and +using variations. + + Overview + -------- + +Variations were added to APEX to facilitate alternative booting +methods. It is common to want a secondary boot process that is +activated by some sort of user action or system state. The specifics +of how these secondary processes is selected is specific to a target +or build of APEX, but the mechanism should be the same in all cases. + +By defining an environment variable or alias of the name 'variation', +APEX will select alternative versions of environment variables or +aliases when available when expanding them on the command line or when +variables are referenced by drivers. When 'variation' is set to +'_alt', APEX will first look for the startup command in 'startup_alt' +and then in 'startup' if the variation is not present. This is true +for all variable references include the ones used to define the base +regions for drivers. + + Implementation + -------------- + +Most targets will want to detect the variation from a runtime source, +e.g. a button being pressed while power is applied. The easiest +method for performing this check is within a service. Care must be +taken to execute the variation service after critical system services +are available such as timers. Generally, it should be safe to +implement the variation service last. + + Environment Variables vs. Aliases + --------------------------------- + +Runtime selection of the variation requires that aliases be +configured. Remember, the difference between environment variables +and aliases is that environment variables are immediately saved to +non-volatile storage when set and aliases are only stored in RAM + + _alt vs. -alt + ------------- + +While both are perfectly valid and the environment variable expansion +code supports both, it is important to be aware that variable and +alias names will only expand with alphanumeric names with - and _ +added to aid readability. + + ==================== + +static void variation_init (void) +{ + if (is_reset_button_pressed ()) + alias_set ("variation", "_alt"); +} + +static __service_9 struct service_d variation_service = { + .init = variation_init, +}; diff --git a/include/alias.h b/include/alias.h new file mode 100644 index 0000000..25ffd55 --- /dev/null +++ b/include/alias.h @@ -0,0 +1,33 @@ +/* alias.h + + written by Marc Singer + 6 July 2005 + + Copyright (C) 2005 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + +*/ + +#if !defined (__ALIAS_H__) +# define __ALIAS_H__ + +/* ----- Types */ + +/* ----- Prototypes */ + +void* alias_enumerate (void* pv, const char** pszKey, + const char** pszValue); +const char* alias_lookup (const char* szKey); +int alias_set (const char* szKey, const char* szValue); +int alias_unset (const char* szKey); +int alias_set_hex (const char* szKey, unsigned value); + +#endif /* __ALIAS_H__ */ diff --git a/include/apex.h b/include/apex.h new file mode 100644 index 0000000..3a9b87b --- /dev/null +++ b/include/apex.h @@ -0,0 +1,82 @@ +/* apex.h + + written by Marc Singer + 3 Nov 2004 + + Copyright (C) 2004 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + +*/ + +#if !defined (__INIT_H__) +# define __INIT_H__ + +/* ----- Includes */ + +#include +#include +#include + +/* ----- Constants */ + +#if defined (CONFIG_SMALL) +# define C_ARG_MAX (20) /* Maximum number of command line word */ +# define CB_COMMAND_MAX (80*2) +# define CB_PRINTF_MAX (80*2) +#else +# define C_ARG_MAX (64) /* Maximum number of command line word */ +# define CB_COMMAND_MAX (1024) +# define CB_PRINTF_MAX (2*1024) +#endif + +/* ----- Types */ + +/* ----- Globals */ + +/* ----- Prototypes */ + +#if !defined (barrier) +# define barrier() __asm volatile ("":::"memory") +#endif + +extern void init_drivers (void); +extern int __attribute__((format (printf, 1, 2))) + printf (const char * fmt, ...); +extern int putchar (int ch); +extern int puts (const char * fmt); +extern int snprintf(char * buf, size_t size, const char * fmt, ...); +extern int sprintf(char * buf, const char * fmt, ...); +extern int read_command (const char* szPrompt, + int* pargc, const char*** pargv); +extern int parse_command (char* rgb, int* pargc, const char*** pargv); +extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); + +extern void __attribute__((noreturn)) exec_monitor (void); + +extern unsigned long timer_read (void); +extern unsigned long timer_delta (unsigned long, unsigned long); +extern void usleep (unsigned long); +#define udelay usleep /* Just for convenience */ +static inline void msleep (int c) { /* Only way to guarantee the range */ + while (c-- > 0) udelay (1000); } +#define mdelay msleep + + +#define dump(p,c,i) dumpw(p,c,i,0) +extern void dumpw (const char* rgb, int cb, + unsigned long index, int width); + +#if defined (CONFIG_COMMAND_HISTORY) +void history_add (const char* sz); +int history_retrieve (int backward, char* rgb, size_t cbMax); +#endif + +#endif /* __INIT_H__ */ diff --git a/include/arch-arm.h b/include/arch-arm.h new file mode 100644 index 0000000..035c79f --- /dev/null +++ b/include/arch-arm.h @@ -0,0 +1,34 @@ +/* arch-arm.h + + written by Marc Singer + 25 Jul 2006 + + Copyright (C) 2006 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + +*/ + +#if !defined (__ARCH_ARM_H__) +# define __ARCH_ARM_H__ + +/* ----- Includes */ + +/* ----- Types */ + +/* ----- Globals */ + +/* ----- Prototypes */ + +extern void preinitialization (void); +extern void relocate_apex (void); +extern const char* cp15_ctrl (unsigned long); + +#endif /* __ARCH_ARM_H__ */ diff --git a/include/asm-arm/assembler.h b/include/asm-arm/assembler.h new file mode 100644 index 0000000..6116e48 --- /dev/null +++ b/include/asm-arm/assembler.h @@ -0,0 +1,116 @@ +/* + * arch/arm/include/asm/assembler.h + * + * Copyright (C) 1996-2000 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This file contains arm architecture specific defines + * for the different processors. + * + * Do not include any C declarations in this file - it is included by + * assembler source. + */ +#ifndef __ASSEMBLY__ +#error "Only include this from assembly code" +#endif + +#include + +/* + * Endian independent macros for shifting bytes within registers. + */ +#ifndef __ARMEB__ +#define pull lsr +#define push lsl +#define get_byte_0 lsl #0 +#define get_byte_1 lsr #8 +#define get_byte_2 lsr #16 +#define get_byte_3 lsr #24 +#define put_byte_0 lsl #0 +#define put_byte_1 lsl #8 +#define put_byte_2 lsl #16 +#define put_byte_3 lsl #24 +#else +#define pull lsl +#define push lsr +#define get_byte_0 lsr #24 +#define get_byte_1 lsr #16 +#define get_byte_2 lsr #8 +#define get_byte_3 lsl #0 +#define put_byte_0 lsl #24 +#define put_byte_1 lsl #16 +#define put_byte_2 lsl #8 +#define put_byte_3 lsl #0 +#endif + +/* + * Data preload for architectures that support it + */ +#if __LINUX_ARM_ARCH__ >= 5 +#define PLD(code...) code +#else +#define PLD(code...) +#endif + +/* + * This can be used to enable code to cacheline align the destination + * pointer when bulk writing to memory. Experiments on StrongARM and + * XScale didn't show this a worthwhile thing to do when the cache is not + * set to write-allocate (this would need further testing on XScale when WA + * is used). + * + * On Feroceon there is much to gain however, regardless of cache mode. + */ +#ifdef CONFIG_CPU_FEROCEON +#define CALGN(code...) code +#else +#define CALGN(code...) +#endif + +/* + * Enable and disable interrupts + */ +#if __LINUX_ARM_ARCH__ >= 6 + .macro disable_irq + cpsid i + .endm + + .macro enable_irq + cpsie i + .endm +#else + .macro disable_irq + msr cpsr_c, #PSR_I_BIT | SVC_MODE + .endm + + .macro enable_irq + msr cpsr_c, #SVC_MODE + .endm +#endif + +/* + * Save the current IRQ state and disable IRQs. Note that this macro + * assumes FIQs are enabled, and that the processor is in SVC mode. + */ + .macro save_and_disable_irqs, oldcpsr + mrs \oldcpsr, cpsr + disable_irq + .endm + +/* + * Restore interrupt state previously stored in a register. We don't + * guarantee that this will preserve the flags. + */ + .macro restore_irqs, oldcpsr + msr cpsr_c, \oldcpsr + .endm + +#define USER(x...) \ +9999: x; \ + .section __ex_table,"a"; \ + .align 3; \ + .long 9999b,9001f; \ + .previous diff --git a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h new file mode 100644 index 0000000..3b59f94 --- /dev/null +++ b/include/asm-arm/atomic.h @@ -0,0 +1,212 @@ +/* + * linux/include/asm-arm/atomic.h + * + * Copyright (C) 1996 Russell King. + * Copyright (C) 2002 Deep Blue Solutions Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_ARM_ATOMIC_H +#define __ASM_ARM_ATOMIC_H + +#include +#include + +typedef struct { volatile int counter; } atomic_t; + +#define ATOMIC_INIT(i) { (i) } + +#ifdef __KERNEL__ + +#define atomic_read(v) ((v)->counter) + +#if __LINUX_ARM_ARCH__ >= 6 + +/* + * ARMv6 UP and SMP safe atomic ops. We use load exclusive and + * store exclusive to ensure that these are atomic. We may loop + * to ensure that the update happens. Writing to 'v->counter' + * without using the following operations WILL break the atomic + * nature of these ops. + */ +static inline void atomic_set(atomic_t *v, int i) +{ + unsigned long tmp; + + __asm__ __volatile__("@ atomic_set\n" +"1: ldrex %0, [%1]\n" +" strex %0, %2, [%1]\n" +" teq %0, #0\n" +" bne 1b" + : "=&r" (tmp) + : "r" (&v->counter), "r" (i) + : "cc"); +} + +static inline int atomic_add_return(int i, atomic_t *v) +{ + unsigned long tmp; + int result; + + __asm__ __volatile__("@ atomic_add_return\n" +"1: ldrex %0, [%2]\n" +" add %0, %0, %3\n" +" strex %1, %0, [%2]\n" +" teq %1, #0\n" +" bne 1b" + : "=&r" (result), "=&r" (tmp) + : "r" (&v->counter), "Ir" (i) + : "cc"); + + return result; +} + +static inline int atomic_sub_return(int i, atomic_t *v) +{ + unsigned long tmp; + int result; + + __asm__ __volatile__("@ atomic_sub_return\n" +"1: ldrex %0, [%2]\n" +" sub %0, %0, %3\n" +" strex %1, %0, [%2]\n" +" teq %1, #0\n" +" bne 1b" + : "=&r" (result), "=&r" (tmp) + : "r" (&v->counter), "Ir" (i) + : "cc"); + + return result; +} + +static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) +{ + unsigned long oldval, res; + + do { + __asm__ __volatile__("@ atomic_cmpxchg\n" + "ldrex %1, [%2]\n" + "mov %0, #0\n" + "teq %1, %3\n" + "strexeq %0, %4, [%2]\n" + : "=&r" (res), "=&r" (oldval) + : "r" (&ptr->counter), "Ir" (old), "r" (new) + : "cc"); + } while (res); + + return oldval; +} + +static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) +{ + unsigned long tmp, tmp2; + + __asm__ __volatile__("@ atomic_clear_mask\n" +"1: ldrex %0, [%2]\n" +" bic %0, %0, %3\n" +" strex %1, %0, [%2]\n" +" teq %1, #0\n" +" bne 1b" + : "=&r" (tmp), "=&r" (tmp2) + : "r" (addr), "Ir" (mask) + : "cc"); +} + +#else /* ARM_ARCH_6 */ + +#include + +#ifdef CONFIG_SMP +#error SMP not supported on pre-ARMv6 CPUs +#endif + +#define atomic_set(v,i) (((v)->counter) = (i)) + +static inline int atomic_add_return(int i, atomic_t *v) +{ + unsigned long flags; + int val; + + raw_local_irq_save(flags); + val = v->counter; + v->counter = val += i; + raw_local_irq_restore(flags); + + return val; +} + +static inline int atomic_sub_return(int i, atomic_t *v) +{ + unsigned long flags; + int val; + + raw_local_irq_save(flags); + val = v->counter; + v->counter = val -= i; + raw_local_irq_restore(flags); + + return val; +} + +static inline int atomic_cmpxchg(atomic_t *v, int old, int new) +{ + int ret; + unsigned long flags; + + raw_local_irq_save(flags); + ret = v->counter; + if (likely(ret == old)) + v->counter = new; + raw_local_irq_restore(flags); + + return ret; +} + +static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) +{ + unsigned long flags; + + raw_local_irq_save(flags); + *addr &= ~mask; + raw_local_irq_restore(flags); +} + +#endif /* __LINUX_ARM_ARCH__ */ + +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + +static inline int atomic_add_unless(atomic_t *v, int a, int u) +{ + int c, old; + + c = atomic_read(v); + while (c != u && (old = atomic_cmpxchg((v), c, c + a)) != c) + c = old; + return c != u; +} +#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) + +#define atomic_add(i, v) (void) atomic_add_return(i, v) +#define atomic_inc(v) (void) atomic_add_return(1, v) +#define atomic_sub(i, v) (void) atomic_sub_return(i, v) +#define atomic_dec(v) (void) atomic_sub_return(1, v) + +#define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0) +#define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0) +#define atomic_inc_return(v) (atomic_add_return(1, v)) +#define atomic_dec_return(v) (atomic_sub_return(1, v)) +#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0) + +#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0) + +/* Atomic operations are already serializing on ARM */ +#define smp_mb__before_atomic_dec() barrier() +#define smp_mb__after_atomic_dec() barrier() +#define smp_mb__before_atomic_inc() barrier() +#define smp_mb__after_atomic_inc() barrier() + +#include +#endif +#endif diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h new file mode 100644 index 0000000..5c60bfc --- /dev/null +++ b/include/asm-arm/bitops.h @@ -0,0 +1,333 @@ +/* + * Copyright 1995, Russell King. + * Various bits and pieces copyrights include: + * Linus Torvalds (test_bit). + * Big endian support: Copyright 2001, Nicolas Pitre + * reworked by rmk. + * + * bit 0 is the LSB of an "unsigned long" quantity. + * + * Please note that the code in this file should never be included + * from user space. Many of these are not implemented in assembler + * since they would be too costly. Also, they require privileged + * instructions (which are not available from user mode) to ensure + * that they are atomic. + */ + +#ifndef __ASM_ARM_BITOPS_H +#define __ASM_ARM_BITOPS_H + +#ifdef __KERNEL__ + +#ifndef _LINUX_BITOPS_H +#error only can be included directly +#endif + +#include +#include + +#define smp_mb__before_clear_bit() mb() +#define smp_mb__after_clear_bit() mb() + +/* + * These functions are the basis of our bit ops. + * + * First, the atomic bitops. These use native endian. + */ +static inline void ____atomic_set_bit(unsigned int bit, volatile unsigned long *p) +{ + unsigned long flags; + unsigned long mask = 1UL << (bit & 31); + + p += bit >> 5; + + raw_local_irq_save(flags); + *p |= mask; + raw_local_irq_restore(flags); +} + +static inline void ____atomic_clear_bit(unsigned int bit, volatile unsigned long *p) +{ + unsigned long flags; + unsigned long mask = 1UL << (bit & 31); + + p += bit >> 5; + + raw_local_irq_save(flags); + *p &= ~mask; + raw_local_irq_restore(flags); +} + +static inline void ____atomic_change_bit(unsigned int bit, volatile unsigned long *p) +{ + unsigned long flags; + unsigned long mask = 1UL << (bit & 31); + + p += bit >> 5; + + raw_local_irq_save(flags); + *p ^= mask; + raw_local_irq_restore(flags); +} + +static inline int +____atomic_test_and_set_bit(unsigned int bit, volatile unsigned long *p) +{ + unsigned long flags; + unsigned int res; + unsigned long mask = 1UL << (bit & 31); + + p += bit >> 5; + + raw_local_irq_save(flags); + res = *p; + *p = res | mask; + raw_local_irq_restore(flags); + + return res & mask; +} + +static inline int +____atomic_test_and_clear_bit(unsigned int bit, volatile unsigned long *p) +{ + unsigned long flags; + unsigned int res; + unsigned long mask = 1UL << (bit & 31); + + p += bit >> 5; + + raw_local_irq_save(flags); + res = *p; + *p = res & ~mask; + raw_local_irq_restore(flags); + + return res & mask; +} + +static inline int +____atomic_test_and_change_bit(unsigned int bit, volatile unsigned long *p) +{ + unsigned long flags; + unsigned int res; + unsigned long mask = 1UL << (bit & 31); + + p += bit >> 5; + + raw_local_irq_save(flags); + res = *p; + *p = res ^ mask; + raw_local_irq_restore(flags); + + return res & mask; +} + +#include + +/* + * A note about Endian-ness. + * ------------------------- + * + * When the ARM is put into big endian mode via CR15, the processor + * merely swaps the order of bytes within words, thus: + * + * ------------ physical data bus bits ----------- + * D31 ... D24 D23 ... D16 D15 ... D8 D7 ... D0 + * little byte 3 byte 2 byte 1 byte 0 + * big byte 0 byte 1 byte 2 byte 3 + * + * This means that reading a 32-bit word at address 0 returns the same + * value irrespective of the endian mode bit. + * + * Peripheral devices should be connected with the data bus reversed in + * "Big Endian" mode. ARM Application Note 61 is applicable, and is + * available from http://www.arm.com/. + * + * The following assumes that the data bus connectivity for big endian + * mode has been followed. + * + * Note that bit 0 is defined to be 32-bit word bit 0, not byte 0 bit 0. + */ + +/* + * Little endian assembly bitops. nr = 0 -> byte 0 bit 0. + */ +extern void _set_bit_le(int nr, volatile unsigned long * p); +extern void _clear_bit_le(int nr, volatile unsigned long * p); +extern void _change_bit_le(int nr, volatile unsigned long * p); +extern int _test_and_set_bit_le(int nr, volatile unsigned long * p); +extern int _test_and_clear_bit_le(int nr, volatile unsigned long * p); +extern int _test_and_change_bit_le(int nr, volatile unsigned long * p); +extern int _find_first_zero_bit_le(const void * p, unsigned size); +extern int _find_next_zero_bit_le(const void * p, int size, int offset); +extern int _find_first_bit_le(const unsigned long *p, unsigned size); +extern int _find_next_bit_le(const unsigned long *p, int size, int offset); + +/* + * Big endian assembly bitops. nr = 0 -> byte 3 bit 0. + */ +extern void _set_bit_be(int nr, volatile unsigned long * p); +extern void _clear_bit_be(int nr, volatile unsigned long * p); +extern void _change_bit_be(int nr, volatile unsigned long * p); +extern int _test_and_set_bit_be(int nr, volatile unsigned long * p); +extern int _test_and_clear_bit_be(int nr, volatile unsigned long * p); +extern int _test_and_change_bit_be(int nr, volatile unsigned long * p); +extern int _find_first_zero_bit_be(const void * p, unsigned size); +extern int _find_next_zero_bit_be(const void * p, int size, int offset); +extern int _find_first_bit_be(const unsigned long *p, unsigned size); +extern int _find_next_bit_be(const unsigned long *p, int size, int offset); + +#ifndef CONFIG_SMP +/* + * The __* form of bitops are non-atomic and may be reordered. + */ +#define ATOMIC_BITOP_LE(name,nr,p) \ + (__builtin_constant_p(nr) ? \ + ____atomic_##name(nr, p) : \ + _##name##_le(nr,p)) + +#define ATOMIC_BITOP_BE(name,nr,p) \ + (__builtin_constant_p(nr) ? \ + ____atomic_##name(nr, p) : \ + _##name##_be(nr,p)) +#else +#define ATOMIC_BITOP_LE(name,nr,p) _##name##_le(nr,p) +#define ATOMIC_BITOP_BE(name,nr,p) _##name##_be(nr,p) +#endif + +#define NONATOMIC_BITOP(name,nr,p) \ + (____nonatomic_##name(nr, p)) + +#ifndef __ARMEB__ +/* + * These are the little endian, atomic definitions. + */ +#define set_bit(nr,p) ATOMIC_BITOP_LE(set_bit,nr,p) +#define clear_bit(nr,p) ATOMIC_BITOP_LE(clear_bit,nr,p) +#define change_bit(nr,p) ATOMIC_BITOP_LE(change_bit,nr,p) +#define test_and_set_bit(nr,p) ATOMIC_BITOP_LE(test_and_set_bit,nr,p) +#define test_and_clear_bit(nr,p) ATOMIC_BITOP_LE(test_and_clear_bit,nr,p) +#define test_and_change_bit(nr,p) ATOMIC_BITOP_LE(test_and_change_bit,nr,p) +#define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) +#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off) +#define find_first_bit(p,sz) _find_first_bit_le(p,sz) +#define find_next_bit(p,sz,off) _find_next_bit_le(p,sz,off) + +#define WORD_BITOFF_TO_LE(x) ((x)) + +#else + +/* + * These are the big endian, atomic definitions. + */ +#define set_bit(nr,p) ATOMIC_BITOP_BE(set_bit,nr,p) +#define clear_bit(nr,p) ATOMIC_BITOP_BE(clear_bit,nr,p) +#define change_bit(nr,p) ATOMIC_BITOP_BE(change_bit,nr,p) +#define test_and_set_bit(nr,p) ATOMIC_BITOP_BE(test_and_set_bit,nr,p) +#define test_and_clear_bit(nr,p) ATOMIC_BITOP_BE(test_and_clear_bit,nr,p) +#define test_and_change_bit(nr,p) ATOMIC_BITOP_BE(test_and_change_bit,nr,p) +#define find_first_zero_bit(p,sz) _find_first_zero_bit_be(p,sz) +#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_be(p,sz,off) +#define find_first_bit(p,sz) _find_first_bit_be(p,sz) +#define find_next_bit(p,sz,off) _find_next_bit_be(p,sz,off) + +#define WORD_BITOFF_TO_LE(x) ((x) ^ 0x18) + +#endif + +#if __LINUX_ARM_ARCH__ < 5 + +#include +#include +#include +#include + +#else + +static inline int constant_fls(int x) +{ + int r = 32; + + if (!x) + return 0; + if (!(x & 0xffff0000u)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xff000000u)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xf0000000u)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xc0000000u)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000u)) { + x <<= 1; + r -= 1; + } + return r; +} + +/* + * On ARMv5 and above those functions can be implemented around + * the clz instruction for much better code efficiency. + */ + +#define fls(x) \ + ( __builtin_constant_p(x) ? constant_fls(x) : \ + ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) +#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) +#define __ffs(x) (ffs(x) - 1) +#define ffz(x) __ffs( ~(x) ) + +#endif + +#include + +#include +#include +#include + +/* + * Ext2 is defined to use little-endian byte ordering. + * These do not need to be atomic. + */ +#define ext2_set_bit(nr,p) \ + __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define ext2_set_bit_atomic(lock,nr,p) \ + test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define ext2_clear_bit(nr,p) \ + __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define ext2_clear_bit_atomic(lock,nr,p) \ + test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define ext2_test_bit(nr,p) \ + test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define ext2_find_first_zero_bit(p,sz) \ + _find_first_zero_bit_le(p,sz) +#define ext2_find_next_zero_bit(p,sz,off) \ + _find_next_zero_bit_le(p,sz,off) +#define ext2_find_next_bit(p, sz, off) \ + _find_next_bit_le(p, sz, off) + +/* + * Minix is defined to use little-endian byte ordering. + * These do not need to be atomic. + */ +#define minix_set_bit(nr,p) \ + __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define minix_test_bit(nr,p) \ + test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define minix_test_and_set_bit(nr,p) \ + __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define minix_test_and_clear_bit(nr,p) \ + __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define minix_find_first_zero_bit(p,sz) \ + _find_first_zero_bit_le(p,sz) + +#endif /* __KERNEL__ */ + +#endif /* _ARM_BITOPS_H */ diff --git a/include/asm-arm/bootstrap.h b/include/asm-arm/bootstrap.h new file mode 100644 index 0000000..2847069 --- /dev/null +++ b/include/asm-arm/bootstrap.h @@ -0,0 +1,48 @@ +/* bootstrap.h + $Id$ + + written by Marc Singer + 9 Nov 2004 + + Copyright (C) 2004 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + +*/ + +#if !defined (__BOOTSTRAP_H__) +# define __BOOTSTRAP_H__ + +/* ----- Includes */ + +#include + +/* ----- Types */ + +/* ----- Globals */ + +extern char APEX_VMA_ENTRY; +extern char APEX_VMA_START; +extern char APEX_VMA_VECTOR_START; +extern char APEX_VMA_VECTOR_END; +extern char APEX_VMA_COPY_START; +extern char APEX_VMA_COPY_END; +extern char APEX_VMA_STACKS_START; +extern char APEX_VMA_STACKS_END; +extern char APEX_VMA_STACK_START; +extern char APEX_VMA_IRQSTACK_START; +extern char APEX_VMA_BSS_START; +extern char APEX_VMA_BSS_END; +extern char APEX_VMA_BOOTSTRAP_STACK_START; + +/* ----- Prototypes */ + + +#endif /* __BOOTSTRAP_H__ */ diff --git a/include/asm-arm/bug.h b/include/asm-arm/bug.h new file mode 100644 index 0000000..7b62351 --- /dev/null +++ b/include/asm-arm/bug.h @@ -0,0 +1,24 @@ +#ifndef _ASMARM_BUG_H +#define _ASMARM_BUG_H + + +#ifdef CONFIG_BUG +#ifdef CONFIG_DEBUG_BUGVERBOSE +extern void __bug(const char *file, int line) __attribute__((noreturn)); + +/* give file/line information */ +#define BUG() __bug(__FILE__, __LINE__) + +#else + +/* this just causes an oops */ +#define BUG() (*(int *)0 = 0) + +#endif + +#define HAVE_ARCH_BUG +#endif + +#include + +#endif diff --git a/include/asm-arm/byteorder.h b/include/asm-arm/byteorder.h new file mode 100644 index 0000000..e6f7fcd --- /dev/null +++ b/include/asm-arm/byteorder.h @@ -0,0 +1,58 @@ +/* + * linux/include/asm-arm/byteorder.h + * + * ARM Endian-ness. In little endian mode, the data bus is connected such + * that byte accesses appear as: + * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 + * and word accesses (data or instruction) appear as: + * d0...d31 + * + * When in big endian mode, byte accesses appear as: + * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7 + * and word accesses (data or instruction) appear as: + * d0...d31 + */ +#ifndef __ASM_ARM_BYTEORDER_H +#define __ASM_ARM_BYTEORDER_H + +#include +#include + +static inline __attribute_const__ __u32 ___arch__swab32(__u32 x) +{ + __u32 t; + +#ifndef __thumb__ + if (!__builtin_constant_p(x)) { + /* + * The compiler needs a bit of a hint here to always do the + * right thing and not screw it up to different degrees + * depending on the gcc version. + */ + asm ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x)); + } else +#endif + t = x ^ ((x << 16) | (x >> 16)); /* eor r1,r0,r0,ror #16 */ + + x = (x << 24) | (x >> 8); /* mov r0,r0,ror #8 */ + t &= ~0x00FF0000; /* bic r1,r1,#0x00FF0000 */ + x ^= (t >> 8); /* eor r0,r0,r1,lsr #8 */ + + return x; +} + +#define __arch__swab32(x) ___arch__swab32(x) + +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __BYTEORDER_HAS_U64__ +# define __SWAB_64_THRU_32__ +#endif + +#ifdef __ARMEB__ +#include +#else +#include +#endif + +#endif + diff --git a/include/asm-arm/cache.h b/include/asm-arm/cache.h new file mode 100644 index 0000000..31332c8 --- /dev/null +++ b/include/asm-arm/cache.h @@ -0,0 +1,10 @@ +/* + * linux/include/asm-arm/cache.h + */ +#ifndef __ASMARM_CACHE_H +#define __ASMARM_CACHE_H + +#define L1_CACHE_SHIFT 5 +#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) + +#endif diff --git a/include/asm-arm/cp15-armv4.h b/include/asm-arm/cp15-armv4.h new file mode 100644 index 0000000..79846f9 --- /dev/null +++ b/include/asm-arm/cp15-armv4.h @@ -0,0 +1,105 @@ +/* cp15-armv4.h + + written by Marc Singer + 13 Jan 2006 + + Copyright (C) 2006 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + +*/ + +#if !defined (__CP15_ARMV4_H__) +# define __CP15_ARMV4_H__ + + /* ---- Cache control */ + +#define INVALIDATE_ICACHE\ + __asm volatile ("mcr p15, 0, %0, c7, c5, 0\n\t" :: "r" (0)) +#define INVALIDATE_ICACHE_VA(a)\ + __asm volatile ("mcr p15, 0, %0, c7, c5, 1\n\t" :: "r" (a)) + +#define INVALIDATE_DCACHE\ + __asm volatile ("mcr p15, 0, %0, c7, c6, 0\n\t" :: "r" (0)) +#define INVALIDATE_DCACHE_VA(a)\ + __asm volatile ("mcr p15, 0, %0, c7, c6, 1\n\t" :: "r" (a)) + +#define INVALIDATE_CACHE\ + __asm volatile ("mcr p15, 0, %0, c7, c7, 0\n\t" :: "r" (0)) + +#define CLEAN_DCACHE_VA(a)\ + __asm volatile ("mcr p15, 0, %0, c7, c10, 1\n\t" :: "r" (a)) +#define CLEAN_DCACHE_I(i)\ + __asm volatile ("mcr p15, 0, %0, c7, c10, 2\n\t" :: "r" (i)) +#define DRAIN_WRITE_BUFFER\ + __asm volatile ("mcr p15, 0, %0, c7, c10, 4\n\t" :: "r" (0)) + +#define PREFETCH_ICACHE_VA(a)\ + __asm volatile ("mcr p15, 0, %0, c7, c13, 1\n\t" :: "r" (a)) + +#define CLEAN_INV_DCACHE_VA(a)\ + __asm volatile ("mcr p15, 0, %0, c7, c14, 1\n\t" :: "r" (a)) +#define CLEAN_INV_DCACHE_I(i)\ + __asm volatile ("mcr p15, 0, %0, c7, c14, 2\n\t" :: "r" (i)) + + /* ---- Cache lockdown */ + +#define UNLOCK_CACHE\ + __asm volatile ("mcr p15, 0, %0, c9, c1, 1\n\t"\ + "mcr p15, 0, %0, c9, c2, 1\n\t" :: "r" (0)) + + /* ---- TLB control */ + +#define INVALIDATE_TLB\ + __asm volatile ("mcr p15, 0, %0, c8, c7, 0\n\t" :: "r" (0)) +#define INVALIDATE_ITLB\ + __asm volatile ("mcr p15, 0, %0, c8, c5, 0\n\t" :: "r" (0)) +#define INVALIDATE_ITLB_VA(a)\ + __asm volatile ("mcr p15, 0, %0, c8, c5, 1\n\t" :: "r" (a)) +#define INVALIDATE_DTLB\ + __asm volatile ("mcr p15, 0, %0, c8, c6, 0\n\t" :: "r" (0)) +#define INVALIDATE_DTLB_VA(a)\ + __asm volatile ("mcr p15, 0, %0, c8, c6, 1\n\t" :: "r" (a)) + + +#define _DLEN(l) ((l>>(12+0))&3) +#define _DSIZE(l) ((l>>(12+6))&7) +#define _DASSOC(l) ((l>>(12+3))&7) +#define _DM(l) ((l>>(12+2))&1) + +/* *** This code may not work on the ARM720T. According to the TRM + *** documentation, the only operation available in the cache is + *** invalidatation of the combined cache in one statement. + *** Cleaning isn't addressed at all. */ + +#define CLEANALL_DCACHE\ + ({ unsigned long cache; int set, index; int linelen; int assoc;\ + __asm volatile ("mrc p15, 0, %0, c0, c0, 1" : "=r" (cache));\ + linelen = _DLEN(cache) + 3;\ + assoc = 32 - _DASSOC(cache);\ +/* if (DM(l)) */ \ +/* assoc = 3*assoc/2; */ \ + for (set = 1<<(_DSIZE(cache) + 6 - _DASSOC(cache) - _DLEN(cache)); \ + set--; )\ + for (index = 1<<_DASSOC(cache); index--;) {\ + __asm volatile ("mcr p15, 0, %0, c7, c10, 2" \ + :: "r" ((index< + +#define CP15_ID\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c0, c0, 0" : "=r" (l)); l; }) +#define CP15_CACHE_TYPE\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c0, c0, 1" : "=r" (l)); l; }) +#define CP15_CTRL\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r" (l)); l; }) +#define CP15_TEST\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c15, c0, 0" : "=r" (l)); l; }) +#define CPSR\ + ({ unsigned long l;\ + __asm volatile ("mrs %0, cpsr" : "=r" (l)); l; }) + +#define STORE_TTB(a)\ + __asm volatile ("mcr p15, 0, %0, c2, c0, 0\n\t" :: "r" (a)) +#define LOAD_TTB\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c2, c0, 0\n\t" : "=r" (l)); l; }) + +#define STORE_DOMAIN(a)\ + __asm volatile ("mcr p15, 0, %0, c3, c0, 0\n\t" :: "r" (a)) +#define LOAD_DOMAIN\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c3, c0, 0\n\t" : "=r" (l)); l; }) + +#define MMU_DISABLE\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c1, c0, 0\n\t"\ + "bic %0, %0, #(1<<0)\n\t"\ + "mcr p15, 0, %0, c1, c0, 0\n\t"\ + : "=&r" (l)); } ) + +#define MMU_ENABLE\ + ({ unsigned long l;\ + __asm volatile ("mrc p15, 0, %0, c1, c0, 0\n\t"\ + "orr %0, %0, #(1<<0)\n\t"\ + "mcr p15, 0, %0, c1, c0, 0\n\t"\ + : "=&r" (l)); } ) + +#define WAIT_FOR_INTERRUPT\ + __asm volatile ("mcr p15, 0, %0, c7, c0, 4\n\t" :: "r" (0)); + + +/* ----- Architecture specific coprocessor support */ + +#if defined (CONFIG_CPU_ARMV4) +# include +#endif + +#if defined (CONFIG_CPU_XSCALE) +# include +#endif + +#if defined (CONFIG_CPU_ARMV5TE) +# include +#endif + +#if defined (CONFIG_CPU_ARMV6) +# include +#endif + +#if !defined (CP15_WAIT) +# define CP15_WAIT +#endif + +extern void cleanall_dcache (void); +extern void cp15_wait (void); +extern void invalidate_dcache_va (uint32_t); + +#endif /* __CP15_H__ */ diff --git a/include/asm-arm/cpu-single.h b/include/asm-arm/cpu-single.h new file mode 100644 index 0000000..0b120ee --- /dev/null +++ b/include/asm-arm/cpu-single.h @@ -0,0 +1,44 @@ +/* + * linux/include/asm-arm/cpu-single.h + * + * Copyright (C) 2000 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +/* + * Single CPU + */ +#ifdef __STDC__ +#define __catify_fn(name,x) name##x +#else +#define __catify_fn(name,x) name/**/x +#endif +#define __cpu_fn(name,x) __catify_fn(name,x) + +/* + * If we are supporting multiple CPUs, then we must use a table of + * function pointers for this lot. Otherwise, we can optimise the + * table away. + */ +#define cpu_proc_init __cpu_fn(CPU_NAME,_proc_init) +#define cpu_proc_fin __cpu_fn(CPU_NAME,_proc_fin) +#define cpu_reset __cpu_fn(CPU_NAME,_reset) +#define cpu_do_idle __cpu_fn(CPU_NAME,_do_idle) +#define cpu_dcache_clean_area __cpu_fn(CPU_NAME,_dcache_clean_area) +#define cpu_do_switch_mm __cpu_fn(CPU_NAME,_switch_mm) +#define cpu_set_pte_ext __cpu_fn(CPU_NAME,_set_pte_ext) + +#include + +struct mm_struct; + +/* declare all the functions as extern */ +extern void cpu_proc_init(void); +extern void cpu_proc_fin(void); +extern int cpu_do_idle(void); +extern void cpu_dcache_clean_area(void *, int); +extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm); +extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext); +extern void cpu_reset(unsigned long addr) __attribute__((noreturn)); diff --git a/include/asm-arm/div64.h b/include/asm-arm/div64.h new file mode 100644 index 0000000..5001390 --- /dev/null +++ b/include/asm-arm/div64.h @@ -0,0 +1,227 @@ +#ifndef __ASM_ARM_DIV64 +#define __ASM_ARM_DIV64 + +#include +#include + +/* + * The semantics of do_div() are: + * + * uint32_t do_div(uint64_t *n, uint32_t base) + * { + * uint32_t remainder = *n % base; + * *n = *n / base; + * return remainder; + * } + * + * In other words, a 64-bit dividend with a 32-bit divisor producing + * a 64-bit result and a 32-bit remainder. To accomplish this optimally + * we call a special __do_div64 helper with completely non standard + * calling convention for arguments and results (beware). + */ + +#ifdef __ARMEB__ +#define __xh "r0" +#define __xl "r1" +#else +#define __xl "r0" +#define __xh "r1" +#endif + +#define __do_div_asm(n, base) \ +({ \ + register unsigned int __base asm("r4") = base; \ + register unsigned long long __n asm("r0") = n; \ + register unsigned long long __res asm("r2"); \ + register unsigned int __rem asm(__xh); \ + asm( __asmeq("%0", __xh) \ + __asmeq("%1", "r2") \ + __asmeq("%2", "r0") \ + __asmeq("%3", "r4") \ + "bl __do_div64" \ + : "=r" (__rem), "=r" (__res) \ + : "r" (__n), "r" (__base) \ + : "ip", "lr", "cc"); \ + n = __res; \ + __rem; \ +}) + +#if __GNUC__ < 4 + +/* + * gcc versions earlier than 4.0 are simply too problematic for the + * optimized implementation below. First there is gcc PR 15089 that + * tend to trig on more complex constructs, spurious .global __udivsi3 + * are inserted even if none of those symbols are referenced in the + * generated code, and those gcc versions are not able to do constant + * propagation on long long values anyway. + */ +#define do_div(n, base) __do_div_asm(n, base) + +#elif __GNUC__ >= 4 + +#include + +/* + * If the divisor happens to be constant, we determine the appropriate + * inverse at compile time to turn the division into a few inline + * multiplications instead which is much faster. And yet only if compiling + * for ARMv4 or higher (we need umull/umlal) and if the gcc version is + * sufficiently recent to perform proper long long constant propagation. + * (It is unfortunate that gcc doesn't perform all this internally.) + */ +#define do_div(n, base) \ +({ \ + unsigned int __r, __b = (base); \ + if (!__builtin_constant_p(__b) || __b == 0 || \ + (__LINUX_ARM_ARCH__ < 4 && (__b & (__b - 1)) != 0)) { \ + /* non-constant divisor (or zero): slow path */ \ + __r = __do_div_asm(n, __b); \ + } else if ((__b & (__b - 1)) == 0) { \ + /* Trivial: __b is constant and a power of 2 */ \ + /* gcc does the right thing with this code. */ \ + __r = n; \ + __r &= (__b - 1); \ + n /= __b; \ + } else { \ + /* Multiply by inverse of __b: n/b = n*(p/b)/p */ \ + /* We rely on the fact that most of this code gets */ \ + /* optimized away at compile time due to constant */ \ + /* propagation and only a couple inline assembly */ \ + /* instructions should remain. Better avoid any */ \ + /* code construct that might prevent that. */ \ + unsigned long long __res, __x, __t, __m, __n = n; \ + unsigned int __c, __p, __z = 0; \ + /* preserve low part of n for reminder computation */ \ + __r = __n; \ + /* determine number of bits to represent __b */ \ + __p = 1 << __div64_fls(__b); \ + /* compute __m = ((__p << 64) + __b - 1) / __b */ \ + __m = (~0ULL / __b) * __p; \ + __m += (((~0ULL % __b + 1) * __p) + __b - 1) / __b; \ + /* compute __res = __m*(~0ULL/__b*__b-1)/(__p << 64) */ \ + __x = ~0ULL / __b * __b - 1; \ + __res = (__m & 0xffffffff) * (__x & 0xffffffff); \ + __res >>= 32; \ + __res += (__m & 0xffffffff) * (__x >> 32); \ + __t = __res; \ + __res += (__x & 0xffffffff) * (__m >> 32); \ + __t = (__res < __t) ? (1ULL << 32) : 0; \ + __res = (__res >> 32) + __t; \ + __res += (__m >> 32) * (__x >> 32); \ + __res /= __p; \ + /* Now sanitize and optimize what we've got. */ \ + if (~0ULL % (__b / (__b & -__b)) == 0) { \ + /* those cases can be simplified with: */ \ + __n /= (__b & -__b); \ + __m = ~0ULL / (__b / (__b & -__b)); \ + __p = 1; \ + __c = 1; \ + } else if (__res != __x / __b) { \ + /* We can't get away without a correction */ \ + /* to compensate for bit truncation errors. */ \ + /* To avoid it we'd need an additional bit */ \ + /* to represent __m which would overflow it. */ \ + /* Instead we do m=p/b and n/b=(n*m+m)/p. */ \ + __c = 1; \ + /* Compute __m = (__p << 64) / __b */ \ + __m = (~0ULL / __b) * __p; \ + __m += ((~0ULL % __b + 1) * __p) / __b; \ + } else { \ + /* Reduce __m/__p, and try to clear bit 31 */ \ + /* of __m when possible otherwise that'll */ \ + /* need extra overflow handling later. */ \ + unsigned int __bits = -(__m & -__m); \ + __bits |= __m >> 32; \ + __bits = (~__bits) << 1; \ + /* If __bits == 0 then setting bit 31 is */ \ + /* unavoidable. Simply apply the maximum */ \ + /* possible reduction in that case. */ \ + /* Otherwise the MSB of __bits indicates the */ \ + /* best reduction we should apply. */ \ + if (!__bits) { \ + __p /= (__m & -__m); \ + __m /= (__m & -__m); \ + } else { \ + __p >>= __div64_fls(__bits); \ + __m >>= __div64_fls(__bits); \ + } \ + /* No correction needed. */ \ + __c = 0; \ + } \ + /* Now we have a combination of 2 conditions: */ \ + /* 1) whether or not we need a correction (__c), and */ \ + /* 2) whether or not there might be an overflow in */ \ + /* the cross product (__m & ((1<<63) | (1<<31))) */ \ + /* Select the best insn combination to perform the */ \ + /* actual __m * __n / (__p << 64) operation. */ \ + if (!__c) { \ + asm ( "umull %Q0, %R0, %1, %Q2\n\t" \ + "mov %Q0, #0" \ + : "=&r" (__res) \ + : "r" (__m), "r" (__n) \ + : "cc" ); \ + } else if (!(__m & ((1ULL << 63) | (1ULL << 31)))) { \ + __res = __m; \ + asm ( "umlal %Q0, %R0, %Q1, %Q2\n\t" \ + "mov %Q0, #0" \ + : "+r" (__res) \ + : "r" (__m), "r" (__n) \ + : "cc" ); \ + } else { \ + asm ( "umull %Q0, %R0, %Q1, %Q2\n\t" \ + "cmn %Q0, %Q1\n\t" \ + "adcs %R0, %R0, %R1\n\t" \ + "adc %Q0, %3, #0" \ + : "=&r" (__res) \ + : "r" (__m), "r" (__n), "r" (__z) \ + : "cc" ); \ + } \ + if (!(__m & ((1ULL << 63) | (1ULL << 31)))) { \ + asm ( "umlal %R0, %Q0, %R1, %Q2\n\t" \ + "umlal %R0, %Q0, %Q1, %R2\n\t" \ + "mov %R0, #0\n\t" \ + "umlal %Q0, %R0, %R1, %R2" \ + : "+r" (__res) \ + : "r" (__m), "r" (__n) \ + : "cc" ); \ + } else { \ + asm ( "umlal %R0, %Q0, %R2, %Q3\n\t" \ + "umlal %R0, %1, %Q2, %R3\n\t" \ + "mov %R0, #0\n\t" \ + "adds %Q0, %1, %Q0\n\t" \ + "adc %R0, %R0, #0\n\t" \ + "umlal %Q0, %R0, %R2, %R3" \ + : "+r" (__res), "+r" (__z) \ + : "r" (__m), "r" (__n) \ + : "cc" ); \ + } \ + __res /= __p; \ + /* The reminder can be computed with 32-bit regs */ \ + /* only, and gcc is good at that. */ \ + { \ + unsigned int __res0 = __res; \ + unsigned int __b0 = __b; \ + __r -= __res0 * __b0; \ + } \ + /* BUG_ON(__r >= __b || __res * __b + __r != n); */ \ + n = __res; \ + } \ + __r; \ +}) + +/* our own fls implementation to make sure constant propagation is fine */ +#define __div64_fls(bits) \ +({ \ + unsigned int __left = (bits), __nr = 0; \ + if (__left & 0xffff0000) __nr += 16, __left >>= 16; \ + if (__left & 0x0000ff00) __nr += 8, __left >>= 8; \ + if (__left & 0x000000f0) __nr += 4, __left >>= 4; \ + if (__left & 0x0000000c) __nr += 2, __left >>= 2; \ + if (__left & 0x00000002) __nr += 1; \ + __nr; \ +}) + +#endif + +#endif diff --git a/include/asm-arm/domain.h b/include/asm-arm/domain.h new file mode 100644 index 0000000..3c12a76 --- /dev/null +++ b/include/asm-arm/domain.h @@ -0,0 +1,78 @@ +/* + * linux/include/asm-arm/domain.h + * + * Copyright (C) 1999 Russell King. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_PROC_DOMAIN_H +#define __ASM_PROC_DOMAIN_H + +/* + * Domain numbers + * + * DOMAIN_IO - domain 2 includes all IO only + * DOMAIN_USER - domain 1 includes all user memory only + * DOMAIN_KERNEL - domain 0 includes all kernel memory only + * + * The domain numbering depends on whether we support 36 physical + * address for I/O or not. Addresses above the 32 bit boundary can + * only be mapped using supersections and supersections can only + * be set for domain 0. We could just default to DOMAIN_IO as zero, + * but there may be systems with supersection support and no 36-bit + * addressing. In such cases, we want to map system memory with + * supersections to reduce TLB misses and footprint. + * + * 36-bit addressing and supersections are only available on + * CPUs based on ARMv6+ or the Intel XSC3 core. + */ +#ifndef CONFIG_IO_36 +#define DOMAIN_KERNEL 0 +#define DOMAIN_TABLE 0 +#define DOMAIN_USER 1 +#define DOMAIN_IO 2 +#else +#define DOMAIN_KERNEL 2 +#define DOMAIN_TABLE 2 +#define DOMAIN_USER 1 +#define DOMAIN_IO 0 +#endif + +/* + * Domain types + */ +#define DOMAIN_NOACCESS 0 +#define DOMAIN_CLIENT 1 +#define DOMAIN_MANAGER 3 + +#define domain_val(dom,type) ((type) << (2*(dom))) + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_MMU +#define set_domain(x) \ + do { \ + __asm__ __volatile__( \ + "mcr p15, 0, %0, c3, c0 @ set domain" \ + : : "r" (x)); \ + isb(); \ + } while (0) + +#define modify_domain(dom,type) \ + do { \ + struct thread_info *thread = current_thread_info(); \ + unsigned int domain = thread->cpu_domain; \ + domain &= ~domain_val(dom, DOMAIN_MANAGER); \ + thread->cpu_domain = domain | domain_val(dom, type); \ + set_domain(thread->cpu_domain); \ + } while (0) + +#else +#define set_domain(x) do { } while (0) +#define modify_domain(dom,type) do { } while (0) +#endif + +#endif +#endif /* !__ASSEMBLY__ */ diff --git a/include/asm-arm/fpstate.h b/include/asm-arm/fpstate.h new file mode 100644 index 0000000..392eb53 --- /dev/null +++ b/include/asm-arm/fpstate.h @@ -0,0 +1,93 @@ +/* + * linux/include/asm-arm/fpstate.h + * + * Copyright (C) 1995 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_ARM_FPSTATE_H +#define __ASM_ARM_FPSTATE_H + + +#ifndef __ASSEMBLY__ + +/* + * VFP storage area has: + * - FPEXC, FPSCR, FPINST and FPINST2. + * - 16 or 32 double precision data registers + * - an implementation-dependant word of state for FLDMX/FSTMX (pre-ARMv6) + * + * FPEXC will always be non-zero once the VFP has been used in this process. + */ + +struct vfp_hard_struct { +#ifdef CONFIG_VFPv3 + __u64 fpregs[32]; +#else + __u64 fpregs[16]; +#endif +#if __LINUX_ARM_ARCH__ < 6 + __u32 fpmx_state; +#endif + __u32 fpexc; + __u32 fpscr; + /* + * VFP implementation specific state + */ + __u32 fpinst; + __u32 fpinst2; + +#ifdef CONFIG_SMP + __u32 cpu; +#endif +}; + +union vfp_state { + struct vfp_hard_struct hard; +}; + +extern void vfp_flush_thread(union vfp_state *); +extern void vfp_release_thread(union vfp_state *); + +#define FP_HARD_SIZE 35 + +struct fp_hard_struct { + unsigned int save[FP_HARD_SIZE]; /* as yet undefined */ +}; + +#define FP_SOFT_SIZE 35 + +struct fp_soft_struct { + unsigned int save[FP_SOFT_SIZE]; /* undefined information */ +}; + +#define IWMMXT_SIZE 0x98 + +struct iwmmxt_struct { + unsigned int save[IWMMXT_SIZE / sizeof(unsigned int)]; +}; + +union fp_state { + struct fp_hard_struct hard; + struct fp_soft_struct soft; +#ifdef CONFIG_IWMMXT + struct iwmmxt_struct iwmmxt; +#endif +}; + +#define FP_SIZE (sizeof(union fp_state) / sizeof(int)) + +struct crunch_state { + unsigned int mvdx[16][2]; + unsigned int mvax[4][3]; + unsigned int dspsc[2]; +}; + +#define CRUNCH_SIZE sizeof(struct crunch_state) + +#endif + +#endif diff --git a/include/asm-arm/glue.h b/include/asm-arm/glue.h new file mode 100644 index 0000000..a97a182 --- /dev/null +++ b/include/asm-arm/glue.h @@ -0,0 +1,149 @@ +/* + * linux/include/asm-arm/glue.h + * + * Copyright (C) 1997-1999 Russell King + * Copyright (C) 2000-2002 Deep Blue Solutions Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This file provides the glue to stick the processor-specific bits + * into the kernel in an efficient manner. The idea is to use branches + * when we're only targetting one class of TLB, or indirect calls + * when we're targetting multiple classes of TLBs. + */ +#ifdef __KERNEL__ + + +#ifdef __STDC__ +#define ____glue(name,fn) name##fn +#else +#define ____glue(name,fn) name/**/fn +#endif +#define __glue(name,fn) ____glue(name,fn) + + + +/* + * Data Abort Model + * ================ + * + * We have the following to choose from: + * arm6 - ARM6 style + * arm7 - ARM7 style + * v4_early - ARMv4 without Thumb early abort handler + * v4t_late - ARMv4 with Thumb late abort handler + * v4t_early - ARMv4 with Thumb early abort handler + * v5tej_early - ARMv5 with Thumb and Java early abort handler + * xscale - ARMv5 with Thumb with Xscale extensions + * v6_early - ARMv6 generic early abort handler + * v7_early - ARMv7 generic early abort handler + */ +#undef CPU_DABORT_HANDLER +#undef MULTI_DABORT + +#if defined(CONFIG_CPU_ARM610) +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER cpu_arm6_data_abort +# endif +#endif + +#if defined(CONFIG_CPU_ARM710) +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER cpu_arm7_data_abort +# endif +#endif + +#ifdef CONFIG_CPU_ABRT_LV4T +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER v4t_late_abort +# endif +#endif + +#ifdef CONFIG_CPU_ABRT_EV4 +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER v4_early_abort +# endif +#endif + +#ifdef CONFIG_CPU_ABRT_EV4T +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER v4t_early_abort +# endif +#endif + +#ifdef CONFIG_CPU_ABRT_EV5TJ +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER v5tj_early_abort +# endif +#endif + +#ifdef CONFIG_CPU_ABRT_EV5T +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER v5t_early_abort +# endif +#endif + +#ifdef CONFIG_CPU_ABRT_EV6 +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER v6_early_abort +# endif +#endif + +#ifdef CONFIG_CPU_ABRT_EV7 +# ifdef CPU_DABORT_HANDLER +# define MULTI_DABORT 1 +# else +# define CPU_DABORT_HANDLER v7_early_abort +# endif +#endif + +#ifndef CPU_DABORT_HANDLER +#error Unknown data abort handler type +#endif + +/* + * Prefetch abort handler. If the CPU has an IFAR use that, otherwise + * use the address of the aborted instruction + */ +#undef CPU_PABORT_HANDLER +#undef MULTI_PABORT + +#ifdef CONFIG_CPU_PABRT_IFAR +# ifdef CPU_PABORT_HANDLER +# define MULTI_PABORT 1 +# else +# define CPU_PABORT_HANDLER(reg, insn) mrc p15, 0, reg, cr6, cr0, 2 +# endif +#endif + +#ifdef CONFIG_CPU_PABRT_NOIFAR +# ifdef CPU_PABORT_HANDLER +# define MULTI_PABORT 1 +# else +# define CPU_PABORT_HANDLER(reg, insn) mov reg, insn +# endif +#endif + +#ifndef CPU_PABORT_HANDLER +#error Unknown prefetch abort handler type +#endif + +#endif diff --git a/include/asm-arm/hwcap.h b/include/asm-arm/hwcap.h new file mode 100644 index 0000000..81f4c89 --- /dev/null +++ b/include/asm-arm/hwcap.h @@ -0,0 +1,29 @@ +#ifndef __ASMARM_HWCAP_H +#define __ASMARM_HWCAP_H + +/* + * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP + */ +#define HWCAP_SWP 1 +#define HWCAP_HALF 2 +#define HWCAP_THUMB 4 +#define HWCAP_26BIT 8 /* Play it safe */ +#define HWCAP_FAST_MULT 16 +#define HWCAP_FPA 32 +#define HWCAP_VFP 64 +#define HWCAP_EDSP 128 +#define HWCAP_JAVA 256 +#define HWCAP_IWMMXT 512 +#define HWCAP_CRUNCH 1024 +#define HWCAP_THUMBEE 2048 + +#if defined(__KERNEL__) && !defined(__ASSEMBLY__) +/* + * This yields a mask that user programs can use to figure out what + * instruction set this cpu supports. + */ +#define ELF_HWCAP (elf_hwcap) +extern unsigned int elf_hwcap; +#endif + +#endif diff --git a/include/asm-arm/interrupts.h b/include/asm-arm/interrupts.h new file mode 100644 index 0000000..1c0dfcc --- /dev/null +++ b/include/asm-arm/interrupts.h @@ -0,0 +1,44 @@ +/* interrupts.h + $Id$ + + written by Marc Singer + 21 Jan 2005 + + Copyright (C) 2005 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + + Support for interrupt handlers. + +*/ + +#if !defined (__INTERRUPTS_H__) +# define __INTERRUPTS_H__ + +/* ----- Includes */ + +/* ----- Types */ + +enum { + IRQ_NONE = 0, + IRQ_HANDLED = 1, +}; + +typedef int irq_return_t; + +/* ----- Globals */ + +extern irq_return_t (*interrupt_handlers[])(int irq); + +/* ----- Prototypes */ + + + +#endif /* __INTERRUPTS_H__ */ diff --git a/include/asm-arm/irqflags.h b/include/asm-arm/irqflags.h new file mode 100644 index 0000000..6d09974 --- /dev/null +++ b/include/asm-arm/irqflags.h @@ -0,0 +1,132 @@ +#ifndef __ASM_ARM_IRQFLAGS_H +#define __ASM_ARM_IRQFLAGS_H + +#ifdef __KERNEL__ + +#include + +/* + * CPU interrupt mask handling. + */ +#if __LINUX_ARM_ARCH__ >= 6 + +#define raw_local_irq_save(x) \ + ({ \ + __asm__ __volatile__( \ + "mrs %0, cpsr @ local_irq_save\n" \ + "cpsid i" \ + : "=r" (x) : : "memory", "cc"); \ + }) + +#define raw_local_irq_enable() __asm__("cpsie i @ __sti" : : : "memory", "cc") +#define raw_local_irq_disable() __asm__("cpsid i @ __cli" : : : "memory", "cc") +#define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc") +#define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc") + +#else + +/* + * Save the current interrupt enable state & disable IRQs + */ +#define raw_local_irq_save(x) \ + ({ \ + unsigned long temp; \ + (void) (&temp == &x); \ + __asm__ __volatile__( \ + "mrs %0, cpsr @ local_irq_save\n" \ +" orr %1, %0, #128\n" \ +" msr cpsr_c, %1" \ + : "=r" (x), "=r" (temp) \ + : \ + : "memory", "cc"); \ + }) + +/* + * Enable IRQs + */ +#define raw_local_irq_enable() \ + ({ \ + unsigned long temp; \ + __asm__ __volatile__( \ + "mrs %0, cpsr @ local_irq_enable\n" \ +" bic %0, %0, #128\n" \ +" msr cpsr_c, %0" \ + : "=r" (temp) \ + : \ + : "memory", "cc"); \ + }) + +/* + * Disable IRQs + */ +#define raw_local_irq_disable() \ + ({ \ + unsigned long temp; \ + __asm__ __volatile__( \ + "mrs %0, cpsr @ local_irq_disable\n" \ +" orr %0, %0, #128\n" \ +" msr cpsr_c, %0" \ + : "=r" (temp) \ + : \ + : "memory", "cc"); \ + }) + +/* + * Enable FIQs + */ +#define local_fiq_enable() \ + ({ \ + unsigned long temp; \ + __asm__ __volatile__( \ + "mrs %0, cpsr @ stf\n" \ +" bic %0, %0, #64\n" \ +" msr cpsr_c, %0" \ + : "=r" (temp) \ + : \ + : "memory", "cc"); \ + }) + +/* + * Disable FIQs + */ +#define local_fiq_disable() \ + ({ \ + unsigned long temp; \ + __asm__ __volatile__( \ + "mrs %0, cpsr @ clf\n" \ +" orr %0, %0, #64\n" \ +" msr cpsr_c, %0" \ + : "=r" (temp) \ + : \ + : "memory", "cc"); \ + }) + +#endif + +/* + * Save the current interrupt enable state. + */ +#define raw_local_save_flags(x) \ + ({ \ + __asm__ __volatile__( \ + "mrs %0, cpsr @ local_save_flags" \ + : "=r" (x) : : "memory", "cc"); \ + }) + +/* + * restore saved IRQ & FIQ state + */ +#define raw_local_irq_restore(x) \ + __asm__ __volatile__( \ + "msr cpsr_c, %0 @ local_irq_restore\n" \ + : \ + : "r" (x) \ + : "memory", "cc") + +#define raw_irqs_disabled_flags(flags) \ +({ \ + (int)((flags) & PSR_I_BIT); \ +}) + +#endif +#endif diff --git a/include/asm-arm/linkage.h b/include/asm-arm/linkage.h new file mode 100644 index 0000000..5a25632 --- /dev/null +++ b/include/asm-arm/linkage.h @@ -0,0 +1,11 @@ +#ifndef __ASM_LINKAGE_H +#define __ASM_LINKAGE_H + +#define __ALIGN .align 0 +#define __ALIGN_STR ".align 0" + +#define ENDPROC(name) \ + .type name, %function; \ + END(name) + +#endif diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h new file mode 100644 index 0000000..9687d36 --- /dev/null +++ b/include/asm-arm/memory.h @@ -0,0 +1,343 @@ +/* + * linux/include/asm-arm/memory.h + * + * Copyright (C) 2000-2002 Russell King + * modification for nommu, Hyok S. Choi, 2004 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Note: this file should not be included by non-asm/.h files + */ +#ifndef __ASM_ARM_MEMORY_H +#define __ASM_ARM_MEMORY_H + +/* + * Allow for constants defined here to be used from assembly code + * by prepending the UL suffix only with actual C code compilation. + */ +#ifndef __ASSEMBLY__ +#define UL(x) (x##UL) +#else +#define UL(x) (x) +#endif + +#include +//#include +#include + +/* PHYS_OFFSET and these macros aren't important to APEX, but this + header needs it. Instead of adding pointless headers to APEX, we + just define a constant. + */ +#define PHYS_OFFSET (0x0) +#define __virt_to_bus(x) __virt_to_phys(x) +#define __bus_to_virt(x) __phys_to_virt(x) + + +#ifdef CONFIG_MMU + +#ifndef TASK_SIZE +/* + * TASK_SIZE - the maximum size of a user space task. + * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area + */ +#define TASK_SIZE UL(0xbf000000) +#define TASK_UNMAPPED_BASE UL(0x40000000) +#endif + +/* + * The maximum size of a 26-bit user space task. + */ +#define TASK_SIZE_26 UL(0x04000000) + +/* + * Page offset: 3GB + */ +#ifndef PAGE_OFFSET +#define PAGE_OFFSET UL(0xc0000000) +#endif + +/* + * The module space lives between the addresses given by TASK_SIZE + * and PAGE_OFFSET - it must be within 32MB of the kernel text. + */ +#define MODULE_END (PAGE_OFFSET) +#define MODULE_START (MODULE_END - 16*1048576) + +#if TASK_SIZE > MODULE_START +#error Top of user space clashes with start of module space +#endif + +/* + * The XIP kernel gets mapped at the bottom of the module vm area. + * Since we use sections to map it, this macro replaces the physical address + * with its virtual address while keeping offset from the base section. + */ +#define XIP_VIRT_ADDR(physaddr) (MODULE_START + ((physaddr) & 0x000fffff)) + +/* + * Allow 16MB-aligned ioremap pages + */ +#define IOREMAP_MAX_ORDER 24 + +#else /* CONFIG_MMU */ + +/* + * The limitation of user task size can grow up to the end of free ram region. + * It is difficult to define and perhaps will never meet the original meaning + * of this define that was meant to. + * Fortunately, there is no reference for this in noMMU mode, for now. + */ +#ifndef TASK_SIZE +#define TASK_SIZE (CONFIG_DRAM_SIZE) +#endif + +#ifndef TASK_UNMAPPED_BASE +#define TASK_UNMAPPED_BASE UL(0x00000000) +#endif + +#ifndef PHYS_OFFSET +#define PHYS_OFFSET (CONFIG_DRAM_BASE) +#endif + +#ifndef END_MEM +#define END_MEM (CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE) +#endif + +#ifndef PAGE_OFFSET +#define PAGE_OFFSET (PHYS_OFFSET) +#endif + +/* + * The module can be at any place in ram in nommu mode. + */ +#define MODULE_END (END_MEM) +#define MODULE_START (PHYS_OFFSET) + +#endif /* !CONFIG_MMU */ + +/* + * Size of DMA-consistent memory region. Must be multiple of 2M, + * between 2MB and 14MB inclusive. + */ +#ifndef CONSISTENT_DMA_SIZE +#define CONSISTENT_DMA_SIZE SZ_2M +#endif + +/* + * Physical vs virtual RAM address space conversion. These are + * private definitions which should NOT be used outside memory.h + * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. + */ +#ifndef __virt_to_phys +#define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET) +#define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET) +#endif + +/* + * Convert a physical address to a Page Frame Number and back + */ +#define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) +#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) + +#ifndef __ASSEMBLY__ + +/* + * The DMA mask corresponding to the maximum bus address allocatable + * using GFP_DMA. The default here places no restriction on DMA + * allocations. This must be the smallest DMA mask in the system, + * so a successful GFP_DMA allocation will always satisfy this. + */ +#ifndef ISA_DMA_THRESHOLD +#define ISA_DMA_THRESHOLD (0xffffffffULL) +#endif + +#ifndef arch_adjust_zones +#define arch_adjust_zones(node,size,holes) do { } while (0) +#endif + +/* + * PFNs are used to describe any physical page; this means + * PFN 0 == physical address 0. + * + * This is the PFN of the first RAM page in the kernel + * direct-mapped view. We assume this is the first page + * of RAM in the mem_map as well. + */ +#define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) + +/* + * These are *only* valid on the kernel direct mapped RAM memory. + * Note: Drivers should NOT use these. They are the wrong + * translation for translating DMA addresses. Use the driver + * DMA support - see dma-mapping.h. + */ +static inline unsigned long virt_to_phys(void *x) +{ + return __virt_to_phys((unsigned long)(x)); +} + +static inline void *phys_to_virt(unsigned long x) +{ + return (void *)(__phys_to_virt((unsigned long)(x))); +} + +/* + * Drivers should NOT use these either. + */ +#define __pa(x) __virt_to_phys((unsigned long)(x)) +#define __va(x) ((void *)__phys_to_virt((unsigned long)(x))) +#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) + +/* + * Virtual <-> DMA view memory address translations + * Again, these are *only* valid on the kernel direct mapped RAM + * memory. Use of these is *deprecated* (and that doesn't mean + * use the __ prefixed forms instead.) See dma-mapping.h. + */ +static inline __deprecated unsigned long virt_to_bus(void *x) +{ + return __virt_to_bus((unsigned long)x); +} + +static inline __deprecated void *bus_to_virt(unsigned long x) +{ + return (void *)__bus_to_virt(x); +} + +/* + * Conversion between a struct page and a physical address. + * + * Note: when converting an unknown physical address to a + * struct page, the resulting pointer must be validated + * using VALID_PAGE(). It must return an invalid struct page + * for any physical address not corresponding to a system + * RAM address. + * + * page_to_pfn(page) convert a struct page * to a PFN number + * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * + * pfn_valid(pfn) indicates whether a PFN number is valid + * + * virt_to_page(k) convert a _valid_ virtual address to struct page * + * virt_addr_valid(k) indicates whether a virtual address is valid + */ +#ifndef CONFIG_DISCONTIGMEM + +#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET + +#ifndef CONFIG_SPARSEMEM +#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) +#endif + +#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) +#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) + +#define PHYS_TO_NID(addr) (0) + +#else /* CONFIG_DISCONTIGMEM */ + +/* + * This is more complex. We have a set of mem_map arrays spread + * around in memory. + */ +#include + +#define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn) +#define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT) + +#define pfn_valid(pfn) \ + ({ \ + unsigned int nid = PFN_TO_NID(pfn); \ + int valid = nid < MAX_NUMNODES; \ + if (valid) { \ + pg_data_t *node = NODE_DATA(nid); \ + valid = (pfn - node->node_start_pfn) < \ + node->node_spanned_pages; \ + } \ + valid; \ + }) + +#define virt_to_page(kaddr) \ + (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) + +#define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < MAX_NUMNODES) + +/* + * Common discontigmem stuff. + * PHYS_TO_NID is used by the ARM kernel/setup.c + */ +#define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) + +/* + * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory + * and returns the mem_map of that node. + */ +#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr)) + +/* + * Given a page frame number, find the owning node of the memory + * and returns the mem_map of that node. + */ +#define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) + +#ifdef NODE_MEM_SIZE_BITS +#define NODE_MEM_SIZE_MASK ((1 << NODE_MEM_SIZE_BITS) - 1) + +/* + * Given a kernel address, find the home node of the underlying memory. + */ +#define KVADDR_TO_NID(addr) \ + (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MEM_SIZE_BITS) + +/* + * Given a page frame number, convert it to a node id. + */ +#define PFN_TO_NID(pfn) \ + (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MEM_SIZE_BITS - PAGE_SHIFT)) + +/* + * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory + * and returns the index corresponding to the appropriate page in the + * node's mem_map. + */ +#define LOCAL_MAP_NR(addr) \ + (((unsigned long)(addr) & NODE_MEM_SIZE_MASK) >> PAGE_SHIFT) + +#endif /* NODE_MEM_SIZE_BITS */ + +#endif /* !CONFIG_DISCONTIGMEM */ + +/* + * For BIO. "will die". Kill me when bio_to_phys() and bvec_to_phys() die. + */ +#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) + +/* + * Optional device DMA address remapping. Do _not_ use directly! + * We should really eliminate virt_to_bus() here - it's deprecated. + */ +#ifndef __arch_page_to_dma +#define page_to_dma(dev, page) ((dma_addr_t)__virt_to_bus((unsigned long)page_address(page))) +#define dma_to_virt(dev, addr) ((void *)__bus_to_virt(addr)) +#define virt_to_dma(dev, addr) ((dma_addr_t)__virt_to_bus((unsigned long)(addr))) +#else +#define page_to_dma(dev, page) (__arch_page_to_dma(dev, page)) +#define dma_to_virt(dev, addr) (__arch_dma_to_virt(dev, addr)) +#define virt_to_dma(dev, addr) (__arch_virt_to_dma(dev, addr)) +#endif + +/* + * Optional coherency support. Currently used only by selected + * Intel XSC3-based systems. + */ +#ifndef arch_is_coherent +#define arch_is_coherent() 0 +#endif + +#endif + +#include + +#endif diff --git a/include/asm-arm/mmu.h b/include/asm-arm/mmu.h new file mode 100644 index 0000000..89806e3 --- /dev/null +++ b/include/asm-arm/mmu.h @@ -0,0 +1,36 @@ +/* mmu.h + + written by Marc Singer + 25 Feb 2007 + + Copyright (C) 2007 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + +*/ + +#if !defined (__MMU_H__) +# define __MMU_H__ + +/* ----- Includes */ + +/* ----- Types */ + +/* ----- Globals */ + +/* ----- Prototypes */ + +void* alloc_uncached (size_t cb, size_t alignment); +void* alloc_uncached_top_retain (size_t cb, size_t alignment); +void mmu_protsegment (void* pv, int cacheable, int bufferable); +void mmu_map_segment (void* physical, void* virtual, + int cacheable, int bufferable); + +#endif /* __MMU_H__ */ diff --git a/include/asm-arm/module.h b/include/asm-arm/module.h new file mode 100644 index 0000000..24b168d --- /dev/null +++ b/include/asm-arm/module.h @@ -0,0 +1,18 @@ +#ifndef _ASM_ARM_MODULE_H +#define _ASM_ARM_MODULE_H + +struct mod_arch_specific +{ + int foo; +}; + +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Ehdr Elf32_Ehdr + +/* + * Include the ARM architecture version. + */ +#define MODULE_ARCH_VERMAGIC "ARMv" __stringify(__LINUX_ARM_ARCH__) " " + +#endif /* _ASM_ARM_MODULE_H */ diff --git a/include/asm-arm/page.h b/include/asm-arm/page.h new file mode 100644 index 0000000..8e05bdb --- /dev/null +++ b/include/asm-arm/page.h @@ -0,0 +1,202 @@ +/* + * linux/include/asm-arm/page.h + * + * Copyright (C) 1995-2003 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef _ASMARM_PAGE_H +#define _ASMARM_PAGE_H + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +/* to align the pointer to the (next) page boundary */ +#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) + +#ifndef __ASSEMBLY__ + +#ifndef CONFIG_MMU + +#include "page-nommu.h" + +#else + +#include + +/* + * User Space Model + * ================ + * + * This section selects the correct set of functions for dealing with + * page-based copying and clearing for user space for the particular + * processor(s) we're building for. + * + * We have the following to choose from: + * v3 - ARMv3 + * v4wt - ARMv4 with writethrough cache, without minicache + * v4wb - ARMv4 with writeback cache, without minicache + * v4_mc - ARMv4 with minicache + * xscale - Xscale + * xsc3 - XScalev3 + */ +#undef _USER +#undef MULTI_USER + +#ifdef CONFIG_CPU_COPY_V3 +# ifdef _USER +# define MULTI_USER 1 +# else +# define _USER v3 +# endif +#endif + +#ifdef CONFIG_CPU_COPY_V4WT +# ifdef _USER +# define MULTI_USER 1 +# else +# define _USER v4wt +# endif +#endif + +#ifdef CONFIG_CPU_COPY_V4WB +# ifdef _USER +# define MULTI_USER 1 +# else +# define _USER v4wb +# endif +#endif + +#ifdef CONFIG_CPU_COPY_FEROCEON +# ifdef _USER +# define MULTI_USER 1 +# else +# define _USER feroceon +# endif +#endif + +#ifdef CONFIG_CPU_SA1100 +# ifdef _USER +# define MULTI_USER 1 +# else +# define _USER v4_mc +# endif +#endif + +#ifdef CONFIG_CPU_XSCALE +# ifdef _USER +# define MULTI_USER 1 +# else +# define _USER xscale_mc +# endif +#endif + +#ifdef CONFIG_CPU_XSC3 +# ifdef _USER +# define MULTI_USER 1 +# else +# define _USER xsc3_mc +# endif +#endif + +#ifdef CONFIG_CPU_COPY_V6 +# define MULTI_USER 1 +#endif + +#if !defined(_USER) && !defined(MULTI_USER) +#error Unknown user operations model +#endif + +struct cpu_user_fns { + void (*cpu_clear_user_page)(void *p, unsigned long user); + void (*cpu_copy_user_page)(void *to, const void *from, + unsigned long user); +}; + +#ifdef MULTI_USER +extern struct cpu_user_fns cpu_user; + +#define __cpu_clear_user_page cpu_user.cpu_clear_user_page +#define __cpu_copy_user_page cpu_user.cpu_copy_user_page + +#else + +#define __cpu_clear_user_page __glue(_USER,_clear_user_page) +#define __cpu_copy_user_page __glue(_USER,_copy_user_page) + +extern void __cpu_clear_user_page(void *p, unsigned long user); +extern void __cpu_copy_user_page(void *to, const void *from, + unsigned long user); +#endif + +#define clear_user_page(addr,vaddr,pg) __cpu_clear_user_page(addr, vaddr) +#define copy_user_page(to,from,vaddr,pg) __cpu_copy_user_page(to, from, vaddr) + +#define clear_page(page) memzero((void *)(page), PAGE_SIZE) +extern void copy_page(void *to, const void *from); + +#undef STRICT_MM_TYPECHECKS + +#ifdef STRICT_MM_TYPECHECKS +/* + * These are used to make use of C type-checking.. + */ +typedef struct { unsigned long pte; } pte_t; +typedef struct { unsigned long pmd; } pmd_t; +typedef struct { unsigned long pgd[2]; } pgd_t; +typedef struct { unsigned long pgprot; } pgprot_t; + +#define pte_val(x) ((x).pte) +#define pmd_val(x) ((x).pmd) +#define pgd_val(x) ((x).pgd[0]) +#define pgprot_val(x) ((x).pgprot) + +#define __pte(x) ((pte_t) { (x) } ) +#define __pmd(x) ((pmd_t) { (x) } ) +#define __pgprot(x) ((pgprot_t) { (x) } ) + +#else +/* + * .. while these make it easier on the compiler + */ +typedef unsigned long pte_t; +typedef unsigned long pmd_t; +typedef unsigned long pgd_t[2]; +typedef unsigned long pgprot_t; + +#define pte_val(x) (x) +#define pmd_val(x) (x) +#define pgd_val(x) ((x)[0]) +#define pgprot_val(x) (x) + +#define __pte(x) (x) +#define __pmd(x) (x) +#define __pgprot(x) (x) + +#endif /* STRICT_MM_TYPECHECKS */ + +#endif /* CONFIG_MMU */ + +typedef struct page *pgtable_t; + +#include + +#endif /* !__ASSEMBLY__ */ + +#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) + +/* + * With EABI on ARMv5 and above we must have 64-bit aligned slab pointers. + */ +#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) +#define ARCH_SLAB_MINALIGN 8 +#endif + +#include + +#endif diff --git a/include/asm-arm/posix_types.h b/include/asm-arm/posix_types.h new file mode 100644 index 0000000..c37379d --- /dev/null +++ b/include/asm-arm/posix_types.h @@ -0,0 +1,77 @@ +/* + * linux/include/asm-arm/posix_types.h + * + * Copyright (C) 1996-1998 Russell King. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Changelog: + * 27-06-1996 RMK Created + */ +#ifndef __ARCH_ARM_POSIX_TYPES_H +#define __ARCH_ARM_POSIX_TYPES_H + +/* + * This file is generally used by user-level software, so you need to + * be a little careful about namespace pollution etc. Also, we cannot + * assume GCC is being used. + */ + +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; + +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; +typedef unsigned short __kernel_old_dev_t; + +#ifdef __GNUC__ +typedef long long __kernel_loff_t; +#endif + +typedef struct { + int val[2]; +} __kernel_fsid_t; + +#if defined(__KERNEL__) + +#undef __FD_SET +#define __FD_SET(fd, fdsetp) \ + (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1<<((fd) & 31))) + +#undef __FD_CLR +#define __FD_CLR(fd, fdsetp) \ + (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1<<((fd) & 31))) + +#undef __FD_ISSET +#define __FD_ISSET(fd, fdsetp) \ + ((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1<<((fd) & 31))) != 0) + +#undef __FD_ZERO +#define __FD_ZERO(fdsetp) \ + (memset (fdsetp, 0, sizeof (*(fd_set *)(fdsetp)))) + +#endif + +#endif diff --git a/include/asm-arm/proc-fns.h b/include/asm-arm/proc-fns.h new file mode 100644 index 0000000..75ec760 --- /dev/null +++ b/include/asm-arm/proc-fns.h @@ -0,0 +1,241 @@ +/* + * linux/include/asm-arm/proc-fns.h + * + * Copyright (C) 1997-1999 Russell King + * Copyright (C) 2000 Deep Blue Solutions Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_PROCFNS_H +#define __ASM_PROCFNS_H + +#ifdef __KERNEL__ + + +/* + * Work out if we need multiple CPU support + */ +#undef MULTI_CPU +#undef CPU_NAME + +/* + * CPU_NAME - the prefix for CPU related functions + */ + +#ifdef CONFIG_CPU_32 +# ifdef CONFIG_CPU_ARM610 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm6 +# endif +# endif +# ifdef CONFIG_CPU_ARM7TDMI +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm7tdmi +# endif +# endif +# ifdef CONFIG_CPU_ARM710 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm7 +# endif +# endif +# ifdef CONFIG_CPU_ARM720T +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm720 +# endif +# endif +# ifdef CONFIG_CPU_ARM740T +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm740 +# endif +# endif +# ifdef CONFIG_CPU_ARM9TDMI +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm9tdmi +# endif +# endif +# ifdef CONFIG_CPU_ARM920T +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm920 +# endif +# endif +# ifdef CONFIG_CPU_ARM922T +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm922 +# endif +# endif +# ifdef CONFIG_CPU_ARM925T +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm925 +# endif +# endif +# ifdef CONFIG_CPU_ARM926T +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm926 +# endif +# endif +# ifdef CONFIG_CPU_ARM940T +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm940 +# endif +# endif +# ifdef CONFIG_CPU_ARM946E +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm946 +# endif +# endif +# ifdef CONFIG_CPU_SA110 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_sa110 +# endif +# endif +# ifdef CONFIG_CPU_SA1100 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_sa1100 +# endif +# endif +# ifdef CONFIG_CPU_ARM1020 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm1020 +# endif +# endif +# ifdef CONFIG_CPU_ARM1020E +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm1020e +# endif +# endif +# ifdef CONFIG_CPU_ARM1022 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm1022 +# endif +# endif +# ifdef CONFIG_CPU_ARM1026 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_arm1026 +# endif +# endif +# ifdef CONFIG_CPU_XSCALE +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_xscale +# endif +# endif +# ifdef CONFIG_CPU_XSC3 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_xsc3 +# endif +# endif +# ifdef CONFIG_CPU_FEROCEON +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_feroceon +# endif +# endif +# ifdef CONFIG_CPU_V6 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_v6 +# endif +# endif +# ifdef CONFIG_CPU_V7 +# ifdef CPU_NAME +# undef MULTI_CPU +# define MULTI_CPU +# else +# define CPU_NAME cpu_v7 +# endif +# endif +#endif + +#ifndef __ASSEMBLY__ + +#ifndef MULTI_CPU +#include +#else +#include +#endif + +#include + +#ifdef CONFIG_MMU + +#define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm) + +#define cpu_get_pgd() \ + ({ \ + unsigned long pg; \ + __asm__("mrc p15, 0, %0, c2, c0, 0" \ + : "=r" (pg) : : "cc"); \ + pg &= ~0x3fff; \ + (pgd_t *)phys_to_virt(pg); \ + }) + +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __KERNEL__ */ +#endif /* __ASM_PROCFNS_H */ diff --git a/include/asm-arm/processor.h b/include/asm-arm/processor.h new file mode 100644 index 0000000..bd8029e --- /dev/null +++ b/include/asm-arm/processor.h @@ -0,0 +1,131 @@ +/* + * linux/include/asm-arm/processor.h + * + * Copyright (C) 1995-1999 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_ARM_PROCESSOR_H +#define __ASM_ARM_PROCESSOR_H + +/* + * Default implementation of macro that returns current + * instruction pointer ("program counter"). + */ +#define current_text_addr() ({ __label__ _l; _l: &&_l;}) + +#ifdef __KERNEL__ + +#include +#include + +#ifdef __KERNEL__ +#define STACK_TOP ((current->personality == PER_LINUX_32BIT) ? \ + TASK_SIZE : TASK_SIZE_26) +#define STACK_TOP_MAX TASK_SIZE +#endif + +union debug_insn { + u32 arm; + u16 thumb; +}; + +struct debug_entry { + u32 address; + union debug_insn insn; +}; + +struct debug_info { + int nsaved; + struct debug_entry bp[2]; +}; + +struct thread_struct { + /* fault info */ + unsigned long address; + unsigned long trap_no; + unsigned long error_code; + /* debugging */ + struct debug_info debug; +}; + +#define INIT_THREAD { } + +#ifdef CONFIG_MMU +#define nommu_start_thread(regs) do { } while (0) +#else +#define nommu_start_thread(regs) regs->ARM_r10 = current->mm->start_data +#endif + +#define start_thread(regs,pc,sp) \ +({ \ + unsigned long *stack = (unsigned long *)sp; \ + set_fs(USER_DS); \ + memzero(regs->uregs, sizeof(regs->uregs)); \ + if (current->personality & ADDR_LIMIT_32BIT) \ + regs->ARM_cpsr = USR_MODE; \ + else \ + regs->ARM_cpsr = USR26_MODE; \ + if (elf_hwcap & HWCAP_THUMB && pc & 1) \ + regs->ARM_cpsr |= PSR_T_BIT; \ + regs->ARM_pc = pc & ~1; /* pc */ \ + regs->ARM_sp = sp; /* sp */ \ + regs->ARM_r2 = stack[2]; /* r2 (envp) */ \ + regs->ARM_r1 = stack[1]; /* r1 (argv) */ \ + regs->ARM_r0 = stack[0]; /* r0 (argc) */ \ + nommu_start_thread(regs); \ +}) + +/* Forward declaration, a strange C thing */ +struct task_struct; + +/* Free all resources held by a thread. */ +extern void release_thread(struct task_struct *); + +/* Prepare to copy thread state - unlazy all lazy status */ +#define prepare_to_copy(tsk) do { } while (0) + +unsigned long get_wchan(struct task_struct *p); + +#define cpu_relax() barrier() + +/* + * Create a new kernel thread + */ +extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); + +#define task_pt_regs(p) \ + ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1) + +#define KSTK_EIP(tsk) task_pt_regs(tsk)->ARM_pc +#define KSTK_ESP(tsk) task_pt_regs(tsk)->ARM_sp + +/* + * Prefetching support - only ARMv5. + */ +#if __LINUX_ARM_ARCH__ >= 5 + +#define ARCH_HAS_PREFETCH +static inline void prefetch(const void *ptr) +{ + __asm__ __volatile__( + "pld\t%0" + : + : "o" (*(char *)ptr) + : "cc"); +} + +#define ARCH_HAS_PREFETCHW +#define prefetchw(ptr) prefetch(ptr) + +#define ARCH_HAS_SPINLOCK_PREFETCH +#define spin_lock_prefetch(x) do { } while (0) + +#endif + +#endif + +#endif /* __ASM_ARM_PROCESSOR_H */ diff --git a/include/asm-arm/ptrace.h b/include/asm-arm/ptrace.h new file mode 100644 index 0000000..7aaa206 --- /dev/null +++ b/include/asm-arm/ptrace.h @@ -0,0 +1,164 @@ +/* + * linux/include/asm-arm/ptrace.h + * + * Copyright (C) 1996-2003 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_ARM_PTRACE_H +#define __ASM_ARM_PTRACE_H + +#include + +#define PTRACE_GETREGS 12 +#define PTRACE_SETREGS 13 +#define PTRACE_GETFPREGS 14 +#define PTRACE_SETFPREGS 15 +/* PTRACE_ATTACH is 16 */ +/* PTRACE_DETACH is 17 */ +#define PTRACE_GETWMMXREGS 18 +#define PTRACE_SETWMMXREGS 19 +/* 20 is unused */ +#define PTRACE_OLDSETOPTIONS 21 +#define PTRACE_GET_THREAD_AREA 22 +#define PTRACE_SET_SYSCALL 23 +/* PTRACE_SYSCALL is 24 */ +#define PTRACE_GETCRUNCHREGS 25 +#define PTRACE_SETCRUNCHREGS 26 + +/* + * PSR bits + */ +#define USR26_MODE 0x00000000 +#define FIQ26_MODE 0x00000001 +#define IRQ26_MODE 0x00000002 +#define SVC26_MODE 0x00000003 +#define USR_MODE 0x00000010 +#define FIQ_MODE 0x00000011 +#define IRQ_MODE 0x00000012 +#define SVC_MODE 0x00000013 +#define ABT_MODE 0x00000017 +#define UND_MODE 0x0000001b +#define SYSTEM_MODE 0x0000001f +#define MODE32_BIT 0x00000010 +#define MODE_MASK 0x0000001f +#define PSR_T_BIT 0x00000020 +#define PSR_F_BIT 0x00000040 +#define PSR_I_BIT 0x00000080 +#define PSR_A_BIT 0x00000100 +#define PSR_J_BIT 0x01000000 +#define PSR_Q_BIT 0x08000000 +#define PSR_V_BIT 0x10000000 +#define PSR_C_BIT 0x20000000 +#define PSR_Z_BIT 0x40000000 +#define PSR_N_BIT 0x80000000 +#define PCMASK 0 + +/* + * Groups of PSR bits + */ +#define PSR_f 0xff000000 /* Flags */ +#define PSR_s 0x00ff0000 /* Status */ +#define PSR_x 0x0000ff00 /* Extension */ +#define PSR_c 0x000000ff /* Control */ + +#ifndef __ASSEMBLY__ + +/* + * This struct defines the way the registers are stored on the + * stack during a system call. Note that sizeof(struct pt_regs) + * has to be a multiple of 8. + */ +struct pt_regs { + long uregs[18]; +}; + +#define ARM_cpsr uregs[16] +#define ARM_pc uregs[15] +#define ARM_lr uregs[14] +#define ARM_sp uregs[13] +#define ARM_ip uregs[12] +#define ARM_fp uregs[11] +#define ARM_r10 uregs[10] +#define ARM_r9 uregs[9] +#define ARM_r8 uregs[8] +#define ARM_r7 uregs[7] +#define ARM_r6 uregs[6] +#define ARM_r5 uregs[5] +#define ARM_r4 uregs[4] +#define ARM_r3 uregs[3] +#define ARM_r2 uregs[2] +#define ARM_r1 uregs[1] +#define ARM_r0 uregs[0] +#define ARM_ORIG_r0 uregs[17] + +#ifdef __KERNEL__ + +#define user_mode(regs) \ + (((regs)->ARM_cpsr & 0xf) == 0) + +#ifdef CONFIG_ARM_THUMB +#define thumb_mode(regs) \ + (((regs)->ARM_cpsr & PSR_T_BIT)) +#else +#define thumb_mode(regs) (0) +#endif + +#define isa_mode(regs) \ + ((((regs)->ARM_cpsr & PSR_J_BIT) >> 23) | \ + (((regs)->ARM_cpsr & PSR_T_BIT) >> 5)) + +#define processor_mode(regs) \ + ((regs)->ARM_cpsr & MODE_MASK) + +#define interrupts_enabled(regs) \ + (!((regs)->ARM_cpsr & PSR_I_BIT)) + +#define fast_interrupts_enabled(regs) \ + (!((regs)->ARM_cpsr & PSR_F_BIT)) + +/* Are the current registers suitable for user mode? + * (used to maintain security in signal handlers) + */ +static inline int valid_user_regs(struct pt_regs *regs) +{ + if (user_mode(regs) && (regs->ARM_cpsr & PSR_I_BIT) == 0) { + regs->ARM_cpsr &= ~(PSR_F_BIT | PSR_A_BIT); + return 1; + } + + /* + * Force CPSR to something logical... + */ + regs->ARM_cpsr &= PSR_f | PSR_s | (PSR_x & ~PSR_A_BIT) | PSR_T_BIT | MODE32_BIT; + if (!(elf_hwcap & HWCAP_26BIT)) + regs->ARM_cpsr |= USR_MODE; + + return 0; +} + +#endif /* __KERNEL__ */ + +#define pc_pointer(v) \ + ((v) & ~PCMASK) + +#define instruction_pointer(regs) \ + (pc_pointer((regs)->ARM_pc)) + +#ifdef CONFIG_SMP +extern unsigned long profile_pc(struct pt_regs *regs); +#else +#define profile_pc(regs) instruction_pointer(regs) +#endif + +#ifdef __KERNEL__ +#define predicate(x) ((x) & 0xf0000000) +#define PREDICATE_ALWAYS 0xe0000000 +#endif + +#endif /* __ASSEMBLY__ */ + +#endif + diff --git a/include/asm-arm/reg.h b/include/asm-arm/reg.h new file mode 100644 index 0000000..97b5e67 --- /dev/null +++ b/include/asm-arm/reg.h @@ -0,0 +1,46 @@ +/* reg.h + + written by Marc Singer + 11 Nov 2004 + + Copyright (C) 2004 Marc Singer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + Please refer to the file debian/copyright for further details. + + ----------- + DESCRIPTION + ----------- + + Macros to make register file access somewhat efficient in C. The + 4K constant comes from the fact that ARM instructions are limited + to a 4K immediate offset. + +*/ + +#if !defined (__REG_H__) +# define __REG_H__ + +/* ----- Includes */ + +/* ----- Types */ + +/* ----- Globals */ + +/* ----- Prototypes */ + +typedef struct { volatile unsigned long offset[4096>>2]; } __reg32; +typedef struct { volatile unsigned short offset[4096>>1]; } __reg16; +typedef struct { volatile unsigned char offset[4096>>0]; } __reg08; + +#define __REG_M(t,x,s) ((t*)((x)&~(4096-1)))->offset[((x)&(4096-1))>>s] + +#define __REG(x) __REG_M (__reg32, (x), 2) +#define __REG16(x) __REG_M (__reg16, (x), 1) +#define __REG8(x) __REG_M (__reg08, (x), 0) + +#define MASK_AND_SET(v,m,s) ({ (v) = ((v) & ~(m)) | (s); }) + +#endif /* __REG_H__ */ diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h new file mode 100644 index 0000000..7bbf105 --- /dev/null +++ b/include/asm-arm/setup.h @@ -0,0 +1,226 @@ +/* + * linux/include/asm/setup.h + * + * Copyright (C) 1997-1999 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Structure passed to kernel to tell it about the + * hardware it's running on. See Documentation/arm/Setup + * for more info. + */ +#ifndef __ASMARM_SETUP_H +#define __ASMARM_SETUP_H + +#include + +#define COMMAND_LINE_SIZE 1024 + +/* The list ends with an ATAG_NONE node. */ +#define ATAG_NONE 0x00000000 + +struct tag_header { + __u32 size; + __u32 tag; +}; + +/* The list must start with an ATAG_CORE node */ +#define ATAG_CORE 0x54410001 + +struct tag_core { + __u32 flags; /* bit 0 = read-only */ + __u32 pagesize; + __u32 rootdev; +}; + +/* it is allowed to have multiple ATAG_MEM nodes */ +#define ATAG_MEM 0x54410002 + +struct tag_mem32 { + __u32 size; + __u32 start; /* physical start address */ +}; + +/* VGA text type displays */ +#define ATAG_VIDEOTEXT 0x54410003 + +struct tag_videotext { + __u8 x; + __u8 y; + __u16 video_page; + __u8 video_mode; + __u8 video_cols; + __u16 video_ega_bx; + __u8 video_lines; + __u8 video_isvga; + __u16 video_points; +}; + +/* describes how the ramdisk will be used in kernel */ +#define ATAG_RAMDISK 0x54410004 + +struct tag_ramdisk { + __u32 flags; /* bit 0 = load, bit 1 = prompt */ + __u32 size; /* decompressed ramdisk size in _kilo_ bytes */ + __u32 start; /* starting block of floppy-based RAM disk image */ +}; + +/* describes where the compressed ramdisk image lives (virtual address) */ +/* + * this one accidentally used virtual addresses - as such, + * it's deprecated. + */ +#define ATAG_INITRD 0x54410005 + +/* describes where the compressed ramdisk image lives (physical address) */ +#define ATAG_INITRD2 0x54420005 + +struct tag_initrd { + __u32 start; /* physical start address */ + __u32 size; /* size of compressed ramdisk image in bytes */ +}; + +/* board serial number. "64 bits should be enough for everybody" */ +#define ATAG_SERIAL 0x54410006 + +struct tag_serialnr { + __u32 low; + __u32 high; +}; + +/* board revision */ +#define ATAG_REVISION 0x54410007 + +struct tag_revision { + __u32 rev; +}; + +/* initial values for vesafb-type framebuffers. see struct screen_info + * in include/linux/tty.h + */ +#define ATAG_VIDEOLFB 0x54410008 + +struct tag_videolfb { + __u16 lfb_width; + __u16 lfb_height; + __u16 lfb_depth; + __u16 lfb_linelength; + __u32 lfb_base; + __u32 lfb_size; + __u8 red_size; + __u8 red_pos; + __u8 green_size; + __u8 green_pos; + __u8 blue_size; + __u8 blue_pos; + __u8 rsvd_size; + __u8 rsvd_pos; +}; + +/* command line: \0 terminated string */ +#define ATAG_CMDLINE 0x54410009 + +struct tag_cmdline { + char cmdline[1]; /* this is the minimum size */ +}; + +/* acorn RiscPC specific information */ +#define ATAG_ACORN 0x41000101 + +struct tag_acorn { + __u32 memc_control_reg; + __u32 vram_pages; + __u8 sounddefault; + __u8 adfsdrives; +}; + +/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ +#define ATAG_MEMCLK 0x41000402 + +struct tag_memclk { + __u32 fmemclk; +}; + +struct tag { + struct tag_header hdr; + union { + struct tag_core core; + struct tag_mem32 mem; + struct tag_videotext videotext; + struct tag_ramdisk ramdisk; + struct tag_initrd initrd; + struct tag_serialnr serialnr; + struct tag_revision revision; + struct tag_videolfb videolfb; + struct tag_cmdline cmdline; + + /* + * Acorn specific + */ + struct tag_acorn acorn; + + /* + * DC21285 specific + */ + struct tag_memclk memclk; + } u; +}; + +struct tagtable { + __u32 tag; + int (*parse)(const struct tag *); +}; + +#define tag_member_present(tag,member) \ + ((unsigned long)(&((struct tag *)0L)->member + 1) \ + <= (tag)->hdr.size * 4) + +#define tag_next(t) ((struct tag *)((__u32 *)(t) + (t)->hdr.size)) +#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) + +#define for_each_tag(t,base) \ + for (t = base; t->hdr.size; t = tag_next(t)) + +#ifdef __KERNEL__ + +#define __tag __used __attribute__((__section__(".taglist.init"))) +#define __tagtable(tag, fn) \ +static struct tagtable __tagtable_##fn __tag = { tag, fn } + +/* + * Memory map description + */ +#ifdef CONFIG_ARCH_LH7A40X +# define NR_BANKS 16 +#else +# define NR_BANKS 8 +#endif + +struct membank { + unsigned long start; + unsigned long size; + int node; +}; + +struct meminfo { + int nr_banks; + struct membank bank[NR_BANKS]; +}; + +/* + * Early command line parameters. + */ +struct early_params { + const char *arg; + void (*fn)(char **p); +}; + +#define __early_param(name,fn) \ +static struct early_params __early_##fn __used \ +__attribute__((__section__(".early_param.init"))) = { name, fn } + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/asm-arm/sizes.h b/include/asm-arm/sizes.h new file mode 100644 index 0000000..503843d --- /dev/null +++ b/include/asm-arm/sizes.h @@ -0,0 +1,56 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* DO NOT EDIT!! - this file automatically generated + * from .s file by awk -f s2h.awk + */ +/* Size definitions + * Copyright (C) ARM Limited 1998. All rights reserved. + */ + +#ifndef __sizes_h +#define __sizes_h 1 + +/* handy sizes */ +#define SZ_16 0x00000010 +#define SZ_256 0x00000100 +#define SZ_512 0x00000200 + +#define SZ_1K 0x00000400 +#define SZ_4K 0x00001000 +#define SZ_8K 0x00002000 +#define SZ_16K 0x00004000 +#define SZ_64K 0x00010000 +#define SZ_128K 0x00020000 +#define SZ_256K 0x00040000 +#define SZ_512K 0x00080000 + +#define SZ_1M 0x00100000 +#define SZ_2M 0x00200000 +#define SZ_4M 0x00400000 +#define SZ_8M 0x00800000 +#define SZ_16M 0x01000000 +#define SZ_32M 0x02000000 +#define SZ_64M 0x04000000 +#define SZ_128M 0x08000000 +#define SZ_256M 0x10000000 +#define SZ_512M 0x20000000 + +#define SZ_1G 0x40000000 +#define SZ_2G 0x80000000 + +#endif + +/* END */ diff --git a/include/asm-arm/stat.h b/include/asm-arm/stat.h new file mode 100644 index 0000000..42c0c13 --- /dev/null +++ b/include/asm-arm/stat.h @@ -0,0 +1,87 @@ +#ifndef _ASMARM_STAT_H +#define _ASMARM_STAT_H + +struct __old_kernel_stat { + unsigned short st_dev; + unsigned short st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned long st_size; + unsigned long st_atime; + unsigned long st_mtime; + unsigned long st_ctime; +}; + +#define STAT_HAVE_NSEC + +struct stat { +#if defined(__ARMEB__) + unsigned short st_dev; + unsigned short __pad1; +#else + unsigned long st_dev; +#endif + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; +#if defined(__ARMEB__) + unsigned short st_rdev; + unsigned short __pad2; +#else + unsigned long st_rdev; +#endif + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long __unused4; + unsigned long __unused5; +}; + +/* This matches struct stat64 in glibc2.1, hence the absolutely + * insane amounts of padding around dev_t's. + * Note: The kernel zero's the padded region because glibc might read them + * in the hope that the kernel has stretched to using larger sizes. + */ +struct stat64 { + unsigned long long st_dev; + unsigned char __pad0[4]; + +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + unsigned int st_mode; + unsigned int st_nlink; + + unsigned long st_uid; + unsigned long st_gid; + + unsigned long long st_rdev; + unsigned char __pad3[4]; + + long long st_size; + unsigned long st_blksize; + unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ + + unsigned long st_atime; + unsigned long st_atime_nsec; + + unsigned long st_mtime; + unsigned long st_mtime_nsec; + + unsigned long st_ctime; + unsigned long st_ctime_nsec; + + unsigned long long st_ino; +}; + +#endif diff --git a/include/asm-arm/string.h b/include/asm-arm/string.h new file mode 100644 index 0000000..e50c4a3 --- /dev/null +++ b/include/asm-arm/string.h @@ -0,0 +1,50 @@ +#ifndef __ASM_ARM_STRING_H +#define __ASM_ARM_STRING_H + +/* + * We don't do inline string functions, since the + * optimised inline asm versions are not small. + */ + +#define __HAVE_ARCH_STRRCHR +extern char * strrchr(const char * s, int c); + +#define __HAVE_ARCH_STRCHR +extern char * strchr(const char * s, int c); + +#define __HAVE_ARCH_MEMCPY +extern void * memcpy(void *, const void *, __kernel_size_t); + +#define __HAVE_ARCH_MEMMOVE +extern void * memmove(void *, const void *, __kernel_size_t); + +#define __HAVE_ARCH_MEMCHR +extern void * memchr(const void *, int, __kernel_size_t); + +#define __HAVE_ARCH_MEMZERO +#define __HAVE_ARCH_MEMSET +extern void * memset(void *, int, __kernel_size_t); + +extern void __memzero(void *ptr, __kernel_size_t n); + +#define memset(p,v,n) \ + ({ \ + void *__p = (p); size_t __n = n; \ + if ((__n) != 0) { \ + if (__builtin_constant_p((v)) && (v) == 0) \ + __memzero((__p),(__n)); \ + else \ + memset((__p),(v),(__n)); \ + } \ + (__p); \ + }) + +#define memzero(p,n) \ + ({ \ + void *__p = (p); size_t __n = n; \ + if ((__n) != 0) \ + __memzero((__p),(__n)); \ + (__p); \ + }) + +#endif diff --git a/include/asm-arm/system.h b/include/asm-arm/system.h new file mode 100644 index 0000000..514af79 --- /dev/null +++ b/include/asm-arm/system.h @@ -0,0 +1,388 @@ +#ifndef __ASM_ARM_SYSTEM_H +#define __ASM_ARM_SYSTEM_H + +#ifdef __KERNEL__ + +#include + +#define CPU_ARCH_UNKNOWN 0 +#define CPU_ARCH_ARMv3 1 +#define CPU_ARCH_ARMv4 2 +#define CPU_ARCH_ARMv4T 3 +#define CPU_ARCH_ARMv5 4 +#define CPU_ARCH_ARMv5T 5 +#define CPU_ARCH_ARMv5TE 6 +#define CPU_ARCH_ARMv5TEJ 7 +#define CPU_ARCH_ARMv6 8 +#define CPU_ARCH_ARMv7 9 + +/* + * CR1 bits (CP#15 CR1) + */ +#define CR_M (1 << 0) /* MMU enable */ +#define CR_A (1 << 1) /* Alignment abort enable */ +#define CR_C (1 << 2) /* Dcache enable */ +#define CR_W (1 << 3) /* Write buffer enable */ +#define CR_P (1 << 4) /* 32-bit exception handler */ +#define CR_D (1 << 5) /* 32-bit data address range */ +#define CR_L (1 << 6) /* Implementation defined */ +#define CR_B (1 << 7) /* Big endian */ +#define CR_S (1 << 8) /* System MMU protection */ +#define CR_R (1 << 9) /* ROM MMU protection */ +#define CR_F (1 << 10) /* Implementation defined */ +#define CR_Z (1 << 11) /* Implementation defined */ +#define CR_I (1 << 12) /* Icache enable */ +#define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */ +#define CR_RR (1 << 14) /* Round Robin cache replacement */ +#define CR_L4 (1 << 15) /* LDR pc can set T bit */ +#define CR_DT (1 << 16) +#define CR_IT (1 << 18) +#define CR_ST (1 << 19) +#define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */ +#define CR_U (1 << 22) /* Unaligned access operation */ +#define CR_XP (1 << 23) /* Extended page tables */ +#define CR_VE (1 << 24) /* Vectored interrupts */ + +#define CPUID_ID 0 +#define CPUID_CACHETYPE 1 +#define CPUID_TCM 2 +#define CPUID_TLBTYPE 3 + +/* + * This is used to ensure the compiler did actually allocate the register we + * asked it for some inline assembly sequences. Apparently we can't trust + * the compiler from one version to another so a bit of paranoia won't hurt. + * This string is meant to be concatenated with the inline asm string and + * will cause compilation to stop on mismatch. + * (for details, see gcc PR 15089) + */ +#define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t" + +#ifndef __ASSEMBLY__ + +#include +#include +#include + +#ifdef CONFIG_CPU_CP15 +#define read_cpuid(reg) \ + ({ \ + unsigned int __val; \ + asm("mrc p15, 0, %0, c0, c0, " __stringify(reg) \ + : "=r" (__val) \ + : \ + : "cc"); \ + __val; \ + }) +#else +extern unsigned int processor_id; +#define read_cpuid(reg) (processor_id) +#endif + +/* + * The CPU ID never changes at run time, so we might as well tell the + * compiler that it's constant. Use this function to read the CPU ID + * rather than directly reading processor_id or read_cpuid() directly. + */ +static inline unsigned int read_cpuid_id(void) __attribute_const__; + +static inline unsigned int read_cpuid_id(void) +{ + return read_cpuid(CPUID_ID); +} + +#define __exception __attribute__((section(".exception.text"))) + +struct thread_info; +struct task_struct; + +/* information about the system we're running on */ +extern unsigned int system_rev; +extern unsigned int system_serial_low; +extern unsigned int system_serial_high; +extern unsigned int mem_fclk_21285; + +struct pt_regs; + +void die(const char *msg, struct pt_regs *regs, int err) + __attribute__((noreturn)); + +struct siginfo; +void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info, + unsigned long err, unsigned long trap); + +void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int, + struct pt_regs *), + int sig, const char *name); + +#define xchg(ptr,x) \ + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) + +extern asmlinkage void __backtrace(void); +extern asmlinkage void c_backtrace(unsigned long fp, int pmode); + +struct mm_struct; +extern void show_pte(struct mm_struct *mm, unsigned long addr); +extern void __show_regs(struct pt_regs *); + +extern int cpu_architecture(void); +extern void cpu_init(void); + +void arm_machine_restart(char mode); +extern void (*arm_pm_restart)(char str); + +/* + * Intel's XScale3 core supports some v6 features (supersections, L2) + * but advertises itself as v5 as it does not support the v6 ISA. For + * this reason, we need a way to explicitly test for this type of CPU. + */ +#ifndef CONFIG_CPU_XSC3 +#define cpu_is_xsc3() 0 +#else +static inline int cpu_is_xsc3(void) +{ + extern unsigned int processor_id; + + if ((processor_id & 0xffffe000) == 0x69056000) + return 1; + + return 0; +} +#endif + +#if !defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_CPU_XSC3) +#define cpu_is_xscale() 0 +#else +#define cpu_is_xscale() 1 +#endif + +#define UDBG_UNDEFINED (1 << 0) +#define UDBG_SYSCALL (1 << 1) +#define UDBG_BADABORT (1 << 2) +#define UDBG_SEGV (1 << 3) +#define UDBG_BUS (1 << 4) + +extern unsigned int user_debug; + +#if __LINUX_ARM_ARCH__ >= 4 +#define vectors_high() (cr_alignment & CR_V) +#else +#define vectors_high() (0) +#endif + +#if __LINUX_ARM_ARCH__ >= 7 +#define isb() __asm__ __volatile__ ("isb" : : : "memory") +#define dsb() __asm__ __volatile__ ("dsb" : : : "memory") +#define dmb() __asm__ __volatile__ ("dmb" : : : "memory") +#elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6 +#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \ + : : "r" (0) : "memory") +#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \ + : : "r" (0) : "memory") +#define dmb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" \ + : : "r" (0) : "memory") +#else +#define isb() __asm__ __volatile__ ("" : : : "memory") +#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \ + : : "r" (0) : "memory") +#define dmb() __asm__ __volatile__ ("" : : : "memory") +#endif + +#ifndef CONFIG_SMP +#define mb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0) +#define rmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0) +#define wmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0) +#define smp_mb() barrier() +#define smp_rmb() barrier() +#define smp_wmb() barrier() +#else +#define mb() dmb() +#define rmb() dmb() +#define wmb() dmb() +#define smp_mb() dmb() +#define smp_rmb() dmb() +#define smp_wmb() dmb() +#endif +#define read_barrier_depends() do { } while(0) +#define smp_read_barrier_depends() do { } while(0) + +#define set_mb(var, value) do { var = value; smp_mb(); } while (0) +#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t"); + +extern unsigned long cr_no_alignment; /* defined in entry-armv.S */ +extern unsigned long cr_alignment; /* defined in entry-armv.S */ + +static inline unsigned int get_cr(void) +{ + unsigned int val; + asm("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) : : "cc"); + return val; +} + +static inline void set_cr(unsigned int val) +{ + asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR" + : : "r" (val) : "cc"); + isb(); +} + +#ifndef CONFIG_SMP +extern void adjust_cr(unsigned long mask, unsigned long set); +#endif + +#define CPACC_FULL(n) (3 << (n * 2)) +#define CPACC_SVC(n) (1 << (n * 2)) +#define CPACC_DISABLE(n) (0 << (n * 2)) + +static inline unsigned int get_copro_access(void) +{ + unsigned int val; + asm("mrc p15, 0, %0, c1, c0, 2 @ get copro access" + : "=r" (val) : : "cc"); + return val; +} + +static inline void set_copro_access(unsigned int val) +{ + asm volatile("mcr p15, 0, %0, c1, c0, 2 @ set copro access" + : : "r" (val) : "cc"); + isb(); +} + +/* + * switch_mm() may do a full cache flush over the context switch, + * so enable interrupts over the context switch to avoid high + * latency. + */ +#define __ARCH_WANT_INTERRUPTS_ON_CTXSW + +/* + * switch_to(prev, next) should switch from task `prev' to `next' + * `prev' will never be the same as `next'. schedule() itself + * contains the memory barrier to tell GCC not to cache `current'. + */ +extern struct task_struct *__switch_to(struct task_struct *, struct thread_info *, struct thread_info *); + +#define switch_to(prev,next,last) \ +do { \ + last = __switch_to(prev,task_thread_info(prev), task_thread_info(next)); \ +} while (0) + +#if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110) +/* + * On the StrongARM, "swp" is terminally broken since it bypasses the + * cache totally. This means that the cache becomes inconsistent, and, + * since we use normal loads/stores as well, this is really bad. + * Typically, this causes oopsen in filp_close, but could have other, + * more disasterous effects. There are two work-arounds: + * 1. Disable interrupts and emulate the atomic swap + * 2. Clean the cache, perform atomic swap, flush the cache + * + * We choose (1) since its the "easiest" to achieve here and is not + * dependent on the processor type. + * + * NOTE that this solution won't work on an SMP system, so explcitly + * forbid it here. + */ +#define swp_is_buggy +#endif + +static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size) +{ + extern void __bad_xchg(volatile void *, int); + unsigned long ret; +#ifdef swp_is_buggy + unsigned long flags; +#endif +#if __LINUX_ARM_ARCH__ >= 6 + unsigned int tmp; +#endif + + switch (size) { +#if __LINUX_ARM_ARCH__ >= 6 + case 1: + asm volatile("@ __xchg1\n" + "1: ldrexb %0, [%3]\n" + " strexb %1, %2, [%3]\n" + " teq %1, #0\n" + " bne 1b" + : "=&r" (ret), "=&r" (tmp) + : "r" (x), "r" (ptr) + : "memory", "cc"); + break; + case 4: + asm volatile("@ __xchg4\n" + "1: ldrex %0, [%3]\n" + " strex %1, %2, [%3]\n" + " teq %1, #0\n" + " bne 1b" + : "=&r" (ret), "=&r" (tmp) + : "r" (x), "r" (ptr) + : "memory", "cc"); + break; +#elif defined(swp_is_buggy) +#ifdef CONFIG_SMP +#error SMP is not supported on this platform +#endif + case 1: + raw_local_irq_save(flags); + ret = *(volatile unsigned char *)ptr; + *(volatile unsigned char *)ptr = x; + raw_local_irq_restore(flags); + break; + + case 4: + raw_local_irq_save(flags); + ret = *(volatile unsigned long *)ptr; + *(volatile unsigned long *)ptr = x; + raw_local_irq_restore(flags); + break; +#else + case 1: + asm volatile("@ __xchg1\n" + " swpb %0, %1, [%2]" + : "=&r" (ret) + : "r" (x), "r" (ptr) + : "memory", "cc"); + break; + case 4: + asm volatile("@ __xchg4\n" + " swp %0, %1, [%2]" + : "=&r" (ret) + : "r" (x), "r" (ptr) + : "memory", "cc"); + break; +#endif + default: + __bad_xchg(ptr, size), ret = 0; + break; + } + + return ret; +} + +extern void disable_hlt(void); +extern void enable_hlt(void); + +#include + +/* + * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make + * them available. + */ +#define cmpxchg_local(ptr, o, n) \ + ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ + (unsigned long)(n), sizeof(*(ptr)))) +#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) + +#ifndef CONFIG_SMP +#include +#endif + +#endif /* __ASSEMBLY__ */ + +#define arch_align_stack(x) (x) + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h new file mode 100644 index 0000000..f5a6647 --- /dev/null +++ b/include/asm-arm/thread_info.h @@ -0,0 +1,166 @@ +/* + * linux/include/asm-arm/thread_info.h + * + * Copyright (C) 2002 Russell King. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_ARM_THREAD_INFO_H +#define __ASM_ARM_THREAD_INFO_H + +#ifdef __KERNEL__ + +#include +#include + +#define THREAD_SIZE_ORDER 1 +#define THREAD_SIZE 8192 +#define THREAD_START_SP (THREAD_SIZE - 8) + +#ifndef __ASSEMBLY__ + +struct task_struct; +struct exec_domain; + +#include +#include + +typedef unsigned long mm_segment_t; + +struct cpu_context_save { + __u32 r4; + __u32 r5; + __u32 r6; + __u32 r7; + __u32 r8; + __u32 r9; + __u32 sl; + __u32 fp; + __u32 sp; + __u32 pc; + __u32 extra[2]; /* Xscale 'acc' register, etc */ +}; + +/* + * low level task data that entry.S needs immediate access to. + * __switch_to() assumes cpu_context follows immediately after cpu_domain. + */ +struct thread_info { + unsigned long flags; /* low level flags */ + int preempt_count; /* 0 => preemptable, <0 => bug */ + mm_segment_t addr_limit; /* address limit */ + struct task_struct *task; /* main task structure */ + struct exec_domain *exec_domain; /* execution domain */ + __u32 cpu; /* cpu */ + __u32 cpu_domain; /* cpu domain */ + struct cpu_context_save cpu_context; /* cpu context */ + __u32 syscall; /* syscall number */ + __u8 used_cp[16]; /* thread used copro */ + unsigned long tp_value; + struct crunch_state crunchstate; + union fp_state fpstate __attribute__((aligned(8))); + union vfp_state vfpstate; +#ifdef CONFIG_ARM_THUMBEE + unsigned long thumbee_state; /* ThumbEE Handler Base register */ +#endif + struct restart_block restart_block; +}; + +#define INIT_THREAD_INFO(tsk) \ +{ \ + .task = &tsk, \ + .exec_domain = &default_exec_domain, \ + .flags = 0, \ + .preempt_count = 1, \ + .addr_limit = KERNEL_DS, \ + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \ + domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \ + domain_val(DOMAIN_IO, DOMAIN_CLIENT), \ + .restart_block = { \ + .fn = do_no_restart_syscall, \ + }, \ +} + +#define init_thread_info (init_thread_union.thread_info) +#define init_stack (init_thread_union.stack) + +/* + * how to get the thread information struct from C + */ +static inline struct thread_info *current_thread_info(void) __attribute_const__; + +static inline struct thread_info *current_thread_info(void) +{ + register unsigned long sp asm ("sp"); + return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); +} + +/* thread information allocation */ +#ifdef CONFIG_DEBUG_STACK_USAGE +#define alloc_thread_info(tsk) \ + ((struct thread_info *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, \ + THREAD_SIZE_ORDER)) +#else +#define alloc_thread_info(tsk) \ + ((struct thread_info *)__get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER)) +#endif + +#define free_thread_info(info) \ + free_pages((unsigned long)info, THREAD_SIZE_ORDER); + +#define thread_saved_pc(tsk) \ + ((unsigned long)(pc_pointer(task_thread_info(tsk)->cpu_context.pc))) +#define thread_saved_fp(tsk) \ + ((unsigned long)(task_thread_info(tsk)->cpu_context.fp)) + +extern void crunch_task_disable(struct thread_info *); +extern void crunch_task_copy(struct thread_info *, void *); +extern void crunch_task_restore(struct thread_info *, void *); +extern void crunch_task_release(struct thread_info *); + +extern void iwmmxt_task_disable(struct thread_info *); +extern void iwmmxt_task_copy(struct thread_info *, void *); +extern void iwmmxt_task_restore(struct thread_info *, void *); +extern void iwmmxt_task_release(struct thread_info *); +extern void iwmmxt_task_switch(struct thread_info *); + +#endif + +/* + * We use bit 30 of the preempt_count to indicate that kernel + * preemption is occurring. See include/asm-arm/hardirq.h. + */ +#define PREEMPT_ACTIVE 0x40000000 + +/* + * thread information flags: + * TIF_SYSCALL_TRACE - syscall trace active + * TIF_SIGPENDING - signal pending + * TIF_NEED_RESCHED - rescheduling necessary + * TIF_USEDFPU - FPU was used by this task this quantum (SMP) + * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED + */ +#define TIF_SIGPENDING 0 +#define TIF_NEED_RESCHED 1 +#define TIF_SYSCALL_TRACE 8 +#define TIF_POLLING_NRFLAG 16 +#define TIF_USING_IWMMXT 17 +#define TIF_MEMDIE 18 +#define TIF_FREEZE 19 + +#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) +#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) +#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) +#define _TIF_FREEZE (1 << TIF_FREEZE) + +/* + * Change these and you break ASM code in entry-common.S + */ +#define _TIF_WORK_MASK 0x000000ff + +#endif /* __KERNEL__ */ +#endif /* __ASM_ARM_THREAD_INFO_H */ diff --git a/include/asm-arm/types.h b/include/asm-arm/types.h new file mode 100644 index 0000000..345df01 --- /dev/null +++ b/include/asm-arm/types.h @@ -0,0 +1,31 @@ +#ifndef __ASM_ARM_TYPES_H +#define __ASM_ARM_TYPES_H + +#include + +#ifndef __ASSEMBLY__ + +typedef unsigned short umode_t; + +#endif /* __ASSEMBLY__ */ + +/* + * These aren't exported outside the kernel to avoid name space clashes + */ +#ifdef __KERNEL__ + +#define BITS_PER_LONG 32 + +#ifndef __ASSEMBLY__ + +/* Dma addresses are 32-bits wide. */ + +typedef u32 dma_addr_t; +typedef u32 dma64_addr_t; + +#endif /* __ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif + diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h new file mode 100644 index 0000000..9d40e87 --- /dev/null +++ b/include/asm-generic/4level-fixup.h @@ -0,0 +1,37 @@ +#ifndef _4LEVEL_FIXUP_H +#define _4LEVEL_FIXUP_H + +#define __ARCH_HAS_4LEVEL_HACK +#define __PAGETABLE_PUD_FOLDED + +#define PUD_SIZE PGDIR_SIZE +#define PUD_MASK PGDIR_MASK +#define PTRS_PER_PUD 1 + +#define pud_t pgd_t + +#define pmd_alloc(mm, pud, address) \ + ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \ + NULL: pmd_offset(pud, address)) + +#define pud_alloc(mm, pgd, address) (pgd) +#define pud_offset(pgd, start) (pgd) +#define pud_none(pud) 0 +#define pud_bad(pud) 0 +#define pud_present(pud) 1 +#define pud_ERROR(pud) do { } while (0) +#define pud_clear(pud) pgd_clear(pud) +#define pud_val(pud) pgd_val(pud) +#define pud_populate(mm, pud, pmd) pgd_populate(mm, pud, pmd) +#define pud_page(pud) pgd_page(pud) +#define pud_page_vaddr(pud) pgd_page_vaddr(pud) + +#undef pud_free_tlb +#define pud_free_tlb(tlb, x) do { } while (0) +#define pud_free(mm, x) do { } while (0) +#define __pud_free_tlb(tlb, x) do { } while (0) + +#undef pud_addr_end +#define pud_addr_end(addr, end) (end) + +#endif diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild new file mode 100644 index 0000000..4c9932a --- /dev/null +++ b/include/asm-generic/Kbuild @@ -0,0 +1,13 @@ +header-y += errno-base.h +header-y += errno.h +header-y += fcntl.h +header-y += ioctl.h +header-y += mman.h +header-y += poll.h +header-y += signal.h +header-y += statfs.h + +unifdef-y += int-l64.h +unifdef-y += int-ll64.h +unifdef-y += resource.h +unifdef-y += siginfo.h diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm new file mode 100644 index 0000000..92a6d91 --- /dev/null +++ b/include/asm-generic/Kbuild.asm @@ -0,0 +1,33 @@ +header-y += kvm.h + +ifeq ($(wildcard include/asm-$(SRCARCH)/a.out.h),include/asm-$(SRCARCH)/a.out.h) +unifdef-y += a.out.h +endif +unifdef-y += auxvec.h +unifdef-y += byteorder.h +unifdef-y += errno.h +unifdef-y += fcntl.h +unifdef-y += ioctl.h +unifdef-y += ioctls.h +unifdef-y += ipcbuf.h +unifdef-y += mman.h +unifdef-y += msgbuf.h +unifdef-y += param.h +unifdef-y += poll.h +unifdef-y += posix_types.h +unifdef-y += ptrace.h +unifdef-y += resource.h +unifdef-y += sembuf.h +unifdef-y += setup.h +unifdef-y += shmbuf.h +unifdef-y += sigcontext.h +unifdef-y += siginfo.h +unifdef-y += signal.h +unifdef-y += socket.h +unifdef-y += sockios.h +unifdef-y += stat.h +unifdef-y += statfs.h +unifdef-y += termbits.h +unifdef-y += termios.h +unifdef-y += types.h +unifdef-y += unistd.h diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h new file mode 100644 index 0000000..85fd0aa --- /dev/null +++ b/include/asm-generic/atomic.h @@ -0,0 +1,258 @@ +#ifndef _ASM_GENERIC_ATOMIC_H +#define _ASM_GENERIC_ATOMIC_H +/* + * Copyright (C) 2005 Silicon Graphics, Inc. + * Christoph Lameter + * + * Allows to provide arch independent atomic definitions without the need to + * edit all arch specific atomic.h files. + */ + +#include + +/* + * Suppport for atomic_long_t + * + * Casts for parameters are avoided for existing atomic functions in order to + * avoid issues with cast-as-lval under gcc 4.x and other limitations that the + * macros of a platform may have. + */ + +#if BITS_PER_LONG == 64 + +typedef atomic64_t atomic_long_t; + +#define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i) + +static inline long atomic_long_read(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return (long)atomic64_read(v); +} + +static inline void atomic_long_set(atomic_long_t *l, long i) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_set(v, i); +} + +static inline void atomic_long_inc(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_inc(v); +} + +static inline void atomic_long_dec(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_dec(v); +} + +static inline void atomic_long_add(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_add(i, v); +} + +static inline void atomic_long_sub(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_sub(i, v); +} + +static inline int atomic_long_sub_and_test(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return atomic64_sub_and_test(i, v); +} + +static inline int atomic_long_dec_and_test(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return atomic64_dec_and_test(v); +} + +static inline int atomic_long_inc_and_test(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return atomic64_inc_and_test(v); +} + +static inline int atomic_long_add_negative(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return atomic64_add_negative(i, v); +} + +static inline long atomic_long_add_return(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return (long)atomic64_add_return(i, v); +} + +static inline long atomic_long_sub_return(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return (long)atomic64_sub_return(i, v); +} + +static inline long atomic_long_inc_return(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return (long)atomic64_inc_return(v); +} + +static inline long atomic_long_dec_return(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return (long)atomic64_dec_return(v); +} + +static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u) +{ + atomic64_t *v = (atomic64_t *)l; + + return (long)atomic64_add_unless(v, a, u); +} + +#define atomic_long_inc_not_zero(l) atomic64_inc_not_zero((atomic64_t *)(l)) + +#define atomic_long_cmpxchg(l, old, new) \ + (atomic_cmpxchg((atomic64_t *)(l), (old), (new))) +#define atomic_long_xchg(v, new) \ + (atomic_xchg((atomic64_t *)(l), (new))) + +#else /* BITS_PER_LONG == 64 */ + +typedef atomic_t atomic_long_t; + +#define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i) +static inline long atomic_long_read(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return (long)atomic_read(v); +} + +static inline void atomic_long_set(atomic_long_t *l, long i) +{ + atomic_t *v = (atomic_t *)l; + + atomic_set(v, i); +} + +static inline void atomic_long_inc(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_inc(v); +} + +static inline void atomic_long_dec(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_dec(v); +} + +static inline void atomic_long_add(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_add(i, v); +} + +static inline void atomic_long_sub(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_sub(i, v); +} + +static inline int atomic_long_sub_and_test(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return atomic_sub_and_test(i, v); +} + +static inline int atomic_long_dec_and_test(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return atomic_dec_and_test(v); +} + +static inline int atomic_long_inc_and_test(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return atomic_inc_and_test(v); +} + +static inline int atomic_long_add_negative(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return atomic_add_negative(i, v); +} + +static inline long atomic_long_add_return(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return (long)atomic_add_return(i, v); +} + +static inline long atomic_long_sub_return(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return (long)atomic_sub_return(i, v); +} + +static inline long atomic_long_inc_return(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return (long)atomic_inc_return(v); +} + +static inline long atomic_long_dec_return(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return (long)atomic_dec_return(v); +} + +static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u) +{ + atomic_t *v = (atomic_t *)l; + + return (long)atomic_add_unless(v, a, u); +} + +#define atomic_long_inc_not_zero(l) atomic_inc_not_zero((atomic_t *)(l)) + +#define atomic_long_cmpxchg(l, old, new) \ + (atomic_cmpxchg((atomic_t *)(l), (old), (new))) +#define atomic_long_xchg(v, new) \ + (atomic_xchg((atomic_t *)(l), (new))) + +#endif /* BITS_