root/arch/sparc/kernel/setup.c

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

DEFINITIONS

This source file includes following definitions.
  1. bios32_init
  2. prom_sync_me
  3. boot_flags_init
  4. setup_arch
  5. sys_ioperm
  6. get_cpuinfo

   1 /*  $Id: setup.c,v 1.54 1996/02/25 06:49:18 davem Exp $
   2  *  linux/arch/sparc/kernel/setup.c
   3  *
   4  *  Copyright (C) 1995  David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 #include <linux/errno.h>
   8 #include <linux/sched.h>
   9 #include <linux/kernel.h>
  10 #include <linux/mm.h>
  11 #include <linux/stddef.h>
  12 #include <linux/unistd.h>
  13 #include <linux/ptrace.h>
  14 #include <linux/malloc.h>
  15 #include <linux/ldt.h>
  16 #include <linux/user.h>
  17 #include <linux/a.out.h>
  18 #include <linux/tty.h>
  19 #include <linux/delay.h>
  20 #include <linux/config.h>
  21 #include <linux/fs.h>
  22 #include <linux/kdev_t.h>
  23 #include <linux/major.h>
  24 
  25 #include <asm/segment.h>
  26 #include <asm/system.h>
  27 #include <asm/io.h>
  28 #include <asm/kgdb.h>
  29 #include <asm/processor.h>
  30 #include <asm/oplib.h>
  31 #include <asm/page.h>
  32 #include <asm/pgtable.h>
  33 #include <asm/traps.h>
  34 #include <asm/vaddrs.h>
  35 #include <asm/kdebug.h>
  36 #include <asm/mbus.h>
  37 
  38 struct screen_info screen_info = {
  39         0, 0,                   /* orig-x, orig-y */
  40         { 0, 0, },              /* unused */
  41         0,                      /* orig-video-page */
  42         0,                      /* orig-video-mode */
  43         128,                    /* orig-video-cols */
  44         0,0,0,                  /* ega_ax, ega_bx, ega_cx */
  45         54,                     /* orig-video-lines */
  46         0,                      /* orig-video-isVGA */
  47         16                      /* orig-video-points */
  48 };
  49 
  50 char wp_works_ok = 0;
  51 unsigned int phys_bytes_of_ram, end_of_phys_memory;
  52 
  53 unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55         return memory_start;
  56 }
  57 
  58 /* Typing sync at the prom promptcalls the function pointed to by
  59  * romvec->pv_synchook which I set to the following function.
  60  * This should sync all filesystems and return, for now it just
  61  * prints out pretty messages and returns.
  62  */
  63 
  64 extern unsigned long trapbase;
  65 extern void breakpoint(void);
  66 extern void console_restore_palette(void);
  67 asmlinkage void sys_sync(void); /* it's really int */
  68 
  69 /* Pretty sick eh? */
  70 void prom_sync_me(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  71 {
  72         unsigned long prom_tbr, flags;
  73 
  74         save_flags(flags); cli();
  75         __asm__ __volatile__("rd %%tbr, %0\n\t" : "=r" (prom_tbr));
  76         __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
  77                              "nop\n\t"
  78                              "nop\n\t"
  79                              "nop\n\t" : : "r" (&trapbase));
  80 
  81         console_restore_palette ();
  82         prom_printf("PROM SYNC COMMAND...\n");
  83         show_free_areas();
  84         if(current != task[0]) {
  85                 sti();
  86                 sys_sync();
  87                 cli();
  88         }
  89         prom_printf("Returning to prom\n");
  90 
  91         __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
  92                              "nop\n\t"
  93                              "nop\n\t"
  94                              "nop\n\t" : : "r" (prom_tbr));
  95         restore_flags(flags);
  96 
  97         return;
  98 }
  99 
 100 extern void rs_kgdb_hook(int tty_num); /* sparc/serial.c */
 101 
 102 unsigned int boot_flags;
 103 #define BOOTME_DEBUG  0x1
 104 #define BOOTME_SINGLE 0x2
 105 #define BOOTME_KGDB   0x4
 106 
 107 /* This routine does no error checking, make sure your string is sane
 108  * before calling this!
 109  * XXX This is cheese, make generic and better.
 110  */
 111 void
 112 boot_flags_init(char *commands)
     /* [previous][next][first][last][top][bottom][index][help] */
 113 {
 114         int i;
 115         for(i=0; i<strlen(commands); i++) {
 116                 if(commands[i]=='-') {
 117                         switch(commands[i+1]) {
 118                         case 'd':
 119                                 boot_flags |= BOOTME_DEBUG;
 120                                 break;
 121                         case 's':
 122                                 boot_flags |= BOOTME_SINGLE;
 123                                 break;
 124                         case 'h':
 125                                 prom_printf("boot_flags_init: Found halt flag, doing so now...\n");
 126                                 halt();
 127                                 break;
 128                         default:
 129                                 printk("boot_flags_init: Unknown boot arg (-%c)\n",
 130                                        commands[i+1]);
 131                                 break;
 132                         };
 133                 } else {
 134                         if(commands[i]=='k' && commands[i+1]=='g' &&
 135                            commands[i+2]=='d' && commands[i+3]=='b' &&
 136                            commands[i+4]=='=' && commands[i+5]=='t' &&
 137                            commands[i+6]=='t' && commands[i+7]=='y') {
 138                                 printk("KGDB: Using serial line /dev/tty%c for "
 139                                        "session\n", commands[i+8]);
 140                                 boot_flags |= BOOTME_KGDB;
 141                                 if(commands[i+8]=='a')
 142                                         rs_kgdb_hook(0);
 143                                 else if(commands[i+8]=='b')
 144                                         rs_kgdb_hook(1);
 145                                 else {
 146                                         printk("KGDB: whoops bogon tty line "
 147                                                "requested, disabling session\n");
 148                                         boot_flags &= (~BOOTME_KGDB);
 149                                 }
 150                         }
 151                 }
 152         }
 153         return;
 154 }
 155 
 156 /* This routine will in the future do all the nasty prom stuff
 157  * to probe for the mmu type and its parameters, etc. This will
 158  * also be where SMP things happen plus the Sparc specific memory
 159  * physical memory probe as on the alpha.
 160  */
 161 
 162 extern void load_mmu(void);
 163 extern int prom_probe_memory(void);
 164 extern void sun4c_probe_vac(void);
 165 extern void get_idprom(void);
 166 extern char cputypval;
 167 extern unsigned long start, end;
 168 extern void panic_setup(char *, int *);
 169 
 170 char saved_command_line[256];
 171 enum sparc_cpu sparc_cpu_model;
 172 
 173 struct tt_entry *sparc_ttable;
 174 
 175 static struct pt_regs fake_swapper_regs = { 0, 0, 0, 0, { 0, } };
 176 
 177 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
 178         unsigned long * memory_start_p, unsigned long * memory_end_p)
 179 {
 180         int total, i, panic_stuff[2];
 181 
 182         /* Always reboot on panic, but give 5 seconds to hit L1-A
 183          * and look at debugging info if desired.
 184          */
 185         panic_stuff[0] = 1;
 186         panic_stuff[1] = 5;
 187         panic_setup(0, panic_stuff);
 188 
 189         sparc_ttable = (struct tt_entry *) &start;
 190 
 191         /* Initialize PROM console and command line. */
 192         *cmdline_p = prom_getbootargs();
 193         strcpy(saved_command_line, *cmdline_p);
 194 
 195         /* Set sparc_cpu_model */
 196         sparc_cpu_model = sun_unknown;
 197         if(!strcmp(&cputypval,"sun4c")) { sparc_cpu_model=sun4c; }
 198         if(!strcmp(&cputypval,"sun4m")) { sparc_cpu_model=sun4m; }
 199         if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; }
 200         if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; }
 201         if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; }
 202         printk("ARCH: ");
 203         switch(sparc_cpu_model)
 204           {
 205           case sun4c:
 206                   printk("SUN4C\n");
 207                   sun4c_probe_vac();
 208                   break;
 209           case sun4m:
 210                   printk("SUN4M\n");
 211                   break;
 212           case sun4d:
 213                   printk("SUN4D\n");
 214                   break;
 215           case sun4e:
 216                   printk("SUN4E\n");
 217                   break;
 218           case sun4u:
 219                   printk("SUN4U\n");
 220                   break;
 221           default:
 222                   printk("UNKNOWN!\n");
 223                   break;
 224           };
 225 
 226         boot_flags_init(*cmdline_p);
 227         if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) && 
 228            ((*(short *)linux_dbvec) != -1)) {
 229                 printk("Booted under KADB. Syncing trap table.\n");
 230                 (*(linux_dbvec->teach_debugger))();
 231         }
 232         if((boot_flags & BOOTME_KGDB)) {
 233                 set_debug_traps();
 234                 breakpoint();
 235         }
 236 
 237         get_idprom();
 238         load_mmu();
 239         total = prom_probe_memory();
 240         *memory_start_p = (((unsigned long) &end));
 241 #if 0
 242         prom_printf("Physical Memory: %d bytes (in hex %08lx)\n", (int) total,
 243                     (unsigned long) total);
 244 #endif
 245 
 246         for(i=0; sp_banks[i].num_bytes != 0; i++) {
 247 #if 0
 248                 printk("Bank %d:  base 0x%x  bytes %d\n", i,
 249                             (unsigned int) sp_banks[i].base_addr, 
 250                             (int) sp_banks[i].num_bytes);
 251 #endif
 252                 end_of_phys_memory = sp_banks[i].base_addr + sp_banks[i].num_bytes;
 253         }
 254 
 255         prom_setsync(prom_sync_me);
 256 
 257         *memory_end_p = (end_of_phys_memory + PAGE_OFFSET);
 258         if(*memory_end_p > IOBASE_VADDR)
 259                 *memory_end_p = IOBASE_VADDR;
 260 
 261         /* Due to stack alignment restrictions and assumptions... */
 262         init_task.mm->mmap->vm_page_prot = PAGE_SHARED;
 263         init_task.mm->mmap->vm_start = KERNBASE;
 264         init_task.mm->mmap->vm_end = *memory_end_p;
 265         init_task.tss.kregs = &fake_swapper_regs;
 266 
 267         {
 268                 extern int serial_console;  /* in console.c, of course */
 269                 int idev = prom_query_input_device();
 270                 int odev = prom_query_output_device();
 271                 if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
 272                         serial_console = 0;
 273                 } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
 274                         serial_console = 1;
 275                 } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
 276                         prom_printf("Console on ttyb is not supported\n");
 277                         prom_halt();
 278                 } else {
 279                         prom_printf("Inconsistent console\n");
 280                         prom_halt();
 281                 }
 282         }
 283 #if 1
 284         /* XXX ROOT_DEV hack for kgdb - davem XXX */
 285 #if 1
 286         ROOT_DEV = MKDEV(UNNAMED_MAJOR, 255); /* NFS */
 287 #else
 288         ROOT_DEV = 0x801; /* SCSI DISK */
 289 #endif
 290 
 291 #endif
 292 }
 293 
 294 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
     /* [previous][next][first][last][top][bottom][index][help] */
 295 {
 296         return -EIO;
 297 }
 298 
 299 /* BUFFER is PAGE_SIZE bytes long. */
 300 
 301 extern char *sparc_cpu_type[];
 302 extern char *sparc_fpu_type[];
 303 
 304 int get_cpuinfo(char *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 305 {
 306         int cpuid=get_cpuid();
 307 
 308         return sprintf(buffer, "cpu\t\t: %s\n"
 309             "fpu\t\t: %s\n"
 310             "promlib\t\t: Version %d Revision %d\n"
 311             "wp\t\t: %s\n"
 312             "type\t\t: %s\n"
 313             "Elf Support\t: %s\n"   /* I can't remember when I do --ralp */
 314             "BogoMips\t: %lu.%02lu\n"
 315             "%s",
 316             sparc_cpu_type[cpuid],
 317             sparc_fpu_type[cpuid],
 318             romvec->pv_romvers, prom_rev,
 319             wp_works_ok ? "yes" : "no",
 320             &cputypval,
 321 #if CONFIG_BINFMT_ELF
 322             "yes",
 323 #else
 324             "no",
 325 #endif
 326             loops_per_sec/500000, (loops_per_sec/5000) % 100,
 327             mmu_info()
 328             );
 329 
 330 }

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