File: setup.c

package info (click to toggle)
kernel-source-2.0.32 2.0.32-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 29,648 kB
  • ctags: 86,850
  • sloc: ansic: 542,141; asm: 26,201; makefile: 3,423; sh: 1,195; perl: 727; tcl: 408; cpp: 277; lisp: 211; awk: 134
file content (350 lines) | stat: -rw-r--r-- 8,241 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*
 *  linux/arch/mips/kernel/setup.c
 *
 *  Copyright (C) 1995  Linus Torvalds
 *  Copyright (C) 1995  Ralf Baechle
 */
#include <linux/config.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/unistd.h>
#include <linux/ptrace.h>
#include <linux/malloc.h>
#include <linux/ldt.h>
#include <linux/user.h>
#include <linux/a.out.h>
#include <linux/tty.h>

#include <asm/asm.h>
#include <asm/bootinfo.h>
#include <asm/vector.h>
#include <asm/segment.h>
#include <asm/stackframe.h>
#include <asm/system.h>

/*
 * How to handle the machine's features
 */
struct feature *feature;

#ifdef CONFIG_ACER_PICA_61
void acer_pica_61_handle_int(void);
/*
 * How to access the floppy controller's ports
 */
unsigned char jazz_fd_inb(unsigned int port);
void jazz_fd_outb(unsigned char value, unsigned int port);
/*
 * How to access the floppy DMA functions.
 */
void jazz_fd_enable_dma(void);
void jazz_fd_disable_dma(void);
int jazz_fd_request_dma(void);
void jazz_fd_free_dma(void);
void jazz_fd_clear_dma_ff(void);
void jazz_fd_set_dma_mode(char mode);
void jazz_fd_set_dma_addr(unsigned int a);
void jazz_fd_set_dma_count(unsigned int count);
int jazz_fd_get_dma_residue(void);
void jazz_fd_enable_irq(void);
void jazz_fd_disable_irq(void);
void jazz_fd_cacheflush(unsigned char *addr, unsigned int size);
/*
 * How to access the RTC functions.
 */
unsigned char jazz_rtc_read_data(void);
void jazz_rtc_write_data(unsigned char data);

struct feature acer_pica_61_feature = {
	acer_pica_61_handle_int,
	/*
	 * How to access the floppy controller's ports
	 */
	jazz_fd_inb,
	jazz_fd_outb,
	/*
	 * How to access the floppy DMA functions.
	 */
	jazz_fd_enable_dma,
	jazz_fd_disable_dma,
	jazz_fd_request_dma,
	jazz_fd_free_dma,
	jazz_fd_clear_dma_ff,
	jazz_fd_set_dma_mode,
	jazz_fd_set_dma_addr,
	jazz_fd_set_dma_count,
	jazz_fd_get_dma_residue,
	jazz_fd_enable_irq,
	jazz_fd_disable_irq,
	jazz_fd_cacheflush,
	/*
	 * How to access the RTC functions.
	 */
	jazz_rtc_read_data,
	jazz_rtc_write_data
};
#endif
#ifdef CONFIG_DECSTATION
void decstation_handle_handle_int(void);
void isa_outb(unsigned char value, unsigned int port);
unsigned char isa_inb(unsigned int port);
struct feature decstation_feature = {
	decstation_handle_handle_int,
	isa_inb /* Dummy - dunno how to handle this yet */
	isa_outb, /* Dummy - dunno how to handle this yet */
};
#endif
#ifdef CONFIG_DESKSTATION_RPC44
void deskstation_rpc44_handle_int(void);
void isa_outb(unsigned char value, unsigned int port);
unsigned char isa_inb(unsigned int port);
struct feature deskstation_rpc44_feature = {
	deskstation_rpc44_handle_int,
	isa_inb
	isa_outb,
};
#endif
#ifdef CONFIG_DESKSTATION_TYNE
void deskstation_tyne_handle_int(void);
void isa_outb(unsigned char value, unsigned int port);
unsigned char isa_inb(unsigned int port);
struct feature deskstation_tyne_feature = {
	deskstation_tyne_handle_int,
	isa_inb,
	isa_outb,
};
#endif
#ifdef CONFIG_MIPS_MAGNUM_4000
void mips_magnum_4000_handle_int(void);
/*
 * How to access the floppy controller's ports
 */
unsigned char jazz_fd_inb(unsigned int port);
void jazz_fd_outb(unsigned char value, unsigned int port);
/*
 * How to access the floppy DMA functions.
 */
void jazz_fd_enable_dma(void);
void jazz_fd_disable_dma(void);
int jazz_fd_request_dma(void);
void jazz_fd_free_dma(void);
void jazz_fd_clear_dma_ff(void);
void jazz_fd_set_dma_mode(char mode);
void jazz_fd_set_dma_addr(unsigned int a);
void jazz_fd_set_dma_count(unsigned int count);
int jazz_fd_get_dma_residue(void);
void jazz_fd_enable_irq(void);
void jazz_fd_disable_irq(void);
void jazz_fd_cacheflush(unsigned char *addr, unsigned int size);
/*
 * How to access the RTC functions.
 */
unsigned char jazz_rtc_read_data(void);
void jazz_rtc_write_data(unsigned char data);

