root/arch/m68k/kernel/setup.c

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

DEFINITIONS

This source file includes following definitions.
  1. dummy_waitbut
  2. setup_arch
  3. setkeycode
  4. getkeycode
  5. get_cpuinfo
  6. get_hardware_list
  7. floppy_init
  8. floppy_setup
  9. arch_kbd_init
  10. rs_init
  11. register_serial
  12. unregister_serial
  13. arch_gettod
  14. video_setup

   1 /*
   2  *  linux/arch/m68k/kernel/setup.c
   3  *
   4  *  Copyright (C) 1995  Hamish Macdonald
   5  */
   6 
   7 /*
   8  * This file handles the architecture-dependent parts of system setup
   9  */
  10 
  11 #include <linux/config.h>
  12 #include <linux/kernel.h>
  13 #include <linux/sched.h>
  14 #include <linux/delay.h>
  15 #include <linux/interrupt.h>
  16 #include <linux/fs.h>
  17 #include <linux/console.h>
  18 #include <linux/genhd.h>
  19 #include <linux/errno.h>
  20 #include <linux/string.h>
  21 
  22 #include <asm/bootinfo.h>
  23 #include <asm/irq.h>
  24 #include <asm/machdep.h>
  25 #include <asm/amigatypes.h>
  26 #include <asm/amigahw.h>
  27 
  28 #ifdef CONFIG_BLK_DEV_INITRD
  29 #include <linux/blk.h>
  30 #include <asm/pgtable.h>
  31 #endif
  32 
  33 struct bootinfo boot_info = {0,};
  34 int bisize = sizeof boot_info;
  35 
  36 int m68k_is040or060 = 0;
  37 
  38 char m68k_debug_device[6] = "";
  39 
  40 extern int end;
  41 extern unsigned long availmem;
  42 
  43 char saved_command_line[CL_SIZE];
  44 
  45 /* setup some dummy routines */
  46 static void dummy_waitbut(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48 }
  49 
  50 void (*mach_sched_init) (isrfunc);
  51 int (*mach_keyb_init) (void);
  52 int (*mach_kbdrate) (struct kbd_repeat *) = NULL;
  53 void (*mach_kbd_leds) (unsigned int) = NULL;
  54 void (*mach_init_INTS) (void);
  55 int (*mach_add_isr) (unsigned long, isrfunc, int, void *, char *);
  56 int (*mach_remove_isr) (unsigned long, isrfunc);
  57 void (*mach_process_int) (int, struct pt_regs *) = NULL;
  58 void (*mach_enable_irq) (unsigned) = NULL;
  59 void (*mach_disable_irq) (unsigned) = NULL;
  60 int (*mach_get_irq_list) (char *, int) = NULL;
  61 unsigned long (*mach_gettimeoffset) (void);
  62 void (*mach_gettod) (int*, int*, int*, int*, int*, int*);
  63 int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
  64 int (*mach_set_clock_mmss) (unsigned long) = NULL;
  65 void (*mach_check_partition) (struct gendisk *, unsigned int);
  66 void (*mach_mksound)( unsigned int count, unsigned int ticks );
  67 void (*mach_reset)( void );
  68 void (*waitbut)(void) = dummy_waitbut;
  69 struct fb_info *(*mach_fb_init)(long *);
  70 long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
  71 void (*mach_debug_init)(void);
  72 void (*mach_video_setup) (char *, int *);
  73 #ifdef CONFIG_BLK_DEV_FD
  74 int (*mach_floppy_init) (void) = NULL;
  75 void (*mach_floppy_setup) (char *, int *) = NULL;
  76 #endif
  77 
  78 extern void config_amiga(void);
  79 extern void config_atari(void);
  80 extern void config_mac(void);
  81 
  82 extern void register_console(void (*proc)(const char *));
  83 extern void ami_serial_print (const char *str);
  84 extern void ata_serial_print (const char *str);
  85 
  86 extern void (*kd_mksound)(unsigned int, unsigned int);
  87 
  88 extern void amiga_get_model(char *model);
  89 extern void atari_get_model(char *model);
  90 extern void mac_get_model(char *model);
  91 extern int amiga_get_hardware_list(char *buffer);
  92 extern int atari_get_hardware_list(char *buffer);
  93 extern int mac_get_hardware_list(char *buffer);
  94 
  95 #define MASK_256K 0xfffc0000
  96 
  97 void setup_arch(char **cmdline_p,
     /* [previous][next][first][last][top][bottom][index][help] */
  98                 unsigned long * memory_start_p, unsigned long * memory_end_p)
  99 {
 100         unsigned long memory_start, memory_end;
 101         extern int _etext, _edata, _end;
 102         int i;
 103         char *p, *q;
 104 
 105 #ifdef CONFIG_AMIGA
 106         if (MACH_IS_AMIGA)
 107           register_console (ami_serial_print);
 108 #endif
 109 #ifdef CONFIG_ATARI
 110         if (MACH_IS_ATARI)
 111           register_console (ata_serial_print);
 112 #endif
 113 
 114         if (boot_info.cputype & CPU_68040)
 115                 m68k_is040or060 = 4;
 116         else if (boot_info.cputype & CPU_68060)
 117                 m68k_is040or060 = 6;
 118 
 119         memory_start = availmem;
 120         memory_end = 0;
 121 
 122         for (i = 0; i < boot_info.num_memory; i++)
 123                 memory_end += boot_info.memory[i].size & MASK_256K;
 124 
 125         init_task.mm->start_code = 0;
 126         init_task.mm->end_code = (unsigned long) &_etext;
 127         init_task.mm->end_data = (unsigned long) &_edata;
 128         init_task.mm->brk = (unsigned long) &_end;
 129 
 130         *cmdline_p = boot_info.command_line;
 131         memcpy(saved_command_line, *cmdline_p, CL_SIZE);
 132 
 133         /* Parse the command line for arch-specific options.
 134          * For the m68k, this is currently only "debug=xxx" to enable printing
 135          * certain kernel messages to some machine-specific device.
 136          */
 137         for( p = *cmdline_p; p && *p; ) {
 138             i = 0;
 139             if (!strncmp( p, "debug=", 6 )) {
 140                 strncpy( m68k_debug_device, p+6, sizeof(m68k_debug_device)-1 );
 141                 m68k_debug_device[sizeof(m68k_debug_device)-1] = 0;
 142                 if ((q = strchr( m68k_debug_device, ' ' ))) *q = 0;
 143                 i = 1;
 144             }
 145 
 146             if (i) {
 147                 /* option processed, delete it */
 148                 if ((q = strchr( p, ' ' )))
 149                     strcpy( p, q+1 );
 150                 else
 151                     *p = 0;
 152             } else {
 153                 if ((p = strchr( p, ' ' ))) ++p;
 154             }
 155         }
 156 
 157         *memory_start_p = memory_start;
 158         *memory_end_p = memory_end;
 159 
 160         switch (boot_info.machtype) {
 161 #ifdef CONFIG_AMIGA
 162             case MACH_AMIGA:
 163                 config_amiga();
 164                 break;
 165 #endif
 166 #ifdef CONFIG_ATARI
 167             case MACH_ATARI:
 168                 config_atari();
 169                 break;
 170 #endif
 171 #ifdef CONFIG_MAC
 172             case MACH_MAC:
 173                 config_mac();
 174                 break;
 175 #endif
 176             default:
 177                 panic ("No configuration setup");
 178         }
 179 
 180 #ifdef CONFIG_BLK_DEV_INITRD
 181         if (boot_info.ramdisk_size) {
 182                 initrd_start = PTOV (boot_info.ramdisk_addr);
 183                 initrd_end = initrd_start + boot_info.ramdisk_size * 1024;
 184         }
 185 #endif
 186 }
 187 
 188 int setkeycode(unsigned int scancode, unsigned int keycode)
     /* [previous][next][first][last][top][bottom][index][help] */
 189 {
 190         return -EOPNOTSUPP;
 191 }
 192 
 193 int getkeycode(unsigned int scancode)
     /* [previous][next][first][last][top][bottom][index][help] */
 194 {
 195         return -EOPNOTSUPP;
 196 }
 197 
 198 int get_cpuinfo(char * buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 199 {
 200     char *cpu, *mmu, *fpu;
 201     u_long clockfreq, clockfactor;
 202 
 203 #define CLOCK_FACTOR_68020      (8046)  /*  3107016 loops/s @ 25 MHz (Sun-3) */
 204 #define CLOCK_FACTOR_68030      (8010)  /*  3994575 loops/s @ 32 MHz */
 205 #define CLOCK_FACTOR_68040      (3010)  /*  8305552 loops/s @ 25 MHz */
 206 #define CLOCK_FACTOR_68060      (998)   /* 50081241 loops/s @ 50 MHz */
 207 
 208     if (boot_info.cputype & CPU_68020) {
 209         cpu = "68020";
 210         mmu = "68851";
 211         clockfactor = CLOCK_FACTOR_68020;
 212     } else if (boot_info.cputype & CPU_68030) {
 213         cpu = mmu = "68030";
 214         clockfactor = CLOCK_FACTOR_68030;
 215     } else if (boot_info.cputype & CPU_68040) {
 216         cpu = mmu = "68040";
 217         clockfactor = CLOCK_FACTOR_68040;
 218     } else if (boot_info.cputype & CPU_68060) {
 219         cpu = mmu = "68060";
 220         clockfactor = CLOCK_FACTOR_68060;
 221     } else {
 222         cpu = mmu = "680x0";
 223         clockfactor = 0;
 224     }
 225 
 226     if (boot_info.cputype & FPU_68881)
 227         fpu = "68881";
 228     else if (boot_info.cputype & FPU_68882)
 229         fpu = "68882";
 230     else if (boot_info.cputype & FPU_68040)
 231         fpu = "68040";
 232     else if (boot_info.cputype & FPU_68060)
 233         fpu = "68060";
 234     else
 235         fpu = "none";
 236 
 237     clockfreq = loops_per_sec/1000*clockfactor;
 238 
 239     return(sprintf(buffer, "CPU:\t\t%s\n"
 240                    "MMU:\t\t%s\n"
 241                    "FPU:\t\t%s\n"
 242                    "Clockspeed:\t%lu.%1luMHz\n"
 243                    "BogoMips:\t%lu.%02lu\n",
 244                    cpu, mmu, fpu, clockfreq/1000000,
 245                    ((clockfreq+50000)/100000)%10, loops_per_sec/500000,
 246                    (loops_per_sec/5000)%100));
 247 }
 248 
 249 int get_hardware_list(char *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
 250 {
 251     int len = 0;
 252     char model[80];
 253     u_long mem;
 254     int i;
 255 
 256     switch (boot_info.machtype) {
 257 #ifdef CONFIG_AMIGA
 258         case MACH_AMIGA:
 259             amiga_get_model(model);
 260             break;
 261 #endif
 262 #ifdef CONFIG_ATARI
 263         case MACH_ATARI:
 264             atari_get_model(model);
 265             break;
 266 #endif
 267 #ifdef CONFIG_MAC
 268         case MACH_MAC:
 269             mac_get_model(model);
 270             break;
 271 #endif
 272         default:
 273             strcpy(model, "Unknown m68k");
 274     } /* boot_info.machtype */
 275 
 276     len += sprintf(buffer+len, "Model:\t\t%s\n", model);
 277     len += get_cpuinfo(buffer+len);
 278     for (mem = 0, i = 0; i < boot_info.num_memory; i++)
 279         mem += boot_info.memory[i].size;
 280     len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
 281 
 282     switch (boot_info.machtype) {
 283 #ifdef CONFIG_AMIGA
 284         case MACH_AMIGA:
 285             len += amiga_get_hardware_list(buffer+len);
 286             break;
 287 #endif
 288 #ifdef CONFIG_ATARI
 289         case MACH_ATARI:
 290             len += atari_get_hardware_list(buffer+len);
 291             break;
 292 #endif
 293 #ifdef CONFIG_MAC
 294         case MACH_MAC:
 295             break;
 296 #endif
 297     } /* boot_info.machtype */
 298 
 299 #if 0 /* ++1.3++ */
 300     len += get_serial_list (buffer + len);
 301 #endif /* ++1.3++ */
 302 
 303     return(len);
 304 }
 305 
 306 #ifdef CONFIG_BLK_DEV_FD
 307 int floppy_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 308 {
 309         if (mach_floppy_init)
 310                 return mach_floppy_init();
 311         else
 312                 return 0;
 313 }
 314 
 315 void floppy_setup(char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
 316 {
 317         if (mach_floppy_setup)
 318                 mach_floppy_setup (str, ints);
 319 }
 320 #endif
 321 
 322 unsigned long arch_kbd_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 323 {
 324         return mach_keyb_init();
 325 }
 326 
 327 int rs_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 328 {
 329         return 0;
 330 }
 331 
 332 struct serial_struct;
 333 int register_serial(struct serial_struct *req)
     /* [previous][next][first][last][top][bottom][index][help] */
 334 {
 335     return -1;
 336 }
 337 
 338 void unregister_serial(int line)
     /* [previous][next][first][last][top][bottom][index][help] */
 339 {
 340 }
 341 
 342 void arch_gettod(int *year, int *mon, int *day, int *hour,
     /* [previous][next][first][last][top][bottom][index][help] */
 343                  int *min, int *sec)
 344 {
 345         if (mach_gettod)
 346                 mach_gettod(year, mon, day, hour, min, sec);
 347         else
 348                 *year = *mon = *day = *hour = *min = *sec = 0;
 349 }
 350 
 351 void video_setup (char *options, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
 352 {
 353         if (mach_video_setup)
 354                 mach_video_setup (options, ints);
 355 }

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