Linux启动参数及实现 __setup与early_param

Linux内存管理(09):启动参数详解 在《fixmap详解》一文中看到在 fixmap 会在内核系统中预留一段虚拟内存用以固定映射,并通过函数 setup_machine_fdt() 对 dtb 内核区域进行映射和解析,其中包括内核的启动参数boot_command_line。启动参数的定义;启动参数的加载;启动参数的实现; 阅读详情

Linux启动参数及实现 __setup与early_param

http://blog.csdn.net/tommy_wxie/article/details/8041487

#define __setup_param(str, unique_id, fn, early)            /
    static char __setup_str_##unique_id[] __initdata = str;    /
    static struct obs_kernel_param __setup_##unique_id    /
        __attribute_used__                /
        __attribute__((__section__(".init.setup")))    /
        __attribute__((aligned((sizeof(long)))))    /
        = { __setup_str_##unique_id, fn, early }
        
#define __setup(str, fn)                    /
    __setup_param(str, fn, fn, 0)
    
#define early_param(str, fn)                    /

    __setup_param(str, fn, fn, 1)


__setup与early_param不同的是,early_param 宏注册的内核选项必须要在其他内核选项之前被处理。

在函数start_kernel中,parse_early_param处理early_param定义的参数,parse_args处理__setup定义的参数。


 parse_early_param();
 parse_args("Booting kernel", static_command_line, __start___param,
     __stop___param - __start___param,
     &unknown_bootoption);

    
1,所有的系统启动参数都是由形如 static int __init foo(char *str);的函数来支持的
注:#define __init        __attribute__ ((__section__ (".init.text")))
申明所有的启动参数支持函数都放入.init.text段


2.1,用__setup宏来导出参数的支持函数
__setup("foo=" , foo);
展开后就是如下的形式

static char __setup_str_foo[] __initdata = "foo=";    
static struct obs_kernel_param __setup_foo    
        __attribute_used__                
        __attribute__((__section__(".init.setup")))    
        __attribute__((aligned((sizeof(long)))))    
        = { __setup_str_foo, foo, 0 };//"foo=",foo,0
也就是说,启动参数(函数指针)被封装到obs_kernel_param结构中,
所有的内核启动参数形成内核映像.init.setup段中的一个
obs_kernel_param数组

2.2用early_param宏来申明需要'早期'处理的启动参数,例如在
arch/i386/kernel/setup.c就有如下的申明:
early_param("mem", parse_mem);
展开后和__setup是一样的只是early参数不一样,因此会在do_early_param
中被处理

3,内核对启动参数的解析:下面函数历遍obs_kernel_param数组,调用
支持函数
static int __init do_early_param(char *param, char *val)
{
    struct obs_kernel_param *p;

    for (p = __setup_start; p < __setup_end; p++) {
        if (p->early && strcmp(param, p->str) == 0) {
            if (p->setup_func(val) != 0)
                printk(KERN_WARNING
                       "Malformed early option '%s'/n", param);
        }
    }
    /* We accept everything at this stage. */
    return 0;
}
这个函数在parse_early_param中被调用,而parse_early_param在start_kernel
中被调用,parse_early_param之后的parse_args会调用下面函数
static int __init obsolete_checksetup(char *line)
{
    struct obs_kernel_param *p;
    int had_early_param = 0;

    p = __setup_start;
    do {
        int n = strlen(p->str);
        if (!strncmp(line, p->str, n)) {
            if (p->early) {
                /* Already done in parse_early_param?
                 * (Needs exact match on param part).
                 * Keep iterating, as we can have early
                 * params and __setups of same names 8( */
                if (line[n] == '/0' || line[n] == '=')
                    had_early_param = 1;
            } else if (!p->setup_func) {
                printk(KERN_WARNING "Parameter %s is obsolete,"
                       " ignored/n", p->str);
                return 1;
            } else if (p->setup_func(line + n))//调用支持函数
                return 1;
        }
        p++;
    } while (p < __setup_end);

    return had_early_param;
}

init/main.c中启动参数申明列表:
__setup("nosmp", nosmp);
__setup("maxcpus=", maxcpus);
__setup("reset_devices", set_reset_devices);

__setup("debug", debug_kernel);
__setup("quiet", quiet_kernel);

__setup("loglevel=", loglevel);

__setup("init=", init_setup);
__setup("rdinit=", rdinit_setup);

__setup("initcall_debug", initcall_debug_setup);



linux内核commandline参数解析过程(原创)  


http://6xudonghai.blog.163.com/blog/static/3364062920093165038776/

最近研究了一下linux内核启动时ramdisk的加载过程,本来是用的是JIFFS文件系统因为调试的需要,现在要通过u-boot直接将内核镜像和ramdisk文件系统镜像下载到SRAM中,首先需要添加并修改command line中的几个参数:

initrd=0x30800040,0x400000 root=/dev/ram init=/linuxrc rootfstype=ext2

 

linux版本:linux-2.6.14

硬件:TE2410 开发板

 

先看看这个commandline是在什么地方解析的

1.start_kernel(void) --> setup_arch(&command_line) --> parse_tags(tags)

parse_tags根据u-boot传过来的tag list解析,调用下面几个函数:

static int __init parse_tag_mem32(const struct tag *tag)

static int __init parse_tag_cmdline(const struct tag *tag)//拷贝commandline

{

strlcpy(default_command_line,tag->u.cmdline.cmdline, COMMAND_LINE_SIZE);

       printk(tag->u.cmdline.cmdline);

       return 0;

}

static int __init parse_tag_initrd2(const struct tag *tag)

{

       phys_initrd_start = tag->u.initrd.start;

       phys_initrd_size = tag->u.initrd.size;

       return 0;

}

 

2.setup_arch(&command_line) -->parse_cmdline(cmdline_p, from)

解析commandline中的2个参数"initrd=" "mem="

 

parse_cmdline调用下面两个函数:

static void __init early_initrd(char **p)

{

       unsigned long start, size;

       start = memparse(*p, p);

       if (**p == ',') {

              size = memparse((*p) + 1, p);

              phys_initrd_start = start;

              phys_initrd_size = size;

       }

}

__early_param("initrd=", early_initrd);

 

static void __init early_mem(char **p)

__early_param("mem=", early_mem);

 

3.start_kernel(void) --> setup_arch(&command_line) -->paging_init(&meminfo, mdesc)

-->bootmem_init(mi)

根据 phys_initrd_start  phys_initrd_size 设置全局变量initrd_start initrd_end

这两个变量在函数populate_rootfs()中会用到

static void __init bootmem_init(struct meminfo *mi)

{

. . .

#ifdef CONFIG_BLK_DEV_INITRD

       if (phys_initrd_size && initrd_node >= 0) {

              reserve_bootmem_node(NODE_DATA(initrd_node), phys_initrd_start,

                                 phys_initrd_size);

              initrd_start = __phys_to_virt(phys_initrd_start);

              initrd_end = initrd_start + phys_initrd_size;

       }

#endif

. . .

}

4.start_kernel(void)-->parse_early_param()-->

parse_args("early options", tmp_cmdline, NULL, 0, do_early_param);

解析commandline的其余参数"root=" "rootfstype=" "init=" "ro" "rw" "console="等

static int __init root_dev_setup(char *line)

{

       strlcpy(saved_root_name, line, sizeof(saved_root_name));

       return 1;

}

__setup("root=", root_dev_setup);

 

static int __init fs_names_setup(char *str)

{

       root_fs_names = str;

       return 1;

}

__setup("rootfstype=", fs_names_setup);

static int __init init_setup(char *str)

{

       unsigned int i;

 

       execute_command = str;

       for (i = 1; i < MAX_INIT_ARGS; i++)

              argv_init[i] = NULL;

       return 1;

}

__setup("init=", init_setup);

 

static int __init readonly(char *str)

{

       if (*str)

              return 0;

       root_mountflags |= MS_RDONLY;

       return 1;

}

 

static int __init readwrite(char *str)

{

       if (*str)

              return 0;

       root_mountflags &= ~MS_RDONLY;

       return 1;

}

 

__setup("ro", readonly);

__setup("rw", readwrite);

ramdisk加载过程

在init进程中populate_rootfs()

void __init populate_rootfs(void)

{

       char *err = unpack_to_rootfs(__initramfs_start,

                      __initramfs_end - __initramfs_start, 0);

       if (err)

              panic(err);

#ifdef CONFIG_BLK_DEV_INITRD

       if (initrd_start) {/*判断是否加载了initrd*/

              int fd;

              printk(KERN_INFO "checking if image is initramfs...");

              err = unpack_to_rootfs((char *)initrd_start,

                     initrd_end - initrd_start, 1);

              if (!err) {/*判断加载的是不是cpio-initrd*/

                     printk(" it is\n");

                     unpack_to_rootfs((char *)initrd_start,

                            initrd_end - initrd_start, 0);

                     free_initrd();

                     return;

              }

              printk("it isn't (%s); looks like an initrd\n", err);

/*如果不是cpio-initrd,则认为是一个image-initrd,将其内容保存到*/ /*initrd.image中,在后面的image-initrd的处理代码中会读取/initrd.image*/

              fd = sys_open("/initrd.image", O_WRONLY|O_CREAT, 700);

              if (fd >= 0) {

                     sys_write(fd, (char *)initrd_start,

                                   initrd_end - initrd_start);

                     sys_close(fd);

                     free_initrd();

              }

       }

#endif

 

后面执init()-->prepare_namespace()-->initrd_load()--> rd_load_image("/initrd.image")

-->identify_ramdisk_image(in_fd, rd_image_start)

 

identify_ramdisk_image对Ramdisk的文件系统类型做检查

 

prepare_namespace()-->mount_root()-->

mount_block_root("/dev/root", root_mountflags);

 

mount_block_root加载文件系统

关于Ramdisk加载过程详细分析参考以下几篇

Linux内核Ramdisk(initrd)机制 http://blog.csdn.net/ruixj/archive/2009/01/14/3772752.aspx

Initrd 流程分析 http://hi.baidu.com/mczyh/blog/item/86153139527ed422b8998f17.html

Linux2.6 内核的 Initrd 机制解析http://www.ibm.com/developerworks/cn/linux/l-k26initrd/index.html

解析linux根文件系统的挂载过程 http://blog.chinaunix.net/u1/51562/showart_1108170.html

最后介绍一个代码查询的网站http://lxr.linux.no/linux,很多时候跟踪代码时找不到函数的源代码,这个网站帮我们解决了这个难题 







华为od 面试八股文_C++_02_含答案 阅读详情

相关推荐

Win10系统内存占用异常飙升?三步排查法快速定位问题根源

本文针对Win10系统内存占用异常飙升问题,提供了一套三步排查法。首先利用任务管理器和资源监视器进行深度系统体检,定位隐形内存消耗者;其次通过干净启动和禁用非必要后台服务,揪出导致内存泄漏的第三方软件或驱动;最后进行终极深度清理,包括检查内存完整性、调整虚拟内存设置以及更新关键驱动程序,帮助用户快速恢复系统流畅运行。

weixin_29251567的博客 210

__setup,early_param宏

我们在跟踪rootfs挂载过程的时候,会在init/main.c看到有如下一个函数rdinit_setup,并通过__setup宏进行声明: //init/main.c static int __init rdinit_setup(char *str)

HZero 1221

CAPL实战:从零构建HEX文件解析器,赋能UDS刷写

本文详细介绍了如何使用CAPL从零构建HEX文件解析器,以支持UDS刷写操作。通过解析HEX文件格式、设计状态机、优化数据结构与算法,实现高效准确的固件数据处理,并提供了与UDS刷写流程对接的工程化实践建议。

weixin_28726391的博客 451

ramdisk配置、解压、创建rootfs、启动简单分析

关键词:ramdisk、rdint、.init.ramfs、__initramfs_start、__initramfs_size、rootfs、ramfs、populate_rootfs()、gzip、actions[]、free_initmem()、run_init_process()等等。 本着了解ramdisk,带着如下几个问题进行分析: 如何打开ramdisk功能? ram...

weixin_30551963的博客 1073

蓝牙RSSI定位实战:用Arduino+BLE4.0搭建厘米级室内定位系统(附完整代码)

本文详细介绍了如何利用Arduino和BLE4.0模块构建厘米级精度的蓝牙RSSI室内定位系统。通过硬件选型、系统架构设计、三点定位算法实现及误差补偿技术,实现在商场导览、仓储管理等场景中的高精度定位。附完整代码和实测数据,帮助开发者快速部署商用级解决方案。

peace的博客 903

哈希拓展攻击CTF题做法

kali下载相关工具hash-ext-attack:hash拓展题目特征:2023楚慧杯upload_shell实验吧之让我进去:前言:具体怎么加密解密补位的原理我不懂,深入理解的部分我在文末挂了链接,以下也只是我做题的结论和通解,可能不准确(但是做题还挺准确),有错误欢迎指出:是在密码加密过程中引入的一个随机值,它与密码结合使用,目的是增加密码的复杂性和安全性。在密码加密中,常见的做法是将用户提供的密码进行哈希处理,然后存储哈希值而不是明文密码

2301_76690905的博客 2427

linux2.6内核initrd机制解析

<br />题记<br />     很久之前就分析过这部分内容,但是那个时候不够深入,姑且知道这么个东西存在,到底怎么用,来龙去脉咋回事就不知道了。前段时间工作上遇到了一个initrd的问题,没办法只能再去研究研究,还好,有点眉目,索性整理了一下。<br />     网络上流传着很多关于ramdisk、initrd的各种版本的分析,我的这篇源于对他们的理解,非常感谢那些前辈的无私奉献,要不然我们这些晚辈学起东西来该是多么艰难呀。在这里需要特别声明的是如果文中有引用了您的思想而没有给出参考文献,请您原

zgolee的专栏 5542

K8S证书过期解决办法之替换证书

k8s证书过期解决方案之替换证书

q_hsolucky的博客 1万+

uboot传递initrd(initramfs or ramdisk) 到kernel的两种方式

1, chosen节点bootargs属性 uboot代码解析ramdisk/initramfs镜像,然后设置环境变量setenv("bootargs"),调用fdt_setprop(common/fdt_support.c)设置chosen节点的bootargs属性。 kernel从r2寄存器拿到fdt后,通过early_init_dt_scan_chosen->of_get_flat_dt

yiyeguzhou100的专栏 7544

从DDPM到DDIM:深入解读《Denoising Diffusion Implicit Models》

DDIM发表在ICRL2021上,是DDPM重要的改进之一,能显著提高DDPM的样本质量、减少采样时间,并且能显式控制插值,已经被广泛应用到现在的Diffusion Models上。这篇博客和大家一起详细解读一下DDIM,认识这一伟大的模型。.........

沉迷单车的追风少年 1万+

PCL 使用RANSAC拟合平面【2027最新版】

RANSAC拟合平面算法原理和实现流程详解以及最大迭代次数和内点期望概率的设置方法。最后再对拟合后的平面法向量与向量(1,1,1)进行定向。博客长期更新,最近一次更新时间为:2026年11月29日。

点云侠的博客 42万+

linux内核机制之设备树

1. 设备树(Device  Tree)基本概念及作用 在内核源码中,存在大量对板级细节信息描述的代码。这些代码充斥在/arch/arm/plat-xxx和/arch/arm/mach-xxx目录,对内核而言这些platform设备、resource、i2c_board_info、spi_board_info以及各种硬件的platform_data绝大多数纯属垃圾冗余代码。为了解决这一问题,ARM内核版本3.x之后引入了原先在Power PC等其他体系架构已经使用的Flatte

wll1228的博客 4197

AI绘画与医疗可视化:用AI生成医学插图的实践

医疗可视化是医学教育、临床沟通和学术研究的核心工具。传统医学插图依赖手工绘制或专业3D建模,存在制作周期长、成本高、更新迭代慢等问题。随着深度学习技术的发展,AI绘画工具(如Stable Diffusion、DALL-E)展现出强大的图像生成能力,但医疗领域对插图的解剖准确性、标注规范性和语义完整性有极高要求,通用AI模型难以直接应用。本文聚焦AI技术与医疗领域的交叉创新,系统阐述如何通过数据预处理、模型定制化训练和后处理校验,构建符合医疗标准的插图生成系统。

大模型应用工坊 1793

linux启动参数 mem,Linux启动参数及实现 __setup与early_param

#define __setup_param(str, unique_id, fn,early)/static char__setup_str_##unique_id[] __initdata =str;/staticstruct obs_kernel_param__setup_##unique_id/__attribute_used__/__attribute__((__section__...

weixin_42504833的博客 499

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Linux启动参数及实现 __setup与early_param

#define __setup_param(str, unique_id, fn, early)            /     static char __setup_str_##unique_id[] __initdata = str;    /     static struct obs_kernel_param __setup_##unique_id    /         __

wxie的Linux人生 1万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

linux运行.setup文件,Linux启动参数及实现 __setup与early_param

#define __setup_param(str, unique_id, fn, early) /static char __setup_str_##unique_id[] __initdata = str; /static struct obs_kernel_param __setup_##unique_id /__attribute_used__...

weixin_32019219的博客 661

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

linux obs 编译参数,Linux启动参数及实现 __setup与early_param

#define __setup_param(str, unique_id, fn,early)/static char__setup_str_##unique_id[] __initdata =str;/staticstruct obs_kernel_param__setup_##unique_id/__attribute_used__/__attribute__((__section__...

weixin_33399354的博客 256

Linux启动参数及实现 __setup与early_param .

__setup与early_param不同的是,early_param 宏注册的内核选项必须要在其他内核选项之前被处理。 在函数start_kernel中,parse_early_param处理early_param定义的参数,parse_args处理__setup定义的参数。  parse_early_param();  parse_args("Booting kernel", sta

SHK242673的专栏 784

Linux启动参数及实现 __setup与early_param(讲的不错,转载)

#define __setup_param(str, unique_id, fn, early)            /     static char __setup_str_##unique_id[] __initdata = str;    /     static struct obs_kernel_param __setup_##unique_id    /         __

steveliu->blog 496

__setup和early_param加载逻辑

在读kernel代码时候又一次碰到early_param这个调用,网上查了下大体和__setup函数作用是一样的,都是在驱动起来后很早加载其回调函数,用来作一些早期的初始化。一直没注意其实现的逻辑过程,只知道应该这样用。现在来看看其到底是如何实现的。 先来看看一个序列图,比较简单: 上面的序列图调用过程会显得比较简单,逻辑并不复杂。由bootloader拉起start_kernel开始进行驱动加载,在加载moudle_init各种驱动之前会处理__setup和early_param这两种结构,如下图:

bruk_spp的博客 1282

linux之early_param()和__setup

原理: 在linux启动时,调用在init/main.c里面的start_kernel()时,执行到parse_early_param()时,uboot传递的cmdline里面有相应的命令,就会调用early_param()和__setup 注册的函数。可以在驱动模块的任何c文件里面用early_param(),__setup()注册,只需要包含include/linux/init.h头文件

子木 4835

linux __setup

本文来自: http://blog.chinaunix.net/uid-13798723-id-2871394.html 介绍的很详细,我也正好用了一次__setup(),蛮好用的:),今天回头看main.c,又搜索了一下,分享给大家:  __setup( //做了一次完整的盗贼,我毫无修改的抄袭了一次,但有时间会做量身裁减的// from

bugouyonggan的专栏 3378
上一篇: 内核中tcm(arm)与sram代码
下一篇: 段错误原因分析和查找
adaptiver
博客等级 码龄16年 194粉丝 51原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值