예제 #1
0
void setup_arch(char **cmdline_p)
{
	int bootmap_size;
	extern int _stext, _etext;
	extern int _edata, _end;
#ifdef DEBUG
	extern int _sdata, _sbss, _ebss;
#ifdef CONFIG_BLK_DEV_BLKMEM
	extern int *romarray;
#endif
#endif
	unsigned char *psrc=(unsigned char *)((NIOS_FLASH_START + NIOS_FLASH_END)>>1);
	int i=0;

	memory_start = (unsigned long)&_end;
	memory_end = (int) nasys_program_mem_end;

	/* copy the command line from booting paramter region */
	flash_command((int)psrc, 0x555, 0x88);
	while ((*psrc!=0xFF) && (i<sizeof(command_line))) {
		command_line[i++]=*psrc++;
	}
	command_line[i]=0;
	exit_se_flash(((NIOS_FLASH_START + NIOS_FLASH_END)>>1) );
	if (command_line[0]==0)
		memcpy(command_line, default_command_line, sizeof(default_command_line));

	printk("\x0F\r\n\nuClinux/NIOS\n");
	printk("Altera NIOS Excalibur support (C) 2001 Microtronix Datacom Ltd.\n");

#ifdef DEBUG
	printk("KERNEL -> TEXT=0x%08x-0x%08x DATA=0x%08x-0x%08x "
		"BSS=0x%08x-0x%08x\n", (int) &_stext, (int) &_etext,
		(int) &_sdata, (int) &_edata,
		(int) &_sbss, (int) &_ebss);
	printk("KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
		"STACK=0x%06x-0x%06x\n",
#ifdef CONFIG_BLK_DEV_BLKMEM
	       (int) romarray, ((int) romarray) + ntohl(romarray[2]),
#else
	       (int) &_ebss, (int) memory_start,
#endif
		(int) memory_start, (int) memory_end,
		(int) memory_end, (int) nasys_program_mem_end);
#endif

	init_mm.start_code = (unsigned long) &_stext;
	init_mm.end_code = (unsigned long) &_etext;
	init_mm.end_data = (unsigned long) &_edata;
	init_mm.brk = (unsigned long) 0; 
//vic FIXME - this necessary ?
	init_task.thread.kregs = &fake_regs;

#if 0
	ROOT_DEV = MKDEV(BLKMEM_MAJOR,0);
#endif

	/* Keep a copy of command line */
	*cmdline_p = &command_line[0];

	memcpy(saved_command_line, command_line, sizeof(saved_command_line));
	saved_command_line[sizeof(saved_command_line)-1] = 0;

#ifdef DEBUG
	if (strlen(*cmdline_p)) 
		printk("Command line: '%s'\n", *cmdline_p);
	else
		printk("No Command line passed\n");
#endif


#if defined (CONFIG_CS89x0) || (CONFIG_SMC91111)
	/* now read the hwaddr of the ethernet --wentao*/
	flash_command(NIOS_FLASH_START, 0x555, 0x88);
	memcpy(cs8900a_hwaddr_array,(void*)NIOS_FLASH_START,6);
	exit_se_flash(NIOS_FLASH_START);
	/* now do the checking, make sure we got a valid addr */
	if (cs8900a_hwaddr_array[0] & (unsigned char)1)
	{
		printk("Invalid ethernet hardware addr, fixed\n");
		cs8900a_hwaddr_array[0] ^= (unsigned char)1;
	}
	cs8900a_hwaddr=cs8900a_hwaddr_array;
#ifdef DEBUG
	printk("Setup the hardware addr for ethernet\n\t %02x %02x %02x %02x %02x %02x\n",
		cs8900a_hwaddr[0],cs8900a_hwaddr[1],
		cs8900a_hwaddr[2],cs8900a_hwaddr[3],
		cs8900a_hwaddr[4],cs8900a_hwaddr[5]);
#endif
#endif


	/*
	 * give all the memory to the bootmap allocator,  tell it to put the
	 * boot mem_map at the start of memory
	 */
	bootmap_size = init_bootmem_node(
			NODE_DATA(0),
			memory_start >> PAGE_SHIFT, /* map goes here */
			PAGE_OFFSET >> PAGE_SHIFT,	/* 0 on coldfire */
			memory_end >> PAGE_SHIFT);
	/*
	 * free the usable memory,  we have to make sure we do not free
	 * the bootmem bitmap so we then reserve it after freeing it :-)
	 */
	free_bootmem(memory_start, memory_end - memory_start);
	reserve_bootmem(memory_start, bootmap_size);
	/*
	 * get kmalloc into gear
	 */
	paging_init();
#ifdef CONFIG_VT
#if defined(CONFIG_DUMMY_CONSOLE)
	conswitchp = &dummy_con;
#endif
#endif

#ifdef DEBUG
	printk("Done setup_arch\n");
#endif

}
예제 #2
0
void __init setup_arch(char **cmdline_p)
{
	int bootmap_size;
	extern int _stext, _etext;
	extern int _edata, _end;
#ifdef DEBUG
	extern int _sdata, _sbss, _ebss;
#ifdef CONFIG_BLK_DEV_BLKMEM
	extern int *romarray;
#endif
#endif
#if 0							    // krh
	unsigned char *psrc=(unsigned char *)((NIOS_FLASH_START + NIOS_FLASH_END)>>1);
	int i=0;
#endif							    // krh

	memory_start = PAGE_ALIGN((unsigned long)&_end);
	memory_end = (unsigned long) nasys_program_mem_end;

#if 0                                                       //;kenw;
	/* copy the command line from booting paramter region */
    #if defined (nasys_am29lv065d_flash_0)                  //;dgt;
      {                                                     //;dgt;
        // ...TBA...                                        //;dgt;
      }                                                     //;dgt;
    #else                                                   //;dgt;
	    flash_command((int)psrc, 0x555, 0x88);
	    while ((*psrc!=0xFF) && (i<sizeof(command_line))) {
	    	command_line[i++]=*psrc++;
	    }
	    command_line[i]=0;
	    exit_se_flash(((NIOS_FLASH_START + NIOS_FLASH_END)>>1) );
	    if (command_line[0]==0)
    #endif                                                  //;dgt;
#endif                                                      //;kenw;
#ifndef CONFIG_PASS_CMDLINE
		memcpy(command_line, default_command_line, sizeof(default_command_line));
#endif

	printk("\x0F\r\n\nuClinux/Nios II\n");
	printk("Altera Nios II support (C) 2004 Microtronix Datacom Ltd.\n");

#ifdef DEBUG
	printk("KERNEL -> TEXT=0x%08x-0x%08x DATA=0x%08x-0x%08x "
		"BSS=0x%08x-0x%08x\n", (int) &_stext, (int) &_etext,
		(int) &_sdata, (int) &_edata,
		(int) &_sbss, (int) &_ebss);
	printk("KERNEL -> MEM=0x%06x-0x%06x STACK=0x%06x-0x%06x\n",
		(int) memory_start, (int) memory_end,
		(int) memory_end, (int) nasys_program_mem_end);
#endif

	init_mm.start_code = (unsigned long) &_stext;
	init_mm.end_code = (unsigned long) &_etext;
	init_mm.end_data = (unsigned long) &_edata;
	init_mm.brk = (unsigned long) 0;
	init_task.thread.kregs = &fake_regs;

#if 0
	ROOT_DEV = MKDEV(BLKMEM_MAJOR,0);
#endif

	/* Keep a copy of command line */
	*cmdline_p = &command_line[0];

	memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
	boot_command_line[COMMAND_LINE_SIZE-1] = 0;

#ifdef DEBUG
	if (strlen(*cmdline_p))
		printk("Command line: '%s'\n", *cmdline_p);
	else
		printk("No Command line passed\n");
#endif


#if defined (CONFIG_CS89x0) || defined (CONFIG_SMC91111) || defined (CONFIG_OPEN_ETH) || defined (CONFIG_MTIP1000_ETH) || defined (CONFIG_DM9000_ETH) || defined (CONFIG_SMC91X) || defined (CONFIG_DM9000) || defined (CONFIG_DM9KS)

    #if defined (CONFIG_MTIP1000_ETH)                       //;dgt3;
        (*((np_mtip_mac *)                                  //;dgt3;
                (na_mtip_mac_control_port))).               //;dgt3;
                    COMMAND_CONFIG = 0;                     //;dgt3;
    #endif                                                  //;dgt3;

	/* now read the hwaddr of the ethernet --wentao*/

#if defined (na_flash_kernel)
    #if 1                                                   //;dgt2;
//    #if defined (nasys_am29lv065d_flash_0)                //;dgt;
      {                                                     //;dgt;
        unsigned char   *flashptr               =           //;dgt;
            ((unsigned char *)                              //;dgt;
                ((                                          //;dgt;
                  #if defined (na_flash_kernel_end)         //;dgt2;
                      na_flash_kernel_end                   //;dgt2;
                  #else                                     //;dgt2;
                    #if defined (na_flash_kernel_base)      //;dgt2;
                      na_flash_kernel_base      +           //;dgt;
                    #else                                   //;dgt2;
                      na_flash_kernel           +           //;dgt2;
                    #endif                                  //;dgt2;
                      na_flash_kernel_size                  //;dgt2;
                  #endif                                    //;dgt2;
                      - 0x00010000)));                      //;dgt;
          // last 64K of Altera stratix/cyclone flash       //;dgt;
                                                            //;dgt;
        if((*((unsigned long *) flashptr)) == 0x00005AFE)   //;dgt;
          {                                                 //;dgt;
            memcpy(excalibur_enet_hwaddr_array,             //;dgt;
                   ((void*) (flashptr+4)),6);               //;dgt;
          }                                                 //;dgt;
          else                                              //;dgt;
          {                                                 //;dgt;
            printk("\nsetup_arch: No persistant network"    //;dgt;
                        " settings signature at %08lX\n",   //;dgt;
                   ((unsigned long) flashptr));             //;dgt;
            *((unsigned long *)                             //;dgt;
                 (&(excalibur_enet_hwaddr_array[0]))) =     //;dgt;
                    0x00ED0700;                             //;dgt2;
                      /* 0x00-07-ED: Altera Corporation.    //;dgt;     */
            *((unsigned short *)                            //;dgt;
                 (&(excalibur_enet_hwaddr_array[4]))) =     //;dgt;
                    0x0000;                                 //;dgt;
            /* Should be: 0x-00-07-ED-0A-03-(Random# 0-256) //;dgt2;    */
            /* 0x-00-07-ED-0A-xx-yy   Vermont boards        //;dgt2;    */
            /* 0x-00-07-ED-0B-xx-yy   Rhode Island boards   //;dgt2;    */
            /* 0x-00-07-ED-0C-xx-yy   Delaware boards       //;dgt2;    */
            /*                00        Internal Altera     //;dgt2;    */
            /*                01        Beta, pre-production//;dgt2;    */
            /*                02        Beta, pre-production//;dgt2;    */
            /*                03        Customer use        //;dgt2;    */
          }                                                 //;dgt;
      }                                                     //;dgt;
    #else                                                   //;dgt;
	  flash_command(NIOS_FLASH_START, 0x555, 0x88);
	  memcpy(excalibur_enet_hwaddr_array,(void*)NIOS_FLASH_START,6);
	  exit_se_flash(NIOS_FLASH_START);;
    #endif                                                  //;dgt;

	/* now do the checking, make sure we got a valid addr */
	if (excalibur_enet_hwaddr_array[0] & (unsigned char)1)
	{
		printk("Ethernet hardware address:Clearing invalid bit #0\n");
		excalibur_enet_hwaddr_array[0] ^= (unsigned char)1;
	}
#else
	excalibur_enet_hwaddr[0] = 0x00;
	excalibur_enet_hwaddr[1] = 0x07;
	excalibur_enet_hwaddr[2] = 0xed;
	excalibur_enet_hwaddr[3] = 0x0a;
	excalibur_enet_hwaddr[4] = 0x03;
	excalibur_enet_hwaddr[5] = 0x00;
#endif /* defined na_flash_kernel */

	excalibur_enet_hwaddr=excalibur_enet_hwaddr_array;
#ifdef DEBUG
	printk("Setup the hardware addr for ethernet\n\t %02x %02x %02x %02x %02x %02x\n",
		excalibur_enet_hwaddr[0],excalibur_enet_hwaddr[1],
		excalibur_enet_hwaddr[2],excalibur_enet_hwaddr[3],
		excalibur_enet_hwaddr[4],excalibur_enet_hwaddr[5]);
#endif
#endif


	/*
	 * give all the memory to the bootmap allocator,  tell it to put the
	 * boot mem_map at the start of memory
	 */
	bootmap_size = init_bootmem_node(
			NODE_DATA(0),
			memory_start >> PAGE_SHIFT, /* map goes here */
			PAGE_OFFSET >> PAGE_SHIFT,	/* 0 on coldfire */
			memory_end >> PAGE_SHIFT);
	/*
	 * free the usable memory,  we have to make sure we do not free
	 * the bootmem bitmap so we then reserve it after freeing it :-)
	 */
	free_bootmem(memory_start, memory_end - memory_start);
	reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
#ifdef CONFIG_BLK_DEV_INITRD
	if (initrd_start)
		reserve_bootmem(virt_to_phys((void *)initrd_start),
			initrd_end - initrd_start, BOOTMEM_DEFAULT);
#endif /* CONFIG_BLK_DEV_INITRD */
	/*
	 * get kmalloc into gear
	 */
	paging_init();
#ifdef CONFIG_VT
#if defined(CONFIG_DUMMY_CONSOLE)
	conswitchp = &dummy_con;
#endif
#endif

#ifdef DEBUG
	printk("Done setup_arch\n");
#endif

}