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. sparc_console_print
  3. prom_sync_me
  4. boot_flags_init
  5. setup_arch
  6. sys_ioperm

   1 /*
   2  *  linux/arch/alpha/kernel/setup.c
   3  *
   4  *  Copyright (C) 1995  David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 /*
   8  * bootup setup stuff..
   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 
  24 #include <asm/segment.h>
  25 #include <asm/system.h>
  26 #include <asm/io.h>
  27 #include <asm/processor.h>
  28 #include <asm/oplib.h>    /* The PROM is your friend... */
  29 #include <asm/page.h>
  30 #include <asm/pgtable.h>
  31 #include <asm/traps.h>
  32 #include <asm/vaddrs.h>
  33 #include <asm/kdebug.h>
  34 
  35 extern unsigned long probe_devices(unsigned long);
  36 
  37 /*
  38  * Gcc is hard to keep happy ;-)
  39  */
  40 struct screen_info screen_info = {
  41         0, 0,                   /* orig-x, orig-y */
  42         { 0, 0, },              /* unused */
  43         0,                      /* orig-video-page */
  44         0,                      /* orig-video-mode */
  45         80,                     /* orig-video-cols */
  46         0,0,0,                  /* ega_ax, ega_bx, ega_cx */
  47         25                      /* orig-video-lines */
  48 };
  49 
  50 char wp_works_ok = 0;
  51 
  52 unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end)
     /* [previous][next][first][last][top][bottom][index][help] */
  53 {
  54         return memory_start;
  55 }
  56 
  57 /* Lame prom console routines, gets registered below. Thanks for the
  58  * tip Linus.  We now use a generic putchar prom routine through the
  59  * linux prom library.
  60  */
  61 
  62 void sparc_console_print(const char * p)
     /* [previous][next][first][last][top][bottom][index][help] */
  63 {
  64   unsigned char c;
  65 
  66         while ((c = *(p++)) != 0)
  67           {
  68             if (c == '\n')
  69               prom_putchar('\r');
  70             prom_putchar(c);
  71           }
  72 
  73   return;
  74 
  75 }
  76 
  77 /* Typing sync at the prom promptcalls the function pointed to by
  78  * romvec->pv_synchook which I set to the following function.
  79  * This should sync all filesystems and return, for now it just
  80  * prints out pretty messages and returns.
  81  */
  82 void prom_sync_me(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  83 {
  84         printk("PROM SYNC COMMAND...\n");
  85         show_free_areas();
  86         printk("Returning to prom\n");
  87         return;
  88 }
  89 
  90 unsigned int boot_flags;
  91 #define BOOTME_DEBUG  0x1
  92 #define BOOTME_SINGLE 0x2
  93 #define BOOTME_KGDB   0x3
  94 
  95 /* This routine does no error checking, make sure your string is sane
  96  * before calling this!
  97  * XXX This is cheese, make generic and better.
  98  */
  99 void
 100 boot_flags_init(char *commands)
     /* [previous][next][first][last][top][bottom][index][help] */
 101 {
 102         int i;
 103         for(i=0; i<strlen(commands); i++)
 104                 if(commands[i]=='-')
 105                         switch(commands[i+1]) {
 106                         case 'd':
 107                                 boot_flags |= BOOTME_DEBUG;
 108                                 break;
 109                         case 's':
 110                                 boot_flags |= BOOTME_SINGLE;
 111                                 break;
 112                         case 'h':
 113                                 printk("boot_flags_init: Found halt flag, doing so now...\n");
 114                                 halt();
 115                                 break;
 116                         case 'k':
 117                                 printk("Found KGDB boot flag...\n");
 118                                 boot_flags |= BOOTME_KGDB;
 119                                 break;
 120                         default:
 121                                 printk("boot_flags_init: Unknown boot arg (-%c)\n",
 122                                        commands[i+1]);
 123                                 break;
 124                         };
 125 
 126         return;
 127 }
 128 
 129 /* This routine will in the future do all the nasty prom stuff
 130  * to probe for the mmu type and its parameters, etc. This will
 131  * also be where SMP things happen plus the Sparc specific memory
 132  * physical memory probe as on the alpha.
 133  */
 134 
 135 extern void register_console(void (*proc)(const char *));
 136 extern void load_mmu(void);
 137 extern int prom_probe_memory(void);
 138 extern void probe_mmu(int node);
 139 extern void get_idprom(void);
 140 extern void srmmu_patch_fhandlers(void);
 141 extern unsigned int prom_iface_vers, end_of_phys_memory, phys_bytes_of_ram;
 142 extern char cputypval;
 143 extern unsigned long start;
 144 char sparc_command_line[256];  /* Should be enough */
 145 enum sparc_cpu sparc_cpu_model;
 146 
 147 struct tt_entry *sparc_ttable;
 148 
 149 /* #define DEBUG_CMDLINE */
 150 
 151 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
 152         unsigned long * memory_start_p, unsigned long * memory_end_p)
 153 {
 154         int counter, total, i, node;
 155         char devtype[64];
 156 
 157         sparc_ttable = (struct tt_entry *) &start;
 158 
 159         register_console(sparc_console_print);
 160 
 161         /* Initialize PROM console and command line. */
 162         *cmdline_p = prom_getbootargs();
 163         boot_flags_init(*cmdline_p);
 164 
 165         /* Synchronize with debugger if necessary.  Grrr, have to check
 166          * the boot flags too. ;(
 167          */
 168         if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) && 
 169            ((*(short *)linux_dbvec) != -1)) {
 170                 printk("Booted under debugger. Syncing up trap table.\n");
 171                 /* Sync us up... */
 172                 (*(linux_dbvec->teach_debugger))();
 173 
 174                 SP_ENTER_DEBUGGER;
 175         }
 176 
 177         /* Set sparc_cpu_model */
 178         sparc_cpu_model = sun_unknown;
 179         if(!strcmp(&cputypval,"sun4c")) { sparc_cpu_model=sun4c; }
 180         if(!strcmp(&cputypval,"sun4m")) { sparc_cpu_model=sun4m; }
 181         if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; }
 182         if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; }
 183         if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; }
 184         printk("ARCH: ");
 185         switch(sparc_cpu_model)
 186           {
 187           case sun4c:
 188                   memset(phys_seg_map, 0x0, sizeof(phys_seg_map[PSEG_ENTRIES]));
 189                   put_segmap(IOBASE_VADDR, IOBASE_SUN4C_SEGMAP);
 190                   phys_seg_map[IOBASE_SUN4C_SEGMAP] = PSEG_RSV;
 191                   node = prom_root_node;
 192 
 193                   printk("SUN4C\n");
 194                   break;
 195           case sun4m:
 196                   node = prom_getchild(prom_root_node);
 197                   prom_getproperty(node, "device_type", devtype, sizeof(devtype));
 198                   while(strcmp(devtype, "cpu") != 0) {
 199                           node = prom_getsibling(node);
 200                           prom_getproperty(node, "device_type", devtype,
 201                                            sizeof(devtype));
 202                   }
 203                   /* Patch trap table. */
 204                   srmmu_patch_fhandlers();
 205                   printk("SUN4M\n");
 206                   break;
 207           case sun4d:
 208                   printk("SUN4D\n");
 209                   break;
 210           case sun4e:
 211                   printk("SUN4E\n");
 212                   break;
 213           case sun4u:
 214                   printk("SUN4U\n");
 215                   break;
 216           default:
 217                   printk("UNKNOWN!\n");
 218                   break;
 219           };
 220 
 221         /* probe_devices() expects this to be done. */
 222         get_idprom();
 223 
 224         /* Probe the mmu constants. */
 225         probe_mmu(node);
 226 
 227         /* Set pointers to memory management routines. */
 228         load_mmu();
 229 
 230         /* Probe for memory. */
 231         total = prom_probe_memory();
 232         *memory_start_p = (((unsigned long) &end));
 233 
 234         printk("Physical Memory: %d bytes (in hex %08lx)\n", (int) total,
 235                (unsigned long) total);
 236 
 237         for(i=0; sp_banks[i].num_bytes != 0; i++) {
 238 #if 0
 239                 printk("Bank %d:  base 0x%x  bytes %d\n", i,
 240                        (unsigned int) sp_banks[i].base_addr, 
 241                        (int) sp_banks[i].num_bytes);
 242 #endif
 243                 end_of_phys_memory = sp_banks[i].base_addr + sp_banks[i].num_bytes;
 244         }
 245 
 246         /* Set prom sync hook pointer */
 247         prom_setsync(prom_sync_me);
 248 
 249         init_task.mm->start_code = PAGE_OFFSET;
 250         init_task.mm->end_code = PAGE_OFFSET + (unsigned long) &etext;
 251         init_task.mm->end_data = PAGE_OFFSET + (unsigned long) &edata;
 252         init_task.mm->brk = PAGE_OFFSET + (unsigned long) &end;
 253         init_task.mm->mmap->vm_page_prot = PAGE_SHARED;
 254 
 255         /* Grrr, wish I knew why I have to do this ;-( */
 256         for(counter=1; counter<NR_TASKS; counter++) {
 257                 task[counter] = NULL;
 258         }
 259 
 260         *memory_end_p = (((unsigned long) (total) + PAGE_OFFSET));
 261 
 262         return;
 263 }
 264 
 265 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
     /* [previous][next][first][last][top][bottom][index][help] */
 266 {
 267         return -EIO;
 268 }

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