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. 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 process handling..
   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 int get_cpuinfo(char * buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 156 {
 157         static const char *model[2][9]={{"DX","SX","DX/2","4","SX/2","6",
 158                                 "DX/2-WB","DX/4"},
 159                         {"Pentium 60/66","Pentium 75+","3",
 160                                 "4","5","6","7","8"}};
 161         char mask[2];
 162 #ifndef CONFIG_SMP      
 163         mask[0] = x86_mask+'@';
 164         mask[1] = '\0';
 165         return sprintf(buffer,"cpu\t\t: %c86\n"
 166                               "model\t\t: %s\n"
 167                               "mask\t\t: %s\n"
 168                               "vid\t\t: %s\n"
 169                               "fdiv_bug\t: %s\n"
 170                               "math\t\t: %s\n"
 171                               "hlt\t\t: %s\n"
 172                               "wp\t\t: %s\n"
 173                               "Integrated NPU\t: %s\n"
 174                               "Enhanced VM86\t: %s\n"
 175                               "IO Breakpoints\t: %s\n"
 176                               "4MB Pages\t: %s\n"
 177                               "TS Counters\t: %s\n"
 178                               "Pentium MSR\t: %s\n"
 179                               "Mach. Ch. Exep.\t: %s\n"
 180                               "CMPXCHGB8B\t: %s\n"
 181                               "BogoMips\t: %lu.%02lu\n",
 182                               x86+'0', 
 183                               x86_model ? model[x86-4][x86_model-1] : "Unknown",
 184                               x86_mask ? mask : "Unknown",
 185                               x86_vendor_id,
 186                               fdiv_bug ? "yes" : "no",
 187                               hard_math ? "yes" : "no",
 188                               hlt_works_ok ? "yes" : "no",
 189                               wp_works_ok ? "yes" : "no",
 190                               x86_capability & 1 ? "yes" : "no",
 191                               x86_capability & 2 ? "yes" : "no",
 192                               x86_capability & 4 ? "yes" : "no",
 193                               x86_capability & 8 ? "yes" : "no",
 194                               x86_capability & 16 ? "yes" : "no",
 195                               x86_capability & 32 ? "yes" : "no",
 196                               x86_capability & 128 ? "yes" : "no",
 197                               x86_capability & 256 ? "yes" : "no",
 198                               loops_per_sec/500000, (loops_per_sec/5000) % 100
 199                               );
 200 #else
 201         char *bp=buffer;
 202         int i;  
 203         bp+=sprintf(bp,"cpu\t\t: ");
 204         for(i=0;i<32;i++)
 205                 if(cpu_present_map&(1<<i))
 206                         bp+=sprintf(bp,"%c86             ",cpu_data[i].x86+'0');
 207         bp+=sprintf(bp,"\nmodel\t\t: ");
 208         for(i=0;i<32;i++)
 209                 if(cpu_present_map&(1<<i))
 210                         bp+=sprintf(bp,"%-16s",cpu_data[i].x86_model?
 211                                         model[cpu_data[i].x86-4][cpu_data[i].x86_model-1]:"Unknown");
 212         bp+=sprintf(bp,"\nmask\t\t: ");
 213         for(i=0;i<32;i++)
 214                 if(cpu_present_map&(1<<i))
 215                 {
 216                         mask[0] = cpu_data[i].x86_mask+'@';
 217                         mask[1] = '\0';         
 218                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_mask ? mask : "Unknown");
 219                 }
 220         bp+=sprintf(bp,"\nvid\t\t: ");
 221         for(i=0;i<32;i++)
 222                 if(cpu_present_map&(1<<i))
 223                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_vendor_id);
 224         bp+=sprintf(bp,"\nfdiv_bug\t: ");
 225         for(i=0;i<32;i++)
 226                 if(cpu_present_map&(1<<i))
 227                         bp+=sprintf(bp,"%-16s", cpu_data[i].fdiv_bug?"yes":"no");
 228         bp+=sprintf(bp,"\nmath\t\t: ");
 229         for(i=0;i<32;i++)
 230                 if(cpu_present_map&(1<<i))
 231                         bp+=sprintf(bp,"%-16s", cpu_data[i].hard_math?"yes":"no");
 232         bp+=sprintf(bp,"\nhlt\t\t: ");
 233         for(i=0;i<32;i++)
 234                 if(cpu_present_map&(1<<i))
 235                         bp+=sprintf(bp,"%-16s", cpu_data[i].hlt_works_ok?"yes":"no");
 236         bp+=sprintf(bp,"\nwp\t\t: ");
 237         for(i=0;i<32;i++)
 238                 if(cpu_present_map&(1<<i))
 239                         bp+=sprintf(bp,"%-16s", cpu_data[i].wp_works_ok?"yes":"no");
 240         bp+=sprintf(bp,"\nIntegrated NPU\t: ");
 241         for(i=0;i<32;i++)
 242                 if(cpu_present_map&(1<<i))
 243                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&1?"yes":"no");
 244         bp+=sprintf(bp,"\nEnhanced VM86\t: ");
 245         for(i=0;i<32;i++)
 246                 if(cpu_present_map&(1<<i))
 247                         bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&2?"yes":"no");
 248         bp+=sprintf(bp,"\nIO Breakpoints\t: ");
 249         for(i=0;i<32;i++)
 250                 if(cpu_present_map&(1<<i))
 251                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&4)?"yes":"no");
 252         bp+=sprintf(bp,"\n4MB Pages\t: ");
 253         for(i=0;i<32;i++)
 254                 if(cpu_present_map&(1<<i))
 255                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability)&8?"yes":"no");
 256         bp+=sprintf(bp,"\nTS Counters\t: ");
 257         for(i=0;i<32;i++)
 258                 if(cpu_present_map&(1<<i))
 259                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&16)?"yes":"no");
 260         bp+=sprintf(bp,"\nPentium MSR\t: ");
 261         for(i=0;i<32;i++)
 262                 if(cpu_present_map&(1<<i))
 263                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&32)?"yes":"no");
 264         bp+=sprintf(bp,"\nMach. Ch. Exep.\t: ");
 265         for(i=0;i<32;i++)
 266                 if(cpu_present_map&(1<<i))
 267                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&128)?"yes":"no");
 268         bp+=sprintf(bp,"\nCMPXCHG8B\t: ");
 269         for(i=0;i<32;i++)
 270                 if(cpu_present_map&(1<<i))
 271                         bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&256)?"yes":"no");
 272         bp+=sprintf(bp,"\nBogoMips\t: ");
 273         for(i=0;i<32;i++)
 274         {
 275                 char tmp[17];
 276                 if(cpu_present_map&(1<<i))
 277                 {
 278                         sprintf(tmp,"%lu.%02lu",cpu_data[i].udelay_val/500000L,
 279                                                    (cpu_data[i].udelay_val/5000L)%100);
 280                         bp+=sprintf(bp,"%-16s",tmp);
 281                 }
 282         }
 283         *bp++='\n';
 284         return bp-buffer;
 285 #endif                        
 286 }

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