Skip to content

Commit

Permalink
140726 study
Browse files Browse the repository at this point in the history
  • Loading branch information
ddozzip committed Jul 26, 2014
1 parent c0bb137 commit 2cf0aeb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 24 deletions.
59 changes: 41 additions & 18 deletions arch/arm/kernel/atags_parse.c
Expand Up @@ -43,19 +43,19 @@ static struct {
struct tag_mem32 mem;
struct tag_header hdr3;
} default_tags __initdata = {
{ tag_size(tag_core), ATAG_CORE },
{ 1, PAGE_SIZE, 0xff },
{ tag_size(tag_mem32), ATAG_MEM },
{ MEM_SIZE },
{ 0, ATAG_NONE }
{ tag_size(tag_core), ATAG_CORE }, // tag_size (8+12)/4 = 5 ATAG_CORE = 0x54410001
{ 1, PAGE_SIZE, 0xff }, // PAGE_SIZE = 4096
{ tag_size(tag_mem32), ATAG_MEM }, // (8+8)/4 = 4 ATAG_MEM = 0x54410002
{ MEM_SIZE }, // 16Mega
{ 0, ATAG_NONE } // ATAG_NONE = 0
};

static int __init parse_tag_core(const struct tag *tag)
{
if (tag->hdr.size > 2) {
if ((tag->u.core.flags & 1) == 0)
root_mountflags &= ~MS_RDONLY;
ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
root_mountflags &= ~MS_RDONLY; // root_mountflags = 2^15+1 에서 MS_RDONLY = 1 를 클리어 = 2^15
ROOT_DEV = old_decode_dev(tag->u.core.rootdev); // 16bit reoot_dev 를 32bit 로 바꿔줌
}
return 0;
}
Expand Down Expand Up @@ -91,9 +91,10 @@ __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);
static int __init parse_tag_ramdisk(const struct tag *tag)
{
extern int rd_size, rd_image_start, rd_prompt, rd_doload;

// rd_size = 8k

rd_image_start = tag->u.ramdisk.start;
rd_doload = (tag->u.ramdisk.flags & 1) == 0;
rd_doload = (tag->u.ramdisk.flags & 1) == 0; //0=load 1=prompt
rd_prompt = (tag->u.ramdisk.flags & 2) == 0;

if (tag->u.ramdisk.size)
Expand Down Expand Up @@ -132,7 +133,7 @@ static int __init parse_tag_cmdline(const struct tag *tag)
pr_warning("Ignoring tag cmdline (using the default kernel command line)\n");
#else
strlcpy(default_command_line, tag->u.cmdline.cmdline,
COMMAND_LINE_SIZE);
COMMAND_LINE_SIZE); // COMMAND_LINE_SIZE = 1024 or 512
#endif
return 0;
}
Expand Down Expand Up @@ -185,7 +186,8 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
const struct machine_desc *mdesc = NULL, *p;
char *from = default_command_line;

default_tags.mem.start = PHYS_OFFSET;
default_tags.mem.start = PHYS_OFFSET; // 0x40000000 exynos
// mem size 는default_tags 에서 16 M 로 초기화되어있음

/*
* locate machine in the list of supported machines.
Expand All @@ -204,9 +206,10 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
}

if (__atags_pointer)
tags = phys_to_virt(__atags_pointer);
tags = phys_to_virt(__atags_pointer); // tag pointer 를 가상주소로
else if (mdesc->atag_offset)
tags = (void *)(PAGE_OFFSET + mdesc->atag_offset);
tags = (void *)(PAGE_OFFSET + mdesc->atag_offset); //0xc0000000 + atag_offset = atag_offset 의 가상주소
// 위 두가지 경우에 해당사항이 없으면 default_tags를 사용함

#if defined(CONFIG_DEPRECATED_PARAM_STRUCT)
/*
Expand All @@ -216,19 +219,39 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
if (tags->hdr.tag != ATAG_CORE)
convert_to_tag_list(tags);
#endif
if (tags->hdr.tag != ATAG_CORE) {
if (tags->hdr.tag != ATAG_CORE) { //0x54410001 예외처리
early_print("Warning: Neither atags nor dtb found\n");
tags = (struct tag *)&default_tags;
}

if (mdesc->fixup)
// __mach_desc_EXYNOS5_DT 에fixup은 정의되어있지 않음 아래if문은 실행되지않음
// arch/arm/mach-exynos/mach-exynos5-dt.c 참고
// fixup은 memory subsystem이 초기화되기 전에 실행된다.
if (mdesc->fixup)
mdesc->fixup(tags, &from, &meminfo);

if (tags->hdr.tag == ATAG_CORE) {
if (meminfo.nr_banks != 0)
squash_mem_tags(tags);
if (meminfo.nr_banks != 0)
squash_mem_tags(tags); // nr_banks 가 있으면 기존의 tags 메모리 정보를뿌셔버림
save_atags(tags);
parse_tags(tags);
parse_tags(tags);
// arch/arm/include/asm/setup.h
//#define __tag __used __attribute__((__section__(".taglist.init")))
//#define __tagtable(tag, fn) \
//static const struct tagtable __tagtable_##fn __tag = { tag, fn }
//위 define을 사용해서 아래struct 변수를 생성하고 tag이름과 function pointer를 설정함
//ex)arch/arm/kernel/atags_parse.c __tagtable(ATAG_RAMDISK, parse_tag_ramdisk);
//__tagtable_parse_tag_cmdline
//__tagtable_parse_tag_revision
//__tagtable_parse_tag_serialnr
//__tagtable_parse_tag_ramdisk
//__tagtable_parse_tag_videotext
//__tagtable_parse_tag_mem32
//__tagtable_parse_tag_core
//__tagtable_parse_tag_initrd2
//__tagtable_parse_tag_initrd
//__smpalt_begin

}

/* parse_early_param needs a boot_command_line */
Expand Down
13 changes: 8 additions & 5 deletions arch/arm/kernel/setup.c
Expand Up @@ -632,7 +632,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
struct membank *bank = &meminfo.bank[meminfo.nr_banks];
u64 aligned_start;

