__vet_atags:
atag또는 dtb가 유효한지 확인한다. 유효하지 않으면 r2=0을 리턴한다.
arch/arm/kernel/head-common.S
/* Determine validity of the r2 atags pointer. The heuristic requires
* that the pointer be aligned, in the first 16k of physical RAM and
* that the ATAG_CORE marker is first and present. If CONFIG_OF_FLATTREE
* is selected, then it will also accept a dtb pointer. Future revisions
* of this function may be more lenient with the physical address and
* may also be able to move the ATAGS block if necessary.
*
* Returns:
* r2 either valid atags pointer, valid dtb pointer, or zero
* r5, r6 corrupted
*/
__vet_atags:
tst r2, #0x3 @ aligned?
bne 1f
- 체크1) align 체크하여 align되어 있지 않으면 에러로 점프.
ldr r5, [r2, #0]
#ifdef CONFIG_OF_FLATTREE
ldr r6, =OF_DT_MAGIC @ is it a DTB?
cmp r5, r6
beq 2f
#endif
- 체크2) dtb magic number가 검출되면 정상이라 판단하고 리턴
cmp r5, #ATAG_CORE_SIZE @ is first tag ATAG_CORE?
cmpne r5, #ATAG_CORE_SIZE_EMPTY
bne 1f
ldr r5, [r2, #4]
ldr r6, =ATAG_CORE
cmp r5, r6
bne 1f
2: ret lr @ atag/dtb pointer is ok
1: mov r2, #0
ret lr
ENDPROC(__vet_atags)
- 체크3) ATAG_CORE가 처음에 오는지 사이즈 및 ATAG_CORE 태그 코드 매치 확인하여 맞으면 ATAG가 맞다고 판단하고 리턴.
- ATAG_CORE_SIZE: 5
- ATAG_CORE: 0x54410001
- mov r2, #0
- r2=0을 담고 리턴(에러)
OF_DT_MAGIC 매크로 상수
#ifdef CONFIG_CPU_BIG_ENDIAN #define OF_DT_MAGIC 0xd00dfeed #else #define OF_DT_MAGIC 0xedfe0dd0 /* 0xd00dfeed in big-endian */ #endif
- 디바이스 트리를 알리는 매직넘버.
- DTB는 빅엔디안형태로 저장되므로 아키첵처 엔디안에 따라 변환하여 인식을 하여야 한다.
ATAG 관련 매크로 상수
#define ATAG_CORE 0x54410001 #define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2) #define ATAG_CORE_SIZE_EMPTY ((2*4) >> 2)
- ATAG_CORE
- ATAG_CORE를 식별할 수 있는 ID
- ATAG_CORE_SIZE
- 공통헤더(2개 word) + ATAG_CORE(3개 word) = 5 word (20 byte)
- ATAG_CORE_SIZE_EMPTY
- 비어 있는 ATAG의 경우에도 최하 공통헤더로 이루어진 ATAG_CORE로 이루어져야 한다. 따라서 2 word가 필요하다.