示例#1
0
void __init setup_arch(char **cmdline_p)
{
	unsigned long bootmap_size;
	unsigned long start_pfn, max_pfn, max_low_pfn;

#ifdef CONFIG_EARLY_PRINTK
	extern void enable_early_printk(void);

	enable_early_printk();
#endif
#ifdef CONFIG_CMDLINE_BOOL
        strcpy(COMMAND_LINE, CONFIG_CMDLINE);
#endif

	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);

#ifdef CONFIG_BLK_DEV_RAM
	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
#endif

	if (!MOUNT_ROOT_RDONLY)
		root_mountflags &= ~MS_RDONLY;
	init_mm.start_code = (unsigned long) _text;
	init_mm.end_code = (unsigned long) _etext;
	init_mm.end_data = (unsigned long) _edata;
	init_mm.brk = (unsigned long) _end;

	code_resource.start = virt_to_bus(_text);
	code_resource.end = virt_to_bus(_etext)-1;
	data_resource.start = virt_to_bus(_etext);
	data_resource.end = virt_to_bus(_edata)-1;

	sh_mv_setup(cmdline_p);

#define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
#define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
#define PFN_PHYS(x)	((x) << PAGE_SHIFT)

	/*
	 * Find the highest page frame number we have available
	 */
	max_pfn = PFN_DOWN(__pa(memory_end));

	/*
	 * Determine low and high memory ranges:
	 */
	max_low_pfn = max_pfn;

	/*
	 * Partially used pages are not usable - thus
	 * we are rounding upwards:
	 */
	start_pfn = PFN_UP(__pa(_end));

	/*
	 * Find a proper area for the bootmem bitmap. After this
	 * bootstrap step all allocations (until the page allocator
	 * is intact) must be done via bootmem_alloc().
	 */
	bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
					 __MEMORY_START>>PAGE_SHIFT,
					 max_low_pfn);
	/*
	 * Register fully available low RAM pages with the bootmem allocator.
	 */
	{
		unsigned long curr_pfn, last_pfn, pages;

		/*
		 * We are rounding up the start address of usable memory:
		 */
		curr_pfn = PFN_UP(__MEMORY_START);
		/*
		 * ... and at the end of the usable range downwards:
		 */
		last_pfn = PFN_DOWN(__pa(memory_end));

		if (last_pfn > max_low_pfn)
			last_pfn = max_low_pfn;

		pages = last_pfn - curr_pfn;
		free_bootmem_node(NODE_DATA(0), PFN_PHYS(curr_pfn),
				  PFN_PHYS(pages));
	}

	/*
	 * Reserve the kernel text and
	 * Reserve the bootmem bitmap. We do this in two steps (first step
	 * was init_bootmem()), because this catches the (definitely buggy)
	 * case of us accidentally initializing the bootmem allocator with
	 * an invalid RAM area.
	 */
	reserve_bootmem_node(NODE_DATA(0), __MEMORY_START+PAGE_SIZE,
		(PFN_PHYS(start_pfn)+bootmap_size+PAGE_SIZE-1)-__MEMORY_START);

	/*
	 * reserve physical page 0 - it's a special BIOS page on many boxes,
	 * enabling clean reboots, SMP operation, laptop functions.
	 */
	reserve_bootmem_node(NODE_DATA(0), __MEMORY_START, PAGE_SIZE);

#ifdef CONFIG_BLK_DEV_INITRD
	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
	if (&__rd_start != &__rd_end) {
		LOADER_TYPE = 1;
		INITRD_START = PHYSADDR((unsigned long)&__rd_start) - __MEMORY_START;
		INITRD_SIZE = (unsigned long)&__rd_end - (unsigned long)&__rd_start;
	}

	if (LOADER_TYPE && INITRD_START) {
		if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
			reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE);
			initrd_start =
				INITRD_START ? INITRD_START + PAGE_OFFSET + __MEMORY_START : 0;
			initrd_end = initrd_start + INITRD_SIZE;
		} else {
			printk("initrd extends beyond end of memory "
			    "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
				    INITRD_START + INITRD_SIZE,
				    max_low_pfn << PAGE_SHIFT);
			initrd_start = 0;
		}
	}
#endif

#ifdef CONFIG_DUMMY_CONSOLE
	conswitchp = &dummy_con;
#endif

	/* Perform the machine specific initialisation */
	platform_setup();

	paging_init();
}
示例#2
0
文件: setup.c 项目: CSU-GH/okl4_3.0
/*
 * Setup L4 architecture requirements:
 *   kip_area, utcb_area, physical memory, current,
 * Init user address space, ramdisk, console, early consle
 */
