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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [or32/] [kernel/] [setup.c] - Blame information for rev 666

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 666 simons
/*
2
 *  linux/arch/or32/kernel/setup.c
3
 *
4
 * Based on m86k
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/fb.h>
18
#include <linux/console.h>
19
#include <linux/genhd.h>
20
#include <linux/errno.h>
21
#include <linux/string.h>
22
#include <linux/major.h>
23
 
24
#include <asm/irq.h>
25
#include <asm/machdep.h>
26
 
27
#ifdef CONFIG_BLK_DEV_INITRD
28
#include <linux/blk.h>
29
#include <asm/pgtable.h>
30
#endif
31
 
32
extern void register_console(void (*proc)(const char *));
33
#ifdef CONFIG_CONSOLE
34
extern struct consw *conswitchp;
35
#ifdef CONFIG_FRAMEBUFFER
36
extern struct consw fb_con;
37
#endif
38
#endif
39
 
40
#ifdef CONFIG_BLK_DEV_INITRD
41
extern unsigned long _initrd_start;
42
extern unsigned long _initrd_end;
43
#endif
44
 
45
unsigned long rom_length;
46
unsigned long memory_start;
47
unsigned long memory_end;
48
 
49
char command_line[512];
50
char saved_command_line[512];
51
char console_device[16];
52
 
53
char console_default[] = "CONSOLE=/dev/ttyS0";
54
 
55
/* setup some dummy routines */
56
static void dummy_waitbut(void)
57
{
58
}
59
 
60
void (*mach_sched_init) (void (*handler)(int, void *, struct pt_regs *)) = NULL;
61
void (*mach_tick)( void ) = NULL;
62
/* machine dependent keyboard functions */
63
int (*mach_keyb_init) (void) = NULL;
64
int (*mach_kbdrate) (struct kbd_repeat *) = NULL;
65
void (*mach_kbd_leds) (unsigned int) = NULL;
66
/* machine dependent irq functions */
67
void (*mach_init_IRQ) (void) = NULL;
68
void (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL;
69
int (*mach_request_irq) (unsigned int, void (*)(int, void *, struct pt_regs *),
70
                         unsigned long, const char *, void *);
71
int (*mach_free_irq) (unsigned int, void *);
72
void (*mach_enable_irq) (unsigned int) = NULL;
73
void (*mach_disable_irq) (unsigned int) = NULL;
74
int (*mach_get_irq_list) (char *) = NULL;
75
int (*mach_process_int) (int, struct pt_regs *) = NULL;
76
void (*mach_trap_init) (void);
77
/* machine dependent timer functions */
78
unsigned long (*mach_gettimeoffset) (void) = NULL;
79
void (*mach_gettod) (int*, int*, int*, int*, int*, int*) = NULL;
80
int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
81
int (*mach_set_clock_mmss) (unsigned long) = NULL;
82
void (*mach_mksound)( unsigned int count, unsigned int ticks ) = NULL;
83
void (*mach_reset)( void ) = NULL;
84
void (*waitbut)(void) = dummy_waitbut;
85
void (*mach_debug_init)(void) = NULL;
86
 
87
 
88
#ifdef CONFIG_OR32
89
        #define CPU "OR32"
90
#endif
91
 
92
/*
93
 *      Setup the console. There may be a console defined in
94
 *      the command line arguments, so we look there first. If the
95
 *      command line arguments don't exist then we default to the
96
 *      first serial port. If we are going to use a console then
97
 *      setup its device name and the UART for it.
98
 */
99
void setup_console(void)
100
{
101
        char *sp, *cp;
102
        int i;
103
        extern void rs_console_init(void);
104
        extern void rs_console_print(const char *b);
105
#ifdef CONFIG_SERIAL
106
        extern int rs_console_setup(char *arg);
107
#endif
108
        /* Quickly check if any command line arguments for CONSOLE. */
109
        for (sp = NULL, i = 0; (i < sizeof(command_line)-8); i++) {
110
                if (command_line[i] == 0)
111
                        break;
112
                if (command_line[i] == 'C') {
113
                        if (!strncmp(&command_line[i], "CONSOLE=", 8)) {
114
                                sp = &command_line[i + 8];
115
                                break;
116
                        }
117
                }
118
        }
119
 
120
        /* If no CONSOLE defined then default one */
121
        if (sp == NULL) {
122
                strcpy(command_line, console_default);
123
                sp = command_line + 8;
124
        }
125
 
126
        /* If console specified then copy it into name buffer */
127
        for (cp = sp, i = 0; (i < (sizeof(console_device) - 1)); i++) {
128
                if ((*sp == 0) || (*sp == ' ') || (*sp == ','))
129
                        break;
130
                console_device[i] = *sp++;
131
        }
132
        console_device[i] = 0;
133
 
134
#ifdef CONFIG_SERIAL
135
        /* If a serial console then init it */
136
        if (rs_console_setup(cp)) {
137
                rs_console_init();
138
                register_console(rs_console_print);
139
        }
140
#endif
141
}
142
 
143
#if defined( CONFIG_GEN) && defined( CONFIG_OR32 )
144
#define CAT_ROMARRAY
145
#endif
146
 
147
void setup_arch(char **cmdline_p,
148
                unsigned long * memory_start_p, unsigned long * memory_end_p)
149
{
150
        extern int _stext, _etext;
151
        extern int _sdata, _edata;
152
        extern int _sbss, _ebss, _end;
153
        extern int _ramstart, _ramend;
154
 
155
#ifdef CAT_ROMARRAY
156
        extern int __data_rom_start;
157
        extern int __data_start;
158
#endif
159
 
160
        memory_start = (unsigned long)&_end;
161
        memory_end = (unsigned long)&_ramend - 4096; /* <- stack area */
162
        config_BSP(&command_line[0], sizeof(command_line));
163
        setup_console();
164
  printk("\nOpenRisc 1000 support (C) www.opencores.org\n");
165
        printk("\r\n\nuClinux/" CPU "\n");
166
        printk("Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
167
 
168
#ifdef DEBUG
169
        printk("KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
170
                "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
171
                (int) &_sdata, (int) &_edata,
172
                (int) &_sbss, (int) &_ebss);
173
        printk("KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
174
                "STACK=0x%06x-0x%06x\n",
175
                (int) &_ebss, (int) memory_start,
176
                (int) memory_start, (int) memory_end,
177
                (int) memory_end, (int) &_ramend);
178
#endif
179
 
180
        init_task.mm->start_code = (unsigned long) &_stext;
181
        init_task.mm->end_code = (unsigned long) &_etext;
182
        init_task.mm->end_data = (unsigned long) &_edata;
183
        init_task.mm->brk = (unsigned long) &_end;
184
 
185
        ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);
186
 
187
        /* Keep a copy of command line */
188
        *cmdline_p = &command_line[0];
189
 
190
        memcpy(saved_command_line, command_line, sizeof(saved_command_line));
191
        saved_command_line[sizeof(saved_command_line)-1] = 0;
192
 
193
#ifdef DEBUG
194
        if (strlen(*cmdline_p))
195
                printk("Command line: '%s'\n", *cmdline_p);
196
        else
197
                printk("No Command line passed\n");
198
#endif
199
        *memory_start_p = memory_start;
200
        *memory_end_p = memory_end;
201
        /*rom_length = (unsigned long)&_flashend - (unsigned long)&_romvec;*/
202
 
203
#ifdef CONFIG_BLK_DEV_INITRD
204
        initrd_start = (unsigned long)&_initrd_start;
205
        initrd_end = (unsigned long)&_initrd_end;
206
#endif
207
 
208
 
209
#ifdef CONFIG_CONSOLE
210
#ifdef CONFIG_FRAMEBUFFER
211
        conswitchp = &fb_con;
212
#else
213
        conswitchp = 0;
214
#endif
215
#endif
216
 
217
#ifdef DEBUG
218
        printk("Done setup_arch\n");
219
#endif
220
 
221
}
222
 
223
int get_cpuinfo(char * buffer)
224
{
225
    char *cpu, *mmu, *fpu;
226
    u_long clockfreq, clockfactor;
227
 
228
    cpu = CPU;
229
    mmu = "none";
230
    fpu = "none";
231
    clockfactor = 16;
232
 
233
    clockfreq = loops_per_sec*clockfactor;
234
 
235
    return(sprintf(buffer, "CPU:\t\t%s\n"
236
                   "MMU:\t\t%s\n"
237
                   "FPU:\t\t%s\n"
238
                   "Clocking:\t%lu.%1luMHz\n"
239
                   "BogoMips:\t%lu.%02lu\n"
240
                   "Calibration:\t%lu loops\n",
241
                   cpu, mmu, fpu,
242
                   clockfreq/1000000,(clockfreq/100000)%10,
243
                   loops_per_sec/500000,(loops_per_sec/5000)%100,
244
                   loops_per_sec));
245
 
246
}
247
 
248
void arch_gettod(int *year, int *mon, int *day, int *hour,
249
                 int *min, int *sec)
250
{
251
        if (mach_gettod)
252
                mach_gettod(year, mon, day, hour, min, sec);
253
        else
254
                *year = *mon = *day = *hour = *min = *sec = 0;
255
}
256
 

powered by: WebSVN 2.1.0

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