笔记三:模拟uboot打印环境变量代码实现

#include
#include
#include
typedef unsigned char uchar;
#define BOOTARGS "movi 0x30000800"
#define BOOTDELAY "3"
#define BOOTTEST "wxy"
uchar default_env[128] = {
        "bootargs=" BOOTARGS    "\0" 
        "bootdelay=" BOOTDELAY  "\0"
        "boottest=" BOOTTEST  "\0"
        "\0"
};
uchar get_envvar(int index)
{
    return (*(uchar *)(default_env + index));
}
int main(int argc,char *argv[])
{
    int i=0,j=0,k=0;
    for(i;get_envvar(i) != '\0';i=j+1){
        for(j=i;get_envvar(j) != '\0';j++)     
            ;
        for(k;k'\n');
    }
    return 0;
}

打印结果:
bootargs=movi 0x30000800
bootdelay=3
boottest=wxy

你可能感兴趣的:(uboot笔记)