写新参数到bootargs,驱动中用__setup(“新参数名=”, 函数),注册自定义函数,并且解析新参数“=”后的字符串
##再使用EXPORT_SYMBOL()导出(这一步应该不需要)。
举个例子:
uboot环境变量:
bootargs_base=setenv bootargs console=${console},${baudrate} ${smp}
bootargs_mmc=setenv bootargs ${bootargs} root=${mmcroot} rootwait rw fec_mac=${fec_mac} ethaddr1=${ethaddr1}
内核部分:
static unsigned char fec_mac[ETH_ALEN];
static int __init parse_fec_mac(char *options)
{
char *tmp, *end;
int j = 0;
if(options != NULL)
{
tmp = options;
for (j = 0; j < 6; j++) {
fec_mac[j] = tmp ?
simple_strtoul(tmp, &end, 16) : 0;
if (tmp)
tmp = (*end) ? end + 1 : end;
}
//printk("parse_fec_mac : %02x %02x %02x %02x %02x %02x\n", fec_mac[0], fec_mac[1], fec_mac[2], fec_mac[3], fec_mac[4], fec_mac[5]);
}
return 1;
}
__setup("fec_mac=", parse_fec_mac);
关于__setup的分析可以参考下面
添加链接描述