[ARM] kernel先頭から。その1
2013/07/17
ARMv7 ARCHのARMから...
MPcoreから追加されている話も新規として扱います. 脳内はARM928EJ-Sあたりで停止していましたので..メモリ空間の属性は、
- ストロングリオーダ(Strongly ordered)
- ノーマル()\メモリ属性は以下がある。
- (Outer Shareable)
- (Inner Shareable)
- (Non shareable)
- デバイス
- (shareable)
- (Non shareable)
Outer/Inter sharebleの差異は、Outerが実装定義でレベルをつけたアクセス制御が入るらしい???
A3-27あたりからatomic accessに関する記載がある。
mm初期化処理を追う... ために, kernel起動先頭から少し追ってみる.
vmlinuxをdisasすると entry pointが "stext"なのがわかる.*1entry pointには、以下のコメントがあり、展開される位置、状態、レジスタ値について記載がある。
・・・どのみちすぐにldscript読まなあかんかった。
FILE:arch/arm/kernel/vmlinux.lds .init.pv_table : { __pv_table_begin = .; *(.pv_table) __pv_table_end = .; }
Kernel startup entry point. --------------------------- This is normally called from the decompressor code. The requirements are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0, r1 = machine nr, r2 = atags or dtb pointer. This code is mostly position independent, so if you link the kernel at 0xc0008000, you call this at __pa(0xc0008000). See linux/arch/arm/tools/mach-types for the complete list of machine numbers for r1. We're trying to keep crap to a minimum; DO NOT add any machine specific crap here - that's what the boot loader (or in extreme, well justified circumstances, zImage) is for.
/* * r1 = machine no, r2 = atags or dtb, * r8 = phys_offset, r9 = cpuid, r10 = procinfo */ bl __vet_atags // ゴミデータなら r2=NULL と修正される。 #ifdef CONFIG_SMP_ON_UP bl __fixup_smp #endif #ifdef CONFIG_ARM_PATCH_PHYS_VIRT //enable bl __fixup_pv_table // #endif bl __create_page_tableskernel imageがロードされた物理アドレス と kernel空間を設置しようとしている論理アドレス、との
アドレス値の差分を r8に計算、保持する。
__fixup_pv_tableを呼び出して、"arch/arm/include/asm/memory.h"で定義した関数・マクロの
論理ー物理変換関数が参照する変数を書き換える。
ロード位置が固定されていればいらないのかもしれないけれど,headの記述からするとそうもいかんような.
このheadは展開後のkernel start位置なので、compressed kernelの先頭は別のところ。*2