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

Subversion Repositories or1k_old

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
/*
2
 *  linux/arch/arm/kernel/setup.c
3
 *
4
 *  Copyright (C) 1995-1998 Russell King
5
 *
6
 * This file obtains various parameters about the system that the kernel
7
 * is running on.
8
 */
9
 
10
#include <linux/config.h>
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/user.h>
20
#include <linux/a.out.h>
21
#include <linux/tty.h>
22
#include <linux/ioport.h>
23
#include <linux/delay.h>
24
#include <linux/major.h>
25
#include <linux/utsname.h>
26
#include <linux/blk.h>
27
 
28
#include <asm/segment.h>
29
#include <asm/system.h>
30
#include <asm/hardware.h>
31
#include <asm/pgtable.h>
32
#include <asm/arch/mmu.h>
33
#include <asm/procinfo.h>
34
#include <asm/io.h>
35
#include <asm/setup.h>
36
 
37
struct drive_info_struct { char dummy[32]; } drive_info;
38
struct screen_info screen_info;
39
struct processor processor;
40
 
41
extern const struct processor arm2_processor_functions;
42
extern const struct processor arm250_processor_functions;
43
extern const struct processor arm3_processor_functions;
44
extern const struct processor arm6_processor_functions;
45
extern const struct processor arm7_processor_functions;
46
extern const struct processor sa110_processor_functions;
47
 
48
struct armversions armidlist[] = {
49
#if defined(CONFIG_CPU_ARM2) || defined(CONFIG_CPU_ARM3)
50
        { 0x41560200, 0xfffffff0, F_MEMC        , "ARM/VLSI",   "arm2"          , &arm2_processor_functions   },
51
        { 0x41560250, 0xfffffff0, F_MEMC        , "ARM/VLSI",   "arm250"        , &arm250_processor_functions },
52
        { 0x41560300, 0xfffffff0, F_MEMC|F_CACHE, "ARM/VLSI",   "arm3"          , &arm3_processor_functions   },
53
#endif
54
#if defined(CONFIG_CPU_ARM6) || defined(CONFIG_CPU_SA110)
55
        { 0x41560600, 0xfffffff0, F_MMU|F_32BIT , "ARM/VLSI",   "arm6"          , &arm6_processor_functions   },
56
        { 0x41560610, 0xfffffff0, F_MMU|F_32BIT , "ARM/VLSI",   "arm610"        , &arm6_processor_functions   },
57
        { 0x41007000, 0xffffff00, F_MMU|F_32BIT , "ARM/VLSI",   "arm7"          , &arm7_processor_functions   },
58
        /* ARM710 does not follow the spec */
59
        { 0x41007100, 0xfff8ff00, F_MMU|F_32BIT , "ARM/VLSI",   "arm710"        , &arm7_processor_functions   },
60
        { 0x4401a100, 0xfffffff0, F_MMU|F_32BIT , "DEC",        "sa110"         , &sa110_processor_functions  },
61
#endif
62
#if defined(CONFIG_CPU_ARM7)
63
        { 0x41007000, 0xffffff00, F_32BIT , "ARM/APLIO",   "arm7"               , &arm7_processor_functions   },
64
#endif
65
 
66
        { 0x00000000, 0x00000000, 0              , "***",        "*unknown*"     , NULL }
67
 
68
};
69
 
70
 
71
 
72
#ifndef CONFIG_ARCH_TRIO
73
 
74
static struct param_struct *params = (struct param_struct *) PARAMS_BASE;
75
#else
76
struct param_struct trio_params = { { {
77
        4096,                           // page_size
78
        4*1024*1024/4096,       // nr_pages
79
        0,                                       // ramdisk_size 
80
        0,                                       // flags
81
        0,                                       // rootdev
82
 
83
        80,                                     // video_num_cols
84
        24,                                     // video_num_rows
85
        0,                                       // video_x
86
        0,                                       // video_y
87
        0,                                       // bytes_per_char_h
88
        0,                                       // bytes_per_char_v
89
 
90
        0,  // initrd_start
91
        0,
92
 
93
 
94
}
95
}
96
};
97
 
