版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、6.5 Points to RememberSome points to remember include the following: Using semaphores allows multiple tasks, or ISRs to tasks, to synchronize execution to synchronize execution or coordinate mutually exclusive access to a shared resource. Semaphores have an associated semaphore control block (SCB),
2、a unique ID, a user-assigned value (binary or a count), and a task-waiting list. Three common types of semaphores are binary, counting, and mutual exclusion (mutex), each of which can be acquired or released. Binary semaphores are either available (1) or unavailable (0). Counting semaphores are also
3、 either available(count =1) or unavailable (0). Mutexes, however, are either unlocked (0) or locked (lock count =1). Acquiring a binary or counting semaphore results in decrementing its value or count, except when the semaphore s value is already 0. In this case, the requesting task blocks if it cho
4、oses to wait for the semaphore. Releasing a binary or counting semaphore results in incrementing the value or count, unless it is a binary semaphore with a value of 1 or a bounded semaphore at its maximum count. In this case, the release of additional semaphores is typically ignored. Recursive mutex
5、es can be locked and unlocked multiple times by the task that owns them. Acquiring an unlocked recursive mutex increments its lock count, while releasing it decrements the lock count. Typical semaphore operations that kernels provide for application development include creating and deleting semaphor
6、es, acquiring and releasing semaphores, flushing semaphore s task-waiting list, and providing dynamic access to semaphore information. 7.8 Points to Remember Some points to remember include the following: Message queues are buffer-like kernel objects used for data communication and synchronization b
7、etween two tasks or between an ISR and a task. Message queues have an associated message queue control block (QCB), a name, a unique ID, memory buffers, a message queue length, a maximum message length, and one or more task-waiting lists. The beginning and end of message queues are called the head a
8、nd tail, respectively; each buffer that can hold one message is called a message-queue element. Message queues are empty when created, full when all message queue elements contain messages, and not empty when some elements are still available for holding new messages. Sending messages to full messag
9、e queues can cause the sending task to block, and receiving messages from an empty message queue can cause a receiving task to block Tasks can send to and receive from message queues without blocking, via blocking with a timeout, or via blocking forever. An ISR can only send messages without blockin
10、g. The task-waiting list associated with a message-queue can release tasks (unblock them) in FIFO or priority-based order.When messages are sent from one task to another, the message is typically copied twice: once from the sending task s memory area to the message queue s and a second time from the
11、 message queue s memory area to the task s. The data itself can either be sent as the message or as a pointer to the data as the message. The first case is better suited for smaller messages, and the latter case is better suited for large messages. Common message-queue operations include creating an
12、d deleting message queues, sending to and receiving from message queues, and obtaining message queue information. Urgent messages are inserted at the head of the queue if urgent messages are supported by the message-queue implementation. Some common ways to use message queues for data based communic
13、ation include non-interlocked and interlocked queues providing one-way or two-way data communication. 2、About the ARM compilation toolsThe compilation tools allow you to build executable images, partially linked object files, and sharedobject files, and to convert images to different formats.A typic
14、al application development might involve the following: Compiling C/C+ source code for the main application (armcc). Assembling ARM assembly source code for near-hardware components, such as interrupt serviceroutines (armasm). Linking all objects together to generate an image (armlink). Converting a
15、n image to flash format in plain binary, Intel Hex, and Motorola-S formats (fromelf).2、關(guān)于ARM編譯工具編譯工具允許你建立可執(zhí)行的映像,部分鏈接的對象文件和共享目標(biāo)文件,并且將映像轉(zhuǎn)換為不同的格式。一個典型的應(yīng)用程序開發(fā)可能涉及以下內(nèi)容:為了主要應(yīng)用編譯C / C +源代碼(armcc)。為了更靠近硬件組件,將ARM匯編源代碼匯編,如中斷服務(wù)例程(armasm)。鏈接所有對象組合在一起,生成映像(armlink)。將映像轉(zhuǎn)換純二進制,Intel Hex,和Motorola-S的Flash格式的(fromel
16、f)。3、Application startupIn most embedded systems, an initialization sequence executes to set up the system before the main task is executed._main is responsible for setting up the memory and _rt_entry is responsible for setting up the runtime environment._main performs code and data copying, decompr
17、ession, and zero initialization of the ZI data. It thenbranches to _rt_entry to set up the stack and heap, initialize the library functions and static data, andcall any top level C+ constructors. _rt_entry then branches to main(), the entry to your application.When the main application has finished
18、executing, _rt_entry shuts down the library, then hands control back to the debugger.The function label main() has a special significance. The presence of a main() function forces the linkerto link in the initialization code in _main and _rt_entry. Without a function labeled main() the initializatio
19、n sequence is not linked in, and as a result, some standard C library functionality is not supported.3、應(yīng)用程序啟動在大多數(shù)嵌入式系統(tǒng)中,在主要任務(wù)前執(zhí)行初始化序列來設(shè)置系統(tǒng)。_main負(fù)責(zé)設(shè)置內(nèi)存和_rt_entry負(fù)責(zé)設(shè)置運行時環(huán)境。_main執(zhí)行代碼和數(shù)據(jù)復(fù)制,解壓縮,零初始化ZI數(shù)據(jù)。然后它跳轉(zhuǎn)到_rt_entry設(shè)置堆棧和堆,初始化庫函數(shù)和靜態(tài)數(shù)據(jù),并調(diào)用任何上層C +構(gòu)造函數(shù)。 _rt_entry然后跳轉(zhuǎn)到main(),進入到你的應(yīng)用程序。當(dāng)主應(yīng)用程序已經(jīng)執(zhí)行完畢,_rt_entr
20、y將庫關(guān)閉,然后把控制權(quán)交給調(diào)試器。函數(shù)標(biāo)簽main()具有特殊的意義。一個main()函數(shù)的存在強制鏈接器鏈接在_main和_rt_entry中的初始化代碼。如果沒有標(biāo)記的main(),初始化序列不會被鏈接,因此,一些標(biāo)準(zhǔn)C庫功能不會被支持。4、_rt_entryThe symbol _rt_entry is the starting point for a program using the ARM C library.Control passes to _rt_entry after all scatter-loaded regions have been relocated to th
21、eir execution addresses.The default implementation of _rt_entry:1. Sets up the heap and stack.2. Initializes the C library by calling _rt_lib_init.3. Calls main().4. Shuts down the C library, by calling _rt_lib_shutdown.5. Exits.4、_ rt_entry符號_rt_entry是使用ARM C庫的程序的起點。在分散加載域被重新定位到它們的執(zhí)行地址后,控制權(quán)傳遞給_rt_e
22、ntry。_rt_entry的缺省功能:1.設(shè)置堆和棧。2.通過調(diào)用_rt_lib_init初始化C庫。3.調(diào)用main()。4.關(guān)閉C庫,通過調(diào)用_rt_lib_shutdown。5.退出。5、Register usage in subroutine callsYou use branch instructions to call and return from subroutines. The Procedure Call Standard for the ARM Architecture defines how to use registers in subroutine calls.A
23、 subroutine is a block of code that performs a task based on some arguments and optionally returns a result. By convention, you use registers R0 to R3 to pass arguments to subroutines, and R0 to pass a result back to the callers. A subroutine that requires more than four inputs uses the stack for th
24、e additional inputs.To call subroutines, use a branch and link instruction. The syntax is:BL destinationwhere destination is usually the label on the first instruction of the subroutine.destination can also be a PC-relative expression.The BL instruction: Places the return address in the link registe
25、r. Sets the PC to the address of the subroutine.After the subroutine code has executed you can use a BX LR instruction to return.5、在子程序調(diào)用中寄存器的用法可以使用分支指令調(diào)用和子程序返回。ARM體系結(jié)構(gòu)的過程調(diào)用標(biāo)準(zhǔn)決定了在子程序調(diào)用中如何使用的寄存器。子程序是執(zhí)行基于某些參數(shù)的任務(wù)和可選的返回結(jié)果的代碼塊。按照慣例,使用寄存器R0到R3將參數(shù)傳遞給子程序,并且將結(jié)果放到R0中傳遞回調(diào)用方。當(dāng)一個子程序需要四個以上參數(shù)時,將額外的參數(shù)放入堆棧中。要調(diào)用子程序,使
26、用跳轉(zhuǎn)和鏈接指令。語法是:BL destinationdestination 通常是在子程序的第一條指令的標(biāo)號。destination也可以是與PC相關(guān)的表達式。BL指令:放置在鏈接寄存器中的返回地址。設(shè)置PC的子程序的地址。在子程序代碼執(zhí)行完后,可以使用BX LR指令返回。6、Stack pointer initialization and heap boundsThe C library requires you to specify where the stack pointer begins. If you intend to use ARM libraryfunctions that
27、 use the heap, for example, malloc(), calloc(), or if you define argc and argv command-line arguments for main(), the C library also requires you to specify which region of memory the heap is initially expected to use.The region of memory used by the heap can be extended at a later stage of program
28、execution, if required.You can specify where the stack pointer begins, and which region of memory the heap is initially expected to use, with any of the following methods: Define the symbol _initial_sp to point to the top of the stack. If using the heap, also define symbols _heap_base and _heap_limi
29、t. In a scatter file, either: Define ARM_LIB_STACK and ARM_LIB_HEAP regions.If you do not intend to use the heap, only define an ARM_LIB_STACK region. Define an ARM_LIB_STACKHEAP region.If you define an ARM_LIB_STACKHEAP region, the stack starts at the top of that region. The heap starts at the bott
30、om. Implement _user_setup_stackheap() to set up the stack pointer and return the bounds of the initial heap region. If you are using legacy code that uses _user_initial_stackheap(), and you do not want to replace _user_initial_stackheap() with _user_setup_stackheap(), continue to use _user_initial_s
31、tackheap().6,堆棧指針初始化和堆范圍C庫要求指定堆棧指針開始的地方。如果你打算使用ARM庫函數(shù)使用堆,例如malloc(),calloc(),或者如果定義了main()的argc和argv命令行參數(shù),C庫也需要明確最初預(yù)期使用堆的內(nèi)存區(qū)域。如果需要的話,所使用的堆的內(nèi)存區(qū)域可以在稍后程序執(zhí)行的階段被擴展。通過下列方法,可以指定的堆棧指針的起始位置和堆的區(qū)域:定義標(biāo)號_initial_sp指向堆棧的頂部。如果使用堆,還要定義標(biāo)號_heap_base和_heap_limit。在分散文件中- 定義ARM_LIB_STACK和ARM_LIB_HEAP地區(qū)。如果你不打算使用堆,只需定義一個A
32、RM_LIB_STACK區(qū)域。- 定義一個ARM_LIB_STACKHEAP區(qū)域。如果定義了ARM_LIB_STACKHEAP區(qū)域,堆棧開始于該區(qū)域的頂部。堆開始于底部。通過調(diào)用_user_setup_stackheap()來設(shè)置堆棧指針,并返回初始堆區(qū)域的界限。如果使用的是_user_initial_stackheap(遺留代碼),并且不希望替換_user_initial_stackheap()與_user_setup_stackheap(),就繼續(xù)使用_user_initial_stackheap()。7、When to use scatter-loadingScatter-loading
33、 is usually required for implementing embedded systems because these use ROM, RAM,and memory-mapped peripherals.Situations where scatter-loading is either required or very useful:Complex memory mapsCode and data that must be placed into many distinct areas of memory require detailed instructions on
34、where to place the sections in the memory space.Different types of memoryMany systems contain a variety of physical memory devices such as flash, ROM, SDRAM, and fast SRAM. A scatter-loading description can match the code and data with the most appropriate type of memory. For example, interrupt code
35、 might be placed into fast SRAM to improve interrupt response time but infrequently-used configuration information might be placed into slower flash memory.Memory-mapped peripheralsThe scatter-loading description can place a data section at a precise address in the memory map so that memory mapped p
36、eripherals can be accessed.Functions at a constant locationA function can be placed at the same location in memory even though the surrounding application has been modified and recompiled. This is useful for jump table implementation.Using symbols to identify the heap and stackSymbols can be defined
37、 for the heap and stack location when the application is linked.7,何時使用分散加載實現(xiàn)嵌入式系統(tǒng)通常需要分散加載,因為這些系統(tǒng)使用ROM,RAM和內(nèi)存映射的外圍設(shè)備。分散加載是必需的并且非常有用:復(fù)雜的存儲器映射代碼和數(shù)據(jù)必須被放置到多個不同的內(nèi)存領(lǐng)域,需要詳細說明段被放置在存儲空間的何處。不同類型的存儲器許多系統(tǒng)包含各種物理存儲設(shè)備,例如flash,ROM,SDRAM和fast SRAM。分散加載描述可以將代碼和數(shù)據(jù)與最適合的內(nèi)存類型相匹配。例如,可以將中斷代碼放在快速SRAM提高中斷響應(yīng)時間,而將不常使用的配置信息放在較慢的
38、閃存。內(nèi)存映射外設(shè)分散加載描述可以在內(nèi)存映射精確的地址放置一個數(shù)據(jù)段,因此內(nèi)存映射的外圍設(shè)備可以訪問。在固定位置的函數(shù)函數(shù)可以被放置在存儲器中相同的位置,即使周邊的應(yīng)用已被修改并重新編譯。這對跳表的實現(xiàn)十分有用。使用標(biāo)號識別堆和棧在應(yīng)用程序鏈接時,標(biāo)號可以定義堆和棧的地址。8、Syntax of source lines in assembly languageThe assembler parses and assembles assembly language to produce object code.SyntaxEach line of assembly language sourc
39、e code has this general form:symbol instruction|directive|pseudo-instruction ;commentAll three sections of the source line are optional.symbol is usually a label. In instructions and pseudo-instructions it is always a label. In some directives it is a symbol for a variable or a constant. The descrip
40、tion of the directive makes this clear in each case.symbol must begin in the first column. It cannot contain any white space character such as a space or atab unless it is enclosed by bars (|).Labels are symbolic representations of addresses. You can use labels to mark specific addresses that you wa
41、nt to refer to from other parts of the code. Directives provide important information to the assembler that either affects the assembly process or affects the final output image.Instructions and pseudo-instructions make up the code a processor uses to perform tasks.A comment is the final part of a s
42、ource line. The first semicolon on a line marks the beginning of acomment except where the semicolon appears inside a string literal. The end of the line is the end of thecomment. A comment alone is a valid line. The assembler ignores all comments. You can use blank lines to make your code more read
43、able.8、在匯編語言中源代碼行的語法匯編器解析和組裝匯編語言生成目標(biāo)代碼。語法匯編語言源代碼的每一行都有這的形式:符號 指令|指令|偽指令 ;注釋源代碼行的所有三部分都是可選的。符號通常是一個標(biāo)號。在指令和偽指令中,它通常是一個標(biāo)號。在某些命令中,它是一個變量或常數(shù)的符號。這些在該指令的說明中已經(jīng)明確了。符號必須開始于第一列。它不能包含任何空白字符,如space或tab,除非它被(|)包圍。標(biāo)號是地址的符號表示。你可以使用標(biāo)號來記錄你要從代碼的其它部分參考的特定的地址,。指令給匯編器提供影響裝配過程或影響最終輸出的映像的重要信息。指令和偽指令組成一個處理器用于執(zhí)行任務(wù)的代碼。注釋是一個源代
44、碼行的最后一部分。一行中的第一個分號標(biāo)志著注釋開始,除非該分號出現(xiàn)在一個字符串里面。該行的結(jié)束代表著注釋的結(jié)束。一個注釋本身就是一個有效的行。匯編器將忽略所有注釋。您可以使用空行使你的代碼更易讀。9、Processor mode and privilege levels for software executionThe processor modes are:Thread mode Used to execute application software. The processor enters Thread mode when it comes out of reset.Handler
45、modeUsed to handle exceptions. The processor returns to Thread mode when it has finished all exception processing.The privilege levels for software execution are:UnprivilegedThe software: has limited access to the MSR and MRS instructions, and cannot use the CPS instruction cannot access the system
46、timer, NVIC, or system control block might have restricted access to memory or peripherals.Unprivileged software executes at the unprivileged level.PrivilegedThe software can use all the instructions and has access to all resources.Privileged software executes at the privileged level.In Thread mode,
47、 the CONTROL register controls whether software execution is privileged or unprivileged. In Handler mode, software execution is always privileged.Only privileged software can write to the CONTROL register to change the privilege level for software execution in Thread mode. Unprivileged software can
48、use the SVC instruction to make a supervisor call to transfer control to privileged software.9,處理器模式和特權(quán)級別的軟件執(zhí)行該處理器模式有:線程模式用于執(zhí)行應(yīng)用軟件。處理器在復(fù)位以后進入線程模式。處理模式用于處理異常。當(dāng)完成了所有的異常處理后處理器返回線程模式。特權(quán)級別的軟件執(zhí)行如下:非特權(quán)模式軟件:有限制訪問MSR和MRS指令,而不能使用CPS指令無法訪問系統(tǒng)定時器,NVIC或者系統(tǒng)控制塊可能有限制地訪問內(nèi)存或外圍設(shè)備。非特權(quán)軟件在非特權(quán)級別執(zhí)行。特權(quán)該軟件可以使用所有的指令和訪問所有的資源。特權(quán)
49、軟件的特權(quán)級別執(zhí)行。在線程模式下,CONTROL寄存器控制軟件是在特權(quán)或非特權(quán)。在處理器模式下,軟件執(zhí)行總是特權(quán)級的。只有特權(quán)軟件可以寫CONTROL寄存器來改變軟件的執(zhí)行線程模式的權(quán)限級別。非特權(quán)軟件可以使用SVC指令來產(chǎn)生一個系統(tǒng)調(diào)用把控制權(quán)轉(zhuǎn)移到特權(quán)下的軟件。Exception entryException entry occurs when there is a pending exception with sufficient priority and either: the processor is in Thread mode the new exception is of hi
50、gher priority than the exception being handled, in which case the new exception preempts the exception being handled.When one exception preempts another, the exceptions are nested.Sufficient priority means the exception has has greater priority than any limits set by the mask registers. An exception
51、 with less priority than this is pending but is not handled by the processor.When the processor takes an exception, unless the exception is a tail-chained or a late-arriving exception, the processor pushes information onto the current stack. This operation is referred to as stacking and the structur
52、e of eight data words is referred as the stack frame. The stack frame contains the following information:Immediately after stacking, the stack pointer indicates the lowest address in the stack frame. Thealignment of the stack frame is controlled via the STKALIGN bit of the Configuration Control Regi
53、ster (CCR).The stack frame includes the return address. This is the address of the next instruction in the interrupted program. This value is restored to the PC at exception return so that the interrupted program resumes.The processor performs a vector fetch that reads the exception handler start ad
54、dress from the vector table. When stacking is complete, the processor starts executing the exception handler.At the same time, the processor writes an EXC_RETURN value to the LR. This indicates which stack pointer corresponds to the stack frame and what operation mode the processor was in before the
55、 entry occurred.If no higher priority exception occurs during exception entry, the processor starts executing the exception handler and automatically changes the status of the corresponding pending interrupt to active.If another higher priority exception occurs during exception entry, the processor starts execut
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 國企培訓(xùn)準(zhǔn)備工作方案
- 漢代快遞行業(yè)形式分析報告
- 開學(xué)保障環(huán)衛(wèi)工作方案
- 涼皮涼面行業(yè)現(xiàn)狀分析報告
- 后續(xù)跟蹤審計實施方案
- 廣告行業(yè)配色分析報告
- 國內(nèi)商貿(mào)業(yè)行業(yè)分析報告
- 門窗行業(yè)品牌分析報告
- 波蘭儲能行業(yè)分析報告
- 幼師行業(yè)和企業(yè)分析報告
- 2026年各地高三語文1月聯(lián)考文言文匯編(文言詳解+挖空)
- 2026年春季統(tǒng)編版三年級下冊小學(xué)語文教學(xué)計劃(含進度表)
- 家庭醫(yī)生簽約服務(wù)工作實施方案
- 冰箱安裝施工方案
- 村委安全生產(chǎn)責(zé)任制度
- 2025-2030中國碳酸氫鈉市場未來前瞻及投資戰(zhàn)略規(guī)劃策略建議研究報告
- 土石方開挖與回填施工方案
- 2025年12月廣西區(qū)一模語文2025-2026年度首屆廣西職教高考第一次模擬考試2026年廣西高等職業(yè)教育考試模擬測試語文含逐題答案解釋99
- 2026元旦主題班會:馬年猜猜樂猜成語 (共130題)【課件】
- 2026年盤錦職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫及參考答案詳解一套
- YY/T 1778.1-2021醫(yī)療應(yīng)用中呼吸氣體通路生物相容性評價第1部分:風(fēng)險管理過程中的評價與試驗
評論
0/150
提交評論