linux启动时可以带命令行参数,这些参数会影响内核乃至启动脚本的行为。在内核中,用early_param(命令行参数名称,命令行参数处理函数)来注册。除了内核参数,还可以有其他的命令行参数,各自有自己的主人,比如我早期设计的双区启动方案,就是通过传递命令行参数“
right”或者“left”来告诉启动脚本,当前是从左边还是从右边启动的,从而可以mount合适的分区。
这里我们只列出可以影响内核行为的命令行参数,包括kernel源代码中所包含的各种驱动和内核模块所注册的命令行参数。
我用的是Galaxy Nexus所用的linux内核源代码,3.0.21版本。
hzh@fangtian:~/android/omap$ onsource grep -H -w -n early_param
./kernel/smp.c:630:early_param("nosmp", nosmp);
./kernel/smp.c:644:early_param("nr_cpus", nrcpus);
./kernel/smp.c:655:early_param("maxcpus", maxcpus);
./kernel/irq/manage.c:28:early_param("threadirqs", setup_forced_irqthreads);
./kernel/sched.c:6538:early_param("sched_debug", sched_domain_debug_setup);
./kernel/crash_dump.c:34:early_param("elfcorehdr", setup_elfcorehdr);
./kernel/panic.c:464:early_param("oops", oops_setup);
./kernel/printk.c:190:early_param("log_buf_len", log_buf_len_setup);
./kernel/printk.c:585:early_param("ignore_loglevel", ignore_loglevel_setup);
./kernel/printk.c:1426:early_param("keep_bootcon", keep_bootcon_setup);
./kernel/debug/debug_core.c:96:early_param("kgdbcon", opt_kgdb_con);
./kernel/debug/debug_core.c:150:early_param("nokgdbroundup", opt_nokgdbroundup);
./kernel/debug/debug_core.c:971:early_param("kgdbwait", opt_kgdb_wait);
./include/linux/init.h:250:#define early_param(str, fn) \
./include/linux/platform_device.h:196:early_param(class_string, early_platform_driver_setup_func)
./drivers/usb/early/ehci-dbgp.c:1058:early_param("kgdbdbgp", kgdbdbgp_parse_config);
./drivers/video/omap2/vram.c:522:early_param("vram", omap_vram_early_vram);
./drivers/pci/pci.c:3517:early_param("pci", pci_setup);
./drivers/pci/intr_remapping.c:31:early_param("nointremap", setup_nointremap);
./drivers/pci/intr_remapping.c:47:early_param("intremap", setup_intremap);
./drivers/firewire/init_ohci1394_dma.c:309:early_param("ohci1394_dma", setup_ohci1394_dma);
./drivers/acpi/tables.c:363:early_param("acpi_apic_instance", acpi_parse_apic_instance);
./drivers/tty/serial/kgdboc.c:320:early_param("ekgdboc", kgdboc_early_init);
./drivers/tty/serial/8250_early.c:287:early_param("earlycon", setup_early_serial8250_console);
./drivers/base/platform.c:962: * @buf: string passed from early_param()
./drivers/base/platform.c:1054: * Since we register our early platform drivers using early_param()
./drivers/base/platform.c:1058: * We use parse_early_options() to make sure the early_param() gets
./drivers/base/platform.c:1059: * called at least once. The early_param() may be called more than
./drivers/base/core.c:40:early_param("sysfs.deprecated", sysfs_deprecated_setup);
./init/main.c:207:early_param("debug", debug_kernel);
./init/main.c:208:early_param("quiet", quiet_kernel);
./init/main.c:216:early_param("loglevel", loglevel);
./arch/x86/xen/platform-pci-unplug.c:142:early_param("xen_emul_unplug", parse_xen_emul_unplug);
./arch/x86/kernel/smpboot.c:1158:early_param("possible_cpus", _setup_possible_cpus);
./arch/x86/kernel/io_delay.c:131:early_param("io_delay", io_delay_param);
./arch/x86/kernel/pci-dma.c:185:early_param("iommu", iommu_setup);
./arch/x86/kernel/dumpstack.c:315:early_param("kstack", kstack_setup);
./arch/x86/kernel/kvmclock.c:38:early_param("no-kvmclock", parse_no_kvmclock);
./arch/x86/kernel/apic/io_apic.c:152:early_param("noapic", parse_noapic);
./arch/x86/kernel/apic/io_apic.c:2693:early_param("disable_timer_pin_1", disable_timer_pin_setup);
./arch/x86/kernel/apic/probe_32.c:176:early_param("apic", parse_apic);
./arch/x86/kernel/apic/x2apic_phys.c:21:early_param("x2apic_phys", set_x2apic_phys_mode);
./arch/x86/kernel/apic/apic.c:105:early_param("lapic", parse_lapic);
./arch/x86/kernel/apic/apic.c:160:early_param("nox2apic", setup_nox2apic);
./arch/x86/kernel/apic/apic.c:2307:early_param("disableapic", setup_disableapic);
./arch/x86/kernel/apic/apic.c:2314:early_param("nolapic", setup_nolapic);
./arch/x86/kernel/apic/apic.c:2321:early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok);
./arch/x86/kernel/apic/apic.c:2328:early_param("noapictimer", parse_disable_apic_timer);
./arch/x86/kernel/apic/apic.c:2335:early_param("nolapic_timer", parse_nolapic_timer);
./arch/x86/kernel/apic/apic.c:2359:early_param("apic", apic_set_verbosity);
./arch/x86/kernel/early_printk.c:259:early_param("earlyprintk", setup_early_printk);
./arch/x86/kernel/process.c:669:early_param("idle", idle_setup);
./arch/x86/kernel/setup.c:677:early_param("reservelow", parse_reservelow);
./arch/x86/kernel/aperture_64.c:260:early_param("gart_fix_e820", parse_gart_mem);
./arch/x86/kernel/acpi/boot.c:1607:early_param("acpi", parse_acpi);
./arch/x86/kernel/acpi/boot.c:1616:early_param("pci", parse_pci);
./arch/x86/kernel/acpi/boot.c:1638:early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
./arch/x86/kernel/acpi/boot.c:1645:early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
./arch/x86/kernel/acpi/boot.c:1668:early_param("acpi_sci", setup_acpi_sci);
./arch/x86/kernel/e820.c:864:early_param("mem", parse_memopt);
./arch/x86/kernel/e820.c:908:early_param("memmap", parse_memmap_opt);
./arch/x86/kernel/cpu/mtrr/cleanup.c:158:early_param("disable_mtrr_cleanup", disable_mtrr_cleanup_setup);
./arch/x86/kernel/cpu/mtrr/cleanup.c:165:early_param("enable_mtrr_cleanup", enable_mtrr_cleanup_setup);
./arch/x86/kernel/cpu/mtrr/cleanup.c:172:early_param("mtrr_cleanup_debug", mtrr_cleanup_debug_setup);
./arch/x86/kernel/cpu/mtrr/cleanup.c:448:early_param("mtrr_chunk_size", parse_mtrr_chunk_size_opt);
./arch/x86/kernel/cpu/mtrr/cleanup.c:460:early_param("mtrr_gran_size", parse_mtrr_gran_size_opt);
./arch/x86/kernel/cpu/mtrr/cleanup.c:471:early_param("mtrr_spare_reg_nr", parse_mtrr_spare_reg);
./arch/x86/kernel/cpu/mtrr/cleanup.c:813:early_param("disable_mtrr_trim", disable_mtrr_trim_setup);
./arch/x86/kernel/mpparse.c:816:early_param("update_mptable", update_mptable_setup);
./arch/x86/kernel/mpparse.c:835:early_param("alloc_mptable", parse_alloc_mptable_opt);
./arch/x86/kernel/check.c:36:early_param("memory_corruption_check", set_corruption_check);
./arch/x86/kernel/check.c:46:early_param("memory_corruption_check_period", set_corruption_check_period);
./arch/x86/kernel/check.c:60:early_param("memory_corruption_check_size", set_corruption_check_size);
./arch/x86/kernel/kvm.c:52:early_param("no-kvmapf", parse_no_kvmapf);
./arch/x86/mm/init_64.c:63:early_param("nogbpages", parse_direct_gbpages_off);
./arch/x86/mm/init_64.c:70:early_param("gbpages", parse_direct_gbpages_on);
./arch/x86/mm/setup_nx.c:30:early_param("noexec", noexec_setup);
./arch/x86/mm/init_32.c:551:early_param("highmem", parse_highmem);
./arch/x86/mm/pat.c:49:early_param("nopat", nopat);
./arch/x86/mm/memtest.c:107:early_param("memtest", parse_memtest);
./arch/x86/mm/numa.c:54:early_param("numa", numa_setup);
./arch/x86/mm/ioremap.c:344:early_param("early_ioremap_debug", early_ioremap_debug_setup);
./arch/x86/mm/kmemcheck/kmemcheck.c:88:early_param("kmemcheck", param_kmemcheck);
./arch/x86/mm/pgtable.c:48:early_param("userpte", setup_userpte);
./arch/x86/mm/pgtable_32.c:115:early_param("vmalloc", parse_vmalloc);
./arch/x86/mm/pgtable_32.c:134:early_param("reservetop", parse_reservetop);
./arch/x86/platform/efi/efi.c:67:early_param("noefi", setup_noefi);
./arch/x86/platform/efi/efi.c:77:early_param("add_efi_memmap", setup_add_efi_memmap);
./arch/x86/platform/uv/tlb_uv.c:114:early_param("nobau", setup_nobau);
./arch/ia64/kernel/sal.c:238:early_param("force_pal_cache_flush", force_pal_cache_flush);
./arch/ia64/kernel/setup.c:480:early_param("nomca", setup_nomca);
./arch/ia64/kernel/acpi.c:840:early_param("additional_cpus", setup_additional_cpus);
./arch/ia64/kernel/irq_ia64.c:383:early_param("vector", parse_vector_domain);
./arch/ia64/mm/hugetlbpage.c:207:early_param("hugepagesz", hugetlb_setup_sz);
./arch/avr32/kernel/setup.c:284:early_param("fbmem", early_parse_fbmem);
./arch/avr32/kernel/setup.c:303:early_param("mem", early_mem);
./arch/sparc/mm/init_64.c:696:early_param("numa", early_numa);
./arch/arm/kernel/early_printk.c:57:early_param("earlyprintk", setup_early_printk);
./arch/arm/kernel/setup.c:518:early_param("mem", early_mem);
./arch/arm/mach-footbridge/common.c:41:early_param("mem_fclk_21285", early_fclk);
./arch/arm/mach-omap2/board-omap3touchbook.c:413:early_param("tbr", early_touchbook_revision);
./arch/arm/mach-vt8500/devices.c:154:early_param("panel", panel_setup);
./arch/arm/mach-pxa/balloon3.c:94:early_param("balloon3_features", parse_balloon3_features);
./arch/arm/mm/mmu.c:133:early_param("cachepolicy", early_cachepolicy);
./arch/arm/mm/mmu.c:142:early_param("nocache", early_nocache);
./arch/arm/mm/mmu.c:151:early_param("nowb", early_nowrite);
./arch/arm/mm/mmu.c:161:early_param("ecc", early_ecc);
./arch/arm/mm/mmu.c:766:early_param("vmalloc", early_vmalloc);
./arch/arm/mm/init.c:54:early_param("initrd", early_initrd);
./arch/tile/kernel/hardwall.c:82:early_param("noudn", noudn);
./arch/tile/kernel/early_printk.c:109:early_param("earlyprintk", setup_early_printk);
./arch/tile/kernel/process.c:63:early_param("idle", idle_setup);
./arch/tile/kernel/setup.c:117:early_param("maxmem", setup_maxmem);
./arch/tile/kernel/setup.c:135:early_param("maxnodemem", setup_maxnodemem);
./arch/tile/kernel/setup.c:147:early_param("isolnodes", setup_isolnodes);
./arch/tile/kernel/setup.c:163:early_param("pci_reserve", setup_pci_reserve);
./arch/tile/kernel/setup.c:185:early_param("vmalloc", parse_vmalloc);
./arch/tile/kernel/setup.c:929:early_param("initramfs_file", setup_initramfs_file);
./arch/tile/kernel/setup.c:1129:early_param("disabled_cpus", disabled_cpus);
./arch/tile/kernel/setup.c:1213:early_param("dataplane", dataplane);
./arch/tile/mm/homecache.c:58:early_param("noallocl2", set_noallocl2);
./arch/tile/mm/init.c:404:early_param("ktext", setup_ktext);
./arch/mips/kernel/setup.c:155:early_param("rd_start", rd_start_early);
./arch/mips/kernel/setup.c:162:early_param("rd_size", rd_size_early);
./arch/mips/kernel/setup.c:454:early_param("mem", early_parse_mem);
./arch/mips/powertv/asic/asic_devices.c:460:early_param("pmemaddr", early_param_pmemaddr);
./arch/mips/powertv/asic/asic_devices.c:474:early_param("pmemlen", early_param_pmemlen);
./arch/mips/powertv/powertv_setup.c:249:early_param("rfmac", rfmac_param);
./arch/powerpc/xmon/xmon.c:2931:early_param("xmon", early_parse_xmon);
./arch/powerpc/kernel/setup_64.c:150:early_param("smt-enabled", early_smt_enabled);
./arch/powerpc/kernel/setup_32.c:160:early_param("wdt", early_parse_wdt);
./arch/powerpc/kernel/setup_32.c:169:early_param("wdt_period", early_parse_wdt_period);
./arch/powerpc/kernel/prom.c:83:early_param("mem", early_parse_mem);
./arch/powerpc/platforms/pseries/phyp_dump.c:503:early_param("phyp_dump", early_phyp_dump_enabled);
./arch/powerpc/platforms/pseries/phyp_dump.c:513:early_param("phyp_dump_reserve_size", early_phyp_dump_reserve_size);
./arch/powerpc/platforms/pseries/iommu.c:656:early_param("disable_ddw", disable_ddw_setup);
./arch/powerpc/platforms/pasemi/idle.c:102:early_param("idle", idle_param);
./arch/powerpc/platforms/44x/idle.c:67:early_param("idle", idle_param);
./arch/powerpc/platforms/ps3/setup.c:157:early_param("ps3fb", early_parse_ps3fb);
./arch/powerpc/platforms/ps3/setup.c:181:early_param("ps3flash", early_parse_ps3flash);
./arch/powerpc/mm/numa.c:1132:early_param("numa", early_numa);
./arch/sh/kernel/machvec.c:81:early_param("sh_mv", early_parse_mv);
./arch/sh/kernel/sh_bios.c:172:early_param("earlyprintk", setup_early_printk);
./arch/sh/kernel/setup.c:115:early_param("mem", early_parse_mem);
./arch/sh/boards/mach-sdk7786/nmi.c:49:early_param("nmi_mode", nmi_mode_setup);
./arch/sh/mm/pmb.c:786:early_param("pmb", early_pmb);
./arch/blackfin/kernel/early_printk.c:272:early_param("earlyprintk", setup_early_printk);
./arch/blackfin/kernel/setup.c:1064:early_param("clkin_hz=", early_init_clkin_hz);
./arch/unicore32/kernel/early_printk.c:59:early_param("earlyprintk", setup_early_printk);
./arch/unicore32/kernel/setup.c:188:early_param("mem", early_mem);
./arch/unicore32/mm/mmu.c:280:early_param("vmalloc", early_vmalloc);
./arch/unicore32/mm/init.c:49:early_param("initrd", early_initrd);
./arch/m68k/amiga/config.c:634:early_param("debug", amiga_savekmsg_setup);
./arch/m68k/amiga/config.c:720:early_param("debug", amiga_debug_setup);
./arch/m68k/atari/debug.c:327:early_param("debug", atari_debug_setup);
./arch/m68k/atari/config.c:188:early_param("switches", atari_switches_setup);
./arch/m68k/q40/config.c:94:early_param("debug", q40_debug_setup);
./arch/m68k/emu/nfcon.c:114:early_param("debug", nf_debug_setup);
./arch/m68k/sun3x/prom.c:130:early_param("debug", sun3x_debug_setup);
./arch/s390/kernel/smp.c:637:early_param("possible_cpus", setup_possible_cpus);
./arch/s390/kernel/topology.c:283:early_param("topology", early_parse_topology);
./arch/s390/kernel/setup.c:273:early_param("mem", early_parse_mem);
./arch/s390/kernel/setup.c:312:early_param("switch_amode", early_parse_switch_amode);
./arch/s390/kernel/setup.c:324:early_param("user_mode", early_parse_user_mode);
./arch/s390/kernel/time.c:419:early_param("etr", early_parse_etr);
./arch/s390/kernel/time.c:1423:early_param("stp", early_parse_stp);
./arch/s390/mm/pgtable.c:45:early_param("vmalloc", parse_vmalloc);
./arch/um/kernel/early_printk.c:33:early_param("earlyprintk", setup_early_printk);
./security/smc/tf_device_mshield.c:351:early_param("smc_mem", tf_mem_setup);
./mm/percpu.c:1380:early_param("percpu_alloc", percpu_alloc_setup);
./mm/kmemleak.c:1660:early_param("kmemleak", kmemleak_boot_config);
./mm/memblock.c:813:early_param("memblock", early_memblock);
./mm/page_alloc.c:2815:early_param("numa_zonelist_order", setup_numa_zonelist_order);
./mm/page_alloc.c:4978:early_param("kernelcore", cmdline_parse_kernelcore);
./mm/page_alloc.c:4979:early_param("movablecore", cmdline_parse_movablecore);
./mm/bootmem.c:48:early_param("bootmem_debug", bootmem_debug_setup);
./mm/mm_init.c:137:early_param("mminit_loglevel", set_mminit_loglevel);
./lib/debugobjects.c:70:early_param("debug_objects", enable_object_debug);
./lib/debugobjects.c:71:early_param("no_debug_objects", disable_object_debug);