- ARM認證工程師應試指南
- 奚海蛟 諶利編著
- 26139字
- 2019-01-01 04:57:54
1.3 大綱詳述
在本節,學生可以了解每個知識點的詳細要求。引用大綱的文字采用斜體,緊跟著正體的文字將解釋大綱的內容,包含如何找到相關信息,以及一些必要的額外信息。
1.3.1 實現
1.ARM處理器家族
(1)什么是多內核
Candidates should be familiar with the available processors from ARM and know which of these may be used in multiprocessor configurations.
考生需要熟悉ARM的處理器,并且了解其中哪些是用于多處理器配置的。
本書3.4節描述了一些常見的ARM處理器,3.5節更詳細地描述了Cortex-A系列的處理器,尤其需要詳細了解表3-3。
(2)連接硬件
Candidates should be aware of the concept of coherency hardware, what it does, why it is required and what are the benefits of using it.
考生需要了解連接硬件的含義,它是做什么的,為什么需要它以及它的優勢是什么。
雖然這部分內容是在大綱的開始部分提及的,但它屬于難度較大的知識點。連接硬件是在多核系統中必須使用的。要理解它是如何工作的以及它是如何影響軟件開發的,需要具備對多核系統以及緩存知識的了解。這部分內容位于第10章(緩存)及第22章(介紹多核系統),連接硬件是在23.1節介紹的。
(3)通用中斷控制器GIC
通用中斷控制器GIC在“編程手冊”的14.2節介紹,考生應該同時參考23.3節(多內核系統中斷處理)來學習。GIC常用于Cortex-A5多內核、Cortex-A9多內核以及Cortex-R7多內核處理器中,它也可作為可選部件存在于Cortex-A7和Cortex-A15內核中。
(4)架構版本歸屬
Candidates must be able to identify which ARM processors conform to which Architecture versions. Architectures from ARMv4T onwards are included, with the exception of ARMv7-M and ARMv6-M architectures.
考生需要能夠識別具體的ARM的處理器是屬于哪個處理器架構版本的。ARMv4T架構之后的都需要了解。
表3-2提供了相關的詳細信息
(5)性能
Candidates must be able to distinguish between applications, real-time and microcontroller profiles, be aware of the distinguishing features between them and understand the typical target market/applications of each.
考生需要能夠區別ARM Cortex的應用、實時和微控制器三大系列的區別,理解它們之間的不同特性以及所針對的典型目標應用和市場。
《Cortex-A系列程序員指南》,顧名思義,它只介紹了Cortex-A系列,并沒有提供很多關于Cortex-R和Cortex-M系列的知識。Cortex-A系列處理器主要應用于需要MMU內存管理單元和緩存工作的操作系統的應用場合,要求擁有高性能的處理能力。
Cortex-R系列處理器主要面向實時應用,它面向需要硬實時反應能力的嵌入式系統。這說明它的特性要求有快速、確定的中斷響應,有緊密耦合的存儲器(TCM)位于處理器的局部快速總線上以提供快速響應的代碼和數據,有奇偶校驗或者ECC校驗機制來保證錯誤的檢測和修正。Cortex-R系列處理器使用內存保護單元MPU代替Cortex-A系列中的內存管理單元MMU來進行內存的管理和保護。
Cortex-M系列處理器面向低成本和功耗敏感的微控制器和混合信號系統。例如一些終端設備,包括智能電表、人機交互設備、自動和工業控制系統、大型家用電器、消費類產品和醫療儀器等。這類領域應用的關鍵是要求微量代碼(更好的代碼密度),易于使用以及節能。例如,Cortex-M0+內核是ARM處理器中能耗最低的內核,可達到mW/MHz。Cortex-M系列處理器僅支持16位和32位的Thumb指令集,通常不含緩存。
2.指令周期時序
Candidates should be aware of the effects of pipeline and memory system on instruction execution timing.
考生需要了解流水線和內存系統對指令執行時間的影響。
流水線在“程序員指南”的5.4節有一些介紹,分支預測在5.5節介紹。這些都提供了一些流水線架構相關的基本知識。
了解ARM7TDMI的三級流水線(取指、譯碼、執行)的含義可以幫助理解流水線對執行周期時序的影響。ARM7TDMI技術參考手冊給出了這個流水線,這讓理解流水線的概念變得更容易。
例如,在ARM7TDMI上分支跳轉會導致2個周期的損失,因為分支跳轉發生在流水線的執行階段,此時位于取指和譯碼階段的指令將被沖刷掉,流水線被重新按新的指令流填滿,因此在跳轉后的第一條指令執行前將產生3個周期的延遲。
同理,一旦理解了簡單的流水線,“加載-使用損耗”的概念就很明了了,它用于描述當寄存器加載一個存儲空間的值時的狀況。如果接下來的指令需要使用這個寄存器的值,那么它需要等待該寄存器完成數據的加載(并到達處理器流水線的相關級,可能通過專用通道到達)。編譯器(或者匯編器)會避免這種情況發生,它一般會試圖把使用加載數據的指令從加載指令處分離開。
1.3.2 軟件調試
1.標準調試手段
(1)軟件斷點和硬件斷點的區別
Candidates should be aware of the differences and limitations between Hardware and Software breakpoints. They should understand the usage of watchpoint units in configuring these two types of breakpoint.
考生需要清楚硬件和軟件斷點的區別以及各自的限制,需要了解在配置這兩種類型的斷點時觀察點單元的使用。
這部分在30.1節有詳細介紹。在較早的處理器(如ARM7TDMI)中,并沒有配備專用的斷點指令BKPT,而是使用設置觀察點單元來查看特定的位模式的,調試器可以在RAM的代碼空間中設置無限量的軟件斷點。調試器會讀取需要放置斷點指令的操作碼,并保存到主機上。這條指令然后被一個特定的數據位替代(通常對應的是一個無效指令)。通常,這需要處理器的數據緩存被清空并且使指令緩存無效,以確保從處理器數據端寫入的特定數據可以被取指邏輯正確訪問。在較新的處理器上,包括所有的Cortex系列處理器,則采用了BKPT指令來代替原來的需要放置斷點的操作碼。當斷點被移除時,原本存儲在主機上的原操作碼會被寫回。與此對應的是,硬件斷點可以被設置在任何類型的存儲器上(包括RAM和ROM),但它的數量則由硬件限制。
在學習這部分內容時,建議使用真實的調試器來理解它的使用和限制,獲得一些實際的應用經驗,這可以比書本上的解釋提供更多的有益背景知識。
(2)監控模式與停止模式調試
Candidates should be aware of the differences between debugging in each of the two modes and when one would be chosen over the other e.g. choosing monitor mode if interrupts must continue to be serviced while debugging.
考生需要了解調試的兩種模式之間的區別以及何時選用哪種模式。例如,需要在調試過程中仍舊響應中斷時,則應選擇監測模式來調試。
這一部分在30.1.1節有介紹。
(3)矢量捕捉
Candidates should be aware of the function of this feature, why and when it is typically used.
考生需要了解矢量捕捉的功能,為什么以及何時需要使用它。
矢量捕捉是調試器捕獲處理器異常中斷的方法,早期開發時在異常中斷服務句柄被取指之前捕獲到處理器的異常中斷。許多ARM的處理器都由矢量捕獲硬件來完成這一任務。而在另外一些處理器,如ARM7TDMI,調試器可以采用在異常矢量表的適當位置設置斷點的方法來進行中斷矢量捕獲。
(4)判別異常觸發原因(如DFSR、SPSR、Link鏈接寄存器)
Candidates should understand how to determine the actual cause of an exception by using additional resources, which might include special registers that contain fault status. For example, using the DFSR, DFAR to determine cause of a Data Abort or using the SPSR and LR to locate and retrieve SVC comment field.
考生應當理解如何使用額外的資源來判別觸發一個異常中斷的原因,這些資源通常包括含有錯誤狀態的特殊寄存器,如使用DFSR、DFAR來判別數據中止的原因,采用SPSR以及Link寄存器來定位并獲取SVC系統調用的參數位。
當調試一段軟件時,通常有必要了解為何特定的處理器異常會發生。為此ARM處理器提供了一系列的寄存器來提供有用的信息。在異常中斷中,當前異常模式的鏈接寄存器(LR)會給出主程序中最靠近觸發異常的指令的位置。通常觸發異常的指令的位置是LR寄存器的值減去4或者8(詳見13.2節)。類似地,SPSR寄存器的mode位可以給出在進入異常模式之前處理器所處的模式。
對于特定的模式,還有一些額外的信息。在取指異常或數據中止異常后,CP15寄存器的錯誤狀態寄存器(FSR)和故障地址寄存器(FAR)是值得注意的,它們可以給出異常中止發生的原因(如一個外部存儲器錯誤或者該地址的轉換表項無效)以及產生異常中止的內存訪問操作的地址。
注意
ARMv6-M和ARMv7-M架構在異常處理模型上與其他的ARM內核有所不同,但在基本的考試中這些并不要求掌握。
(5)跟蹤
Candidates should be aware of what Trace is, what on-chip and off-chip components are required to make it work, what it is used for. Also that it is non-intrusive.
考生需要了解什么是跟蹤,它正常工作需要哪些片上和片外模塊,它是用來做什么的,以及它是屬于非侵入式的。
這些都在30.2節中介紹。
(6)交叉觸發
考試對這部分不做要求
(7)物理調試接口
Candidates should be aware of available options for making physical connections to the target for the purpose of run-control debug (e.g. JTAG, SWD)
考生需要理解在線調試所需要的連接到物理目標系統的物理連接選項(如JTAG、SWD)。
這部分在第30章介紹。JTAG是一個廣泛使用的工業標準,它在物理上通常需要至少5個信號引腳來連接主機計算機和ARM目標系統板。串行調試口SWD是一個擁有類似調試功能的2腳調試口,并且它通常只在較新的處理器上才有。而從處理器抓取跟蹤信息,則需要比控制代碼執行大得多的帶寬,因為每個周期都會有很多的32位地址和數據信息產生,因此專用的跟蹤端口需要更多的引腳。此外,跟蹤信息也可以存儲在片上的緩沖區中,采用較少物理引腳的慢速調試口來讀取這些跟蹤信息。
(8)調試訪問內存
Candidates should be aware of how a debugger uses the processor to access memory and be aware of how memory translation affects this. They should also understand the potential impact of cache maintenance caused by debug operations on the state of the memory system.
考生需要了解調試器是如何使用處理器來訪問內存的,并且理解內存轉換如何影響這種訪問,還需要理解對內存系統狀態的調試操作可能帶來對緩存內容維系的潛在影響。
調試器通常需要顯示調試目標內存(或者外設)的內容并進行修改,它通常是通過處理器執行加載或者存儲指令來實現的,然而有些系統則可以通過內建的調試系統單元來直接對內存進行寫(或讀)操作,不需要處理器本身參與內存操作。
一個良好的調試器會減少調試動作對系統的影響。例如,它通常會盡量減小調試時對緩存的修改。如果調試器在調試窗口上顯示一塊內存區域的內容但調試器必須使用處理器來讀取內存時,它會盡量采用非緩存方式來操作,從而確保之前緩存中的內容不會被沖刷掉。程序員必須了解(當內存管理單元MMU被使能時)調試顯示使用的是虛擬地址而非物理地址,而且緩存中的內容可能與外部存儲器的內容不一致。
如果內存訪問是直接通過片上系統的調試單元(而非處理器)來進行的,那么訪問使用的就是物理地址而非處理器的虛擬地址轉換,而且它是直接訪問內存的(繞過處理器的緩存)。
(9)半主機
Candidates should be aware of semi-hosting, understand what its function is and how it can be used during development. They should also be aware of the invasive nature of using this feature and how it may affect timing etc. They should also be aware of the danger of using semi-hosting when no debugger is connected and how to retarget the standard C library.
考生需要理解半主機的功能是什么,在開發過程中應如何使用;需要了解這種機制的侵入式特性以及它對時序等方面的影響;還需要了解當目標板沒有連接調試器時使用這一機制的風險,以及它如何重定向到標準C庫。
半主機是一種讓ARM目標板上的代碼可以使用主機計算機上調試器提供的部分資源的機制。
這些資源可以包含鍵盤輸入、顯示輸出、硬盤I/O。例如,程序員可以使用這種機制提供的標準C庫函數,如printf()和Scanf()來使用主機上的終端屏幕和鍵盤。開發的硬件通常不包含全功能的輸入/輸出設備,而半主機則可以讓主機提供這些資源。
半主機是通過一系列專用的軟件指令產生異常來實現的。應用程序使用適當的半主機異常調用——調試中介來響應異常處理。調試中介會提供到主機所需的通信。
半主機的接口一般是通過ARM提供的調試單元作為中介來實現的。ARM的工具使用SVC 0x123456(ARM狀態)或者SVC 0xAB(Thumb狀態)來表示半主機調試函數。
當然,如果脫離了開發環境,運行著調試器的主機并不會連接到目標系統上。此時開發人員有必要將任何使用到半主機的庫函數重定向,如fputc()函數。這意味著需要使用能夠輸出字符到指定設備的代碼來替代使用SVC調用半主機的庫函數代碼。
2.標準調試技術
(1)調用棧
Candidates must understand what a call stack is and how it may be used in debugging.
考生需要理解什么是調用棧以及它在調試時應如何使用。
應用程序代碼主要使用堆棧來進行參數傳遞、保存局部變量和保存返回地址。每個函數壓入堆棧的數據都被組織為一個“堆棧幀”,當調試器停止處理器時,它可以分析堆棧中的數據,為程序員提供“調用棧”,這是從最頂層函數調用到當前子函數之間每一層級的調用關系,它可以在調試時讓用戶非常方便地了解整個調用路徑,了解為何程序會運行到當前的位置。
為了能夠重建調用棧,調試器必須能夠確定堆棧的哪些項包含了返回地址的信息。如果編譯的時候包含的話,這些信息一般會存在于“調試器信息”(DWARF調試表)中,或者從一個由程序壓入堆棧的“幀指針”鏈表獲得。當然,代碼必須使用幀指針。如果這兩種類型的信息都沒有,那么這個調用棧無法被重建。
在多線程任務應用中,每個線程都有自己的堆棧,因此調用棧的信息也只和它對應的線程相關。
(2)單步執行
Candidates must understand what single stepping is and how it may be used in debugging. They should understand the difference between Step-In and Step-Over when single-stepping.
考生需要理解什么是單步執行以及如何在調試中應用,它需要理解在單步執行時Step-In和Step-Over的區別。
單步執行指的是調試時調試器可以控制執行部分代碼,每一次執行一條指令。Step-In和Step-Over的區別可以從函數調用中理解。當采用Step-Over來調試函數時,整個函數會作為一步來執行,讓程序員可以直接執行整個函數而不需要進入函數里面去單步執行。Step-In表示進入函數里面去單步執行函數體。
(3)開始/停止
Candidates must understand what start/stop debugging is and how it may be used.
考生需要理解什么是開始/停止調試以及如何使用它。
開始的含義就是按下調試器的“開始”按鈕,處理器退出調試狀態并重新進入正常執行狀態(從當前的程序指針處開始執行),直到程序遇到某個讓它停止的因素為止,這些因素通常是一個斷點、觀察點或者捕捉向量事件或者是從外部調試器及其他系統阻塞所產生的調試請求。
開始/停止的調試模式與不能停止代碼執行的調試的系統形成鮮明的對照。在一些嵌入式系統中(如汽車引擎控制系統),在進行系統調試時是不能簡單地讓處理器停止執行的。
(4)打印printf
Candidates must understand how printf may be used in code instrumentation (they may also be expected to understand what other kinds of instrumentation might typically be used).
考生需要理解如何在代碼儀器化中使用printf(還需要理解其他可用的儀器化函數)。
這是一個最基本的調試技術,通常在所有的處理器架構中使用,用于在代碼中插入指令來輸出一些數據,例如來顯示程序的指令流或者某一時刻一些關鍵變量的值。
(5)裸機代碼和應用代碼
Candidates should be aware of the difference in debug options between applications running on OS-based or bare metal system (e.g. Ethernet, GDB server, ICE).
Example: Candidates should know that it is necessary to run a server program on the target system in order to debug an OS-based application.
考生需要了解基于操作系統的應用層軟件調試和基于裸機代碼的系統調試方法的差別(如以太網、GDBServer、ICE)。
例如,考生需要知道在目標板上調試一個基于操作系統的應用程序必須運行一個調試服務程序。
在30.4節介紹了這方面的內容。
(6)RAM/ROM調試
Candidates should be aware of the limitations of debugging code running in different types of memory (e.g. breakpoints and image load).
Example: Candidates should know that it is not possible to set an unlimited number of breakpoints when executing code in ROM. More advanced candidates would understand why this is the case.
考生需要了解在不同類型的存儲空間中進行代碼調試的限制。
例如,考生應該知道調試在ROM中執行的代碼時是不能設置無限量的斷點的,更深入的了解應該知道為什么如此。
軟件斷點只能設置在RAM中,因為RAM是可寫的空間。調試ROM中的代碼的另一個通常的限制是很難修改代碼來修改錯誤的部分。
(7)調試時序相關問題
Candidates should be aware that certain debug approaches may affect the timing of the code (e.g. halt mode) and be aware of non-invasive alternatives (e.g. trace).
考生需要了解某些調試方法可能會影響代碼的時序(如暫停模式)并了解其他非侵入式的調試方法(如跟蹤)。
(8)使用調試器調試軟件的影響(系統可能會被更改狀態)
Candidates should be aware of the implications/impact of debugging (e.g. reading memory locations).
考生需要了解調試的含義和影響(如讀取內存位置)。
1.3.3 架構
本節主要討論指令集架構。
1.指令集
(1)LDREX/STREXCLEX
Candidates should be aware of how these instructions work and how they might be used to implement software synchronization (e.g. mutex). At this level candidates should be able to recognize a simple mutex implementation (in assembler) and be able to explain its operation. They will not be expected to write one.
Example: Candidates should be aware of what a mutex is. More advanced candidates will be aware of the exclusive access instructions which are used to implement mutexes and similar constructs.
考生需要了解這些指令如何工作,如何用于軟件的同步(如互斥);應該能夠識別一個互斥的應用(在匯編代碼中)并能解釋它們的作用,但不需要考生自己編寫一個此類代碼應用。
例如,考生需要理解什么是互斥。更高級的考試需要了解用來實現互斥或類似操作的獨占訪問指令。
獨占訪問和互斥在23.4節和24.4節介紹,考生需要花時間來熟悉例子23-1中的代碼并理解它的操作。
(2)DMB/DSB/ISB
Candidates must understand the features of a weakly ordered memory system and recognize when manual ordering is required. Candidates must also know how to achieve required access ordering using the ARM barrier instructions. They should be able to insert suitable barrier instructions in simple code sequences where particular ordering is required.
Examples: Candidates should know that ARM systems implement a weakly-ordered memory model and that this means barriers are required to enforce ordering in some circumstances. More advanced candidates will know what these instructions are and how to use them in simple code sequences.
考生需要理解弱排序內存系統訪問的特性以及知道什么時候需要手動排序;還必須要知道如何通過ARM的隔離指令實現所需要的內存訪問順序,當需要特定的順序時,應該能夠在簡單的代碼序列中插入恰當的隔離指令。
例如,考生需要知道ARM系統采用的弱排序內存模型并且意味著在某些特殊場合需要用隔離來強制訪問順序。更高級別的考試需要了解這些隔離指令是什么,以及如何使用它們。
在第12章詳細介紹了ARM內存系統順序模型以及隔離的使用,考生需要特別關注這些才能理解DSB和DMB的區別以及12.2節中給出的應用例子。如果可能的話,考生應該在實際的應用例子中尋找一個使用隔離指令的應用。例如,如果一個中斷源可以被通過訪問映射到內存空間的外設寄存器來清除的話,就可能有必要使用隔離指令來強制確保這個清除操作完全執行完畢,再進行后續的指令,如重新使能中斷。但如果沒有這個隔離指令的話,可能會產生虛假的中斷。
(3)VFP
考生不需要掌握此方面知識。
(4)NEON
考生不需要掌握此方面知識。
(5)Exception異常入口/出口
Candidates must be able to describe the exception entry sequence of an ARM processor. They must understand and describe the state of the processor on entry to an exception (e.g. PC, LR, CPSR, SPSR etc). Candidates must also be familiar with the standard exception return instructions (not including ERET) and return address adjustments for each exception type.
Example: Candidates should know what operations the core undertakes automatically on processing an exception. More advanced candidates will know the standard exception return instructions for each exception type.
考生必須能描述ARM處理器的異常入口序列,必須理解并能描述處理器在一個異常入口的狀態(如PC、LR、CPSR、SPSR等寄存器),還必須熟悉異常返回的標準指令(不包括ERET)以及對每種異常類型的返回地址的調整。
例如,考生應該知道在處理一個異常時哪些操作是內核自動處理的。更高級別的考試需要知道每個異常類型的標準返回指令。
這些內容將在第13~15章介紹
(6)PSR操作指令
Candidates must know the instructions that allow manual control of the PSRs, which bits may and may not be modified in unprivileged mode.
Example: Candidates should know the instructions which may be used to modify the PSR. More advanced candidates will know how to use these instructions and what their limitations are.
考生必須知道手動控制PSR寄存器的標準指令,以及在非特權級別模式下寄存器的哪些位可以或不可以修改。
例如,考生應該知道用來修改PSR寄存器的指令。更高級別的考試需要了解如何使用這些指令以及它們的限制。
PSR寄存器將在5.3節介紹。在用戶模式(非特權模式)下,程序不能修改PSR的用來控制處理器模式的[4:0]位,以及用來管理異常的使能/禁止的A、I和F位。
(7)WFI、WFE、SEV
Candidates should be aware of the ARM hint instructions for entering low power states, what a typical implementation does on executing such an instruction and when they might be used. Candidates should also have knowledge of wakeup conditions from each low power state.
Example: Candidates must be aware of the WFI instruction and that it may not actually do anything. More advanced candidates will be aware also of WFE and of the conditions which cause wakeup from standby mode.
考生應該知道ARM用來進入低功耗模式的隱藏指令、執行這些指令的典型操作以及何時使用它們,還應該了解從每種低功耗狀態下喚醒的條件。
例如,考生必須了解WFI指令以及它可能實際并不做任何動作。更高級別的考試需要了解WFE指令以及從休眠模式下喚醒的條件。
這部分知識將在第26章介紹(在12.2.3節中也有描述)。
(8)通用指令集
Candidates must have a good knowledge of the syntax and semantics of ARM and Thumb data processing, branch and load/store instructions. They should be able to recognise and interpret such instructions, and be able to match fragments of C code with their corresponding fragments of assembler code.
Example: Candidates will be familiar with the core instruction set, including operand order, basic syntax and addressing modes. More advanced candidates will be able to map instructions onto C code, including knowledge of literal pools, loop structures, register spilling and simple compiler transformations.
考生必須非常熟悉ARM和Thumb指令的語法和語義,包括數據處理指令、分支指令和加載/存儲指令,應該能夠識別并解釋這些指令,并且能為C語言代碼編寫合適的匯編代碼。
例如,考生需要熟悉內核指令集,包括操作數順序、基本語法和尋址方式。更高級別的考試要能夠將指令映射到C代碼,包括代碼中的文字池概念、循環結構、寄存器溢出和簡單的編譯轉換。
第6~7章介紹了ARM的匯編語言。考生還可以參考DS-5編譯器工具的“ARM匯編編譯工具鏈”文檔,這個文檔可以從ARM網站下載。在網絡上和已出版的相關圖書中還有很多介紹ARM匯編語言的輔導資料。
強烈建議考生通過編寫匯編語言代碼并觀察編譯器的輸出C代碼來獲得實際應用經驗。
對于在考試大綱中提到的文字池的概念,第一次提到是在7.1.1節,它主要是用來表示常數,寄存器泄漏在18.1節介紹,20.3節給出了一些循環結構和編譯器轉換的例子。
2.電源模式
(1)待機,休眠,關機
Candidates must know the architectural power modes, and understand the progression between these power modes. Candidates are not expected to know the power domains or power-saving features of specific processors or implementations.
Example: Candidates will know that there are different sleep modes and be able to rank them in order of power saving. More advanced candidates will be aware of the progression between these modes.
考生必須了解電源模式的架構并理解這些電源模式的關聯,不需要知道特定處理器的電源域或省電特性的實現。
例如,考生要知道有不同的睡眠模式而且能從省電角度來分出級別。更高級別的考試要能理解這些模式的關聯。
請參考第26章。
(2)入口/出口
Candidates should be aware of the software requirements for entering and exiting power saving modes (e.g. they should know what state must be preserved and be aware of how this is done).
Example: Candidates will k now about the WFI instruction and when it might be used. More advanced candidates will know what state must be preserved on entry to power saving modes.
考生需要了解進入和退出省電模式的軟件需求(例如要知道什么狀態必須保存,而且應當知道如何做到)。
例如,考生要了解WFI指令并知道何時使用。更高級別的考試要了解進入省電模式時要保存哪些狀態。
請參考第26章。
3.內存模型
(1)訪問順序
Candidates must understand the characteristics of a weakly ordered memory system as used by ARM processors. They should be able to recognize examples of access patterns which could and could not be re-ordered by a processor.
Example: Candidates will know that ARM supports a weakly-ordered memory model and what this means when writing software. More advanced candidates will be able to recognize and analyze access patterns from fragments of code.
考生必須理解ARM處理器使用的弱排序內存系統的特性,應該能識別可以或不可以重排序的訪問模式。
例如,考生需要知道ARM支持的是弱排序內存模型以及在編寫代碼時意味著什么。更高級別的考試需要能識別并分析代碼片中的訪問模式。
請參考第12章。
(2)內存類型(如普通、設備、嚴格排序)
Candidates must know the three memory types defined by the ARM architecture. They should understand the characteristics of each, what they are used for and the ordering requirements which result.
Example: Candidates must know the three memory types defined by the ARM architecture and that peripherals should be classed as Device memory. More advanced candidates will know the characteristics and typical use of each memory type.
考生必須知道ARM架構定義的這三種內存類型,應該理解每種內存類型的特性、用于什么場合以及產生的排序結果。
例如,考生必須了解這三種ARM架構的內存類型,外設必須歸類為設備類空間。更高級別的考試需要知道每種內存類型的特點以及典型應用。
請參考第12章。
(3)VMSA
① 轉換表格式
對這部分不做要求。
② 轉換表位置
對這部分不做要求。
③ TLB
Candidates should be aware of the existence, location and purpose of TLBs. They should be aware of circumstances which require TLB maintenance operations.
Example: Candidates must know the purpose of TLBs. More advanced candidates will know that TLB maintenance operations are required and when these must be carried out.
考生應該了解TLB的存在、位置及目的,需要了解什么情況需要使用TLB。
例如,考生必須知道TLB的目的是什么。更高級別考試要了解TLB運行所需的操作以及何時使用。
轉換查找緩沖區(TLB)在11.4節介紹。使用操作則在10.5節介紹。
④ OS支持(如ASID)
對這部分內容不做要求。
⑤ 地址轉換
Candidates must have an awareness of virtual to physical memory translation, why it is necessary and how it is used by Operating Systems. They should be aware of where the MMU is located in the memory system hierarchy. They should be aware of which cores have virtual memory capability and which do not.
At this level, knowledge of page table and descriptor formats is not required.
Example: Candidates must know what virtual-physical address translation is and what it is used for in an Operating System environment. More advanced candidates will be aware of how Operating Systems use the MMU to achieve this and may be aware of multi-level translation tables.
考生必須理解虛擬內存到物理內存的轉換及其必要性,以及操作系統如何使用這種轉換,應該理解MMU在內存系統架構中所處的位置,還需要了解哪些內核有虛擬內存、哪些沒有。
在初級認證的難度下,對頁表和描述符格式的知識不做要求。
例如,考生必須知道虛擬地址到物理地址的轉換以及它為何要在操作系統中使用。更高級別的考試需要了解操作系統如何使用MMU來實現這種轉換并了解多級轉換表。
第11章詳細介紹了MMU內存管理單元,MMU是L1存儲系統的一部分,因此需要熟悉第10、12章的內容,以便更好地理解MMU的工作。
考生應該嘗試實際編程應用MMU,這并非意味著新建一個頁表。例如,考生可以運行系統,觀察使能MMU和禁止MMU,無地址轉換發生并且所有的數據內存訪問被視為強順序訪問,因此數據緩存是未使用的。CP15的SCTLR寄存器的M位用于使能或者禁止MMU。
(4)PMSA
Candidates should have an awareness of the features of the PMSA and what it can be used for. They should know which cores have MPUs and which do not. They should be aware of the limitations of a MPU as compared to an MMU.
Example: Candidates should know that an MPU can be used to partition and protect memory regions. More advanced candidates will know the number and usage of these regions.
考生應該理解PMSA的特性及其用途,應該知道哪些內核有MPU、哪些沒有,應該理解使用MPU相比MMU的限制。
例如,考生應該知道MPU是用來分開并保護內存區域的。更高級的考試需要知道這些區域的數量以及使用。
本書沒有介紹這方面的內容,因為MPU是與Cortex-R/M系列相關的。
在不需要MMU的系統中,ARM提供了MPU,它并不為虛擬地址提供地址轉換功能,但可與L1內存系統工作來控制訪問L1和外部存儲空間。MPU可以將內存分為不同的區域并設置獨立的內存屬性(普通/設備/強排序、可緩存屬性等)以及每個區域的保護屬性。MPU通常支持小的、固定數量(如8或12)的內存分區。
每個分區均配置了自己的基地址和大小,而且分區可以重疊以滿足內存映射的編程效率。為了支持重疊,分區都分配了優先級。當訪問地址位于區域中時,MPU會返回優先級最高的區域屬性和訪問許可。
(5)Alignment對齊
Candidates must have good knowledge of the data and instruction alignment requirements of the ARM architecture and be aware of the consequences of misalignment in systems with and without an MMU.
Example: Candidates will know the basic code and data alignment restrictions. More advanced candidates will be aware of specific cases (e.g. LDREX, LDRD, VFP) and of the consequences of violating alignment rules.
考生必須清楚ARM架構中數據和指令對齊的要求并了解有MMU和無MMU情況下非對齊的系統影響。
例如,考生需要知道代碼和數據對齊額基本限制。更高級別的考試需要理解一些特殊情況(如LDREX、LDRD、VFP)以及違反對齊規則的影響。
請參考17.2節。考生應該熟悉上面提到的幾種情況的特殊對齊規則(加載和存儲獨占指令、加載和存儲雙精度與浮點指令),可以參考ARM架構參考手冊(ARM)或其他匯編文檔。
(6)Endianness
Candidates must know what endianness means. They should know the two endian models supported by the ARMv7 architecture. Knowledge of endianness support prior to ARMv7 is not required.
Example: Candidates should know what endianness is and that ARM supports both big-endian and little-endian models. More advanced candidates would know that endianness can be changed at runtime and how to use this feature.
考生必須知道endianness的含義,應該知道ARMv7架構支持兩種endian模型。ARMv7架構之前的架構所支持endian的知識不做要求。
例如,考生應該知道什么是endianess以及ARM同時支持的big-endian(大端)和little-endian(小端)模型。更高級別的考試要了解endianness可以在運行時調整并且如何使用這種特性。
請參考17.1節
(7)屬性(如可共享屬性,可執行屬性)
Candidates must know the memory attributes available in ARMv7, (e.g. executability) and understand when and how to apply them in real-world examples.
Example: Candidates should know and understand the read-write and execute permissions. More advanced candidates will know about shareability and how and when to use it.
考生必須知道ARMv7架構的內存屬性(如可執行)并理解何時以及如何在真實的應用中使用。
例如,考生應該知道并理解讀寫和執行權限。更高級別的考試要要知道共享屬性以及何時、如何使用。
這部分內容將在11.7節和第12章介紹。
本書并沒有介紹在頁表中設置的一個重要的屬性——XN位(永不執行)。當置位時,它可以禁止從該存儲區域的預測取指操作(對外設空間很有用)并產生一個取指中止的異常,表示不應該從該內存地址取指(這對于捕獲無效的函數調用產生的問題很有用)。
(8)緩存
Candidates must understand the ARMv7 cache hierarchy (e.g. levels of cache, Harvard vs. unified). Candidate must know the available cache maintenance operations (e.g.Clean, Invalidate) and understand when they are required. Detailed knowledge of the instructions used to carry out these operations, nor how to address individual cache lines, is not required.
Example: Candidates should know caches exist, that they are in a hierarchy, that some are unified while others are Harvard. More advanced candidates will know that maintenance operations are required, what these operations are and in what circumstances they would be used.
考生必須理解ARMv7架構的緩存層級(如緩存的級別,哈弗結構與統一結構),必須知道一些對緩存的操作(如清空、使失效)并理解何時使用,但不需要了解這些詳細的操作指令以及如何尋址失效的緩存行。
例如,考生應該知道緩存如何存在,它們的層級關系,其中一些是統一結構的,而另一些是哈弗結構。更高級別考試要了解緩存需要一些維護操作,這些操作是什么以及何種情況下使用。
第10章詳細介紹緩存架構。考生應該了解一些實際的應用緩存的經驗,例如,可以驗證在關閉緩存時系統的性能顯著下降。
4.寄存器
(1)VFP
Candidates should be aware that VFP supports a separate register bank. They should be aware of the number and size of these registers. Detailed knowledge of floating point operating and number formats is not required.
Example: Candidates must know that VFP uses a separate register bank. More advanced candidates will know the size, format and behavior of these registers.
考生應該了解VFP擁有一個獨立的寄存器表,應了解這些寄存器的數量和大小。關于浮點運算和浮點格式的詳細知識不做要求。
例如,考生必須知道VFP使用一個獨立的寄存器表。更高級別的考試需要知道大小,格式和這些寄存器的行為。
第8章介紹了ARM的浮點單元。
NEON和VFPv3使用同一寄存器表。這是與ARM的寄存器表獨立的。在VFPv3中,可以看到這些寄存器表有32個64位雙精度寄存器(D0~D31),以及32個32位單字寄存器(S0~S31,在這種情況下只有一半的寄存器)或者這些寄存器的組合。在VFPv2和VFPv-D16中,提供了更少數量的雙精度寄存器(D0~D15)。
(2)NEON
Candidates should be aware that NEON supports a separate register bank. They should know how this overlaps with the VFP registers. Detailed knowledge of NEON operations and instructions is not required.
Example: Candidates must know that NEON uses a separate register bank. More advanced candidates will know the size, format and behavior of these registers.
考生應該了解NEON采用獨立的寄存器表以及這些寄存器是如何與VFP的寄存器重疊的,NEON的詳細操作和指令不做要求。
例如,考生必須知道NEON使用獨立的寄存器表。更高級別的考試需要知道這些寄存器的大小、格式以及它們的行為。
第9章介紹NEON,更高級別的考試還需要參考第21章。
(3)ARM
Candidates must have detailed knowledge of the ARM general purpose registers (R0- R15), including any with special significance/use (e.g. R15 = PC). They should know which are banked between modes.
考生必須了解ARM通用寄存器的知識(R0~R15),包括特殊用途的寄存器(如R15 =PC),還需要了解寄存器在不同模式下存在的分組空間。
請參考5.3節。
(4)系統控制寄存器(如CP14、CP15)
Candidates should be aware that system control registers are accessed via CP15 and debug registers via CP14. Although detailed knowledge is not required, they should be aware of what features are available in VMSA and PMSA processors.
Example: Candidates must know that CP15 is used for system control and CP14 for debug. More advanced candidates will know some detail on specific registers.
考生應該了解如何通過CP15來訪問系統控制寄存器、通過CP14來訪問調試寄存器。雖然對詳細的知識不做要求,但應該了解VMSA和PMSA處理器的特性。
例如,考生必須知道CP15是用來訪問系統控制的,CP14是用來訪問調試的。更高級別的考試要了解一些特殊寄存器的細節。
這些內容在7.8.1節中有介紹,此外在全書中均介紹了一些特殊寄存器。
5.版本
(1)ARM架構
Candidates must have a high-level knowledge of the evolution of the ARM architecture between ARMv4T and ARMv7-AR. Candidates should be able to identify which architectural features are available in which versions. They should be able to match processors with the architecture to which they conform. Candidates should be aware of what is defined by the architecture (e.g. programmer' s model) and what by the implementation (e.g. pipeline structure).
考生需要深入了解ARM架構中ARMv4T和ARMv7-AR的演變,能識別哪種架構特性在哪個版本中,能夠識別處理器屬于哪種架構,應該了解架構定義了哪些內容(如編程模型)以及實現了哪些功能(如流水線架構)。
請參考3.1節。
(2)VFP架構
Candidates should be aware of the major differences between the VFPv3 and VFPv4.
Candidates should also be aware of differences between the D16 and D32 variants (i.e. number of registers). Detailed knowledge of VFP function or number format is not required.
考生必須了解VFPv3和VFPv4的主要區別,了解D16和D32模式的區別(如寄存器的數量)。VFP功能和數據格式的詳細知識不做要求。
這部分內容在第3章介紹,包含D16和D32模式的雙精度寄存器數量的區別。在D16模式中,有16個雙精度寄存器,也可以變成32個單精度寄存器;在D32模式中,有32個雙精度寄存器(D0~D31)。在Cortex-A5、A7以及A15處理器中支持VFPv4架構的擴展,它在VFPv的基礎上擴展了混合乘累加操作和半精度格式轉換。
(3)NEON架構
Candidates should be aware of the major differences between versions 1 and 2 of the advanced SIMD extensions. They should also be aware that Advanced SIMD extensions are only available in A class processors. Detailed knowledge of NEON instruction behavior is not required.
考生應該了解高級SIMD擴展的版本1和版本2的主要區別,了解高級SIMD擴展只存在于Cortex-A系列處理器。NEON指令詳細的知識要求。
請參考第3章。
(4)兼容性
Candidates must understand the compatibility limitations of code written for the different architecture versions (e.g. ARMv6 code cannot be guaranteed to run on a ARMv5 processor but will run on a ARMv7 processor).
考生應該理解不同架構版本代碼的兼容性限制(如ARMv6代碼不能保證一定可在ARMv5上運行,但可以在ARMv7上運行)。
請參考第3章。
6.異常模型
(1)模式
Candidates must know the names and functions of the seven basic operating modes.
Knowledge of HYP and MON modes is not required. They should know about register banking, including which registers are banked in which modes. They should know which modes are privileged and which are associated with specific types of exception or interrupt.
考生必須知道7種基本操作模式的名字和功能,HYP和MON模式的知識不做要求;此外還需了解寄存器分組,包括哪些寄存器在哪種模式下有分組,應該知道哪種模式是特權模式,以及與特殊類型的異常或中斷相關聯。
請參考第5章。
(2)中斷
Candidates must understand the differences between FIQ and IRQ, including banked registers, placement of FIQ in the vector table, use with an interrupt controller. Candidates should know how to enable and disable FIQ and IRQ via the CPSR.
考生必須理解FIQ和IRQ的區別,包括分組寄存器、FIQ在矢量表中的位置,以及如何使用中斷控制器,應該知道如何通過CPSR使能和禁止FIQ和IRQ。
請參考第13、14章。
(3)中止
① 數據中止
Candidates should know what events can cause a Data Abort exception and what the usual corrective actions are. Knowledge of how to code solutions for these corrective actions is not required. Candidates should be aware of the high-level difference between a synchronous and asynchronous abort.
Example: Candidates must know what events may cause a data abort. More advanced candidates would understand the difference between asynchronous and synchronous aborts.
考生應該知道哪種情況會導致數據中止異常以及如何進行糾正(對這些糾正的代碼方案不做要求),應該從高層級了解同步中止和異步中止的區別。
例如,考生必須知道哪種情形導致數據中止。更高級別考試需要理解同步中止和異步中止的區別。
② 預取指中止
Candidates should know what events can cause a Prefetch Abort exception and what the usual corrective actions are. Knowledge of how to code solutions for these corrective actions is not required. Candidates should know and understand why the Prefetch Abort exception is not taken immediately on receiving the error from the memory system.
考生應該知道哪種情況會產生預取指中止異常以及如何進行修正(關于如何修正的具體代碼方案不需要掌握),需要知道并理解為何預取指異常并不是在接收到內存系統錯誤時立即觸發。
數據中止和預取指中止在第13章和15.1節中有介紹。
本書并沒有介紹更早版本的ARM架構,ARM7TDMI與更早的ARM處理器的一個主要區別是它使用了一個基本更新數據中止模型。更新的ARM設計則使用了一個基本恢復的模型。
基本恢復數據中止模型是指當數據中止異常出現在執行內存訪問指令時,處理器硬件會將基址寄存器的值恢復到執行該指令之前。這可以避免數據中止異常處理程序中由于中止指令可能對特定的基址寄存器進行更新而采取的展開基址寄存器操作。這讓編寫一個可以解決中止和重復執行錯誤指令的異常處理程序變得簡單。
(4)未定義指令
Candidates should know what events can cause an Undefined Instruction exception, how to determine which event has occurred and what the usual corrective actions are for each cause. At this level, knowledge of how to code these solutions is not required.
考生需要知道哪些情形可能觸發未定義指令異常,如何確定哪種情形發生以及每種情況發生時通常正確的處理是什么。在這一級別,正確處理的代碼編寫不要求掌握。
請參考15.2節。
(5)管理員調用
Candidates must know what Supervisor Calls are typically used for, what causes an Supervisor Call exception, how to use the SVC instruction, what happens to the comment field, how to pass parameters to a Supervisor Call exception handler.
Example: Candidates should know what an SVC instruction is used for. More advanced candidates will know how to pass parameters to an SVC handler.
考生必須了解管理員調用的典型用途是什么,哪種情形會觸發管理員調用異常,如何使用SVC指令,備注區有何信息,以及如何向管理員調用異常服務程序傳遞參數。
例如,考生應該了解SVC指令的用途。更高級別的考試應知道如何向異常服務程序傳遞參數。
請參考15.3節。
(6)SMC
Candidates should know that the SMC instruction exists and that it is associated with entry to Mon mode in TrustZone systems. Detailed knowledge of its behavior is not required.
考生應該知道SMC指令并了解在TrustZone系統中它與進入Mon模式相關,該指令詳細的作用不做要求。
請參考27章。
(7)復位
Candidates must know what can cause a system reset (debug, reset pin etc). They should also be aware of configuration options which can be sensed during reset (endianness, vector table location etc).
Example: Candidates must know the behavior and state of the processor on reset. More advanced candidates should know which configuration options can be sensed during reset.
考生必須知道哪些情況會產生系統復位(如調試、復位引腳),還應該了解在復位時的一些配置選項(如endianness、矢量表的位置等)。
例如,考生必須知道處理器在復位時的動作和狀態。更高級別的考試需要知道復位時會檢測哪些配置選項。
第13、16章將介紹復位異常的處理器行為。
在ARM架構中通常也把復位當做一種異常來考慮,盡管考慮它的異常返回毫無意義,復位是系統的起始,而并非可以返回的位置。本書沒有專門列出所有的配置選項,不過HIVECS矢量表的地址在13.5節介紹。在一些處理器中,可能通過類似的樣式支持配置endianness位(或者支持非對齊訪問)。
(8)HVC
對此方面知識不做要求。
(9)入口順序
Candidates must know the actions taken by the core during exception entry, including any modifications made to registers.
考生必須知道內核在進入異常時的動作,包括任何對寄存器的修改。
請參考13.3節。
(10)退出順序
Candidates must know what actions which must be taken in order to return from an exception handler. They should know the standard instructions for returning from each exception type and why these are used in each case.
考生必須知道退出異常處理所需要進行的操作,應該了解從每種異常類型的處理函數中退出的標準指令以及為何要采用。
請參考13.4節。
(11)嵌套/重入
Candidates should be aware that exceptions of different types may be nested easily but that there are issues with return addresses when interrupts are re-entrant. Also that standard good practice is not to make FIQ re-entrant. Detailed knowledge of coding a solution for re-entrant interrupts is not required.
Example: Candidates must know what is meant by a re-entrant interrupt handler and that there are issues with nesting interrupts on ARM systems. More advanced candidates will know what these issues are and be aware of common solutions to them.
考生應該了解不同類型的異常可以很容易地嵌套,但當中斷是可重入時返回地址會有問題,此外標準的好習慣是不要讓FIQ可重入。關于可重入中斷的代碼解決方案的知識不做要求。
例如,考生必須知道什么是可重入中斷服務以及在ARM系統中嵌套中斷的問題。更高級別的考試需要了解這些問題是什么以及通常的解決方法。
請參考14.1.3節。
(12)低延遲中斷模式
對此方面知識不做要求。
(13)中斷矢量表
Candidates should know the two standard locations of the vector table, how these are selected (HIVECS), that the vector table contains instructions not addresses, that RESET is the first entry and FIQ is the last. Knowledge of extra vector tables in systems implementing the Security Extensions is not required.
Example: Candidates must know that the default location for the vector table is at 0x0 and that it contains instructions. More advanced candidates will know that the vector table can be relocated and to where, and will know the layout of the table.
考生應該知道關于矢量表的兩個標準位置,如何進行選擇(HIVECS),矢量表中包含的是指令而非地址,以及復位是矢量表的第一個元素,而FIQ是最后一個。關于系統配備的安全擴展部分的額外的矢量表知識不做要求。
例如,考生必須知道矢量表缺省的地址是0x0,它的元素是指令。更高級別的考試要知道矢量表可以重定位到哪里,并知道表的格式。
請參考13.5節。
7.安全擴展
(1)安全監控
Candidates should know that a Secure Monitor is used for handling the transition between Secure and Normal worlds. They should have a general understanding of how monitor mode is used to achieve this. Detailed knowledge of its internal function is not required.
考生應該知道安全監控是用來處理安全模式和普通模式的切換的,應該對如何使用安全模式來實現有一個通常的認識。關于它內部的功能的知識不做要求。
(2)安全異常
對此方面知識不做要求。
(3)安全內存
Candidates should be aware that, in a TrustZone system, areas of memory can be made Secure as the S/NS information is propagated on the external bus. They should understand why this is useful.
考生應該了解在TrustZone系統中,內存的區域可以配置為安全內存,S/NS信息可在外部總線上傳遞,應該理解為什么這個功能很有用。
請參考第27章。
(4)虛擬化擴展
對此方面知識不做要求。
1.3.4 軟件開發
1.同步(如互斥、信號量、互鎖)
Candidates should be aware of the need for this kind of construct and be able to insert them in example code sequences. They should be able to read and understand synchronization functions which use LDREX/STREX. They should understand that memory barriers are sometimes required to ensure correct and efficient operation.
考生應該了解這類同步結構的需求以及能夠在例程中添加它們,應該能使用LDREX/STREX來進行同步的函數,還應該能夠在需要的時候使用內存隔離來確保正確高效的操作。
請參考23.4節。
2.內存管理
(1)緩存維護
Candidates should be aware that operations are required to maintain coherency between contents of cache and main memory. They should understand the terms “flush”, “clean” and“invalidate”. They should know that these operations are achieved via CP15 but detailed knowledge of instructions used to achieve these operations is not required.
考生應該了解保持緩存內容和主存儲器內容一致需要一定的維護操作,理解沖刷、清空、使失效等術語的含義,應該知道這些維護操作是通過CP15來實現的,但關于實現這些操作的具體指令的知識不做要求。
請參考10.8節。
(2)隔離
Candidates must know what ISB, DSB and DMB instructions do. They should also be able to determine where these instructions are required in typical use cases.
考生必須知道ISB、DSB和DMB指令的具體功能是什么,還應該知道這些指令分別適用于哪種情形。
請參考12.2節。
3.操作系統架構
(1)SMP和AMP
Candidates should be aware of the principal differences between SMP and AMP systems. Given examples, they should be able to differentiate between them.
Example: Candidates must know what is meant by SMP. More advanced candidates will also understand AMP and be able to differentiate between the two.
考生應該了解SMP和AMP系統原理上的區別,能區分這兩種系統。
例如,考生必須知道SMP是什么意思。更高級別的考試還需要理解AMP以及他們兩個之間的區別。
請參考第22章。
(2)線程,任務和過程
Candidates should be aware of the meaning of these terms in SMP and AMP systems.
Example: Candidates must know what these terms mean. More advanced candidates will know specifics of how some Operating Systems treat them.
考生應該了解SMP和AMP系統中線程、任務和過程的術語的含義。
例如,考生必須知道這些術語的含義。更高級別的考試要知道特定的操作系統中它們的特定含義。
請參考22.2節。
(3)內核與用戶空間
Candidates should be aware that Operating Systems partition memory into Kernel (privileged) and User (non-privileged) regions. They should know that this is configured via the MMU. They should understand that a transition to privileged mode is required to access Kernel space and that this is usually achieved via an exception. They should be aware of typical operations (e.g. memory map maintenance, exception handling) which must be carried out in a privileged mode.
Example: Candidates must know that different privilege levels exist in an Operating System environment. More advanced candidates will know how Operating Systems partition memory and how user programs gain access to privileged operations.
考生應該了解操作系統一般把內存分為內核(特權級別)和用戶(非特權級別)兩個區域,知道這是通過MMU來配置的,還應該理解要訪問內核空間需要內核轉換到特權模式,并且都是通過產生異常調用來實現的,應該了解在特權模式下的典型操作(如內存映射維護、異常處理)。
例如,考生必須知道在一個操作系統環境中存在不同的特權級別。更高級別的考試需要知道操作系統是如何分配內存以及用戶編程如何獲得特權級別的。
特權級別的概念將在第5章介紹,此外還將介紹相關的特權模式的異常處理。內核的內存管理相關概念在第11章介紹。更高級別的考試可以從Linux中syscall的使用來理解用戶程序如何獲得特權操作(如閱讀syscall man的內容)。
(4)BSP
Candidates should be aware that some level of board/device-specific code is usually required by an operating system, and this is usually referred to as a Board Support Package (BSP).
考生應該了解操作系統通常需要一定級別的板級/針對設備的代碼,這通常稱為板級支持包。
板級支持包的概念在4.1.4節介紹。
4.啟動
(1)多處理器啟動
對此方面知識不做要求。
(2)使能VFP和NEON
對此方面知識不做要求。
(3)從RAM啟動
對此方面知識不做要求。
(4)從ROM啟動
對此方面知識不做要求。
(5)從TCM啟動
對此方面知識不做要求。
(6)初始化堆棧指針
對此方面知識不做要求。
(7)放置中斷矢量表
對此方面知識不做要求。
(8)占用中斷矢量表
對此方面知識不做要求。
(9)外設配置
對此方面知識不做要求。
(10)緩存初始化(如TLB轉換表、分支預測)
對此方面知識不做要求。
(11)MMU/MPU初始化
對此方面知識不做要求。
(12)安全啟動
對此方面知識不做要求。
(13)特性詢問
對此方面知識不做要求。
5.ABI
(1)AAPCS、ARM架構過程調用標準
Candidates should be familiar with the AAPCS rules in respect of register usage, parameter passing and result return, stack alignment and register preservation.
Example: Candidates must be aware of the AAPCS register usage rules and the requirement for stack alignment. More advanced candidates will know how parameters are mapped to registers and stack.
考生應該熟悉AAPCS在寄存器使用方面的規則、數傳遞和返回規則、棧對齊和寄存器保存規則。
例如,必須知道AAPCS的寄存器使用規則和對堆棧對齊的要求。更高級別的考試需要知道參數如何保存在寄存器和堆棧中。
ARM架構過程調用標準(AAPCS)在第18章介紹。重要的是,理解ARM架構中的變量聲明的大小可能和其他架構有所不同(int是32位,short是16位,char是8位,雙精度浮點是64位),且局部變量可能保存在寄存器中(如果當前使用的局部變量的數量不是太多)或者在堆棧中。
(2)硬/軟鏈接
Candidates should be familiar with the concepts of hard and soft linkage in procedure calls with respect to floating point. Given examples, candidates should be able to differentiate between the two. They should be able to explain why this matters.
This is covered in the Cortex-A Series Programmer' s Guide 18.1.2, although familiarity with Chapter 7 and Cortex-A Series Programmer' s Guide 18.1.1 is assumed.
考生應該熟悉在浮點處理的過程調用中硬鏈接和軟鏈接的概念,應該能夠區分兩者,能夠解釋為什么這很重要。
這部分在18.1.2節中介紹,在第8章和18.1.1節也有提及。
浮點運算可能使用硬件協處理器指令或者庫函數,而浮點數鏈接則涉及浮點變量的函數之間傳遞參數。
軟浮點鏈接是指函數的傳遞參數和返回值使用ARM的整數寄存器R0~R3及堆棧,硬浮點鏈接則使用VFP協處理器的寄存器來傳遞參數和返回值。使用軟浮點鏈接的好處在于代碼可以在沒有VFP協處理器的內核上編譯鏈接執行,這一點對于要編譯一個可以同時在有浮點協處理器和無浮點協處理器上運行的函數庫來說非常重要。使用硬浮點鏈接的好處是它比軟浮點鏈接效率更高,但它只能運行在有浮點協處理器的系統上,而且所有的目標代碼/函數庫都必須編譯成使用硬浮點鏈接。
(3)堆棧對齊(異常處理入口)
對此方面知識不做要求。
6.編譯器
(1)自動矢量化
Candidates must know what vectorization is and that the compiler can do this automatically. They should be aware of what properties of a loop make this easier and more efficient for the compiler. They should know that certain combinations of compiler options may be required to enable this feature.
Example: Candidates must know what vectorization is. More advanced candidates will know how to write code and configure the compiler in order to facilitate this.
考生必須知道什么是矢量化以及編譯器可以自動進行矢量化,了解循環的什么性能可以使得編譯器的矢量化更容易以及效率更高,知道使能這種特性,必須會使用編譯器的一些組合選項。
例如,考生必須知道什么是矢量化。更高級別的考試要了解如何編寫代碼以及配置編譯器來實現這一特性。
在21.1.1節介紹了矢量化。編譯器可以自動對源代碼進行矢量化。由于C語言并沒有并行特性,可能不得不告訴編譯器在哪里進行這種動作更安全。這將需要用到關鍵字_restrict來保證指針不會尋址內存的重疊區域。
讀者可以不用犧牲代碼在不同平臺或工具鏈上的可移植性就實現這點。
例1.4
http://infocenter.arm.com/help/topic/com.arm.doc.dht0002a/ch01s04s03.html#CACEHEAG鏈接給出了一個簡短的函數,編譯器可以安全地進行矢量化。這是因為編程者使用了關鍵字_restrict來保證指針pa和pb不會尋址到重疊的存儲空間。
同樣必要告訴編譯器的是對于一個for循環來說(如下面類似的例子),對n的最低2位做屏蔽,將產生一系列乘4的迭代。
for(i = 0; i < ( n & ~3); i++)
兩種編譯器所必要的語法不同;在GCC編譯器中必須加上“-mfpu=neon”以及“-ftree-vectorize”。而在一些工具鏈版本中,還必須加入“-mfloat-abi=softfp”來聲明NEON變量必須在通用寄存器中傳遞。對于ARM編譯器,讀者必須指定包含NEON技術的目標處理器,編譯器的優化等級大于等于“-O2”,以及增加“-0time”和“-vectorize”到編譯命令行中。
(2)內部函數
Candidates should know what an intrinsic function is and why they are to be preferred to writing native assembly code. They should be aware that a large number of intrinsics are supported by the C compiler and be able to explain what certain example functions do.
Example: Candidates must know what is in intrinsic function and that the C compiler supports a large number of them. More advanced candidates will know how to use some of these functions.
考生應該知道什么是內部函數以及為何傾向于用匯編代碼來實現它們,了解C編譯器提供了大量的內部函數并能解釋這些函數的作用。
例如,考生必須知道內部函數中有什么以及C編譯器支持大量的函數。更高級別的考試要了解如何使用其中一些函數。
NEON的內部函數在21.1.3節介紹,其他的函數(如隔離和信號指令)在其他章節(如12.2節)。內部函數通常都使用無對應C語言操作符的ARM匯編語言函數。這樣要么可以得到系統級的特性,要么可以更高效率地實現算法(如NEON的函數)。
(3)編譯選項
Candidates should be aware of: Space/time optimization; Optimization level; C90/c99/cpp;Architecture/CPU specification.
考生需要了解時間/空間優化、優化等級、C90/c99/cpp、架構/CPU特定規格。
考生應該熟悉所使用的編譯器中這些相關編譯選項。GCC優化選項(如-O1, -O2)在20.1.5節介紹。-arch和-cpu的選項在兩種編譯選項中類似。在gcc中,一個特定的選項是“-std=c90”,而在armcc中,對應的選項是“-c90”或者“-c99”。
(4)ARM/Thumb狀態
Candidates should know that it is possible to configure a compiler for ARM or Thumb compilation. They should be able to make sensible suggestions for when to use each instruction set.
Example: Candidates must know that it is possible to compile for ARM or Thumb. More advanced candidates will be able to make suggestions as to when each option is appropriate.
考生應該知道可以配置編譯器的ARM或Thumb編譯,能清晰地指出何時采用哪種指令集。
例如,考生必須知道可以編譯ARM或者Thumb。更高級別的考試應該能夠知道恰當的使用每種指令集。
這一部分內容并沒有在本書中系統地說明,對于Cortex-A系列處理器來說,通常優先使用Thumb指令集的Thumb2擴展,而對于Cortex-M系列處理器則只支持Thumb指令集。
在較早的ARM處理器中,系統通常包含編譯成ARM狀態的代碼和編譯成Thumb狀態的代碼。32位ARM指令的功能更強,且實現特定任務所需的指令數量更少,所以一般用于系統中對性能要求較為苛刻的部分。另外,它還用于異常處理的代碼,因為異常不能在Thumb狀態下處理,如ARM7和ARM9系列處理器。
16位的Thumb指令在處理同樣的任務時,相比ARM指令需要更多數量的指令。Thumb代碼通常可以很容易在指令中編碼較小的常數,因此有較短的相對跳轉分支。這個相對的跳轉分支對于ARM指令來說大約為±32MB的距離,而對于Thumb-2來說則為±16MB的距離。Thumb更限制了只有16位的指令,且條件相對跳轉分支的范圍為±256 B,無條件相對跳轉的范圍限制在±2048 B。
然而,由于Thumb指令只需要一般的空間存儲,整個程序大小比相當的ARM程序減小1/3,因此Thumb指令通常被用于增加代碼密度減小系統容量需求。當處理器直接連接16位存儲空間且沒有緩存的幫助時,Thumb代碼的優勢則更為明顯。一個Thumb指令可以在一個周期內取出,而一個32位的ARM指令則需要2個時鐘周期。
當執行一個Thumb指令時,PC程序指針每次從當前指令位置增加4。僅有的可以直接修改PC指針的16位Thumb指令是MOV和ADD。寫入PC寄存器的值會被強制進行半字對齊,忽略數值的最低位并強制為0。
在ARMCC中,編譯選項“-thumb”或“-arm”(缺省)可以用來選擇編譯器所用的指令集。
(5)交叉編譯和本地編譯
Candidates must know the difference between Cross compilation and Native compilation, and recognize advantages and disadvantages of each.
考生必須知道交叉編譯和本地編譯的區別,并知道它們的優缺點。
4.1.3節介紹了交叉編譯和本地編譯及其優缺點。
7.鏈接器
(1)動態和靜態
Candidates must know the nature of the difference between Static and Dynamic linkage. They should be aware that dynamic linkage is usually used in OS environments while static linkage is used for bare-metal applications.
考生必須知道靜態和動態鏈接的本質區別,了解動態鏈接通常用于操作系統環境,而靜態鏈接常用于裸機程序應用。
在編譯代碼時,工具會把源代碼編成目標代碼模塊,鏈接則把它們組合成可執行的程序。這一鏈接過程可以鏈接不同語言源代碼(如匯編)或者編譯好的庫文件,不過它不一定有源代碼,如果一個文件是靜態鏈接生成的可執行程序,那表明文件的內容就包含在可執行程序中;在動態鏈接中,一個指向目標的指針包含在可執行程序中,但目標文件本身并不包含在其中,而是在程序在線運行時,把所需要的動態鏈接文件放入內存中的程序中。
靜態鏈接文件是在鏈接時固定下來的且不可改變,而程序所調用的動態鏈接文件則可以通過直接修改文件內容而改變,因此改變文件的函數功能不需要通過重新鏈接程序的代碼。
(2)內存布局
Candidates must be aware that they can provide a description of memory layout to a linker, and understand when and why this is necessary. They are not expected to know the format used by a particular tool.
考生必須能夠給鏈接器提供一個內存布局的描述,并理解何時以及為什么要提供,無須知道具體特定工具描述內存布局所使用的格式。
在很多系統中,程序員有必要給鏈接器指定內存系統布局。例如,鏈接器需要知道系統中用來保存變量的RAM的位置以及用來保存可執行代碼的ROM的位置,這些信息可以通過命令行選項或者scatter文件來傳遞給鏈接器。
ELF鏡像文件會包含程序的各段、區域、輸入片和輸出片。輸入片是輸入目標文件的單獨的一個片段,它包含代碼、初始化數據、以及用來描述不需初始化的內存片段或在代碼執行前必須設置為0的片段,這些性質都由諸如RO、RW和ZI等屬性來標明。鏈接器通過這些屬性來把各片段組成更大的塊,即輸出片和區域。一個輸出片是由一系列相同RO、RW或ZI屬性的輸入片被鏈接器放置在一塊連續的內存而構成的,一個區域則是由一系列連續順序的放置在物理存儲空間(通常是ROM或RAM)的輸出片構成的。一個程序段對應于一個加載區域并包含輸出片,程序段包含諸如代碼文本和數據的信息。
輸出片可以是RO(只讀)、RW(可讀寫)或者ZI(初始化為0)的屬性,只讀區域的例子有程序中包含的常數;可讀寫區域的例子有一般的初始值不為0的變量,而這個初始值必須保存在鏡像中,但這個變量需要放置在執行代碼可以改變其值的地方;ZI區域的例子有初始值為0或沒有指定的程序變量。
一個鏡像可以包含一系列的不同區域和輸出片,每個區域可能在內存中有用來存儲的位置和一個不同的用來執行的位置(對于動態加載,或者為了加速代碼執行在啟動階段從ROM復制到RAM)。獨立于位置的代碼或可重定位的代碼是可以在運行時改變執行地址的。
(3)入口點
Candidates should know what constitutes an “entry point”. They should know why it is necessary to define entry points e.g. to indicate to the debugger where execution starts, or to prevent unwanted deletion of unreferenced sections. They should know the various methods of defining these to the linker.
考生應該知道一個入口是由什么構成的,知道定義入口的必要性,例如告訴調試器從哪里開始執行,或者防止對沒有調用的片區的誤刪除,還應該知道鏈接器定義入口的幾種方法。
例如,考生必須知道什么是入口而且鏈接器不能刪除它。更高級別的考試要理解在鏈接時如何定義入口。
入口是鏡像中程序執行的起始位置,鏡像的初始入口是鏡像執行起始的唯一位置。讀者必須為程序指定唯一的初始入口點,否則鏈接器會輸出告警信息。不是所有的源代碼都有入口,一個源代碼文件不允許有多個入口,初始入口點必須位于可執行區域,不能與其他的可執行區域重疊,而且必須是根執行區域(加載地址與執行地址一致)。
可以在匯編代碼中使用“ENTRY”指令來指定多個入口點,在嵌入式系統中,這個指定用來標記處理器異常向量表(如復位、IRQ和FIQ)之后的代碼,可以使用ENTRY關鍵字標記輸出代碼段,這將告訴鏈接器在進行裁剪未使用片段時不要刪除該片段。對于C和C++程序,C庫中的__main()函數是入口點。命令行中“-entry”也可以用來指定初始入口點,例如,“-entry 0x0”可以用于位于0地址的ROM的嵌入式系統。
鏈接器會從鏡像中刪除沒有被使用的數據和代碼段。如果沒有指定入口,那么就無法識別沒有被使用的片段。
(4)軟件浮點庫
Candidates should know that options exist for support of floating point in software.
考生應該知道軟件上存在支持浮點運算的選擇。
請參考第8章。
8.C函數庫
(1)重定向
Candidates should be aware of the concept of semihosting, of why it is important to remove it before producing final code and of how to retarget basic functions in the C library. Exhaustive knowledge of these functions is not required.
考生應該了解半主機的概念,為什么在生成最終代碼前一定要刪除它,以及如何重定向C庫中的基本函數。對這些函數的詳盡了解不做要求。
(2)配置(如棧、堆)
Candidates should be aware of the possible heap and stack configurations (one-region, two region) and how these are configured. Candidates are not required to know precise details of how to achieve this using different tool chains.
Example: Candidates must know that stack and heap occupy separate regions of memory. More advanced candidates would know how to configure this in the final image.
考生應該了解堆和棧有哪些配置(一個區域、兩個區域)以及如何配置,無須知道使用不同工具鏈的詳細配置方法。
例如,考生必須知道棧和堆占用不同的內存區域。更高級別的考試需要知道如何在最終的鏡像中配置這些。
棧是用來保存代碼執行流過程中的臨時數據用的,在ARM處理器,都是支持從特定地址向下生長的棧。堆則是用來動態分配內存的,ARM工具可以支持用在scatter文件中為鏈接器指定區域名稱來配置堆和棧的起始地址,或者通過重定向“__user_initial_stackheap()”或“__user_setup_stackheap()”函數來配置。ARM工具支持兩種類型的堆和棧:在單區域模型中,堆和棧共享一個內存空間,堆從內存空間的底部起始向上增長,而棧從內存空間的頂部向下生長;在雙區域模型中,堆和棧擁有各自獨立的內存空間,這些區域可以位于內存中任何合適的位置,堆仍然在它的區域內向上增長而棧在它的區域內向下增長。
在ARM架構的應用程序二進制接口(ABI)中要求棧在所有的外部接口必須是8字節對齊的,比如在不同源代碼文件的函數之間的調用。然而,在內部調用中則不要求棧是8字節對齊的,比如在葉函數(葉函數是一系列多級函數調用的最底端函數,它不再調用其他函數),這樣會導致當中斷或異常產生時,堆棧可能不是8字節對齊的。
一般通常的棧頂指針都設置在RAM空間的頂點。例如,如果系統的內存地址從0到0x7FFF,那么R13的初始值可以設為0x8000,這意味著從0x7FFC起始的4字節是作為棧的第一個空閑位置。
(3)庫(如裸機程序和操作系統、C函數庫)
Candidates should be aware of the need for standard libraries, and understand that different implementations of the libraries are needed for bare-metal or Operating System environments.
Example: Candidates must know that here are several variants of the standard library. More advanced candidates would know what the differences are between these variants.
考生應該了解標準庫的需要,并理解對于裸機程序或操作系統環境來說標準庫是不相同的。
例如,考生必須知道有不同的標準庫。更高級別的考試要了解這些庫的不同點。
標準C庫是在ANSI規范中為C語言定義的,用來為通常的任務提供諸如輸入/輸出、字符串處理、數學運算以及內存分配等功能函數。
基于不同的原因可能會有不同的實現庫的方法。由于嵌入式系統通常只有很小的內存資源,可能會使用更小版本的庫(如newlib),在這些庫中有的函數被省略,或者只有較少的選項可配置。庫的不同通常都是基于特定的操作系統/編譯器的。
例如,GNU/Linux擁有的是典型的glibc標準庫,嵌入式ARM庫可能使用軟浮點或者硬浮點,可能使用大端或者小端,可能采用ARM狀態或者Thumb狀態。此外,在本章的前面部分介紹過,庫可能與應用程序靜態鏈接或者動態鏈接。
9.目標
(1)模型(如PV和CA)
Candidates must know what types of ARM CPU model are available to them as software developers and be able to recognize advantages and disadvantages of each, as well as the advantages and disadvantages of using them over Development Boards and Final Hardware. They are not required to have knowledge of products from any specific company.
考生必須知道ARM CPU模型為軟件開發者提供了哪些類型,并且知道每種類型的優缺點,以及在開發板和最終硬件平臺上使用它們的優缺點。考生無須了解特定公司的相關產品技術知識。
ARM處理器的模型可以用來在缺少真實硬件的情況下進行軟件開發。這些模型讓系統可以在個人電腦上模擬系統并提供準確的模擬處理器,以及它所連接的內存和外設。這些模型可以提供有用的調試功能,讓開發者在沒有JTAG調試器的情況下可以觀察寄存器和變量的值。當然,模型的運行速度遠低于真實的硬件,通常來說,它啟動Linux需要非常長的時間。
ARM的DS-5產品包含一個實時系統模型(RTSM),可以讓在一臺個人電腦上的系統模擬達到250 MHz的速度。除了處理器本身,它還可以使用主機電腦的資源來模擬諸如LCD控制器、鍵盤、鼠標、觸摸屏、串口以及以太網控制器等外設。為了裸機應用或Linux內核開發的調試,DS-5提供了使用CADI連接的停止模式調試,以及專為Linux應用開發的使用gdb server連接的運行模式調試。
(2)開發板
Candidates must know what types of Development Board are available to them to target as software developers, and be able to recognize advantages and disadvantages of each, as well as the advantages and disadvantages of using them over Models and Final Hardware. They are not required to have knowledge of products from any specific company.
考生必須知道軟件開發者可以使用哪些類型的開發板,并知道每種類型的優缺點,以及使用開發板而非模型和最終硬件的優缺點。考生無須熟悉任何特定半導體公司的產品的知識。
(3)最終硬件
Candidates should be able to recognize advantages and disadvantages of using Final Hardware over Models and Development Boards. They are not required to have knowledge of products from any specific company.
考生必須知道使用最終硬件與模型和開發板之間的優缺點。對任何特定公司的產品的知識不做要求。
市面上有非常豐富的使用ARM Cortex-A系列處理器的低成本開發板,建議考生基于這些硬件運行一些實際代碼來獲取經驗。4.5節列出了一些合適的板子,但市面上還有更多、更新的板子。
1.3.5 系統
本節介紹系統部分的要求。
1.GIC架構
(1)分布模型
Candidates should be aware that multiprocessor systems require an interrupt controller/distributor such as a GIC. They should be aware of and know the differences between 1-N and 1-1 interrupt distribution models.
考生應該了解多處理器系統需要一個如GIC一樣的中斷控制/分布器,了解1-N(一對多)和1-1(一對一)中斷分布模型的區別。
通用中斷控制器GIC在14.2節和23.3節介紹。GIC主要存在于Cortex-A的多內核系列處理器中,屬于ARM處理器的私有總線接口上的設備。它在單處理器和多處理器系統中管理中斷,且本質上由一個在多處理器間共享的分布器加上一個或多個獨立的私有處理器接口構成。
1-N(一對多)與1-1(一對一)分布模型的區別在于,1-N模型中一個中斷會被發布給所有的處理器,而在1-1模型中,每個中斷只會傳遞給一個處理器。
(2)優先級管理
Candidates should be aware that the priority of interrupts is configured via the GIC, how many levels of priority are available and what effect this has on interrupt handling.
考生應該了解中斷優先級是通過GIC來配置的,有多少個中斷優先級,以及優先級對中斷處理的影響。
GIC的優先級管理在14.2.1節簡單介紹。
(3)中斷狀態模型
Candidates should know the possible states of an interrupt as it is handled via the GIC, together with the necessary actions which are taken in each state. They should be aware of what causes transitions between states.
考生應該知道在GIC處理時一個中斷可能存在的狀態,以及在每個狀態下進行的必要動作,了解什么條件會導致狀態切換。
GIC的中斷狀態模型在14.2節提及。
(4)軟件觸發中斷
Candidates should be aware that the SGI mechanism exists within the GIC and what it might be used for.
考生應該了解GIC中存在軟件觸發中斷SGI機制及其用途。
SGI可以通過寫軟件觸發中斷控制器(ICDSGIR)來產生,它主要用于做處理器間通信。
2.軟件存儲和上傳
(1)Flash
Candidates must know what types of code and/or data are typically stored in Flash memory, and what the advantages and disadvantages of Flash memory are over other types of storage. They should also have a basic (high-level) understanding of how code and/or data are uploaded to Flash memory (e.g. that a specific algorithm is required to program it and that this is usually achieved by running a dedicated programming routine on the target hardware).
考生必須知道什么類型的代碼和/或數據通常存儲在Flash,以及使用Flash來存儲而非其他存儲器的優缺點,還應該對代碼和/或數據如何加載進Flash存儲器(如對Flash進行編程需要特殊的算法且通常需要在目標硬件上運行一段特殊的代碼流)有一定的了解。
Flash存儲器是非易失性存儲器,可以電可擦寫以及重復寫入。Flash的擦寫次數是有限的,重寫Flash需要特殊的軟件算法。
有兩種主要類型的Flash存儲器,名字來源于所使用的NAND和NOR邏輯門。NAND Flash的位在擦除后變為1,而NOR Flash的位在擦除后變為0。
NAND Flash可以在一個頁范圍(小于整個存儲器空間)內進行讀寫,這與磁盤的讀寫類似。頁的大小通常為512~4096 B。存儲器可以支持每個塊的擦除,一個塊通常包含32到128個頁。Flash設備通常有一些ECC校驗機制。NOR Flash支持隨機讀操作并且可以支持代碼直接在此設備上運行,而對于NAND設備則只能把代碼從NAND復制到內部RAM來執行。NOR Flash要比NAND成本高,通常用來存儲諸如啟動代碼,而NAND Flash則多用于USB“閃存盤”或存儲卡。
(2)可移除
Candidates should know the common types of removable storage, and what types of code and/or data are typically stored in them. They should know what the advantages and disadvantages of removable storage are over other types of storage. They should also have a basic (high-level) understanding of how code and/or data are uploaded to removable storage.
考生應該了解可移除存儲器的常用類型,以及通常用來存儲哪些代碼和/或數據,應該知道使用可移除存儲器相比其他類型存儲器的優缺點,還應該對如何將代碼和/或數據存儲到可移除設備有基本的認識。
計算機系統通常有許多可移除存儲媒介,常用的包括CD或DVD,軟盤以及存儲卡。這些媒介相比系統內存來說提供了大容量的存儲空間,但需要更長的讀取時間。
(3)網絡存儲
Candidates should know the common types of network storage, and what types of code and/or data are typically stored in them. They should know what the advantages and disadvantages of network storage are over other types of storage. They should also have a basic (high-level) understanding of how code and/or data is uploaded to network storage.
考生應該了解網絡存儲的幾種通常的類型,以及哪些類型的代碼和/或數據可以存儲在上面,應該知道網絡存儲相比其他類型存儲的優缺點,應該對如何將代碼和/或數據存儲到網絡設備上有基本的認識。
網絡存儲是指計算機系統可以將代碼和/或數據(通常是文件級別)存儲到通過網絡連接的外部設備上。這些設備可能是一個或多個的硬盤驅動器(通常采用糾錯冗余方式來組織),這些文件典型地都是通過諸如NFS或SMB的協議來訪問。
3.電源管理
Candidates must be aware of the four basic power modes support by ARM cores (Run, Standby, Dormant, and Shutdown), of the comparative power saving available in each mode and of when these states might be used in a typical system. They should be aware of what system state is preserved in each state and of the comparative complexity and cost of entering and exiting each state. Detailed knowledge of entry/exit sequences is not required, nor is knowledge of any external PMC support circuitry.
考生必須了解ARM內核所支持的4種基本電源模式(運行、待機、休眠、關機),了解每種模式的省電級別以及何時運用于一個典型的系統中,應該了解在每種狀態下保存了哪些系統狀態,以及進入和退出每種狀態的復雜性和消耗的比較。關于進入和退出狀態的詳細步驟不做要求,任何外部PMC所需的電路知識也不做要求。
請參考第26章。
4.內存系統層級
(1)集成和非集成緩存(POC和POU)
Candidates are not expected to demonstrate knowledge of this subject.
對這部分內容不做要求。
(2)緩存層級
Candidates should be aware that systems frequently have more than one level of cache and the differences between unified and Harvard caches. The terminologies and topologies of simple example architectures should be known. They should know the cache topologies of some common systems, for example, the Cortex-A8 processor.
考生應該了解系統由多個緩存級別以及統一和哈弗結構緩存的區別,還應該知道簡單例程的架構的名稱和拓撲結構,應該了解一些常用系統的緩存拓撲結構,如Cortex -A8處理器。
請參考第10章。
(3)內存映射
Candidates should be aware of the constraints of memory map structures and be able to distinguish between common/desirable physical memory maps for ARM-based systems and those that are uncommon/undesirable.
考生應該了解內存映射結構的限制,并能夠區分普通/特定的ARM系統物理內存映射與非常規/非特定的物理內存映射。
通常,Cortex-A系列處理器的物理內存映射不是由架構固定的,因此主要考慮的是確保復位異常的向量在啟動時位于0地址(或者0xFFFF 0000),也許還需確保矢量表位于RAM中,以保證相比位于Flash和ROM更快速的執行。這些在訪問諸如GIC、定時器之類的私有內存空間的位置時需要仔細考慮。
Cortex-R系列和Cortex-M系列處理器有典型的缺省內存映射。Cortex-R系列處理器(以及ARM11和ARM9系列處理器)會包含緊密耦合內存(TCM)。一些系統要求快速的、確定性的訪問含有關鍵代碼和數據的內存。TCM用來提供低延遲訪問內存,位于處理器的局部總線(屬于L1內存系統),不會有由緩存造成的不可預知訪問時間。通常處理器有典型的2個分立的TCM模塊提供給指令通道和數據通道,在一些特定的處理器中,每個TCM還被分為2個獨立訪問的塊。
TCM可以用來保存關鍵代碼,如中斷處理函數或者實時任務,對于這些部分來說不建議采用具有不確定性的緩存,它還可以用來保存不適合保存在緩存的臨時數據,以及諸如中斷堆棧的關鍵數據結構。
不像緩存空間,TCM構成處理器的物理存儲空間映射,TCM的狀態和控制可以通過特定的CP15寄存器。這些寄存器可以配置TCM的基地址,還可以讓代碼讀取它的容量。
1.3.6 軟件優化
這一部分介紹軟件優化。
1.綜述
(1)PMU
Candidates should be aware that ARMv7-AR cores implement a set of hardware performance counters. They should be aware of the types of event which can be counted, of combinations of counts which can provide useful information and of the use of interrupts to extend the range of the counters. They should know that use of the performance counters is non-intrusive.
Example: Candidates must be aware of the PMU and its basic purpose. More advanced candidates will be aware of some of the events which can be counted and the kind of information which they can be used to derive.
考生應該了解ARMv7-AR內核配備了一套硬件性能計數器,了解可以被計數的事件類型,可以提供有用信息的計數組合,以及使用中斷進行計數擴展,應知道使用性能計數是非侵入式的。
例如,考生必須了解PMU和它的基本目的。更高級別的考試要了解可以用來計數的事件以及這些事件可以提供的信息。
Cortex-R和Cortex-A處理器包含有一個性能監控單元(PMU),用于進行標準性能測試和代碼性能分析。這讓代碼分析可以提供有用的統計信息,如循環和指令計數等。PMU有一個循環計數器,可以配置成每個處理器循環或者每64個循環增加一個計數。它還包含一些可配置的事件計數器,可以用來計算所選定的事件次數(如指令執行、數據緩存缺失、分支預測失敗等)。不同的處理器所配備的計數器的個數以及可計算的事件范圍都各不相同。
軟件或調試工具可以通過訪問CP15來進行配置和訪問性能計數器。因此,應該在進行性能標準測試后檢查性能計數器是否溢出。有必要通過軟件技術來使能計數更多數量的事件。例如,有可能讓處理器在計數值溢出后自動觸發中斷從而通過軟件來增加計數變量并復位PMU計數器。
(2)低功耗的代碼編程技術
Candidates should be aware of simple coding techniques to minimize external memory accesses, minimize instruction count and make use of available power modes. They should be aware that these are all techniques which may be used to reduce power consumption.
考生應該了解用以減小外部內存訪問的簡單代碼技術、減小指令數量的技術以及使用電源模式的技術,了解這些是可以用以減小系統功耗的技術。
減少需要執行的代碼數量來實現任務,以及減少訪問外部存儲器都可以用來降低系統功耗,尤其是訪問片外內存需要更大的功耗。第20章介紹這部分知識。
(3)高性能代碼編程技術
Candidates should be aware of simple coding techniques which may be used to improve performance. For example, using integers for data processing operations, passing no more than four parameters, writing decrementing loops to zero, naturally aligning data.
考生應該了解用來提高系統性能的簡單代碼技術,例如,使用整型數據做數據處理操作,盡量不要傳遞4個以上參數,使用遞減到0的循環,自然保持數據對齊。
請參考第20章。
(4)緊湊代碼尺寸的編程技術
Candidates should be aware of simple coding techniques which may be used to reduce memory footprint of code and data. For example, use of _packed to reduce padding in structures, configuring the compiler to optimize for code size, using Thumb code.
考生應該了解用來減少代碼和數據尺寸的簡單代碼技術,例如,使用_packed來減少結構中的空缺填補,配置編譯器來優化代碼大小,使用Thumb指令。
請參考第20章,應該了解“-0space”的命令行選項可以用來告訴編譯器來為減小內存使用進行優化。應該理解16位的Thumb指令集讓Thumb代碼可以相比同級別的ARM指令顯著降低代碼大小。17.3.2節描述了結構、填補以及_packed屬性的知識。
(5)對緩存敏感的編程
對這部分內容不做要求。
2.識別性能瓶頸的技術
(1)概要分析
Candidates must know what profiling is and, given a description of an application performance problem, the candidate should know what can be learned and what cannot be learned from profiling the application.
考生必須了解概要分析是什么,以及對于一個應用性能的問題,知道對應用的概要分析可以獲得以及不能獲得哪些信息。
請參考第19章。
(2)CPU變頻
Given a description of an application performance problem, the candidate should know what can be learned and what cannot be learned from changing the CPU frequency.
對于一個應用性能問題的描述,考生應該知道通過改變CPU頻率可以獲得什么以及不能獲得什么。
在許多系統中,處理器的時鐘頻率都是性能的瓶頸,因此,提高處理器時鐘速度可以增強系統的性能。相反地,如果提高處理器的時鐘速度不能增強系統的性能,就說明處理器的時鐘速度并不是系統性能的限制因素,從而需要檢查系統給的其他部分。例如,可能是訪問某特定外設的延遲,或者不足的系統內存帶寬影響了系統性能。
(3)任務執行時間
Given a description of an application performance problem, the candidate should know what can be learned and what cannot be learned from measuring the wall clock time elapsed for different parts of the application. They should know when this method is not suitable (e.g. when using a model).
對于一個應用性能方面的問題,考生應該知道測量應用中不同部分的任務執行時間可以獲得什么信息以及無法獲得什么信息,知道何時不應該使用這種方法(如使用模型時)。
測量“真實”的時間消耗通常僅對在真實硬件上運行的軟件有意義。一個處理器的仿真模型可能運行低于1 MHz的時鐘,而且速度可能被主機上的其他不相關部分所影響。
- 全國計算機等級考試真題匯編與專用題庫:二級C語言
- 全國計算機等級考試歷年真題與機考題庫:二級MS Office高級應用
- 全國計算機等級考試歷年真題與機考題庫:一級計算機基礎及MS Office應用
- 全國計算機等級考試一本通:二級Access
- 全國計算機等級考試全真模擬考場:二級C語言
- 2014年全國計算機等級考試3年真題精解與過關全真訓練題:二級Visual FoxPro數據庫程序設計
- 5天通過職稱計算機考試(考點視頻串講+全真模擬):Word 2003中文字處理(第2版) (全國專業技術人員計算機應用能力考試指導叢書)
- 2020年3月全國計算機等級考試《二級Visual Basic語言程序設計》歷年真題與模擬試題詳解
- 信息技術計算機等級考試模塊(一級MS Office)
- 2020年3月全國計算機等級考試《四級計算機網絡》復習全書【核心講義+歷年真題詳解】
- PMP項目管理認證學習指南(第4版)
- 全國職稱計算機考試講義·真題·預測三合一:PowerPoint 2003中文演示文稿
- 全國計算機等級考試歷年真題與標準題庫:一級計算機基礎及MS Office 應用
- 全國計算機等級考試歷年真題與標準題庫:二級MS Office高級應用
- 2020年3月全國計算機等級考試《三級網絡技術》復習全書【核心講義+歷年真題詳解】