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 enum sparc_cpu sparc_cpu_model;
 157 
 158 struct tt_entry *sparc_ttable;
 159 
 160 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
 161         unsigned long * memory_start_p, unsigned long * memory_end_p)
 162 {
 163         int total, i;
 164 
 165         sparc_ttable = (struct tt_entry *) &start;
 166 
 167         /* Initialize PROM console and command line. */
 168         *cmdline_p = prom_getbootargs();
 169 
 170         /* Set sparc_cpu_model */
 171         sparc_cpu_model = sun_unknown;
 172         if(!strcmp(&cputypval,"sun4c")) { sparc_cpu_model=sun4c; }
 173         if(!strcmp(&cputypval,"sun4m")) { sparc_cpu_model=sun4m; }
 174         if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; }
 175         if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; }
 176         if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; }
 177         printk("ARCH: ");
 178         switch(sparc_cpu_model)
 179           {
 180           case sun4c:
 181                   printk("SUN4C\n");
 182                   probe_vac();
 183                   break;
 184           case sun4m:
 185                   printk("SUN4M\n");
 186                   break;
 187           case sun4d:
 188                   printk("SUN4D\n");
 189                   break;
 190           case sun4e:
 191                   printk("SUN4E\n");
 192                   break;
 193           case sun4u:
 194                   printk("SUN4U\n");
 195                   break;
 196           default:
 197                   printk("UNKNOWN!\n");
 198                   break;
 199           };
 200 
 201         boot_flags_init(*cmdline_p);
 202         if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) && 
 203            ((*(short *)linux_dbvec) != -1)) {
 204                 printk("Booted under KADB. Syncing trap table.\n");
 205                 (*(linux_dbvec->teach_debugger))();
 206         }
 207         if((boot_flags & BOOTME_KGDB)) {
 208                 set_debug_traps();
 209                 breakpoint();
 210         }
 211 
 212         get_idprom();
 213         load_mmu();
 214         total = prom_probe_memory();
 215         *memory_start_p = (((unsigned long) &end));
 216         printk("Physical Memory: %d bytes (in hex %08lx)\n", (int) total,
 217                     (unsigned long) total);
 218 
 219         for(i=0; sp_banks[i].num_bytes != 0; i++) {
 220 #if 0
 221                 printk("Bank %d:  base 0x%x  bytes %d\n", i,
 222                             (unsigned int) sp_banks[i].base_addr, 
 223                             (int) sp_banks[i].num_bytes);
 224 #endif
 225                 end_of_phys_memory = sp_banks[i].base_addr + sp_banks[i].num_bytes;
 226         }
 227 
 228         prom_setsync(prom_sync_me);
 229 
 230         /* Due to stack alignment restrictions and assumptions... */
 231         init_task.mm->mmap->vm_page_prot = PAGE_SHARED;
 232 
 233         *memory_end_p = (end_of_phys_memory + PAGE_OFFSET);
 234 
 235         {
 236                 extern int serial_console;  /* in console.c, of course */
 237                 int idev = prom_query_input_device();
 238                 int odev = prom_query_output_device();
 239                 if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
 240                         serial_console = 0;
 241                 } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
 242                         serial_console = 1;
 243                 } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
 244                         prom_printf("Console on ttyb is not supported\n");
 245                         prom_halt();
 246                 } else {
 247                         prom_printf("Inconsistent console\n");
 248                         prom_halt();
 249                 }
 250         }
 251 }
 252 
 253 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
     /* [previous][next][first][last][top][bottom][index][help] */
 254 {
 255         return -EIO;
 256 }
 257 
 258 /*
 259  * BUFFER is PAGE_SIZE bytes long.
 260  *
 261  * XXX Need to do better than this! XXX
 262  */
 263 int get_cpuinfo(char *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 264 {
 265         return sprintf(buffer, "Sparc RISC\n");
 266 }

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