From a1df417e74aa6dae7352dc8cbb0ad471af5b7c69 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Mon, 25 Apr 2016 10:00:44 -0400 Subject: initial Olimex linux tree from Daniel, originally Feb 3, 2016 --- linux/scripts/.conmakehash.cmd | 50 + linux/scripts/.gitignore | 12 + linux/scripts/.kallsyms.cmd | 50 + linux/scripts/.pnmtologo.cmd | 60 + linux/scripts/.recordmcount.cmd | 69 + linux/scripts/.sortextable.cmd | 71 + linux/scripts/Kbuild.include | 305 ++ linux/scripts/Lindent | 18 + linux/scripts/Makefile | 42 + linux/scripts/Makefile.asm-generic | 23 + linux/scripts/Makefile.build | 427 ++ linux/scripts/Makefile.clean | 91 + linux/scripts/Makefile.dtbinst | 51 + linux/scripts/Makefile.extrawarn | 68 + linux/scripts/Makefile.fwinst | 70 + linux/scripts/Makefile.headersinst | 139 + linux/scripts/Makefile.help | 3 + linux/scripts/Makefile.host | 128 + linux/scripts/Makefile.kasan | 29 + linux/scripts/Makefile.lib | 390 ++ linux/scripts/Makefile.modbuiltin | 60 + linux/scripts/Makefile.modinst | 41 + linux/scripts/Makefile.modpost | 152 + linux/scripts/Makefile.modsign | 32 + linux/scripts/analyze_suspend.py | 3591 +++++++++++++ linux/scripts/asn1_compiler.c | 1555 ++++++ linux/scripts/basic/.bin2c.cmd | 26 + linux/scripts/basic/.fixdep.cmd | 90 + linux/scripts/basic/.gitignore | 2 + linux/scripts/basic/Makefile | 16 + linux/scripts/basic/bin2c.c | 35 + linux/scripts/basic/fixdep.c | 462 ++ linux/scripts/basic/modules.order | 0 linux/scripts/bloat-o-meter | 65 + linux/scripts/bootgraph.pl | 238 + linux/scripts/check_extable.sh | 146 + linux/scripts/checkincludes.pl | 89 + linux/scripts/checkkconfigsymbols.py | 268 + linux/scripts/checkpatch.pl | 5584 ++++++++++++++++++++ linux/scripts/checkstack.pl | 176 + linux/scripts/checksyscalls.sh | 216 + linux/scripts/checkversion.pl | 71 + linux/scripts/cleanfile | 176 + linux/scripts/cleanpatch | 258 + linux/scripts/coccicheck | 179 + .../scripts/coccinelle/api/alloc/alloc_cast.cocci | 72 + .../coccinelle/api/alloc/kzalloc-simple.cocci | 86 + linux/scripts/coccinelle/api/d_find_alias.cocci | 80 + linux/scripts/coccinelle/api/err_cast.cocci | 56 + linux/scripts/coccinelle/api/kstrdup.cocci | 104 + linux/scripts/coccinelle/api/memdup.cocci | 66 + linux/scripts/coccinelle/api/memdup_user.cocci | 60 + .../coccinelle/api/platform_no_drv_owner.cocci | 106 + linux/scripts/coccinelle/api/pm_runtime.cocci | 109 + linux/scripts/coccinelle/api/ptr_ret.cocci | 96 + linux/scripts/coccinelle/api/resource_size.cocci | 93 + linux/scripts/coccinelle/api/simple_open.cocci | 70 + linux/scripts/coccinelle/free/clk_put.cocci | 67 + linux/scripts/coccinelle/free/devm_free.cocci | 71 + linux/scripts/coccinelle/free/ifnullfree.cocci | 53 + linux/scripts/coccinelle/free/iounmap.cocci | 67 + linux/scripts/coccinelle/free/kfree.cocci | 121 + linux/scripts/coccinelle/free/kfreeaddr.cocci | 32 + .../coccinelle/free/pci_free_consistent.cocci | 52 + linux/scripts/coccinelle/iterators/fen.cocci | 123 + linux/scripts/coccinelle/iterators/itnull.cocci | 94 + .../coccinelle/iterators/list_entry_update.cocci | 62 + .../coccinelle/iterators/use_after_iter.cocci | 147 + linux/scripts/coccinelle/locks/call_kern.cocci | 105 + linux/scripts/coccinelle/locks/double_lock.cocci | 92 + linux/scripts/coccinelle/locks/flags.cocci | 80 + linux/scripts/coccinelle/locks/mini_lock.cocci | 96 + linux/scripts/coccinelle/misc/array_size.cocci | 87 + linux/scripts/coccinelle/misc/badty.cocci | 76 + linux/scripts/coccinelle/misc/boolinit.cocci | 178 + linux/scripts/coccinelle/misc/boolreturn.cocci | 58 + linux/scripts/coccinelle/misc/bugon.cocci | 62 + linux/scripts/coccinelle/misc/cstptr.cocci | 41 + linux/scripts/coccinelle/misc/doubleinit.cocci | 53 + linux/scripts/coccinelle/misc/ifaddr.cocci | 35 + linux/scripts/coccinelle/misc/ifcol.cocci | 48 + linux/scripts/coccinelle/misc/irqf_oneshot.cocci | 89 + linux/scripts/coccinelle/misc/noderef.cocci | 65 + linux/scripts/coccinelle/misc/of_table.cocci | 62 + linux/scripts/coccinelle/misc/orplus.cocci | 55 + linux/scripts/coccinelle/misc/returnvar.cocci | 66 + linux/scripts/coccinelle/misc/semicolon.cocci | 83 + linux/scripts/coccinelle/misc/simple_return.cocci | 180 + linux/scripts/coccinelle/misc/warn.cocci | 109 + linux/scripts/coccinelle/null/badzero.cocci | 238 + linux/scripts/coccinelle/null/deref_null.cocci | 282 + linux/scripts/coccinelle/null/eno.cocci | 48 + linux/scripts/coccinelle/null/kmerr.cocci | 72 + linux/scripts/coccinelle/tests/doublebitand.cocci | 54 + linux/scripts/coccinelle/tests/doubletest.cocci | 40 + linux/scripts/coccinelle/tests/odd_ptr_err.cocci | 65 + linux/scripts/config | 225 + linux/scripts/conmakehash.c | 293 + linux/scripts/decode_stacktrace.sh | 126 + linux/scripts/decodecode | 104 + linux/scripts/depmod.sh | 64 + linux/scripts/diffconfig | 131 + linux/scripts/docproc.c | 580 ++ linux/scripts/dtc/.checks.o.cmd | 69 + linux/scripts/dtc/.data.o.cmd | 69 + linux/scripts/dtc/.dtc-lexer.lex.o.cmd | 71 + linux/scripts/dtc/.dtc-parser.tab.o.cmd | 71 + linux/scripts/dtc/.dtc.cmd | 1 + linux/scripts/dtc/.dtc.o.cmd | 72 + linux/scripts/dtc/.flattree.o.cmd | 70 + linux/scripts/dtc/.fstree.o.cmd | 76 + linux/scripts/dtc/.gitignore | 4 + linux/scripts/dtc/.livetree.o.cmd | 69 + linux/scripts/dtc/.srcpos.o.cmd | 70 + linux/scripts/dtc/.treesource.o.cmd | 70 + linux/scripts/dtc/.util.o.cmd | 74 + linux/scripts/dtc/Makefile | 31 + linux/scripts/dtc/Makefile.dtc | 18 + linux/scripts/dtc/checks.c | 862 +++ linux/scripts/dtc/checks.o | Bin 0 -> 25848 bytes linux/scripts/dtc/data.c | 269 + linux/scripts/dtc/data.o | Bin 0 -> 8408 bytes linux/scripts/dtc/dtc-lexer.l | 294 ++ linux/scripts/dtc/dtc-lexer.lex.c_shipped | 2246 ++++++++ linux/scripts/dtc/dtc-lexer.lex.o | Bin 0 -> 32960 bytes linux/scripts/dtc/dtc-parser.tab.c_shipped | 2277 ++++++++ linux/scripts/dtc/dtc-parser.tab.h_shipped | 123 + linux/scripts/dtc/dtc-parser.tab.o | Bin 0 -> 17616 bytes linux/scripts/dtc/dtc-parser.y | 493 ++ linux/scripts/dtc/dtc.c | 324 ++ linux/scripts/dtc/dtc.h | 309 ++ linux/scripts/dtc/dtc.o | Bin 0 -> 14472 bytes linux/scripts/dtc/fdtdump.c | 162 + linux/scripts/dtc/fdtget.c | 366 ++ linux/scripts/dtc/fdtput.c | 362 ++ linux/scripts/dtc/flattree.c | 1135 ++++ linux/scripts/dtc/flattree.o | Bin 0 -> 30392 bytes linux/scripts/dtc/fstree.c | 90 + linux/scripts/dtc/fstree.o | Bin 0 -> 4296 bytes linux/scripts/dtc/libfdt/Makefile.libfdt | 10 + linux/scripts/dtc/libfdt/fdt.c | 222 + linux/scripts/dtc/libfdt/fdt.h | 60 + linux/scripts/dtc/libfdt/fdt_empty_tree.c | 83 + linux/scripts/dtc/libfdt/fdt_ro.c | 574 ++ linux/scripts/dtc/libfdt/fdt_rw.c | 492 ++ linux/scripts/dtc/libfdt/fdt_strerror.c | 96 + linux/scripts/dtc/libfdt/fdt_sw.c | 256 + linux/scripts/dtc/libfdt/fdt_wip.c | 118 + linux/scripts/dtc/libfdt/libfdt.h | 1478 ++++++ linux/scripts/dtc/libfdt/libfdt_env.h | 29 + linux/scripts/dtc/libfdt/libfdt_internal.h | 95 + linux/scripts/dtc/livetree.c | 711 +++ linux/scripts/dtc/livetree.o | Bin 0 -> 14672 bytes linux/scripts/dtc/modules.order | 0 linux/scripts/dtc/srcpos.c | 321 ++ linux/scripts/dtc/srcpos.h | 119 + linux/scripts/dtc/srcpos.o | Bin 0 -> 8280 bytes linux/scripts/dtc/treesource.c | 283 + linux/scripts/dtc/treesource.o | Bin 0 -> 12136 bytes linux/scripts/dtc/update-dtc-source.sh | 54 + linux/scripts/dtc/util.c | 444 ++ linux/scripts/dtc/util.h | 252 + linux/scripts/dtc/util.o | Bin 0 -> 13328 bytes linux/scripts/dtc/version_gen.h | 1 + linux/scripts/export_report.pl | 186 + linux/scripts/extract-ikconfig | 68 + linux/scripts/extract-vmlinux | 62 + linux/scripts/gcc-goto.sh | 21 + linux/scripts/gcc-ld | 29 + linux/scripts/gcc-version.sh | 32 + linux/scripts/gcc-x86_32-has-stack-protector.sh | 8 + linux/scripts/gcc-x86_64-has-stack-protector.sh | 8 + linux/scripts/gdb/Makefile | 1 + linux/scripts/gdb/linux/.gitignore | 2 + linux/scripts/gdb/linux/Makefile | 11 + linux/scripts/gdb/linux/__init__.py | 1 + linux/scripts/gdb/linux/cpus.py | 135 + linux/scripts/gdb/linux/dmesg.py | 65 + linux/scripts/gdb/linux/modules.py | 96 + linux/scripts/gdb/linux/symbols.py | 177 + linux/scripts/gdb/linux/tasks.py | 100 + linux/scripts/gdb/linux/utils.py | 156 + linux/scripts/gdb/vmlinux-gdb.py | 30 + linux/scripts/gen_initramfs_list.sh | 323 ++ linux/scripts/genksyms/.genksyms.cmd | 1 + linux/scripts/genksyms/.genksyms.o.cmd | 55 + linux/scripts/genksyms/.gitignore | 5 + linux/scripts/genksyms/.lex.lex.o.cmd | 70 + linux/scripts/genksyms/.parse.tab.o.cmd | 50 + linux/scripts/genksyms/Makefile | 14 + linux/scripts/genksyms/genksyms.c | 875 +++ linux/scripts/genksyms/genksyms.h | 94 + linux/scripts/genksyms/genksyms.o | Bin 0 -> 23400 bytes linux/scripts/genksyms/keywords.gperf | 60 + linux/scripts/genksyms/keywords.hash.c_shipped | 229 + linux/scripts/genksyms/lex.l | 482 ++ linux/scripts/genksyms/lex.lex.c_shipped | 2292 ++++++++ linux/scripts/genksyms/lex.lex.o | Bin 0 -> 39928 bytes linux/scripts/genksyms/modules.order | 0 linux/scripts/genksyms/parse.tab.c_shipped | 2407 +++++++++ linux/scripts/genksyms/parse.tab.h_shipped | 96 + linux/scripts/genksyms/parse.tab.o | Bin 0 -> 29904 bytes linux/scripts/genksyms/parse.y | 504 ++ linux/scripts/get_maintainer.pl | 2269 ++++++++ linux/scripts/gfp-translate | 86 + linux/scripts/headerdep.pl | 192 + linux/scripts/headers.sh | 28 + linux/scripts/headers_check.pl | 165 + linux/scripts/headers_install.sh | 46 + linux/scripts/kallsyms.c | 720 +++ linux/scripts/kconfig/.conf.cmd | 1 + linux/scripts/kconfig/.conf.o.cmd | 81 + linux/scripts/kconfig/.gitignore | 22 + linux/scripts/kconfig/.mconf.cmd | 1 + linux/scripts/kconfig/.mconf.o.cmd | 105 + linux/scripts/kconfig/.zconf.tab.o.cmd | 104 + linux/scripts/kconfig/Makefile | 310 ++ linux/scripts/kconfig/POTFILES.in | 12 + linux/scripts/kconfig/check.sh | 13 + linux/scripts/kconfig/conf.c | 722 +++ linux/scripts/kconfig/conf.o | Bin 0 -> 23168 bytes linux/scripts/kconfig/confdata.c | 1248 +++++ linux/scripts/kconfig/expr.c | 1170 ++++ linux/scripts/kconfig/expr.h | 236 + linux/scripts/kconfig/gconf.c | 1521 ++++++ linux/scripts/kconfig/gconf.glade | 661 +++ linux/scripts/kconfig/images.c | 326 ++ linux/scripts/kconfig/kxgettext.c | 235 + linux/scripts/kconfig/list.h | 131 + linux/scripts/kconfig/lkc.h | 186 + linux/scripts/kconfig/lkc_proto.h | 52 + linux/scripts/kconfig/lxdialog/.checklist.o.cmd | 71 + linux/scripts/kconfig/lxdialog/.gitignore | 4 + linux/scripts/kconfig/lxdialog/.inputbox.o.cmd | 71 + linux/scripts/kconfig/lxdialog/.menubox.o.cmd | 71 + linux/scripts/kconfig/lxdialog/.textbox.o.cmd | 71 + linux/scripts/kconfig/lxdialog/.util.o.cmd | 72 + linux/scripts/kconfig/lxdialog/.yesno.o.cmd | 71 + linux/scripts/kconfig/lxdialog/BIG.FAT.WARNING | 4 + linux/scripts/kconfig/lxdialog/check-lxdialog.sh | 91 + linux/scripts/kconfig/lxdialog/checklist.c | 332 ++ linux/scripts/kconfig/lxdialog/checklist.o | Bin 0 -> 12360 bytes linux/scripts/kconfig/lxdialog/dialog.h | 257 + linux/scripts/kconfig/lxdialog/inputbox.c | 301 ++ linux/scripts/kconfig/lxdialog/inputbox.o | Bin 0 -> 11832 bytes linux/scripts/kconfig/lxdialog/menubox.c | 437 ++ linux/scripts/kconfig/lxdialog/menubox.o | Bin 0 -> 12824 bytes linux/scripts/kconfig/lxdialog/textbox.c | 408 ++ linux/scripts/kconfig/lxdialog/textbox.o | Bin 0 -> 9144 bytes linux/scripts/kconfig/lxdialog/util.c | 713 +++ linux/scripts/kconfig/lxdialog/util.o | Bin 0 -> 23960 bytes linux/scripts/kconfig/lxdialog/yesno.c | 114 + linux/scripts/kconfig/lxdialog/yesno.o | Bin 0 -> 4336 bytes linux/scripts/kconfig/mconf.c | 1047 ++++ linux/scripts/kconfig/mconf.o | Bin 0 -> 33856 bytes linux/scripts/kconfig/menu.c | 697 +++ linux/scripts/kconfig/merge_config.sh | 158 + linux/scripts/kconfig/nconf.c | 1561 ++++++ linux/scripts/kconfig/nconf.gui.c | 656 +++ linux/scripts/kconfig/nconf.h | 96 + linux/scripts/kconfig/qconf.cc | 1798 +++++++ linux/scripts/kconfig/qconf.h | 338 ++ linux/scripts/kconfig/streamline_config.pl | 647 +++ linux/scripts/kconfig/symbol.c | 1373 +++++ linux/scripts/kconfig/util.c | 147 + linux/scripts/kconfig/zconf.gperf | 48 + linux/scripts/kconfig/zconf.hash.c_shipped | 289 + linux/scripts/kconfig/zconf.l | 363 ++ linux/scripts/kconfig/zconf.lex.c_shipped | 2420 +++++++++ linux/scripts/kconfig/zconf.tab.c_shipped | 2538 +++++++++ linux/scripts/kconfig/zconf.tab.o | Bin 0 -> 156744 bytes linux/scripts/kconfig/zconf.y | 733 +++ linux/scripts/kernel-doc | 2619 +++++++++ linux/scripts/ksymoops/README | 8 + linux/scripts/ld-version.sh | 8 + linux/scripts/link-vmlinux.sh | 240 + linux/scripts/makelst | 31 + linux/scripts/markup_oops.pl | 369 ++ linux/scripts/mkcompile_h | 102 + linux/scripts/mkmakefile | 52 + linux/scripts/mksysmap | 44 + linux/scripts/mkuboot.sh | 19 + linux/scripts/mkversion | 6 + linux/scripts/mod/.devicetable-offsets.h.cmd | 1 + linux/scripts/mod/.devicetable-offsets.s.cmd | 48 + linux/scripts/mod/.elfconfig.h.cmd | 1 + linux/scripts/mod/.empty.o.cmd | 9 + linux/scripts/mod/.file2alias.o.cmd | 72 + linux/scripts/mod/.gitignore | 4 + linux/scripts/mod/.mk_elfconfig.cmd | 53 + linux/scripts/mod/.modpost.cmd | 1 + linux/scripts/mod/.modpost.o.cmd | 95 + linux/scripts/mod/.sumversion.o.cmd | 94 + linux/scripts/mod/Makefile | 48 + linux/scripts/mod/devicetable-offsets.c | 193 + linux/scripts/mod/devicetable-offsets.s | 687 +++ linux/scripts/mod/empty.c | 1 + linux/scripts/mod/empty.o | Bin 0 -> 764 bytes linux/scripts/mod/file2alias.c | 1298 +++++ linux/scripts/mod/file2alias.o | Bin 0 -> 36176 bytes linux/scripts/mod/mk_elfconfig.c | 56 + linux/scripts/mod/modpost.c | 2476 +++++++++ linux/scripts/mod/modpost.h | 187 + linux/scripts/mod/modpost.o | Bin 0 -> 54488 bytes linux/scripts/mod/modules.order | 0 linux/scripts/mod/sumversion.c | 519 ++ linux/scripts/mod/sumversion.o | Bin 0 -> 9800 bytes linux/scripts/module-common.lds | 22 + linux/scripts/modules.order | 0 linux/scripts/namespace.pl | 470 ++ linux/scripts/objdiff | 159 + linux/scripts/package/Makefile | 145 + linux/scripts/package/builddeb | 446 ++ linux/scripts/package/buildtar | 137 + linux/scripts/package/mkspec | 163 + linux/scripts/patch-kernel | 331 ++ linux/scripts/pnmtologo.c | 514 ++ linux/scripts/profile2linkerlist.pl | 19 + linux/scripts/recordmcount.c | 485 ++ linux/scripts/recordmcount.h | 555 ++ linux/scripts/recordmcount.pl | 606 +++ linux/scripts/rt-tester/check-all.sh | 21 + linux/scripts/rt-tester/rt-tester.py | 218 + linux/scripts/rt-tester/t2-l1-2rt-sameprio.tst | 94 + linux/scripts/rt-tester/t2-l1-pi.tst | 77 + linux/scripts/rt-tester/t2-l1-signal.tst | 72 + linux/scripts/rt-tester/t2-l2-2rt-deadlock.tst | 84 + linux/scripts/rt-tester/t3-l1-pi-1rt.tst | 87 + linux/scripts/rt-tester/t3-l1-pi-2rt.tst | 88 + linux/scripts/rt-tester/t3-l1-pi-3rt.tst | 87 + linux/scripts/rt-tester/t3-l1-pi-signal.tst | 93 + linux/scripts/rt-tester/t3-l1-pi-steal.tst | 91 + linux/scripts/rt-tester/t3-l2-pi.tst | 87 + linux/scripts/rt-tester/t4-l2-pi-deboost.tst | 118 + .../rt-tester/t5-l4-pi-boost-deboost-setsched.tst | 178 + linux/scripts/rt-tester/t5-l4-pi-boost-deboost.tst | 138 + linux/scripts/selinux/Makefile | 2 + linux/scripts/selinux/README | 2 + linux/scripts/selinux/genheaders/.genheaders.cmd | 62 + linux/scripts/selinux/genheaders/.gitignore | 1 + linux/scripts/selinux/genheaders/Makefile | 4 + linux/scripts/selinux/genheaders/genheaders.c | 138 + linux/scripts/selinux/install_policy.sh | 68 + linux/scripts/selinux/mdp/.gitignore | 2 + linux/scripts/selinux/mdp/.mdp.cmd | 55 + linux/scripts/selinux/mdp/Makefile | 5 + linux/scripts/selinux/mdp/dbus_contexts | 6 + linux/scripts/selinux/mdp/mdp.c | 147 + linux/scripts/setlocalversion | 174 + linux/scripts/show_delta | 128 + linux/scripts/sign-file | 421 ++ linux/scripts/sortextable.c | 360 ++ linux/scripts/sortextable.h | 211 + linux/scripts/spelling.txt | 1043 ++++ linux/scripts/tags.sh | 339 ++ linux/scripts/tracing/draw_functrace.py | 129 + linux/scripts/unifdef.c | 1225 +++++ linux/scripts/ver_linux | 98 + linux/scripts/xen-hypercalls.sh | 12 + linux/scripts/xz_wrap.sh | 23 + 360 files changed, 94364 insertions(+) create mode 100644 linux/scripts/.conmakehash.cmd create mode 100644 linux/scripts/.gitignore create mode 100644 linux/scripts/.kallsyms.cmd create mode 100644 linux/scripts/.pnmtologo.cmd create mode 100644 linux/scripts/.recordmcount.cmd create mode 100644 linux/scripts/.sortextable.cmd create mode 100644 linux/scripts/Kbuild.include create mode 100755 linux/scripts/Lindent create mode 100644 linux/scripts/Makefile create mode 100644 linux/scripts/Makefile.asm-generic create mode 100644 linux/scripts/Makefile.build create mode 100644 linux/scripts/Makefile.clean create mode 100644 linux/scripts/Makefile.dtbinst create mode 100644 linux/scripts/Makefile.extrawarn create mode 100644 linux/scripts/Makefile.fwinst create mode 100644 linux/scripts/Makefile.headersinst create mode 100644 linux/scripts/Makefile.help create mode 100644 linux/scripts/Makefile.host create mode 100644 linux/scripts/Makefile.kasan create mode 100644 linux/scripts/Makefile.lib create mode 100644 linux/scripts/Makefile.modbuiltin create mode 100644 linux/scripts/Makefile.modinst create mode 100644 linux/scripts/Makefile.modpost create mode 100644 linux/scripts/Makefile.modsign create mode 100755 linux/scripts/analyze_suspend.py create mode 100644 linux/scripts/asn1_compiler.c create mode 100644 linux/scripts/basic/.bin2c.cmd create mode 100644 linux/scripts/basic/.fixdep.cmd create mode 100644 linux/scripts/basic/.gitignore create mode 100644 linux/scripts/basic/Makefile create mode 100644 linux/scripts/basic/bin2c.c create mode 100644 linux/scripts/basic/fixdep.c create mode 100644 linux/scripts/basic/modules.order create mode 100755 linux/scripts/bloat-o-meter create mode 100755 linux/scripts/bootgraph.pl create mode 100755 linux/scripts/check_extable.sh create mode 100755 linux/scripts/checkincludes.pl create mode 100755 linux/scripts/checkkconfigsymbols.py create mode 100755 linux/scripts/checkpatch.pl create mode 100755 linux/scripts/checkstack.pl create mode 100755 linux/scripts/checksyscalls.sh create mode 100755 linux/scripts/checkversion.pl create mode 100755 linux/scripts/cleanfile create mode 100755 linux/scripts/cleanpatch create mode 100755 linux/scripts/coccicheck create mode 100644 linux/scripts/coccinelle/api/alloc/alloc_cast.cocci create mode 100644 linux/scripts/coccinelle/api/alloc/kzalloc-simple.cocci create mode 100644 linux/scripts/coccinelle/api/d_find_alias.cocci create mode 100644 linux/scripts/coccinelle/api/err_cast.cocci create mode 100644 linux/scripts/coccinelle/api/kstrdup.cocci create mode 100644 linux/scripts/coccinelle/api/memdup.cocci create mode 100644 linux/scripts/coccinelle/api/memdup_user.cocci create mode 100644 linux/scripts/coccinelle/api/platform_no_drv_owner.cocci create mode 100644 linux/scripts/coccinelle/api/pm_runtime.cocci create mode 100644 linux/scripts/coccinelle/api/ptr_ret.cocci create mode 100644 linux/scripts/coccinelle/api/resource_size.cocci create mode 100644 linux/scripts/coccinelle/api/simple_open.cocci create mode 100644 linux/scripts/coccinelle/free/clk_put.cocci create mode 100644 linux/scripts/coccinelle/free/devm_free.cocci create mode 100644 linux/scripts/coccinelle/free/ifnullfree.cocci create mode 100644 linux/scripts/coccinelle/free/iounmap.cocci create mode 100644 linux/scripts/coccinelle/free/kfree.cocci create mode 100644 linux/scripts/coccinelle/free/kfreeaddr.cocci create mode 100644 linux/scripts/coccinelle/free/pci_free_consistent.cocci create mode 100644 linux/scripts/coccinelle/iterators/fen.cocci create mode 100644 linux/scripts/coccinelle/iterators/itnull.cocci create mode 100644 linux/scripts/coccinelle/iterators/list_entry_update.cocci create mode 100644 linux/scripts/coccinelle/iterators/use_after_iter.cocci create mode 100644 linux/scripts/coccinelle/locks/call_kern.cocci create mode 100644 linux/scripts/coccinelle/locks/double_lock.cocci create mode 100644 linux/scripts/coccinelle/locks/flags.cocci create mode 100644 linux/scripts/coccinelle/locks/mini_lock.cocci create mode 100644 linux/scripts/coccinelle/misc/array_size.cocci create mode 100644 linux/scripts/coccinelle/misc/badty.cocci create mode 100644 linux/scripts/coccinelle/misc/boolinit.cocci create mode 100644 linux/scripts/coccinelle/misc/boolreturn.cocci create mode 100644 linux/scripts/coccinelle/misc/bugon.cocci create mode 100644 linux/scripts/coccinelle/misc/cstptr.cocci create mode 100644 linux/scripts/coccinelle/misc/doubleinit.cocci create mode 100644 linux/scripts/coccinelle/misc/ifaddr.cocci create mode 100644 linux/scripts/coccinelle/misc/ifcol.cocci create mode 100644 linux/scripts/coccinelle/misc/irqf_oneshot.cocci create mode 100644 linux/scripts/coccinelle/misc/noderef.cocci create mode 100644 linux/scripts/coccinelle/misc/of_table.cocci create mode 100644 linux/scripts/coccinelle/misc/orplus.cocci create mode 100644 linux/scripts/coccinelle/misc/returnvar.cocci create mode 100644 linux/scripts/coccinelle/misc/semicolon.cocci create mode 100644 linux/scripts/coccinelle/misc/simple_return.cocci create mode 100644 linux/scripts/coccinelle/misc/warn.cocci create mode 100644 linux/scripts/coccinelle/null/badzero.cocci create mode 100644 linux/scripts/coccinelle/null/deref_null.cocci create mode 100644 linux/scripts/coccinelle/null/eno.cocci create mode 100644 linux/scripts/coccinelle/null/kmerr.cocci create mode 100644 linux/scripts/coccinelle/tests/doublebitand.cocci create mode 100644 linux/scripts/coccinelle/tests/doubletest.cocci create mode 100644 linux/scripts/coccinelle/tests/odd_ptr_err.cocci create mode 100755 linux/scripts/config create mode 100644 linux/scripts/conmakehash.c create mode 100755 linux/scripts/decode_stacktrace.sh create mode 100755 linux/scripts/decodecode create mode 100755 linux/scripts/depmod.sh create mode 100755 linux/scripts/diffconfig create mode 100644 linux/scripts/docproc.c create mode 100644 linux/scripts/dtc/.checks.o.cmd create mode 100644 linux/scripts/dtc/.data.o.cmd create mode 100644 linux/scripts/dtc/.dtc-lexer.lex.o.cmd create mode 100644 linux/scripts/dtc/.dtc-parser.tab.o.cmd create mode 100644 linux/scripts/dtc/.dtc.cmd create mode 100644 linux/scripts/dtc/.dtc.o.cmd create mode 100644 linux/scripts/dtc/.flattree.o.cmd create mode 100644 linux/scripts/dtc/.fstree.o.cmd create mode 100644 linux/scripts/dtc/.gitignore create mode 100644 linux/scripts/dtc/.livetree.o.cmd create mode 100644 linux/scripts/dtc/.srcpos.o.cmd create mode 100644 linux/scripts/dtc/.treesource.o.cmd create mode 100644 linux/scripts/dtc/.util.o.cmd create mode 100644 linux/scripts/dtc/Makefile create mode 100644 linux/scripts/dtc/Makefile.dtc create mode 100644 linux/scripts/dtc/checks.c create mode 100644 linux/scripts/dtc/checks.o create mode 100644 linux/scripts/dtc/data.c create mode 100644 linux/scripts/dtc/data.o create mode 100644 linux/scripts/dtc/dtc-lexer.l create mode 100644 linux/scripts/dtc/dtc-lexer.lex.c_shipped create mode 100644 linux/scripts/dtc/dtc-lexer.lex.o create mode 100644 linux/scripts/dtc/dtc-parser.tab.c_shipped create mode 100644 linux/scripts/dtc/dtc-parser.tab.h_shipped create mode 100644 linux/scripts/dtc/dtc-parser.tab.o create mode 100644 linux/scripts/dtc/dtc-parser.y create mode 100644 linux/scripts/dtc/dtc.c create mode 100644 linux/scripts/dtc/dtc.h create mode 100644 linux/scripts/dtc/dtc.o create mode 100644 linux/scripts/dtc/fdtdump.c create mode 100644 linux/scripts/dtc/fdtget.c create mode 100644 linux/scripts/dtc/fdtput.c create mode 100644 linux/scripts/dtc/flattree.c create mode 100644 linux/scripts/dtc/flattree.o create mode 100644 linux/scripts/dtc/fstree.c create mode 100644 linux/scripts/dtc/fstree.o create mode 100644 linux/scripts/dtc/libfdt/Makefile.libfdt create mode 100644 linux/scripts/dtc/libfdt/fdt.c create mode 100644 linux/scripts/dtc/libfdt/fdt.h create mode 100644 linux/scripts/dtc/libfdt/fdt_empty_tree.c create mode 100644 linux/scripts/dtc/libfdt/fdt_ro.c create mode 100644 linux/scripts/dtc/libfdt/fdt_rw.c create mode 100644 linux/scripts/dtc/libfdt/fdt_strerror.c create mode 100644 linux/scripts/dtc/libfdt/fdt_sw.c create mode 100644 linux/scripts/dtc/libfdt/fdt_wip.c create mode 100644 linux/scripts/dtc/libfdt/libfdt.h create mode 100644 linux/scripts/dtc/libfdt/libfdt_env.h create mode 100644 linux/scripts/dtc/libfdt/libfdt_internal.h create mode 100644 linux/scripts/dtc/livetree.c create mode 100644 linux/scripts/dtc/livetree.o create mode 100644 linux/scripts/dtc/modules.order create mode 100644 linux/scripts/dtc/srcpos.c create mode 100644 linux/scripts/dtc/srcpos.h create mode 100644 linux/scripts/dtc/srcpos.o create mode 100644 linux/scripts/dtc/treesource.c create mode 100644 linux/scripts/dtc/treesource.o create mode 100755 linux/scripts/dtc/update-dtc-source.sh create mode 100644 linux/scripts/dtc/util.c create mode 100644 linux/scripts/dtc/util.h create mode 100644 linux/scripts/dtc/util.o create mode 100644 linux/scripts/dtc/version_gen.h create mode 100755 linux/scripts/export_report.pl create mode 100755 linux/scripts/extract-ikconfig create mode 100755 linux/scripts/extract-vmlinux create mode 100755 linux/scripts/gcc-goto.sh create mode 100755 linux/scripts/gcc-ld create mode 100755 linux/scripts/gcc-version.sh create mode 100755 linux/scripts/gcc-x86_32-has-stack-protector.sh create mode 100755 linux/scripts/gcc-x86_64-has-stack-protector.sh create mode 100644 linux/scripts/gdb/Makefile create mode 100644 linux/scripts/gdb/linux/.gitignore create mode 100644 linux/scripts/gdb/linux/Makefile create mode 100644 linux/scripts/gdb/linux/__init__.py create mode 100644 linux/scripts/gdb/linux/cpus.py create mode 100644 linux/scripts/gdb/linux/dmesg.py create mode 100644 linux/scripts/gdb/linux/modules.py create mode 100644 linux/scripts/gdb/linux/symbols.py create mode 100644 linux/scripts/gdb/linux/tasks.py create mode 100644 linux/scripts/gdb/linux/utils.py create mode 100644 linux/scripts/gdb/vmlinux-gdb.py create mode 100755 linux/scripts/gen_initramfs_list.sh create mode 100644 linux/scripts/genksyms/.genksyms.cmd create mode 100644 linux/scripts/genksyms/.genksyms.o.cmd create mode 100644 linux/scripts/genksyms/.gitignore create mode 100644 linux/scripts/genksyms/.lex.lex.o.cmd create mode 100644 linux/scripts/genksyms/.parse.tab.o.cmd create mode 100644 linux/scripts/genksyms/Makefile create mode 100644 linux/scripts/genksyms/genksyms.c create mode 100644 linux/scripts/genksyms/genksyms.h create mode 100644 linux/scripts/genksyms/genksyms.o create mode 100644 linux/scripts/genksyms/keywords.gperf create mode 100644 linux/scripts/genksyms/keywords.hash.c_shipped create mode 100644 linux/scripts/genksyms/lex.l create mode 100644 linux/scripts/genksyms/lex.lex.c_shipped create mode 100644 linux/scripts/genksyms/lex.lex.o create mode 100644 linux/scripts/genksyms/modules.order create mode 100644 linux/scripts/genksyms/parse.tab.c_shipped create mode 100644 linux/scripts/genksyms/parse.tab.h_shipped create mode 100644 linux/scripts/genksyms/parse.tab.o create mode 100644 linux/scripts/genksyms/parse.y create mode 100755 linux/scripts/get_maintainer.pl create mode 100755 linux/scripts/gfp-translate create mode 100755 linux/scripts/headerdep.pl create mode 100755 linux/scripts/headers.sh create mode 100755 linux/scripts/headers_check.pl create mode 100755 linux/scripts/headers_install.sh create mode 100644 linux/scripts/kallsyms.c create mode 100644 linux/scripts/kconfig/.conf.cmd create mode 100644 linux/scripts/kconfig/.conf.o.cmd create mode 100644 linux/scripts/kconfig/.gitignore create mode 100644 linux/scripts/kconfig/.mconf.cmd create mode 100644 linux/scripts/kconfig/.mconf.o.cmd create mode 100644 linux/scripts/kconfig/.zconf.tab.o.cmd create mode 100644 linux/scripts/kconfig/Makefile create mode 100644 linux/scripts/kconfig/POTFILES.in create mode 100755 linux/scripts/kconfig/check.sh create mode 100644 linux/scripts/kconfig/conf.c create mode 100644 linux/scripts/kconfig/conf.o create mode 100644 linux/scripts/kconfig/confdata.c create mode 100644 linux/scripts/kconfig/expr.c create mode 100644 linux/scripts/kconfig/expr.h create mode 100644 linux/scripts/kconfig/gconf.c create mode 100644 linux/scripts/kconfig/gconf.glade create mode 100644 linux/scripts/kconfig/images.c create mode 100644 linux/scripts/kconfig/kxgettext.c create mode 100644 linux/scripts/kconfig/list.h create mode 100644 linux/scripts/kconfig/lkc.h create mode 100644 linux/scripts/kconfig/lkc_proto.h create mode 100644 linux/scripts/kconfig/lxdialog/.checklist.o.cmd create mode 100644 linux/scripts/kconfig/lxdialog/.gitignore create mode 100644 linux/scripts/kconfig/lxdialog/.inputbox.o.cmd create mode 100644 linux/scripts/kconfig/lxdialog/.menubox.o.cmd create mode 100644 linux/scripts/kconfig/lxdialog/.textbox.o.cmd create mode 100644 linux/scripts/kconfig/lxdialog/.util.o.cmd create mode 100644 linux/scripts/kconfig/lxdialog/.yesno.o.cmd create mode 100644 linux/scripts/kconfig/lxdialog/BIG.FAT.WARNING create mode 100755 linux/scripts/kconfig/lxdialog/check-lxdialog.sh create mode 100644 linux/scripts/kconfig/lxdialog/checklist.c create mode 100644 linux/scripts/kconfig/lxdialog/checklist.o create mode 100644 linux/scripts/kconfig/lxdialog/dialog.h create mode 100644 linux/scripts/kconfig/lxdialog/inputbox.c create mode 100644 linux/scripts/kconfig/lxdialog/inputbox.o create mode 100644 linux/scripts/kconfig/lxdialog/menubox.c create mode 100644 linux/scripts/kconfig/lxdialog/menubox.o create mode 100644 linux/scripts/kconfig/lxdialog/textbox.c create mode 100644 linux/scripts/kconfig/lxdialog/textbox.o create mode 100644 linux/scripts/kconfig/lxdialog/util.c create mode 100644 linux/scripts/kconfig/lxdialog/util.o create mode 100644 linux/scripts/kconfig/lxdialog/yesno.c create mode 100644 linux/scripts/kconfig/lxdialog/yesno.o create mode 100644 linux/scripts/kconfig/mconf.c create mode 100644 linux/scripts/kconfig/mconf.o create mode 100644 linux/scripts/kconfig/menu.c create mode 100755 linux/scripts/kconfig/merge_config.sh create mode 100644 linux/scripts/kconfig/nconf.c create mode 100644 linux/scripts/kconfig/nconf.gui.c create mode 100644 linux/scripts/kconfig/nconf.h create mode 100644 linux/scripts/kconfig/qconf.cc create mode 100644 linux/scripts/kconfig/qconf.h create mode 100755 linux/scripts/kconfig/streamline_config.pl create mode 100644 linux/scripts/kconfig/symbol.c create mode 100644 linux/scripts/kconfig/util.c create mode 100644 linux/scripts/kconfig/zconf.gperf create mode 100644 linux/scripts/kconfig/zconf.hash.c_shipped create mode 100644 linux/scripts/kconfig/zconf.l create mode 100644 linux/scripts/kconfig/zconf.lex.c_shipped create mode 100644 linux/scripts/kconfig/zconf.tab.c_shipped create mode 100644 linux/scripts/kconfig/zconf.tab.o create mode 100644 linux/scripts/kconfig/zconf.y create mode 100755 linux/scripts/kernel-doc create mode 100644 linux/scripts/ksymoops/README create mode 100755 linux/scripts/ld-version.sh create mode 100755 linux/scripts/link-vmlinux.sh create mode 100755 linux/scripts/makelst create mode 100755 linux/scripts/markup_oops.pl create mode 100755 linux/scripts/mkcompile_h create mode 100755 linux/scripts/mkmakefile create mode 100755 linux/scripts/mksysmap create mode 100755 linux/scripts/mkuboot.sh create mode 100644 linux/scripts/mkversion create mode 100644 linux/scripts/mod/.devicetable-offsets.h.cmd create mode 100644 linux/scripts/mod/.devicetable-offsets.s.cmd create mode 100644 linux/scripts/mod/.elfconfig.h.cmd create mode 100644 linux/scripts/mod/.empty.o.cmd create mode 100644 linux/scripts/mod/.file2alias.o.cmd create mode 100644 linux/scripts/mod/.gitignore create mode 100644 linux/scripts/mod/.mk_elfconfig.cmd create mode 100644 linux/scripts/mod/.modpost.cmd create mode 100644 linux/scripts/mod/.modpost.o.cmd create mode 100644 linux/scripts/mod/.sumversion.o.cmd create mode 100644 linux/scripts/mod/Makefile create mode 100644 linux/scripts/mod/devicetable-offsets.c create mode 100644 linux/scripts/mod/devicetable-offsets.s create mode 100644 linux/scripts/mod/empty.c create mode 100644 linux/scripts/mod/empty.o create mode 100644 linux/scripts/mod/file2alias.c create mode 100644 linux/scripts/mod/file2alias.o create mode 100644 linux/scripts/mod/mk_elfconfig.c create mode 100644 linux/scripts/mod/modpost.c create mode 100644 linux/scripts/mod/modpost.h create mode 100644 linux/scripts/mod/modpost.o create mode 100644 linux/scripts/mod/modules.order create mode 100644 linux/scripts/mod/sumversion.c create mode 100644 linux/scripts/mod/sumversion.o create mode 100644 linux/scripts/module-common.lds create mode 100644 linux/scripts/modules.order create mode 100755 linux/scripts/namespace.pl create mode 100755 linux/scripts/objdiff create mode 100644 linux/scripts/package/Makefile create mode 100755 linux/scripts/package/builddeb create mode 100755 linux/scripts/package/buildtar create mode 100755 linux/scripts/package/mkspec create mode 100755 linux/scripts/patch-kernel create mode 100644 linux/scripts/pnmtologo.c create mode 100755 linux/scripts/profile2linkerlist.pl create mode 100644 linux/scripts/recordmcount.c create mode 100644 linux/scripts/recordmcount.h create mode 100755 linux/scripts/recordmcount.pl create mode 100644 linux/scripts/rt-tester/check-all.sh create mode 100755 linux/scripts/rt-tester/rt-tester.py create mode 100644 linux/scripts/rt-tester/t2-l1-2rt-sameprio.tst create mode 100644 linux/scripts/rt-tester/t2-l1-pi.tst create mode 100644 linux/scripts/rt-tester/t2-l1-signal.tst create mode 100644 linux/scripts/rt-tester/t2-l2-2rt-deadlock.tst create mode 100644 linux/scripts/rt-tester/t3-l1-pi-1rt.tst create mode 100644 linux/scripts/rt-tester/t3-l1-pi-2rt.tst create mode 100644 linux/scripts/rt-tester/t3-l1-pi-3rt.tst create mode 100644 linux/scripts/rt-tester/t3-l1-pi-signal.tst create mode 100644 linux/scripts/rt-tester/t3-l1-pi-steal.tst create mode 100644 linux/scripts/rt-tester/t3-l2-pi.tst create mode 100644 linux/scripts/rt-tester/t4-l2-pi-deboost.tst create mode 100644 linux/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst create mode 100644 linux/scripts/rt-tester/t5-l4-pi-boost-deboost.tst create mode 100644 linux/scripts/selinux/Makefile create mode 100644 linux/scripts/selinux/README create mode 100644 linux/scripts/selinux/genheaders/.genheaders.cmd create mode 100644 linux/scripts/selinux/genheaders/.gitignore create mode 100644 linux/scripts/selinux/genheaders/Makefile create mode 100644 linux/scripts/selinux/genheaders/genheaders.c create mode 100755 linux/scripts/selinux/install_policy.sh create mode 100644 linux/scripts/selinux/mdp/.gitignore create mode 100644 linux/scripts/selinux/mdp/.mdp.cmd create mode 100644 linux/scripts/selinux/mdp/Makefile create mode 100644 linux/scripts/selinux/mdp/dbus_contexts create mode 100644 linux/scripts/selinux/mdp/mdp.c create mode 100755 linux/scripts/setlocalversion create mode 100755 linux/scripts/show_delta create mode 100755 linux/scripts/sign-file create mode 100644 linux/scripts/sortextable.c create mode 100644 linux/scripts/sortextable.h create mode 100644 linux/scripts/spelling.txt create mode 100755 linux/scripts/tags.sh create mode 100755 linux/scripts/tracing/draw_functrace.py create mode 100644 linux/scripts/unifdef.c create mode 100755 linux/scripts/ver_linux create mode 100644 linux/scripts/xen-hypercalls.sh create mode 100755 linux/scripts/xz_wrap.sh (limited to 'linux/scripts') diff --git a/linux/scripts/.conmakehash.cmd b/linux/scripts/.conmakehash.cmd new file mode 100644 index 00000000..5d98a2ef --- /dev/null +++ b/linux/scripts/.conmakehash.cmd @@ -0,0 +1,50 @@ +cmd_scripts/conmakehash := gcc -Wp,-MD,scripts/.conmakehash.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -I./tools/include -o scripts/conmakehash scripts/conmakehash.c + +source_scripts/conmakehash := scripts/conmakehash.c + +deps_scripts/conmakehash := \ + /usr/include/stdc-predef.h \ + /usr/include/stdio.h \ + /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/sysexits.h \ + /usr/include/string.h \ + /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/ctype.h \ + +scripts/conmakehash: $(deps_scripts/conmakehash) + +$(deps_scripts/conmakehash): diff --git a/linux/scripts/.gitignore b/linux/scripts/.gitignore new file mode 100644 index 00000000..5ecfe93f --- /dev/null +++ b/linux/scripts/.gitignore @@ -0,0 +1,12 @@ +# +# Generated files +# +conmakehash +kallsyms +pnmtologo +unifdef +ihex2fw +recordmcount +docproc +sortextable +asn1_compiler diff --git a/linux/scripts/.kallsyms.cmd b/linux/scripts/.kallsyms.cmd new file mode 100644 index 00000000..ff453445 --- /dev/null +++ b/linux/scripts/.kallsyms.cmd @@ -0,0 +1,50 @@ +cmd_scripts/kallsyms := gcc -Wp,-MD,scripts/.kallsyms.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -I./tools/include -o scripts/kallsyms scripts/kallsyms.c + +source_scripts/kallsyms := scripts/kallsyms.c + +deps_scripts/kallsyms := \ + $(wildcard include/config/page/offset.h) \ + /usr/include/stdc-predef.h \ + /usr/include/stdio.h \ + /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/string.h \ + /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/ctype.h \ + +scripts/kallsyms: $(deps_scripts/kallsyms) + +$(deps_scripts/kallsyms): diff --git a/linux/scripts/.pnmtologo.cmd b/linux/scripts/.pnmtologo.cmd new file mode 100644 index 00000000..adcbbcec --- /dev/null +++ b/linux/scripts/.pnmtologo.cmd @@ -0,0 +1,60 @@ +cmd_scripts/pnmtologo := gcc -Wp,-MD,scripts/.pnmtologo.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -I./tools/include -o scripts/pnmtologo scripts/pnmtologo.c + +source_scripts/pnmtologo := scripts/pnmtologo.c + +deps_scripts/pnmtologo := \ + /usr/include/stdc-predef.h \ + /usr/include/ctype.h \ + /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/xlocale.h \ + /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h \ + /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/unistd.h \ + /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/getopt.h \ + +scripts/pnmtologo: $(deps_scripts/pnmtologo) + +$(deps_scripts/pnmtologo): diff --git a/linux/scripts/.recordmcount.cmd b/linux/scripts/.recordmcount.cmd new file mode 100644 index 00000000..05b13706 --- /dev/null +++ b/linux/scripts/.recordmcount.cmd @@ -0,0 +1,69 @@ +cmd_scripts/recordmcount := gcc -Wp,-MD,scripts/.recordmcount.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -I./tools/include -o scripts/recordmcount scripts/recordmcount.c + +source_scripts/recordmcount := scripts/recordmcount.c + +deps_scripts/recordmcount := \ + /usr/include/stdc-predef.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/time.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/sys/mman.h \ + /usr/include/x86_64-linux-gnu/bits/mman.h \ + /usr/include/x86_64-linux-gnu/bits/mman-linux.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h \ + /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/getopt.h \ + /usr/include/elf.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h \ + /usr/include/stdint.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/auxv.h \ + /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/setjmp.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/stdio.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/string.h \ + /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/unistd.h \ + /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + scripts/recordmcount.h \ + +scripts/recordmcount: $(deps_scripts/recordmcount) + +$(deps_scripts/recordmcount): diff --git a/linux/scripts/.sortextable.cmd b/linux/scripts/.sortextable.cmd new file mode 100644 index 00000000..be449170 --- /dev/null +++ b/linux/scripts/.sortextable.cmd @@ -0,0 +1,71 @@ +cmd_scripts/sortextable := gcc -Wp,-MD,scripts/.sortextable.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -I./tools/include -I./tools/include -o scripts/sortextable scripts/sortextable.c + +source_scripts/sortextable := scripts/sortextable.c + +deps_scripts/sortextable := \ + /usr/include/stdc-predef.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/time.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/sys/mman.h \ + /usr/include/x86_64-linux-gnu/bits/mman.h \ + /usr/include/x86_64-linux-gnu/bits/mman-linux.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h \ + /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/getopt.h \ + /usr/include/elf.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h \ + /usr/include/stdint.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/auxv.h \ + /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/setjmp.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/stdio.h \ + /usr/include/libio.h \ + /usr/include/_G_config.h \ + /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/string.h \ + /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/unistd.h \ + /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + tools/include/tools/be_byteshift.h \ + tools/include/tools/le_byteshift.h \ + scripts/sortextable.h \ + +scripts/sortextable: $(deps_scripts/sortextable) + +$(deps_scripts/sortextable): diff --git a/linux/scripts/Kbuild.include b/linux/scripts/Kbuild.include new file mode 100644 index 00000000..d3437b82 --- /dev/null +++ b/linux/scripts/Kbuild.include @@ -0,0 +1,305 @@ +#### +# kbuild: Generic definitions + +# Convenient variables +comma := , +quote := " +squote := ' +empty := +space := $(empty) $(empty) + +### +# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o +dot-target = $(dir $@).$(notdir $@) + +### +# The temporary file to save gcc -MD generated dependencies must not +# contain a comma +depfile = $(subst $(comma),_,$(dot-target).d) + +### +# filename of target with directory and extension stripped +basetarget = $(basename $(notdir $@)) + +### +# filename of first prerequisite with directory and extension stripped +baseprereq = $(basename $(notdir $<)) + +### +# Escape single quote for use in echo statements +escsq = $(subst $(squote),'\$(squote)',$1) + +### +# Easy method for doing a status message + kecho := : + quiet_kecho := echo +silent_kecho := : +kecho := $($(quiet)kecho) + +### +# filechk is used to check if the content of a generated file is updated. +# Sample usage: +# define filechk_sample +# echo $KERNELRELEASE +# endef +# version.h : Makefile +# $(call filechk,sample) +# The rule defined shall write to stdout the content of the new file. +# The existing file will be compared with the new one. +# - If no file exist it is created +# - If the content differ the new file is used +# - If they are equal no change, and no timestamp update +# - stdin is piped in from the first prerequisite ($<) so one has +# to specify a valid file as first prerequisite (often the kbuild file) +define filechk + $(Q)set -e; \ + $(kecho) ' CHK $@'; \ + mkdir -p $(dir $@); \ + $(filechk_$(1)) < $< > $@.tmp; \ + if [ -r $@ ] && cmp -s $@ $@.tmp; then \ + rm -f $@.tmp; \ + else \ + $(kecho) ' UPD $@'; \ + mv -f $@.tmp $@; \ + fi +endef + +###### +# gcc support functions +# See documentation in Documentation/kbuild/makefiles.txt + +# cc-cross-prefix +# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) +# Return first prefix where a prefix$(CC) is found in PATH. +# If no $(CC) found in PATH with listed prefixes return nothing +cc-cross-prefix = \ + $(word 1, $(foreach c,$(1), \ + $(shell set -e; \ + if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \ + echo $(c); \ + fi))) + +# output directory for tests below +TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) + +# try-run +# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) +# Exit code chooses option. "$$TMP" is can be used as temporary file and +# is automatically cleaned up. +try-run = $(shell set -e; \ + TMP="$(TMPOUT).$$$$.tmp"; \ + TMPO="$(TMPOUT).$$$$.o"; \ + if ($(1)) >/dev/null 2>&1; \ + then echo "$(2)"; \ + else echo "$(3)"; \ + fi; \ + rm -f "$$TMP" "$$TMPO") + +# as-option +# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) + +as-option = $(call try-run,\ + $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) + +# as-instr +# Usage: cflags-y += $(call as-instr,instr,option1,option2) + +as-instr = $(call try-run,\ + printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) + +# cc-option +# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) + +cc-option = $(call try-run,\ + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) + +# cc-option-yn +# Usage: flag := $(call cc-option-yn,-march=winchip-c6) +cc-option-yn = $(call try-run,\ + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + +# cc-option-align +# Prefix align with either -falign or -malign +cc-option-align = $(subst -functions=0,,\ + $(call cc-option,-falign-functions=0,-malign-functions=0)) + +# cc-disable-warning +# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) +cc-disable-warning = $(call try-run,\ + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) + +# cc-version +cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) + +# cc-fullversion +cc-fullversion = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/gcc-version.sh -p $(CC)) + +# cc-ifversion +# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) +cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) + +# cc-ldoption +# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) +cc-ldoption = $(call try-run,\ + $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) + +# ld-option +# Usage: LDFLAGS += $(call ld-option, -X) +ld-option = $(call try-run,\ + $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) + +# ar-option +# Usage: KBUILD_ARFLAGS := $(call ar-option,D) +# Important: no spaces around options +ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) + +# ld-version +# Note this is mainly for HJ Lu's 3 number binutil versions +ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) + +# ld-ifversion +# Usage: $(call ld-ifversion, -ge, 22252, y) +ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4)) + +###### + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= +# Usage: +# $(Q)$(MAKE) $(build)=dir +build := -f $(srctree)/scripts/Makefile.build obj + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= +# Usage: +# $(Q)$(MAKE) $(modbuiltin)=dir +modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= +# Usage: +# $(Q)$(MAKE) $(dtbinst)=dir +dtbinst := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.dtbinst obj + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= +# Usage: +# $(Q)$(MAKE) $(clean)=dir +clean := -f $(srctree)/scripts/Makefile.clean obj + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.headersinst obj= +# Usage: +# $(Q)$(MAKE) $(hdr-inst)=dir +hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj + +# Prefix -I with $(srctree) if it is not an absolute path. +# skip if -I has no parameter +addtree = $(if $(patsubst -I%,%,$(1)), \ +$(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)) + +# Find all -I options and call addtree +flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) + +# echo command. +# Short version is used, if $(quiet) equals `quiet_', otherwise full one. +echo-cmd = $(if $($(quiet)cmd_$(1)),\ + echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) + +# printing commands +cmd = @$(echo-cmd) $(cmd_$(1)) + +# Add $(obj)/ for paths that are not absolute +objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) + +### +# if_changed - execute command if any prerequisite is newer than +# target, or command line has changed +# if_changed_dep - as if_changed, but uses fixdep to reveal dependencies +# including used config symbols +# if_changed_rule - as if_changed but execute rule instead +# See Documentation/kbuild/makefiles.txt for more info + +ifneq ($(KBUILD_NOCMDDEP),1) +# Check if both arguments has same arguments. Result is empty string if equal. +# User may override this check using make KBUILD_NOCMDDEP=1 +arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ + $(filter-out $(cmd_$@), $(cmd_$(1))) ) +else +arg-check = $(if $(strip $(cmd_$@)),,1) +endif + +# Replace >$< with >$$< to preserve $ when reloading the .cmd file +# (needed for make) +# Replace >#< with >\#< to avoid starting a comment in the .cmd file +# (needed for make) +# Replace >'< with >'\''< to be able to enclose the whole string in '...' +# (needed for the shell) +make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) + +# Find any prerequisites that is newer than target or that does not exist. +# PHONY targets skipped in both cases. +any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) + +# Execute command if command has changed or prerequisite(s) are updated. +# +if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ + @set -e; \ + $(echo-cmd) $(cmd_$(1)); \ + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) + +# Execute the command and also postprocess generated .d dependencies file. +if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ + @set -e; \ + $(echo-cmd) $(cmd_$(1)); \ + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ + rm -f $(depfile); \ + mv -f $(dot-target).tmp $(dot-target).cmd) + +# Usage: $(call if_changed_rule,foo) +# Will check if $(cmd_foo) or any of the prerequisites changed, +# and if so will execute $(rule_foo). +if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ + @set -e; \ + $(rule_$(1))) + +### +# why - tell why a a target got build +# enabled by make V=2 +# Output (listed in the order they are checked): +# (1) - due to target is PHONY +# (2) - due to target missing +# (3) - due to: file1.h file2.h +# (4) - due to command line change +# (5) - due to missing .cmd file +# (6) - due to target not in $(targets) +# (1) PHONY targets are always build +# (2) No target, so we better build it +# (3) Prerequisite is newer than target +# (4) The command line stored in the file named dir/.target.cmd +# differed from actual command line. This happens when compiler +# options changes +# (5) No dir/.target.cmd file (used to store command line) +# (6) No dir/.target.cmd file and target not listed in $(targets) +# This is a good hint that there is a bug in the kbuild file +ifeq ($(KBUILD_VERBOSE),2) +why = \ + $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ + $(if $(wildcard $@), \ + $(if $(strip $(any-prereq)),- due to: $(any-prereq), \ + $(if $(arg-check), \ + $(if $(cmd_$@),- due to command line change, \ + $(if $(filter $@, $(targets)), \ + - due to missing .cmd file, \ + - due to $(notdir $@) not in $$(targets) \ + ) \ + ) \ + ) \ + ), \ + - due to target missing \ + ) \ + ) + +echo-why = $(call escsq, $(strip $(why))) +endif diff --git a/linux/scripts/Lindent b/linux/scripts/Lindent new file mode 100755 index 00000000..9c4b3e2b --- /dev/null +++ b/linux/scripts/Lindent @@ -0,0 +1,18 @@ +#!/bin/sh +PARAM="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1" +RES=`indent --version` +V1=`echo $RES | cut -d' ' -f3 | cut -d'.' -f1` +V2=`echo $RES | cut -d' ' -f3 | cut -d'.' -f2` +V3=`echo $RES | cut -d' ' -f3 | cut -d'.' -f3` +if [ $V1 -gt 2 ]; then + PARAM="$PARAM -il0" +elif [ $V1 -eq 2 ]; then + if [ $V2 -gt 2 ]; then + PARAM="$PARAM -il0"; + elif [ $V2 -eq 2 ]; then + if [ $V3 -ge 10 ]; then + PARAM="$PARAM -il0" + fi + fi +fi +indent $PARAM "$@" diff --git a/linux/scripts/Makefile b/linux/scripts/Makefile new file mode 100644 index 00000000..2016a644 --- /dev/null +++ b/linux/scripts/Makefile @@ -0,0 +1,42 @@ +### +# scripts contains sources for various helper programs used throughout +# the kernel for the build process. +# --------------------------------------------------------------------------- +# kallsyms: Find all symbols in vmlinux +# pnmttologo: Convert pnm files to logo files +# conmakehash: Create chartable +# conmakehash: Create arrays for initializing the kernel console tables +# docproc: Used in Documentation/DocBook + +HOST_EXTRACFLAGS += -I$(srctree)/tools/include + +hostprogs-$(CONFIG_KALLSYMS) += kallsyms +hostprogs-$(CONFIG_LOGO) += pnmtologo +hostprogs-$(CONFIG_VT) += conmakehash +hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount +hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable +hostprogs-$(CONFIG_ASN1) += asn1_compiler + +HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include +HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include + +always := $(hostprogs-y) $(hostprogs-m) + +# The following hostprogs-y programs are only build on demand +hostprogs-y += unifdef docproc + +# These targets are used internally to avoid "is up to date" messages +PHONY += build_unifdef build_docproc +build_unifdef: $(obj)/unifdef + @: +build_docproc: $(obj)/docproc + @: + +subdir-$(CONFIG_MODVERSIONS) += genksyms +subdir-y += mod +subdir-$(CONFIG_SECURITY_SELINUX) += selinux +subdir-$(CONFIG_DTC) += dtc +subdir-$(CONFIG_GDB_SCRIPTS) += gdb + +# Let clean descend into subdirs +subdir- += basic kconfig package diff --git a/linux/scripts/Makefile.asm-generic b/linux/scripts/Makefile.asm-generic new file mode 100644 index 00000000..045e0098 --- /dev/null +++ b/linux/scripts/Makefile.asm-generic @@ -0,0 +1,23 @@ +# include/asm-generic contains a lot of files that are used +# verbatim by several architectures. +# +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild +# and for each file listed in this file with generic-y creates +# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) + +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild +-include $(kbuild-file) + +include scripts/Kbuild.include + +# Create output directory if not already present +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) + +quiet_cmd_wrap = WRAP $@ +cmd_wrap = echo "\#include " >$@ + +all: $(patsubst %, $(obj)/%, $(generic-y)) + @: + +$(obj)/%.h: + $(call cmd,wrap) diff --git a/linux/scripts/Makefile.build b/linux/scripts/Makefile.build new file mode 100644 index 00000000..01df30af --- /dev/null +++ b/linux/scripts/Makefile.build @@ -0,0 +1,427 @@ +# ========================================================================== +# Building +# ========================================================================== + +src := $(obj) + +PHONY := __build +__build: + +# Init all relevant variables used in kbuild files so +# 1) they have correct type +# 2) they do not inherit any value from the environment +obj-y := +obj-m := +lib-y := +lib-m := +always := +targets := +subdir-y := +subdir-m := +EXTRA_AFLAGS := +EXTRA_CFLAGS := +EXTRA_CPPFLAGS := +EXTRA_LDFLAGS := +asflags-y := +ccflags-y := +cppflags-y := +ldflags-y := + +subdir-asflags-y := +subdir-ccflags-y := + +# Read auto.conf if it exists, otherwise ignore +-include include/config/auto.conf + +include scripts/Kbuild.include + +# For backward compatibility check that these variables do not change +save-cflags := $(CFLAGS) + +# The filename Kbuild has precedence over Makefile +kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) +include $(kbuild-file) + +# If the save-* variables changed error out +ifeq ($(KBUILD_NOPEDANTIC),) + ifneq ("$(save-cflags)","$(CFLAGS)") + $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y) + endif +endif + +include scripts/Makefile.lib + +ifdef host-progs +ifneq ($(hostprogs-y),$(host-progs)) +$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!) +hostprogs-y += $(host-progs) +endif +endif + +# Do not include host rules unless needed +ifneq ($(hostprogs-y)$(hostprogs-m),) +include scripts/Makefile.host +endif + +ifneq ($(KBUILD_SRC),) +# Create output directory if not already present +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) + +# Create directories for object files if directory does not exist +# Needed when obj-y := dir/file.o syntax is used +_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) +endif + +ifndef obj +$(warning kbuild: Makefile.build is included improperly) +endif + +# =========================================================================== + +ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) +lib-target := $(obj)/lib.a +endif + +ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) +builtin-target := $(obj)/built-in.o +endif + +modorder-target := $(obj)/modules.order + +# We keep a list of all modules in $(MODVERDIR) + +__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ + $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \ + $(subdir-ym) $(always) + @: + +# Linus' kernel sanity checking tool +ifneq ($(KBUILD_CHECKSRC),0) + ifeq ($(KBUILD_CHECKSRC),2) + quiet_cmd_force_checksrc = CHECK $< + cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; + else + quiet_cmd_checksrc = CHECK $< + cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; + endif +endif + +# Do section mismatch analysis for each module/built-in.o +ifdef CONFIG_DEBUG_SECTION_MISMATCH + cmd_secanalysis = ; scripts/mod/modpost $@ +endif + +# Compile C sources (.c) +# --------------------------------------------------------------------------- + +# Default is built-in, unless we know otherwise +modkern_cflags = \ + $(if $(part-of-module), \ + $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ + $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) +quiet_modtag := $(empty) $(empty) + +$(real-objs-m) : part-of-module := y +$(real-objs-m:.o=.i) : part-of-module := y +$(real-objs-m:.o=.s) : part-of-module := y +$(real-objs-m:.o=.lst): part-of-module := y + +$(real-objs-m) : quiet_modtag := [M] +$(real-objs-m:.o=.i) : quiet_modtag := [M] +$(real-objs-m:.o=.s) : quiet_modtag := [M] +$(real-objs-m:.o=.lst): quiet_modtag := [M] + +$(obj-m) : quiet_modtag := [M] + +# Default for not multi-part modules +modname = $(basetarget) + +$(multi-objs-m) : modname = $(modname-multi) +$(multi-objs-m:.o=.i) : modname = $(modname-multi) +$(multi-objs-m:.o=.s) : modname = $(modname-multi) +$(multi-objs-m:.o=.lst) : modname = $(modname-multi) +$(multi-objs-y) : modname = $(modname-multi) +$(multi-objs-y:.o=.i) : modname = $(modname-multi) +$(multi-objs-y:.o=.s) : modname = $(modname-multi) +$(multi-objs-y:.o=.lst) : modname = $(modname-multi) + +quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ +cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< + +$(obj)/%.s: $(src)/%.c FORCE + $(call if_changed_dep,cc_s_c) + +quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ +cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< + +$(obj)/%.i: $(src)/%.c FORCE + $(call if_changed_dep,cc_i_c) + +cmd_gensymtypes = \ + $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ + $(GENKSYMS) $(if $(1), -T $(2)) \ + $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ + $(if $(KBUILD_PRESERVE),-p) \ + -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + +quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ +cmd_cc_symtypes_c = \ + set -e; \ + $(call cmd_gensymtypes,true,$@) >/dev/null; \ + test -s $@ || rm -f $@ + +$(obj)/%.symtypes : $(src)/%.c FORCE + $(call cmd,cc_symtypes_c) + +# C (.c) files +# The C file is compiled and updated dependency information is generated. +# (See cmd_cc_o_c + relevant part of rule_cc_o_c) + +quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ + +ifndef CONFIG_MODVERSIONS +cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< + +else +# When module versioning is enabled the following steps are executed: +# o compile a .tmp_.o from .c +# o if .tmp_.o doesn't contain a __ksymtab version, i.e. does +# not export symbols, we just rename .tmp_.o to .o and +# are done. +# o otherwise, we calculate symbol versions using the good old +# genksyms on the preprocessed source and postprocess them in a way +# that they are usable as a linker script +# o generate .o from .tmp_.o using the linker to +# replace the unresolved symbols __crc_exported_symbol with +# the actual value of the checksum generated by genksyms + +cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< +cmd_modversions = \ + if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ + $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ + else \ + mv -f $(@D)/.tmp_$(@F) $@; \ + fi; +endif + +ifdef CONFIG_FTRACE_MCOUNT_RECORD +ifdef BUILD_C_RECORDMCOUNT +ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") + RECORDMCOUNT_FLAGS = -w +endif +# Due to recursion, we must skip empty.o. +# The empty.o file is created in the make process in order to determine +# the target endianness and word size. It is made before all other C +# files, including recordmcount. +sub_cmd_record_mcount = \ + if [ $(@) != "scripts/mod/empty.o" ]; then \ + $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ + fi; +recordmcount_source := $(srctree)/scripts/recordmcount.c \ + $(srctree)/scripts/recordmcount.h +else +sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ + "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ + "$(if $(CONFIG_64BIT),64,32)" \ + "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ + "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ + "$(if $(part-of-module),1,0)" "$(@)"; +recordmcount_source := $(srctree)/scripts/recordmcount.pl +endif +cmd_record_mcount = \ + if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ + "$(CC_FLAGS_FTRACE)" ]; then \ + $(sub_cmd_record_mcount) \ + fi; +endif + +define rule_cc_o_c + $(call echo-cmd,checksrc) $(cmd_checksrc) \ + $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ + $(cmd_modversions) \ + $(call echo-cmd,record_mcount) \ + $(cmd_record_mcount) \ + scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ + $(dot-target).tmp; \ + rm -f $(depfile); \ + mv -f $(dot-target).tmp $(dot-target).cmd +endef + +# Built-in and composite module parts +$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE + $(call cmd,force_checksrc) + $(call if_changed_rule,cc_o_c) + +# Single-part modules are special since we need to mark them in $(MODVERDIR) + +$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE + $(call cmd,force_checksrc) + $(call if_changed_rule,cc_o_c) + @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) + +quiet_cmd_cc_lst_c = MKLST $@ + cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ + $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ + System.map $(OBJDUMP) > $@ + +$(obj)/%.lst: $(src)/%.c FORCE + $(call if_changed_dep,cc_lst_c) + +# Compile assembler sources (.S) +# --------------------------------------------------------------------------- + +modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) + +$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) +$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) + +quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ +cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< + +$(obj)/%.s: $(src)/%.S FORCE + $(call if_changed_dep,as_s_S) + +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +$(obj)/%.o: $(src)/%.S FORCE + $(call if_changed_dep,as_o_S) + +targets += $(real-objs-y) $(real-objs-m) $(lib-y) +targets += $(extra-y) $(MAKECMDGOALS) $(always) + +# Linker scripts preprocessor (.lds.S -> .lds) +# --------------------------------------------------------------------------- +quiet_cmd_cpp_lds_S = LDS $@ + cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \ + -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< + +$(obj)/%.lds: $(src)/%.lds.S FORCE + $(call if_changed_dep,cpp_lds_S) + +# ASN.1 grammar +# --------------------------------------------------------------------------- +quiet_cmd_asn1_compiler = ASN.1 $@ + cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ + $(subst .h,.c,$@) $(subst .c,.h,$@) + +.PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h + +$(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler + $(call cmd,asn1_compiler) + +# Build the compiled-in targets +# --------------------------------------------------------------------------- + +# To build objects in subdirs, we need to descend into the directories +$(sort $(subdir-obj-y)): $(subdir-ym) ; + +# +# Rule to compile a set of .o files into one .o file +# +ifdef builtin-target +quiet_cmd_link_o_target = LD $@ +# If the list of objects to link is empty, just create an empty built-in.o +cmd_link_o_target = $(if $(strip $(obj-y)),\ + $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ + $(cmd_secanalysis),\ + rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) + +$(builtin-target): $(obj-y) FORCE + $(call if_changed,link_o_target) + +targets += $(builtin-target) +endif # builtin-target + +# +# Rule to create modules.order file +# +# Create commands to either record .ko file or cat modules.order from +# a subdirectory +modorder-cmds = \ + $(foreach m, $(modorder), \ + $(if $(filter %/modules.order, $m), \ + cat $m;, echo kernel/$m;)) + +$(modorder-target): $(subdir-ym) FORCE + $(Q)(cat /dev/null; $(modorder-cmds)) > $@ + +# +# Rule to compile a set of .o files into one .a file +# +ifdef lib-target +quiet_cmd_link_l_target = AR $@ +cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) + +$(lib-target): $(lib-y) FORCE + $(call if_changed,link_l_target) + +targets += $(lib-target) +endif + +# +# Rule to link composite objects +# +# Composite objects are specified in kbuild makefile as follows: +# -objs := +# or +# -y := +link_multi_deps = \ +$(filter $(addprefix $(obj)/, \ +$($(subst $(obj)/,,$(@:.o=-objs))) \ +$($(subst $(obj)/,,$(@:.o=-y)))), $^) + +quiet_cmd_link_multi-y = LD $@ +cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) + +quiet_cmd_link_multi-m = LD [M] $@ +cmd_link_multi-m = $(cmd_link_multi-y) + +$(multi-used-y): FORCE + $(call if_changed,link_multi-y) +$(call multi_depend, $(multi-used-y), .o, -objs -y) + +$(multi-used-m): FORCE + $(call if_changed,link_multi-m) + @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) +$(call multi_depend, $(multi-used-m), .o, -objs -y) + +targets += $(multi-used-y) $(multi-used-m) + + +# Descending +# --------------------------------------------------------------------------- + +PHONY += $(subdir-ym) +$(subdir-ym): + $(Q)$(MAKE) $(build)=$@ + +# Add FORCE to the prequisites of a target to force it to be always rebuilt. +# --------------------------------------------------------------------------- + +PHONY += FORCE + +FORCE: + +# Read all saved command lines and dependencies for the $(targets) we +# may be building above, using $(if_changed{,_dep}). As an +# optimization, we don't need to read them if the target does not +# exist, we will rebuild anyway in that case. + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + include $(cmd_files) +endif + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/linux/scripts/Makefile.clean b/linux/scripts/Makefile.clean new file mode 100644 index 00000000..55c96cb8 --- /dev/null +++ b/linux/scripts/Makefile.clean @@ -0,0 +1,91 @@ +# ========================================================================== +# Cleaning up +# ========================================================================== + +src := $(obj) + +PHONY := __clean +__clean: + +include scripts/Kbuild.include + +# The filename Kbuild has precedence over Makefile +kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) + +# Figure out what we need to build from the various variables +# ========================================================================== + +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +__subdir- := $(patsubst %/,%,$(filter %/, $(obj-))) +subdir- += $(__subdir-) + +# Subdirectories we need to descend into + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) +subdir-ymn := $(sort $(subdir-ym) $(subdir-)) + +# Add subdir path + +subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) + +# build a list of files to remove, usually relative to the current +# directory + +__clean-files := $(extra-y) $(extra-m) $(extra-) \ + $(always) $(targets) $(clean-files) \ + $(host-progs) \ + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) + +__clean-files := $(filter-out $(no-clean-files), $(__clean-files)) + +# clean-files is given relative to the current directory, unless it +# starts with $(objtree)/ (which means "./", so do not add "./" unless +# you want to delete a file from the toplevel object directory). + +__clean-files := $(wildcard \ + $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \ + $(filter $(objtree)/%, $(__clean-files))) + +# same as clean-files + +__clean-dirs := $(wildcard \ + $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \ + $(filter $(objtree)/%, $(clean-dirs))) + +# ========================================================================== + +quiet_cmd_clean = CLEAN $(obj) + cmd_clean = rm -f $(__clean-files) +quiet_cmd_cleandir = CLEAN $(__clean-dirs) + cmd_cleandir = rm -rf $(__clean-dirs) + + +__clean: $(subdir-ymn) +ifneq ($(strip $(__clean-files)),) + +$(call cmd,clean) +endif +ifneq ($(strip $(__clean-dirs)),) + +$(call cmd,cleandir) +endif + @: + + +# =========================================================================== +# Generic stuff +# =========================================================================== + +# Descending +# --------------------------------------------------------------------------- + +PHONY += $(subdir-ymn) +$(subdir-ymn): + $(Q)$(MAKE) $(clean)=$@ + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/linux/scripts/Makefile.dtbinst b/linux/scripts/Makefile.dtbinst new file mode 100644 index 00000000..1c15717e --- /dev/null +++ b/linux/scripts/Makefile.dtbinst @@ -0,0 +1,51 @@ +# ========================================================================== +# Installing dtb files +# +# Installs all dtb files listed in $(dtb-y) either in the +# INSTALL_DTBS_PATH directory or the default location: +# +# $INSTALL_PATH/dtbs/$KERNELRELEASE +# +# Traverse through subdirectories listed in $(dts-dirs). +# ========================================================================== + +src := $(obj) + +PHONY := __dtbs_install +__dtbs_install: + +export dtbinst-root ?= $(obj) + +include include/config/auto.conf +include scripts/Kbuild.include +include $(src)/Makefile + +PHONY += __dtbs_install_prep +__dtbs_install_prep: +ifeq ("$(dtbinst-root)", "$(obj)") + $(Q)if [ -d $(INSTALL_DTBS_PATH).old ]; then rm -rf $(INSTALL_DTBS_PATH).old; fi + $(Q)if [ -d $(INSTALL_DTBS_PATH) ]; then mv $(INSTALL_DTBS_PATH) $(INSTALL_DTBS_PATH).old; fi + $(Q)mkdir -p $(INSTALL_DTBS_PATH) +endif + +dtbinst-files := $(dtb-y) +dtbinst-dirs := $(dts-dirs) + +# Helper targets for Installing DTBs into the boot directory +quiet_cmd_dtb_install = INSTALL $< + cmd_dtb_install = mkdir -p $(2); cp $< $(2) + +install-dir = $(patsubst $(dtbinst-root)%,$(INSTALL_DTBS_PATH)%,$(obj)) + +$(dtbinst-files) $(dtbinst-dirs): | __dtbs_install_prep + +$(dtbinst-files): %.dtb: $(obj)/%.dtb + $(call cmd,dtb_install,$(install-dir)) + +$(dtbinst-dirs): + $(Q)$(MAKE) $(dtbinst)=$(obj)/$@ + +PHONY += $(dtbinst-files) $(dtbinst-dirs) +__dtbs_install: $(dtbinst-files) $(dtbinst-dirs) + +.PHONY: $(PHONY) diff --git a/linux/scripts/Makefile.extrawarn b/linux/scripts/Makefile.extrawarn new file mode 100644 index 00000000..f734033a --- /dev/null +++ b/linux/scripts/Makefile.extrawarn @@ -0,0 +1,68 @@ +# ========================================================================== +# +# make W=... settings +# +# W=1 - warnings that may be relevant and does not occur too often +# W=2 - warnings that occur quite often but may still be relevant +# W=3 - the more obscure warnings, can most likely be ignored +# +# $(call cc-option, -W...) handles gcc -W.. options which +# are not supported by all versions of the compiler +# ========================================================================== + +ifeq ("$(origin W)", "command line") + export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) +endif + +ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS +warning- := $(empty) + +warning-1 := -Wextra -Wunused -Wno-unused-parameter +warning-1 += -Wmissing-declarations +warning-1 += -Wmissing-format-attribute +warning-1 += $(call cc-option, -Wmissing-prototypes) +warning-1 += -Wold-style-definition +warning-1 += $(call cc-option, -Wmissing-include-dirs) +warning-1 += $(call cc-option, -Wunused-but-set-variable) +warning-1 += $(call cc-disable-warning, missing-field-initializers) + +warning-2 := -Waggregate-return +warning-2 += -Wcast-align +warning-2 += -Wdisabled-optimization +warning-2 += -Wnested-externs +warning-2 += -Wshadow +warning-2 += $(call cc-option, -Wlogical-op) +warning-2 += $(call cc-option, -Wmissing-field-initializers) + +warning-3 := -Wbad-function-cast +warning-3 += -Wcast-qual +warning-3 += -Wconversion +warning-3 += -Wpacked +warning-3 += -Wpadded +warning-3 += -Wpointer-arith +warning-3 += -Wredundant-decls +warning-3 += -Wswitch-default +warning-3 += $(call cc-option, -Wpacked-bitfield-compat) +warning-3 += $(call cc-option, -Wvla) + +warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) +warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) +warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) + +ifeq ("$(strip $(warning))","") + $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown) +endif + +KBUILD_CFLAGS += $(warning) +else + +ifeq ($(COMPILER),clang) +KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-value) +KBUILD_CFLAGS += $(call cc-disable-warning, format) +KBUILD_CFLAGS += $(call cc-disable-warning, unknown-warning-option) +KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare) +KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length) +KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized) +endif +endif diff --git a/linux/scripts/Makefile.fwinst b/linux/scripts/Makefile.fwinst new file mode 100644 index 00000000..b2729003 --- /dev/null +++ b/linux/scripts/Makefile.fwinst @@ -0,0 +1,70 @@ +# ========================================================================== +# Installing firmware +# +# We don't include the .config, so all firmware files are in $(fw-shipped-) +# rather than in $(fw-shipped-y) or $(fw-shipped-m). +# ========================================================================== + +INSTALL := install +src := $(obj) + +# For modules_install installing firmware, we want to see .config +# But for firmware_install, we don't care, but don't want to require it. +-include $(objtree)/.config + +include scripts/Kbuild.include +include $(src)/Makefile + +include scripts/Makefile.host + +mod-fw := $(fw-shipped-m) +# If CONFIG_FIRMWARE_IN_KERNEL isn't set, then install the +# firmware for in-kernel drivers too. +ifndef CONFIG_FIRMWARE_IN_KERNEL +mod-fw += $(fw-shipped-y) +endif + +ifneq ($(KBUILD_SRC),) +# Create output directory if not already present +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) + +firmware-dirs := $(sort $(addprefix $(objtree)/$(obj)/,$(dir $(fw-external-y) $(fw-shipped-all)))) +# Create directories for firmware in subdirectories +_dummy := $(foreach d,$(firmware-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) +endif + +installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) + +installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) + +quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) + cmd_install = mkdir -p $(@D); $(INSTALL) -m0644 $< $@ + +$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% + $(call cmd,install) + +PHONY += __fw_install __fw_modinst FORCE + +.PHONY: $(PHONY) + +__fw_install: $(installed-fw) + +__fw_modinst: $(installed-mod-fw) + @: + +__fw_modbuild: $(addprefix $(obj)/,$(mod-fw)) + @: + +FORCE: + +# Read all saved command lines and dependencies for the $(targets) we +# may be building using $(if_changed{,_dep}). As an optimization, we +# don't need to read them if the target does not exist; we will rebuild +# anyway in that case. + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + include $(cmd_files) +endif diff --git a/linux/scripts/Makefile.headersinst b/linux/scripts/Makefile.headersinst new file mode 100644 index 00000000..1106d6ca --- /dev/null +++ b/linux/scripts/Makefile.headersinst @@ -0,0 +1,139 @@ +# ========================================================================== +# Installing headers +# +# header-y - list files to be installed. They are preprocessed +# to remove __KERNEL__ section of the file +# genhdr-y - Same as header-y but in a generated/ directory +# +# ========================================================================== + +# generated header directory +gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) + +kbuild-file := $(srctree)/$(obj)/Kbuild +include $(kbuild-file) + +# called may set destination dir (when installing to asm/) +_dst := $(if $(destination-y),$(destination-y),$(if $(dst),$(dst),$(obj))) + +old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild +ifneq ($(wildcard $(old-kbuild-file)),) +include $(old-kbuild-file) +endif + +include scripts/Kbuild.include + +installdir := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst)) + +header-y := $(sort $(header-y)) +subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) +header-y := $(filter-out %/, $(header-y)) + +# files used to track state of install/check +install-file := $(installdir)/.install +check-file := $(installdir)/.check + +# generic-y list all files an architecture uses from asm-generic +# Use this to build a list of headers which require a wrapper +wrapper-files := $(filter $(header-y), $(generic-y)) + +srcdir := $(srctree)/$(obj) +gendir := $(objtree)/$(gen) + +oldsrcdir := $(srctree)/$(subst /uapi,,$(obj)) + +# all headers files for this dir +header-y := $(filter-out $(generic-y), $(header-y)) +all-files := $(header-y) $(genhdr-y) $(wrapper-files) +output-files := $(addprefix $(installdir)/, $(all-files)) + +input-files1 := $(foreach hdr, $(header-y), \ + $(if $(wildcard $(srcdir)/$(hdr)), \ + $(wildcard $(srcdir)/$(hdr))) \ + ) +input-files1-name := $(notdir $(input-files1)) +input-files2 := $(foreach hdr, $(header-y), \ + $(if $(wildcard $(srcdir)/$(hdr)),, \ + $(if $(wildcard $(oldsrcdir)/$(hdr)), \ + $(wildcard $(oldsrcdir)/$(hdr)), \ + $(error Missing UAPI file $(srcdir)/$(hdr))) \ + )) +input-files2-name := $(notdir $(input-files2)) +input-files3 := $(foreach hdr, $(genhdr-y), \ + $(if $(wildcard $(gendir)/$(hdr)), \ + $(wildcard $(gendir)/$(hdr)), \ + $(error Missing generated UAPI file $(gendir)/$(hdr)) \ + )) +input-files3-name := $(notdir $(input-files3)) + +# Work out what needs to be removed +oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) +unwanted := $(filter-out $(all-files),$(oldheaders)) + +# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) +unwanted-file := $(addprefix $(installdir)/, $(unwanted)) + +printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) + +quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ + file$(if $(word 2, $(all-files)),s)) + cmd_install = \ + $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(input-files1-name); \ + $(CONFIG_SHELL) $< $(installdir) $(oldsrcdir) $(input-files2-name); \ + $(CONFIG_SHELL) $< $(installdir) $(gendir) $(input-files3-name); \ + for F in $(wrapper-files); do \ + echo "\#include " > $(installdir)/$$F; \ + done; \ + touch $@ + +quiet_cmd_remove = REMOVE $(unwanted) + cmd_remove = rm -f $(unwanted-file) + +quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) +# Headers list can be pretty long, xargs helps to avoid +# the "Argument list too long" error. + cmd_check = for f in $(all-files); do \ + echo "$(installdir)/$${f}"; done \ + | xargs \ + $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ + touch $@ + +PHONY += __headersinst __headerscheck + +ifndef HDRCHECK +# Rules for installing headers +__headersinst: $(subdirs) $(install-file) + @: + +targets += $(install-file) +$(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE + $(if $(unwanted),$(call cmd,remove),) + $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) + $(call if_changed,install) + +else +__headerscheck: $(subdirs) $(check-file) + @: + +targets += $(check-file) +$(check-file): scripts/headers_check.pl $(output-files) FORCE + $(call if_changed,check) + +endif + +# Recursion +.PHONY: $(subdirs) +$(subdirs): + $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard \ + $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + include $(cmd_files) +endif + +.PHONY: $(PHONY) +PHONY += FORCE +FORCE: ; diff --git a/linux/scripts/Makefile.help b/linux/scripts/Makefile.help new file mode 100644 index 00000000..d03608f5 --- /dev/null +++ b/linux/scripts/Makefile.help @@ -0,0 +1,3 @@ + +checker-help: + @echo ' coccicheck - Check with Coccinelle.' diff --git a/linux/scripts/Makefile.host b/linux/scripts/Makefile.host new file mode 100644 index 00000000..133edfae --- /dev/null +++ b/linux/scripts/Makefile.host @@ -0,0 +1,128 @@ +# ========================================================================== +# Building binaries on the host system +# Binaries are used during the compilation of the kernel, for example +# to preprocess a data file. +# +# Both C and C++ are supported, but preferred language is C for such utilities. +# +# Sample syntax (see Documentation/kbuild/makefiles.txt for reference) +# hostprogs-y := bin2hex +# Will compile bin2hex.c and create an executable named bin2hex +# +# hostprogs-y := lxdialog +# lxdialog-objs := checklist.o lxdialog.o +# Will compile lxdialog.c and checklist.c, and then link the executable +# lxdialog, based on checklist.o and lxdialog.o +# +# hostprogs-y := qconf +# qconf-cxxobjs := qconf.o +# qconf-objs := menu.o +# Will compile qconf as a C++ program, and menu as a C program. +# They are linked as C++ code to the executable qconf + +__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) + +# C code +# Executables compiled from a single .c file +host-csingle := $(foreach m,$(__hostprogs), \ + $(if $($(m)-objs)$($(m)-cxxobjs),,$(m))) + +# C executables linked based on several .o files +host-cmulti := $(foreach m,$(__hostprogs),\ + $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) + +# Object (.o) files compiled from .c files +host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) + +# C++ code +# C++ executables compiled from at least one .cc file +# and zero or more .c files +host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) + +# C++ Object (.o) files compiled from .cc files +host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) + +# output directory for programs/.o files +# hostprogs-y := tools/build may have been specified. +# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation +host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs)) + +host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) + + +__hostprogs := $(addprefix $(obj)/,$(__hostprogs)) +host-csingle := $(addprefix $(obj)/,$(host-csingle)) +host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) +host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) +host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) +host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) +host-objdirs := $(addprefix $(obj)/,$(host-objdirs)) + +obj-dirs += $(host-objdirs) + +##### +# Handle options to gcc. Support building with separate output directory + +_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ + $(HOSTCFLAGS_$(basetarget).o) +_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ + $(HOSTCXXFLAGS_$(basetarget).o) + +ifeq ($(KBUILD_SRC),) +__hostc_flags = $(_hostc_flags) +__hostcxx_flags = $(_hostcxx_flags) +else +__hostc_flags = -I$(obj) $(call flags,_hostc_flags) +__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) +endif + +hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) +hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) + +##### +# Compile programs on the host + +# Create executable from a single .c file +# host-csingle -> Executable +quiet_cmd_host-csingle = HOSTCC $@ + cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) +$(host-csingle): $(obj)/%: $(src)/%.c FORCE + $(call if_changed_dep,host-csingle) + +# Link an executable based on list of .o files, all plain c +# host-cmulti -> executable +quiet_cmd_host-cmulti = HOSTLD $@ + cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ + $(addprefix $(obj)/,$($(@F)-objs)) \ + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) +$(host-cmulti): FORCE + $(call if_changed,host-cmulti) +$(call multi_depend, $(host-cmulti), , -objs) + +# Create .o file from a single .c file +# host-cobjs -> .o +quiet_cmd_host-cobjs = HOSTCC $@ + cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< +$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE + $(call if_changed_dep,host-cobjs) + +# Link an executable based on list of .o files, a mixture of .c and .cc +# host-cxxmulti -> executable +quiet_cmd_host-cxxmulti = HOSTLD $@ + cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \ + $(foreach o,objs cxxobjs,\ + $(addprefix $(obj)/,$($(@F)-$(o)))) \ + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) +$(host-cxxmulti): FORCE + $(call if_changed,host-cxxmulti) +$(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs) + +# Create .o file from a single .cc (C++) file +quiet_cmd_host-cxxobjs = HOSTCXX $@ + cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< +$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE + $(call if_changed_dep,host-cxxobjs) + +targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ + $(host-cxxmulti) $(host-cxxobjs) diff --git a/linux/scripts/Makefile.kasan b/linux/scripts/Makefile.kasan new file mode 100644 index 00000000..3f874d24 --- /dev/null +++ b/linux/scripts/Makefile.kasan @@ -0,0 +1,29 @@ +ifdef CONFIG_KASAN +ifdef CONFIG_KASAN_INLINE + call_threshold := 10000 +else + call_threshold := 0 +endif + +CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address + +CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \ + -fasan-shadow-offset=$(CONFIG_KASAN_SHADOW_OFFSET) \ + --param asan-stack=1 --param asan-globals=1 \ + --param asan-instrumentation-with-call-threshold=$(call_threshold)) + +ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),) + ifneq ($(CONFIG_COMPILE_TEST),y) + $(warning Cannot use CONFIG_KASAN: \ + -fsanitize=kernel-address is not supported by compiler) + endif +else + ifeq ($(CFLAGS_KASAN),) + ifneq ($(CONFIG_COMPILE_TEST),y) + $(warning CONFIG_KASAN: compiler does not support all options.\ + Trying minimal configuration) + endif + CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) + endif +endif +endif diff --git a/linux/scripts/Makefile.lib b/linux/scripts/Makefile.lib new file mode 100644 index 00000000..79e86613 --- /dev/null +++ b/linux/scripts/Makefile.lib @@ -0,0 +1,390 @@ +# Backward compatibility +asflags-y += $(EXTRA_AFLAGS) +ccflags-y += $(EXTRA_CFLAGS) +cppflags-y += $(EXTRA_CPPFLAGS) +ldflags-y += $(EXTRA_LDFLAGS) + +# +# flags that take effect in sub directories +export KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y) +export KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y) + +# Figure out what we need to build from the various variables +# =========================================================================== + +# When an object is listed to be built compiled-in and modular, +# only build the compiled-in version + +obj-m := $(filter-out $(obj-y),$(obj-m)) + +# Libraries are always collected in one lib file. +# Filter out objects already built-in + +lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) + + +# Handle objects in subdirs +# --------------------------------------------------------------------------- +# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o +# and add the directory to the list of dirs to descend into: $(subdir-y) +# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) +# and add the directory to the list of dirs to descend into: $(subdir-m) + +# Determine modorder. +# Unfortunately, we don't have information about ordering between -y +# and -m subdirs. Just put -y's first. +modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) + +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) +obj-m := $(filter-out %/, $(obj-m)) + +# Subdirectories we need to descend into + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) + +# if $(foo-objs) exists, foo.o is a composite object +multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) +multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) +multi-used := $(multi-used-y) $(multi-used-m) +single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) + +# Build list of the parts of our composite objects, our composite +# objects depend on those (obviously) +multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) +multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) +multi-objs := $(multi-objs-y) $(multi-objs-m) + +# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to +# tell kbuild to descend +subdir-obj-y := $(filter %/built-in.o, $(obj-y)) + +# $(obj-dirs) is a list of directories that contain object files +obj-dirs := $(dir $(multi-objs) $(obj-y)) + +# Replace multi-part objects by their individual parts, look at local dir only +real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) +real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) + +# Add subdir path + +extra-y := $(addprefix $(obj)/,$(extra-y)) +always := $(addprefix $(obj)/,$(always)) +targets := $(addprefix $(obj)/,$(targets)) +modorder := $(addprefix $(obj)/,$(modorder)) +obj-y := $(addprefix $(obj)/,$(obj-y)) +obj-m := $(addprefix $(obj)/,$(obj-m)) +lib-y := $(addprefix $(obj)/,$(lib-y)) +subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) +real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) +real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) +single-used-m := $(addprefix $(obj)/,$(single-used-m)) +multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) +multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) +multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) +multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) +subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) +obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) + +# These flags are needed for modversions and compiling, so we define them here +# already +# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will +# end up in (or would, if it gets compiled in) +# Note: Files that end up in two or more modules are compiled without the +# KBUILD_MODNAME definition. The reason is that any made-up name would +# differ in different configs. +name-fix = $(subst $(comma),_,$(subst -,_,$1)) +basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +modname_flags = $(if $(filter 1,$(words $(modname))),\ + -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") + +orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ + $(ccflags-y) $(CFLAGS_$(basetarget).o) +_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) +_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ + $(asflags-y) $(AFLAGS_$(basetarget).o) +_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) + +# +# Enable gcov profiling flags for a file, directory or for all files depending +# on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL +# (in this order) +# +ifeq ($(CONFIG_GCOV_KERNEL),y) +_c_flags += $(if $(patsubst n%,, \ + $(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \ + $(CFLAGS_GCOV)) +endif + +# +# Enable address sanitizer flags for kernel except some files or directories +# we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE) +# +ifeq ($(CONFIG_KASAN),y) +_c_flags += $(if $(patsubst n%,, \ + $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ + $(CFLAGS_KASAN)) +endif + +# If building the kernel in a separate objtree expand all occurrences +# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). + +ifeq ($(KBUILD_SRC),) +__c_flags = $(_c_flags) +__a_flags = $(_a_flags) +__cpp_flags = $(_cpp_flags) +else + +# -I$(obj) locates generated .h files +# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files +# and locates generated .h files +# FIXME: Replace both with specific CFLAGS* statements in the makefiles +__c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags) +__a_flags = $(call flags,_a_flags) +__cpp_flags = $(call flags,_cpp_flags) +endif + +c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ + $(__c_flags) $(modkern_cflags) \ + -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + +a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ + $(__a_flags) $(modkern_aflags) + +cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ + $(__cpp_flags) + +ld_flags = $(LDFLAGS) $(ldflags-y) + +dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ + -I$(srctree)/arch/$(SRCARCH)/boot/dts \ + -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ + -I$(srctree)/drivers/of/testcase-data \ + -undef -D__DTS__ + +# Finds the multi-part object the current object will be linked into +modname-multi = $(sort $(foreach m,$(multi-used),\ + $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) + +# Useful for describing the dependency of composite objects +# Usage: +# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add) +define multi_depend +$(foreach m, $(notdir $1), \ + $(eval $(obj)/$m: \ + $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) +endef + +ifdef REGENERATE_PARSERS + +# GPERF +# --------------------------------------------------------------------------- +quiet_cmd_gperf = GPERF $@ + cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< + +.PRECIOUS: $(src)/%.hash.c_shipped +$(src)/%.hash.c_shipped: $(src)/%.gperf + $(call cmd,gperf) + +# LEX +# --------------------------------------------------------------------------- +LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy) + +quiet_cmd_flex = LEX $@ + cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $< + +.PRECIOUS: $(src)/%.lex.c_shipped +$(src)/%.lex.c_shipped: $(src)/%.l + $(call cmd,flex) + +# YACC +# --------------------------------------------------------------------------- +YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) + +quiet_cmd_bison = YACC $@ + cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $< + +.PRECIOUS: $(src)/%.tab.c_shipped +$(src)/%.tab.c_shipped: $(src)/%.y + $(call cmd,bison) + +quiet_cmd_bison_h = YACC $@ + cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< + +.PRECIOUS: $(src)/%.tab.h_shipped +$(src)/%.tab.h_shipped: $(src)/%.y + $(call cmd,bison_h) + +endif + +# Shipped files +# =========================================================================== + +quiet_cmd_shipped = SHIPPED $@ +cmd_shipped = cat $< > $@ + +$(obj)/%: $(src)/%_shipped + $(call cmd,shipped) + +# Commands useful for building a boot image +# =========================================================================== +# +# Use as following: +# +# target: source(s) FORCE +# $(if_changed,ld/objcopy/gzip) +# +# and add target to extra-y so that we know we have to +# read in the saved command line + +# Linking +# --------------------------------------------------------------------------- + +quiet_cmd_ld = LD $@ +cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \ + $(filter-out FORCE,$^) -o $@ + +# Objcopy +# --------------------------------------------------------------------------- + +quiet_cmd_objcopy = OBJCOPY $@ +cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ + +# Gzip +# --------------------------------------------------------------------------- + +quiet_cmd_gzip = GZIP $@ +cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \ + (rm -f $@ ; false) + +# DTC +# --------------------------------------------------------------------------- + +# Generate an assembly file to wrap the output of the device tree compiler +quiet_cmd_dt_S_dtb= DTB $@ +cmd_dt_S_dtb= \ +( \ + echo '\#include '; \ + echo '.section .dtb.init.rodata,"a"'; \ + echo '.balign STRUCT_ALIGNMENT'; \ + echo '.global __dtb_$(*F)_begin'; \ + echo '__dtb_$(*F)_begin:'; \ + echo '.incbin "$<" '; \ + echo '__dtb_$(*F)_end:'; \ + echo '.global __dtb_$(*F)_end'; \ + echo '.balign STRUCT_ALIGNMENT'; \ +) > $@ + +$(obj)/%.dtb.S: $(obj)/%.dtb + $(call cmd,dt_S_dtb) + +quiet_cmd_dtc = DTC $@ +cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ + $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ + $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ + -i $(dir $<) $(DTC_FLAGS) \ + -d $(depfile).dtc.tmp $(dtc-tmp) ; \ + cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) + +$(obj)/%.dtb: $(src)/%.dts FORCE + $(call if_changed_dep,dtc) + +dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) + +# Bzip2 +# --------------------------------------------------------------------------- + +# Bzip2 and LZMA do not include size in file... so we have to fake that; +# append the size as a 32-bit littleendian number as gzip does. +size_append = printf $(shell \ +dec_size=0; \ +for F in $1; do \ + fsize=$$(stat -c "%s" $$F); \ + dec_size=$$(expr $$dec_size + $$fsize); \ +done; \ +printf "%08x\n" $$dec_size | \ + sed 's/\(..\)/\1 /g' | { \ + read ch0 ch1 ch2 ch3; \ + for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \ + printf '%s%03o' '\\' $$((0x$$ch)); \ + done; \ + } \ +) + +quiet_cmd_bzip2 = BZIP2 $@ +cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ + bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ + (rm -f $@ ; false) + +# Lzma +# --------------------------------------------------------------------------- + +quiet_cmd_lzma = LZMA $@ +cmd_lzma = (cat $(filter-out FORCE,$^) | \ + lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ + (rm -f $@ ; false) + +quiet_cmd_lzo = LZO $@ +cmd_lzo = (cat $(filter-out FORCE,$^) | \ + lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ + (rm -f $@ ; false) + +quiet_cmd_lz4 = LZ4 $@ +cmd_lz4 = (cat $(filter-out FORCE,$^) | \ + lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ + (rm -f $@ ; false) + +# U-Boot mkimage +# --------------------------------------------------------------------------- + +MKIMAGE := $(srctree)/scripts/mkuboot.sh + +# SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces +# the number of overrides in arch makefiles +UIMAGE_ARCH ?= $(SRCARCH) +UIMAGE_COMPRESSION ?= $(if $(2),$(2),none) +UIMAGE_OPTS-y ?= +UIMAGE_TYPE ?= kernel +UIMAGE_LOADADDR ?= arch_must_set_this +UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) +UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)' +UIMAGE_IN ?= $< +UIMAGE_OUT ?= $@ + +quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT) + cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ + -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ + -T $(UIMAGE_TYPE) \ + -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ + -n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT) + +# XZ +# --------------------------------------------------------------------------- +# Use xzkern to compress the kernel image and xzmisc to compress other things. +# +# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage +# of the kernel decompressor. A BCJ filter is used if it is available for +# the target architecture. xzkern also appends uncompressed size of the data +# using size_append. The .xz format has the size information available at +# the end of the file too, but it's in more complex format and it's good to +# avoid changing the part of the boot code that reads the uncompressed size. +# Note that the bytes added by size_append will make the xz tool think that +# the file is corrupt. This is expected. +# +# xzmisc doesn't use size_append, so it can be used to create normal .xz +# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very +# big dictionary would increase the memory usage too much in the multi-call +# decompression mode. A BCJ filter isn't used either. +quiet_cmd_xzkern = XZKERN $@ +cmd_xzkern = (cat $(filter-out FORCE,$^) | \ + sh $(srctree)/scripts/xz_wrap.sh && \ + $(call size_append, $(filter-out FORCE,$^))) > $@ || \ + (rm -f $@ ; false) + +quiet_cmd_xzmisc = XZMISC $@ +cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ + xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ + (rm -f $@ ; false) diff --git a/linux/scripts/Makefile.modbuiltin b/linux/scripts/Makefile.modbuiltin new file mode 100644 index 00000000..1adb974e --- /dev/null +++ b/linux/scripts/Makefile.modbuiltin @@ -0,0 +1,60 @@ +# ========================================================================== +# Generating modules.builtin +# ========================================================================== + +src := $(obj) + +PHONY := __modbuiltin +__modbuiltin: + +-include include/config/auto.conf +# tristate.conf sets tristate variables to uppercase 'Y' or 'M' +# That way, we get the list of built-in modules in obj-Y +-include include/config/tristate.conf + +include scripts/Kbuild.include + +ifneq ($(KBUILD_SRC),) +# Create output directory if not already present +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) +endif + +# The filename Kbuild has precedence over Makefile +kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) +include $(kbuild-file) + +include scripts/Makefile.lib +__subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y))) +subdir-Y += $(__subdir-Y) +subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m)) +subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) +obj-Y := $(addprefix $(obj)/,$(obj-Y)) + +modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym)) +modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko)) +modbuiltin-target := $(obj)/modules.builtin + +__modbuiltin: $(modbuiltin-target) $(subdir-ym) + @: + +$(modbuiltin-target): $(subdir-ym) FORCE + $(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done; \ + cat /dev/null $(modbuiltin-subdirs)) > $@ + +PHONY += FORCE + +FORCE: + +# Descending +# --------------------------------------------------------------------------- + +PHONY += $(subdir-ym) +$(subdir-ym): + $(Q)$(MAKE) $(modbuiltin)=$@ + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/linux/scripts/Makefile.modinst b/linux/scripts/Makefile.modinst new file mode 100644 index 00000000..e48a4e9d --- /dev/null +++ b/linux/scripts/Makefile.modinst @@ -0,0 +1,41 @@ +# ========================================================================== +# Installing modules +# ========================================================================== + +PHONY := __modinst +__modinst: + +include scripts/Kbuild.include + +# + +__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) +modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) + +PHONY += $(modules) +__modinst: $(modules) + @: + +# Don't stop modules_install if we can't sign external modules. +quiet_cmd_modules_install = INSTALL $@ + cmd_modules_install = \ + mkdir -p $(2) ; \ + cp $@ $(2) ; \ + $(mod_strip_cmd) $(2)/$(notdir $@) ; \ + $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \ + $(mod_compress_cmd) $(2)/$(notdir $@) + +# Modules built outside the kernel source tree go into extra by default +INSTALL_MOD_DIR ?= extra +ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) + +modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) + +$(modules): + $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable so we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/linux/scripts/Makefile.modpost b/linux/scripts/Makefile.modpost new file mode 100644 index 00000000..69f0a141 --- /dev/null +++ b/linux/scripts/Makefile.modpost @@ -0,0 +1,152 @@ +# =========================================================================== +# Module versions +# =========================================================================== +# +# Stage one of module building created the following: +# a) The individual .o files used for the module +# b) A .o file which is the .o files above linked together +# c) A .mod file in $(MODVERDIR)/, listing the name of the +# the preliminary .o file, plus all .o files + +# Stage 2 is handled by this file and does the following +# 1) Find all modules from the files listed in $(MODVERDIR)/ +# 2) modpost is then used to +# 3) create one .mod.c file pr. module +# 4) create one Module.symvers file with CRC for all exported symbols +# 5) compile all .mod.c files +# 6) final link of the module to a file + +# Step 3 is used to place certain information in the module's ELF +# section, including information such as: +# Version magic (see include/linux/vermagic.h for full details) +# - Kernel release +# - SMP is CONFIG_SMP +# - PREEMPT is CONFIG_PREEMPT +# - GCC Version +# Module info +# - Module version (MODULE_VERSION) +# - Module alias'es (MODULE_ALIAS) +# - Module license (MODULE_LICENSE) +# - See include/linux/module.h for more details + +# Step 4 is solely used to allow module versioning in external modules, +# where the CRC of each module is retrieved from the Module.symvers file. + +# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined +# symbols in the final module linking stage +# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. +# This is solely useful to speed up test compiles +PHONY := _modpost +_modpost: __modpost + +include include/config/auto.conf +include scripts/Kbuild.include + +# When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info +ifneq ($(KBUILD_EXTMOD),) + +# set src + obj - they may be used when building the .mod.c file +obj := $(KBUILD_EXTMOD) +src := $(obj) + +# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS +include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ + $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) +endif + +include scripts/Makefile.lib + +kernelsymfile := $(objtree)/Module.symvers +modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers + +# Step 1), find all modules listed in $(MODVERDIR)/ +MODLISTCMD := find $(MODVERDIR) -name '*.mod' | xargs -r grep -h '\.ko$$' | sort -u +__modules := $(shell $(MODLISTCMD)) +modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) + +# Stop after building .o files if NOFINAL is set. Makes compile tests quicker +_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) + +# Step 2), invoke modpost +# Includes step 3,4 +modpost = scripts/mod/modpost \ + $(if $(CONFIG_MODVERSIONS),-m) \ + $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ + $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ + $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ + $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ + $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) + +MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS))) + +# We can go over command line length here, so be careful. +quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules + cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) $(MODPOST_OPT) -s -T - + +PHONY += __modpost +__modpost: $(modules:.ko=.o) FORCE + $(call cmd,modpost) $(wildcard vmlinux) + +quiet_cmd_kernel-mod = MODPOST $@ + cmd_kernel-mod = $(modpost) $@ + +vmlinux.o: FORCE + $(call cmd,kernel-mod) + +# Declare generated files as targets for modpost +$(symverfile): __modpost ; +$(modules:.ko=.mod.c): __modpost ; + + +# Step 5), compile all *.mod.c files + +# modname is set to make c_flags define KBUILD_MODNAME +modname = $(notdir $(@:.mod.o=)) + +quiet_cmd_cc_o_c = CC $@ + cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \ + -c -o $@ $< + +$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE + $(call if_changed_dep,cc_o_c) + +targets += $(modules:.ko=.mod.o) + +# Step 6), final link of the modules +quiet_cmd_ld_ko_o = LD [M] $@ + cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ + $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ + -o $@ $(filter-out FORCE,$^) + +$(modules): %.ko :%.o %.mod.o FORCE + $(call if_changed,ld_ko_o) + +targets += $(modules) + + +# Add FORCE to the prequisites of a target to force it to be always rebuilt. +# --------------------------------------------------------------------------- + +PHONY += FORCE + +FORCE: + +# Read all saved command lines and dependencies for the $(targets) we +# may be building above, using $(if_changed{,_dep}). As an +# optimization, we don't need to read them if the target does not +# exist, we will rebuild anyway in that case. + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + include $(cmd_files) +endif + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/linux/scripts/Makefile.modsign b/linux/scripts/Makefile.modsign new file mode 100644 index 00000000..b6ac7084 --- /dev/null +++ b/linux/scripts/Makefile.modsign @@ -0,0 +1,32 @@ +# ========================================================================== +# Signing modules +# ========================================================================== + +PHONY := __modsign +__modsign: + +include scripts/Kbuild.include + +__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) +modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) + +PHONY += $(modules) +__modsign: $(modules) + @: + +quiet_cmd_sign_ko = SIGN [M] $(2)/$(notdir $@) + cmd_sign_ko = $(mod_sign_cmd) $(2)/$(notdir $@) + +# Modules built outside the kernel source tree go into extra by default +INSTALL_MOD_DIR ?= extra +ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) + +modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) + +$(modules): + $(call cmd,sign_ko,$(MODLIB)/$(modinst_dir)) + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/linux/scripts/analyze_suspend.py b/linux/scripts/analyze_suspend.py new file mode 100755 index 00000000..93e1fd40 --- /dev/null +++ b/linux/scripts/analyze_suspend.py @@ -0,0 +1,3591 @@ +#!/usr/bin/python +# +# Tool for analyzing suspend/resume timing +# Copyright (c) 2013, Intel Corporation. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms and conditions of the GNU General Public License, +# version 2, as published by the Free Software Foundation. +# +# This program is distributed in the hope it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +# +# Authors: +# Todd Brandt +# +# Description: +# This tool is designed to assist kernel and OS developers in optimizing +# their linux stack's suspend/resume time. Using a kernel image built +# with a few extra options enabled, the tool will execute a suspend and +# will capture dmesg and ftrace data until resume is complete. This data +# is transformed into a device timeline and a callgraph to give a quick +# and detailed view of which devices and callbacks are taking the most +# time in suspend/resume. The output is a single html file which can be +# viewed in firefox or chrome. +# +# The following kernel build options are required: +# CONFIG_PM_DEBUG=y +# CONFIG_PM_SLEEP_DEBUG=y +# CONFIG_FTRACE=y +# CONFIG_FUNCTION_TRACER=y +# CONFIG_FUNCTION_GRAPH_TRACER=y +# +# For kernel versions older than 3.15: +# The following additional kernel parameters are required: +# (e.g. in file /etc/default/grub) +# GRUB_CMDLINE_LINUX_DEFAULT="... initcall_debug log_buf_len=16M ..." +# + +# ----------------- LIBRARIES -------------------- + +import sys +import time +import os +import string +import re +import platform +from datetime import datetime +import struct + +# ----------------- CLASSES -------------------- + +# Class: SystemValues +# Description: +# A global, single-instance container used to +# store system values and test parameters +class SystemValues: + version = 3.0 + verbose = False + testdir = '.' + tpath = '/sys/kernel/debug/tracing/' + fpdtpath = '/sys/firmware/acpi/tables/FPDT' + epath = '/sys/kernel/debug/tracing/events/power/' + traceevents = [ + 'suspend_resume', + 'device_pm_callback_end', + 'device_pm_callback_start' + ] + modename = { + 'freeze': 'Suspend-To-Idle (S0)', + 'standby': 'Power-On Suspend (S1)', + 'mem': 'Suspend-to-RAM (S3)', + 'disk': 'Suspend-to-disk (S4)' + } + mempath = '/dev/mem' + powerfile = '/sys/power/state' + suspendmode = 'mem' + hostname = 'localhost' + prefix = 'test' + teststamp = '' + dmesgfile = '' + ftracefile = '' + htmlfile = '' + rtcwake = False + rtcwaketime = 10 + rtcpath = '' + android = False + adb = 'adb' + devicefilter = [] + stamp = 0 + execcount = 1 + x2delay = 0 + usecallgraph = False + usetraceevents = False + usetraceeventsonly = False + notestrun = False + altdevname = dict() + postresumetime = 0 + tracertypefmt = '# tracer: (?P.*)' + firmwarefmt = '# fwsuspend (?P[0-9]*) fwresume (?P[0-9]*)$' + postresumefmt = '# post resume time (?P[0-9]*)$' + stampfmt = '# suspend-(?P[0-9]{2})(?P[0-9]{2})(?P[0-9]{2})-'+\ + '(?P[0-9]{2})(?P[0-9]{2})(?P[0-9]{2})'+\ + ' (?P.*) (?P.*) (?P.*)$' + def __init__(self): + self.hostname = platform.node() + if(self.hostname == ''): + self.hostname = 'localhost' + rtc = "rtc0" + if os.path.exists('/dev/rtc'): + rtc = os.readlink('/dev/rtc') + rtc = '/sys/class/rtc/'+rtc + if os.path.exists(rtc) and os.path.exists(rtc+'/date') and \ + os.path.exists(rtc+'/time') and os.path.exists(rtc+'/wakealarm'): + self.rtcpath = rtc + def setOutputFile(self): + if((self.htmlfile == '') and (self.dmesgfile != '')): + m = re.match('(?P.*)_dmesg\.txt$', self.dmesgfile) + if(m): + self.htmlfile = m.group('name')+'.html' + if((self.htmlfile == '') and (self.ftracefile != '')): + m = re.match('(?P.*)_ftrace\.txt$', self.ftracefile) + if(m): + self.htmlfile = m.group('name')+'.html' + if(self.htmlfile == ''): + self.htmlfile = 'output.html' + def initTestOutput(self, subdir): + if(not self.android): + self.prefix = self.hostname + v = open('/proc/version', 'r').read().strip() + kver = string.split(v)[2] + else: + self.prefix = 'android' + v = os.popen(self.adb+' shell cat /proc/version').read().strip() + kver = string.split(v)[2] + testtime = datetime.now().strftime('suspend-%m%d%y-%H%M%S') + if(subdir != "."): + self.testdir = subdir+"/"+testtime + else: + self.testdir = testtime + self.teststamp = \ + '# '+testtime+' '+self.prefix+' '+self.suspendmode+' '+kver + self.dmesgfile = \ + self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_dmesg.txt' + self.ftracefile = \ + self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_ftrace.txt' + self.htmlfile = \ + self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html' + os.mkdir(self.testdir) + def setDeviceFilter(self, devnames): + self.devicefilter = string.split(devnames) + def rtcWakeAlarm(self): + os.system('echo 0 > '+self.rtcpath+'/wakealarm') + outD = open(self.rtcpath+'/date', 'r').read().strip() + outT = open(self.rtcpath+'/time', 'r').read().strip() + mD = re.match('^(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)', outD) + mT = re.match('^(?P[0-9]*):(?P[0-9]*):(?P[0-9]*)', outT) + if(mD and mT): + # get the current time from hardware + utcoffset = int((datetime.now() - datetime.utcnow()).total_seconds()) + dt = datetime(\ + int(mD.group('y')), int(mD.group('m')), int(mD.group('d')), + int(mT.group('h')), int(mT.group('m')), int(mT.group('s'))) + nowtime = int(dt.strftime('%s')) + utcoffset + else: + # if hardware time fails, use the software time + nowtime = int(datetime.now().strftime('%s')) + alarm = nowtime + self.rtcwaketime + os.system('echo %d > %s/wakealarm' % (alarm, self.rtcpath)) + +sysvals = SystemValues() + +# Class: DeviceNode +# Description: +# A container used to create a device hierachy, with a single root node +# and a tree of child nodes. Used by Data.deviceTopology() +class DeviceNode: + name = '' + children = 0 + depth = 0 + def __init__(self, nodename, nodedepth): + self.name = nodename + self.children = [] + self.depth = nodedepth + +# Class: Data +# Description: +# The primary container for suspend/resume test data. There is one for +# each test run. The data is organized into a cronological hierarchy: +# Data.dmesg { +# root structure, started as dmesg & ftrace, but now only ftrace +# contents: times for suspend start/end, resume start/end, fwdata +# phases { +# 10 sequential, non-overlapping phases of S/R +# contents: times for phase start/end, order/color data for html +# devlist { +# device callback or action list for this phase +# device { +# a single device callback or generic action +# contents: start/stop times, pid/cpu/driver info +# parents/children, html id for timeline/callgraph +# optionally includes an ftrace callgraph +# optionally includes intradev trace events +# } +# } +# } +# } +# +class Data: + dmesg = {} # root data structure + phases = [] # ordered list of phases + start = 0.0 # test start + end = 0.0 # test end + tSuspended = 0.0 # low-level suspend start + tResumed = 0.0 # low-level resume start + tLow = 0.0 # time spent in low-level suspend (standby/freeze) + fwValid = False # is firmware data available + fwSuspend = 0 # time spent in firmware suspend + fwResume = 0 # time spent in firmware resume + dmesgtext = [] # dmesg text file in memory + testnumber = 0 + idstr = '' + html_device_id = 0 + stamp = 0 + outfile = '' + def __init__(self, num): + idchar = 'abcdefghijklmnopqrstuvwxyz' + self.testnumber = num + self.idstr = idchar[num] + self.dmesgtext = [] + self.phases = [] + self.dmesg = { # fixed list of 10 phases + 'suspend_prepare': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#CCFFCC', 'order': 0}, + 'suspend': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#88FF88', 'order': 1}, + 'suspend_late': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#00AA00', 'order': 2}, + 'suspend_noirq': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#008888', 'order': 3}, + 'suspend_machine': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#0000FF', 'order': 4}, + 'resume_machine': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#FF0000', 'order': 5}, + 'resume_noirq': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#FF9900', 'order': 6}, + 'resume_early': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#FFCC00', 'order': 7}, + 'resume': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#FFFF88', 'order': 8}, + 'resume_complete': {'list': dict(), 'start': -1.0, 'end': -1.0, + 'row': 0, 'color': '#FFFFCC', 'order': 9} + } + self.phases = self.sortedPhases() + def getStart(self): + return self.dmesg[self.phases[0]]['start'] + def setStart(self, time): + self.start = time + self.dmesg[self.phases[0]]['start'] = time + def getEnd(self): + return self.dmesg[self.phases[-1]]['end'] + def setEnd(self, time): + self.end = time + self.dmesg[self.phases[-1]]['end'] = time + def isTraceEventOutsideDeviceCalls(self, pid, time): + for phase in self.phases: + list = self.dmesg[phase]['list'] + for dev in list: + d = list[dev] + if(d['pid'] == pid and time >= d['start'] and + time <= d['end']): + return False + return True + def addIntraDevTraceEvent(self, action, name, pid, time): + if(action == 'mutex_lock_try'): + color = 'red' + elif(action == 'mutex_lock_pass'): + color = 'green' + elif(action == 'mutex_unlock'): + color = 'blue' + else: + # create separate colors based on the name + v1 = len(name)*10 % 256 + v2 = string.count(name, 'e')*100 % 256 + v3 = ord(name[0])*20 % 256 + color = '#%06X' % ((v1*0x10000) + (v2*0x100) + v3) + for phase in self.phases: + list = self.dmesg[phase]['list'] + for dev in list: + d = list[dev] + if(d['pid'] == pid and time >= d['start'] and + time <= d['end']): + e = TraceEvent(action, name, color, time) + if('traceevents' not in d): + d['traceevents'] = [] + d['traceevents'].append(e) + return d + break + return 0 + def capIntraDevTraceEvent(self, action, name, pid, time): + for phase in self.phases: + list = self.dmesg[phase]['list'] + for dev in list: + d = list[dev] + if(d['pid'] == pid and time >= d['start'] and + time <= d['end']): + if('traceevents' not in d): + return + for e in d['traceevents']: + if(e.action == action and + e.name == name and not e.ready): + e.length = time - e.time + e.ready = True + break + return + def trimTimeVal(self, t, t0, dT, left): + if left: + if(t > t0): + if(t - dT < t0): + return t0 + return t - dT + else: + return t + else: + if(t < t0 + dT): + if(t > t0): + return t0 + dT + return t + dT + else: + return t + def trimTime(self, t0, dT, left): + self.tSuspended = self.trimTimeVal(self.tSuspended, t0, dT, left) + self.tResumed = self.trimTimeVal(self.tResumed, t0, dT, left) + self.start = self.trimTimeVal(self.start, t0, dT, left) + self.end = self.trimTimeVal(self.end, t0, dT, left) + for phase in self.phases: + p = self.dmesg[phase] + p['start'] = self.trimTimeVal(p['start'], t0, dT, left) + p['end'] = self.trimTimeVal(p['end'], t0, dT, left) + list = p['list'] + for name in list: + d = list[name] + d['start'] = self.trimTimeVal(d['start'], t0, dT, left) + d['end'] = self.trimTimeVal(d['end'], t0, dT, left) + if('ftrace' in d): + cg = d['ftrace'] + cg.start = self.trimTimeVal(cg.start, t0, dT, left) + cg.end = self.trimTimeVal(cg.end, t0, dT, left) + for line in cg.list: + line.time = self.trimTimeVal(line.time, t0, dT, left) + if('traceevents' in d): + for e in d['traceevents']: + e.time = self.trimTimeVal(e.time, t0, dT, left) + def normalizeTime(self, tZero): + # first trim out any standby or freeze clock time + if(self.tSuspended != self.tResumed): + if(self.tResumed > tZero): + self.trimTime(self.tSuspended, \ + self.tResumed-self.tSuspended, True) + else: + self.trimTime(self.tSuspended, \ + self.tResumed-self.tSuspended, False) + # shift the timeline so that tZero is the new 0 + self.tSuspended -= tZero + self.tResumed -= tZero + self.start -= tZero + self.end -= tZero + for phase in self.phases: + p = self.dmesg[phase] + p['start'] -= tZero + p['end'] -= tZero + list = p['list'] + for name in list: + d = list[name] + d['start'] -= tZero + d['end'] -= tZero + if('ftrace' in d): + cg = d['ftrace'] + cg.start -= tZero + cg.end -= tZero + for line in cg.list: + line.time -= tZero + if('traceevents' in d): + for e in d['traceevents']: + e.time -= tZero + def newPhaseWithSingleAction(self, phasename, devname, start, end, color): + for phase in self.phases: + self.dmesg[phase]['order'] += 1 + self.html_device_id += 1 + devid = '%s%d' % (self.idstr, self.html_device_id) + list = dict() + list[devname] = \ + {'start': start, 'end': end, 'pid': 0, 'par': '', + 'length': (end-start), 'row': 0, 'id': devid, 'drv': '' }; + self.dmesg[phasename] = \ + {'list': list, 'start': start, 'end': end, + 'row': 0, 'color': color, 'order': 0} + self.phases = self.sortedPhases() + def newPhase(self, phasename, start, end, color, order): + if(order < 0): + order = len(self.phases) + for phase in self.phases[order:]: + self.dmesg[phase]['order'] += 1 + if(order > 0): + p = self.phases[order-1] + self.dmesg[p]['end'] = start + if(order < len(self.phases)): + p = self.phases[order] + self.dmesg[p]['start'] = end + list = dict() + self.dmesg[phasename] = \ + {'list': list, 'start': start, 'end': end, + 'row': 0, 'color': color, 'order': order} + self.phases = self.sortedPhases() + def setPhase(self, phase, ktime, isbegin): + if(isbegin): + self.dmesg[phase]['start'] = ktime + else: + self.dmesg[phase]['end'] = ktime + def dmesgSortVal(self, phase): + return self.dmesg[phase]['order'] + def sortedPhases(self): + return sorted(self.dmesg, key=self.dmesgSortVal) + def sortedDevices(self, phase): + list = self.dmesg[phase]['list'] + slist = [] + tmp = dict() + for devname in list: + dev = list[devname] + tmp[dev['start']] = devname + for t in sorted(tmp): + slist.append(tmp[t]) + return slist + def fixupInitcalls(self, phase, end): + # if any calls never returned, clip them at system resume end + phaselist = self.dmesg[phase]['list'] + for devname in phaselist: + dev = phaselist[devname] + if(dev['end'] < 0): + dev['end'] = end + vprint('%s (%s): callback didnt return' % (devname, phase)) + def deviceFilter(self, devicefilter): + # remove all by the relatives of the filter devnames + filter = [] + for phase in self.phases: + list = self.dmesg[phase]['list'] + for name in devicefilter: + dev = name + while(dev in list): + if(dev not in filter): + filter.append(dev) + dev = list[dev]['par'] + children = self.deviceDescendants(name, phase) + for dev in children: + if(dev not in filter): + filter.append(dev) + for phase in self.phases: + list = self.dmesg[phase]['list'] + rmlist = [] + for name in list: + pid = list[name]['pid'] + if(name not in filter and pid >= 0): + rmlist.append(name) + for name in rmlist: + del list[name] + def fixupInitcallsThatDidntReturn(self): + # if any calls never returned, clip them at system resume end + for phase in self.phases: + self.fixupInitcalls(phase, self.getEnd()) + def newActionGlobal(self, name, start, end): + # which phase is this device callback or action "in" + targetphase = "none" + overlap = 0.0 + for phase in self.phases: + pstart = self.dmesg[phase]['start'] + pend = self.dmesg[phase]['end'] + o = max(0, min(end, pend) - max(start, pstart)) + if(o > overlap): + targetphase = phase + overlap = o + if targetphase in self.phases: + self.newAction(targetphase, name, -1, '', start, end, '') + return True + return False + def newAction(self, phase, name, pid, parent, start, end, drv): + # new device callback for a specific phase + self.html_device_id += 1 + devid = '%s%d' % (self.idstr, self.html_device_id) + list = self.dmesg[phase]['list'] + length = -1.0 + if(start >= 0 and end >= 0): + length = end - start + list[name] = {'start': start, 'end': end, 'pid': pid, 'par': parent, + 'length': length, 'row': 0, 'id': devid, 'drv': drv } + def deviceIDs(self, devlist, phase): + idlist = [] + list = self.dmesg[phase]['list'] + for devname in list: + if devname in devlist: + idlist.append(list[devname]['id']) + return idlist + def deviceParentID(self, devname, phase): + pdev = '' + pdevid = '' + list = self.dmesg[phase]['list'] + if devname in list: + pdev = list[devname]['par'] + if pdev in list: + return list[pdev]['id'] + return pdev + def deviceChildren(self, devname, phase): + devlist = [] + list = self.dmesg[phase]['list'] + for child in list: + if(list[child]['par'] == devname): + devlist.append(child) + return devlist + def deviceDescendants(self, devname, phase): + children = self.deviceChildren(devname, phase) + family = children + for child in children: + family += self.deviceDescendants(child, phase) + return family + def deviceChildrenIDs(self, devname, phase): + devlist = self.deviceChildren(devname, phase) + return self.deviceIDs(devlist, phase) + def printDetails(self): + vprint(' test start: %f' % self.start) + for phase in self.phases: + dc = len(self.dmesg[phase]['list']) + vprint(' %16s: %f - %f (%d devices)' % (phase, \ + self.dmesg[phase]['start'], self.dmesg[phase]['end'], dc)) + vprint(' test end: %f' % self.end) + def masterTopology(self, name, list, depth): + node = DeviceNode(name, depth) + for cname in list: + clist = self.deviceChildren(cname, 'resume') + cnode = self.masterTopology(cname, clist, depth+1) + node.children.append(cnode) + return node + def printTopology(self, node): + html = '' + if node.name: + info = '' + drv = '' + for phase in self.phases: + list = self.dmesg[phase]['list'] + if node.name in list: + s = list[node.name]['start'] + e = list[node.name]['end'] + if list[node.name]['drv']: + drv = ' {'+list[node.name]['drv']+'}' + info += ('
  • %s: %.3fms
  • ' % (phase, (e-s)*1000)) + html += '
  • '+node.name+drv+'' + if info: + html += '
      '+info+'
    ' + html += '
  • ' + if len(node.children) > 0: + html += '
      ' + for cnode in node.children: + html += self.printTopology(cnode) + html += '
    ' + return html + def rootDeviceList(self): + # list of devices graphed + real = [] + for phase in self.dmesg: + list = self.dmesg[phase]['list'] + for dev in list: + if list[dev]['pid'] >= 0 and dev not in real: + real.append(dev) + # list of top-most root devices + rootlist = [] + for phase in self.dmesg: + list = self.dmesg[phase]['list'] + for dev in list: + pdev = list[dev]['par'] + if(re.match('[0-9]*-[0-9]*\.[0-9]*[\.0-9]*\:[\.0-9]*$', pdev)): + continue + if pdev and pdev not in real and pdev not in rootlist: + rootlist.append(pdev) + return rootlist + def deviceTopology(self): + rootlist = self.rootDeviceList() + master = self.masterTopology('', rootlist, 0) + return self.printTopology(master) + +# Class: TraceEvent +# Description: +# A container for trace event data found in the ftrace file +class TraceEvent: + ready = False + name = '' + time = 0.0 + color = '#FFFFFF' + length = 0.0 + action = '' + def __init__(self, a, n, c, t): + self.action = a + self.name = n + self.color = c + self.time = t + +# Class: FTraceLine +# Description: +# A container for a single line of ftrace data. There are six basic types: +# callgraph line: +# call: " dpm_run_callback() {" +# return: " }" +# leaf: " dpm_run_callback();" +# trace event: +# tracing_mark_write: SUSPEND START or RESUME COMPLETE +# suspend_resume: phase or custom exec block data +# device_pm_callback: device callback info +class FTraceLine: + time = 0.0 + length = 0.0 + fcall = False + freturn = False + fevent = False + depth = 0 + name = '' + type = '' + def __init__(self, t, m, d): + self.time = float(t) + # is this a trace event + if(d == 'traceevent' or re.match('^ *\/\* *(?P.*) \*\/ *$', m)): + if(d == 'traceevent'): + # nop format trace event + msg = m + else: + # function_graph format trace event + em = re.match('^ *\/\* *(?P.*) \*\/ *$', m) + msg = em.group('msg') + + emm = re.match('^(?P.*?): (?P.*)', msg) + if(emm): + self.name = emm.group('msg') + self.type = emm.group('call') + else: + self.name = msg + self.fevent = True + return + # convert the duration to seconds + if(d): + self.length = float(d)/1000000 + # the indentation determines the depth + match = re.match('^(?P *)(?P.*)$', m) + if(not match): + return + self.depth = self.getDepth(match.group('d')) + m = match.group('o') + # function return + if(m[0] == '}'): + self.freturn = True + if(len(m) > 1): + # includes comment with function name + match = re.match('^} *\/\* *(?P.*) *\*\/$', m) + if(match): + self.name = match.group('n') + # function call + else: + self.fcall = True + # function call with children + if(m[-1] == '{'): + match = re.match('^(?P.*) *\(.*', m) + if(match): + self.name = match.group('n') + # function call with no children (leaf) + elif(m[-1] == ';'): + self.freturn = True + match = re.match('^(?P.*) *\(.*', m) + if(match): + self.name = match.group('n') + # something else (possibly a trace marker) + else: + self.name = m + def getDepth(self, str): + return len(str)/2 + def debugPrint(self, dev): + if(self.freturn and self.fcall): + print('%s -- %f (%02d): %s(); (%.3f us)' % (dev, self.time, \ + self.depth, self.name, self.length*1000000)) + elif(self.freturn): + print('%s -- %f (%02d): %s} (%.3f us)' % (dev, self.time, \ + self.depth, self.name, self.length*1000000)) + else: + print('%s -- %f (%02d): %s() { (%.3f us)' % (dev, self.time, \ + self.depth, self.name, self.length*1000000)) + +# Class: FTraceCallGraph +# Description: +# A container for the ftrace callgraph of a single recursive function. +# This can be a dpm_run_callback, dpm_prepare, or dpm_complete callgraph +# Each instance is tied to a single device in a single phase, and is +# comprised of an ordered list of FTraceLine objects +class FTraceCallGraph: + start = -1.0 + end = -1.0 + list = [] + invalid = False + depth = 0 + def __init__(self): + self.start = -1.0 + self.end = -1.0 + self.list = [] + self.depth = 0 + def setDepth(self, line): + if(line.fcall and not line.freturn): + line.depth = self.depth + self.depth += 1 + elif(line.freturn and not line.fcall): + self.depth -= 1 + line.depth = self.depth + else: + line.depth = self.depth + def addLine(self, line, match): + if(not self.invalid): + self.setDepth(line) + if(line.depth == 0 and line.freturn): + if(self.start < 0): + self.start = line.time + self.end = line.time + self.list.append(line) + return True + if(self.invalid): + return False + if(len(self.list) >= 1000000 or self.depth < 0): + if(len(self.list) > 0): + first = self.list[0] + self.list = [] + self.list.append(first) + self.invalid = True + if(not match): + return False + id = 'task %s cpu %s' % (match.group('pid'), match.group('cpu')) + window = '(%f - %f)' % (self.start, line.time) + if(self.depth < 0): + print('Too much data for '+id+\ + ' (buffer overflow), ignoring this callback') + else: + print('Too much data for '+id+\ + ' '+window+', ignoring this callback') + return False + self.list.append(line) + if(self.start < 0): + self.start = line.time + return False + def slice(self, t0, tN): + minicg = FTraceCallGraph() + count = -1 + firstdepth = 0 + for l in self.list: + if(l.time < t0 or l.time > tN): + continue + if(count < 0): + if(not l.fcall or l.name == 'dev_driver_string'): + continue + firstdepth = l.depth + count = 0 + l.depth -= firstdepth + minicg.addLine(l, 0) + if((count == 0 and l.freturn and l.fcall) or + (count > 0 and l.depth <= 0)): + break + count += 1 + return minicg + def sanityCheck(self): + stack = dict() + cnt = 0 + for l in self.list: + if(l.fcall and not l.freturn): + stack[l.depth] = l + cnt += 1 + elif(l.freturn and not l.fcall): + if(l.depth not in stack): + return False + stack[l.depth].length = l.length + stack[l.depth] = 0 + l.length = 0 + cnt -= 1 + if(cnt == 0): + return True + return False + def debugPrint(self, filename): + if(filename == 'stdout'): + print('[%f - %f]') % (self.start, self.end) + for l in self.list: + if(l.freturn and l.fcall): + print('%f (%02d): %s(); (%.3f us)' % (l.time, \ + l.depth, l.name, l.length*1000000)) + elif(l.freturn): + print('%f (%02d): %s} (%.3f us)' % (l.time, \ + l.depth, l.name, l.length*1000000)) + else: + print('%f (%02d): %s() { (%.3f us)' % (l.time, \ + l.depth, l.name, l.length*1000000)) + print(' ') + else: + fp = open(filename, 'w') + print(filename) + for l in self.list: + if(l.freturn and l.fcall): + fp.write('%f (%02d): %s(); (%.3f us)\n' % (l.time, \ + l.depth, l.name, l.length*1000000)) + elif(l.freturn): + fp.write('%f (%02d): %s} (%.3f us)\n' % (l.time, \ + l.depth, l.name, l.length*1000000)) + else: + fp.write('%f (%02d): %s() { (%.3f us)\n' % (l.time, \ + l.depth, l.name, l.length*1000000)) + fp.close() + +# Class: Timeline +# Description: +# A container for a suspend/resume html timeline. In older versions +# of the script there were multiple timelines, but in the latest +# there is only one. +class Timeline: + html = {} + scaleH = 0.0 # height of the row as a percent of the timeline height + rowH = 0.0 # height of each row in percent of the timeline height + row_height_pixels = 30 + maxrows = 0 + height = 0 + def __init__(self): + self.html = { + 'timeline': '', + 'legend': '', + 'scale': '' + } + def setRows(self, rows): + self.maxrows = int(rows) + self.scaleH = 100.0/float(self.maxrows) + self.height = self.maxrows*self.row_height_pixels + r = float(self.maxrows - 1) + if(r < 1.0): + r = 1.0 + self.rowH = (100.0 - self.scaleH)/r + +# Class: TestRun +# Description: +# A container for a suspend/resume test run. This is necessary as +# there could be more than one, and they need to be separate. +class TestRun: + ftrace_line_fmt_fg = \ + '^ *(?P