OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [m68k/] [kernel/] [setup.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*
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)
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, void *);
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_mksound)( unsigned int count, unsigned int ticks );
66
void (*mach_reset)( void );
67
void (*waitbut)(void) = dummy_waitbut;
68
struct fb_info *(*mach_fb_init)(long *);
69
long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
70
void (*mach_debug_init)(void);
71
void (*mach_video_setup) (char *, int *);
72
#ifdef CONFIG_BLK_DEV_FD
73
int (*mach_floppy_init) (void) = NULL;
74
void (*mach_floppy_setup) (char *, int *) = NULL;
75
void (*mach_floppy_eject) (void) = 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,
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
        /* clear the fpu if we have one */
120
        if (boot_info.cputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
121
                volatile int zero = 0;
122
                asm __volatile__ ("frestore %0" : : "m" (zero));
123
        }
124
 
125
        memory_start = availmem;
126
        memory_end = 0;
127
 
128
        for (i = 0; i < boot_info.num_memory; i++)
129
                memory_end += boot_info.memory[i].size & MASK_256K;
130
 
131
        init_task.mm->start_code = 0;
132
        init_task.mm->end_code = (unsigned long) &_etext;
133
        init_task.mm->end_data = (unsigned long) &_edata;
134
        init_task.mm->brk = (unsigned long) &_end;
135
 
136
        *cmdline_p = boot_info.command_line;
137
        memcpy(saved_command_line, *cmdline_p, CL_SIZE);
138
 
139
        /* Parse the command line for arch-specific options.
140
         * For the m68k, this is currently only "debug=xxx" to enable printing
141
         * certain kernel messages to some machine-specific device.
142
         */
143
        for( p = *cmdline_p; p && *p; ) {
144
            i = 0;
145
            if (!strncmp( p, "debug=", 6 )) {
146
                strncpy( m68k_debug_device, p+6, sizeof(m68k_debug_device)-1 );
147
                m68k_debug_device[sizeof(m68k_debug_device)-1] = 0;
148
                if ((q = strchr( m68k_debug_device, ' ' ))) *q = 0;
149
                i = 1;
150
            }
151
 
152
            if (i) {
153
                /* option processed, delete it */
154
                if ((q = strchr( p, ' ' )))
155
                    strcpy( p, q+1 );
156
                else
157
                    *p = 0;
158
            } else {
159
                if ((p = strchr( p, ' ' ))) ++p;
160
            }
161
        }
162
 
163
        *memory_start_p = memory_start;
164
        *memory_end_p = memory_end;
165
 
166
        switch (boot_info.machtype) {
167
#ifdef CONFIG_AMIGA
168
            case MACH_AMIGA:
169
                config_amiga();
170
                break;
171
#endif
172
#ifdef CONFIG_ATARI
173
            case MACH_ATARI:
174
                config_atari();
175
                break;
176
#endif
177
#ifdef CONFIG_MAC
178
            case MACH_MAC:
179
                config_mac();
180
                break;
181
#endif
182
            default:
183
                panic ("No configuration setup");
184
        }
185
 
186
#ifdef CONFIG_BLK_DEV_INITRD
187
        if (boot_info.ramdisk_size) {
188
                initrd_start = PTOV (boot_info.ramdisk_addr);
189
                initrd_end = initrd_start + boot_info.ramdisk_size * 1024;
190
        }
191
#endif
192
}
193
 
194
int setkeycode(unsigned int scancode, unsigned int keycode)
195
{
196
        return -EOPNOTSUPP;
197
}
198
 
199
int getkeycode(unsigned int scancode)
200
{
201
        return -EOPNOTSUPP;
202
}
203
 
