CPU 에 따라 Cache Policy, mem_types, protection_map 설정한다.
smdk2410 에서의 설정 내용으로 cache_policies[CPOLICY_WRITEBACK] 설정한다.
.policy     = "writeback",
.cr_mask    = 0,
.pmd        = PMD_SECT_WB,
.pte        = PTE_BUFFERABLE|PTE_CACHEABLE,
#define PMD_SECT_WB     (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
 
protection_map[0]=0x0000000f  L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_CACHEABLE | L_PTE_BUFFERABLE
protection_map[1]=0x0000005f  L_PTE_USER | L_PTE_EXEC | L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_CACHEABLE | L_PTE_BUFFERABLE
protection_map[2]=0x0000005f
protection_map[3]=0x0000005f
protection_map[4]=0x0000005f
protection_map[5]=0x0000005f
protection_map[6]=0x0000005f
protection_map[7]=0x0000005f
protection_map[8]=0x0000000f
protection_map[9]=0x0000005f
protection_map[10]=0x0000007f L_PTE_USER | L_PTE_WRITE | L_PTE_EXEC | L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_CACHEABLE | L_PTE_BUFFERABLE
protection_map[11]=0x0000007f
protection_map[12]=0x0000005f
protection_map[13]=0x0000005f
protection_map[14]=0x0000007f
protection_map[15]=0x0000007f
 
[MT_DEVICE]
prot_pte 0x000000a3 L_PTE_DIRTY | L_PTE_WRITE | L_PTE_YOUNG | L_PTE_PRESENT
prot_l1 0x00000011 PMD_BIT4 | PMD_TYPE_TABLE
prot_sect 0x00000412 PMD_SECT_AP_WRITE | PMD_BIT4 | PMD_TYPE_SECT | PMD_SECT_UNCACHED
domain 0x00000002 DOMAIN_IO
[MT_CACHECLEAN]
prot_pte 0x00000000
prot_l1 0x00000000
prot_sect 0x0000001e PMD_BIT4 | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE | PMD_TYPE_SECT
domain 0x00000000 DOMAIN_KERNEL
[MT_MINICLEAN]
prot_pte 0x00000000
prot_l1 0x00000000
prot_sect 0x0000001a PMD_SECT_TEX(1) | PMD_BIT4 | PMD_SECT_CACHEABLE | PMD_TYPE_SECT
domain 0x00000000 DOMAIN_KERNEL
[MT_LOW_VECTORS]
prot_pte 0x000000cf L_PTE_DIRTY | L_PTE_EXEC | L_PTE_CACHEABLE | L_PTE_BUFFERABLE | L_PTE_YOUNG | L_PTE_PRESENT
prot_l1 0x00000011 PMD_BIT4 | PMD_TYPE_TABLE
prot_sect 0x00000000
domain 0x00000001 DOMAIN_USER
[MT_HIGH_VECTORS]
prot_pte 0x000000df L_PTE_DIRTY | L_PTE_EXEC | L_PTE_USER | L_PTE_CACHEABLE | L_PTE_BUFFERABLE | L_PTE_YOUNG | L_PTE_PRESENT
prot_l1 0x00000011 PMD_BIT4 | PMD_TYPE_TABLE
prot_sect 0x00000000
domain 0x00000001 DOMAIN_USER

[MT_MEMORY]
prot_pte 0x00000000
prot_l1 0x00000000
prot_sect 0x0000041e PMD_SECT_AP_WRITE | PMD_BIT4 | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE | PMD_TYPE_SECT
domain 0x00000000 DOMAIN_KERNEL

[MT_ROM]
prot_pte 0x00000000
prot_l1 0x00000000
prot_sect 0x0000001e PMD_BIT4 | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE | PMD_TYPE_SECT
domain 0x00000000 DOMAIN_KERNEL

[MT_IXP2000_DEVICE]
prot_pte 0x000000a3 L_PTE_DIRTY | L_PTE_WRITE | L_PTE_YOUNG | L_PTE_PRESENT
prot_l1 0x00000011 PMD_BIT4 | PMD_TYPE_TABLE
prot_sect 0x00001416 PMD_SECT_TEX(1) | PMD_SECT_AP_WRITE | PMD_BIT4 | PMD_SECT_BUFFERABLE | PMD_TYPE_SECT | PMD_SECT_UNCACHED
domain 0x00000002 DOMAIN_IO

[MT_NONSHARED_DEVICE]
prot_pte 0x00000000
prot_l1 0x00000011 PMD_BIT4 | PMD_TYPE_TABLE
prot_sect 0x00002412 PMD_SECT_TEX(2) | PMD_SECT_AP_WRITE | PMD_BIT4 | PMD_TYPE_SECT
domain 0x00000002 DOMAIN_IO
Posted by blee
,
예전 전달 방식이라면, tag list 형식으로 고쳐준다. 

[ parse_tags ] arch/arm/kernel/setup.c
 
