root/arch/i386/kernel/setup.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. setup_arch
  2. i486model
  3. i586model
  4. getmodel
  5. get_cpuinfo

   1 /*
   2  *  linux/arch/i386/kernel/setup.c
   3  *
   4  *  Copyright (C) 1995  Linus Torvalds
   5  */
   6 
   7 /*
   8  * This file handles the architecture-dependent parts of initialization
   9  */
  10 
  11 #include <linux/errno.h>
  12 #include <linux/sched.h>
  13 #include <linux/kernel.h>
  14 #include <linux/mm.h>
  15 #include <linux/stddef.h>
  16 #include <linux/unistd.h>
  17 #include <linux/ptrace.h>
  18 #include <linux/malloc.h>
  19 #include <linux/ldt.h>
  20 #include <linux/user.h>
  21 #include <linux/a.out.h>
  22 #include <linux/tty.h>
  23 #include <linux/ioport.h>
  24 #include <linux/delay.h>
  25 #include <linux/config.h>
  26 
  27 #include <asm/segment.h>
  28 #include <asm/system.h>
  29 #include <asm/smp.h>
  30 
  31 /*
  32  * Tell us the machine setup..
  33  */
  34 char hard_math = 0;             /* set by boot/head.S */
  35 char x86 = 0;                   /* set by boot/head.S to 3 or 4 */
  36 char x86_model = 0;             /* set by boot/head.S */
  37 char x86_mask = 0;              /* set by boot/head.S */
  38 int x86_capability = 0;         /* set by boot/head.S */
  39 int fdiv_bug = 0;               /* set if Pentium(TM) with FP bug */
  40 
  41 char x86_vendor_id[13] = "Unknown";
  42 
  43 char ignore_irq13 = 0;          /* set if exception 16 works */
  44 char wp_works_ok = -1;          /* set if paging hardware honours WP */ 
  45 char hlt_works_ok = 1;          /* set if the "hlt" instruction works */
  46 
  47 /*
  48  * Bus types ..
  49  */
  50 int EISA_bus = 0;
  51 
  52 /*
  53  * Setup options
  54  */
  55 struct drive_info_struct { char dummy[32]; } drive_info;
  56 struct screen_info screen_info;
  57 
  58 unsigned char aux_device_present;
  59 extern int ramdisk_size;
  60 extern int root_mountflags;
  61 extern int _etext, _edata, _end;
  62 
  63 extern char empty_zero_page[PAGE_SIZE];
  64 
  65 /*
  66  * This is set up by the setup-routine at boot-time
  67  */
  68 #define PARAM   empty_zero_page
  69 #define EXT_MEM_K (*(unsigned short *) (PARAM+2))
  70 #define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
  71 #define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
  72 #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
  73 #define RAMDISK_SIZE (*(unsigned short *) (PARAM+0x1F8))
  74 #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
  75 #define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
  76 #define COMMAND_LINE ((char *) (PARAM+2048))
  77 #define COMMAND_LINE_SIZE 256
  78 
  79 static char command_line[COMMAND_LINE_SIZE] = { 0, };
  80 
  81 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
  82         unsigned long * memory_start_p, unsigned long * memory_end_p)
  83 {
  84         unsigned long memory_start, memory_end;
  85         char c = ' ', *to = command_line, *from = COMMAND_LINE;
  86         int len = 0;
  87         static unsigned char smptrap=0;
  88 
  89         if(smptrap==1)
  90         {
  91                 return;
  92         }
  93         smptrap=1;
  94 
  95         ROOT_DEV = to_kdev_t(ORIG_ROOT_DEV);
  96         drive_info = DRIVE_INFO;
  97         screen_info = SCREEN_INFO;
  98         aux_device_present = AUX_DEVICE_INFO;
  99         memory_end = (1<<20) + (EXT_MEM_K<<10);
 100         memory_end &= PAGE_MASK;
 101         ramdisk_size = RAMDISK_SIZE;
 102 #ifdef CONFIG_MAX_16M
 103         if (memory_end > 16*1024*1024)
 104                 memory_end = 16*1024*1024;
 105 #endif
 106         if (!MOUNT_ROOT_RDONLY)
 107                 root_mountflags &= ~MS_RDONLY;
 108         memory_start = (unsigned long) &_end;
 109         init_task.mm->start_code = TASK_SIZE;
 110         init_task.mm->end_code = TASK_SIZE + (unsigned long) &_etext;
 111         init_task.mm->end_data = TASK_SIZE + (unsigned long) &_edata;
 112         init_task.mm->brk = TASK_SIZE + (unsigned long) &_end;
 113 
 114         for (;;) {
 115                 /*
 116                  * "mem=nopentium" disables the 4MB page tables.
 117                  * "mem=XXX[kKmM]" overrides the BIOS-reported
 118                  * memory size
 119                  */
 120                 if (c == ' ' && *(const unsigned long *)from == *(const unsigned long *)"mem=") {
 121                         if (!memcmp(from+4, "nopentium", 9)) {
 122                                 from += 9+4;
 123                                 x86_capability &= ~8;
 124                         } else {
 125                                 memory_end = simple_strtoul(from+4, &from, 0);
 126                                 if ( *from == 'K' || *from == 'k' ) {
 127                                         memory_end = memory_end << 10;
 128                                         from++;
 129                                 } else if ( *from == 'M' || *from == 'm' ) {
 130                                         memory_end = memory_end << 20;
 131                                         from++;
 132                                 }
 133                         }
 134                 }
 135                 c = *(from++);
 136                 if (!c)
 137                         break;
 138                 if (COMMAND_LINE_SIZE <= ++len)
 139                         break;
 140                 *(to++) = c;
 141         }
 142         *to = '\0';
 143         *cmdline_p = command_line;
 144         *memory_start_p = memory_start;
 145         *memory_end_p = memory_end;
 146         /* request io space for devices used on all i[345]86 PC'S */
 147         request_region(0x00,0x20,"dma1");
 148         request_region(0x40,0x20,"timer");
 149         request_region(0x70,0x10,"rtc");
 150         request_region(0x80,0x20,"dma page reg");
 151         request_region(0xc0,0x20,"dma2");
 152         request_region(0xf0,0x10,"npu");
 153 }
 154 
 155 static const char * i486model(unsigned int nr)
     /* [previous][next][first][last][top][bottom][index][help] */
 156 {
 157         static const char *model[] = {
 158                 "0", "DX","SX","DX/2","4","SX/2","6","DX/2-WB","DX/4"
 159         };
 160         if (nr < sizeof(model)/sizeof(char *))
 161                 return model[nr];
 162         return "Unknown";
 163 }
 164 
 165 static const char * i586model(unsigned int nr)
     /* [previous][next][first][last][top][bottom][index][help] */
 166 {
 167         static const char *model[] = {
 168                 "0", "Pentium 60/66","Pentium 75+"
 169         };
 170         if (nr < sizeof(model)/sizeof(char *))
 171                 return model[nr];
 172         return "Unknown";
 173 }
 174 
 175 static const char * getmodel(int x86, int model)
     /* [previous][next][first][last][top][bottom][index][help] */
 176 {
 177         switch (x86) {
 178                 case 4:
 179                         return i486model(model);
 180                 case 5:
 181                         return i586model(model);
 182         }
 183         return "Unknown";
 184 }
 185 
 186 int get_cpuinfo(char * buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 187 {
 188         char mask[2];
 189 #ifndef __SMP__ 
 190         mask[0] = x86_mask+'@';
 191         mask[1] = '\0';
 192         return sprintf(buffer,"cpu\t\t: %c86\n"
 193                               "model\t\t: %s\n"
 194                               "mask\t\t: %s\n"
 195                               "vid\t\t: %s\n"
 196                               "fdiv_bug\t: %s\n"
 197                               "math\t\t: %s\n"
 198                               "hlt\t\t: %s\n"
 199                               "wp\t\t: %s\n"
 200                               "Integrated NPU\t: %s\n"
 201                               "Enhanced VM86\t: %s\n"
 202                               "IO Breakpoints\t: %s\n"
 203                               "4MB Pages\t: %s\n"
 204                               "TS Counters\t: %s\n"
 205                               "Pentium MSR\t: %s\n"
 206                               "Mach. Ch. Exep.\t: %s\n"
 207                               "CMPXCHGB8B\t: %s\n"
 208                               "BogoMips\t: %lu.%02lu\n",
 209                               x86+'0', 
 210                               getmodel(x86, x86_model),
 211                               x86_mask ? mask : "Unknown",
 212                               x86_vendor_id,
 213                               fdiv_bug ? "yes" : "no",
 214                               hard_math ? "yes" : "no",
 215                               hlt_works_ok ? "yes" : "no",
 216                               wp_works_ok ? "yes" : "no",
 217                               x86_capability & 1 ? "yes" : "no",
 218                               x86_capability & 2 ? "yes" : "no",
 219                               x86_capability & 4 ? "yes" : "no",
 220                               x86_capability & 8 ? "yes" : "no",
 221                               x86_capability & 16 ? "yes" : "no",
 222                               x86_capability & 32 ? "yes" : "no",
 223                               x86_capability & 128 ? "yes" : "no",
 224                               x86_capability & 256 ? "yes" : "no",
 225                               loops_per_sec/500000, (loops_per_sec/5000) % 100
 226                               );
 227 #else
 228         char *bp=buffer;
 229         int i;  
 230         bp+=sprintf(bp,"cpu\t\t: ");
 231         for(i=0;i<32;i++)
 232                 if(cpu_present_map&(1<<i))
 233                         bp+=sprintf(bp,"%c86             ",cpu_data[i].x86+'0');
 234         bp+=sprintf(bp,"\nmodel\t\t: ");
 235         for(i=0;i<32;i++)
 236                 if(cpu_present_map&(1<<i))
 237                         bp+=sprintf(bp,"%-16s",getmodel(cpu_data[i].x86,cpu_data[i].x86_model));
 238         bp+=sprintf(bp,"\nmask\t\t: ");
 239         for(i=0;i<32;i++)
 240                 if(cpu_present_map&(1<<i))
 241                 {
 242                         mask[0] = cpu_data[i].x86_mask+'@';
 243                         mask[1] = '\0';         
 244                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_mask ? mask : "Unknown");
 245                 }
 246         bp+=sprintf(bp,"\nvid\t\t: ");
 247         for(i=0;i<32;i++)
 248                 if(cpu_present_map&(1<<i))
 249                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_vendor_id);
 250         bp+=sprintf(bp,"\nfdiv_bug\t: ");
 251         for(i=0;i<32;i++)
 252                 if(cpu_present_map&(1<<i))
 253                         bp+=sprintf(bp,"%-16s", cpu_data[i].fdiv_bug?"yes":"no");
 254         bp+=sprintf(bp,"\nmath\t\t: ");
 255         for(i=0;i<32;i++)
 256                 if(cpu_present_map&(1<<i))
 257                         bp+=sprintf(bp,"%-16s", cpu_data[i].hard_math?"yes":"no");
 258         bp+=sprintf(bp,"\nhlt\t\t: ");
 259         for(i=0;i<32;i++)
 260                 if(cpu_present_map&(1<<i))
 261                         bp+=sprintf(bp,"%-16s", cpu_data[i].hlt_works_ok?"yes":"no");
 262         bp+=sprintf(bp,"\nwp\t\t: ");
 263         for(i=0;i<32;i++)
 264                 if(cpu_present_map&(1<<i))
 265                         bp+=sprintf(bp,"%-16s", cpu_data[i].wp_works_ok?"yes":"no");
 266         bp+=sprintf(bp,"\nIntegrated NPU\t: ");
 267         for(i=0;i<32;i++)
 268                 if(cpu_present_map&(1<<i))
 269                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&1?"yes":"no");
 270         bp+=sprintf(bp,"\nEnhanced VM86\t: ");
 271         for(i=0;i<32;i++)
 272                 if(cpu_present_map&(1<<i))
 273                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&2?"yes":"no");
 274         bp+=sprintf(bp,"\nIO Breakpoints\t: ");
 275         for(i=0;i<32;i++)
 276                 if(cpu_present_map&(1<<i))
 277                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&4)?"yes":"no");
 278         bp+=sprintf(bp,"\n4MB Pages\t: ");
 279         for(i=0;i<32;i++)
 280                 if(cpu_present_map&(1<<i))
 281                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability)&8?"yes":"no");
 282         bp+=sprintf(bp,"\nTS Counters\t: ");
 283         for(i=0;i<32;i++)
 284                 if(cpu_present_map&(1<<i))
 285                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&16)?"yes":"no");
 286         bp+=sprintf(bp,"\nPentium MSR\t: ");
 287         for(i=0;i<32;i++)
 288                 if(cpu_present_map&(1<<i))
 289                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&32)?"yes":"no");
 290         bp+=sprintf(bp,"\nMach. Ch. Exep.\t: ");
 291         for(i=0;i<32;i++)
 292                 if(cpu_present_map&(1<<i))
 293                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&128)?"yes":"no");
 294         bp+=sprintf(bp,"\nCMPXCHG8B\t: ");
 295         for(i=0;i<32;i++)
 296                 if(cpu_present_map&(1<<i))
 297                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&256)?"yes":"no");
 298         bp+=sprintf(bp,"\nBogoMips\t: ");
 299         for(i=0;i<32;i++)
 300         {
 301                 char tmp[17];
 302                 if(cpu_present_map&(1<<i))
 303                 {
 304                         sprintf(tmp,"%lu.%02lu",cpu_data[i].udelay_val/500000L,
 305                                                    (cpu_data[i].udelay_val/5000L)%100);
 306                         bp+=sprintf(bp,"%-16s",tmp);
 307                 }
 308         }
 309         *bp++='\n';
 310         return bp-buffer;
 311 #endif                        
 312 }

/* [previous][next][first][last][top][bottom][index][help] */