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 
  30 /*
  31  * Tell us the machine setup..
  32  */
  33 char hard_math = 0;             /* set by boot/head.S */
  34 char x86 = 0;                   /* set by boot/head.S to 3 or 4 */
  35 char x86_model = 0;             /* set by boot/head.S */
  36 char x86_mask = 0;              /* set by boot/head.S */
  37 int x86_capability = 0;         /* set by boot/head.S */
  38 int fdiv_bug = 0;               /* set if Pentium(TM) with FP bug */
  39 
  40 char x86_vendor_id[13] = "Unknown";
  41 
  42 char ignore_irq13 = 0;          /* set if exception 16 works */
  43 char wp_works_ok = -1;          /* set if paging hardware honours WP */ 
  44 char hlt_works_ok = 1;          /* set if the "hlt" instruction works */
  45 
  46 /*
  47  * Bus types ..
  48  */
  49 int EISA_bus = 0;
  50 
  51 /*
  52  * Setup options
  53  */
  54 struct drive_info_struct { char dummy[32]; } drive_info;
  55 struct screen_info screen_info;
  56 
  57 unsigned char aux_device_present;
  58 extern int ramdisk_size;
  59 extern int root_mountflags;
  60 extern int _etext, _edata, _end;
  61 
  62 extern char empty_zero_page[PAGE_SIZE];
  63 
  64 /*
  65  * This is set up by the setup-routine at boot-time
  66  */
  67 #define PARAM   empty_zero_page
  68 #define EXT_MEM_K (*(unsigned short *) (PARAM+2))
  69 #define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
  70 #define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
  71 #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
  72 #define RAMDISK_SIZE (*(unsigned short *) (PARAM+0x1F8))
  73 #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
  74 #define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
  75 #define COMMAND_LINE ((char *) (PARAM+2048))
  76 #define COMMAND_LINE_SIZE 256
  77 
  78 static char command_line[COMMAND_LINE_SIZE] = { 0, };
  79 
  80 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
  81         unsigned long * memory_start_p, unsigned long * memory_end_p)
  82 {
  83         unsigned long memory_start, memory_end;
  84         char c = ' ', *to = command_line, *from = COMMAND_LINE;
  85         int len = 0;
  86 
  87         ROOT_DEV = to_kdev_t(ORIG_ROOT_DEV);
  88         drive_info = DRIVE_INFO;
  89         screen_info = SCREEN_INFO;
  90         aux_device_present = AUX_DEVICE_INFO;
  91         memory_end = (1<<20) + (EXT_MEM_K<<10);
  92         memory_end &= PAGE_MASK;
  93         ramdisk_size = RAMDISK_SIZE;
  94 #ifdef CONFIG_MAX_16M
  95         if (memory_end > 16*1024*1024)
  96                 memory_end = 16*1024*1024;
  97 #endif
  98         if (MOUNT_ROOT_RDONLY)
  99                 root_mountflags |= MS_RDONLY;
 100         memory_start = (unsigned long) &_end;
 101         init_task.mm->start_code = TASK_SIZE;
 102         init_task.mm->end_code = TASK_SIZE + (unsigned long) &_etext;
 103         init_task.mm->end_data = TASK_SIZE + (unsigned long) &_edata;
 104         init_task.mm->brk = TASK_SIZE + (unsigned long) &_end;
 105 
 106         for (;;) {
 107                 /*
 108                  * "mem=nopentium" disables the 4MB page tables.
 109                  * "mem=XXX[kKmM]" overrides the BIOS-reported
 110                  * memory size
 111                  */
 112                 if (c == ' ' && *(const unsigned long *)from == *(const unsigned long *)"mem=") {
 113                         if (!memcmp(from+4, "nopentium", 9)) {
 114                                 from += 9+4;
 115                                 x86_capability &= ~8;
 116                         } else {
 117                                 memory_end = simple_strtoul(from+4, &from, 0);
 118                                 if ( *from == 'K' || *from == 'k' ) {
 119                                         memory_end = memory_end << 10;
 120                                         from++;
 121                                 } else if ( *from == 'M' || *from == 'm' ) {
 122                                         memory_end = memory_end << 20;
 123                                         from++;
 124                                 }
 125                         }
 126                 }
 127                 c = *(from++);
 128                 if (!c)
 129                         break;
 130                 if (COMMAND_LINE_SIZE <= ++len)
 131                         break;
 132                 *(to++) = c;
 133         }
 134         *to = '\0';
 135         *cmdline_p = command_line;
 136         *memory_start_p = memory_start;
 137         *memory_end_p = memory_end;
 138         /* request io space for devices used on all i[345]86 PC'S */
 139         request_region(0x00,0x20,"dma1");
 140         request_region(0x40,0x20,"timer");
 141         request_region(0x70,0x10,"rtc");
 142         request_region(0x80,0x20,"dma page reg");
 143         request_region(0xc0,0x20,"dma2");
 144         request_region(0xf0,0x10,"npu");
 145 }
 146 
 147 int get_cpuinfo(char * buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 148 {
 149         static const char *model[2][9]={{"DX","SX","DX/2","4","SX/2","6",
 150                                 "DX/2-WB","DX/4"},
 151                         {"Pentium 60/66","Pentium 90/100","3",
 152                                 "4","5","6","7","8"}};
 153         char mask[2];
 154         mask[0] = x86_mask+'@';
 155         mask[1] = '\0';
 156         return sprintf(buffer,"cpu\t\t: %c86\n"
 157                               "model\t\t: %s\n"
 158                               "mask\t\t: %s\n"
 159                               "vid\t\t: %s\n"
 160                               "fdiv_bug\t: %s\n"
 161                               "math\t\t: %s\n"
 162                               "hlt\t\t: %s\n"
 163                               "wp\t\t: %s\n"
 164                               "Integrated NPU\t: %s\n"
 165                               "Enhanced VM86\t: %s\n"
 166                               "IO Breakpoints\t: %s\n"
 167                               "4MB Pages\t: %s\n"
 168                               "TS Counters\t: %s\n"
 169                               "Pentium MSR\t: %s\n"
 170                               "Mach. Ch. Exep.\t: %s\n"
 171                               "CMPXCHGB8B\t: %s\n"
 172                               "BogoMips\t: %lu.%02lu\n",
 173                               x86+'0', 
 174                               x86_model ? model[x86-4][x86_model-1] : "Unknown",
 175                               x86_mask ? mask : "Unknown",
 176                               x86_vendor_id,
 177                               fdiv_bug ? "yes" : "no",
 178                               hard_math ? "yes" : "no",
 179                               hlt_works_ok ? "yes" : "no",
 180                               wp_works_ok ? "yes" : "no",
 181                               x86_capability & 1 ? "yes" : "no",
 182                               x86_capability & 2 ? "yes" : "no",
 183                               x86_capability & 4 ? "yes" : "no",
 184                               x86_capability & 8 ? "yes" : "no",
 185                               x86_capability & 16 ? "yes" : "no",
 186                               x86_capability & 32 ? "yes" : "no",
 187                               x86_capability & 128 ? "yes" : "no",
 188                               x86_capability & 256 ? "yes" : "no",
 189                               loops_per_sec/500000, (loops_per_sec/5000) % 100
 190                               );
 191 }

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