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

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