204
int get_cpuinfo(char * buffer)
205
{
206
    char *cpu, *mmu, *fpu;
207
    u_long clockfreq, clockfactor;
208
 
209
#define CLOCK_FACTOR_68020      (8046)  /*  3107016 loops/s @ 25 MHz (Sun-3) */
210
#define CLOCK_FACTOR_68030      (8010)  /*  3994575 loops/s @ 32 MHz */
211
#define CLOCK_FACTOR_68040      (3010)  /*  8305552 loops/s @ 25 MHz */
212
#define CLOCK_FACTOR_68060      (998)   /* 50081241 loops/s @ 50 MHz */
213
 
214
    if (boot_info.cputype & CPU_68020) {
215
        cpu = "68020";
216
        mmu = "68851";
217
        clockfactor = CLOCK_FACTOR_68020;
218
    } else if (boot_info.cputype & CPU_68030) {
219
        cpu = mmu = "68030";
220
        clockfactor = CLOCK_FACTOR_68030;
221
    } else if (boot_info.cputype & CPU_68040) {
222
        cpu = mmu = "68040";
223
        clockfactor = CLOCK_FACTOR_68040;
224
    } else if (boot_info.cputype & CPU_68060) {
225
        cpu = mmu = "68060";
226
        clockfactor = CLOCK_FACTOR_68060;
227
    } else {
228
        cpu = mmu = "680x0";
229
        clockfactor = 0;
230
    }
231
 
232
    if (boot_info.cputype & FPU_68881)
233
        fpu = "68881";
234
    else if (boot_info.cputype & FPU_68882)
235
        fpu = "68882";
236
    else if (boot_info.cputype & FPU_68040)
237
        fpu = "68040";
238
    else if (boot_info.cputype & FPU_68060)
239
        fpu = "68060";
240
    else
241
        fpu = "none";
242
 
243
    clockfreq = loops_per_sec/1000*clockfactor;
244
 
245
    return(sprintf(buffer, "CPU:\t\t%s\n"
246
                   "MMU:\t\t%s\n"
247
                   "FPU:\t\t%s\n"
248
                   "Clockspeed:\t%lu.%1luMHz\n"
249
                   "BogoMips:\t%lu.%02lu\n",
250
                   cpu, mmu, fpu, (clockfreq+50000)/1000000,
251
                   ((clockfreq+50000)/100000)%10, loops_per_sec/500000,
252
                   (loops_per_sec/5000)%100));
253
}
254
 
255
int get_hardware_list(char *buffer)
256
{
257
    int len = 0;
258
    char model[80];
259
    u_long mem;
260
    int i;
261
 
262
    switch (boot_info.machtype) {
263
#ifdef CONFIG_AMIGA
264
        case MACH_AMIGA:
265
            amiga_get_model(model);
266
            break;
267
#endif
268
#ifdef CONFIG_ATARI
269
        case MACH_ATARI:
270
            atari_get_model(model);
271
            break;
272
#endif
273
#ifdef CONFIG_MAC
274
        case MACH_MAC:
275
            mac_get_model(model);
276
            break;
277
#endif
278
        default:
279
            strcpy(model, "Unknown m68k");
280
    } /* boot_info.machtype */
281
 
282
    len += sprintf(buffer+len, "Model:\t\t%s\n", model);
283
    len += get_cpuinfo(buffer+len);
284
    for (mem = 0, i = 0; i < boot_info.num_memory; i++)
285
        mem += boot_info.memory[i].size;
286
    len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
287
 
288
    switch (boot_info.machtype) {
289
#ifdef CONFIG_AMIGA
290
        case MACH_AMIGA:
291
            len += amiga_get_hardware_list(buffer+len);
292
            break;
293
#endif
294
#ifdef CONFIG_ATARI
295
        case MACH_ATARI:
296
            len += atari_get_hardware_list(buffer+len);
297
            break;
298
#endif
299
#ifdef CONFIG_MAC
300
        case MACH_MAC:
301
            break;
302
#endif
303
    } /* boot_info.machtype */
304
 
305
    return(len);
306
}
307
 
308
#ifdef CONFIG_BLK_DEV_FD
309
int floppy_init(void)
310
{
311
        if (mach_floppy_init)
312
                return mach_floppy_init();
313
        else
314
                return 0;
315
}
316
 
317
void floppy_setup(char *str, int *ints)
318
{
319
        if (mach_floppy_setup)
320
                mach_floppy_setup (str, ints);
321
}
322
 
323
void floppy_eject(void)
324
{
325
        if (mach_floppy_eject)
326
                mach_floppy_eject();
327
}
328
#endif
329
 
330
unsigned long arch_kbd_init(void)
331
{
332
        return mach_keyb_init();
333
}
334
 
335
void arch_gettod(int *year, int *mon, int *day, int *hour,
336
                 int *min, int *sec)
337
{
338
        if (mach_gettod)
339
                mach_gettod(year, mon, day, hour, min, sec);
340
        else
341
                *year = *mon = *day = *hour = *min = *sec = 0;
342
}
343
 
344
void video_setup (char *options, int *ints)
345
{
346
        if (mach_video_setup)
347
                mach_video_setup (options, ints);
348
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.