星期一, 9月 25, 2006

CE : Kernel Startup Sequence and some others

在MSDN 這一篇:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnce50/html/ce50prev.asp
有說明 CE 的startup sequence..

從bootloader開始講,範例是ARM。
要配合BSP的code來看,BSP的code中,bootloader 依照boot flash type : NOR 或是NAND。而有不同。(BSP中有一個readme,說明boot environment: FLASH Layout)

NOR : EBOOT
NAND : STEPLOADER

EBOOT 就是 etherboot,支援download image from ethernet,writing to NANDFLASH。
(這個功能是因為demo board上有一個JMP可以設boot device : FROM NOR/NAND)。

STEMPLOADER是一個小size的bootloader,配合cpu NAND boot support的功能。boot時,cpu會從NANDFLASH讀取4k的data進入internal SRAM,再由internal SRAM boot。


Wakeup 和 Reset不一樣的地方在於Wakeup 時,SDRAM的內容是Sleep時的內容,沒有消失,所以只要適當將週邊再設定好,就可以回到當初sleep的狀態繼續執行。
Reset就不一樣。

這個bootloader的starup code要作的事情很多,因為不管是wake from sleep,reset 和WDT timout都是從這裡開始執行。
所以要判斷是wakeup,reset還是WDT,wake up的話,要check saved data是不是OK。restore saved data (CACHE/MMU control)。
WDT的話,要clear DRAM data。
reset的話,要將kernel從NANDFLASH load進來(C code)。


Bootloader的部份都是以EBOOT為範例解說。 -- 這部份略過,因為NAND FLASH不使用EBOOT作bootloader。

Kernel

由 Src\Kernel\OAL\Startup.s 開始。 負責hardware 相關的初始化(dram, cache...),最後計算好OEMAddressTable 的位置,當作是argument,呼叫KernelStart。
OEMAddressTable 宣告在Src\inc\oemaddrtab_cfg.inc。

KernalStart在MS的private code folder的armtrap.s(也就是說,其內容是不能在公開場合提及的)。在msdn這一篇 ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecoreos5/html/wce50conNkexeBootProcess.asp ) armtrap.s 這一個assembly 不太好看,裡面包括很多部份,大部分是要setup MMU,所以有一堆Virtual, Physical 轉換。

ARM MMU architecture (furber P.302)

ARM MMU 使用 2-level page table和一個TLB(存放最近用過的translations)。
memory mapping的size可以有以下選擇:
  • Sections - 1M byte
  • Large Pages - 64K Byte,其中每16K byte又被分為一個sub page,可以分開控制
  • Small Pages - 4K Byte,分成 1K byte subpage
  • Tiny Pages - 1K Bytes tiny page
在KernelStart (armtrap.s) 中看到設定MMU Translation Table的部份,最後的 byte是1。
所以是 Coarse page - 64k per entry。

使用Corse Page,所以Address Translation 要經過兩次轉換:由 MMU的 TTB(Translation Table Base)register 和要轉換的address查表到一個descriptor,由descriptor內的


有關MMU - ARM MMU : CP15 (P.299 furber)

C3 : Domain Control - 16 個domain的access control (2 bits/domain)
C2 : Translation Table Start Address - 在RAM中存放Translation Table的start address
C8 : 控制每個domain動作 - Flush.. etc
C1 : MMU的各項funtion (enable MMU,address alignmnt fault, data cache, Write buffer...)




CE 的system call 和Linux kernel service 類似,有implement一個call-gate,將API轉為Service_ID傳入統一的kernel 介面。

Service ID 定義在oak\inc\psyscall.h

3 則留言:

匿名 提到...

I am studying 3 question ...
(1)Is it possible that Process A can share memory with Process B?
(2)Please explain translation flow of virtual address.
(3)Please explain how to translate g_oalAddressTable to MMU translation table.

===== trace log

($:\wince500\platform\NH5\src\Bootloader\eboot\startup.s)

‧ Line 348 : Setup mmu to map (VA==0) to (PA==0x30000000)
‧ Line 386 : Initialize the MMU and turn it on.
‧ Line 396 : Enable: MMU
‧ Line 404 : jump to new virtual address
‧ Line 440 : jump to main.c
‧ Line 447 : include oemaddrtab_cfg.inc
‧ Line 456 : OALCPUPowerOff : Save MMU & CPU Register to RAM
($:\wince500\platform\NH5\src\Kernel\OAL\startup.s)

‧ Line 379~381 :compute OEMAddressTable's address ,use it as argument,call KernelStart。
OEMAddressTable declare in oemaddrtab_cfg.inc。
‧ Line 385 : Include oemaddrtab_cfg.inc
‧ Line 396 : OALCPUPowerOff : Save MMU & CPU Register to RAM
‧ Line 288 : Resume process: call MMU enable
‧ Line 318~329 : MMU enable
‧ Line 331 : wakeup routine: restore MMU control

($:\wince500\private\womceos\coreos\nk\kernel\arm\armtrap.s)

‧ Line 144~151 : write/read TTBR (Translation Table Base Register c2) Macro
‧ Line 402 : LEAF_ENTRY KernelStart
‧ Line 406 :figure out the virtual address of OEMAddressTable
‧ Line 132 : space for first-level page table
‧ Line 411 : convert base of PTs to Physical address
‧ Line 417 : (r10) = ptr to FirstPT (physical)
‧ Line 569 : The page tables and exception vectors are setup. Initialize the MMU and turn it on.
‧ Line 574 : {mtc15 r10, c2} => write TTBR to c2
‧ Line 582 : {ldr r0, VirtualStart} => load virtual start address to ro.
‧ Line 585 : jump to new virtual address

I trace armtrap.s ..
how to get the translation base(bit 14~31) ?

checko 提到...

translation base ?
是在 translation table 裡面的各個region 的base 嗎?

會在translation table 裡..

??

匿名 提到...

我找到code了,
armtrap.s第132行,
定義translation table的size..
KDataArea
PTs % 0x4000 ; space for first-level page table
ExceptionVectors

412行把physical 轉成virtual address:
; convert base of PTs to Physical address
ldr r4, =PTs ; (r4) = virtual address of FirstPT
====
之後就開始用OEMAddressTable建translation table,

只是我現在不知道ARM MMU把Virtual address利用translation table轉成physical address的code 在哪?

網誌存檔