为Cortex-A系列处理器开发应用的程序开发者提供把广泛的不同类别的资源收集到一起集成为一本指南,涵盖那些对应用代码开发者有价值的缓存,内存管理等概念,是为C\编开发者提供有用的信息。ContentsCortex-A Series Programmer's GuidePrefaceReferenXTypographical conventionsFeedback on this booksaryChapter 1troductionHistol1-21.2 System-on-Chip(Soc);;;。;1-3Embedded systems1-4Chapter 2ARM Architecture and processors2.1Architecture versions2-3Architecture history and extensions242.3 Key architectural points of ARM Cortex-A series processors282. 4 Processors and pipelines2-92.5The Cortex-A series processors2-11Chapter 3Tools, Operating systems and boards3.1Linux distributions∴3-23.2Useful tools3.3 Software toolchains for ARM processors3-83.4ARM DS-53.5 Example platforms3-13Chapter 4ARM Registers, Modes and Instruction Sets4.1Instruction sets“aaaa:.4-24.2Modes4-3ARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedDo71612Non-ConfidentialContents4.3 Registers4-4Instruction pipelines4.5Branch prediction4-10Chapter 5Introduction to Assembly Language5.1Comparison with other assembly languages5-25.2Instruction sets5.3Introduction to the gnu assembler5-55.4aRM tools assembly language5-95.5nterworking…5-15.6 Identifying assembly codeChapter 6ARM/Thumb Unified Assembly Language Instructions6.1Instruction set basics.6-26.2 Data processing operations.Ii..6-66.3Multiplication operations6-96.4Memory instructions6-106.5Branches6-136.6 Integer SIMD instructions6-146.76-186.8 Miscellaneous instructions6-19Chapter 7Floating PointFloating-point basics and the IEEE-754 standard7-27. 2 VFP support in GCC7-8VFP support in the aRm compiler7-974FP support in Linux…7-107.5Floating-point optimization7-11Chapter 8Introducing NEON8.1S|MD…8-28.2Neon architecture overview8-4Chapter 9Caches9.1Why do caches help?9-3Cache drawbacks9-49.3 Memory hierarchy9-5969.5Cache policies9-129.6Write and fetch buffers.9-149.7 Cache performance and hit rate………..9-159.8 Invalidating and cleaning cache memory9-169. 9 Point of coherency and unification9-179.10 Level 2 cache controller9189. 11 Parity and ECC in caches9-19Chapter 10Memory Management Unit10.1 Virtual memory10-310.2 Level 1 page tables10-410.3 Level 2 page tables10-710.4 The Translation lookaside buffer10-10105TLB coherency….10-1110.6 Choice of page sizes10-1210.7 Memory attributes10-1310.8 Multi-tasking and os usage of page tables10-1610.9 Large Physical Address Extensions10-19ARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedD071612Non-ConfidentialContentsChapter 11Memory Ordering11.1 ARM memory ordering model..11-411.2 Memory barriers11-71.3 Cache coherency implications11-12Chapter 12Exception Handling12.1 Types of exception12-312.2 Exception mode summary12-512.3 Entering an exception handler∴12-712.4 Exit from an exception handler12-812.5∨ ector table12912.6 Return instruction12-10Chapter 13Interrupt Handling3.1 EXternal interrupt requests13-213.2 Generic Interrupt Controller13-4Chapter 14Other Exception Handlers14.1Abort handler14-214.2 Undefined instruction handling14-314.3 SVC exception handling....14-414.4 Linux exception program flow14-5Chapter 15Boot code15.1 Booting a bare- metal system15-215.2 Configuration.15-615.3 Booting Linux15-7Chapter 16Porting16.1 Endianness16-216.2 Alignment16-516.3 Miscellaneous c porting issues16-716.4 Porting aRM assembly code to ARMv716-1016.5 Porting arm code to Thumb16-11Chapter 17Application Binary Interfaces17.1 Procedure call standard17-217.2 Mixing C and17-7Chapter 18Profilin18.1 Profiler output18-3Chapter 19Optimizing code to Run on ARM Processors19.1 Compiler optimizations.19-319.2 ARM memory system optimization19-819.3 Source code modifications1913Chapter 20 Writing NEON Code20. 1 NEON C Compiler and assembler20-220.2 Optimizing neon assembler code20-720. 3 NEoN power saving20-9Chapter 21Introduction to Multi- processingMulti-processing ARM systems21-321.2 Symmetric multi-processing21521.3 Asymmetric multi-processing21-7ARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedD071612Non-ConfidentialContentsChapter 22SMP Architectural considerations22.1 Cache coherency22222.2 TLB and cache maintenance broadcast22-5ts in an smP22. 4 Exclusive accesses22-7Booting SMP systems22-1022.6 Private memory region22-12Chapter 23Parallelizing Software23.1Decomposition methods23-223.2 Threading models23-423.3Threading libraries23-523.4 Synchronization mechanisms in the Linux kernel.23-8Chapter 24Issues with Parallelizing software24.1 Thread safety and reentrancy24-224.2 Performance issues24-324.3 Profiling in SMP systems24-5Chapter 25Power Management25.1 Power and clocking….25-2Chapter 26Security26.1 Trustzone hardware architecture.26-2Chapter 27Virtualization27.1 ARMv7-A Virtualization extensions27-327.2 Hypervisor exception model27-527.3 Relationship between virtualization and ARM Security Extensions27-6Chapter 28Introducing big LITTLE28. 1 big. LITTLE configuration…28-228.2 Structure of a big. LITTLE system..28-328.3 Execution models in big LITTLE28-428.4 big. LITTLE MP operation28-9Chapter 29Debug29ARM debug hardware....29-229.2 ARM trace hardware29429.3 Debug monitor29729.4 Debugging Linux applications29-829.5 DS-5 debug and traceAppendix a Instruction SummaryA.1Instruction Summary…“cEA-2Appendix B NeoN and VFP Instruction SummaryB. 1 neon general data processing instructions...B-6B.2Neon Shift instructionsB-13B.3neoN logical and compare operationsB-17B.4NEoN arithmetic instructionsB-23B5 NEON multiply instructionsB-32B.6neon load and store element and structure instructionsB-35B7 VEP instructionsB-41B.8NEOn and VFP pseudo-instructionsB-47ARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedD071612Non-ConfidentialContentsAppendixc Building Linux for ARM SystemsC.1Building the Linux kernelC-2C2 Creating the Linux filesystem..C-6C3 Putting it togetherARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedD071612Non-ConfidentialPrefaceThis book provides an introduction to ARM technology for programmers using ARM Cortex-Aseries processors that conform to the aRM ARMv7-a architecture. The v 7 refers to version 7 ofthe architecture while the a indicates the architecture profile that describes application processorsThis includes the Cortex-A5, Cortex-A7, Cortex-A8, Cortex-A9 and Cortex-Al5 processors Thebook complements rather than replaces other arM documentation that is available for Cortex-Aseries processors, such as the ARM Technical Reference Manuals(TRMs) for the processorsthemselves, documentation for individual devices or boards and, most importantly, the ARMArchitecture reference Manual(or the"ARM ARM)The purpose of this book is to bring together information from a wide variety of sources to providea single guide for programmers who want to develop applications for the latest Cortex-A series ofprocessors. We will cover hardware concepts such as caches and Memory Management Units, butonly where this is valuable to the application writer. The book is intended to provide informationthat will be useful to both assembly language and c programmers We will look at how complexoperating systems, such as Linux, make use of ARM features, and how to take full advantage ofthe many advanced capabilities of the ARM processor, in particular writing software formulti-processing and using the SIMd capabilities of the deviceAlthough much of the book is also applicable to other arm processors, we do not explicitly coverprocessors that implement older versions of the Architecture. The Cortex-R series and M-seriesprocessors are mentioned but not described. Our intention is to provide an approachableintroduction to the ARM architecture, covering the feature set in detail and providing practicaladvice on writing both C and assembly language programs lo run efficiently on a Corlex-A seriesprocessor.This is not an introductory level book. We assume knowledge of the c programming language andmicroprocessors, but not of any ARM-specific background. In the allotted space, we cannot hopeto cover every topic in detail. In some chapters, we suggest further reading(referring either tobooks or websites) that can give a deeper level of background to the topic in hand but in this bookwe will focus on the ARM-specific detail. We do not assume the use of any particular tool chainARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedDo71612Non-ConfidentialPrefaceWe will mention both GNU and ARM tools in the course of the book. We hope that the bookwill be well suited to programmers who have a desktop PC or x86 background and are takingtheir first steps into the arM processor based worldThe first chapters of the book cover the basic features of the ARM Cortex-A series processorsAn introduction to the fundamentals of the arM architecture and some background onindividual processors is provided in Chapter 2. In Chapter 3, we briefly consider some of thetools and platforms available to those getting started with aRM programming Chapters 4, 5 and6 provide a brisk introduction to ARM assembly language programming, covering the variousregisters, modes and assembly language instructions We look at floating-point and the armAdvanced SIMD extensions (NEON)in Chapters 7 and 8. These chapters are only anintroduction to the relevant topics. It would take significantly longer to cover all of the powerfulcapabilities of neoN and how to apply these to common signal processing algorithms. We thenswitch our focus to the memory system and look at Caches, Memory Management and MemoryOrdering in Chapters 9, 10 and 11. Dealing with interrupts and other exceptions is described inChapters 12 to 14The remaining chapters of the book provide more advanced programming informationChapter 15 provides an overview of boot code. Chapter 16 looks at issues with porting C andassembly code to the ARMv7 architecture, from other architectures and from older versions ofthe arm architecture. Chapter 17 covers the application Binary Interlace, knowledge of whichis useful to both C and assembly language programmers Profiling and optimizing of code iscovered in Chapters 18 and 19. Many of the techniques presented are not specific to the armarchitecture, but we also provide some processor-specific hintsChapters 21-24 cover the area of multi-processing. We take a detailed look at how this isimplemented by arm and how you can write code to take advantage of it. Power managementis an important part of arm programming and is covered in Chapter 21. The final chapters ofthe book provide a brief coverage of the ARM Security Extensions(TrustZone ) the ARMVirtualization extensions(Chapter 27), big. LITTLE technology(Chapter 28), and thepowerful hardware debug features available to programmers( Chapter 29). Appendices a and Bgive a summary of the available ARM, NEON and VFP instructions and Appendix c givesstep-by-step instructions for configuring and building linux for arm systemsARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedDo71612Non-ConfidentialPrefaceReferencesCohen, D. On Holy Wars and a Plea for Peace, USC/ISI IEN April, 1980,htlp://www.ietf.org/rfc/ien/ien137.txtFurber, Steve. "ARM System-on-chip Architecture, 2nd edition, Addison-Wesley, 2000, ISBN9780201675191Hohl, William. "ARM Assembly Language: Fundamentals and Techniques "CRC Press, 2009ISBN:9781439806104Sloss, Andrew N; Symes, Dominic; Wright, Chris. ARM SyStem Developer's GuideDesigning and Optimizing System Software", Morgan Kaufmann, 2004, ISBN9781558608740.ANSITEEE Std 754-1985, IEEE Standard for Binary Floating-Point ArithmeticANSI/TEEE Std 754-2008, IEEE Standard for Binary Floating-Point ArithmeticANSI/TEEE Std 1003. 1-1990, Standard for Information Technology- Portable operatingSystem Interface(Posix Base specifications, Issue 7ANSI/TEEE Std 1149.1-2001, "TEEE Standard Test Access Port and Boundary-ScanArchitecture?"The aRM Architecture Reference Manual(known as the arM arm)is a must-read for anyserious ARM programmer. It is available(after registration) from the ARM website. It fullydescribes the ARMv7 instruction set architecture, programmers model, system registers, debugfeatures and memory model. It forms a detailed specification to which all implementations ofARM processors must adhereReferences to the ARM Architecture reference manual in this document are toARM Architecture reference manual-ARMv7-A and ARMv7-R edition(ARM DDI 0406)NoteIn the event of a contradiction between this book and the armarm. the armarm isdefinitive and must take precedence. In most instances, however, the ARMARM and theCortex-A Programmer's Guide cover two separate world views. The ARM ARM is foprocessor implementers, while this book is for processor users. The most likely scenario is thatthis book will describe something in a way that does not cover all architecturally permittedbehaviors-or simply rewords an abstract concept in more practical termsARM Generic Interrupt Controller Architecture Specification (ARM IHI 0048)ARM Compiler Toolchain Assembler Reference(DUI 0489)ARM C Language Extensions (IHI 0053)The individual processor Technical Reference Manuals provide a detailed description of theprocessor behavior. They can be obtained from the ARM website documentation area,http://infocenter.arm.comARM DENO013CCopyright o 2011, 2012 ARM. All rights reservedDo71612Non-Confidential