if (meminfo.nr_banks >= NR_BANKS) {
if (meminfo.nr_banks >= NR_BANKS) { //NR_BANKS = 8 , meminfo.nr_banks는 8보다 작아야함
printk(KERN_CRIT "NR_BANKS too low, "
"ignoring memory at 0x%08llx\n", (long long)start);
return -EINVAL;
Expand Down Expand Up @@ -664,7 +664,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
}
#endif

if (aligned_start < PHYS_OFFSET) {
if (aligned_start < PHYS_OFFSET) { //PHYS_OFFSET = 0x40000000
if (aligned_start + size <= PHYS_OFFSET) {
pr_info("Ignoring memory below PHYS_OFFSET: 0x%08llx-0x%08llx\n",
aligned_start, aligned_start + size);
Expand Down Expand Up @@ -893,9 +893,12 @@ void __init setup_arch(char **cmdline_p)
machine_desc = mdesc;
machine_name = mdesc->name;

setup_dma_zone(mdesc);
setup_dma_zone(mdesc);

if (mdesc->reboot_mode != REBOOT_HARD)

// REBOOT_HARD(cold) : 재부팅시 CPU의 power를 물리적으로 껏다 킴
// REBOOT_SOFT(warm) : 재부팅시 CPU의 Power를 끊지 않고 재부팅
if (mdesc->reboot_mode != REBOOT_HARD) // default = REBOOT_COLD
reboot_mode = mdesc->reboot_mode;

init_mm.start_code = (unsigned long) _text;
Expand All @@ -905,7 +908,7 @@ void __init setup_arch(char **cmdline_p)

/* populate cmd_line too for later use, preserving boot_command_line */
strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
*cmdline_p = cmd_line;
*cmdline_p = cmd_line; //start_kernel의 다른 함수에서도 사용하기위해 cmdline_p에 boot_command_line을 복사

parse_early_param();

Expand Down
2 changes: 1 addition & 1 deletion init/do_mounts.c
Expand Up @@ -37,7 +37,7 @@

int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */

int root_mountflags = MS_RDONLY | MS_SILENT;
int root_mountflags = MS_RDONLY | MS_SILENT; // MS_RDONLY = 1 | MS_SILENT =2^15 = 2^15 + 1
static char * __initdata root_device_name;
static char __initdata saved_root_name[64];
static int root_wait;
Expand Down
2 changes: 2 additions & 0 deletions kernel/params.c
Expand Up @@ -177,6 +177,7 @@ static char *next_arg(char *args, char **param, char **val)
}

/* Args looks like "foo=bar,bar2 baz=fuz wiz". */
// "early_option, cmdline, null, 0, 0, 0, do_early_param"
int parse_args(const char *doing,
char *args,
const struct kernel_param *params,
Expand All @@ -198,6 +199,7 @@ int parse_args(const char *doing,
int irq_was_disabled;

args = next_arg(args, &param, &val);
// 140726 여기까지함
irq_was_disabled = irqs_disabled();
ret = parse_one(param, val, doing, params, num,
min_level, max_level, unknown);
Expand Down

0 comments on commit 2cf0aeb

Please sign in to comment.