Linux 2.6.13-rc4
[linux-2.6/next.git] / arch / arm / kernel / compat.c
blob7195add42e74cab407e4478743993246b04a62ee
1 /*
2 * linux/arch/arm/kernel/compat.c
4 * Copyright (C) 2001 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * We keep the old params compatibility cruft in one place (here)
11 * so we don't end up with lots of mess around other places.
13 * NOTE:
14 * The old struct param_struct is deprecated, but it will be kept in
15 * the kernel for 5 years from now (2001). This will allow boot loaders
16 * to convert to the new struct tag way.
18 #include <linux/config.h>
19 #include <linux/types.h>
20 #include <linux/kernel.h>
21 #include <linux/string.h>
22 #include <linux/init.h>
24 #include <asm/setup.h>
25 #include <asm/mach-types.h>
26 #include <asm/page.h>
28 #include <asm/mach/arch.h>
31 * Usage:
32 * - do not go blindly adding fields, add them at the end
33 * - when adding fields, don't rely on the address until
34 * a patch from me has been released
35 * - unused fields should be zero (for future expansion)
36 * - this structure is relatively short-lived - only
37 * guaranteed to contain useful data in setup_arch()
39 * This is the old deprecated way to pass parameters to the kernel
41 struct param_struct {
42 union {
43 struct {
44 unsigned long page_size; /* 0 */
45 unsigned long nr_pages; /* 4 */
46 unsigned long ramdisk_size; /* 8 */
47 unsigned long flags; /* 12 */
48 #define FLAG_READONLY 1
49 #define FLAG_RDLOAD 4
50 #define FLAG_RDPROMPT 8
51 unsigned long rootdev; /* 16 */
52 unsigned long video_num_cols; /* 20 */
53 unsigned long video_num_rows; /* 24 */
54 unsigned long video_x; /* 28 */
55 unsigned long video_y; /* 32 */
56 unsigned long memc_control_reg; /* 36 */
57 unsigned char sounddefault; /* 40 */
58 unsigned char adfsdrives; /* 41 */
59 unsigned char bytes_per_char_h; /* 42 */
60 unsigned char bytes_per_char_v; /* 43 */
61 unsigned long pages_in_bank[4]; /* 44 */
62 unsigned long pages_in_vram; /* 60 */
63 unsigned long initrd_start; /* 64 */
64 unsigned long initrd_size; /* 68 */
65 unsigned long rd_start; /* 72 */
66 unsigned long system_rev; /* 76 */
67 unsigned long system_serial_low; /* 80 */
68 unsigned long system_serial_high; /* 84 */
69 unsigned long mem_fclk_21285; /* 88 */
70 } s;
71 char unused[256];
72 } u1;
73 union {
74 char paths[8][128];
75 struct {
76 unsigned long magic;
77 char n[1024 - sizeof(unsigned long)];
78 } s;
79 } u2;
80 char commandline[COMMAND_LINE_SIZE];
83 static struct tag * __init memtag(struct tag *tag, unsigned long start, unsigned long size)
85 tag = tag_next(tag);
86 tag->hdr.tag = ATAG_MEM;
87 tag->hdr.size = tag_size(tag_mem32);
88 tag->u.mem.size = size;
89 tag->u.mem.start = start;
91 return tag;
94 static void __init build_tag_list(struct param_struct *params, void *taglist)
96 struct tag *tag = taglist;
98 if (params->u1.s.page_size != PAGE_SIZE) {
99 printk(KERN_WARNING "Warning: bad configuration page, "
100 "trying to continue\n");
101 return;
104 printk(KERN_DEBUG "Converting old-style param struct to taglist\n");
106 #ifdef CONFIG_ARCH_NETWINDER
107 if (params->u1.s.nr_pages != 0x02000 &&
108 params->u1.s.nr_pages != 0x04000 &&
109 params->u1.s.nr_pages != 0x08000 &&
110 params->u1.s.nr_pages != 0x10000) {
111 printk(KERN_WARNING "Warning: bad NeTTrom parameters "
112 "detected, using defaults\n");
114 params->u1.s.nr_pages = 0x1000; /* 16MB */
115 params->u1.s.ramdisk_size = 0;
116 params->u1.s.flags = FLAG_READONLY;
117 params->u1.s.initrd_start = 0;
118 params->u1.s.initrd_size = 0;
119 params->u1.s.rd_start = 0;
121 #endif
123 tag->hdr.tag = ATAG_CORE;
124 tag->hdr.size = tag_size(tag_core);
125 tag->u.core.flags = params->u1.s.flags & FLAG_READONLY;
126 tag->u.core.pagesize = params->u1.s.page_size;
127 tag->u.core.rootdev = params->u1.s.rootdev;
129 tag = tag_next(tag);
130 tag->hdr.tag = ATAG_RAMDISK;
131 tag->hdr.size = tag_size(tag_ramdisk);
132 tag->u.ramdisk.flags = (params->u1.s.flags & FLAG_RDLOAD ? 1 : 0) |
133 (params->u1.s.flags & FLAG_RDPROMPT ? 2 : 0);
134 tag->u.ramdisk.size = params->u1.s.ramdisk_size;
135 tag->u.ramdisk.start = params->u1.s.rd_start;
137 tag = tag_next(tag);
138 tag->hdr.tag = ATAG_INITRD;
139 tag->hdr.size = tag_size(tag_initrd);
140 tag->u.initrd.start = params->u1.s.initrd_start;
141 tag->u.initrd.size = params->u1.s.initrd_size;
143 tag = tag_next(tag);
144 tag->hdr.tag = ATAG_SERIAL;
145 tag->hdr.size = tag_size(tag_serialnr);
146 tag->u.serialnr.low = params->u1.s.system_serial_low;
147 tag->u.serialnr.high = params->u1.s.system_serial_high;
149 tag = tag_next(tag);
150 tag->hdr.tag = ATAG_REVISION;
151 tag->hdr.size = tag_size(tag_revision);
152 tag->u.revision.rev = params->u1.s.system_rev;
154 #ifdef CONFIG_ARCH_ACORN
155 if (machine_is_riscpc()) {
156 int i;
157 for (i = 0; i < 4; i++)
158 tag = memtag(tag, PHYS_OFFSET + (i << 26),
159 params->u1.s.pages_in_bank[i] * PAGE_SIZE);
160 } else
161 #endif
162 tag = memtag(tag, PHYS_OFFSET, params->u1.s.nr_pages * PAGE_SIZE);
164 #ifdef CONFIG_FOOTBRIDGE
165 if (params->u1.s.mem_fclk_21285) {
166 tag = tag_next(tag);
167 tag->hdr.tag = ATAG_MEMCLK;
168 tag->hdr.size = tag_size(tag_memclk);
169 tag->u.memclk.fmemclk = params->u1.s.mem_fclk_21285;
171 #endif
173 #ifdef CONFIG_ARCH_EBSA285
174 if (machine_is_ebsa285()) {
175 tag = tag_next(tag);
176 tag->hdr.tag = ATAG_VIDEOTEXT;
177 tag->hdr.size = tag_size(tag_videotext);
178 tag->u.videotext.x = params->u1.s.video_x;
179 tag->u.videotext.y = params->u1.s.video_y;
180 tag->u.videotext.video_page = 0;
181 tag->u.videotext.video_mode = 0;
182 tag->u.videotext.video_cols = params->u1.s.video_num_cols;
183 tag->u.videotext.video_ega_bx = 0;
184 tag->u.videotext.video_lines = params->u1.s.video_num_rows;
185 tag->u.videotext.video_isvga = 1;
186 tag->u.videotext.video_points = 8;
188 #endif
190 #ifdef CONFIG_ARCH_ACORN
191 tag = tag_next(tag);
192 tag->hdr.tag = ATAG_ACORN;
193 tag->hdr.size = tag_size(tag_acorn);
194 tag->u.acorn.memc_control_reg = params->u1.s.memc_control_reg;
195 tag->u.acorn.vram_pages = params->u1.s.pages_in_vram;
196 tag->u.acorn.sounddefault = params->u1.s.sounddefault;
197 tag->u.acorn.adfsdrives = params->u1.s.adfsdrives;
198 #endif
200 tag = tag_next(tag);
201 tag->hdr.tag = ATAG_CMDLINE;
202 tag->hdr.size = (strlen(params->commandline) + 3 +
203 sizeof(struct tag_header)) >> 2;
204 strcpy(tag->u.cmdline.cmdline, params->commandline);
206 tag = tag_next(tag);
207 tag->hdr.tag = ATAG_NONE;
208 tag->hdr.size = 0;
210 memmove(params, taglist, ((int)tag) - ((int)taglist) +
211 sizeof(struct tag_header));
214 void __init convert_to_tag_list(struct tag *tags)
216 struct param_struct *params = (struct param_struct *)tags;
217 build_tag_list(params, &params->u2);
220 void __init squash_mem_tags(struct tag *tag)
222 for (; tag->hdr.size; tag = tag_next(tag))
223 if (tag->hdr.tag == ATAG_MEM)
224 tag->hdr.tag = ATAG_NONE;