ATAG_NONE 일 때까지 루프 돌면서 parse_tag 에 태그(struct tag)를 인자로 넘겨 호출한다.
parse_tag 는 넘겨온 tag 가 __tagtable_begin에서 __tagtable_end 까지 섹션 .taglist.init 영역 안에 저장되어 있는 tagtable 구조체의 tag 값을 비교하여 같은 것이 있다면, tagtable 구조체의 parse 함수를 호출한다. tagtable 구조체는 include/asm-arm/setup.h 정의되어 있다.
struct tagtable {
    __u32 tag;
    int (*parse)(const struct tag *);
};
.taglist.init 영역에 값을 넣는 매크로는 __tagtable 로써 include/asm-arm/setup.h 에 정의되어 있다.

#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
#define __tagtable(tag, fn) \
static struct tagtable __tagtable_##fn __tag = { tag, fn }

arch/arm/kernel/setup.c
에 다음과 같은 코드가 존재한다.

__tagtable(ATAG_CORE, parse_tag_core);
__tagtable(ATAG_MEM, parse_tag_mem32);
:
__tagtable(ATAG_REVISION, parse_tag_revision);
 
tagtable[0]
  ATAG_REVISION   <-- __tagtable_begin
    parse_tag_revision  
 :  :  
 :   ATAG_MEM  *.taglist.init
 :   parse_tag_mem32  
tagtable[n]
  ATAG_CORE  
 
  parse_tag_core   <-- __tagtable_end
 
[ parse_cmdline ] arch/arm/kernel/setup.c
 
default_command_line 저장되어 있는 문자열을 분석한다. 값은 커널 옵션에서 지정한 값이며, 만약 부트로더에서 ATAG_CMDLINE 태그로 넘겼을 경우 부터로더에서 넘긴 값으로 대체된다.
__early_begin 부터 __early_end 까지 .early_param.init 영역에 저장되어 있는 early_params 구조체의 arg 값을 string 처음부터 끝까지 memcmp 메모리 비교를 하고, 같으면 해당 함수에 일치하는 문자 다음부터 포인터를 인자로 넘기며 호출한다. 그렇지 않으면 cmdline_p에 내용을 복사한다.
early_params 구조체는 include/asm-arm/setup.h 정의되어 .
( cmdline_p=
xxx=1234 yyy=1234 형태로 저장된다.)

struct early_params {
    const char *arg;
    void (*fn)(char **p);
};

.early_param.init 영역에 값을 넣는 매크로는
__early_param 로써 include/asm-arm/setup.h 에 정의되어 있다.

#define __early_param(name,fn)
                  \
static struct early_params __early_##fn __attribute_used__  \
__attribute__((__section__(".early_param.init"))) = { name, fn }

arch/arm/kernel/setup.c
다음과 같은 코드가 존재한다.
__early_param("initrd=", early_initrd);
__early_param("mem=", early_mem);

arch/arm/mm/mmu.c
다음과 같은 코드가 존재한다.
__early_param("cachepolicy=", early_cachepolicy);
__early_param("nocache", early_nocache);
__early_param("nowb", early_nowrite);
__early_param("ecc=", early_ecc);

“initrd=“
<-- __early_begin
 early_initrd
 :
 “nowb”
.early_param.init
 early_nowrite
 “ecc=“
 early_ecc
<-- __early_end
Posted by blee
,
lookup_processor_type에 processor_id 를 인자로 전달하여 호출한다.
processor_id
는 head.S 에서 저장한 CPU ID 값이며, 이 함수의 호출 결과로 구조체 proc_info_list 에 대한 포인터를 얻는다.
각 전역 변수에 값을 대입한다.  elf_hwcap 는 하드웨어 지원사항을 나타낸다.
init_uts_ns.name.machine 를 arch_name, ENDIANNESS 스트링으로 저장한다.
elf_platform 를 elf_name 과 ENDIANNESS 스트링으로 저장한다.
cpu_proc_int 를 호출하는데, processor._proc_init() 로 정의되어 있다.
CPU별로 정
의되어 있는 processor_function내에 존재하는 초기화 코드를 수행한다.

// arch/arm/mm/proc-arm920.S
arm920_processor_functions
// arch/arm/mm/proc-v6.S
v6_processor_functions

두 코드 다 하는 일 없이 바로 리턴한다.
 
 cpu_name = list->cpu_name;
#ifdef MULTI_CPU
    processor = *list->proc;
#endif
#ifdef MULTI_TLB
    cpu_tlb = *list->tlb;
#endif
#ifdef MULTI_USER
    cpu_user = *list->user;
#endif
#ifdef MULTI_CACHE
    cpu_cache = *list->cache;
#endif
    elf_hwcap = list->elf_hwcap;

'리눅스커널' 카테고리의 다른 글

[ build_mem_type_table ] arch/arm/mm/mmu.c  (0) 2009.10.02
[ convert_to_tag_list ] arch/arm/kernel/setup.c  (0) 2009.10.02
[ setup_arch ] arch/arm/kernel/setup.c  (0) 2009.10.02
[ volatile , barrier ]  (0) 2009.10.02
Memory Barrier  (0) 2009.10.02
Posted by blee
,