Linux 2.6.13-rc4
[linux-2.6/next.git] / arch / arm26 / kernel / compat.c
blobdb0310db8998b66212ff3dd36ad70aafa55b0398
1 /*
2 * linux/arch/arm26/kernel/compat.c
4 * Copyright (C) 2001 Russell King
5 * 2003 Ian Molton
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * We keep the old params compatibility cruft in one place (here)
12 * so we don't end up with lots of mess around other places.
14 * NOTE:
15 * The old struct param_struct is deprecated, but it will be kept in
16 * the kernel for 5 years from now (2001). This will allow boot loaders
17 * to convert to the new struct tag way.
19 #include <linux/config.h>
20 #include <linux/types.h>
21 #include <linux/kernel.h>
22 #include <linux/string.h>
23 #include <linux/init.h>
25 #include <asm/setup.h>
26 #include <asm/mach-types.h>
27 #include <asm/page.h>
29 //#include <asm/arch.h>
30 //#include <asm/mach/irq.h>
33 * Usage:
34 * - do not go blindly adding fields, add them at the end
35 * - when adding fields, don't rely on the address until
36 * a patch from me has been released
37 * - unused fields should be zero (for future expansion)
38 * - this structure is relatively short-lived - only
39 * guaranteed to contain useful data in setup_arch()
41 * This is the old deprecated way to pass parameters to the kernel
43 struct param_struct {
44 union {
45 struct {
46 unsigned long page_size; /* 0 */
47 unsigned long nr_pages; /* 4 */
48 unsigned long ramdisk_size; /* 8 */
49 unsigned long flags; /* 12 */
50 #define FLAG_READONLY 1
51 #define FLAG_RDLOAD 4
52 #define FLAG_RDPROMPT 8
53 unsigned long rootdev; /* 16 */
54 unsigned long video_num_cols; /* 20 */
55 unsigned long video_num_rows; /* 24 */
56 unsigned long video_x; /* 28 */
57 unsigned long video_y; /* 32 */
58 unsigned long memc_control_reg; /* 36 */
59 unsigned char sounddefault; /* 40 */
60 unsigned char adfsdrives; /* 41 */
61 unsigned char bytes_per_char_h; /* 42 */
62 unsigned char bytes_per_char_v; /* 43 */
63 unsigned long pages_in_bank[4]; /* 44 */
64 unsigned long pages_in_vram; /* 60 */
65 unsigned long initrd_start; /* 64 */
66 unsigned long initrd_size; /* 68 */
67 unsigned long rd_start; /* 72 */
68 unsigned long system_rev; /* 76 */
69 unsigned long system_serial_low; /* 80 */
70 unsigned long system_serial_high; /* 84 */
71 unsigned long mem_fclk_21285; /* 88 */
72 } s;
73 char unused[256];
74 } u1;
75 union {
76 char paths[8][128];
77 struct {
78 unsigned long magic;
79 char n[1024 - sizeof(unsigned long)];
80 } s;
81 } u2;
82 char commandline[COMMAND_LINE_SIZE];
85 static struct tag * __init memtag(struct tag *tag, unsigned long start, unsigned long size)
87 tag = tag_next(tag);
88 tag->hdr.tag = ATAG_MEM;
89 tag->hdr.size = tag_size(tag_mem32);
90 tag->u.mem.size = size;
91 tag->u.mem.start = start;
93 return tag;
96 static void __init build_tag_list(struct param_struct *params, void *taglist)
98 struct tag *tag = taglist;
100 if (params->u1.s.page_size != PAGE_SIZE) {
101 printk(KERN_WARNING "Warning: bad configuration page, "
102 "trying to continue\n");
103 return;
106 printk(KERN_DEBUG "Converting old-style param struct to taglist\n");
108 tag->hdr.tag = ATAG_CORE;
109 tag->hdr.size = tag_size(tag_core);
110 tag->u.core.flags = params->u1.s.flags & FLAG_READONLY;
111 tag->u.core.pagesize = params->u1.s.page_size;
112 tag->u.core.rootdev = params->u1.s.rootdev;
114 tag = tag_next(tag);
115 tag->hdr.tag = ATAG_RAMDISK;
116 tag->hdr.size = tag_size(tag_ramdisk);
117 tag->u.ramdisk.flags = (params->u1.s.flags & FLAG_RDLOAD ? 1 : 0) |
118 (params->u1.s.flags & FLAG_RDPROMPT ? 2 : 0);
119 tag->u.ramdisk.size = params->u1.s.ramdisk_size;
120 tag->u.ramdisk.start = params->u1.s.rd_start;
122 tag = tag_next(tag);
123 tag->hdr.tag = ATAG_INITRD;
124 tag->hdr.size = tag_size(tag_initrd);
125 tag->u.initrd.start = params->u1.s.initrd_start;
126 tag->u.initrd.size = params->u1.s.initrd_size;
128 tag = tag_next(tag);
129 tag->hdr.tag = ATAG_SERIAL;
130 tag->hdr.size = tag_size(tag_serialnr);
131 tag->u.serialnr.low = params->u1.s.system_serial_low;
132 tag->u.serialnr.high = params->u1.s.system_serial_high;
134 tag = tag_next(tag);
135 tag->hdr.tag = ATAG_REVISION;
136 tag->hdr.size = tag_size(tag_revision);
137 tag->u.revision.rev = params->u1.s.system_rev;
139 tag = memtag(tag, PHYS_OFFSET, params->u1.s.nr_pages * PAGE_SIZE);
141 tag = tag_next(tag);
142 tag->hdr.tag = ATAG_ACORN;
143 tag->hdr.size = tag_size(tag_acorn);
144 tag->u.acorn.memc_control_reg = params->u1.s.memc_control_reg;
145 tag->u.acorn.vram_pages = params->u1.s.pages_in_vram;
146 tag->u.acorn.sounddefault = params->u1.s.sounddefault;
147 tag->u.acorn.adfsdrives = params->u1.s.adfsdrives;
149 tag = tag_next(tag);
150 tag->hdr.tag = ATAG_CMDLINE;
151 tag->hdr.size = (strlen(params->commandline) + 3 +
152 sizeof(struct tag_header)) >> 2;
153 strcpy(tag->u.cmdline.cmdline, params->commandline);
155 tag = tag_next(tag);
156 tag->hdr.tag = ATAG_NONE;
157 tag->hdr.size = 0;
159 memmove(params, taglist, ((int)tag) - ((int)taglist) +
160 sizeof(struct tag_header));
163 void __init convert_to_tag_list(struct tag *tags)
165 struct param_struct *params = (struct param_struct *)tags;
166 build_tag_list(params, &params->u2);
169 void __init squash_mem_tags(struct tag *tag)
171 for (; tag->hdr.size; tag = tag_next(tag))
172 if (tag->hdr.tag == ATAG_MEM)
173 tag->hdr.tag = ATAG_NONE;