struct feature mips_magnum_4000_feature = {
	mips_magnum_4000_handle_int,
	/*
	 * How to access the floppy controller's ports
	 */
	jazz_fd_inb,
	jazz_fd_outb,
	/*
	 * How to access the floppy DMA functions.
	 */
	jazz_fd_enable_dma,
	jazz_fd_disable_dma,
	jazz_fd_request_dma,
	jazz_fd_free_dma,
	jazz_fd_clear_dma_ff,
	jazz_fd_set_dma_mode,
	jazz_fd_set_dma_addr,
	jazz_fd_set_dma_count,
	jazz_fd_get_dma_residue,
	jazz_fd_enable_irq,
	jazz_fd_disable_irq,
	jazz_fd_cacheflush,
	/*
	 * How to access the RTC functions.
	 */
	jazz_rtc_read_data,
	jazz_rtc_write_data
};
#endif

/*
 * Tell us the machine setup..
 */
char wait_available;		/* set if the "wait" instruction available */

/*
 * Bus types ..
 */
int EISA_bus = 0;

/*
 * Setup options
 */
struct drive_info_struct drive_info;
struct screen_info screen_info = SCREEN_INFO;

unsigned char aux_device_present;
extern int ramdisk_size;
extern int root_mountflags;
extern int _end;

extern char empty_zero_page[PAGE_SIZE];

/*
 * Initialise this structure so that it will be placed in the
 * .data section of the object file
 */
struct bootinfo boot_info = BOOT_INFO;

/*
 * This is set up by the setup-routine at boot-time
 */
#define PARAM	empty_zero_page
#if 0
#define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
#define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
#endif

static char command_line[CL_SIZE] = { 0, };
       char saved_command_line[CL_SIZE];

#if 0
/*
 * Code for easy access to new style bootinfo
 *
 * Parameter:  tag      -- taglist entry
 *
 * returns  :  (tag *) -- pointer to taglist entry, NULL for not found
 */
tag *
bi_TagFind(enum bi_tag tag)
{
	/* TBD */
	return 0;
}

/*
 * Only for taglist creators (bootloaders)
 *
 * Parameter:  tag       -- (enum bi_tag) taglist entry
 *
 * returns  :  1         -- success
 *             0         -- failure
 */
int
bi_TagAdd(enum bi_tag tag, unsigned long size, void *tagdata)
{
	/* TBD */
	return 0;
}
#endif /* 0 */

void setup_arch(char **cmdline_p,
	unsigned long * memory_start_p, unsigned long * memory_end_p)
{
	unsigned long memory_start, memory_end;

	switch(boot_info.machtype)
	{
#ifdef CONFIG_ACER_PICA_61
	case MACH_ACER_PICA_61:
		feature = &acer_pica_61_feature;
		break;
#endif
#ifdef CONFIG_DECSTATION
	case MACH_DECSTATION:
		feature = &decstation_feature;
		break;
#endif
#ifdef CONFIG_DESKSTATION_RPC
	case MACH_DESKSTATION_RPC:
		feature = &deskstation_rpc44_feature;
		break;
#endif
#ifdef CONFIG_DESKSTATION_TYNE
	case MACH_DESKSTATION_TYNE:
		feature = &deskstation_tyne_feature;
		break;
#endif
#ifdef CONFIG_MIPS_MAGNUM_4000
	case MACH_MIPS_MAGNUM_4000:
		feature = &mips_magnum_4000_feature;
		break;
#endif
	default:
		panic("Unsupported architecture");
	}

#if 0
 	ROOT_DEV = to_kdev_t(ORIG_ROOT_DEV);
#else
#ifdef CONFIG_BLK_DEV_FD
	ROOT_DEV = to_kdev_t(0x021c);	/* fd0H1440 */
#else
	ROOT_DEV = to_kdev_t(0x0101);	/* ram */ 
#endif
/*	ROOT_DEV = to_kdev_t(0x00ff); */	/* NFS */
#endif
 	memcpy(&drive_info, &boot_info.drive_info, sizeof(drive_info));
#if 0
	aux_device_present = AUX_DEVICE_INFO;
#endif
	memory_end = boot_info.memupper;
	memory_end &= PAGE_MASK;
	ramdisk_size = boot_info.ramdisk_size;
	if (boot_info.mount_root_rdonly)
		root_mountflags |= MS_RDONLY;

	memory_start = (unsigned long) &_end;
	memory_start += (ramdisk_size << 10);

	memcpy(saved_command_line, command_line, CL_SIZE);
	saved_command_line[CL_SIZE-1] = '\0';

	*cmdline_p = command_line;
	*memory_start_p = memory_start;
	*memory_end_p = memory_end;

#if 0
	/*
	 * Check that struct pt_regs is defined properly
	 * (Should be optimized away, but gcc 2.6.3 is too bad..)
	 */
	if (FR_SIZE != sizeof(struct pt_regs) ||
	    FR_SIZE & 7)
	{
		panic("Check_definition_of_struct_pt_regs\n");
	}
#endif
}

#ifdef CONFIG_PROC_FS
/*
 * BUFFER is PAGE_SIZE bytes long.
 */
int get_cpuinfo(char *buffer)
{
	const char *cpu_name[] = CPU_NAMES;
	const char *mach_name[] = MACH_NAMES;

	return sprintf(buffer,
		       "cpu\t\t\t: MIPS\n"
		       "cpu model\t\t: %s\n"
		       "system type\t\t: %s\n"
		       "BogoMIPS\t\t: %lu.%02lu\n",

		       cpu_name[boot_info.cputype < CPU_LAST ? boot_info.cputype : CPU_UNKNOWN],
		       mach_name[boot_info.machtype < CPU_LAST ? boot_info.machtype : CPU_UNKNOWN],
		       loops_per_sec / 500000, (loops_per_sec / 5000) % 100);
}
#endif /* CONFIG_PROC_FS */