summaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/setup-ebsa110.c
blob: 8cbfe7dc31580e19baf4e96970c9b81ee4beed06 (plain)
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
/*
 *  linux/arch/arm/kernel/setup-sa.c
 *
 *  Copyright (C) 1995, 1996 Russell King
 */

/*
 * This file obtains various parameters about the system that the kernel
 * is running on.
 */

#include <linux/config.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/stddef.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 <linux/ioport.h>
#include <linux/delay.h>
#include <linux/major.h>
#include <linux/utsname.h>
#include <linux/init.h>

#include <asm/hardware.h>
#include <asm/pgtable.h>
#include <asm/segment.h>
#include <asm/setup.h>
#include <asm/system.h>

#ifndef CONFIG_CMDLINE
#define CONFIG_CMDLINE	"root=nfs rw console=ttyS1,38400n8"
#endif
#define COMMAND_LINE_SIZE 256

#define MEM_SIZE	(16*1024*1024)

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

struct processor processor;
struct screen_info screen_info;
unsigned char aux_device_present;
unsigned long arm_id;

extern int root_mountflags;
extern int _etext, _edata, _end;
extern const struct processor sa110_processor_functions;

#ifdef CONFIG_BLK_DEV_RAM
extern int rd_doload;		/* 1 = load ramdisk, 0 = don't load */
extern int rd_prompt;		/* 1 = prompt for ramdisk, 0 = don't prompt */
extern int rd_image_start;	/* starting block # of image */

static inline void setup_ramdisk(int start, int prompt, int load)
{
	rd_image_start	= start;
	rd_prompt	= prompt;
	rd_doload	= load;
}
#else
#define setup_ramdisk(start,prompt,load)
#endif

#ifdef PARAMS_BASE
static struct param_struct *params = (struct param_struct *)PARAMS_BASE;

static inline char *setup_params(unsigned long *mem_end_p)
{
	ROOT_DEV	  = to_kdev_t(params->u1.s.rootdev);
	ORIG_X		  = params->u1.s.video_x;
	ORIG_Y		  = params->u1.s.video_y;
	ORIG_VIDEO_COLS	  = params->u1.s.video_num_cols;
	ORIG_VIDEO_LINES  = params->u1.s.video_num_rows;

	setup_ramdisk(params->u1.s.rd_start,
		      (params->u1.s.flags & FLAG_RDPROMPT) == 0,
		      (params->u1.s.flags & FLAG_RDLOAD) == 0);

	*mem_end_p = 0xc0000000 + MEM_SIZE;

	return params->commandline;
}
#else
static char default_command_line[] = CONFIG_CMDLINE;

static inline char *setup_params(unsigned long *mem_end_p)
{
	ROOT_DEV	  = 0x00ff;

	setup_ramdisk(0, 1, 1);

	*mem_end_p = 0xc0000000 + MEM_SIZE;

	return default_command_line;
}
#endif

__initfunc(void setup_arch(char **cmdline_p,
	unsigned long * memory_start_p, unsigned long * memory_end_p))
{
	unsigned long memory_start, memory_end;
	char c = ' ', *to = command_line, *from;
	int len = 0;

	memory_start = (unsigned long)&_end;

	processor = sa110_processor_functions;
	processor._proc_init();

	from = setup_params(&memory_end);

	init_task.mm->start_code = TASK_SIZE;
	init_task.mm->end_code	 = TASK_SIZE + (unsigned long) &_etext;
	init_task.mm->end_data	 = TASK_SIZE + (unsigned long) &_edata;
	init_task.mm->brk	 = TASK_SIZE + (unsigned long) &_end;

	/* Save unparsed command line copy for /proc/cmdline */
	memcpy(saved_command_line, from, COMMAND_LINE_SIZE);
	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';

	for (;;) {
		if (c == ' ' &&
		    from[0] == 'm' &&
		    from[1] == 'e' &&
		    from[2] == 'm' &&
		    from[3] == '=') {
			memory_end = simple_strtoul(from+4, &from, 0);
			if ( *from == 'K' || *from == 'k' ) {
				memory_end = memory_end << 10;
				from++;
			} else if ( *from == 'M' || *from == 'm' ) {
				memory_end = memory_end << 20;
				from++;
			}
			memory_end = memory_end + PAGE_OFFSET;
		}
		c = *from++;
		if (!c)
			break;
		if (COMMAND_LINE_SIZE <= ++len)
			break;
		*to++ = c;
	}

	*to = '\0';
	*cmdline_p = command_line;
	*memory_start_p = memory_start;
	*memory_end_p = memory_end;
	strcpy (system_utsname.machine, "sa110");
}

int get_cpuinfo(char * buffer)
{
	int len;

	len = sprintf (buffer,  "CPU:\n"
				"Type\t\t: %s\n"
				"Revision\t: %d\n"
				"Manufacturer\t: %s\n"
				"32bit modes\t: %s\n"
				"BogoMips\t: %lu.%02lu\n",
				"sa110",
				(int)arm_id & 15,
				"DEC",
				"yes",
				(loops_per_sec+2500) / 500000,
				((loops_per_sec+2500) / 5000) % 100);
	return len;
}