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.41 1995/11/25 00:58:21 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 
  20 #include <asm/segment.h>
  21 #include <asm/system.h>
  22 #include <asm/io.h>
  23 #include <asm/kgdb.h>
  24 #include <asm/processor.h>
  25 #include <asm/oplib.h>
  26 #include <asm/page.h>
  27 #include <asm/pgtable.h>
  28 #include <asm/traps.h>
  29 #include <asm/vaddrs.h>
  30 #include <asm/kdebug.h>
  31 
  32 struct screen_info screen_info = {
  33         0, 0,                   /* orig-x, orig-y */
  34         { 0, 0, },              /* unused */
  35         0,                      /* orig-video-page */
  36         0,                      /* orig-video-mode */
  37         128,                    /* orig-video-cols */
  38         0,0,0,                  /* ega_ax, ega_bx, ega_cx */
  39         54,                     /* orig-video-lines */
  40         0,                      /* orig-video-isVGA */
  41         16                      /* orig-video-points */
  42 };
  43 
  44 char wp_works_ok = 0;
  45 
  46 unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48         return memory_start;
  49 }
  50 
  51 /* Typing sync at the prom promptcalls the function pointed to by
  52  * romvec->pv_synchook which I set to the following function.
  53  * This should sync all filesystems and return, for now it just
  54  * prints out pretty messages and returns.
  55  */
  56 
  57 extern unsigned long trapbase;
  58 
  59 /* Pretty sick eh? */
  60 void prom_sync_me(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  61 {
  62         unsigned long prom_tbr, flags;
  63 
  64         save_flags(flags); cli();
  65         __asm__ __volatile__("rd %%tbr, %0\n\t" : "=r" (prom_tbr));
  66         __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
  67                              "nop\n\t"
  68                              "nop\n\t"
  69                              "nop\n\t" : : "r" (&trapbase));
  70 
  71         prom_printf("PROM SYNC COMMAND...\n");
  72         show_free_areas();
  73         prom_printf("Returning to prom\n");
  74 
  75         __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
  76                              "nop\n\t"
  77                              "nop\n\t"
  78                              "nop\n\t" : : "r" (prom_tbr));
  79         restore_flags(flags);
  80 
  81         return;
  82 }
  83 
  84 extern void rs_kgdb_hook(int tty_num); /* sparc/serial.c */
  85 
  86 unsigned int boot_flags;
  87 #define BOOTME_DEBUG  0x1
  88 #define BOOTME_SINGLE 0x2
  89 #define BOOTME_KGDB   0x4
  90 
  91 /* This routine does no error checking, make sure your string is sane
  92  * before calling this!
  93  * XXX This is cheese, make generic and better.
  94  */
  95 void
  96 boot_flags_init(char *commands)
     /* [previous][next][first][last][top][bottom][index][help] */
  97 {
  98         int i;
  99         for(i=0; i<strlen(commands); i++) {
 100                 if(commands[i]=='-') {
 101                         switch(commands[i+1]) {
 102                         case 'd':
 103                                 boot_flags |= BOOTME_DEBUG;
 104                                 break;
 105                         case 's':
 106                                 boot_flags |= BOOTME_SINGLE;
 107                                 break;
 108                         case 'h':
 109                                 prom_printf("boot_flags_init: Found halt flag, doing so now...\n");
 110                                 halt();
 111                                 break;
 112                         default:
 113                                 printk("boot_flags_init: Unknown boot arg (-%c)\n",
 114                                        commands[i+1]);
 115                                 break;
 116                         };
 117                 } else {
 118                         if(commands[i]=='k' && commands[i+1]=='g' &&
 119                            commands[i+2]=='d' && commands[i+3]=='b' &&
 120                            commands[i+4]=='=' && commands[i+5]=='t' &&
 121                            commands[i+6]=='t' && commands[i+7]=='y') {
 122                                 printk("KGDB: Using serial line /dev/tty%c for "
 123                                        "session\n", commands[i+8]);
 124                                 boot_flags |= BOOTME_KGDB;
 125                                 if(commands[i+8]=='a')
 126                                         rs_kgdb_hook(0);
 127                                 else if(commands[i+8]=='b')
 128                                         rs_kgdb_hook(1);
 129                                 else {
 130                                         printk("KGDB: whoops bogon tty line "
 131                                                "requested, disabling session\n");
 132                                         boot_flags &= (~BOOTME_KGDB);
 133                                 }
 134                         }
 135                 }
 136         }
 137         return;
 138 }
 139 
 140 /* This routine will in the future do all the nasty prom stuff
 141  * to probe for the mmu type and its parameters, etc. This will
 142  * also be where SMP things happen plus the Sparc specific memory
 143  * physical memory probe as on the alpha.
 144  */
 145 
 146 extern void load_mmu(void);
 147 extern int prom_probe_memory(void);
 148 extern void probe_vac(void);
 149 extern void get_idprom(void);
 150 extern unsigned int end_of_phys_memory;
 151 extern char cputypval;
 152 extern unsigned long start, end, bootup_stack, bootup_kstack;
 153 
 154 
 155 char sparc_command_line[256];  /* Should be enough */
 156 char saved_command_line[256];
 157 enum sparc_cpu sparc_cpu_model;
 158 
 159 struct tt_entry *sparc_ttable;
 160 
 161 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
 162         unsigned long * memory_start_p, unsigned long * memory_end_p)
 163 {
 164         int total, i;
 165 
 166         sparc_ttable = (struct tt_entry *) &start;
 167 
 168         /* Initialize PROM console and command line. */
 169         *cmdline_p = prom_getbootargs();
 170         strcpy(saved_command_line, *cmdline_p);
 171 
 172         /* Set sparc_cpu_model */
 173         sparc_cpu_model = sun_unknown;
 174         if(!strcmp(&cputypval,"sun4c")) { sparc_cpu_model=sun4c; }
 175         if(!strcmp(&cputypval,"sun4m")) { sparc_cpu_model=sun4m; }
 176         if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; }
 177         if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; }
 178         if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; }
 179         printk("ARCH: ");
 180         switch(sparc_cpu_model)
 181           {
 182           case sun4c:
 183                   printk("SUN4C\n");
 184                   probe_vac();
 185                   break;
 186           case sun4m:
 187                   printk("SUN4M\n");
 188                   break;
 189           case sun4d:
 190                   printk("SUN4D\n");
 191                   break;
 192           case sun4e:
 193                   printk("SUN4E\n");
 194                   break;
 195           case sun4u:
 196                   printk("SUN4U\n");
 197                   break;
 198           default:
 199                   printk("UNKNOWN!\n");
 200                   break;
 201           };
 202 
 203         boot_flags_init(*cmdline_p);
 204         if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) && 
 205            ((*(short *)linux_dbvec) != -1)) {
 206                 printk("Booted under KADB. Syncing trap table.\n");
 207                 (*(linux_dbvec->teach_debugger))();
 208         }
 209         if((boot_flags & BOOTME_KGDB)) {
 210                 set_debug_traps();
 211                 breakpoint();
 212         }
 213 
 214         get_idprom();
 215         load_mmu();
 216         total = prom_probe_memory();
 217         *memory_start_p = (((unsigned long) &end));
 218         printk("Physical Memory: %d bytes (in hex %08lx)\n", (int) total,
 219                     (unsigned long) total);
 220 
 221         for(i=0; sp_banks[i].num_bytes != 0; i++) {
 222 #if 0
 223                 printk("Bank %d:  base 0x%x  bytes %d\n", i,
 224                             (unsigned int) sp_banks[i].base_addr, 
 225                             (int) sp_banks[i].num_bytes);
 226 #endif
 227                 end_of_phys_memory = sp_banks[i].base_addr + sp_banks[i].num_bytes;
 228         }
 229 
 230         prom_setsync(prom_sync_me);
 231 
 232         /* Due to stack alignment restrictions and assumptions... */
 233         init_task.mm->mmap->vm_page_prot = PAGE_SHARED;
 234 
 235         *memory_end_p = (end_of_phys_memory + PAGE_OFFSET);
 236 
 237         {
 238                 extern int serial_console;  /* in console.c, of course */
 239                 int idev = prom_query_input_device();
 240                 int odev = prom_query_output_device();
 241                 if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
 242                         serial_console = 0;
 243                 } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
 244                         serial_console = 1;
 245                 } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
 246                         prom_printf("Console on ttyb is not supported\n");
 247                         prom_halt();
 248                 } else {
 249                         prom_printf("Inconsistent console\n");
 250                         prom_halt();
 251                 }
 252         }
 253 }
 254 
 255 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
     /* [previous][next][first][last][top][bottom][index][help] */
 256 {
 257         return -EIO;
 258 }
 259 
 260 /*
 261  * BUFFER is PAGE_SIZE bytes long.
 262  *
 263  * XXX Need to do better than this! XXX
 264  */
 265 int get_cpuinfo(char *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 266 {
 267         return sprintf(buffer, "Sparc RISC\n");
 268 }

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