요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
1
=======
2
Porting
3
=======
5
Taken from list archive at http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2001-July/004064.html
7
Initial definitions
8
-------------------
10
The following symbol definitions rely on you knowing the translation that
11
__virt_to_phys() does for your machine. This macro converts the passed
12
virtual address to a physical address. Normally, it is simply:
14
phys = virt - PAGE_OFFSET + PHYS_OFFSET
17
Decompressor Symbols
18
--------------------
20
ZTEXTADDR
21
Start address of decompressor. There's no point in talking about
22
virtual or physical addresses here, since the MMU will be off at
23
the time when you call the decompressor code. You normally call
24
the kernel at this address to start it booting. This doesn't have
25
to be located in RAM, it can be in flash or other read-only or
26
read-write addressable medium.
28
ZBSSADDR
29
Start address of zero-initialised work area for the decompressor.
30
This must be pointing at RAM. The decompressor will zero initialise
31
this for you. Again, the MMU will be off.
33
ZRELADDR
34
This is the address where the decompressed kernel will be written,
35
and eventually executed. The following constraint must be valid:
37
__virt_to_phys(TEXTADDR) == ZRELADDR
39
The initial part of the kernel is carefully coded to be position
40
independent.
42
INITRD_PHYS
43
Physical address to place the initial RAM disk. Only relevant if
44
you are using the bootpImage stuff (which only works on the old
45
struct param_struct).
47
INITRD_VIRT
48
Virtual address of the initial RAM disk. The following constraint
49
must be valid:
51
__virt_to_phys(INITRD_VIRT) == INITRD_PHYS
53
PARAMS_PHYS
54
Physical address of the struct param_struct or tag list, giving the
55
kernel various parameters about its execution environment.
58
Kernel Symbols
59
--------------
61
PHYS_OFFSET
62
Physical start address of the first bank of RAM.
64
PAGE_OFFSET
65
Virtual start address of the first bank of RAM. During the kernel
66
boot phase, virtual address PAGE_OFFSET will be mapped to physical
67
address PHYS_OFFSET, along with any other mappings you supply.
68
This should be the same value as TASK_SIZE.
70
TASK_SIZE
71
The maximum size of a user process in bytes. Since user space
72
always starts at zero, this is the maximum address that a user
73
process can access+1. The user space stack grows down from this
74
address.
76
Any virtual address below TASK_SIZE is deemed to be user process
77
area, and therefore managed dynamically on a process by process
78
basis by the kernel. I'll call this the user segment.
80
Anything above TASK_SIZE is common to all processes. I'll call
81
this the kernel segment.
83
(In other words, you can't put IO mappings below TASK_SIZE, and
84
hence PAGE_OFFSET).
86
TEXTADDR
87
Virtual start address of kernel, normally PAGE_OFFSET + 0x8000.
88
This is where the kernel image ends up. With the latest kernels,
89
it must be located at 32768 bytes into a 128MB region. Previous
90
kernels placed a restriction of 256MB here.
92
DATAADDR
93
Virtual address for the kernel data segment. Must not be defined
94
when using the decompressor.
96
VMALLOC_START / VMALLOC_END
97
Virtual addresses bounding the vmalloc() area. There must not be
98
any static mappings in this area; vmalloc will overwrite them.
99
The addresses must also be in the kernel segment (see above).
100
Normally, the vmalloc() area starts VMALLOC_OFFSET bytes above the
101
last virtual RAM address (found using variable high_memory).
103
VMALLOC_OFFSET
104
Offset normally incorporated into VMALLOC_START to provide a hole
105
between virtual RAM and the vmalloc area. We do this to allow
106
out of bounds memory accesses (eg, something writing off the end
107
of the mapped memory map) to be caught. Normally set to 8MB.
109
Architecture Specific Macros
110
----------------------------
112
BOOT_MEM(pram,pio,vio)
113
`pram` specifies the physical start address of RAM. Must always
114
be present, and should be the same as PHYS_OFFSET.
116
`pio` is the physical address of an 8MB region containing IO for
117
use with the debugging macros in arch/arm/kernel/debug-armv.S.
119
`vio` is the virtual address of the 8MB debugging region.
121
It is expected that the debugging region will be re-initialised
122
by the architecture specific code later in the code (via the
123
MAPIO function).
125
BOOT_PARAMS
126
Same as, and see PARAMS_PHYS.
128
FIXUP(func)
129
Machine specific fixups, run before memory subsystems have been
130
initialised.
132
MAPIO(func)
133
Machine specific function to map IO areas (including the debug
134
region above).
136
INITIRQ(func)
137
Machine specific function to initialise interrupts.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Porting
1-6ARM Linux를 새 machine에 port할 때 정의해야 하는 주소 symbol과 architecture macro를 설명합니다.
Initial definitions
7-16다음 symbol을 정하려면 해당 machine에서 `__virt_to_phys()`가 수행하는 변환을 알아야 합니다. 이 macro는 전달받은 virtual address를 physical address로 바꾸며, 보통 관계식은 다음과 같습니다.
phys = virt - PAGE_OFFSET + PHYS_OFFSET
Decompressor Symbols
17-57| symbol | 의미와 제약 |
|---|---|
| `ZTEXTADDR` | decompressor 시작 address. 호출 시 MMU가 꺼져 있어 virtual/physical 구분이 없으며 보통 이 address로 kernel boot를 시작합니다. RAM뿐 아니라 flash나 다른 read-only/read-write addressable medium에도 둘 수 있습니다. |
| `ZBSSADDR` | decompressor의 zero-initialized work area 시작 address. 반드시 RAM을 가리켜야 하며 decompressor가 0으로 초기화합니다. 이때도 MMU는 꺼져 있습니다. |
| `ZRELADDR` | 압축 해제한 kernel을 쓰고 최종 실행할 address. kernel의 초기 부분은 position independent로 세심하게 작성됩니다. |
| `INITRD_PHYS` | initial RAM disk를 놓을 physical address. 오래된 `struct param_struct`에서만 동작하는 `bootpImage`를 사용할 때만 관련됩니다. |
| `INITRD_VIRT` | initial RAM disk의 virtual address. `INITRD_PHYS`와 변환 관계가 일치해야 합니다. |
| `PARAMS_PHYS` | kernel 실행 환경 parameter를 전달하는 `struct param_struct` 또는 tag list의 physical address |
`ZRELADDR`에는 다음 제약이 반드시 성립해야 합니다.
__virt_to_phys(TEXTADDR) == ZRELADDR
initial RAM disk의 두 주소에는 다음 제약이 반드시 성립해야 합니다.
__virt_to_phys(INITRD_VIRT) == INITRD_PHYS
Kernel Symbols
58-108| symbol | 의미와 제약 |
|---|---|
| `PHYS_OFFSET` | 첫 번째 RAM bank의 physical 시작 address |
| `PAGE_OFFSET` | 첫 번째 RAM bank의 virtual 시작 address. boot 중 `PAGE_OFFSET`를 `PHYS_OFFSET`에 mapping하며 `TASK_SIZE`와 같은 값이어야 합니다. |
| `TASK_SIZE` | user process의 최대 byte 크기이자 접근 가능한 마지막 address + 1. user stack은 여기서 아래로 자랍니다. 이 값 아래는 process별 user segment, 위는 모든 process가 공유하는 kernel segment입니다. I/O mapping은 `TASK_SIZE`, 따라서 `PAGE_OFFSET` 아래에 둘 수 없습니다. |
| `TEXTADDR` | kernel virtual 시작 address. 보통 `PAGE_OFFSET + 0x8000`이며 kernel image가 놓입니다. 최신 kernel에서는 128MB region 안의 32768-byte offset에 있어야 하고, 이전 kernel은 256MB 제약을 사용했습니다. |
| `DATAADDR` | kernel data segment의 virtual address. decompressor를 사용할 때는 정의하면 안 됩니다. |
| `VMALLOC_START` / `VMALLOC_END` | `vmalloc()` 영역 경계. static mapping이 있으면 vmalloc이 덮어쓰므로 이 안에 두면 안 되며 kernel segment에 있어야 합니다. 보통 `high_memory`가 나타내는 마지막 virtual RAM address보다 `VMALLOC_OFFSET`만큼 위에서 시작합니다. |
| `VMALLOC_OFFSET` | virtual RAM과 vmalloc 사이의 hole. mapped memory 끝을 벗어난 access를 잡기 위해 사용하며 보통 8MB입니다. |
Architecture Specific Macros
109-137| macro | 역할 |
|---|---|
| `BOOT_MEM(pram,pio,vio)` | `pram`은 RAM physical 시작 address로 필수이며 `PHYS_OFFSET`과 같아야 합니다. `pio`는 `arch/arm/kernel/debug-armv.S` debug macro가 쓰는 8MB I/O 영역의 physical address, `vio`는 그 영역의 virtual address입니다. 이후 architecture code가 `MAPIO`로 다시 초기화합니다. |
| `BOOT_PARAMS` | `PARAMS_PHYS`와 같은 의미 |
| `FIXUP(func)` | memory subsystem 초기화 전에 실행하는 machine-specific fixup |
| `MAPIO(func)` | debug 영역을 포함한 I/O area를 mapping하는 machine-specific function |
| `INITIRQ(func)` | interrupt를 초기화하는 machine-specific function |
요약과 해설
porting.rst:1-137porting의 핵심은 세 주소 세계를 혼동하지 않는 것입니다. MMU가 꺼진 decompressor 단계, `PAGE_OFFSET`로 시작하는 kernel virtual segment, 그리고 debug I/O mapping이 각기 다른 symbol로 연결됩니다.
압축 해제 전부터 kernel virtual mapping과 architecture 초기화까지의 순서입니다.
세 관계식이 맞지 않으면 image와 initrd를 올바르게 찾을 수 없습니다.