uboot中bootargs实现

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值