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

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