setup.h通过宏定义实现了bootargs传递参数到内核,值得以后编程学习。
include/asm-arm/setup.h
14 * NOTE:
15 * This file contains two ways to pass information from the boot
16 * loader to the kernel. The old struct param_struct is deprecated,
17 * but it will be kept in the kernel for 5 years from now
18 * (2001). This will allow boot loaders to convert to the new struct
19 * tag way.
The new way of passing infomation: a list of tagged eneries.
208 struct tag {
209 struct tag_header hdr;
210 union {
211 struct tag_core core;
212 struct tag_mem32 mem;
213 struct tag_videotext videotext;
214 struct tag_ramdisk ramdisk;
215 struct tag_initrd initrd;
216 struct tag_serialnr serialnr;
217 struct tag_revision revision;
218 struct tag_videolfb videolfb;
219 struct tag_cmdline cmdline;
220
221 /*
222 * Acorn specific
223 */
224 struct tag_acorn acorn;
225
226 /*
227 * DC21285 specific
228 */
229 struct tag_memclk memclk;
230 } u;
231 };
232
233 struct tagtable {
234 u32 tag;
235 int (*parse)(const struct tag *);
236 };
实现参数遍历:
238 #define __tag __attribute__((unused, __section__(".taglist")))
239 #define __tagtable(tag, fn)
240 static struct tagtable __tagtable_##fn __tag = { tag, fn }
241
242 #define tag_member_present(tag,member)
243 ((unsigned long)(&((struct tag *)0L)->member + 1)
244 <= (tag)->hdr.size * 4)
245
246 #define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size))
247 #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
248
249 #define for_each_tag(t,base)
250 for (t = base; t->hdr.size; t = tag_next(t))
具体应用在lib_arm/bootm.c