void __init
setup_arch (char **command_line)
{
    unsigned long base, area;

#if defined(CONFIG_IGUANA)
    setup_tls(1);
#endif

    /* Return the command line to the rest of the kernel */
    boot_command_line[COMMAND_LINE_SIZE-1] = '\0';
    *command_line = boot_command_line;

    if (L4_UtcbIsKernelManaged()) {
        utcb_area = L4_Nilpage;
    } else {
        /* Currently hardcoded to 1024 L4 threads per linux
         * user address space */
        area = L4_GetUtcbSize() * 1024;

        /*
             * Find some area to put the utcb in outside user's
             * area.  When the KIP was present, 16 pages were
             * reserved for it, so keep the same spacing here
             * because the equation is not fully understood.
             */
        base = PAGE_ALIGN(TASK_SIZE) + 16 * PAGE_SIZE  + area;
        /* Round address to the 'area' boundary. */
        base = (base + (area-1)) & (~(area-1));

        utcb_area = L4_Fpage(base, L4_GetUtcbSize() * 1024);
    }

    /* Initialise our machine name */
    setup_machine_name();

    /* FIXME: (why?) */
    start_phys_mem = __pa(start_phys_mem);
    end_phys_mem = __pa(end_phys_mem);

    /* Initialise paging */
    paging_init();

    /* Thread info setup. */
    /* FIXME:  remember for SMP startup */
    current_tinfo(smp_processor_id()) =
        (unsigned long)&init_thread_union.thread_info;
    task_thread_info(current)->user_tid = L4_nilthread;
    task_thread_info(current)->user_handle = L4_nilthread;

#ifdef CONFIG_EARLY_PRINTK
    /* early console initialisation */
    enable_early_printk();
#endif

    /* Ramdisk setup */
#ifdef CONFIG_BLK_DEV_INITRD
    /* Board specific code should have set up initrd_start and initrd_end */
    ROOT_DEV = Root_RAM0;
    /* FIXME! */
    initrd_start = 0; //naming_lookup("ramdisk");
    initrd_end = 0; //naming_lookup("ramdisk_end");
    printk("end: %lx\n", initrd_end);
    initrd_below_start_ok = 1;

    if (initrd_start) {
        unsigned long initrd_size =
            ((unsigned char *)initrd_end) -
            ((unsigned char *)initrd_start);
        printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
               (void *)initrd_start, initrd_size);
    }
#endif /* CONFIG_BLK_DEV_INITRD  */

#ifdef CONFIG_VT
#if defined(CONFIG_VGA_CONSOLE)
    __setup_vga();
    conswitchp = &vga_con;
#elif defined(CONFIG_DUMMY_CONSOLE)
    conswitchp = &dummy_con;
#endif /* CONFIG_VGA_CONSOLE */
    screen_info.lfb_base	= 0xe000000;
    screen_info.lfb_size	= 600*800;
    screen_info.lfb_height	= 600;
    screen_info.lfb_width	= 800;
#endif /* CONFIG_VT */

    panic_timeout = 1;

#if defined(CONFIG_CELL)
    /* L4-specific -gl,cvs */
    {
        extern unsigned long TIMER_BASE, SERIAL_BASE;
        okl4_env_lookup_address("MAIN_TIMER_MEM0", &TIMER_BASE);
        okl4_env_lookup_address("MAIN_SERIAL_MEM0", &SERIAL_BASE);
    }
#if defined(CONFIG_VERSATILE)
    {
        extern unsigned long ETH_BASE, CLCD_BASE, VERSATILE_SYS_BASE,
               KMI0_BASE, KMI1_BASE;
        okl4_env_lookup_address("MAIN_ETH_MEM0", &ETH_BASE);
        okl4_env_lookup_address("MAIN_VERSATILESYS_MEM0", &VERSATILE_SYS_BASE);
        okl4_env_lookup_address("MAIN_CLCD_MEM0", &CLCD_BASE);
        okl4_env_lookup_address("MAIN_KMI0_MEM0", &KMI0_BASE);
        okl4_env_lookup_address("MAIN_KMI1_MEM0", &KMI1_BASE);
    }
#endif
#if defined(CONFIG_ARCH_GUMSTIX)
    {
        extern unsigned long GPIO_BASE, DMAC_BASE;
        extern unsigned long PXA_CS1_PHYS, PXA_CS1_DMA;
        extern unsigned long PXA_CS2_PHYS, PXA_CS2_DMA;
        okl4_env_lookup_address("MAIN_GPIO_MEM0", &GPIO_BASE);
        okl4_env_lookup_address("MAIN_DMA_MEM0", &DMAC_BASE);
        okl4_env_lookup_address("MAIN_CS_MEM1", &PXA_CS1_PHYS);
        okl4_env_lookup_address("MAIN_CS_MEM2", &PXA_CS2_PHYS);

        PXA_CS1_DMA = *((unsigned long *)okl4_env_get("cs_mem1_physical"));
        PXA_CS2_DMA = *((unsigned long *)okl4_env_get("cs_mem2_physical"));
    }
#endif

#endif	/*CELL*/
}