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. kernel_enter_debugger
  4. obp_system_intr
  5. boot_flags_init
  6. setup_arch
  7. sys_ioperm
  8. get_cpuinfo

   1 /*  $Id: setup.c,v 1.62 1996/04/25 09:11:33 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/smp.h>
  17 #include <linux/user.h>
  18 #include <linux/a.out.h>
  19 #include <linux/tty.h>
  20 #include <linux/delay.h>
  21 #include <linux/config.h>
  22 #include <linux/fs.h>
  23 #include <linux/kdev_t.h>
  24 #include <linux/major.h>
  25 
  26 #include <asm/segment.h>
  27 #include <asm/system.h>
  28 #include <asm/io.h>
  29 #include <asm/kgdb.h>
  30 #include <asm/processor.h>
  31 #include <asm/oplib.h>
  32 #include <asm/page.h>
  33 #include <asm/pgtable.h>
  34 #include <asm/traps.h>
  35 #include <asm/vaddrs.h>
  36 #include <asm/kdebug.h>
  37 #include <asm/mbus.h>
  38 
  39 struct screen_info screen_info = {
  40         0, 0,                   /* orig-x, orig-y */
  41         { 0, 0, },              /* unused */
  42         0,                      /* orig-video-page */
  43         0,                      /* orig-video-mode */
  44         128,                    /* orig-video-cols */
  45         0,0,0,                  /* ega_ax, ega_bx, ega_cx */
  46         54,                     /* orig-video-lines */
  47         0,                      /* orig-video-isVGA */
  48         16                      /* orig-video-points */
  49 };
  50 
  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 prompt calls 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 #if CONFIG_SUN_CONSOLE
  67 extern void console_restore_palette(void);
  68 #endif
  69 asmlinkage void sys_sync(void); /* it's really int */
  70 
  71 /* Pretty sick eh? */
  72 void prom_sync_me(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  73 {
  74         unsigned long prom_tbr, flags;
  75 
  76         save_flags(flags); cli();
  77         __asm__ __volatile__("rd %%tbr, %0\n\t" : "=r" (prom_tbr));
  78         __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
  79                              "nop\n\t"
  80                              "nop\n\t"
  81                              "nop\n\t" : : "r" (&trapbase));
  82 
  83 #if CONFIG_SUN_CONSOLE
  84         console_restore_palette ();
  85 #endif
  86         prom_printf("PROM SYNC COMMAND...\n");
  87         show_free_areas();
  88         if(current->pid != 0) {
  89                 sti();
  90                 sys_sync();
  91                 cli();
  92         }
  93         prom_printf("Returning to prom\n");
  94 
  95         __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
  96                              "nop\n\t"
  97                              "nop\n\t"
  98                              "nop\n\t" : : "r" (prom_tbr));
  99         restore_flags(flags);
 100 
 101         return;
 102 }
 103 
 104 extern void rs_kgdb_hook(int tty_num); /* sparc/serial.c */
 105 
 106 unsigned int boot_flags;
 107 #define BOOTME_DEBUG  0x1
 108 #define BOOTME_SINGLE 0x2
 109 #define BOOTME_KGDB   0x4
 110 
 111 void kernel_enter_debugger(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 112 {
 113         if (boot_flags & BOOTME_KGDB) {
 114                 printk("KGDB: Entered\n");
 115                 breakpoint();
 116         }
 117 }
 118 
 119 int obp_system_intr(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 120 {
 121         if (boot_flags & BOOTME_KGDB) {
 122                 printk("KGDB: system interrupted\n");
 123                 breakpoint();
 124                 return 1;
 125         }
 126         if (boot_flags & BOOTME_DEBUG) {
 127                 printk("OBP: system interrupted\n");
 128                 prom_halt();
 129                 return 1;
 130         }
 131         return 0;
 132 }
 133 
 134 /* This routine does no error checking, make sure your string is sane
 135  * before calling this!
 136  * XXX This is cheese, make generic and better.
 137  */
 138 void
 139 boot_flags_init(char *commands)
     /* [previous][next][first][last][top][bottom][index][help] */
 140 {
 141         int i;
 142         for(i=0; i<strlen(commands); i++) {
 143                 if(commands[i]=='-') {
 144                         switch(commands[i+1]) {
 145                         case 'd':
 146                                 boot_flags |= BOOTME_DEBUG;
 147                                 break;
 148                         case 's':
 149                                 boot_flags |= BOOTME_SINGLE;
 150                                 break;
 151                         case 'h':
 152                                 prom_printf("boot_flags_init: Found halt flag, doing so now...\n");
 153                                 halt();
 154                                 break;
 155                         default:
 156                                 printk("boot_flags_init: Unknown boot arg (-%c)\n",
 157                                        commands[i+1]);
 158                                 break;
 159                         };
 160                 } else {
 161                         if(commands[i]=='k' && commands[i+1]=='g' &&
 162                            commands[i+2]=='d' && commands[i+3]=='b' &&
 163                            commands[i+4]=='=' && commands[i+5]=='t' &&
 164                            commands[i+6]=='t' && commands[i+7]=='y') {
 165                                 printk("KGDB: Using serial line /dev/tty%c for "
 166                                        "session\n", commands[i+8]);
 167                                 boot_flags |= BOOTME_KGDB;
 168 #if CONFIG_SUN_SERIAL
 169                                 if(commands[i+8]=='a')
 170                                         rs_kgdb_hook(0);
 171                                 else if(commands[i+8]=='b')
 172                                         rs_kgdb_hook(1);
 173                                 else
 174 #endif
 175 #if CONFIG_AP1000
 176                                 if(commands[i+8]=='c')
 177                                   printk("KGDB: ap1000+ debugging\n");
 178                                 else
 179 #endif
 180                                 {
 181                                         printk("KGDB: whoops bogon tty line "
 182                                                "requested, disabling session\n");
 183                                         boot_flags &= (~BOOTME_KGDB);
 184                                 }
 185                         }
 186                 }
 187         }
 188         return;
 189 }
 190 
 191 /* This routine will in the future do all the nasty prom stuff
 192  * to probe for the mmu type and its parameters, etc. This will
 193  * also be where SMP things happen plus the Sparc specific memory
 194  * physical memory probe as on the alpha.
 195  */
 196 
 197 extern void load_mmu(void);
 198 extern int prom_probe_memory(void);
 199 extern void sun4c_probe_vac(void);
 200 extern void get_idprom(void);
 201 extern char cputypval;
 202 extern unsigned long start, end;
 203 extern void panic_setup(char *, int *);
 204 
 205 char saved_command_line[256];
 206 enum sparc_cpu sparc_cpu_model;
 207 
 208 struct tt_entry *sparc_ttable;
 209 
 210 static struct pt_regs fake_swapper_regs = { 0, 0, 0, 0, { 0, } };
 211 
 212 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
 213         unsigned long * memory_start_p, unsigned long * memory_end_p)
 214 {
 215         int total, i, packed;
 216 
 217 #if CONFIG_AP1000
 218         register_console(prom_printf);
 219         ((char *)(&cputypval))[4] = 'm'; /* ugly :-( */
 220 #endif
 221 
 222         sparc_ttable = (struct tt_entry *) &start;
 223 
 224         /* Initialize PROM console and command line. */
 225         *cmdline_p = prom_getbootargs();
 226         strcpy(saved_command_line, *cmdline_p);
 227 
 228         /* Set sparc_cpu_model */
 229         sparc_cpu_model = sun_unknown;
 230         if(!strcmp(&cputypval,"sun4c")) { sparc_cpu_model=sun4c; }
 231         if(!strcmp(&cputypval,"sun4m")) { sparc_cpu_model=sun4m; }
 232         if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; }
 233         if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; }
 234         if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; }
 235         printk("ARCH: ");
 236         packed = 0;
 237         switch(sparc_cpu_model)
 238           {
 239           case sun4c:
 240                   printk("SUN4C\n");
 241                   sun4c_probe_vac();
 242                   packed = 0;
 243                   break;
 244           case sun4m:
 245                   printk("SUN4M\n");
 246                   packed = 1;
 247                   break;
 248           case sun4d:
 249                   printk("SUN4D\n");
 250                   packed = 1;
 251                   break;
 252           case sun4e:
 253                   printk("SUN4E\n");
 254                   packed = 0;
 255                   break;
 256           case sun4u:
 257                   printk("SUN4U\n");
 258                   break;
 259           default:
 260                   printk("UNKNOWN!\n");
 261                   break;
 262           };
 263 
 264         boot_flags_init(*cmdline_p);
 265         if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) && 
 266            ((*(short *)linux_dbvec) != -1)) {
 267                 printk("Booted under KADB. Syncing trap table.\n");
 268                 (*(linux_dbvec->teach_debugger))();
 269         }
 270         if((boot_flags & BOOTME_KGDB)) {
 271                 set_debug_traps();
 272                 breakpoint();
 273         }
 274 
 275         get_idprom();
 276         load_mmu();
 277         total = prom_probe_memory();
 278         *memory_start_p = (((unsigned long) &end));
 279 
 280         if(!packed) {
 281                 for(i=0; sp_banks[i].num_bytes != 0; i++)
 282                         end_of_phys_memory = sp_banks[i].base_addr +
 283                                 sp_banks[i].num_bytes;
 284         } else {
 285                 unsigned int sum = 0;
 286 
 287                 for(i = 0; sp_banks[i].num_bytes != 0; i++)
 288                         sum += sp_banks[i].num_bytes;
 289 
 290                 end_of_phys_memory = sum;
 291         }
 292 
 293         prom_setsync(prom_sync_me);
 294 
 295         *memory_end_p = (end_of_phys_memory + PAGE_OFFSET);
 296         if(*memory_end_p > IOBASE_VADDR)
 297                 *memory_end_p = IOBASE_VADDR;
 298 
 299         /* Due to stack alignment restrictions and assumptions... */
 300         init_task.mm->mmap->vm_page_prot = PAGE_SHARED;
 301         init_task.mm->mmap->vm_start = KERNBASE;
 302         init_task.mm->mmap->vm_end = *memory_end_p;
 303         init_task.tss.kregs = &fake_swapper_regs;
 304 
 305         {
 306                 extern int serial_console;  /* in console.c, of course */
 307 #if !CONFIG_SUN_SERIAL
 308                 serial_console = 0;
 309 #else
 310                 int idev = prom_query_input_device();
 311                 int odev = prom_query_output_device();
 312                 if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
 313                         serial_console = 0;
 314                 } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
 315                         serial_console = 1;
 316                 } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
 317                         prom_printf("Console on ttyb is not supported\n");
 318                         prom_halt();
 319                 } else {
 320                         prom_printf("Inconsistent console\n");
 321                         prom_halt();
 322                 }
 323 #endif
 324         }
 325 #if 1
 326         /* XXX ROOT_DEV hack for kgdb - davem XXX */
 327 #if 1
 328         ROOT_DEV = MKDEV(UNNAMED_MAJOR, 255); /* NFS */
 329 #else
 330         ROOT_DEV = 0x801; /* SCSI DISK */
 331 #endif
 332 
 333 #endif
 334 }
 335 
 336 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
     /* [previous][next][first][last][top][bottom][index][help] */
 337 {
 338         return -EIO;
 339 }
 340 
 341 /* BUFFER is PAGE_SIZE bytes long. */
 342 
 343 extern char *sparc_cpu_type[];
 344 extern char *sparc_fpu_type[];
 345 
 346 extern char *smp_info(void);
 347 
 348 int get_cpuinfo(char *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 349 {
 350         int cpuid=get_cpuid();
 351 
 352         return sprintf(buffer, "cpu\t\t: %s\n"
 353             "fpu\t\t: %s\n"
 354             "promlib\t\t: Version %d Revision %d\n"
 355             "type\t\t: %s\n"
 356             "Elf Support\t: %s\n"   /* I can't remember when I do --ralp */
 357 #ifndef __SMP__
 358             "BogoMips\t: %lu.%02lu\n"
 359 #else
 360             "Cpu0Bogo\t: %lu.%02lu\n"
 361             "Cpu1Bogo\t: %lu.%02lu\n"
 362             "Cpu2Bogo\t: %lu.%02lu\n"
 363             "Cpu3Bogo\t: %lu.%02lu\n"
 364 #endif
 365             "%s"
 366 #ifdef __SMP__
 367             "%s"
 368 #endif
 369             ,
 370             sparc_cpu_type[cpuid],
 371             sparc_fpu_type[cpuid],
 372 #if CONFIG_AP1000
 373             0, 0,
 374 #else
 375             romvec->pv_romvers, prom_rev,
 376 #endif
 377             &cputypval,
 378 #if CONFIG_BINFMT_ELF
 379             "yes",
 380 #else
 381             "no",
 382 #endif
 383 #ifndef __SMP__
 384             loops_per_sec/500000, (loops_per_sec/5000) % 100,
 385 #else
 386             cpu_data[0].udelay_val/500000, (cpu_data[0].udelay_val/5000)%100,
 387             cpu_data[1].udelay_val/500000, (cpu_data[1].udelay_val/5000)%100,
 388             cpu_data[2].udelay_val/500000, (cpu_data[2].udelay_val/5000)%100,
 389             cpu_data[3].udelay_val/500000, (cpu_data[3].udelay_val/5000)%100,
 390 #endif
 391             mmu_info()
 392 #ifdef __SMP__
 393             , smp_info()
 394 #endif
 395             );
 396 
 397 }

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