98
static struct param_struct *params = &trio_params;
99
#endif
100
 
101
 
102
 
103
unsigned long arm_id;
104
unsigned int vram_half_sam;
105
int armidindex;
106
int ioebpresent;
107
int memc_ctrl_reg;
108
int number_ide_drives;
109
int number_mfm_drives;
110
 
111
extern int bytes_per_char_h;
112
extern int bytes_per_char_v;
113
extern int root_mountflags;
114
extern int _etext, _edata, _end;
115
extern unsigned long real_end_mem;
116
 
117
/*
118
 * ram disk
119
 */
120
#ifdef CONFIG_BLK_DEV_RAM
121
extern int rd_doload;           /* 1 = load ramdisk, 0 = don't load */
122
extern int rd_prompt;           /* 1 = prompt for ramdisk, 0 = don't prompt */
123
extern int rd_image_start;      /* starting block # of image */
124
 
125
static void setup_ramdisk (struct param_struct *params)
126
{
127
        rd_image_start  = params->u1.s.rd_start;
128
        rd_prompt       = (params->u1.s.flags & FLAG_RDPROMPT) == 0;
129
        rd_doload       = (params->u1.s.flags & FLAG_RDLOAD) == 0;
130
}
131
#else
132
#define setup_ramdisk(p)
133
#endif
134
 
135
/*
136
 * initial ram disk
137
 */
138
#ifdef CONFIG_BLK_DEV_INITRD
139
static void setup_initrd (struct param_struct *params, unsigned long memory_end)
140
{
141
        initrd_start = params->u1.s.initrd_start;
142
        initrd_end   = params->u1.s.initrd_start + params->u1.s.initrd_size;
143
 
144
        if (initrd_end > memory_end) {
145
                printk ("initrd extends beyond end of memory "
146
                        "(0x%08lx > 0x%08lx) - disabling initrd\n",
147
                        initrd_end, memory_end);
148
                initrd_start = 0;
149
        }
150
}
151
#else
152
#define setup_initrd(p,m)
153
#endif
154
 
155
static inline void check_ioeb_present(void)
156
{
157
#ifndef CONFIG_ARCH_TRIO        
158
        if (((*IOEB_BASE) & 15) == 5)
159
                armidlist[armidindex].features |= F_IOEB;
160
#endif
161
}
162
 
163
static void get_processor_type (void)
164
{
165
        for (armidindex = 0; ; armidindex ++)
166
                if (!((armidlist[armidindex].id ^ arm_id) &
167
                      armidlist[armidindex].mask))
168
                        break;
169
 
170
        if (armidlist[armidindex].id == 0) {
171
#ifndef CONFIG_ARCH_TRIO
172
                int i;
173
                for (i = 0; i < 3200; i++)
174
                        ((unsigned long *)SCREEN2_BASE)[i] = 0x77113322;
175
#endif
176
 
177
                while (1);
178
        }
179
 
180
        processor = *armidlist[armidindex].proc;
181
}
182
 
183
#define COMMAND_LINE_SIZE 256
184
 
185
static char command_line[COMMAND_LINE_SIZE] = { 0, };
186
       char saved_command_line[COMMAND_LINE_SIZE];
187
 
188
void setup_arch(char **cmdline_p,
189
        unsigned long * memory_start_p, unsigned long * memory_end_p)
