📄 00000000.htm
字号:
entation of this function. $(TOPDIR)/include/asm/bootinfo.h contains entries <br /> for the cputype (MYCPU) and machine group (MY_MACH_GROUP). The mips_ cputyp <br />e variable has to be updated in the cpu_probe function. This value is used l <br />ater to determine the exception handling and MMU routines that need to be lo <br />aded for the given CPU, as well as to get the CPU information in the /proc f <br />ile system. <br />Listing 2: Code to probe cputype <br />LEAF(cpu_probe) <br />la t3, mips_cputype <br />li t2, MYCPU /* include/asm-mips/bootinfo.h */ <br />b probe_done <br />sw t2, (t3) <br />END(cpu_probe) <br />The initial stack for the kernel is set up next. Then the bss section of the <br /> kernel image is cleared. Control then transfers to the prom_init() function <br />. Then the TLB and caches are flushed and the cache manipulation functions a <br />re set up inside loadmmu(). Disabling of the coprocessors other than coproce <br />ssor 0 is done next, followed by a jump to start_kernel(). <br />$(TOPDIR)/arch/MY_ARCH/mm contains the TLB routines and cache handling routi <br />nes. <br />Platform specific changes to the kernel code <br />$(TOPDIR)/arch/MY_ARCH has a sub-directory for each target development platf <br />orm that is supported. Create a MY_PLATFORM directory by copying a platform <br />closest to your configuration. This directory should contain the interrupt h <br />andling, timer, initialization, and setup routines for your specific platfor <br />m. Create a MY_PLATFORM directory under $(TOPDIR)/include/asm. This director <br />y is used to hold include files specific to your platform. <br />The prom_init() function, which is part of $(TOPDIR)/arch/MY_ARCH/MY_PLATFOR <br />M/prom.c (Listing 3), modifies the command line string to add parameters tha <br />t need to be passed to the kernel from the bootloader. The machine group and <br /> upper bound of usable memory are set up here. <br />Listing 3: PROM initialization <br />int __init prom_init (int argc, char **argv, char **envp) <br />{ <br />unsigned int mem_limit; <br />// set upper limit to maximum physical RAM (32MB) <br />mem_limit = 32 * 1024 * 1024; <br />// the bootloader usually passes us argc/argv[ ]. <br />//In the present case, these arguments are not <br />//passed from the bootloader. The kernel wants <br />// one big string. put it in arcs_cmdline, which <br />later gets copied to command_line <br />//(see arch/mips/kernel/setup.c) <br />strcpy (arcs_cmdline, *root=/dev/ram*); <br />mips_machgroup = MY_MACH_GROUP; <br />// set the upper bound of usable memory <br />mips_memory_upper = KSEG0 + mem_limit; <br />printk(*Detected %dMB of memory\n*, mem_limit >> 20); <br />return 0; <br />} <br />Starting the kernel <br />Listing 4 contains the first few interesting lines of the start_kernel() fun <br />ction, located in $(TOPDIR)/init/main.c. <br />Listing 4: The beginning of the start_kernel function <br />asmlinkage void __init start_kernel(void) <br />{ <br />char * command_line; <br />/* <br />* Interrupts are still disabled. Do necessary setups, then <br />* enable them <br />*/ <br />lock_kernel(); <br />printk(linux_banner); <br />setup_arch(&command_line, &memory_start, &memory_end); <br />memory_start = paging_init(memory_start, memory_end); <br />trap_init(); <br />init_IRQ(); <br />sched_init(); <br />time_init(); <br />parse_options(command_line); <br />. <br />. <br />. <br />Listing 5 shows the setup_arch() function in $(TOPDIR)/arch/MY_ARCH/kernel/s <br />etup.c. The board-specific setup function is called from here. The command l <br />ine string and memory start and memory end are passed over to the caller of <br />this function. The start and end addresses for the linked-in ramdisk image a <br />re also updated here. <br />Listing 5: Architecture setup function <br />__initfunc(void setup_arch(char **cmdline_p, <br />unsigned long * memory_start_p, <br />unsigned long * memory_end_p)) <br />{ <br />#ifdef CONFIG_BLK_DEV_INITRD <br />#if CONFIG_BLK_DEV_INITRD_OFILE <br />extern void *__rd_start, *__rd_end; <br />#endif <br />#endif <br />myplatform_setup(); <br />strncpy(command_line, arcs_cmdline, CL_SIZE); <br />*cmdline_p = command_line; <br />*memory_start_p = (unsigned_long) &_end; <br />*memory_end_p = mips_memory_upper; <br />#ifdef CONFIG_BLK_DEV_INITRD <br />#if CONFIG_BLK_DEV_INITRD_OFILE <br />// Use the linked-in ramdisk <br />// image located at __rd_start. <br />initrd_start = (unsigned long)&__rd_start; <br />initrd_end = (unsigned long)&__rd_end; <br />initrd_below_start_ok = 1; <br />if (initrd_end > memory_end) <br />{ <br />printk(*initrd extends beyond end of memory * <br />*(0x%08lx > 0x%08lx)\ndisabling initrd\n*, <br />initrd_end, memory_end); <br />initrd_start = 0; <br />} <br />#endif <br />#endif <br />} <br />$(TOPDIR)/arch/MY_ARCH/MY_PLATFORM/setup.c contains the platform-specific in <br />itialization code (Listing 6). Here, the various base addresses and the plat <br />form-specific RTC and PCI operations are set up. For PCI, the following seve <br />n functions need to be implemented for the given platform: <br />Listing 6: Platform-specific initialization code <br />__initfunc(void myplatform_setup(void)) <br />{ <br />irq_setup = myplatform_irq_setup; <br />/* <br />* mips_io_port_base is the beginning <br />*of the address space to which x86 <br />* style I/O ports are mapped. <br />*/ <br />mips_io_port_base = 0xa0000000; <br />/* <br />* platform_io_mem_base is the <br />*beginning of I/O bus memory space as <br />* seen from the physical address bus. <br />*This may or may not be ident- <br />* ical to mips_io_port_base, e.g. the <br />*former could point to the beginning of PCI <br />*memory space while the latter might <br />*indicate PCI I/O space. The two values are <br />*used in different sets of macros. This <br />* must be set to a correct value by the <br />*platform setup code. <br />*/ <br />platform_io_mem_base=0x10000000; <br />/* <br />* platform_mem_iobus_base is the <br />*beginning of main memory as seen <br />* from the I/O bus, and must be set <br />*by the platform setup code. <br />*/ <br />platform_mem_iobus_base=0x0; <br />#ifdef CONFIG_REMOTE_DEBUG <br />/* <br />* Do the minimum necessary to set up debugging <br />*/ <br />myplatform_kgdb_hook(0); <br />remote_debug = 1; <br />#endif <br />#ifdef CONFIG_BLK_DEV_IDE <br />
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -