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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [or32/] [kernel/] [setup.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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