bootparse.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #include <linux/string.h>
  2. #include <linux/kernel.h>
  3. #include <linux/sched.h>
  4. #include <asm/irq.h>
  5. #include <asm/setup.h>
  6. #include <asm/bootinfo.h>
  7. #include <asm/macintosh.h>
  8. /*
  9.  * Booter vars
  10.  */
  11.  
  12. int boothowto;
  13. int _boothowto;
  14.  
  15. /*
  16.  * Called early to parse the environment (passed to us from the booter)
  17.  * into a bootinfo struct. Will die as soon as we have our own booter
  18.  */
  19. #define atol(x) simple_strtoul(x,NULL,0)
  20.  
  21. void parse_booter(char *env)
  22. {
  23.   char *name;
  24.   char *value;
  25. #if 0
  26.   while(0 && *env)
  27. #else
  28.   while(*env)
  29. #endif
  30.   {
  31.   name=env;
  32.   value=name;
  33.   while(*value!='='&&*value)
  34.   value++;
  35.   if(*value=='=')
  36.   *value++=0;
  37.   env=value;
  38.   while(*env)
  39.   env++;
  40.   env++;
  41. #if 0 
  42.   if(strcmp(name,"VIDEO_ADDR")==0)
  43.   mac_mch.videoaddr=atol(value);
  44.   if(strcmp(name,"ROW_BYTES")==0)
  45.   mac_mch.videorow=atol(value); 
  46.   if(strcmp(name,"SCREEN_DEPTH")==0)
  47.   mac_mch.videodepth=atol(value);
  48.   if(strcmp(name,"DIMENSIONS")==0)
  49.   mac_mch.dimensions=atol(value);
  50. #endif 
  51.   if(strcmp(name,"BOOTTIME")==0)
  52.   mac_bi_data.boottime=atol(value);
  53.   if(strcmp(name,"GMTBIAS")==0)
  54.   mac_bi_data.gmtbias=atol(value);
  55.   if(strcmp(name,"BOOTERVER")==0)
  56.   mac_bi_data.bootver=atol(value);
  57.   if(strcmp(name,"MACOS_VIDEO")==0)
  58.   mac_bi_data.videological=atol(value);
  59.   if(strcmp(name,"MACOS_SCC")==0)
  60.   mac_bi_data.sccbase=atol(value);
  61.   if(strcmp(name,"MACHINEID")==0)
  62.   mac_bi_data.id=atol(value);
  63.   if(strcmp(name,"MEMSIZE")==0)
  64.   mac_bi_data.memsize=atol(value);
  65.   if(strcmp(name,"SERIAL_MODEM_FLAGS")==0)
  66.   mac_bi_data.serialmf=atol(value);
  67.   if(strcmp(name,"SERIAL_MODEM_HSKICLK")==0)
  68.   mac_bi_data.serialhsk=atol(value);
  69.   if(strcmp(name,"SERIAL_MODEM_GPICLK")==0)
  70.   mac_bi_data.serialgpi=atol(value);
  71.   if(strcmp(name,"SERIAL_PRINT_FLAGS")==0)
  72.   mac_bi_data.printmf=atol(value);
  73.   if(strcmp(name,"SERIAL_PRINT_HSKICLK")==0)
  74.   mac_bi_data.printhsk=atol(value);
  75.   if(strcmp(name,"SERIAL_PRINT_GPICLK")==0)
  76.   mac_bi_data.printgpi=atol(value);
  77.   if(strcmp(name,"PROCESSOR")==0)
  78.   mac_bi_data.cpuid=atol(value);
  79.   if(strcmp(name,"ROMBASE")==0)
  80.   mac_bi_data.rombase=atol(value);
  81.   if(strcmp(name,"TIMEDBRA")==0)
  82.   mac_bi_data.timedbra=atol(value);
  83.   if(strcmp(name,"ADBDELAY")==0)
  84.   mac_bi_data.adbdelay=atol(value);
  85.   }
  86. #if 0 /* XXX: TODO with m68k_mach_* */
  87.   /* Fill in the base stuff */
  88.   boot_info.machtype=MACH_MAC;
  89.   /* Read this from the macinfo we got ! */
  90. /* boot_info.cputype=CPU_68020|FPUB_68881;*/
  91. /*  boot_info.memory[0].addr=0;*/
  92. /*  boot_info.memory[0].size=((mac_bi_data.id>>7)&31)<<20;*/
  93.   boot_info.num_memory=1; /* On a MacII */
  94.   boot_info.ramdisk_size=0; /* For now */
  95.   *boot_info.command_line=0;
  96. #endif
  97.  }
  98.  
  99. void print_booter(char *env)
  100. {
  101.   char *name;
  102.   char *value;
  103.   while(*env)
  104.   {
  105.   name=env;
  106.   value=name;
  107.   while(*value!='='&&*value)
  108.   value++;
  109.   if(*value=='=')
  110.   *value++=0;
  111.   env=value;
  112.   while(*env)
  113.   env++;
  114.   env++;
  115.   printk("%s=%sn", name,value);
  116.   }
  117.  }
  118.