190
{
191
        static unsigned char smptrap;
192
        unsigned long memory_start, memory_end;
193
        char c = ' ', *to = command_line, *from;
194
        int len = 0;
195
 
196
        if (smptrap == 1)
197
                return;
198
        smptrap = 1;
199
 
200
        get_processor_type ();
201
        check_ioeb_present ();
202
        processor._proc_init ();
203
 
204
        bytes_per_char_h  = params->u1.s.bytes_per_char_h;
205
        bytes_per_char_v  = params->u1.s.bytes_per_char_v;
206
        from              = params->commandline;
207
        ROOT_DEV          = to_kdev_t (params->u1.s.rootdev);
208
        ORIG_X            = params->u1.s.video_x;
209
        ORIG_Y            = params->u1.s.video_y;
210
        ORIG_VIDEO_COLS   = params->u1.s.video_num_cols;
211
        ORIG_VIDEO_LINES  = params->u1.s.video_num_rows;
212
 
213
 
214
        setup_ramdisk (params);
215
 
216
        if (!(params->u1.s.flags & FLAG_READONLY))
217
                root_mountflags &= ~MS_RDONLY;
218
 
219
        memory_start = MAPTOPHYS((unsigned long)&_end);
220
        memory_end   = GET_MEMORY_END(params);
221
 
222
        init_task.mm->start_code = TASK_SIZE;
223
        init_task.mm->end_code   = TASK_SIZE + (unsigned long) &_etext;
224
        init_task.mm->end_data   = TASK_SIZE + (unsigned long) &_edata;
225
        init_task.mm->brk        = TASK_SIZE + (unsigned long) &_end;
226
 
227
        /* Save unparsed command line copy for /proc/cmdline */
228
        memcpy(saved_command_line, from, COMMAND_LINE_SIZE);
229
        saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
230
 
231
        for (;;) {
232
                if (c == ' ' &&
233
                    from[0] == 'm' &&
234
                    from[1] == 'e' &&
235
                    from[2] == 'm' &&
236
                    from[3] == '=') {
237
                        memory_end = simple_strtoul(from+4, &from, 0);
238
                        if (*from == 'K' || *from == 'k') {
239
                                memory_end = memory_end << 10;
240
                                from++;
241
                        } else if (*from == 'M' || *from == 'm') {
242
                                memory_end = memory_end << 20;
243
                                from++;
244
                        }
245
                        memory_end = memory_end + PAGE_OFFSET;
246
                }
247
                c = *from++;
248
                if (!c)
249
                        break;
250
                if (COMMAND_LINE_SIZE <= ++len)
251
                        break;
252
                *to++ = c;
253
        }
254
 
255
        *to = '\0';
256
        *cmdline_p = command_line;
257
        *memory_start_p = memory_start;
258
        *memory_end_p = memory_end;
259
 
260
        setup_initrd (params, memory_end);
261
 
262
        strcpy (system_utsname.machine, armidlist[armidindex].name);
263
#ifdef CONFIG_SERIAL_TRIO
264
        {
265
                extern void register_console(void (*proc)(const char *));
266
                extern void console_print_trio(const char * b);
267
                register_console(console_print_trio);
268
        }
269
#endif
270
 
271
 
272
}
273
 
274
#define ISSET(bit) (armidlist[armidindex].features & bit)
275
 
276
int get_cpuinfo(char * buffer)
277
{
278
        int len;
279
 
280
        len = sprintf (buffer,  "CPU:\n"
281
                                "Type\t\t: %s\n"
282
                                "Revision\t: %d\n"
283
                                "Manufacturer\t: %s\n"
284
                                "32bit modes\t: %s\n"
285
                                "BogoMips\t: %lu.%02lu\n",
286
                                armidlist[armidindex].name,
287
                                (int)arm_id & 15,
288
                                armidlist[armidindex].manu,
289
                                ISSET (F_32BIT) ? "yes" : "no",
290
                                (loops_per_sec+2500) / 500000,
291
                                ((loops_per_sec+2500) / 5000) % 100);
292
        len += sprintf (buffer + len,
293
                                "\nHardware:\n"
294
                                "Mem System\t: %s\n"
295
                                "IOEB\t\t: %s\n",
296
                                ISSET(F_MEMC)  ? "MEMC" :
297
                                ISSET(F_MMU)   ? "MMU"  : "*unknown*",
298
                                ISSET(F_IOEB)  ? "present" : "absent"
299
                                );
300
        return len;
301
}

powered by: WebSVN 2.1.0

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