diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /scripts | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'scripts')
119 files changed, 1531 insertions, 10993 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 978416dd31c..d897278b1f9 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -98,24 +98,24 @@ try-run = $(shell set -e; \ | |||
98 | # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) | 98 | # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) |
99 | 99 | ||
100 | as-option = $(call try-run,\ | 100 | as-option = $(call try-run,\ |
101 | $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) | 101 | $(CC) $(KBUILD_CFLAGS) $(1) -c -xassembler /dev/null -o "$$TMP",$(1),$(2)) |
102 | 102 | ||
103 | # as-instr | 103 | # as-instr |
104 | # Usage: cflags-y += $(call as-instr,instr,option1,option2) | 104 | # Usage: cflags-y += $(call as-instr,instr,option1,option2) |
105 | 105 | ||
106 | as-instr = $(call try-run,\ | 106 | as-instr = $(call try-run,\ |
107 | printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) | 107 | /bin/echo -e "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3)) |
108 | 108 | ||
109 | # cc-option | 109 | # cc-option |
110 | # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) | 110 | # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) |
111 | 111 | ||
112 | cc-option = $(call try-run,\ | 112 | cc-option = $(call try-run,\ |
113 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) | 113 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) |
114 | 114 | ||
115 | # cc-option-yn | 115 | # cc-option-yn |
116 | # Usage: flag := $(call cc-option-yn,-march=winchip-c6) | 116 | # Usage: flag := $(call cc-option-yn,-march=winchip-c6) |
117 | cc-option-yn = $(call try-run,\ | 117 | cc-option-yn = $(call try-run,\ |
118 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) | 118 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) |
119 | 119 | ||
120 | # cc-option-align | 120 | # cc-option-align |
121 | # Prefix align with either -falign or -malign | 121 | # Prefix align with either -falign or -malign |
@@ -125,7 +125,7 @@ cc-option-align = $(subst -functions=0,,\ | |||
125 | # cc-disable-warning | 125 | # cc-disable-warning |
126 | # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) | 126 | # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) |
127 | cc-disable-warning = $(call try-run,\ | 127 | cc-disable-warning = $(call try-run,\ |
128 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) | 128 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1))) |
129 | 129 | ||
130 | # cc-version | 130 | # cc-version |
131 | # Usage gcc-ver := $(call cc-version) | 131 | # Usage gcc-ver := $(call cc-version) |
@@ -143,7 +143,7 @@ cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) | |||
143 | # cc-ldoption | 143 | # cc-ldoption |
144 | # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) | 144 | # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) |
145 | cc-ldoption = $(call try-run,\ | 145 | cc-ldoption = $(call try-run,\ |
146 | $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) | 146 | $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2)) |
147 | 147 | ||
148 | # ld-option | 148 | # ld-option |
149 | # Usage: LDFLAGS += $(call ld-option, -X) | 149 | # Usage: LDFLAGS += $(call ld-option, -X) |
@@ -209,7 +209,7 @@ endif | |||
209 | # >$< substitution to preserve $ when reloading .cmd file | 209 | # >$< substitution to preserve $ when reloading .cmd file |
210 | # note: when using inline perl scripts [perl -e '...$$t=1;...'] | 210 | # note: when using inline perl scripts [perl -e '...$$t=1;...'] |
211 | # in $(cmd_xxx) double $$ your perl vars | 211 | # in $(cmd_xxx) double $$ your perl vars |
212 | make-cmd = $(subst \\,\\\\,$(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))) | 212 | make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) |
213 | 213 | ||
214 | # Find any prerequisites that is newer than target or that does not exist. | 214 | # Find any prerequisites that is newer than target or that does not exist. |
215 | # PHONY targets skipped in both cases. | 215 | # PHONY targets skipped in both cases. |
diff --git a/scripts/Makefile b/scripts/Makefile index 01e7adb838d..df7678febf2 100644 --- a/scripts/Makefile +++ b/scripts/Makefile | |||
@@ -8,18 +8,11 @@ | |||
8 | # conmakehash: Create arrays for initializing the kernel console tables | 8 | # conmakehash: Create arrays for initializing the kernel console tables |
9 | # docproc: Used in Documentation/DocBook | 9 | # docproc: Used in Documentation/DocBook |
10 | 10 | ||
11 | HOST_EXTRACFLAGS += -I$(srctree)/tools/include | ||
12 | |||
13 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms | 11 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms |
14 | hostprogs-$(CONFIG_LOGO) += pnmtologo | 12 | hostprogs-$(CONFIG_LOGO) += pnmtologo |
15 | hostprogs-$(CONFIG_VT) += conmakehash | 13 | hostprogs-$(CONFIG_VT) += conmakehash |
16 | hostprogs-$(CONFIG_IKCONFIG) += bin2c | 14 | hostprogs-$(CONFIG_IKCONFIG) += bin2c |
17 | hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount | 15 | hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount |
18 | hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable | ||
19 | hostprogs-$(CONFIG_ASN1) += asn1_compiler | ||
20 | |||
21 | HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include | ||
22 | HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include | ||
23 | 16 | ||
24 | always := $(hostprogs-y) $(hostprogs-m) | 17 | always := $(hostprogs-y) $(hostprogs-m) |
25 | 18 | ||
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic index d17e0ea911e..40caf3c26cd 100644 --- a/scripts/Makefile.asm-generic +++ b/scripts/Makefile.asm-generic | |||
@@ -5,7 +5,7 @@ | |||
5 | # and for each file listed in this file with generic-y creates | 5 | # and for each file listed in this file with generic-y creates |
6 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) | 6 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) |
7 | 7 | ||
8 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild | 8 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild |
9 | -include $(kbuild-file) | 9 | -include $(kbuild-file) |
10 | 10 | ||
11 | include scripts/Kbuild.include | 11 | include scripts/Kbuild.include |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 0e801c3cdaf..a0fd5029cfe 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -46,7 +46,7 @@ include $(kbuild-file) | |||
46 | # If the save-* variables changed error out | 46 | # If the save-* variables changed error out |
47 | ifeq ($(KBUILD_NOPEDANTIC),) | 47 | ifeq ($(KBUILD_NOPEDANTIC),) |
48 | ifneq ("$(save-cflags)","$(CFLAGS)") | 48 | ifneq ("$(save-cflags)","$(CFLAGS)") |
49 | $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y) | 49 | $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use EXTRA_CFLAGS) |
50 | endif | 50 | endif |
51 | endif | 51 | endif |
52 | 52 | ||
@@ -69,7 +69,6 @@ warning-1 += -Wmissing-prototypes | |||
69 | warning-1 += -Wold-style-definition | 69 | warning-1 += -Wold-style-definition |
70 | warning-1 += $(call cc-option, -Wmissing-include-dirs) | 70 | warning-1 += $(call cc-option, -Wmissing-include-dirs) |
71 | warning-1 += $(call cc-option, -Wunused-but-set-variable) | 71 | warning-1 += $(call cc-option, -Wunused-but-set-variable) |
72 | warning-1 += $(call cc-disable-warning, missing-field-initializers) | ||
73 | 72 | ||
74 | warning-2 := -Waggregate-return | 73 | warning-2 := -Waggregate-return |
75 | warning-2 += -Wcast-align | 74 | warning-2 += -Wcast-align |
@@ -77,7 +76,6 @@ warning-2 += -Wdisabled-optimization | |||
77 | warning-2 += -Wnested-externs | 76 | warning-2 += -Wnested-externs |
78 | warning-2 += -Wshadow | 77 | warning-2 += -Wshadow |
79 | warning-2 += $(call cc-option, -Wlogical-op) | 78 | warning-2 += $(call cc-option, -Wlogical-op) |
80 | warning-2 += $(call cc-option, -Wmissing-field-initializers) | ||
81 | 79 | ||
82 | warning-3 := -Wbad-function-cast | 80 | warning-3 := -Wbad-function-cast |
83 | warning-3 += -Wcast-qual | 81 | warning-3 += -Wcast-qual |
@@ -354,17 +352,6 @@ quiet_cmd_cpp_lds_S = LDS $@ | |||
354 | $(obj)/%.lds: $(src)/%.lds.S FORCE | 352 | $(obj)/%.lds: $(src)/%.lds.S FORCE |
355 | $(call if_changed_dep,cpp_lds_S) | 353 | $(call if_changed_dep,cpp_lds_S) |
356 | 354 | ||
357 | # ASN.1 grammar | ||
358 | # --------------------------------------------------------------------------- | ||
359 | quiet_cmd_asn1_compiler = ASN.1 $@ | ||
360 | cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ | ||
361 | $(subst .h,.c,$@) $(subst .c,.h,$@) | ||
362 | |||
363 | .PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h | ||
364 | |||
365 | $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler | ||
366 | $(call cmd,asn1_compiler) | ||
367 | |||
368 | # Build the compiled-in targets | 355 | # Build the compiled-in targets |
369 | # --------------------------------------------------------------------------- | 356 | # --------------------------------------------------------------------------- |
370 | 357 | ||
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst index 4d908d16c03..6bf8e87f1dc 100644 --- a/scripts/Makefile.fwinst +++ b/scripts/Makefile.fwinst | |||
@@ -27,7 +27,7 @@ endif | |||
27 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) | 27 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) |
28 | 28 | ||
29 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) | 29 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) |
30 | installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./ | 30 | installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/. |
31 | 31 | ||
32 | # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. | 32 | # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. |
33 | PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs | 33 | PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs |
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 06ba4a70bd4..a57f5bd5a13 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
@@ -3,77 +3,57 @@ | |||
3 | # | 3 | # |
4 | # header-y - list files to be installed. They are preprocessed | 4 | # header-y - list files to be installed. They are preprocessed |
5 | # to remove __KERNEL__ section of the file | 5 | # to remove __KERNEL__ section of the file |
6 | # genhdr-y - Same as header-y but in a generated/ directory | 6 | # objhdr-y - Same as header-y but for generated files |
7 | # | 7 | # |
8 | # ========================================================================== | 8 | # ========================================================================== |
9 | 9 | ||
10 | # called may set destination dir (when installing to asm/) | 10 | # called may set destination dir (when installing to asm/) |
11 | _dst := $(or $(destination-y),$(dst),$(obj)) | 11 | _dst := $(if $(dst),$(dst),$(obj)) |
12 | |||
13 | # generated header directory | ||
14 | gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) | ||
15 | 12 | ||
16 | kbuild-file := $(srctree)/$(obj)/Kbuild | 13 | kbuild-file := $(srctree)/$(obj)/Kbuild |
17 | include $(kbuild-file) | 14 | include $(kbuild-file) |
18 | 15 | ||
19 | old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild | 16 | _dst := $(if $(destination-y),$(destination-y),$(_dst)) |
20 | ifneq ($(wildcard $(old-kbuild-file)),) | ||
21 | include $(old-kbuild-file) | ||
22 | endif | ||
23 | 17 | ||
24 | include scripts/Kbuild.include | 18 | include scripts/Kbuild.include |
25 | 19 | ||
26 | installdir := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst)) | 20 | install := $(INSTALL_HDR_PATH)/$(_dst) |
27 | 21 | ||
28 | header-y := $(sort $(header-y)) | 22 | header-y := $(sort $(header-y)) |
29 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) | 23 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) |
30 | header-y := $(filter-out %/, $(header-y)) | 24 | header-y := $(filter-out %/, $(header-y)) |
31 | 25 | ||
32 | # files used to track state of install/check | 26 | # files used to track state of install/check |
33 | install-file := $(installdir)/.install | 27 | install-file := $(install)/.install |
34 | check-file := $(installdir)/.check | 28 | check-file := $(install)/.check |
35 | 29 | ||
36 | # generic-y list all files an architecture uses from asm-generic | 30 | # generic-y list all files an architecture uses from asm-generic |
37 | # Use this to build a list of headers which require a wrapper | 31 | # Use this to build a list of headers which require a wrapper |
38 | wrapper-files := $(filter $(header-y), $(generic-y)) | 32 | wrapper-files := $(filter $(header-y), $(generic-y)) |
39 | 33 | ||
40 | srcdir := $(srctree)/$(obj) | ||
41 | gendir := $(objtree)/$(gen) | ||
42 | |||
43 | oldsrcdir := $(srctree)/$(subst /uapi,,$(obj)) | ||
44 | |||
45 | # all headers files for this dir | 34 | # all headers files for this dir |
46 | header-y := $(filter-out $(generic-y), $(header-y)) | 35 | header-y := $(filter-out $(generic-y), $(header-y)) |
47 | all-files := $(header-y) $(genhdr-y) $(wrapper-files) | 36 | all-files := $(header-y) $(objhdr-y) $(wrapper-files) |
48 | output-files := $(addprefix $(installdir)/, $(all-files)) | 37 | input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ |
49 | 38 | $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) | |
50 | input-files := $(foreach hdr, $(header-y), \ | 39 | output-files := $(addprefix $(install)/, $(all-files)) |
51 | $(or \ | ||
52 | $(wildcard $(srcdir)/$(hdr)), \ | ||
53 | $(wildcard $(oldsrcdir)/$(hdr)), \ | ||
54 | $(error Missing UAPI file $(srcdir)/$(hdr)) \ | ||
55 | )) \ | ||
56 | $(foreach hdr, $(genhdr-y), \ | ||
57 | $(or \ | ||
58 | $(wildcard $(gendir)/$(hdr)), \ | ||
59 | $(error Missing generated UAPI file $(gendir)/$(hdr)) \ | ||
60 | )) | ||
61 | 40 | ||
62 | # Work out what needs to be removed | 41 | # Work out what needs to be removed |
63 | oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) | 42 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) |
64 | unwanted := $(filter-out $(all-files),$(oldheaders)) | 43 | unwanted := $(filter-out $(all-files),$(oldheaders)) |
65 | 44 | ||
66 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) | 45 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
67 | unwanted-file := $(addprefix $(installdir)/, $(unwanted)) | 46 | unwanted-file := $(addprefix $(install)/, $(unwanted)) |
68 | 47 | ||
69 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) | 48 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
70 | 49 | ||
71 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ | 50 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ |
72 | file$(if $(word 2, $(all-files)),s)) | 51 | file$(if $(word 2, $(all-files)),s)) |
73 | cmd_install = \ | 52 | cmd_install = \ |
74 | $(PERL) $< $(installdir) $(SRCARCH) $(input-files); \ | 53 | $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ |
54 | $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ | ||
75 | for F in $(wrapper-files); do \ | 55 | for F in $(wrapper-files); do \ |
76 | echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ | 56 | echo "\#include <asm-generic/$$F>" > $(install)/$$F; \ |
77 | done; \ | 57 | done; \ |
78 | touch $@ | 58 | touch $@ |
79 | 59 | ||
@@ -84,7 +64,7 @@ quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) | |||
84 | # Headers list can be pretty long, xargs helps to avoid | 64 | # Headers list can be pretty long, xargs helps to avoid |
85 | # the "Argument list too long" error. | 65 | # the "Argument list too long" error. |
86 | cmd_check = for f in $(all-files); do \ | 66 | cmd_check = for f in $(all-files); do \ |
87 | echo "$(installdir)/$${f}"; done \ | 67 | echo "$(install)/$${f}"; done \ |
88 | | xargs \ | 68 | | xargs \ |
89 | $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ | 69 | $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ |
90 | touch $@ | 70 | touch $@ |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index bdf42fdf64c..aeea84a2483 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -93,9 +93,9 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) | |||
93 | # already | 93 | # already |
94 | # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will | 94 | # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will |
95 | # end up in (or would, if it gets compiled in) | 95 | # end up in (or would, if it gets compiled in) |
96 | # Note: Files that end up in two or more modules are compiled without the | 96 | # Note: It's possible that one object gets potentially linked into more |
97 | # KBUILD_MODNAME definition. The reason is that any made-up name would | 97 | # than one module. In that case KBUILD_MODNAME will be set to foo_bar, |
98 | # differ in different configs. | 98 | # where foo and bar are the name of the modules. |
99 | name-fix = $(subst $(comma),_,$(subst -,_,$1)) | 99 | name-fix = $(subst $(comma),_,$(subst -,_,$1)) |
100 | basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" | 100 | basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" |
101 | modname_flags = $(if $(filter 1,$(words $(modname))),\ | 101 | modname_flags = $(if $(filter 1,$(words $(modname))),\ |
@@ -167,7 +167,6 @@ ifdef REGENERATE_PARSERS | |||
167 | quiet_cmd_gperf = GPERF $@ | 167 | quiet_cmd_gperf = GPERF $@ |
168 | cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< | 168 | cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< |
169 | 169 | ||
170 | .PRECIOUS: $(src)/%.hash.c_shipped | ||
171 | $(src)/%.hash.c_shipped: $(src)/%.gperf | 170 | $(src)/%.hash.c_shipped: $(src)/%.gperf |
172 | $(call cmd,gperf) | 171 | $(call cmd,gperf) |
173 | 172 | ||
@@ -178,7 +177,6 @@ LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy) | |||
178 | quiet_cmd_flex = LEX $@ | 177 | quiet_cmd_flex = LEX $@ |
179 | cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $< | 178 | cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $< |
180 | 179 | ||
181 | .PRECIOUS: $(src)/%.lex.c_shipped | ||
182 | $(src)/%.lex.c_shipped: $(src)/%.l | 180 | $(src)/%.lex.c_shipped: $(src)/%.l |
183 | $(call cmd,flex) | 181 | $(call cmd,flex) |
184 | 182 | ||
@@ -189,14 +187,12 @@ YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) | |||
189 | quiet_cmd_bison = YACC $@ | 187 | quiet_cmd_bison = YACC $@ |
190 | cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $< | 188 | cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $< |
191 | 189 | ||
192 | .PRECIOUS: $(src)/%.tab.c_shipped | ||
193 | $(src)/%.tab.c_shipped: $(src)/%.y | 190 | $(src)/%.tab.c_shipped: $(src)/%.y |
194 | $(call cmd,bison) | 191 | $(call cmd,bison) |
195 | 192 | ||
196 | quiet_cmd_bison_h = YACC $@ | 193 | quiet_cmd_bison_h = YACC $@ |
197 | cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< | 194 | cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< |
198 | 195 | ||
199 | .PRECIOUS: $(src)/%.tab.h_shipped | ||
200 | $(src)/%.tab.h_shipped: $(src)/%.y | 196 | $(src)/%.tab.h_shipped: $(src)/%.y |
201 | $(call cmd,bison_h) | 197 | $(call cmd,bison_h) |
202 | 198 | ||
@@ -264,10 +260,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb | |||
264 | $(call cmd,dt_S_dtb) | 260 | $(call cmd,dt_S_dtb) |
265 | 261 | ||
266 | quiet_cmd_dtc = DTC $@ | 262 | quiet_cmd_dtc = DTC $@ |
267 | cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $< | 263 | cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $< |
268 | |||
269 | $(obj)/%.dtb: $(src)/%.dts FORCE | ||
270 | $(call if_changed_dep,dtc) | ||
271 | 264 | ||
272 | # Bzip2 | 265 | # Bzip2 |
273 | # --------------------------------------------------------------------------- | 266 | # --------------------------------------------------------------------------- |
@@ -307,30 +300,6 @@ cmd_lzo = (cat $(filter-out FORCE,$^) | \ | |||
307 | lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ | 300 | lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ |
308 | (rm -f $@ ; false) | 301 | (rm -f $@ ; false) |
309 | 302 | ||
310 | # U-Boot mkimage | ||
311 | # --------------------------------------------------------------------------- | ||
312 | |||
313 | MKIMAGE := $(srctree)/scripts/mkuboot.sh | ||
314 | |||
315 | # SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces | ||
316 | # the number of overrides in arch makefiles | ||
317 | UIMAGE_ARCH ?= $(SRCARCH) | ||
318 | UIMAGE_COMPRESSION ?= $(if $(2),$(2),none) | ||
319 | UIMAGE_OPTS-y ?= | ||
320 | UIMAGE_TYPE ?= kernel | ||
321 | UIMAGE_LOADADDR ?= arch_must_set_this | ||
322 | UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) | ||
323 | UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)' | ||
324 | UIMAGE_IN ?= $< | ||
325 | UIMAGE_OUT ?= $@ | ||
326 | |||
327 | quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT) | ||
328 | cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ | ||
329 | -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ | ||
330 | -T $(UIMAGE_TYPE) \ | ||
331 | -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ | ||
332 | -n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT) | ||
333 | |||
334 | # XZ | 303 | # XZ |
335 | # --------------------------------------------------------------------------- | 304 | # --------------------------------------------------------------------------- |
336 | # Use xzkern to compress the kernel image and xzmisc to compress other things. | 305 | # Use xzkern to compress the kernel image and xzmisc to compress other things. |
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index ecbb44797e2..efa5d940e63 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst | |||
@@ -9,16 +9,15 @@ include scripts/Kbuild.include | |||
9 | 9 | ||
10 | # | 10 | # |
11 | 11 | ||
12 | __modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) | 12 | __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) |
13 | modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) | 13 | modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) |
14 | 14 | ||
15 | PHONY += $(modules) | 15 | PHONY += $(modules) |
16 | __modinst: $(modules) | 16 | __modinst: $(modules) |
17 | @: | 17 | @: |
18 | 18 | ||
19 | # Don't stop modules_install if we can't sign external modules. | ||
20 | quiet_cmd_modules_install = INSTALL $@ | 19 | quiet_cmd_modules_install = INSTALL $@ |
21 | cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) | 20 | cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) |
22 | 21 | ||
23 | # Modules built outside the kernel source tree go into extra by default | 22 | # Modules built outside the kernel source tree go into extra by default |
24 | INSTALL_MOD_DIR ?= extra | 23 | INSTALL_MOD_DIR ?= extra |
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index a1cb0222ebe..08dce14f2dc 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -60,7 +60,7 @@ kernelsymfile := $(objtree)/Module.symvers | |||
60 | modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers | 60 | modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers |
61 | 61 | ||
62 | # Step 1), find all modules listed in $(MODVERDIR)/ | 62 | # Step 1), find all modules listed in $(MODVERDIR)/ |
63 | __modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) | 63 | __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) |
64 | modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) | 64 | modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) |
65 | 65 | ||
66 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker | 66 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker |
diff --git a/scripts/Makefile.modsign b/scripts/Makefile.modsign deleted file mode 100644 index abfda626dba..00000000000 --- a/scripts/Makefile.modsign +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | # ========================================================================== | ||
2 | # Signing modules | ||
3 | # ========================================================================== | ||
4 | |||
5 | PHONY := __modsign | ||
6 | __modsign: | ||
7 | |||
8 | include scripts/Kbuild.include | ||
9 | |||
10 | __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) | ||
11 | modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) | ||
12 | |||
13 | PHONY += $(modules) | ||
14 | __modsign: $(modules) | ||
15 | @: | ||
16 | |||
17 | quiet_cmd_sign_ko = SIGN [M] $(2)/$(notdir $@) | ||
18 | cmd_sign_ko = $(mod_sign_cmd) $(2)/$(notdir $@) | ||
19 | |||
20 | # Modules built outside the kernel source tree go into extra by default | ||
21 | INSTALL_MOD_DIR ?= extra | ||
22 | ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) | ||
23 | |||
24 | modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) | ||
25 | |||
26 | $(modules): | ||
27 | $(call cmd,sign_ko,$(MODLIB)/$(modinst_dir)) | ||
28 | |||
29 | # Declare the contents of the .PHONY variable as phony. We keep that | ||
30 | # information in a variable se we can use it in if_changed and friends. | ||
31 | |||
32 | .PHONY: $(PHONY) | ||
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c deleted file mode 100644 index db0e5cd34c7..00000000000 --- a/scripts/asn1_compiler.c +++ /dev/null | |||
@@ -1,1545 +0,0 @@ | |||
1 | /* Simplified ASN.1 notation parser | ||
2 | * | ||
3 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public Licence | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the Licence, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <stdarg.h> | ||
13 | #include <stdio.h> | ||
14 | #include <stdlib.h> | ||
15 | #include <stdint.h> | ||
16 | #include <string.h> | ||
17 | #include <ctype.h> | ||
18 | #include <unistd.h> | ||
19 | #include <fcntl.h> | ||
20 | #include <sys/stat.h> | ||
21 | #include <linux/asn1_ber_bytecode.h> | ||
22 | |||
23 | enum token_type { | ||
24 | DIRECTIVE_ABSENT, | ||
25 | DIRECTIVE_ALL, | ||
26 | DIRECTIVE_ANY, | ||
27 | DIRECTIVE_APPLICATION, | ||
28 | DIRECTIVE_AUTOMATIC, | ||
29 | DIRECTIVE_BEGIN, | ||
30 | DIRECTIVE_BIT, | ||
31 | DIRECTIVE_BMPString, | ||
32 | DIRECTIVE_BOOLEAN, | ||
33 | DIRECTIVE_BY, | ||
34 | DIRECTIVE_CHARACTER, | ||
35 | DIRECTIVE_CHOICE, | ||
36 | DIRECTIVE_CLASS, | ||
37 | DIRECTIVE_COMPONENT, | ||
38 | DIRECTIVE_COMPONENTS, | ||
39 | DIRECTIVE_CONSTRAINED, | ||
40 | DIRECTIVE_CONTAINING, | ||
41 | DIRECTIVE_DEFAULT, | ||
42 | DIRECTIVE_DEFINED, | ||
43 | DIRECTIVE_DEFINITIONS, | ||
44 | DIRECTIVE_EMBEDDED, | ||
45 | DIRECTIVE_ENCODED, | ||
46 | DIRECTIVE_ENCODING_CONTROL, | ||
47 | DIRECTIVE_END, | ||
48 | DIRECTIVE_ENUMERATED, | ||
49 | DIRECTIVE_EXCEPT, | ||
50 | DIRECTIVE_EXPLICIT, | ||
51 | DIRECTIVE_EXPORTS, | ||
52 | DIRECTIVE_EXTENSIBILITY, | ||
53 | DIRECTIVE_EXTERNAL, | ||
54 | DIRECTIVE_FALSE, | ||
55 | DIRECTIVE_FROM, | ||
56 | DIRECTIVE_GeneralString, | ||
57 | DIRECTIVE_GeneralizedTime, | ||
58 | DIRECTIVE_GraphicString, | ||
59 | DIRECTIVE_IA5String, | ||
60 | DIRECTIVE_IDENTIFIER, | ||
61 | DIRECTIVE_IMPLICIT, | ||
62 | DIRECTIVE_IMPLIED, | ||
63 | DIRECTIVE_IMPORTS, | ||
64 | DIRECTIVE_INCLUDES, | ||
65 | DIRECTIVE_INSTANCE, | ||
66 | DIRECTIVE_INSTRUCTIONS, | ||
67 | DIRECTIVE_INTEGER, | ||
68 | DIRECTIVE_INTERSECTION, | ||
69 | DIRECTIVE_ISO646String, | ||
70 | DIRECTIVE_MAX, | ||
71 | DIRECTIVE_MIN, | ||
72 | DIRECTIVE_MINUS_INFINITY, | ||
73 | DIRECTIVE_NULL, | ||
74 | DIRECTIVE_NumericString, | ||
75 | DIRECTIVE_OBJECT, | ||
76 | DIRECTIVE_OCTET, | ||
77 | DIRECTIVE_OF, | ||
78 | DIRECTIVE_OPTIONAL, | ||
79 | DIRECTIVE_ObjectDescriptor, | ||
80 | DIRECTIVE_PATTERN, | ||
81 | DIRECTIVE_PDV, | ||
82 | DIRECTIVE_PLUS_INFINITY, | ||
83 | DIRECTIVE_PRESENT, | ||
84 | DIRECTIVE_PRIVATE, | ||
85 | DIRECTIVE_PrintableString, | ||
86 | DIRECTIVE_REAL, | ||
87 | DIRECTIVE_RELATIVE_OID, | ||
88 | DIRECTIVE_SEQUENCE, | ||
89 | DIRECTIVE_SET, | ||
90 | DIRECTIVE_SIZE, | ||
91 | DIRECTIVE_STRING, | ||
92 | DIRECTIVE_SYNTAX, | ||
93 | DIRECTIVE_T61String, | ||
94 | DIRECTIVE_TAGS, | ||
95 | DIRECTIVE_TRUE, | ||
96 | DIRECTIVE_TeletexString, | ||
97 | DIRECTIVE_UNION, | ||
98 | DIRECTIVE_UNIQUE, | ||
99 | DIRECTIVE_UNIVERSAL, | ||
100 | DIRECTIVE_UTCTime, | ||
101 | DIRECTIVE_UTF8String, | ||
102 | DIRECTIVE_UniversalString, | ||
103 | DIRECTIVE_VideotexString, | ||
104 | DIRECTIVE_VisibleString, | ||
105 | DIRECTIVE_WITH, | ||
106 | NR__DIRECTIVES, | ||
107 | TOKEN_ASSIGNMENT = NR__DIRECTIVES, | ||
108 | TOKEN_OPEN_CURLY, | ||
109 | TOKEN_CLOSE_CURLY, | ||
110 | TOKEN_OPEN_SQUARE, | ||
111 | TOKEN_CLOSE_SQUARE, | ||
112 | TOKEN_OPEN_ACTION, | ||
113 | TOKEN_CLOSE_ACTION, | ||
114 | TOKEN_COMMA, | ||
115 | TOKEN_NUMBER, | ||
116 | TOKEN_TYPE_NAME, | ||
117 | TOKEN_ELEMENT_NAME, | ||
118 | NR__TOKENS | ||
119 | }; | ||
120 | |||
121 | static const unsigned char token_to_tag[NR__TOKENS] = { | ||
122 | /* EOC goes first */ | ||
123 | [DIRECTIVE_BOOLEAN] = ASN1_BOOL, | ||
124 | [DIRECTIVE_INTEGER] = ASN1_INT, | ||
125 | [DIRECTIVE_BIT] = ASN1_BTS, | ||
126 | [DIRECTIVE_OCTET] = ASN1_OTS, | ||
127 | [DIRECTIVE_NULL] = ASN1_NULL, | ||
128 | [DIRECTIVE_OBJECT] = ASN1_OID, | ||
129 | [DIRECTIVE_ObjectDescriptor] = ASN1_ODE, | ||
130 | [DIRECTIVE_EXTERNAL] = ASN1_EXT, | ||
131 | [DIRECTIVE_REAL] = ASN1_REAL, | ||
132 | [DIRECTIVE_ENUMERATED] = ASN1_ENUM, | ||
133 | [DIRECTIVE_EMBEDDED] = 0, | ||
134 | [DIRECTIVE_UTF8String] = ASN1_UTF8STR, | ||
135 | [DIRECTIVE_RELATIVE_OID] = ASN1_RELOID, | ||
136 | /* 14 */ | ||
137 | /* 15 */ | ||
138 | [DIRECTIVE_SEQUENCE] = ASN1_SEQ, | ||
139 | [DIRECTIVE_SET] = ASN1_SET, | ||
140 | [DIRECTIVE_NumericString] = ASN1_NUMSTR, | ||
141 | [DIRECTIVE_PrintableString] = ASN1_PRNSTR, | ||
142 | [DIRECTIVE_T61String] = ASN1_TEXSTR, | ||
143 | [DIRECTIVE_TeletexString] = ASN1_TEXSTR, | ||
144 | [DIRECTIVE_VideotexString] = ASN1_VIDSTR, | ||
145 | [DIRECTIVE_IA5String] = ASN1_IA5STR, | ||
146 | [DIRECTIVE_UTCTime] = ASN1_UNITIM, | ||
147 | [DIRECTIVE_GeneralizedTime] = ASN1_GENTIM, | ||
148 | [DIRECTIVE_GraphicString] = ASN1_GRASTR, | ||
149 | [DIRECTIVE_VisibleString] = ASN1_VISSTR, | ||
150 | [DIRECTIVE_GeneralString] = ASN1_GENSTR, | ||
151 | [DIRECTIVE_UniversalString] = ASN1_UNITIM, | ||
152 | [DIRECTIVE_CHARACTER] = ASN1_CHRSTR, | ||
153 | [DIRECTIVE_BMPString] = ASN1_BMPSTR, | ||
154 | }; | ||
155 | |||
156 | static const char asn1_classes[4][5] = { | ||
157 | [ASN1_UNIV] = "UNIV", | ||
158 | [ASN1_APPL] = "APPL", | ||
159 | [ASN1_CONT] = "CONT", | ||
160 | [ASN1_PRIV] = "PRIV" | ||
161 | }; | ||
162 | |||
163 | static const char asn1_methods[2][5] = { | ||
164 | [ASN1_UNIV] = "PRIM", | ||
165 | [ASN1_APPL] = "CONS" | ||
166 | }; | ||
167 | |||
168 | static const char *const asn1_universal_tags[32] = { | ||
169 | "EOC", | ||
170 | "BOOL", | ||
171 | "INT", | ||
172 | "BTS", | ||
173 | "OTS", | ||
174 | "NULL", | ||
175 | "OID", | ||
176 | "ODE", | ||
177 | "EXT", | ||
178 | "REAL", | ||
179 | "ENUM", | ||
180 | "EPDV", | ||
181 | "UTF8STR", | ||
182 | "RELOID", | ||
183 | NULL, /* 14 */ | ||
184 | NULL, /* 15 */ | ||
185 | "SEQ", | ||
186 | "SET", | ||
187 | "NUMSTR", | ||
188 | "PRNSTR", | ||
189 | "TEXSTR", | ||
190 | "VIDSTR", | ||
191 | "IA5STR", | ||
192 | "UNITIM", | ||
193 | "GENTIM", | ||
194 | "GRASTR", | ||
195 | "VISSTR", | ||
196 | "GENSTR", | ||
197 | "UNISTR", | ||
198 | "CHRSTR", | ||
199 | "BMPSTR", | ||
200 | NULL /* 31 */ | ||
201 | }; | ||
202 | |||
203 | static const char *filename; | ||
204 | static const char *grammar_name; | ||
205 | static const char *outputname; | ||
206 | static const char *headername; | ||
207 | |||
208 | static const char *const directives[NR__DIRECTIVES] = { | ||
209 | #define _(X) [DIRECTIVE_##X] = #X | ||
210 | _(ABSENT), | ||
211 | _(ALL), | ||
212 | _(ANY), | ||
213 | _(APPLICATION), | ||
214 | _(AUTOMATIC), | ||
215 | _(BEGIN), | ||
216 | _(BIT), | ||
217 | _(BMPString), | ||
218 | _(BOOLEAN), | ||
219 | _(BY), | ||
220 | _(CHARACTER), | ||
221 | _(CHOICE), | ||
222 | _(CLASS), | ||
223 | _(COMPONENT), | ||
224 | _(COMPONENTS), | ||
225 | _(CONSTRAINED), | ||
226 | _(CONTAINING), | ||
227 | _(DEFAULT), | ||
228 | _(DEFINED), | ||
229 | _(DEFINITIONS), | ||
230 | _(EMBEDDED), | ||
231 | _(ENCODED), | ||
232 | [DIRECTIVE_ENCODING_CONTROL] = "ENCODING-CONTROL", | ||
233 | _(END), | ||
234 | _(ENUMERATED), | ||
235 | _(EXCEPT), | ||
236 | _(EXPLICIT), | ||
237 | _(EXPORTS), | ||
238 | _(EXTENSIBILITY), | ||
239 | _(EXTERNAL), | ||
240 | _(FALSE), | ||
241 | _(FROM), | ||
242 | _(GeneralString), | ||
243 | _(GeneralizedTime), | ||
244 | _(GraphicString), | ||
245 | _(IA5String), | ||
246 | _(IDENTIFIER), | ||
247 | _(IMPLICIT), | ||
248 | _(IMPLIED), | ||
249 | _(IMPORTS), | ||
250 | _(INCLUDES), | ||
251 | _(INSTANCE), | ||
252 | _(INSTRUCTIONS), | ||
253 | _(INTEGER), | ||
254 | _(INTERSECTION), | ||
255 | _(ISO646String), | ||
256 | _(MAX), | ||
257 | _(MIN), | ||
258 | [DIRECTIVE_MINUS_INFINITY] = "MINUS-INFINITY", | ||
259 | [DIRECTIVE_NULL] = "NULL", | ||
260 | _(NumericString), | ||
261 | _(OBJECT), | ||
262 | _(OCTET), | ||
263 | _(OF), | ||
264 | _(OPTIONAL), | ||
265 | _(ObjectDescriptor), | ||
266 | _(PATTERN), | ||
267 | _(PDV), | ||
268 | [DIRECTIVE_PLUS_INFINITY] = "PLUS-INFINITY", | ||
269 | _(PRESENT), | ||
270 | _(PRIVATE), | ||
271 | _(PrintableString), | ||
272 | _(REAL), | ||
273 | [DIRECTIVE_RELATIVE_OID] = "RELATIVE-OID", | ||
274 | _(SEQUENCE), | ||
275 | _(SET), | ||
276 | _(SIZE), | ||
277 | _(STRING), | ||
278 | _(SYNTAX), | ||
279 | _(T61String), | ||
280 | _(TAGS), | ||
281 | _(TRUE), | ||
282 | _(TeletexString), | ||
283 | _(UNION), | ||
284 | _(UNIQUE), | ||
285 | _(UNIVERSAL), | ||
286 | _(UTCTime), | ||
287 | _(UTF8String), | ||
288 | _(UniversalString), | ||
289 | _(VideotexString), | ||
290 | _(VisibleString), | ||
291 | _(WITH) | ||
292 | }; | ||
293 | |||
294 | struct action { | ||
295 | struct action *next; | ||
296 | unsigned char index; | ||
297 | char name[]; | ||
298 | }; | ||
299 | |||
300 | static struct action *action_list; | ||
301 | static unsigned nr_actions; | ||
302 | |||
303 | struct token { | ||
304 | unsigned short line; | ||
305 | enum token_type token_type : 8; | ||
306 | unsigned char size; | ||
307 | struct action *action; | ||
308 | const char *value; | ||
309 | struct type *type; | ||
310 | }; | ||
311 | |||
312 | static struct token *token_list; | ||
313 | static unsigned nr_tokens; | ||
314 | |||
315 | static int directive_compare(const void *_key, const void *_pdir) | ||
316 | { | ||
317 | const struct token *token = _key; | ||
318 | const char *const *pdir = _pdir, *dir = *pdir; | ||
319 | size_t dlen, clen; | ||
320 | int val; | ||
321 | |||
322 | dlen = strlen(dir); | ||
323 | clen = (dlen < token->size) ? dlen : token->size; | ||
324 | |||
325 | //printf("cmp(%*.*s,%s) = ", | ||
326 | // (int)token->size, (int)token->size, token->value, | ||
327 | // dir); | ||
328 | |||
329 | val = memcmp(token->value, dir, clen); | ||
330 | if (val != 0) { | ||
331 | //printf("%d [cmp]\n", val); | ||
332 | return val; | ||
333 | } | ||
334 | |||
335 | if (dlen == token->size) { | ||
336 | //printf("0\n"); | ||
337 | return 0; | ||
338 | } | ||
339 | //printf("%d\n", (int)dlen - (int)token->size); | ||
340 | return dlen - token->size; /* shorter -> negative */ | ||
341 | } | ||
342 | |||
343 | /* | ||
344 | * Tokenise an ASN.1 grammar | ||
345 | */ | ||
346 | static void tokenise(char *buffer, char *end) | ||
347 | { | ||
348 | struct token *tokens; | ||
349 | char *line, *nl, *p, *q; | ||
350 | unsigned tix, lineno; | ||
351 | |||
352 | /* Assume we're going to have half as many tokens as we have | ||
353 | * characters | ||
354 | */ | ||
355 | token_list = tokens = calloc((end - buffer) / 2, sizeof(struct token)); | ||
356 | if (!tokens) { | ||
357 | perror(NULL); | ||
358 | exit(1); | ||
359 | } | ||
360 | tix = 0; | ||
361 | |||
362 | lineno = 0; | ||
363 | while (buffer < end) { | ||
364 | /* First of all, break out a line */ | ||
365 | lineno++; | ||
366 | line = buffer; | ||
367 | nl = memchr(line, '\n', end - buffer); | ||
368 | if (!nl) { | ||
369 | buffer = nl = end; | ||
370 | } else { | ||
371 | buffer = nl + 1; | ||
372 | *nl = '\0'; | ||
373 | } | ||
374 | |||
375 | /* Remove "--" comments */ | ||
376 | p = line; | ||
377 | next_comment: | ||
378 | while ((p = memchr(p, '-', nl - p))) { | ||
379 | if (p[1] == '-') { | ||
380 | /* Found a comment; see if there's a terminator */ | ||
381 | q = p + 2; | ||
382 | while ((q = memchr(q, '-', nl - q))) { | ||
383 | if (q[1] == '-') { | ||
384 | /* There is - excise the comment */ | ||
385 | q += 2; | ||
386 | memmove(p, q, nl - q); | ||
387 | goto next_comment; | ||
388 | } | ||
389 | q++; | ||
390 | } | ||
391 | *p = '\0'; | ||
392 | nl = p; | ||
393 | break; | ||
394 | } else { | ||
395 | p++; | ||
396 | } | ||
397 | } | ||
398 | |||
399 | p = line; | ||
400 | while (p < nl) { | ||
401 | /* Skip white space */ | ||
402 | while (p < nl && isspace(*p)) | ||
403 | *(p++) = 0; | ||
404 | if (p >= nl) | ||
405 | break; | ||
406 | |||
407 | tokens[tix].line = lineno; | ||
408 | tokens[tix].value = p; | ||
409 | |||
410 | /* Handle string tokens */ | ||
411 | if (isalpha(*p)) { | ||
412 | const char **dir; | ||
413 | |||
414 | /* Can be a directive, type name or element | ||
415 | * name. Find the end of the name. | ||
416 | */ | ||
417 | q = p + 1; | ||
418 | while (q < nl && (isalnum(*q) || *q == '-' || *q == '_')) | ||
419 | q++; | ||
420 | tokens[tix].size = q - p; | ||
421 | p = q; | ||
422 | |||
423 | /* If it begins with a lowercase letter then | ||
424 | * it's an element name | ||
425 | */ | ||
426 | if (islower(tokens[tix].value[0])) { | ||
427 | tokens[tix++].token_type = TOKEN_ELEMENT_NAME; | ||
428 | continue; | ||
429 | } | ||
430 | |||
431 | /* Otherwise we need to search the directive | ||
432 | * table | ||
433 | */ | ||
434 | dir = bsearch(&tokens[tix], directives, | ||
435 | sizeof(directives) / sizeof(directives[1]), | ||
436 | sizeof(directives[1]), | ||
437 | directive_compare); | ||
438 | if (dir) { | ||
439 | tokens[tix++].token_type = dir - directives; | ||
440 | continue; | ||
441 | } | ||
442 | |||
443 | tokens[tix++].token_type = TOKEN_TYPE_NAME; | ||
444 | continue; | ||
445 | } | ||
446 | |||
447 | /* Handle numbers */ | ||
448 | if (isdigit(*p)) { | ||
449 | /* Find the end of the number */ | ||
450 | q = p + 1; | ||
451 | while (q < nl && (isdigit(*q))) | ||
452 | q++; | ||
453 | tokens[tix].size = q - p; | ||
454 | p = q; | ||
455 | tokens[tix++].token_type = TOKEN_NUMBER; | ||
456 | continue; | ||
457 | } | ||
458 | |||
459 | if (nl - p >= 3) { | ||
460 | if (memcmp(p, "::=", 3) == 0) { | ||
461 | p += 3; | ||
462 | tokens[tix].size = 3; | ||
463 | tokens[tix++].token_type = TOKEN_ASSIGNMENT; | ||
464 | continue; | ||
465 | } | ||
466 | } | ||
467 | |||
468 | if (nl - p >= 2) { | ||
469 | if (memcmp(p, "({", 2) == 0) { | ||
470 | p += 2; | ||
471 | tokens[tix].size = 2; | ||
472 | tokens[tix++].token_type = TOKEN_OPEN_ACTION; | ||
473 | continue; | ||
474 | } | ||
475 | if (memcmp(p, "})", 2) == 0) { | ||
476 | p += 2; | ||
477 | tokens[tix].size = 2; | ||
478 | tokens[tix++].token_type = TOKEN_CLOSE_ACTION; | ||
479 | continue; | ||
480 | } | ||
481 | } | ||
482 | |||
483 | if (nl - p >= 1) { | ||
484 | tokens[tix].size = 1; | ||
485 | switch (*p) { | ||
486 | case '{': | ||
487 | p += 1; | ||
488 | tokens[tix++].token_type = TOKEN_OPEN_CURLY; | ||
489 | continue; | ||
490 | case '}': | ||
491 | p += 1; | ||
492 | tokens[tix++].token_type = TOKEN_CLOSE_CURLY; | ||
493 | continue; | ||
494 | case '[': | ||
495 | p += 1; | ||
496 | tokens[tix++].token_type = TOKEN_OPEN_SQUARE; | ||
497 | continue; | ||
498 | case ']': | ||
499 | p += 1; | ||
500 | tokens[tix++].token_type = TOKEN_CLOSE_SQUARE; | ||
501 | continue; | ||
502 | case ',': | ||
503 | p += 1; | ||
504 | tokens[tix++].token_type = TOKEN_COMMA; | ||
505 | continue; | ||
506 | default: | ||
507 | break; | ||
508 | } | ||
509 | } | ||
510 | |||
511 | fprintf(stderr, "%s:%u: Unknown character in grammar: '%c'\n", | ||
512 | filename, lineno, *p); | ||
513 | exit(1); | ||
514 | } | ||
515 | } | ||
516 | |||
517 | nr_tokens = tix; | ||
518 | printf("Extracted %u tokens\n", nr_tokens); | ||
519 | |||
520 | #if 0 | ||
521 | { | ||
522 | int n; | ||
523 | for (n = 0; n < nr_tokens; n++) | ||
524 | printf("Token %3u: '%*.*s'\n", | ||
525 | n, | ||
526 | (int)token_list[n].size, (int)token_list[n].size, | ||
527 | token_list[n].value); | ||
528 | } | ||
529 | #endif | ||
530 | } | ||
531 | |||
532 | static void build_type_list(void); | ||
533 | static void parse(void); | ||
534 | static void render(FILE *out, FILE *hdr); | ||
535 | |||
536 | /* | ||
537 | * | ||
538 | */ | ||
539 | int main(int argc, char **argv) | ||
540 | { | ||
541 | struct stat st; | ||
542 | ssize_t readlen; | ||
543 | FILE *out, *hdr; | ||
544 | char *buffer, *p; | ||
545 | int fd; | ||
546 | |||
547 | if (argc != 4) { | ||
548 | fprintf(stderr, "Format: %s <grammar-file> <c-file> <hdr-file>\n", | ||
549 | argv[0]); | ||
550 | exit(2); | ||
551 | } | ||
552 | |||
553 | filename = argv[1]; | ||
554 | outputname = argv[2]; | ||
555 | headername = argv[3]; | ||
556 | |||
557 | fd = open(filename, O_RDONLY); | ||
558 | if (fd < 0) { | ||
559 | perror(filename); | ||
560 | exit(1); | ||
561 | } | ||
562 | |||
563 | if (fstat(fd, &st) < 0) { | ||
564 | perror(filename); | ||
565 | exit(1); | ||
566 | } | ||
567 | |||
568 | if (!(buffer = malloc(st.st_size + 1))) { | ||
569 | perror(NULL); | ||
570 | exit(1); | ||
571 | } | ||
572 | |||
573 | if ((readlen = read(fd, buffer, st.st_size)) < 0) { | ||
574 | perror(filename); | ||
575 | exit(1); | ||
576 | } | ||
577 | |||
578 | if (close(fd) < 0) { | ||
579 | perror(filename); | ||
580 | exit(1); | ||
581 | } | ||
582 | |||
583 | if (readlen != st.st_size) { | ||
584 | fprintf(stderr, "%s: Short read\n", filename); | ||
585 | exit(1); | ||
586 | } | ||
587 | |||
588 | p = strrchr(argv[1], '/'); | ||
589 | p = p ? p + 1 : argv[1]; | ||
590 | grammar_name = strdup(p); | ||
591 | if (!p) { | ||
592 | perror(NULL); | ||
593 | exit(1); | ||
594 | } | ||
595 | p = strchr(grammar_name, '.'); | ||
596 | if (p) | ||
597 | *p = '\0'; | ||
598 | |||
599 | buffer[readlen] = 0; | ||
600 | tokenise(buffer, buffer + readlen); | ||
601 | build_type_list(); | ||
602 | parse(); | ||
603 | |||
604 | out = fopen(outputname, "w"); | ||
605 | if (!out) { | ||
606 | perror(outputname); | ||
607 | exit(1); | ||
608 | } | ||
609 | |||
610 | hdr = fopen(headername, "w"); | ||
611 | if (!out) { | ||
612 | perror(headername); | ||
613 | exit(1); | ||
614 | } | ||
615 | |||
616 | render(out, hdr); | ||
617 | |||
618 | if (fclose(out) < 0) { | ||
619 | perror(outputname); | ||
620 | exit(1); | ||
621 | } | ||
622 | |||
623 | if (fclose(hdr) < 0) { | ||
624 | perror(headername); | ||
625 | exit(1); | ||
626 | } | ||
627 | |||
628 | return 0; | ||
629 | } | ||
630 | |||
631 | enum compound { | ||
632 | NOT_COMPOUND, | ||
633 | SET, | ||
634 | SET_OF, | ||
635 | SEQUENCE, | ||
636 | SEQUENCE_OF, | ||
637 | CHOICE, | ||
638 | ANY, | ||
639 | TYPE_REF, | ||
640 | TAG_OVERRIDE | ||
641 | }; | ||
642 | |||
643 | struct element { | ||
644 | struct type *type_def; | ||
645 | struct token *name; | ||
646 | struct token *type; | ||
647 | struct action *action; | ||
648 | struct element *children; | ||
649 | struct element *next; | ||
650 | struct element *render_next; | ||
651 | struct element *list_next; | ||
652 | uint8_t n_elements; | ||
653 | enum compound compound : 8; | ||
654 | enum asn1_class class : 8; | ||
655 | enum asn1_method method : 8; | ||
656 | uint8_t tag; | ||
657 | unsigned entry_index; | ||
658 | unsigned flags; | ||
659 | #define ELEMENT_IMPLICIT 0x0001 | ||
660 | #define ELEMENT_EXPLICIT 0x0002 | ||
661 | #define ELEMENT_MARKED 0x0004 | ||
662 | #define ELEMENT_RENDERED 0x0008 | ||
663 | #define ELEMENT_SKIPPABLE 0x0010 | ||
664 | #define ELEMENT_CONDITIONAL 0x0020 | ||
665 | }; | ||
666 | |||
667 | struct type { | ||
668 | struct token *name; | ||
669 | struct token *def; | ||
670 | struct element *element; | ||
671 | unsigned ref_count; | ||
672 | unsigned flags; | ||
673 | #define TYPE_STOP_MARKER 0x0001 | ||
674 | #define TYPE_BEGIN 0x0002 | ||
675 | }; | ||
676 | |||
677 | static struct type *type_list; | ||
678 | static struct type **type_index; | ||
679 | static unsigned nr_types; | ||
680 | |||
681 | static int type_index_compare(const void *_a, const void *_b) | ||
682 | { | ||
683 | const struct type *const *a = _a, *const *b = _b; | ||
684 | |||
685 | if ((*a)->name->size != (*b)->name->size) | ||
686 | return (*a)->name->size - (*b)->name->size; | ||
687 | else | ||
688 | return memcmp((*a)->name->value, (*b)->name->value, | ||
689 | (*a)->name->size); | ||
690 | } | ||
691 | |||
692 | static int type_finder(const void *_key, const void *_ti) | ||
693 | { | ||
694 | const struct token *token = _key; | ||
695 | const struct type *const *ti = _ti; | ||
696 | const struct type *type = *ti; | ||
697 | |||
698 | if (token->size != type->name->size) | ||
699 | return token->size - type->name->size; | ||
700 | else | ||
701 | return memcmp(token->value, type->name->value, | ||
702 | token->size); | ||
703 | } | ||
704 | |||
705 | /* | ||
706 | * Build up a list of types and a sorted index to that list. | ||
707 | */ | ||
708 | static void build_type_list(void) | ||
709 | { | ||
710 | struct type *types; | ||
711 | unsigned nr, t, n; | ||
712 | |||
713 | nr = 0; | ||
714 | for (n = 0; n < nr_tokens - 1; n++) | ||
715 | if (token_list[n + 0].token_type == TOKEN_TYPE_NAME && | ||
716 | token_list[n + 1].token_type == TOKEN_ASSIGNMENT) | ||
717 | nr++; | ||
718 | |||
719 | if (nr == 0) { | ||
720 | fprintf(stderr, "%s: No defined types\n", filename); | ||
721 | exit(1); | ||
722 | } | ||
723 | |||
724 | nr_types = nr; | ||
725 | types = type_list = calloc(nr + 1, sizeof(type_list[0])); | ||
726 | if (!type_list) { | ||
727 | perror(NULL); | ||
728 | exit(1); | ||
729 | } | ||
730 | type_index = calloc(nr, sizeof(type_index[0])); | ||
731 | if (!type_index) { | ||
732 | perror(NULL); | ||
733 | exit(1); | ||
734 | } | ||
735 | |||
736 | t = 0; | ||
737 | types[t].flags |= TYPE_BEGIN; | ||
738 | for (n = 0; n < nr_tokens - 1; n++) { | ||
739 | if (token_list[n + 0].token_type == TOKEN_TYPE_NAME && | ||
740 | token_list[n + 1].token_type == TOKEN_ASSIGNMENT) { | ||
741 | types[t].name = &token_list[n]; | ||
742 | type_index[t] = &types[t]; | ||
743 | t++; | ||
744 | } | ||
745 | } | ||
746 | types[t].name = &token_list[n + 1]; | ||
747 | types[t].flags |= TYPE_STOP_MARKER; | ||
748 | |||
749 | qsort(type_index, nr, sizeof(type_index[0]), type_index_compare); | ||
750 | |||
751 | printf("Extracted %u types\n", nr_types); | ||
752 | #if 0 | ||
753 | for (n = 0; n < nr_types; n++) { | ||
754 | struct type *type = type_index[n]; | ||
755 | printf("- %*.*s\n", | ||
756 | (int)type->name->size, | ||
757 | (int)type->name->size, | ||
758 | type->name->value); | ||
759 | } | ||
760 | #endif | ||
761 | } | ||
762 | |||
763 | static struct element *parse_type(struct token **_cursor, struct token *stop, | ||
764 | struct token *name); | ||
765 | |||
766 | /* | ||
767 | * Parse the token stream | ||
768 | */ | ||
769 | static void parse(void) | ||
770 | { | ||
771 | struct token *cursor; | ||
772 | struct type *type; | ||
773 | |||
774 | /* Parse one type definition statement at a time */ | ||
775 | type = type_list; | ||
776 | do { | ||
777 | cursor = type->name; | ||
778 | |||
779 | if (cursor[0].token_type != TOKEN_TYPE_NAME || | ||
780 | cursor[1].token_type != TOKEN_ASSIGNMENT) | ||
781 | abort(); | ||
782 | cursor += 2; | ||
783 | |||
784 | type->element = parse_type(&cursor, type[1].name, NULL); | ||
785 | type->element->type_def = type; | ||
786 | |||
787 | if (cursor != type[1].name) { | ||
788 | fprintf(stderr, "%s:%d: Parse error at token '%*.*s'\n", | ||
789 | filename, cursor->line, | ||
790 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
791 | exit(1); | ||
792 | } | ||
793 | |||
794 | } while (type++, !(type->flags & TYPE_STOP_MARKER)); | ||
795 | |||
796 | printf("Extracted %u actions\n", nr_actions); | ||
797 | } | ||
798 | |||
799 | static struct element *element_list; | ||
800 | |||
801 | static struct element *alloc_elem(struct token *type) | ||
802 | { | ||
803 | struct element *e = calloc(1, sizeof(*e)); | ||
804 | if (!e) { | ||
805 | perror(NULL); | ||
806 | exit(1); | ||
807 | } | ||
808 | e->list_next = element_list; | ||
809 | element_list = e; | ||
810 | return e; | ||
811 | } | ||
812 | |||
813 | static struct element *parse_compound(struct token **_cursor, struct token *end, | ||
814 | int alternates); | ||
815 | |||
816 | /* | ||
817 | * Parse one type definition statement | ||
818 | */ | ||
819 | static struct element *parse_type(struct token **_cursor, struct token *end, | ||
820 | struct token *name) | ||
821 | { | ||
822 | struct element *top, *element; | ||
823 | struct action *action, **ppaction; | ||
824 | struct token *cursor = *_cursor; | ||
825 | struct type **ref; | ||
826 | char *p; | ||
827 | int labelled = 0, implicit = 0; | ||
828 | |||
829 | top = element = alloc_elem(cursor); | ||
830 | element->class = ASN1_UNIV; | ||
831 | element->method = ASN1_PRIM; | ||
832 | element->tag = token_to_tag[cursor->token_type]; | ||
833 | element->name = name; | ||
834 | |||
835 | /* Extract the tag value if one given */ | ||
836 | if (cursor->token_type == TOKEN_OPEN_SQUARE) { | ||
837 | cursor++; | ||
838 | if (cursor >= end) | ||
839 | goto overrun_error; | ||
840 | switch (cursor->token_type) { | ||
841 | case DIRECTIVE_UNIVERSAL: | ||
842 | element->class = ASN1_UNIV; | ||
843 | cursor++; | ||
844 | break; | ||
845 | case DIRECTIVE_APPLICATION: | ||
846 | element->class = ASN1_APPL; | ||
847 | cursor++; | ||
848 | break; | ||
849 | case TOKEN_NUMBER: | ||
850 | element->class = ASN1_CONT; | ||
851 | break; | ||
852 | case DIRECTIVE_PRIVATE: | ||
853 | element->class = ASN1_PRIV; | ||
854 | cursor++; | ||
855 | break; | ||
856 | default: | ||
857 | fprintf(stderr, "%s:%d: Unrecognised tag class token '%*.*s'\n", | ||
858 | filename, cursor->line, | ||
859 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
860 | exit(1); | ||
861 | } | ||
862 | |||
863 | if (cursor >= end) | ||
864 | goto overrun_error; | ||
865 | if (cursor->token_type != TOKEN_NUMBER) { | ||
866 | fprintf(stderr, "%s:%d: Missing tag number '%*.*s'\n", | ||
867 | filename, cursor->line, | ||
868 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
869 | exit(1); | ||
870 | } | ||
871 | |||
872 | element->tag &= ~0x1f; | ||
873 | element->tag |= strtoul(cursor->value, &p, 10); | ||
874 | if (p - cursor->value != cursor->size) | ||
875 | abort(); | ||
876 | cursor++; | ||
877 | |||
878 | if (cursor >= end) | ||
879 | goto overrun_error; | ||
880 | if (cursor->token_type != TOKEN_CLOSE_SQUARE) { | ||
881 | fprintf(stderr, "%s:%d: Missing closing square bracket '%*.*s'\n", | ||
882 | filename, cursor->line, | ||
883 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
884 | exit(1); | ||
885 | } | ||
886 | cursor++; | ||
887 | if (cursor >= end) | ||
888 | goto overrun_error; | ||
889 | labelled = 1; | ||
890 | } | ||
891 | |||
892 | /* Handle implicit and explicit markers */ | ||
893 | if (cursor->token_type == DIRECTIVE_IMPLICIT) { | ||
894 | element->flags |= ELEMENT_IMPLICIT; | ||
895 | implicit = 1; | ||
896 | cursor++; | ||
897 | if (cursor >= end) | ||
898 | goto overrun_error; | ||
899 | } else if (cursor->token_type == DIRECTIVE_EXPLICIT) { | ||
900 | element->flags |= ELEMENT_EXPLICIT; | ||
901 | cursor++; | ||
902 | if (cursor >= end) | ||
903 | goto overrun_error; | ||
904 | } | ||
905 | |||
906 | if (labelled) { | ||
907 | if (!implicit) | ||
908 | element->method |= ASN1_CONS; | ||
909 | element->compound = implicit ? TAG_OVERRIDE : SEQUENCE; | ||
910 | element->children = alloc_elem(cursor); | ||
911 | element = element->children; | ||
912 | element->class = ASN1_UNIV; | ||
913 | element->method = ASN1_PRIM; | ||
914 | element->tag = token_to_tag[cursor->token_type]; | ||
915 | element->name = name; | ||
916 | } | ||
917 | |||
918 | /* Extract the type we're expecting here */ | ||
919 | element->type = cursor; | ||
920 | switch (cursor->token_type) { | ||
921 | case DIRECTIVE_ANY: | ||
922 | element->compound = ANY; | ||
923 | cursor++; | ||
924 | break; | ||
925 | |||
926 | case DIRECTIVE_NULL: | ||
927 | case DIRECTIVE_BOOLEAN: | ||
928 | case DIRECTIVE_ENUMERATED: | ||
929 | case DIRECTIVE_INTEGER: | ||
930 | element->compound = NOT_COMPOUND; | ||
931 | cursor++; | ||
932 | break; | ||
933 | |||
934 | case DIRECTIVE_EXTERNAL: | ||
935 | element->method = ASN1_CONS; | ||
936 | |||
937 | case DIRECTIVE_BMPString: | ||
938 | case DIRECTIVE_GeneralString: | ||
939 | case DIRECTIVE_GraphicString: | ||
940 | case DIRECTIVE_IA5String: | ||
941 | case DIRECTIVE_ISO646String: | ||
942 | case DIRECTIVE_NumericString: | ||
943 | case DIRECTIVE_PrintableString: | ||
944 | case DIRECTIVE_T61String: | ||
945 | case DIRECTIVE_TeletexString: | ||
946 | case DIRECTIVE_UniversalString: | ||
947 | case DIRECTIVE_UTF8String: | ||
948 | case DIRECTIVE_VideotexString: | ||
949 | case DIRECTIVE_VisibleString: | ||
950 | case DIRECTIVE_ObjectDescriptor: | ||
951 | case DIRECTIVE_GeneralizedTime: | ||
952 | case DIRECTIVE_UTCTime: | ||
953 | element->compound = NOT_COMPOUND; | ||
954 | cursor++; | ||
955 | break; | ||
956 | |||
957 | case DIRECTIVE_BIT: | ||
958 | case DIRECTIVE_OCTET: | ||
959 | element->compound = NOT_COMPOUND; | ||
960 | cursor++; | ||
961 | if (cursor >= end) | ||
962 | goto overrun_error; | ||
963 | if (cursor->token_type != DIRECTIVE_STRING) | ||
964 | goto parse_error; | ||
965 | cursor++; | ||
966 | break; | ||
967 | |||
968 | case DIRECTIVE_OBJECT: | ||
969 | element->compound = NOT_COMPOUND; | ||
970 | cursor++; | ||
971 | if (cursor >= end) | ||
972 | goto overrun_error; | ||
973 | if (cursor->token_type != DIRECTIVE_IDENTIFIER) | ||
974 | goto parse_error; | ||
975 | cursor++; | ||
976 | break; | ||
977 | |||
978 | case TOKEN_TYPE_NAME: | ||
979 | element->compound = TYPE_REF; | ||
980 | ref = bsearch(cursor, type_index, nr_types, sizeof(type_index[0]), | ||
981 | type_finder); | ||
982 | if (!ref) { | ||
983 | fprintf(stderr, "%s:%d: Type '%*.*s' undefined\n", | ||
984 | filename, cursor->line, | ||
985 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
986 | exit(1); | ||
987 | } | ||
988 | cursor->type = *ref; | ||
989 | (*ref)->ref_count++; | ||
990 | cursor++; | ||
991 | break; | ||
992 | |||
993 | case DIRECTIVE_CHOICE: | ||
994 | element->compound = CHOICE; | ||
995 | cursor++; | ||
996 | element->children = parse_compound(&cursor, end, 1); | ||
997 | break; | ||
998 | |||
999 | case DIRECTIVE_SEQUENCE: | ||
1000 | element->compound = SEQUENCE; | ||
1001 | element->method = ASN1_CONS; | ||
1002 | cursor++; | ||
1003 | if (cursor >= end) | ||
1004 | goto overrun_error; | ||
1005 | if (cursor->token_type == DIRECTIVE_OF) { | ||
1006 | element->compound = SEQUENCE_OF; | ||
1007 | cursor++; | ||
1008 | if (cursor >= end) | ||
1009 | goto overrun_error; | ||
1010 | element->children = parse_type(&cursor, end, NULL); | ||
1011 | } else { | ||
1012 | element->children = parse_compound(&cursor, end, 0); | ||
1013 | } | ||
1014 | break; | ||
1015 | |||
1016 | case DIRECTIVE_SET: | ||
1017 | element->compound = SET; | ||
1018 | element->method = ASN1_CONS; | ||
1019 | cursor++; | ||
1020 | if (cursor >= end) | ||
1021 | goto overrun_error; | ||
1022 | if (cursor->token_type == DIRECTIVE_OF) { | ||
1023 | element->compound = SET_OF; | ||
1024 | cursor++; | ||
1025 | if (cursor >= end) | ||
1026 | goto parse_error; | ||
1027 | element->children = parse_type(&cursor, end, NULL); | ||
1028 | } else { | ||
1029 | element->children = parse_compound(&cursor, end, 1); | ||
1030 | } | ||
1031 | break; | ||
1032 | |||
1033 | default: | ||
1034 | fprintf(stderr, "%s:%d: Token '%*.*s' does not introduce a type\n", | ||
1035 | filename, cursor->line, | ||
1036 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1037 | exit(1); | ||
1038 | } | ||
1039 | |||
1040 | /* Handle elements that are optional */ | ||
1041 | if (cursor < end && (cursor->token_type == DIRECTIVE_OPTIONAL || | ||
1042 | cursor->token_type == DIRECTIVE_DEFAULT) | ||
1043 | ) { | ||
1044 | cursor++; | ||
1045 | top->flags |= ELEMENT_SKIPPABLE; | ||
1046 | } | ||
1047 | |||
1048 | if (cursor < end && cursor->token_type == TOKEN_OPEN_ACTION) { | ||
1049 | cursor++; | ||
1050 | if (cursor >= end) | ||
1051 | goto overrun_error; | ||
1052 | if (cursor->token_type != TOKEN_ELEMENT_NAME) { | ||
1053 | fprintf(stderr, "%s:%d: Token '%*.*s' is not an action function name\n", | ||
1054 | filename, cursor->line, | ||
1055 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1056 | exit(1); | ||
1057 | } | ||
1058 | |||
1059 | action = malloc(sizeof(struct action) + cursor->size + 1); | ||
1060 | if (!action) { | ||
1061 | perror(NULL); | ||
1062 | exit(1); | ||
1063 | } | ||
1064 | action->index = 0; | ||
1065 | memcpy(action->name, cursor->value, cursor->size); | ||
1066 | action->name[cursor->size] = 0; | ||
1067 | |||
1068 | for (ppaction = &action_list; | ||
1069 | *ppaction; | ||
1070 | ppaction = &(*ppaction)->next | ||
1071 | ) { | ||
1072 | int cmp = strcmp(action->name, (*ppaction)->name); | ||
1073 | if (cmp == 0) { | ||
1074 | free(action); | ||
1075 | action = *ppaction; | ||
1076 | goto found; | ||
1077 | } | ||
1078 | if (cmp < 0) { | ||
1079 | action->next = *ppaction; | ||
1080 | *ppaction = action; | ||
1081 | nr_actions++; | ||
1082 | goto found; | ||
1083 | } | ||
1084 | } | ||
1085 | action->next = NULL; | ||
1086 | *ppaction = action; | ||
1087 | nr_actions++; | ||
1088 | found: | ||
1089 | |||
1090 | element->action = action; | ||
1091 | cursor->action = action; | ||
1092 | cursor++; | ||
1093 | if (cursor >= end) | ||
1094 | goto overrun_error; | ||
1095 | if (cursor->token_type != TOKEN_CLOSE_ACTION) { | ||
1096 | fprintf(stderr, "%s:%d: Missing close action, got '%*.*s'\n", | ||
1097 | filename, cursor->line, | ||
1098 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1099 | exit(1); | ||
1100 | } | ||
1101 | cursor++; | ||
1102 | } | ||
1103 | |||
1104 | *_cursor = cursor; | ||
1105 | return top; | ||
1106 | |||
1107 | parse_error: | ||
1108 | fprintf(stderr, "%s:%d: Unexpected token '%*.*s'\n", | ||
1109 | filename, cursor->line, | ||
1110 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1111 | exit(1); | ||
1112 | |||
1113 | overrun_error: | ||
1114 | fprintf(stderr, "%s: Unexpectedly hit EOF\n", filename); | ||
1115 | exit(1); | ||
1116 | } | ||
1117 | |||
1118 | /* | ||
1119 | * Parse a compound type list | ||
1120 | */ | ||
1121 | static struct element *parse_compound(struct token **_cursor, struct token *end, | ||
1122 | int alternates) | ||
1123 | { | ||
1124 | struct element *children, **child_p = &children, *element; | ||
1125 | struct token *cursor = *_cursor, *name; | ||
1126 | |||
1127 | if (cursor->token_type != TOKEN_OPEN_CURLY) { | ||
1128 | fprintf(stderr, "%s:%d: Expected compound to start with brace not '%*.*s'\n", | ||
1129 | filename, cursor->line, | ||
1130 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1131 | exit(1); | ||
1132 | } | ||
1133 | cursor++; | ||
1134 | if (cursor >= end) | ||
1135 | goto overrun_error; | ||
1136 | |||
1137 | if (cursor->token_type == TOKEN_OPEN_CURLY) { | ||
1138 | fprintf(stderr, "%s:%d: Empty compound\n", | ||
1139 | filename, cursor->line); | ||
1140 | exit(1); | ||
1141 | } | ||
1142 | |||
1143 | for (;;) { | ||
1144 | name = NULL; | ||
1145 | if (cursor->token_type == TOKEN_ELEMENT_NAME) { | ||
1146 | name = cursor; | ||
1147 | cursor++; | ||
1148 | if (cursor >= end) | ||
1149 | goto overrun_error; | ||
1150 | } | ||
1151 | |||
1152 | element = parse_type(&cursor, end, name); | ||
1153 | if (alternates) | ||
1154 | element->flags |= ELEMENT_SKIPPABLE | ELEMENT_CONDITIONAL; | ||
1155 | |||
1156 | *child_p = element; | ||
1157 | child_p = &element->next; | ||
1158 | |||
1159 | if (cursor >= end) | ||
1160 | goto overrun_error; | ||
1161 | if (cursor->token_type != TOKEN_COMMA) | ||
1162 | break; | ||
1163 | cursor++; | ||
1164 | if (cursor >= end) | ||
1165 | goto overrun_error; | ||
1166 | } | ||
1167 | |||
1168 | children->flags &= ~ELEMENT_CONDITIONAL; | ||
1169 | |||
1170 | if (cursor->token_type != TOKEN_CLOSE_CURLY) { | ||
1171 | fprintf(stderr, "%s:%d: Expected compound closure, got '%*.*s'\n", | ||
1172 | filename, cursor->line, | ||
1173 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1174 | exit(1); | ||
1175 | } | ||
1176 | cursor++; | ||
1177 | |||
1178 | *_cursor = cursor; | ||
1179 | return children; | ||
1180 | |||
1181 | overrun_error: | ||
1182 | fprintf(stderr, "%s: Unexpectedly hit EOF\n", filename); | ||
1183 | exit(1); | ||
1184 | } | ||
1185 | |||
1186 | static void render_element(FILE *out, struct element *e, struct element *tag); | ||
1187 | static void render_out_of_line_list(FILE *out); | ||
1188 | |||
1189 | static int nr_entries; | ||
1190 | static int render_depth = 1; | ||
1191 | static struct element *render_list, **render_list_p = &render_list; | ||
1192 | |||
1193 | __attribute__((format(printf, 2, 3))) | ||
1194 | static void render_opcode(FILE *out, const char *fmt, ...) | ||
1195 | { | ||
1196 | va_list va; | ||
1197 | |||
1198 | if (out) { | ||
1199 | fprintf(out, "\t[%4d] =%*s", nr_entries, render_depth, ""); | ||
1200 | va_start(va, fmt); | ||
1201 | vfprintf(out, fmt, va); | ||
1202 | va_end(va); | ||
1203 | } | ||
1204 | nr_entries++; | ||
1205 | } | ||
1206 | |||
1207 | __attribute__((format(printf, 2, 3))) | ||
1208 | static void render_more(FILE *out, const char *fmt, ...) | ||
1209 | { | ||
1210 | va_list va; | ||
1211 | |||
1212 | if (out) { | ||
1213 | va_start(va, fmt); | ||
1214 | vfprintf(out, fmt, va); | ||
1215 | va_end(va); | ||
1216 | } | ||
1217 | } | ||
1218 | |||
1219 | /* | ||
1220 | * Render the grammar into a state machine definition. | ||
1221 | */ | ||
1222 | static void render(FILE *out, FILE *hdr) | ||
1223 | { | ||
1224 | struct element *e; | ||
1225 | struct action *action; | ||
1226 | struct type *root; | ||
1227 | int index; | ||
1228 | |||
1229 | fprintf(hdr, "/*\n"); | ||
1230 | fprintf(hdr, " * Automatically generated by asn1_compiler. Do not edit\n"); | ||
1231 | fprintf(hdr, " *\n"); | ||
1232 | fprintf(hdr, " * ASN.1 parser for %s\n", grammar_name); | ||
1233 | fprintf(hdr, " */\n"); | ||
1234 | fprintf(hdr, "#include <linux/asn1_decoder.h>\n"); | ||
1235 | fprintf(hdr, "\n"); | ||
1236 | fprintf(hdr, "extern const struct asn1_decoder %s_decoder;\n", grammar_name); | ||
1237 | if (ferror(hdr)) { | ||
1238 | perror(headername); | ||
1239 | exit(1); | ||
1240 | } | ||
1241 | |||
1242 | fprintf(out, "/*\n"); | ||
1243 | fprintf(out, " * Automatically generated by asn1_compiler. Do not edit\n"); | ||
1244 | fprintf(out, " *\n"); | ||
1245 | fprintf(out, " * ASN.1 parser for %s\n", grammar_name); | ||
1246 | fprintf(out, " */\n"); | ||
1247 | fprintf(out, "#include <linux/asn1_ber_bytecode.h>\n"); | ||
1248 | fprintf(out, "#include \"%s-asn1.h\"\n", grammar_name); | ||
1249 | fprintf(out, "\n"); | ||
1250 | if (ferror(out)) { | ||
1251 | perror(outputname); | ||
1252 | exit(1); | ||
1253 | } | ||
1254 | |||
1255 | /* Tabulate the action functions we might have to call */ | ||
1256 | fprintf(hdr, "\n"); | ||
1257 | index = 0; | ||
1258 | for (action = action_list; action; action = action->next) { | ||
1259 | action->index = index++; | ||
1260 | fprintf(hdr, | ||
1261 | "extern int %s(void *, size_t, unsigned char," | ||
1262 | " const void *, size_t);\n", | ||
1263 | action->name); | ||
1264 | } | ||
1265 | fprintf(hdr, "\n"); | ||
1266 | |||
1267 | fprintf(out, "enum %s_actions {\n", grammar_name); | ||
1268 | for (action = action_list; action; action = action->next) | ||
1269 | fprintf(out, "\tACT_%s = %u,\n", | ||
1270 | action->name, action->index); | ||
1271 | fprintf(out, "\tNR__%s_actions = %u\n", grammar_name, nr_actions); | ||
1272 | fprintf(out, "};\n"); | ||
1273 | |||
1274 | fprintf(out, "\n"); | ||
1275 | fprintf(out, "static const asn1_action_t %s_action_table[NR__%s_actions] = {\n", | ||
1276 | grammar_name, grammar_name); | ||
1277 | for (action = action_list; action; action = action->next) | ||
1278 | fprintf(out, "\t[%4u] = %s,\n", action->index, action->name); | ||
1279 | fprintf(out, "};\n"); | ||
1280 | |||
1281 | if (ferror(out)) { | ||
1282 | perror(outputname); | ||
1283 | exit(1); | ||
1284 | } | ||
1285 | |||
1286 | /* We do two passes - the first one calculates all the offsets */ | ||
1287 | printf("Pass 1\n"); | ||
1288 | nr_entries = 0; | ||
1289 | root = &type_list[0]; | ||
1290 | render_element(NULL, root->element, NULL); | ||
1291 | render_opcode(NULL, "ASN1_OP_COMPLETE,\n"); | ||
1292 | render_out_of_line_list(NULL); | ||
1293 | |||
1294 | for (e = element_list; e; e = e->list_next) | ||
1295 | e->flags &= ~ELEMENT_RENDERED; | ||
1296 | |||
1297 | /* And then we actually render */ | ||
1298 | printf("Pass 2\n"); | ||
1299 | fprintf(out, "\n"); | ||
1300 | fprintf(out, "static const unsigned char %s_machine[] = {\n", | ||
1301 | grammar_name); | ||
1302 | |||
1303 | nr_entries = 0; | ||
1304 | root = &type_list[0]; | ||
1305 | render_element(out, root->element, NULL); | ||
1306 | render_opcode(out, "ASN1_OP_COMPLETE,\n"); | ||
1307 | render_out_of_line_list(out); | ||
1308 | |||
1309 | fprintf(out, "};\n"); | ||
1310 | |||
1311 | fprintf(out, "\n"); | ||
1312 | fprintf(out, "const struct asn1_decoder %s_decoder = {\n", grammar_name); | ||
1313 | fprintf(out, "\t.machine = %s_machine,\n", grammar_name); | ||
1314 | fprintf(out, "\t.machlen = sizeof(%s_machine),\n", grammar_name); | ||
1315 | fprintf(out, "\t.actions = %s_action_table,\n", grammar_name); | ||
1316 | fprintf(out, "};\n"); | ||
1317 | } | ||
1318 | |||
1319 | /* | ||
1320 | * Render the out-of-line elements | ||
1321 | */ | ||
1322 | static void render_out_of_line_list(FILE *out) | ||
1323 | { | ||
1324 | struct element *e, *ce; | ||
1325 | const char *act; | ||
1326 | int entry; | ||
1327 | |||
1328 | while ((e = render_list)) { | ||
1329 | render_list = e->render_next; | ||
1330 | if (!render_list) | ||
1331 | render_list_p = &render_list; | ||
1332 | |||
1333 | render_more(out, "\n"); | ||
1334 | e->entry_index = entry = nr_entries; | ||
1335 | render_depth++; | ||
1336 | for (ce = e->children; ce; ce = ce->next) | ||
1337 | render_element(out, ce, NULL); | ||
1338 | render_depth--; | ||
1339 | |||
1340 | act = e->action ? "_ACT" : ""; | ||
1341 | switch (e->compound) { | ||
1342 | case SEQUENCE: | ||
1343 | render_opcode(out, "ASN1_OP_END_SEQ%s,\n", act); | ||
1344 | break; | ||
1345 | case SEQUENCE_OF: | ||
1346 | render_opcode(out, "ASN1_OP_END_SEQ_OF%s,\n", act); | ||
1347 | render_opcode(out, "_jump_target(%u),\n", entry); | ||
1348 | break; | ||
1349 | case SET: | ||
1350 | render_opcode(out, "ASN1_OP_END_SET%s,\n", act); | ||
1351 | break; | ||
1352 | case SET_OF: | ||
1353 | render_opcode(out, "ASN1_OP_END_SET_OF%s,\n", act); | ||
1354 | render_opcode(out, "_jump_target(%u),\n", entry); | ||
1355 | break; | ||
1356 | } | ||
1357 | if (e->action) | ||
1358 | render_opcode(out, "_action(ACT_%s),\n", | ||
1359 | e->action->name); | ||
1360 | render_opcode(out, "ASN1_OP_RETURN,\n"); | ||
1361 | } | ||
1362 | } | ||
1363 | |||
1364 | /* | ||
1365 | * Render an element. | ||
1366 | */ | ||
1367 | static void render_element(FILE *out, struct element *e, struct element *tag) | ||
1368 | { | ||
1369 | struct element *ec; | ||
1370 | const char *cond, *act; | ||
1371 | int entry, skippable = 0, outofline = 0; | ||
1372 | |||
1373 | if (e->flags & ELEMENT_SKIPPABLE || | ||
1374 | (tag && tag->flags & ELEMENT_SKIPPABLE)) | ||
1375 | skippable = 1; | ||
1376 | |||
1377 | if ((e->type_def && e->type_def->ref_count > 1) || | ||
1378 | skippable) | ||
1379 | outofline = 1; | ||
1380 | |||
1381 | if (e->type_def && out) { | ||
1382 | render_more(out, "\t// %*.*s\n", | ||
1383 | (int)e->type_def->name->size, (int)e->type_def->name->size, | ||
1384 | e->type_def->name->value); | ||
1385 | } | ||
1386 | |||
1387 | /* Render the operation */ | ||
1388 | cond = (e->flags & ELEMENT_CONDITIONAL || | ||
1389 | (tag && tag->flags & ELEMENT_CONDITIONAL)) ? "COND_" : ""; | ||
1390 | act = e->action ? "_ACT" : ""; | ||
1391 | switch (e->compound) { | ||
1392 | case ANY: | ||
1393 | render_opcode(out, "ASN1_OP_%sMATCH_ANY%s,", cond, act); | ||
1394 | if (e->name) | ||
1395 | render_more(out, "\t\t// %*.*s", | ||
1396 | (int)e->name->size, (int)e->name->size, | ||
1397 | e->name->value); | ||
1398 | render_more(out, "\n"); | ||
1399 | goto dont_render_tag; | ||
1400 | |||
1401 | case TAG_OVERRIDE: | ||
1402 | render_element(out, e->children, e); | ||
1403 | return; | ||
1404 | |||
1405 | case SEQUENCE: | ||
1406 | case SEQUENCE_OF: | ||
1407 | case SET: | ||
1408 | case SET_OF: | ||
1409 | render_opcode(out, "ASN1_OP_%sMATCH%s%s,", | ||
1410 | cond, | ||
1411 | outofline ? "_JUMP" : "", | ||
1412 | skippable ? "_OR_SKIP" : ""); | ||
1413 | break; | ||
1414 | |||
1415 | case CHOICE: | ||
1416 | goto dont_render_tag; | ||
1417 | |||
1418 | case TYPE_REF: | ||
1419 | if (e->class == ASN1_UNIV && e->method == ASN1_PRIM && e->tag == 0) | ||
1420 | goto dont_render_tag; | ||
1421 | default: | ||
1422 | render_opcode(out, "ASN1_OP_%sMATCH%s%s,", | ||
1423 | cond, act, | ||
1424 | skippable ? "_OR_SKIP" : ""); | ||
1425 | break; | ||
1426 | } | ||
1427 | |||
1428 | if (e->name) | ||
1429 | render_more(out, "\t\t// %*.*s", | ||
1430 | (int)e->name->size, (int)e->name->size, | ||
1431 | e->name->value); | ||
1432 | render_more(out, "\n"); | ||
1433 | |||
1434 | /* Render the tag */ | ||
1435 | if (!tag) | ||
1436 | tag = e; | ||
1437 | if (tag->class == ASN1_UNIV && | ||
1438 | tag->tag != 14 && | ||
1439 | tag->tag != 15 && | ||
1440 | tag->tag != 31) | ||
1441 | render_opcode(out, "_tag(%s, %s, %s),\n", | ||
1442 | asn1_classes[tag->class], | ||
1443 | asn1_methods[tag->method | e->method], | ||
1444 | asn1_universal_tags[tag->tag]); | ||
1445 | else | ||
1446 | render_opcode(out, "_tagn(%s, %s, %2u),\n", | ||
1447 | asn1_classes[tag->class], | ||
1448 | asn1_methods[tag->method | e->method], | ||
1449 | tag->tag); | ||
1450 | tag = NULL; | ||
1451 | dont_render_tag: | ||
1452 | |||
1453 | /* Deal with compound types */ | ||
1454 | switch (e->compound) { | ||
1455 | case TYPE_REF: | ||
1456 | render_element(out, e->type->type->element, tag); | ||
1457 | if (e->action) | ||
1458 | render_opcode(out, "ASN1_OP_ACT,\n"); | ||
1459 | break; | ||
1460 | |||
1461 | case SEQUENCE: | ||
1462 | if (outofline) { | ||
1463 | /* Render out-of-line for multiple use or | ||
1464 | * skipability */ | ||
1465 | render_opcode(out, "_jump_target(%u),", e->entry_index); | ||
1466 | if (e->type_def && e->type_def->name) | ||
1467 | render_more(out, "\t\t// --> %*.*s", | ||
1468 | (int)e->type_def->name->size, | ||
1469 | (int)e->type_def->name->size, | ||
1470 | e->type_def->name->value); | ||
1471 | render_more(out, "\n"); | ||
1472 | if (!(e->flags & ELEMENT_RENDERED)) { | ||
1473 | e->flags |= ELEMENT_RENDERED; | ||
1474 | *render_list_p = e; | ||
1475 | render_list_p = &e->render_next; | ||
1476 | } | ||
1477 | return; | ||
1478 | } else { | ||
1479 | /* Render inline for single use */ | ||
1480 | render_depth++; | ||
1481 | for (ec = e->children; ec; ec = ec->next) | ||
1482 | render_element(out, ec, NULL); | ||
1483 | render_depth--; | ||
1484 | render_opcode(out, "ASN1_OP_END_SEQ%s,\n", act); | ||
1485 | } | ||
1486 | break; | ||
1487 | |||
1488 | case SEQUENCE_OF: | ||
1489 | case SET_OF: | ||
1490 | if (outofline) { | ||
1491 | /* Render out-of-line for multiple use or | ||
1492 | * skipability */ | ||
1493 | render_opcode(out, "_jump_target(%u),", e->entry_index); | ||
1494 | if (e->type_def && e->type_def->name) | ||
1495 | render_more(out, "\t\t// --> %*.*s", | ||
1496 | (int)e->type_def->name->size, | ||
1497 | (int)e->type_def->name->size, | ||
1498 | e->type_def->name->value); | ||
1499 | render_more(out, "\n"); | ||
1500 | if (!(e->flags & ELEMENT_RENDERED)) { | ||
1501 | e->flags |= ELEMENT_RENDERED; | ||
1502 | *render_list_p = e; | ||
1503 | render_list_p = &e->render_next; | ||
1504 | } | ||
1505 | return; | ||
1506 | } else { | ||
1507 | /* Render inline for single use */ | ||
1508 | entry = nr_entries; | ||
1509 | render_depth++; | ||
1510 | render_element(out, e->children, NULL); | ||
1511 | render_depth--; | ||
1512 | if (e->compound == SEQUENCE_OF) | ||
1513 | render_opcode(out, "ASN1_OP_END_SEQ_OF%s,\n", act); | ||
1514 | else | ||
1515 | render_opcode(out, "ASN1_OP_END_SET_OF%s,\n", act); | ||
1516 | render_opcode(out, "_jump_target(%u),\n", entry); | ||
1517 | } | ||
1518 | break; | ||
1519 | |||
1520 | case SET: | ||
1521 | /* I can't think of a nice way to do SET support without having | ||
1522 | * a stack of bitmasks to make sure no element is repeated. | ||
1523 | * The bitmask has also to be checked that no non-optional | ||
1524 | * elements are left out whilst not preventing optional | ||
1525 | * elements from being left out. | ||
1526 | */ | ||
1527 | fprintf(stderr, "The ASN.1 SET type is not currently supported.\n"); | ||
1528 | exit(1); | ||
1529 | |||
1530 | case CHOICE: | ||
1531 | for (ec = e->children; ec; ec = ec->next) | ||
1532 | render_element(out, ec, NULL); | ||
1533 | if (!skippable) | ||
1534 | render_opcode(out, "ASN1_OP_COND_FAIL,\n"); | ||
1535 | if (e->action) | ||
1536 | render_opcode(out, "ASN1_OP_ACT,\n"); | ||
1537 | break; | ||
1538 | |||
1539 | default: | ||
1540 | break; | ||
1541 | } | ||
1542 | |||
1543 | if (e->action) | ||
1544 | render_opcode(out, "_action(ACT_%s),\n", e->action->name); | ||
1545 | } | ||
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index cb1f50cf12e..291228e2598 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
@@ -345,7 +345,6 @@ static void parse_dep_file(void *map, size_t len) | |||
345 | memcpy(s, m, p-m); s[p-m] = 0; | 345 | memcpy(s, m, p-m); s[p-m] = 0; |
346 | if (strrcmp(s, "include/generated/autoconf.h") && | 346 | if (strrcmp(s, "include/generated/autoconf.h") && |
347 | strrcmp(s, "arch/um/include/uml-config.h") && | 347 | strrcmp(s, "arch/um/include/uml-config.h") && |
348 | strrcmp(s, "include/linux/kconfig.h") && | ||
349 | strrcmp(s, ".ver")) { | 348 | strrcmp(s, ".ver")) { |
350 | /* | 349 | /* |
351 | * Do not list the source file as dependency, so that | 350 | * Do not list the source file as dependency, so that |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4d2c7dfdaab..3dfc47134e5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -33,7 +33,6 @@ my %ignore_type = (); | |||
33 | my @ignore = (); | 33 | my @ignore = (); |
34 | my $help = 0; | 34 | my $help = 0; |
35 | my $configuration_file = ".checkpatch.conf"; | 35 | my $configuration_file = ".checkpatch.conf"; |
36 | my $max_line_length = 80; | ||
37 | 36 | ||
38 | sub help { | 37 | sub help { |
39 | my ($exitcode) = @_; | 38 | my ($exitcode) = @_; |
@@ -52,7 +51,6 @@ Options: | |||
52 | -f, --file treat FILE as regular source file | 51 | -f, --file treat FILE as regular source file |
53 | --subjective, --strict enable more subjective tests | 52 | --subjective, --strict enable more subjective tests |
54 | --ignore TYPE(,TYPE2...) ignore various comma separated message types | 53 | --ignore TYPE(,TYPE2...) ignore various comma separated message types |
55 | --max-line-length=n set the maximum line length, if exceeded, warn | ||
56 | --show-types show the message "types" in the output | 54 | --show-types show the message "types" in the output |
57 | --root=PATH PATH to the kernel tree root | 55 | --root=PATH PATH to the kernel tree root |
58 | --no-summary suppress the per-file summary | 56 | --no-summary suppress the per-file summary |
@@ -109,7 +107,6 @@ GetOptions( | |||
109 | 'strict!' => \$check, | 107 | 'strict!' => \$check, |
110 | 'ignore=s' => \@ignore, | 108 | 'ignore=s' => \@ignore, |
111 | 'show-types!' => \$show_types, | 109 | 'show-types!' => \$show_types, |
112 | 'max-line-length=i' => \$max_line_length, | ||
113 | 'root=s' => \$root, | 110 | 'root=s' => \$root, |
114 | 'summary!' => \$summary, | 111 | 'summary!' => \$summary, |
115 | 'mailback!' => \$mailback, | 112 | 'mailback!' => \$mailback, |
@@ -230,11 +227,7 @@ our $Inline = qr{inline|__always_inline|noinline}; | |||
230 | our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; | 227 | our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; |
231 | our $Lval = qr{$Ident(?:$Member)*}; | 228 | our $Lval = qr{$Ident(?:$Member)*}; |
232 | 229 | ||
233 | our $Float_hex = qr{(?i:0x[0-9a-f]+p-?[0-9]+[fl]?)}; | 230 | our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*}; |
234 | our $Float_dec = qr{(?i:((?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?))}; | ||
235 | our $Float_int = qr{(?i:[0-9]+e-?[0-9]+[fl]?)}; | ||
236 | our $Float = qr{$Float_hex|$Float_dec|$Float_int}; | ||
237 | our $Constant = qr{(?:$Float|(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*))}; | ||
238 | our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; | 231 | our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; |
239 | our $Compare = qr{<=|>=|==|!=|<|>}; | 232 | our $Compare = qr{<=|>=|==|!=|<|>}; |
240 | our $Operators = qr{ | 233 | our $Operators = qr{ |
@@ -247,8 +240,9 @@ our $NonptrType; | |||
247 | our $Type; | 240 | our $Type; |
248 | our $Declare; | 241 | our $Declare; |
249 | 242 | ||
250 | our $NON_ASCII_UTF8 = qr{ | 243 | our $UTF8 = qr { |
251 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | 244 | [\x09\x0A\x0D\x20-\x7E] # ASCII |
245 | | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | ||
252 | | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | 246 | | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs |
253 | | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | 247 | | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte |
254 | | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | 248 | | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates |
@@ -257,11 +251,6 @@ our $NON_ASCII_UTF8 = qr{ | |||
257 | | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 | 251 | | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 |
258 | }x; | 252 | }x; |
259 | 253 | ||
260 | our $UTF8 = qr{ | ||
261 | [\x09\x0A\x0D\x20-\x7E] # ASCII | ||
262 | | $NON_ASCII_UTF8 | ||
263 | }x; | ||
264 | |||
265 | our $typeTypedefs = qr{(?x: | 254 | our $typeTypedefs = qr{(?x: |
266 | (?:__)?(?:u|s|be|le)(?:8|16|32|64)| | 255 | (?:__)?(?:u|s|be|le)(?:8|16|32|64)| |
267 | atomic_t | 256 | atomic_t |
@@ -322,7 +311,7 @@ sub build_types { | |||
322 | $NonptrType = qr{ | 311 | $NonptrType = qr{ |
323 | (?:$Modifier\s+|const\s+)* | 312 | (?:$Modifier\s+|const\s+)* |
324 | (?: | 313 | (?: |
325 | (?:typeof|__typeof__)\s*\([^\)]*\)| | 314 | (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)| |
326 | (?:$typeTypedefs\b)| | 315 | (?:$typeTypedefs\b)| |
327 | (?:${all}\b) | 316 | (?:${all}\b) |
328 | ) | 317 | ) |
@@ -330,23 +319,17 @@ sub build_types { | |||
330 | }x; | 319 | }x; |
331 | $Type = qr{ | 320 | $Type = qr{ |
332 | $NonptrType | 321 | $NonptrType |
333 | (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)? | 322 | (?:[\s\*]+\s*const|[\s\*]+|(?:\s*\[\s*\])+)? |
334 | (?:\s+$Inline|\s+$Modifier)* | 323 | (?:\s+$Inline|\s+$Modifier)* |
335 | }x; | 324 | }x; |
336 | $Declare = qr{(?:$Storage\s+)?$Type}; | 325 | $Declare = qr{(?:$Storage\s+)?$Type}; |
337 | } | 326 | } |
338 | build_types(); | 327 | build_types(); |
339 | 328 | ||
329 | our $match_balanced_parentheses = qr/(\((?:[^\(\)]+|(-1))*\))/; | ||
340 | 330 | ||
341 | our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; | 331 | our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; |
342 | 332 | our $LvalOrFunc = qr{($Lval)\s*($match_balanced_parentheses{0,1})\s*}; | |
343 | # Using $balanced_parens, $LvalOrFunc, or $FuncArg | ||
344 | # requires at least perl version v5.10.0 | ||
345 | # Any use must be runtime checked with $^V | ||
346 | |||
347 | our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; | ||
348 | our $LvalOrFunc = qr{($Lval)\s*($balanced_parens{0,1})\s*}; | ||
349 | our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)}; | ||
350 | 333 | ||
351 | sub deparenthesize { | 334 | sub deparenthesize { |
352 | my ($string) = @_; | 335 | my ($string) = @_; |
@@ -359,6 +342,27 @@ sub deparenthesize { | |||
359 | 342 | ||
360 | $chk_signoff = 0 if ($file); | 343 | $chk_signoff = 0 if ($file); |
361 | 344 | ||
345 | my @dep_includes = (); | ||
346 | my @dep_functions = (); | ||
347 | my $removal = "Documentation/feature-removal-schedule.txt"; | ||
348 | if ($tree && -f "$root/$removal") { | ||
349 | open(my $REMOVE, '<', "$root/$removal") || | ||
350 | die "$P: $removal: open failed - $!\n"; | ||
351 | while (<$REMOVE>) { | ||
352 | if (/^Check:\s+(.*\S)/) { | ||
353 | for my $entry (split(/[, ]+/, $1)) { | ||
354 | if ($entry =~ m@include/(.*)@) { | ||
355 | push(@dep_includes, $1); | ||
356 | |||
357 | } elsif ($entry !~ m@/@) { | ||
358 | push(@dep_functions, $entry); | ||
359 | } | ||
360 | } | ||
361 | } | ||
362 | } | ||
363 | close($REMOVE); | ||
364 | } | ||
365 | |||
362 | my @rawlines = (); | 366 | my @rawlines = (); |
363 | my @lines = (); | 367 | my @lines = (); |
364 | my $vname; | 368 | my $vname; |
@@ -407,7 +411,7 @@ sub top_of_kernel_tree { | |||
407 | } | 411 | } |
408 | } | 412 | } |
409 | return 1; | 413 | return 1; |
410 | } | 414 | } |
411 | 415 | ||
412 | sub parse_email { | 416 | sub parse_email { |
413 | my ($formatted_email) = @_; | 417 | my ($formatted_email) = @_; |
@@ -668,10 +672,6 @@ sub ctx_statement_block { | |||
668 | if ($off >= $len) { | 672 | if ($off >= $len) { |
669 | last; | 673 | last; |
670 | } | 674 | } |
671 | if ($level == 0 && substr($blk, $off) =~ /^.\s*#\s*define/) { | ||
672 | $level++; | ||
673 | $type = '#'; | ||
674 | } | ||
675 | } | 675 | } |
676 | $p = $c; | 676 | $p = $c; |
677 | $c = substr($blk, $off, 1); | 677 | $c = substr($blk, $off, 1); |
@@ -734,13 +734,6 @@ sub ctx_statement_block { | |||
734 | last; | 734 | last; |
735 | } | 735 | } |
736 | } | 736 | } |
737 | # Preprocessor commands end at the newline unless escaped. | ||
738 | if ($type eq '#' && $c eq "\n" && $p ne "\\") { | ||
739 | $level--; | ||
740 | $type = ''; | ||
741 | $off++; | ||
742 | last; | ||
743 | } | ||
744 | $off++; | 737 | $off++; |
745 | } | 738 | } |
746 | # We are truly at the end, so shuffle to the next line. | 739 | # We are truly at the end, so shuffle to the next line. |
@@ -1023,7 +1016,7 @@ sub annotate_values { | |||
1023 | } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') { | 1016 | } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') { |
1024 | print "CAST($1)\n" if ($dbg_values > 1); | 1017 | print "CAST($1)\n" if ($dbg_values > 1); |
1025 | push(@av_paren_type, $type); | 1018 | push(@av_paren_type, $type); |
1026 | $type = 'c'; | 1019 | $type = 'C'; |
1027 | 1020 | ||
1028 | } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) { | 1021 | } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) { |
1029 | print "DECLARE($1)\n" if ($dbg_values > 1); | 1022 | print "DECLARE($1)\n" if ($dbg_values > 1); |
@@ -1215,9 +1208,7 @@ sub possible { | |||
1215 | case| | 1208 | case| |
1216 | else| | 1209 | else| |
1217 | asm|__asm__| | 1210 | asm|__asm__| |
1218 | do| | 1211 | do |
1219 | \#| | ||
1220 | \#\#| | ||
1221 | )(?:\s|$)| | 1212 | )(?:\s|$)| |
1222 | ^(?:typedef|struct|enum)\b | 1213 | ^(?:typedef|struct|enum)\b |
1223 | )}x; | 1214 | )}x; |
@@ -1321,36 +1312,6 @@ sub check_absolute_file { | |||
1321 | } | 1312 | } |
1322 | } | 1313 | } |
1323 | 1314 | ||
1324 | sub pos_last_openparen { | ||
1325 | my ($line) = @_; | ||
1326 | |||
1327 | my $pos = 0; | ||
1328 | |||
1329 | my $opens = $line =~ tr/\(/\(/; | ||
1330 | my $closes = $line =~ tr/\)/\)/; | ||
1331 | |||
1332 | my $last_openparen = 0; | ||
1333 | |||
1334 | if (($opens == 0) || ($closes >= $opens)) { | ||
1335 | return -1; | ||
1336 | } | ||
1337 | |||
1338 | my $len = length($line); | ||
1339 | |||
1340 | for ($pos = 0; $pos < $len; $pos++) { | ||
1341 | my $string = substr($line, $pos); | ||
1342 | if ($string =~ /^($FuncArg|$balanced_parens)/) { | ||
1343 | $pos += length($1) - 1; | ||
1344 | } elsif (substr($line, $pos, 1) eq '(') { | ||
1345 | $last_openparen = $pos; | ||
1346 | } elsif (index($string, '(') == -1) { | ||
1347 | last; | ||
1348 | } | ||
1349 | } | ||
1350 | |||
1351 | return $last_openparen + 1; | ||
1352 | } | ||
1353 | |||
1354 | sub process { | 1315 | sub process { |
1355 | my $filename = shift; | 1316 | my $filename = shift; |
1356 | 1317 | ||
@@ -1369,11 +1330,6 @@ sub process { | |||
1369 | my $signoff = 0; | 1330 | my $signoff = 0; |
1370 | my $is_patch = 0; | 1331 | my $is_patch = 0; |
1371 | 1332 | ||
1372 | my $in_header_lines = 1; | ||
1373 | my $in_commit_log = 0; #Scanning lines before patch | ||
1374 | |||
1375 | my $non_utf8_charset = 0; | ||
1376 | |||
1377 | our @report = (); | 1333 | our @report = (); |
1378 | our $cnt_lines = 0; | 1334 | our $cnt_lines = 0; |
1379 | our $cnt_error = 0; | 1335 | our $cnt_error = 0; |
@@ -1396,9 +1352,6 @@ sub process { | |||
1396 | my %suppress_ifbraces; | 1352 | my %suppress_ifbraces; |
1397 | my %suppress_whiletrailers; | 1353 | my %suppress_whiletrailers; |
1398 | my %suppress_export; | 1354 | my %suppress_export; |
1399 | my $suppress_statement = 0; | ||
1400 | |||
1401 | my %camelcase = (); | ||
1402 | 1355 | ||
1403 | # Pre-scan the patch sanitizing the lines. | 1356 | # Pre-scan the patch sanitizing the lines. |
1404 | # Pre-scan the patch looking for any __setup documentation. | 1357 | # Pre-scan the patch looking for any __setup documentation. |
@@ -1508,7 +1461,6 @@ sub process { | |||
1508 | %suppress_ifbraces = (); | 1461 | %suppress_ifbraces = (); |
1509 | %suppress_whiletrailers = (); | 1462 | %suppress_whiletrailers = (); |
1510 | %suppress_export = (); | 1463 | %suppress_export = (); |
1511 | $suppress_statement = 0; | ||
1512 | next; | 1464 | next; |
1513 | 1465 | ||
1514 | # track the line number as we move through the hunk, note that | 1466 | # track the line number as we move through the hunk, note that |
@@ -1545,11 +1497,10 @@ sub process { | |||
1545 | if ($line =~ /^diff --git.*?(\S+)$/) { | 1497 | if ($line =~ /^diff --git.*?(\S+)$/) { |
1546 | $realfile = $1; | 1498 | $realfile = $1; |
1547 | $realfile =~ s@^([^/]*)/@@; | 1499 | $realfile =~ s@^([^/]*)/@@; |
1548 | $in_commit_log = 0; | 1500 | |
1549 | } elsif ($line =~ /^\+\+\+\s+(\S+)/) { | 1501 | } elsif ($line =~ /^\+\+\+\s+(\S+)/) { |
1550 | $realfile = $1; | 1502 | $realfile = $1; |
1551 | $realfile =~ s@^([^/]*)/@@; | 1503 | $realfile =~ s@^([^/]*)/@@; |
1552 | $in_commit_log = 0; | ||
1553 | 1504 | ||
1554 | $p1_prefix = $1; | 1505 | $p1_prefix = $1; |
1555 | if (!$file && $tree && $p1_prefix ne '' && | 1506 | if (!$file && $tree && $p1_prefix ne '' && |
@@ -1585,22 +1536,16 @@ sub process { | |||
1585 | # Check the patch for a signoff: | 1536 | # Check the patch for a signoff: |
1586 | if ($line =~ /^\s*signed-off-by:/i) { | 1537 | if ($line =~ /^\s*signed-off-by:/i) { |
1587 | $signoff++; | 1538 | $signoff++; |
1588 | $in_commit_log = 0; | ||
1589 | } | 1539 | } |
1590 | 1540 | ||
1591 | # Check signature styles | 1541 | # Check signature styles |
1592 | if (!$in_header_lines && | 1542 | if ($line =~ /^(\s*)($signature_tags)(\s*)(.*)/) { |
1593 | $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) { | ||
1594 | my $space_before = $1; | 1543 | my $space_before = $1; |
1595 | my $sign_off = $2; | 1544 | my $sign_off = $2; |
1596 | my $space_after = $3; | 1545 | my $space_after = $3; |
1597 | my $email = $4; | 1546 | my $email = $4; |
1598 | my $ucfirst_sign_off = ucfirst(lc($sign_off)); | 1547 | my $ucfirst_sign_off = ucfirst(lc($sign_off)); |
1599 | 1548 | ||
1600 | if ($sign_off !~ /$signature_tags/) { | ||
1601 | WARN("BAD_SIGN_OFF", | ||
1602 | "Non-standard signature: $sign_off\n" . $herecurr); | ||
1603 | } | ||
1604 | if (defined $space_before && $space_before ne "") { | 1549 | if (defined $space_before && $space_before ne "") { |
1605 | WARN("BAD_SIGN_OFF", | 1550 | WARN("BAD_SIGN_OFF", |
1606 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); | 1551 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); |
@@ -1668,28 +1613,6 @@ sub process { | |||
1668 | "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); | 1613 | "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); |
1669 | } | 1614 | } |
1670 | 1615 | ||
1671 | # Check if it's the start of a commit log | ||
1672 | # (not a header line and we haven't seen the patch filename) | ||
1673 | if ($in_header_lines && $realfile =~ /^$/ && | ||
1674 | $rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) { | ||
1675 | $in_header_lines = 0; | ||
1676 | $in_commit_log = 1; | ||
1677 | } | ||
1678 | |||
1679 | # Check if there is UTF-8 in a commit log when a mail header has explicitly | ||
1680 | # declined it, i.e defined some charset where it is missing. | ||
1681 | if ($in_header_lines && | ||
1682 | $rawline =~ /^Content-Type:.+charset="(.+)".*$/ && | ||
1683 | $1 !~ /utf-8/i) { | ||
1684 | $non_utf8_charset = 1; | ||
1685 | } | ||
1686 | |||
1687 | if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ && | ||
1688 | $rawline =~ /$NON_ASCII_UTF8/) { | ||
1689 | WARN("UTF8_BEFORE_PATCH", | ||
1690 | "8-bit UTF-8 used in possible commit log\n" . $herecurr); | ||
1691 | } | ||
1692 | |||
1693 | # ignore non-hunk lines and lines being removed | 1616 | # ignore non-hunk lines and lines being removed |
1694 | next if (!$hunk_line || $line =~ /^-/); | 1617 | next if (!$hunk_line || $line =~ /^-/); |
1695 | 1618 | ||
@@ -1710,26 +1633,19 @@ sub process { | |||
1710 | # Only applies when adding the entry originally, after that we do not have | 1633 | # Only applies when adding the entry originally, after that we do not have |
1711 | # sufficient context to determine whether it is indeed long enough. | 1634 | # sufficient context to determine whether it is indeed long enough. |
1712 | if ($realfile =~ /Kconfig/ && | 1635 | if ($realfile =~ /Kconfig/ && |
1713 | $line =~ /.\s*config\s+/) { | 1636 | $line =~ /\+\s*(?:---)?help(?:---)?$/) { |
1714 | my $length = 0; | 1637 | my $length = 0; |
1715 | my $cnt = $realcnt; | 1638 | my $cnt = $realcnt; |
1716 | my $ln = $linenr + 1; | 1639 | my $ln = $linenr + 1; |
1717 | my $f; | 1640 | my $f; |
1718 | my $is_start = 0; | ||
1719 | my $is_end = 0; | 1641 | my $is_end = 0; |
1720 | for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) { | 1642 | while ($cnt > 0 && defined $lines[$ln - 1]) { |
1721 | $f = $lines[$ln - 1]; | 1643 | $f = $lines[$ln - 1]; |
1722 | $cnt-- if ($lines[$ln - 1] !~ /^-/); | 1644 | $cnt-- if ($lines[$ln - 1] !~ /^-/); |
1723 | $is_end = $lines[$ln - 1] =~ /^\+/; | 1645 | $is_end = $lines[$ln - 1] =~ /^\+/; |
1646 | $ln++; | ||
1724 | 1647 | ||
1725 | next if ($f =~ /^-/); | 1648 | next if ($f =~ /^-/); |
1726 | |||
1727 | if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) { | ||
1728 | $is_start = 1; | ||
1729 | } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) { | ||
1730 | $length = -1; | ||
1731 | } | ||
1732 | |||
1733 | $f =~ s/^.//; | 1649 | $f =~ s/^.//; |
1734 | $f =~ s/#.*//; | 1650 | $f =~ s/#.*//; |
1735 | $f =~ s/^\s+//; | 1651 | $f =~ s/^\s+//; |
@@ -1741,58 +1657,22 @@ sub process { | |||
1741 | $length++; | 1657 | $length++; |
1742 | } | 1658 | } |
1743 | WARN("CONFIG_DESCRIPTION", | 1659 | WARN("CONFIG_DESCRIPTION", |
1744 | "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_start && $is_end && $length < 4); | 1660 | "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_end && $length < 4); |
1745 | #print "is_start<$is_start> is_end<$is_end> length<$length>\n"; | 1661 | #print "is_end<$is_end> length<$length>\n"; |
1746 | } | ||
1747 | |||
1748 | # discourage the addition of CONFIG_EXPERIMENTAL in Kconfig. | ||
1749 | if ($realfile =~ /Kconfig/ && | ||
1750 | $line =~ /.\s*depends on\s+.*\bEXPERIMENTAL\b/) { | ||
1751 | WARN("CONFIG_EXPERIMENTAL", | ||
1752 | "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n"); | ||
1753 | } | ||
1754 | |||
1755 | if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && | ||
1756 | ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { | ||
1757 | my $flag = $1; | ||
1758 | my $replacement = { | ||
1759 | 'EXTRA_AFLAGS' => 'asflags-y', | ||
1760 | 'EXTRA_CFLAGS' => 'ccflags-y', | ||
1761 | 'EXTRA_CPPFLAGS' => 'cppflags-y', | ||
1762 | 'EXTRA_LDFLAGS' => 'ldflags-y', | ||
1763 | }; | ||
1764 | |||
1765 | WARN("DEPRECATED_VARIABLE", | ||
1766 | "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag}); | ||
1767 | } | 1662 | } |
1768 | 1663 | ||
1769 | # check we are in a valid source file if not then ignore this hunk | 1664 | # check we are in a valid source file if not then ignore this hunk |
1770 | next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); | 1665 | next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); |
1771 | 1666 | ||
1772 | #line length limit | 1667 | #80 column limit |
1773 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && | 1668 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && |
1774 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && | 1669 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && |
1775 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || | 1670 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || |
1776 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && | 1671 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && |
1777 | $length > $max_line_length) | 1672 | $length > 80) |
1778 | { | 1673 | { |
1779 | WARN("LONG_LINE", | 1674 | WARN("LONG_LINE", |
1780 | "line over $max_line_length characters\n" . $herecurr); | 1675 | "line over 80 characters\n" . $herecurr); |
1781 | } | ||
1782 | |||
1783 | # Check for user-visible strings broken across lines, which breaks the ability | ||
1784 | # to grep for the string. Limited to strings used as parameters (those | ||
1785 | # following an open parenthesis), which almost completely eliminates false | ||
1786 | # positives, as well as warning only once per parameter rather than once per | ||
1787 | # line of the string. Make an exception when the previous string ends in a | ||
1788 | # newline (multiple lines in one string constant) or \n\t (common in inline | ||
1789 | # assembly to indent the instruction on the following line). | ||
1790 | if ($line =~ /^\+\s*"/ && | ||
1791 | $prevline =~ /"\s*$/ && | ||
1792 | $prevline =~ /\(/ && | ||
1793 | $prevrawline !~ /\\n(?:\\t)*"\s*$/) { | ||
1794 | WARN("SPLIT_STRING", | ||
1795 | "quoted string split across lines\n" . $hereprev); | ||
1796 | } | 1676 | } |
1797 | 1677 | ||
1798 | # check for spaces before a quoted newline | 1678 | # check for spaces before a quoted newline |
@@ -1841,58 +1721,6 @@ sub process { | |||
1841 | "please, no space before tabs\n" . $herevet); | 1721 | "please, no space before tabs\n" . $herevet); |
1842 | } | 1722 | } |
1843 | 1723 | ||
1844 | # check for && or || at the start of a line | ||
1845 | if ($rawline =~ /^\+\s*(&&|\|\|)/) { | ||
1846 | CHK("LOGICAL_CONTINUATIONS", | ||
1847 | "Logical continuations should be on the previous line\n" . $hereprev); | ||
1848 | } | ||
1849 | |||
1850 | # check multi-line statement indentation matches previous line | ||
1851 | if ($^V && $^V ge 5.10.0 && | ||
1852 | $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) { | ||
1853 | $prevline =~ /^\+(\t*)(.*)$/; | ||
1854 | my $oldindent = $1; | ||
1855 | my $rest = $2; | ||
1856 | |||
1857 | my $pos = pos_last_openparen($rest); | ||
1858 | if ($pos >= 0) { | ||
1859 | $line =~ /^(\+| )([ \t]*)/; | ||
1860 | my $newindent = $2; | ||
1861 | |||
1862 | my $goodtabindent = $oldindent . | ||
1863 | "\t" x ($pos / 8) . | ||
1864 | " " x ($pos % 8); | ||
1865 | my $goodspaceindent = $oldindent . " " x $pos; | ||
1866 | |||
1867 | if ($newindent ne $goodtabindent && | ||
1868 | $newindent ne $goodspaceindent) { | ||
1869 | CHK("PARENTHESIS_ALIGNMENT", | ||
1870 | "Alignment should match open parenthesis\n" . $hereprev); | ||
1871 | } | ||
1872 | } | ||
1873 | } | ||
1874 | |||
1875 | if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) { | ||
1876 | CHK("SPACING", | ||
1877 | "No space is necessary after a cast\n" . $hereprev); | ||
1878 | } | ||
1879 | |||
1880 | if ($realfile =~ m@^(drivers/net/|net/)@ && | ||
1881 | $rawline =~ /^\+[ \t]*\/\*[ \t]*$/ && | ||
1882 | $prevrawline =~ /^\+[ \t]*$/) { | ||
1883 | WARN("NETWORKING_BLOCK_COMMENT_STYLE", | ||
1884 | "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev); | ||
1885 | } | ||
1886 | |||
1887 | if ($realfile =~ m@^(drivers/net/|net/)@ && | ||
1888 | $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */ | ||
1889 | $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ | ||
1890 | $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/ | ||
1891 | $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */ | ||
1892 | WARN("NETWORKING_BLOCK_COMMENT_STYLE", | ||
1893 | "networking block comments put the trailing */ on a separate line\n" . $herecurr); | ||
1894 | } | ||
1895 | |||
1896 | # check for spaces at the beginning of a line. | 1724 | # check for spaces at the beginning of a line. |
1897 | # Exceptions: | 1725 | # Exceptions: |
1898 | # 1) within comments | 1726 | # 1) within comments |
@@ -1907,12 +1735,6 @@ sub process { | |||
1907 | # check we are in a valid C source file if not then ignore this hunk | 1735 | # check we are in a valid C source file if not then ignore this hunk |
1908 | next if ($realfile !~ /\.(h|c)$/); | 1736 | next if ($realfile !~ /\.(h|c)$/); |
1909 | 1737 | ||
1910 | # discourage the addition of CONFIG_EXPERIMENTAL in #if(def). | ||
1911 | if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) { | ||
1912 | WARN("CONFIG_EXPERIMENTAL", | ||
1913 | "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n"); | ||
1914 | } | ||
1915 | |||
1916 | # check for RCS/CVS revision markers | 1738 | # check for RCS/CVS revision markers |
1917 | if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { | 1739 | if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { |
1918 | WARN("CVS_KEYWORD", | 1740 | WARN("CVS_KEYWORD", |
@@ -1934,24 +1756,12 @@ sub process { | |||
1934 | # Check for potential 'bare' types | 1756 | # Check for potential 'bare' types |
1935 | my ($stat, $cond, $line_nr_next, $remain_next, $off_next, | 1757 | my ($stat, $cond, $line_nr_next, $remain_next, $off_next, |
1936 | $realline_next); | 1758 | $realline_next); |
1937 | #print "LINE<$line>\n"; | 1759 | if ($realcnt && $line =~ /.\s*\S/) { |
1938 | if ($linenr >= $suppress_statement && | ||
1939 | $realcnt && $line =~ /.\s*\S/) { | ||
1940 | ($stat, $cond, $line_nr_next, $remain_next, $off_next) = | 1760 | ($stat, $cond, $line_nr_next, $remain_next, $off_next) = |
1941 | ctx_statement_block($linenr, $realcnt, 0); | 1761 | ctx_statement_block($linenr, $realcnt, 0); |
1942 | $stat =~ s/\n./\n /g; | 1762 | $stat =~ s/\n./\n /g; |
1943 | $cond =~ s/\n./\n /g; | 1763 | $cond =~ s/\n./\n /g; |
1944 | 1764 | ||
1945 | #print "linenr<$linenr> <$stat>\n"; | ||
1946 | # If this statement has no statement boundaries within | ||
1947 | # it there is no point in retrying a statement scan | ||
1948 | # until we hit end of it. | ||
1949 | my $frag = $stat; $frag =~ s/;+\s*$//; | ||
1950 | if ($frag !~ /(?:{|;)/) { | ||
1951 | #print "skip<$line_nr_next>\n"; | ||
1952 | $suppress_statement = $line_nr_next; | ||
1953 | } | ||
1954 | |||
1955 | # Find the real next line. | 1765 | # Find the real next line. |
1956 | $realline_next = $line_nr_next; | 1766 | $realline_next = $line_nr_next; |
1957 | if (defined $realline_next && | 1767 | if (defined $realline_next && |
@@ -2040,12 +1850,6 @@ sub process { | |||
2040 | my $pre_ctx = "$1$2"; | 1850 | my $pre_ctx = "$1$2"; |
2041 | 1851 | ||
2042 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); | 1852 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); |
2043 | |||
2044 | if ($line =~ /^\+\t{6,}/) { | ||
2045 | WARN("DEEP_INDENTATION", | ||
2046 | "Too many leading tabs - consider code refactoring\n" . $herecurr); | ||
2047 | } | ||
2048 | |||
2049 | my $ctx_cnt = $realcnt - $#ctx - 1; | 1853 | my $ctx_cnt = $realcnt - $#ctx - 1; |
2050 | my $ctx = join("\n", @ctx); | 1854 | my $ctx = join("\n", @ctx); |
2051 | 1855 | ||
@@ -2083,9 +1887,6 @@ sub process { | |||
2083 | 1887 | ||
2084 | # Check relative indent for conditionals and blocks. | 1888 | # Check relative indent for conditionals and blocks. |
2085 | if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { | 1889 | if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { |
2086 | ($stat, $cond, $line_nr_next, $remain_next, $off_next) = | ||
2087 | ctx_statement_block($linenr, $realcnt, 0) | ||
2088 | if (!defined $stat); | ||
2089 | my ($s, $c) = ($stat, $cond); | 1890 | my ($s, $c) = ($stat, $cond); |
2090 | 1891 | ||
2091 | substr($s, 0, length($c), ''); | 1892 | substr($s, 0, length($c), ''); |
@@ -2226,11 +2027,8 @@ sub process { | |||
2226 | my $path = $1; | 2027 | my $path = $1; |
2227 | if ($path =~ m{//}) { | 2028 | if ($path =~ m{//}) { |
2228 | ERROR("MALFORMED_INCLUDE", | 2029 | ERROR("MALFORMED_INCLUDE", |
2229 | "malformed #include filename\n" . $herecurr); | 2030 | "malformed #include filename\n" . |
2230 | } | 2031 | $herecurr); |
2231 | if ($path =~ "^uapi/" && $realfile =~ m@\binclude/uapi/@) { | ||
2232 | ERROR("UAPI_INCLUDE", | ||
2233 | "No #include in ...include/uapi/... should use a uapi/ path prefix\n" . $herecurr); | ||
2234 | } | 2032 | } |
2235 | } | 2033 | } |
2236 | 2034 | ||
@@ -2256,7 +2054,7 @@ sub process { | |||
2256 | # XXX(foo); | 2054 | # XXX(foo); |
2257 | # EXPORT_SYMBOL(something_foo); | 2055 | # EXPORT_SYMBOL(something_foo); |
2258 | my $name = $1; | 2056 | my $name = $1; |
2259 | if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ && | 2057 | if ($stat =~ /^.([A-Z_]+)\s*\(\s*($Ident)/ && |
2260 | $name =~ /^${Ident}_$2/) { | 2058 | $name =~ /^${Ident}_$2/) { |
2261 | #print "FOO C name<$name>\n"; | 2059 | #print "FOO C name<$name>\n"; |
2262 | $suppress_export{$realline_next} = 1; | 2060 | $suppress_export{$realline_next} = 1; |
@@ -2334,9 +2132,8 @@ sub process { | |||
2334 | 2132 | ||
2335 | # * goes on variable not on type | 2133 | # * goes on variable not on type |
2336 | # (char*[ const]) | 2134 | # (char*[ const]) |
2337 | while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) { | 2135 | if ($line =~ m{\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\)}) { |
2338 | #print "AA<$1>\n"; | 2136 | my ($from, $to) = ($1, $1); |
2339 | my ($from, $to) = ($2, $2); | ||
2340 | 2137 | ||
2341 | # Should start with a space. | 2138 | # Should start with a space. |
2342 | $to =~ s/^(\S)/ $1/; | 2139 | $to =~ s/^(\S)/ $1/; |
@@ -2351,10 +2148,8 @@ sub process { | |||
2351 | ERROR("POINTER_LOCATION", | 2148 | ERROR("POINTER_LOCATION", |
2352 | "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); | 2149 | "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); |
2353 | } | 2150 | } |
2354 | } | 2151 | } elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) { |
2355 | while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) { | 2152 | my ($from, $to, $ident) = ($1, $1, $2); |
2356 | #print "BB<$1>\n"; | ||
2357 | my ($from, $to, $ident) = ($2, $2, $3); | ||
2358 | 2153 | ||
2359 | # Should start with a space. | 2154 | # Should start with a space. |
2360 | $to =~ s/^(\S)/ $1/; | 2155 | $to =~ s/^(\S)/ $1/; |
@@ -2415,21 +2210,6 @@ sub process { | |||
2415 | } | 2210 | } |
2416 | } | 2211 | } |
2417 | 2212 | ||
2418 | if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) { | ||
2419 | my $orig = $1; | ||
2420 | my $level = lc($orig); | ||
2421 | $level = "warn" if ($level eq "warning"); | ||
2422 | my $level2 = $level; | ||
2423 | $level2 = "dbg" if ($level eq "debug"); | ||
2424 | WARN("PREFER_PR_LEVEL", | ||
2425 | "Prefer netdev_$level2(netdev, ... then dev_$level2(dev, ... then pr_$level(... to printk(KERN_$orig ...\n" . $herecurr); | ||
2426 | } | ||
2427 | |||
2428 | if ($line =~ /\bpr_warning\s*\(/) { | ||
2429 | WARN("PREFER_PR_LEVEL", | ||
2430 | "Prefer pr_warn(... to pr_warning(...\n" . $herecurr); | ||
2431 | } | ||
2432 | |||
2433 | # function brace can't be on same line, except for #defines of do while, | 2213 | # function brace can't be on same line, except for #defines of do while, |
2434 | # or if closed on same line | 2214 | # or if closed on same line |
2435 | if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and | 2215 | if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and |
@@ -2459,7 +2239,7 @@ sub process { | |||
2459 | my ($where, $prefix) = ($-[1], $1); | 2239 | my ($where, $prefix) = ($-[1], $1); |
2460 | if ($prefix !~ /$Type\s+$/ && | 2240 | if ($prefix !~ /$Type\s+$/ && |
2461 | ($where != 0 || $prefix !~ /^.\s+$/) && | 2241 | ($where != 0 || $prefix !~ /^.\s+$/) && |
2462 | $prefix !~ /[{,]\s+$/) { | 2242 | $prefix !~ /{\s+$/) { |
2463 | ERROR("BRACKET_SPACE", | 2243 | ERROR("BRACKET_SPACE", |
2464 | "space prohibited before open square bracket '['\n" . $herecurr); | 2244 | "space prohibited before open square bracket '['\n" . $herecurr); |
2465 | } | 2245 | } |
@@ -2496,13 +2276,6 @@ sub process { | |||
2496 | "space prohibited between function name and open parenthesis '('\n" . $herecurr); | 2276 | "space prohibited between function name and open parenthesis '('\n" . $herecurr); |
2497 | } | 2277 | } |
2498 | } | 2278 | } |
2499 | |||
2500 | # check for whitespace before a non-naked semicolon | ||
2501 | if ($line =~ /^\+.*\S\s+;/) { | ||
2502 | CHK("SPACING", | ||
2503 | "space prohibited before semicolon\n" . $herecurr); | ||
2504 | } | ||
2505 | |||
2506 | # Check operator spacing. | 2279 | # Check operator spacing. |
2507 | if (!($line=~/\#\s*include/)) { | 2280 | if (!($line=~/\#\s*include/)) { |
2508 | my $ops = qr{ | 2281 | my $ops = qr{ |
@@ -2759,7 +2532,7 @@ sub process { | |||
2759 | # Flatten any parentheses | 2532 | # Flatten any parentheses |
2760 | $value =~ s/\(/ \(/g; | 2533 | $value =~ s/\(/ \(/g; |
2761 | $value =~ s/\)/\) /g; | 2534 | $value =~ s/\)/\) /g; |
2762 | while ($value =~ s/\[[^\[\]]*\]/1/ || | 2535 | while ($value =~ s/\[[^\{\}]*\]/1/ || |
2763 | $value !~ /(?:$Ident|-?$Constant)\s* | 2536 | $value !~ /(?:$Ident|-?$Constant)\s* |
2764 | $Compare\s* | 2537 | $Compare\s* |
2765 | (?:$Ident|-?$Constant)/x && | 2538 | (?:$Ident|-?$Constant)/x && |
@@ -2784,6 +2557,28 @@ sub process { | |||
2784 | } | 2557 | } |
2785 | } | 2558 | } |
2786 | 2559 | ||
2560 | # typecasts on min/max could be min_t/max_t | ||
2561 | if ($line =~ /^\+(?:.*?)\b(min|max)\s*\($Typecast{0,1}($LvalOrFunc)\s*,\s*$Typecast{0,1}($LvalOrFunc)\s*\)/) { | ||
2562 | if (defined $2 || defined $8) { | ||
2563 | my $call = $1; | ||
2564 | my $cast1 = deparenthesize($2); | ||
2565 | my $arg1 = $3; | ||
2566 | my $cast2 = deparenthesize($8); | ||
2567 | my $arg2 = $9; | ||
2568 | my $cast; | ||
2569 | |||
2570 | if ($cast1 ne "" && $cast2 ne "") { | ||
2571 | $cast = "$cast1 or $cast2"; | ||
2572 | } elsif ($cast1 ne "") { | ||
2573 | $cast = $cast1; | ||
2574 | } else { | ||
2575 | $cast = $cast2; | ||
2576 | } | ||
2577 | WARN("MINMAX", | ||
2578 | "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . $herecurr); | ||
2579 | } | ||
2580 | } | ||
2581 | |||
2787 | # Need a space before open parenthesis after if, while etc | 2582 | # Need a space before open parenthesis after if, while etc |
2788 | if ($line=~/\b(if|while|for|switch)\(/) { | 2583 | if ($line=~/\b(if|while|for|switch)\(/) { |
2789 | ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr); | 2584 | ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr); |
@@ -2792,9 +2587,6 @@ sub process { | |||
2792 | # Check for illegal assignment in if conditional -- and check for trailing | 2587 | # Check for illegal assignment in if conditional -- and check for trailing |
2793 | # statements after the conditional. | 2588 | # statements after the conditional. |
2794 | if ($line =~ /do\s*(?!{)/) { | 2589 | if ($line =~ /do\s*(?!{)/) { |
2795 | ($stat, $cond, $line_nr_next, $remain_next, $off_next) = | ||
2796 | ctx_statement_block($linenr, $realcnt, 0) | ||
2797 | if (!defined $stat); | ||
2798 | my ($stat_next) = ctx_statement_block($line_nr_next, | 2590 | my ($stat_next) = ctx_statement_block($line_nr_next, |
2799 | $remain_next, $off_next); | 2591 | $remain_next, $off_next); |
2800 | $stat_next =~ s/\n./\n /g; | 2592 | $stat_next =~ s/\n./\n /g; |
@@ -2910,17 +2702,12 @@ sub process { | |||
2910 | } | 2702 | } |
2911 | } | 2703 | } |
2912 | 2704 | ||
2913 | #CamelCase | 2705 | #studly caps, commented out until figure out how to distinguish between use of existing and adding new |
2914 | while ($line =~ m{($Constant|$Lval)}g) { | 2706 | # if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { |
2915 | my $var = $1; | 2707 | # print "No studly caps, use _\n"; |
2916 | if ($var !~ /$Constant/ && | 2708 | # print "$herecurr"; |
2917 | $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && | 2709 | # $clean = 0; |
2918 | !defined $camelcase{$var}) { | 2710 | # } |
2919 | $camelcase{$var} = 1; | ||
2920 | WARN("CAMELCASE", | ||
2921 | "Avoid CamelCase: <$var>\n" . $herecurr); | ||
2922 | } | ||
2923 | } | ||
2924 | 2711 | ||
2925 | #no spaces allowed after \ in define | 2712 | #no spaces allowed after \ in define |
2926 | if ($line=~/\#\s*define.*\\\s$/) { | 2713 | if ($line=~/\#\s*define.*\\\s$/) { |
@@ -2955,13 +2742,47 @@ sub process { | |||
2955 | my $cnt = $realcnt; | 2742 | my $cnt = $realcnt; |
2956 | my ($off, $dstat, $dcond, $rest); | 2743 | my ($off, $dstat, $dcond, $rest); |
2957 | my $ctx = ''; | 2744 | my $ctx = ''; |
2745 | |||
2746 | my $args = defined($1); | ||
2747 | |||
2748 | # Find the end of the macro and limit our statement | ||
2749 | # search to that. | ||
2750 | while ($cnt > 0 && defined $lines[$ln - 1] && | ||
2751 | $lines[$ln - 1] =~ /^(?:-|..*\\$)/) | ||
2752 | { | ||
2753 | $ctx .= $rawlines[$ln - 1] . "\n"; | ||
2754 | $cnt-- if ($lines[$ln - 1] !~ /^-/); | ||
2755 | $ln++; | ||
2756 | } | ||
2757 | $ctx .= $rawlines[$ln - 1]; | ||
2758 | |||
2958 | ($dstat, $dcond, $ln, $cnt, $off) = | 2759 | ($dstat, $dcond, $ln, $cnt, $off) = |
2959 | ctx_statement_block($linenr, $realcnt, 0); | 2760 | ctx_statement_block($linenr, $ln - $linenr + 1, 0); |
2960 | $ctx = $dstat; | ||
2961 | #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n"; | 2761 | #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n"; |
2962 | #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n"; | 2762 | #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n"; |
2963 | 2763 | ||
2964 | $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//; | 2764 | # Extract the remainder of the define (if any) and |
2765 | # rip off surrounding spaces, and trailing \'s. | ||
2766 | $rest = ''; | ||
2767 | while ($off != 0 || ($cnt > 0 && $rest =~ /\\\s*$/)) { | ||
2768 | #print "ADDING cnt<$cnt> $off <" . substr($lines[$ln - 1], $off) . "> rest<$rest>\n"; | ||
2769 | if ($off != 0 || $lines[$ln - 1] !~ /^-/) { | ||
2770 | $rest .= substr($lines[$ln - 1], $off) . "\n"; | ||
2771 | $cnt--; | ||
2772 | } | ||
2773 | $ln++; | ||
2774 | $off = 0; | ||
2775 | } | ||
2776 | $rest =~ s/\\\n.//g; | ||
2777 | $rest =~ s/^\s*//s; | ||
2778 | $rest =~ s/\s*$//s; | ||
2779 | |||
2780 | # Clean up the original statement. | ||
2781 | if ($args) { | ||
2782 | substr($dstat, 0, length($dcond), ''); | ||
2783 | } else { | ||
2784 | $dstat =~ s/^.\s*\#\s*define\s+$Ident\s*//; | ||
2785 | } | ||
2965 | $dstat =~ s/$;//g; | 2786 | $dstat =~ s/$;//g; |
2966 | $dstat =~ s/\\\n.//g; | 2787 | $dstat =~ s/\\\n.//g; |
2967 | $dstat =~ s/^\s*//s; | 2788 | $dstat =~ s/^\s*//s; |
@@ -2970,20 +2791,14 @@ sub process { | |||
2970 | # Flatten any parentheses and braces | 2791 | # Flatten any parentheses and braces |
2971 | while ($dstat =~ s/\([^\(\)]*\)/1/ || | 2792 | while ($dstat =~ s/\([^\(\)]*\)/1/ || |
2972 | $dstat =~ s/\{[^\{\}]*\}/1/ || | 2793 | $dstat =~ s/\{[^\{\}]*\}/1/ || |
2973 | $dstat =~ s/\[[^\[\]]*\]/1/) | 2794 | $dstat =~ s/\[[^\{\}]*\]/1/) |
2974 | { | ||
2975 | } | ||
2976 | |||
2977 | # Flatten any obvious string concatentation. | ||
2978 | while ($dstat =~ s/("X*")\s*$Ident/$1/ || | ||
2979 | $dstat =~ s/$Ident\s*("X*")/$1/) | ||
2980 | { | 2795 | { |
2981 | } | 2796 | } |
2982 | 2797 | ||
2983 | my $exceptions = qr{ | 2798 | my $exceptions = qr{ |
2984 | $Declare| | 2799 | $Declare| |
2985 | module_param_named| | 2800 | module_param_named| |
2986 | MODULE_PARM_DESC| | 2801 | MODULE_PARAM_DESC| |
2987 | DECLARE_PER_CPU| | 2802 | DECLARE_PER_CPU| |
2988 | DEFINE_PER_CPU| | 2803 | DEFINE_PER_CPU| |
2989 | __typeof__\(| | 2804 | __typeof__\(| |
@@ -2993,84 +2808,23 @@ sub process { | |||
2993 | ^\"|\"$ | 2808 | ^\"|\"$ |
2994 | }x; | 2809 | }x; |
2995 | #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; | 2810 | #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; |
2996 | if ($dstat ne '' && | 2811 | if ($rest ne '' && $rest ne ',') { |
2997 | $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), | 2812 | if ($rest !~ /while\s*\(/ && |
2998 | $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo(); | 2813 | $dstat !~ /$exceptions/) |
2999 | $dstat !~ /^[!~-]?(?:$Ident|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo | 2814 | { |
3000 | $dstat !~ /^'X'$/ && # character constants | ||
3001 | $dstat !~ /$exceptions/ && | ||
3002 | $dstat !~ /^\.$Ident\s*=/ && # .foo = | ||
3003 | $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ && # do {...} while (...); // do {...} while (...) | ||
3004 | $dstat !~ /^for\s*$Constant$/ && # for (...) | ||
3005 | $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar() | ||
3006 | $dstat !~ /^do\s*{/ && # do {... | ||
3007 | $dstat !~ /^\({/) # ({... | ||
3008 | { | ||
3009 | $ctx =~ s/\n*$//; | ||
3010 | my $herectx = $here . "\n"; | ||
3011 | my $cnt = statement_rawlines($ctx); | ||
3012 | |||
3013 | for (my $n = 0; $n < $cnt; $n++) { | ||
3014 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
3015 | } | ||
3016 | |||
3017 | if ($dstat =~ /;/) { | ||
3018 | ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", | 2815 | ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", |
3019 | "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx"); | 2816 | "Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n"); |
3020 | } else { | ||
3021 | ERROR("COMPLEX_MACRO", | ||
3022 | "Macros with complex values should be enclosed in parenthesis\n" . "$herectx"); | ||
3023 | } | 2817 | } |
3024 | } | ||
3025 | |||
3026 | # check for line continuations outside of #defines, preprocessor #, and asm | ||
3027 | |||
3028 | } else { | ||
3029 | if ($prevline !~ /^..*\\$/ && | ||
3030 | $line !~ /^\+\s*\#.*\\$/ && # preprocessor | ||
3031 | $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ && # asm | ||
3032 | $line =~ /^\+.*\\$/) { | ||
3033 | WARN("LINE_CONTINUATIONS", | ||
3034 | "Avoid unnecessary line continuations\n" . $herecurr); | ||
3035 | } | ||
3036 | } | ||
3037 | |||
3038 | # do {} while (0) macro tests: | ||
3039 | # single-statement macros do not need to be enclosed in do while (0) loop, | ||
3040 | # macro should not end with a semicolon | ||
3041 | if ($^V && $^V ge 5.10.0 && | ||
3042 | $realfile !~ m@/vmlinux.lds.h$@ && | ||
3043 | $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) { | ||
3044 | my $ln = $linenr; | ||
3045 | my $cnt = $realcnt; | ||
3046 | my ($off, $dstat, $dcond, $rest); | ||
3047 | my $ctx = ''; | ||
3048 | ($dstat, $dcond, $ln, $cnt, $off) = | ||
3049 | ctx_statement_block($linenr, $realcnt, 0); | ||
3050 | $ctx = $dstat; | ||
3051 | 2818 | ||
3052 | $dstat =~ s/\\\n.//g; | 2819 | } elsif ($ctx !~ /;/) { |
3053 | 2820 | if ($dstat ne '' && | |
3054 | if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) { | 2821 | $dstat !~ /^(?:$Ident|-?$Constant)$/ && |
3055 | my $stmts = $2; | 2822 | $dstat !~ /$exceptions/ && |
3056 | my $semis = $3; | 2823 | $dstat !~ /^\.$Ident\s*=/ && |
3057 | 2824 | $dstat =~ /$Operators/) | |
3058 | $ctx =~ s/\n*$//; | 2825 | { |
3059 | my $cnt = statement_rawlines($ctx); | 2826 | ERROR("COMPLEX_MACRO", |
3060 | my $herectx = $here . "\n"; | 2827 | "Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n"); |
3061 | |||
3062 | for (my $n = 0; $n < $cnt; $n++) { | ||
3063 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
3064 | } | ||
3065 | |||
3066 | if (($stmts =~ tr/;/;/) == 1 && | ||
3067 | $stmts !~ /^\s*(if|while|for|switch)\b/) { | ||
3068 | WARN("SINGLE_STATEMENT_DO_WHILE_MACRO", | ||
3069 | "Single statement macros should not use a do {} while (0) loop\n" . "$herectx"); | ||
3070 | } | ||
3071 | if (defined $semis && $semis ne "") { | ||
3072 | WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON", | ||
3073 | "do {} while (0) macros should not be semicolon terminated\n" . "$herectx"); | ||
3074 | } | 2828 | } |
3075 | } | 2829 | } |
3076 | } | 2830 | } |
@@ -3092,8 +2846,7 @@ sub process { | |||
3092 | #print "chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n"; | 2846 | #print "chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n"; |
3093 | #print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n"; | 2847 | #print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n"; |
3094 | if ($#chunks > 0 && $level == 0) { | 2848 | if ($#chunks > 0 && $level == 0) { |
3095 | my @allowed = (); | 2849 | my $allowed = 0; |
3096 | my $allow = 0; | ||
3097 | my $seen = 0; | 2850 | my $seen = 0; |
3098 | my $herectx = $here . "\n"; | 2851 | my $herectx = $here . "\n"; |
3099 | my $ln = $linenr - 1; | 2852 | my $ln = $linenr - 1; |
@@ -3104,7 +2857,6 @@ sub process { | |||
3104 | my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s); | 2857 | my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s); |
3105 | my $offset = statement_rawlines($whitespace) - 1; | 2858 | my $offset = statement_rawlines($whitespace) - 1; |
3106 | 2859 | ||
3107 | $allowed[$allow] = 0; | ||
3108 | #print "COND<$cond> whitespace<$whitespace> offset<$offset>\n"; | 2860 | #print "COND<$cond> whitespace<$whitespace> offset<$offset>\n"; |
3109 | 2861 | ||
3110 | # We have looked at and allowed this specific line. | 2862 | # We have looked at and allowed this specific line. |
@@ -3117,34 +2869,23 @@ sub process { | |||
3117 | 2869 | ||
3118 | $seen++ if ($block =~ /^\s*{/); | 2870 | $seen++ if ($block =~ /^\s*{/); |
3119 | 2871 | ||
3120 | #print "cond<$cond> block<$block> allowed<$allowed[$allow]>\n"; | 2872 | #print "cond<$cond> block<$block> allowed<$allowed>\n"; |
3121 | if (statement_lines($cond) > 1) { | 2873 | if (statement_lines($cond) > 1) { |
3122 | #print "APW: ALLOWED: cond<$cond>\n"; | 2874 | #print "APW: ALLOWED: cond<$cond>\n"; |
3123 | $allowed[$allow] = 1; | 2875 | $allowed = 1; |
3124 | } | 2876 | } |
3125 | if ($block =~/\b(?:if|for|while)\b/) { | 2877 | if ($block =~/\b(?:if|for|while)\b/) { |
3126 | #print "APW: ALLOWED: block<$block>\n"; | 2878 | #print "APW: ALLOWED: block<$block>\n"; |
3127 | $allowed[$allow] = 1; | 2879 | $allowed = 1; |
3128 | } | 2880 | } |
3129 | if (statement_block_size($block) > 1) { | 2881 | if (statement_block_size($block) > 1) { |
3130 | #print "APW: ALLOWED: lines block<$block>\n"; | 2882 | #print "APW: ALLOWED: lines block<$block>\n"; |
3131 | $allowed[$allow] = 1; | 2883 | $allowed = 1; |
3132 | } | 2884 | } |
3133 | $allow++; | ||
3134 | } | 2885 | } |
3135 | if ($seen) { | 2886 | if ($seen && !$allowed) { |
3136 | my $sum_allowed = 0; | 2887 | WARN("BRACES", |
3137 | foreach (@allowed) { | 2888 | "braces {} are not necessary for any arm of this statement\n" . $herectx); |
3138 | $sum_allowed += $_; | ||
3139 | } | ||
3140 | if ($sum_allowed == 0) { | ||
3141 | WARN("BRACES", | ||
3142 | "braces {} are not necessary for any arm of this statement\n" . $herectx); | ||
3143 | } elsif ($sum_allowed != $allow && | ||
3144 | $seen != $allow) { | ||
3145 | CHK("BRACES", | ||
3146 | "braces {} should be used on all arms of this statement\n" . $herectx); | ||
3147 | } | ||
3148 | } | 2889 | } |
3149 | } | 2890 | } |
3150 | } | 2891 | } |
@@ -3191,11 +2932,11 @@ sub process { | |||
3191 | } | 2932 | } |
3192 | } | 2933 | } |
3193 | if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) { | 2934 | if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) { |
3194 | my $herectx = $here . "\n"; | 2935 | my $herectx = $here . "\n";; |
3195 | my $cnt = statement_rawlines($block); | 2936 | my $cnt = statement_rawlines($block); |
3196 | 2937 | ||
3197 | for (my $n = 0; $n < $cnt; $n++) { | 2938 | for (my $n = 0; $n < $cnt; $n++) { |
3198 | $herectx .= raw_line($linenr, $n) . "\n"; | 2939 | $herectx .= raw_line($linenr, $n) . "\n";; |
3199 | } | 2940 | } |
3200 | 2941 | ||
3201 | WARN("BRACES", | 2942 | WARN("BRACES", |
@@ -3203,14 +2944,20 @@ sub process { | |||
3203 | } | 2944 | } |
3204 | } | 2945 | } |
3205 | 2946 | ||
3206 | # check for unnecessary blank lines around braces | 2947 | # don't include deprecated include files (uses RAW line) |
3207 | if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) { | 2948 | for my $inc (@dep_includes) { |
3208 | CHK("BRACES", | 2949 | if ($rawline =~ m@^.\s*\#\s*include\s*\<$inc>@) { |
3209 | "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); | 2950 | ERROR("DEPRECATED_INCLUDE", |
2951 | "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr); | ||
2952 | } | ||
3210 | } | 2953 | } |
3211 | if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { | 2954 | |
3212 | CHK("BRACES", | 2955 | # don't use deprecated functions |
3213 | "Blank lines aren't necessary after an open brace '{'\n" . $hereprev); | 2956 | for my $func (@dep_functions) { |
2957 | if ($line =~ /\b$func\b/) { | ||
2958 | ERROR("DEPRECATED_FUNCTION", | ||
2959 | "Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr); | ||
2960 | } | ||
3214 | } | 2961 | } |
3215 | 2962 | ||
3216 | # no volatiles please | 2963 | # no volatiles please |
@@ -3227,12 +2974,20 @@ sub process { | |||
3227 | $herecurr); | 2974 | $herecurr); |
3228 | } | 2975 | } |
3229 | 2976 | ||
3230 | # check for needless "if (<foo>) fn(<foo>)" uses | 2977 | # check for needless kfree() checks |
3231 | if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) { | 2978 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { |
3232 | my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;'; | 2979 | my $expr = $1; |
3233 | if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) { | 2980 | if ($line =~ /\bkfree\(\Q$expr\E\);/) { |
3234 | WARN('NEEDLESS_IF', | 2981 | WARN("NEEDLESS_KFREE", |
3235 | "$1(NULL) is safe this check is probably not required\n" . $hereprev); | 2982 | "kfree(NULL) is safe this check is probably not required\n" . $hereprev); |
2983 | } | ||
2984 | } | ||
2985 | # check for needless usb_free_urb() checks | ||
2986 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { | ||
2987 | my $expr = $1; | ||
2988 | if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) { | ||
2989 | WARN("NEEDLESS_USB_FREE_URB", | ||
2990 | "usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev); | ||
3236 | } | 2991 | } |
3237 | } | 2992 | } |
3238 | 2993 | ||
@@ -3320,100 +3075,18 @@ sub process { | |||
3320 | "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); | 3075 | "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); |
3321 | } | 3076 | } |
3322 | 3077 | ||
3323 | # Check for __attribute__ format(printf, prefer __printf | ||
3324 | if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { | ||
3325 | WARN("PREFER_PRINTF", | ||
3326 | "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr); | ||
3327 | } | ||
3328 | |||
3329 | # Check for __attribute__ format(scanf, prefer __scanf | ||
3330 | if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) { | ||
3331 | WARN("PREFER_SCANF", | ||
3332 | "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr); | ||
3333 | } | ||
3334 | |||
3335 | # check for sizeof(&) | 3078 | # check for sizeof(&) |
3336 | if ($line =~ /\bsizeof\s*\(\s*\&/) { | 3079 | if ($line =~ /\bsizeof\s*\(\s*\&/) { |
3337 | WARN("SIZEOF_ADDRESS", | 3080 | WARN("SIZEOF_ADDRESS", |
3338 | "sizeof(& should be avoided\n" . $herecurr); | 3081 | "sizeof(& should be avoided\n" . $herecurr); |
3339 | } | 3082 | } |
3340 | 3083 | ||
3341 | # check for sizeof without parenthesis | ||
3342 | if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) { | ||
3343 | WARN("SIZEOF_PARENTHESIS", | ||
3344 | "sizeof $1 should be sizeof($1)\n" . $herecurr); | ||
3345 | } | ||
3346 | |||
3347 | # check for line continuations in quoted strings with odd counts of " | 3084 | # check for line continuations in quoted strings with odd counts of " |
3348 | if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { | 3085 | if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { |
3349 | WARN("LINE_CONTINUATIONS", | 3086 | WARN("LINE_CONTINUATIONS", |
3350 | "Avoid line continuations in quoted strings\n" . $herecurr); | 3087 | "Avoid line continuations in quoted strings\n" . $herecurr); |
3351 | } | 3088 | } |
3352 | 3089 | ||
3353 | # check for struct spinlock declarations | ||
3354 | if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) { | ||
3355 | WARN("USE_SPINLOCK_T", | ||
3356 | "struct spinlock should be spinlock_t\n" . $herecurr); | ||
3357 | } | ||
3358 | |||
3359 | # Check for misused memsets | ||
3360 | if ($^V && $^V ge 5.10.0 && | ||
3361 | defined $stat && | ||
3362 | $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/s) { | ||
3363 | |||
3364 | my $ms_addr = $2; | ||
3365 | my $ms_val = $7; | ||
3366 | my $ms_size = $12; | ||
3367 | |||
3368 | if ($ms_size =~ /^(0x|)0$/i) { | ||
3369 | ERROR("MEMSET", | ||
3370 | "memset to 0's uses 0 as the 2nd argument, not the 3rd\n" . "$here\n$stat\n"); | ||
3371 | } elsif ($ms_size =~ /^(0x|)1$/i) { | ||
3372 | WARN("MEMSET", | ||
3373 | "single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . "$here\n$stat\n"); | ||
3374 | } | ||
3375 | } | ||
3376 | |||
3377 | # typecasts on min/max could be min_t/max_t | ||
3378 | if ($^V && $^V ge 5.10.0 && | ||
3379 | defined $stat && | ||
3380 | $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { | ||
3381 | if (defined $2 || defined $7) { | ||
3382 | my $call = $1; | ||
3383 | my $cast1 = deparenthesize($2); | ||
3384 | my $arg1 = $3; | ||
3385 | my $cast2 = deparenthesize($7); | ||
3386 | my $arg2 = $8; | ||
3387 | my $cast; | ||
3388 | |||
3389 | if ($cast1 ne "" && $cast2 ne "" && $cast1 ne $cast2) { | ||
3390 | $cast = "$cast1 or $cast2"; | ||
3391 | } elsif ($cast1 ne "") { | ||
3392 | $cast = $cast1; | ||
3393 | } else { | ||
3394 | $cast = $cast2; | ||
3395 | } | ||
3396 | WARN("MINMAX", | ||
3397 | "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . "$here\n$stat\n"); | ||
3398 | } | ||
3399 | } | ||
3400 | |||
3401 | # check usleep_range arguments | ||
3402 | if ($^V && $^V ge 5.10.0 && | ||
3403 | defined $stat && | ||
3404 | $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) { | ||
3405 | my $min = $1; | ||
3406 | my $max = $7; | ||
3407 | if ($min eq $max) { | ||
3408 | WARN("USLEEP_RANGE", | ||
3409 | "usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
3410 | } elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ && | ||
3411 | $min > $max) { | ||
3412 | WARN("USLEEP_RANGE", | ||
3413 | "usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
3414 | } | ||
3415 | } | ||
3416 | |||
3417 | # check for new externs in .c files. | 3090 | # check for new externs in .c files. |
3418 | if ($realfile =~ /\.c$/ && defined $stat && | 3091 | if ($realfile =~ /\.c$/ && defined $stat && |
3419 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) | 3092 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) |
@@ -3462,22 +3135,8 @@ sub process { | |||
3462 | 3135 | ||
3463 | # check for multiple semicolons | 3136 | # check for multiple semicolons |
3464 | if ($line =~ /;\s*;\s*$/) { | 3137 | if ($line =~ /;\s*;\s*$/) { |
3465 | WARN("ONE_SEMICOLON", | 3138 | WARN("ONE_SEMICOLON", |
3466 | "Statements terminations use 1 semicolon\n" . $herecurr); | 3139 | "Statements terminations use 1 semicolon\n" . $herecurr); |
3467 | } | ||
3468 | |||
3469 | # check for switch/default statements without a break; | ||
3470 | if ($^V && $^V ge 5.10.0 && | ||
3471 | defined $stat && | ||
3472 | $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) { | ||
3473 | my $ctx = ''; | ||
3474 | my $herectx = $here . "\n"; | ||
3475 | my $cnt = statement_rawlines($stat); | ||
3476 | for (my $n = 0; $n < $cnt; $n++) { | ||
3477 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
3478 | } | ||
3479 | WARN("DEFAULT_NO_BREAK", | ||
3480 | "switch default: should use break\n" . $herectx); | ||
3481 | } | 3140 | } |
3482 | 3141 | ||
3483 | # check for gcc specific __FUNCTION__ | 3142 | # check for gcc specific __FUNCTION__ |
@@ -3486,30 +3145,22 @@ sub process { | |||
3486 | "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); | 3145 | "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); |
3487 | } | 3146 | } |
3488 | 3147 | ||
3489 | # check for use of yield() | ||
3490 | if ($line =~ /\byield\s*\(\s*\)/) { | ||
3491 | WARN("YIELD", | ||
3492 | "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n" . $herecurr); | ||
3493 | } | ||
3494 | |||
3495 | # check for semaphores initialized locked | 3148 | # check for semaphores initialized locked |
3496 | if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { | 3149 | if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { |
3497 | WARN("CONSIDER_COMPLETION", | 3150 | WARN("CONSIDER_COMPLETION", |
3498 | "consider using a completion\n" . $herecurr); | 3151 | "consider using a completion\n" . $herecurr); |
3499 | } | ||
3500 | 3152 | ||
3501 | # recommend kstrto* over simple_strto* and strict_strto* | 3153 | } |
3502 | if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) { | 3154 | # recommend kstrto* over simple_strto* |
3155 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { | ||
3503 | WARN("CONSIDER_KSTRTO", | 3156 | WARN("CONSIDER_KSTRTO", |
3504 | "$1 is obsolete, use k$3 instead\n" . $herecurr); | 3157 | "consider using kstrto* in preference to simple_$1\n" . $herecurr); |
3505 | } | 3158 | } |
3506 | |||
3507 | # check for __initcall(), use device_initcall() explicitly please | 3159 | # check for __initcall(), use device_initcall() explicitly please |
3508 | if ($line =~ /^.\s*__initcall\s*\(/) { | 3160 | if ($line =~ /^.\s*__initcall\s*\(/) { |
3509 | WARN("USE_DEVICE_INITCALL", | 3161 | WARN("USE_DEVICE_INITCALL", |
3510 | "please use device_initcall() instead of __initcall()\n" . $herecurr); | 3162 | "please use device_initcall() instead of __initcall()\n" . $herecurr); |
3511 | } | 3163 | } |
3512 | |||
3513 | # check for various ops structs, ensure they are const. | 3164 | # check for various ops structs, ensure they are const. |
3514 | my $struct_ops = qr{acpi_dock_ops| | 3165 | my $struct_ops = qr{acpi_dock_ops| |
3515 | address_space_operations| | 3166 | address_space_operations| |
@@ -3607,6 +3258,12 @@ sub process { | |||
3607 | WARN("EXPORTED_WORLD_WRITABLE", | 3258 | WARN("EXPORTED_WORLD_WRITABLE", |
3608 | "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); | 3259 | "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); |
3609 | } | 3260 | } |
3261 | |||
3262 | # Check for memset with swapped arguments | ||
3263 | if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) { | ||
3264 | ERROR("MEMSET", | ||
3265 | "memset size is 3rd argument, not the second.\n" . $herecurr); | ||
3266 | } | ||
3610 | } | 3267 | } |
3611 | 3268 | ||
3612 | # If we have no input at all, then there is nothing to report on | 3269 | # If we have no input at all, then there is nothing to report on |
@@ -3646,12 +3303,6 @@ sub process { | |||
3646 | } | 3303 | } |
3647 | 3304 | ||
3648 | if ($quiet == 0) { | 3305 | if ($quiet == 0) { |
3649 | |||
3650 | if ($^V lt 5.10.0) { | ||
3651 | print("NOTE: perl $^V is not modern enough to detect all possible issues.\n"); | ||
3652 | print("An upgrade to at least perl v5.10.0 is suggested.\n\n"); | ||
3653 | } | ||
3654 | |||
3655 | # If there were whitespace errors which cleanpatch can fix | 3306 | # If there were whitespace errors which cleanpatch can fix |
3656 | # then suggest that. | 3307 | # then suggest that. |
3657 | if ($rpt_cleaners) { | 3308 | if ($rpt_cleaners) { |
@@ -3661,12 +3312,13 @@ sub process { | |||
3661 | } | 3312 | } |
3662 | } | 3313 | } |
3663 | 3314 | ||
3664 | if ($quiet == 0 && keys %ignore_type) { | 3315 | if (keys %ignore_type) { |
3665 | print "NOTE: Ignored message types:"; | 3316 | print "NOTE: Ignored message types:"; |
3666 | foreach my $ignore (sort keys %ignore_type) { | 3317 | foreach my $ignore (sort keys %ignore_type) { |
3667 | print " $ignore"; | 3318 | print " $ignore"; |
3668 | } | 3319 | } |
3669 | print "\n\n"; | 3320 | print "\n"; |
3321 | print "\n" if ($quiet == 0); | ||
3670 | } | 3322 | } |
3671 | 3323 | ||
3672 | if ($clean == 1 && $quiet == 0) { | 3324 | if ($clean == 1 && $quiet == 0) { |
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh index fd8fa9aa7c4..3ab316e5231 100755 --- a/scripts/checksyscalls.sh +++ b/scripts/checksyscalls.sh | |||
@@ -198,16 +198,11 @@ EOF | |||
198 | } | 198 | } |
199 | 199 | ||
200 | syscall_list() { | 200 | syscall_list() { |
201 | grep '^[0-9]' "$1" | sort -n | ( | 201 | sed -n -e '/^\#define/ s/[^_]*__NR_\([^[:space:]]*\).*/\ |
202 | while read nr abi name entry ; do | 202 | \#if !defined \(__NR_\1\) \&\& !defined \(__IGNORE_\1\)\ |
203 | cat <<EOF | 203 | \#warning syscall \1 not implemented\ |
204 | #if !defined(__NR_${name}) && !defined(__IGNORE_${name}) | 204 | \#endif/p' $1 |
205 | #warning syscall ${name} not implemented | ||
206 | #endif | ||
207 | EOF | ||
208 | done | ||
209 | ) | ||
210 | } | 205 | } |
211 | 206 | ||
212 | (ignore_list && syscall_list $(dirname $0)/../arch/x86/syscalls/syscall_32.tbl) | \ | 207 | (ignore_list && syscall_list $(dirname $0)/../arch/x86/include/asm/unistd_32.h) | \ |
213 | $* -E -x c - > /dev/null | 208 | $* -E -x c - > /dev/null |
diff --git a/scripts/coccicheck b/scripts/coccicheck index 1a49d1c7ecf..1bb1a1bd2da 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck | |||
@@ -10,17 +10,13 @@ if [ "$C" = "1" -o "$C" = "2" ]; then | |||
10 | # OPTIONS=$* | 10 | # OPTIONS=$* |
11 | 11 | ||
12 | # Workaround for Coccinelle < 0.2.3 | 12 | # Workaround for Coccinelle < 0.2.3 |
13 | FLAGS="-I $srctree/include -very_quiet" | 13 | FLAGS="-I $srctree/include -very_quiet" |
14 | shift $(( $# - 1 )) | 14 | shift $(( $# - 1 )) |
15 | OPTIONS=$1 | 15 | OPTIONS=$1 |
16 | else | 16 | else |
17 | ONLINE=0 | 17 | ONLINE=0 |
18 | FLAGS="-very_quiet" | 18 | FLAGS="-very_quiet" |
19 | if [ "$KBUILD_EXTMOD" = "" ] ; then | 19 | OPTIONS="-dir $srctree" |
20 | OPTIONS="-dir $srctree" | ||
21 | else | ||
22 | OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree -I $srctree/include -I $KBUILD_EXTMOD/include" | ||
23 | fi | ||
24 | fi | 20 | fi |
25 | 21 | ||
26 | if [ ! -x "$SPATCH" ]; then | 22 | if [ ! -x "$SPATCH" ]; then |
@@ -95,9 +91,6 @@ coccinelle () { | |||
95 | $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ | 91 | $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ |
96 | $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ | 92 | $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ |
97 | $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 | 93 | $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 |
98 | elif [ "$MODE" = "rep+ctxt" ] ; then | ||
99 | $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \ | ||
100 | $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 | ||
101 | else | 94 | else |
102 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 | 95 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 |
103 | fi | 96 | fi |
diff --git a/scripts/coccinelle/api/d_find_alias.cocci b/scripts/coccinelle/api/d_find_alias.cocci deleted file mode 100644 index a9694a8d3e5..00000000000 --- a/scripts/coccinelle/api/d_find_alias.cocci +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | /// Make sure calls to d_find_alias() have a corresponding call to dput(). | ||
2 | // | ||
3 | // Keywords: d_find_alias, dput | ||
4 | // | ||
5 | // Confidence: Moderate | ||
6 | // URL: http://coccinelle.lip6.fr/ | ||
7 | // Options: -include_headers | ||
8 | |||
9 | virtual context | ||
10 | virtual org | ||
11 | virtual patch | ||
12 | virtual report | ||
13 | |||
14 | @r exists@ | ||
15 | local idexpression struct dentry *dent; | ||
16 | expression E, E1; | ||
17 | statement S1, S2; | ||
18 | position p1, p2; | ||
19 | @@ | ||
20 | ( | ||
21 | if (!(dent@p1 = d_find_alias(...))) S1 | ||
22 | | | ||
23 | dent@p1 = d_find_alias(...) | ||
24 | ) | ||
25 | |||
26 | <...when != dput(dent) | ||
27 | when != if (...) { <+... dput(dent) ...+> } | ||
28 | when != true !dent || ... | ||
29 | when != dent = E | ||
30 | when != E = dent | ||
31 | if (!dent || ...) S2 | ||
32 | ...> | ||
33 | ( | ||
34 | return <+...dent...+>; | ||
35 | | | ||
36 | return @p2 ...; | ||
37 | | | ||
38 | dent@p2 = E1; | ||
39 | | | ||
40 | E1 = dent; | ||
41 | ) | ||
42 | |||
43 | @depends on context@ | ||
44 | local idexpression struct dentry *r.dent; | ||
45 | position r.p1,r.p2; | ||
46 | @@ | ||
47 | * dent@p1 = ... | ||
48 | ... | ||
49 | ( | ||
50 | * return@p2 ...; | ||
51 | | | ||
52 | * dent@p2 | ||
53 | ) | ||
54 | |||
55 | |||
56 | @script:python depends on org@ | ||
57 | p1 << r.p1; | ||
58 | p2 << r.p2; | ||
59 | @@ | ||
60 | cocci.print_main("Missing call to dput()",p1) | ||
61 | cocci.print_secs("",p2) | ||
62 | |||
63 | @depends on patch@ | ||
64 | local idexpression struct dentry *r.dent; | ||
65 | position r.p2; | ||
66 | @@ | ||
67 | ( | ||
68 | + dput(dent); | ||
69 | return @p2 ...; | ||
70 | | | ||
71 | + dput(dent); | ||
72 | dent@p2 = ...; | ||
73 | ) | ||
74 | |||
75 | @script:python depends on report@ | ||
76 | p1 << r.p1; | ||
77 | p2 << r.p2; | ||
78 | @@ | ||
79 | msg = "Missing call to dput() at line %s." | ||
80 | coccilib.report.print_report(p1[0], msg % (p2[0].line)) | ||
diff --git a/scripts/coccinelle/api/devm_request_and_ioremap.cocci b/scripts/coccinelle/api/devm_request_and_ioremap.cocci deleted file mode 100644 index 46beb81406a..00000000000 --- a/scripts/coccinelle/api/devm_request_and_ioremap.cocci +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | /// Reimplement a call to devm_request_mem_region followed by a call to ioremap | ||
2 | /// or ioremap_nocache by a call to devm_request_and_ioremap. | ||
3 | /// Devm_request_and_ioremap was introduced in | ||
4 | /// 72f8c0bfa0de64c68ee59f40eb9b2683bffffbb0. It makes the code much more | ||
5 | /// concise. | ||
6 | /// | ||
7 | /// | ||
8 | // Confidence: High | ||
9 | // Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. GPLv2. | ||
10 | // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2. | ||
11 | // URL: http://coccinelle.lip6.fr/ | ||
12 | // Comments: | ||
13 | // Options: -no_includes -include_headers | ||
14 | |||
15 | virtual patch | ||
16 | virtual org | ||
17 | virtual report | ||
18 | virtual context | ||
19 | |||
20 | @nm@ | ||
21 | expression myname; | ||
22 | identifier i; | ||
23 | @@ | ||
24 | |||
25 | struct platform_driver i = { .driver = { .name = myname } }; | ||
26 | |||
27 | @depends on patch@ | ||
28 | expression dev,res,size; | ||
29 | @@ | ||
30 | |||
31 | -if (!devm_request_mem_region(dev, res->start, size, | ||
32 | - \(res->name\|dev_name(dev)\))) { | ||
33 | - ... | ||
34 | - return ...; | ||
35 | -} | ||
36 | ... when != res->start | ||
37 | ( | ||
38 | -devm_ioremap(dev,res->start,size) | ||
39 | +devm_request_and_ioremap(dev,res) | ||
40 | | | ||
41 | -devm_ioremap_nocache(dev,res->start,size) | ||
42 | +devm_request_and_ioremap(dev,res) | ||
43 | ) | ||
44 | ... when any | ||
45 | when != res->start | ||
46 | |||
47 | // this rule is separate from the previous one, because a single file can | ||
48 | // have multiple values of myname | ||
49 | @depends on patch@ | ||
50 | expression dev,res,size; | ||
51 | expression nm.myname; | ||
52 | @@ | ||
53 | |||
54 | -if (!devm_request_mem_region(dev, res->start, size,myname)) { | ||
55 | - ... | ||
56 | - return ...; | ||
57 | -} | ||
58 | ... when != res->start | ||
59 | ( | ||
60 | -devm_ioremap(dev,res->start,size) | ||
61 | +devm_request_and_ioremap(dev,res) | ||
62 | | | ||
63 | -devm_ioremap_nocache(dev,res->start,size) | ||
64 | +devm_request_and_ioremap(dev,res) | ||
65 | ) | ||
66 | ... when any | ||
67 | when != res->start | ||
68 | |||
69 | |||
70 | @pb depends on org || report || context@ | ||
71 | expression dev,res,size; | ||
72 | expression nm.myname; | ||
73 | position p1,p2; | ||
74 | @@ | ||
75 | |||
76 | *if | ||
77 | (!devm_request_mem_region@p1(dev, res->start, size, | ||
78 | \(res->name\|dev_name(dev)\|myname\))) { | ||
79 | ... | ||
80 | return ...; | ||
81 | } | ||
82 | ... when != res->start | ||
83 | ( | ||
84 | *devm_ioremap@p2(dev,res->start,size) | ||
85 | | | ||
86 | *devm_ioremap_nocache@p2(dev,res->start,size) | ||
87 | ) | ||
88 | ... when any | ||
89 | when != res->start | ||
90 | |||
91 | @script:python depends on org@ | ||
92 | p1 << pb.p1; | ||
93 | p2 << pb.p2; | ||
94 | @@ | ||
95 | |||
96 | cocci.print_main("INFO: replace by devm_request_and_ioremap",p1) | ||
97 | cocci.print_secs("",p2) | ||
98 | |||
99 | @script:python depends on report@ | ||
100 | p1 << pb.p1; | ||
101 | p2 << pb.p2; | ||
102 | @@ | ||
103 | |||
104 | msg = "INFO: devm_request_mem_region followed by ioremap on line %s can be replaced by devm_request_and_ioremap" % (p2[0].line) | ||
105 | coccilib.report.print_report(p1[0],msg) | ||
diff --git a/scripts/coccinelle/api/kstrdup.cocci b/scripts/coccinelle/api/kstrdup.cocci index 07a74b2c619..e0805ad08d3 100644 --- a/scripts/coccinelle/api/kstrdup.cocci +++ b/scripts/coccinelle/api/kstrdup.cocci | |||
@@ -1,19 +1,16 @@ | |||
1 | /// Use kstrdup rather than duplicating its implementation | 1 | /// Use kstrdup rather than duplicating its implementation |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
10 | 10 | ||
11 | virtual patch | 11 | virtual patch |
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | 12 | ||
16 | @depends on patch@ | 13 | @@ |
17 | expression from,to; | 14 | expression from,to; |
18 | expression flag,E1,E2; | 15 | expression flag,E1,E2; |
19 | statement S; | 16 | statement S; |
@@ -26,7 +23,7 @@ statement S; | |||
26 | ... when != \(from = E2 \| to = E2 \) | 23 | ... when != \(from = E2 \| to = E2 \) |
27 | - strcpy(to, from); | 24 | - strcpy(to, from); |
28 | 25 | ||
29 | @depends on patch@ | 26 | @@ |
30 | expression x,from,to; | 27 | expression x,from,to; |
31 | expression flag,E1,E2,E3; | 28 | expression flag,E1,E2,E3; |
32 | statement S; | 29 | statement S; |
@@ -40,65 +37,3 @@ statement S; | |||
40 | if (to==NULL || ...) S | 37 | if (to==NULL || ...) S |
41 | ... when != \(x = E3 \| from = E3 \| to = E3 \) | 38 | ... when != \(x = E3 \| from = E3 \| to = E3 \) |
42 | - memcpy(to, from, x); | 39 | - memcpy(to, from, x); |
43 | |||
44 | // --------------------------------------------------------------------- | ||
45 | |||
46 | @r1 depends on !patch exists@ | ||
47 | expression from,to; | ||
48 | expression flag,E1,E2; | ||
49 | statement S; | ||
50 | position p1,p2; | ||
51 | @@ | ||
52 | |||
53 | * to = kmalloc@p1(strlen(from) + 1,flag); | ||
54 | ... when != \(from = E1 \| to = E1 \) | ||
55 | if (to==NULL || ...) S | ||
56 | ... when != \(from = E2 \| to = E2 \) | ||
57 | * strcpy@p2(to, from); | ||
58 | |||
59 | @r2 depends on !patch exists@ | ||
60 | expression x,from,to; | ||
61 | expression flag,E1,E2,E3; | ||
62 | statement S; | ||
63 | position p1,p2; | ||
64 | @@ | ||
65 | |||
66 | * x = strlen(from) + 1; | ||
67 | ... when != \( x = E1 \| from = E1 \) | ||
68 | * to = \(kmalloc@p1\|kzalloc@p2\)(x,flag); | ||
69 | ... when != \(x = E2 \| from = E2 \| to = E2 \) | ||
70 | if (to==NULL || ...) S | ||
71 | ... when != \(x = E3 \| from = E3 \| to = E3 \) | ||
72 | * memcpy@p2(to, from, x); | ||
73 | |||
74 | @script:python depends on org@ | ||
75 | p1 << r1.p1; | ||
76 | p2 << r1.p2; | ||
77 | @@ | ||
78 | |||
79 | cocci.print_main("WARNING opportunity for kstrdep",p1) | ||
80 | cocci.print_secs("strcpy",p2) | ||
81 | |||
82 | @script:python depends on org@ | ||
83 | p1 << r2.p1; | ||
84 | p2 << r2.p2; | ||
85 | @@ | ||
86 | |||
87 | cocci.print_main("WARNING opportunity for kstrdep",p1) | ||
88 | cocci.print_secs("memcpy",p2) | ||
89 | |||
90 | @script:python depends on report@ | ||
91 | p1 << r1.p1; | ||
92 | p2 << r1.p2; | ||
93 | @@ | ||
94 | |||
95 | msg = "WARNING opportunity for kstrdep (strcpy on line %s)" % (p2[0].line) | ||
96 | coccilib.report.print_report(p1[0], msg) | ||
97 | |||
98 | @script:python depends on report@ | ||
99 | p1 << r2.p1; | ||
100 | p2 << r2.p2; | ||
101 | @@ | ||
102 | |||
103 | msg = "WARNING opportunity for kstrdep (memcpy on line %s)" % (p2[0].line) | ||
104 | coccilib.report.print_report(p1[0], msg) | ||
diff --git a/scripts/coccinelle/api/memdup.cocci b/scripts/coccinelle/api/memdup.cocci index 4dceab6d54d..b5d722077dc 100644 --- a/scripts/coccinelle/api/memdup.cocci +++ b/scripts/coccinelle/api/memdup.cocci | |||
@@ -1,17 +1,14 @@ | |||
1 | /// Use kmemdup rather than duplicating its implementation | 1 | /// Use kmemdup rather than duplicating its implementation |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
10 | 10 | ||
11 | virtual patch | 11 | virtual patch |
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | 12 | ||
16 | @r1@ | 13 | @r1@ |
17 | expression from,to; | 14 | expression from,to; |
@@ -31,7 +28,7 @@ position p; | |||
31 | ... when != \( x = E1 \| from = E1 \) | 28 | ... when != \( x = E1 \| from = E1 \) |
32 | to = \(kmalloc@p\|kzalloc@p\)(x,flag); | 29 | to = \(kmalloc@p\|kzalloc@p\)(x,flag); |
33 | 30 | ||
34 | @depends on patch@ | 31 | @@ |
35 | expression from,to,size,flag; | 32 | expression from,to,size,flag; |
36 | position p != {r1.p,r2.p}; | 33 | position p != {r1.p,r2.p}; |
37 | statement S; | 34 | statement S; |
@@ -41,26 +38,3 @@ statement S; | |||
41 | + to = kmemdup(from,size,flag); | 38 | + to = kmemdup(from,size,flag); |
42 | if (to==NULL || ...) S | 39 | if (to==NULL || ...) S |
43 | - memcpy(to, from, size); | 40 | - memcpy(to, from, size); |
44 | |||
45 | @r depends on !patch@ | ||
46 | expression from,to,size,flag; | ||
47 | position p != {r1.p,r2.p}; | ||
48 | statement S; | ||
49 | @@ | ||
50 | |||
51 | * to = \(kmalloc@p\|kzalloc@p\)(size,flag); | ||
52 | to = kmemdup(from,size,flag); | ||
53 | if (to==NULL || ...) S | ||
54 | * memcpy(to, from, size); | ||
55 | |||
56 | @script:python depends on org@ | ||
57 | p << r.p; | ||
58 | @@ | ||
59 | |||
60 | coccilib.org.print_todo(p[0], "WARNING opportunity for kmemdep") | ||
61 | |||
62 | @script:python depends on report@ | ||
63 | p << r.p; | ||
64 | @@ | ||
65 | |||
66 | coccilib.report.print_report(p[0], "WARNING opportunity for kmemdep") | ||
diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci index 2b131a8a130..72ce012e878 100644 --- a/scripts/coccinelle/api/memdup_user.cocci +++ b/scripts/coccinelle/api/memdup_user.cocci | |||
@@ -1,25 +1,23 @@ | |||
1 | /// Use memdup_user rather than duplicating its implementation | 1 | /// Use kmemdup_user rather than duplicating its implementation |
2 | /// This is a little bit restricted to reduce false positives | 2 | /// This is a little bit restricted to reduce false positives |
3 | /// | 3 | /// |
4 | // Confidence: High | 4 | // Confidence: High |
5 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 5 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 6 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
7 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 7 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
8 | // URL: http://coccinelle.lip6.fr/ | 8 | // URL: http://coccinelle.lip6.fr/ |
9 | // Comments: | 9 | // Comments: |
10 | // Options: -no_includes -include_headers | 10 | // Options: -no_includes -include_headers |
11 | 11 | ||
12 | virtual patch | 12 | virtual patch |
13 | virtual context | ||
14 | virtual org | ||
15 | virtual report | ||
16 | 13 | ||
17 | @depends on patch@ | 14 | @@ |
18 | expression from,to,size,flag; | 15 | expression from,to,size,flag; |
16 | position p; | ||
19 | identifier l1,l2; | 17 | identifier l1,l2; |
20 | @@ | 18 | @@ |
21 | 19 | ||
22 | - to = \(kmalloc\|kzalloc\)(size,flag); | 20 | - to = \(kmalloc@p\|kzalloc@p\)(size,flag); |
23 | + to = memdup_user(from,size); | 21 | + to = memdup_user(from,size); |
24 | if ( | 22 | if ( |
25 | - to==NULL | 23 | - to==NULL |
@@ -35,26 +33,3 @@ identifier l1,l2; | |||
35 | - -EFAULT | 33 | - -EFAULT |
36 | - ...+> | 34 | - ...+> |
37 | - } | 35 | - } |
38 | |||
39 | @r depends on !patch@ | ||
40 | expression from,to,size,flag; | ||
41 | position p; | ||
42 | statement S1,S2; | ||
43 | @@ | ||
44 | |||
45 | * to = \(kmalloc@p\|kzalloc@p\)(size,flag); | ||
46 | if (to==NULL || ...) S1 | ||
47 | if (copy_from_user(to, from, size) != 0) | ||
48 | S2 | ||
49 | |||
50 | @script:python depends on org@ | ||
51 | p << r.p; | ||
52 | @@ | ||
53 | |||
54 | coccilib.org.print_todo(p[0], "WARNING opportunity for memdup_user") | ||
55 | |||
56 | @script:python depends on report@ | ||
57 | p << r.p; | ||
58 | @@ | ||
59 | |||
60 | coccilib.report.print_report(p[0], "WARNING opportunity for memdup_user") | ||
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci deleted file mode 100644 index 15f076fdecb..00000000000 --- a/scripts/coccinelle/api/ptr_ret.cocci +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | /// | ||
2 | /// Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Options: -no_includes -include_headers | ||
9 | // | ||
10 | // Keywords: ERR_PTR, PTR_ERR, PTR_RET | ||
11 | // Version min: 2.6.39 | ||
12 | // | ||
13 | |||
14 | virtual context | ||
15 | virtual patch | ||
16 | virtual org | ||
17 | virtual report | ||
18 | |||
19 | @depends on patch@ | ||
20 | expression ptr; | ||
21 | @@ | ||
22 | |||
23 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; | ||
24 | + return PTR_RET(ptr); | ||
25 | |||
26 | @depends on patch@ | ||
27 | expression ptr; | ||
28 | @@ | ||
29 | |||
30 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | ||
31 | + return PTR_RET(ptr); | ||
32 | |||
33 | @depends on patch@ | ||
34 | expression ptr; | ||
35 | @@ | ||
36 | |||
37 | - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) | ||
38 | + PTR_RET(ptr) | ||
39 | |||
40 | @r1 depends on !patch@ | ||
41 | expression ptr; | ||
42 | position p1; | ||
43 | @@ | ||
44 | |||
45 | * if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; | ||
46 | |||
47 | @r2 depends on !patch@ | ||
48 | expression ptr; | ||
49 | position p2; | ||
50 | @@ | ||
51 | |||
52 | * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | ||
53 | |||
54 | @r3 depends on !patch@ | ||
55 | expression ptr; | ||
56 | position p3; | ||
57 | @@ | ||
58 | |||
59 | * IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0 | ||
60 | |||
61 | @script:python depends on org@ | ||
62 | p << r1.p1; | ||
63 | @@ | ||
64 | |||
65 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | ||
66 | |||
67 | |||
68 | @script:python depends on org@ | ||
69 | p << r2.p2; | ||
70 | @@ | ||
71 | |||
72 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | ||
73 | |||
74 | @script:python depends on org@ | ||
75 | p << r3.p3; | ||
76 | @@ | ||
77 | |||
78 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | ||
79 | |||
80 | @script:python depends on report@ | ||
81 | p << r1.p1; | ||
82 | @@ | ||
83 | |||
84 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | ||
85 | |||
86 | @script:python depends on report@ | ||
87 | p << r2.p2; | ||
88 | @@ | ||
89 | |||
90 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | ||
91 | |||
92 | @script:python depends on report@ | ||
93 | p << r3.p3; | ||
94 | @@ | ||
95 | |||
96 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | ||
diff --git a/scripts/coccinelle/api/simple_open.cocci b/scripts/coccinelle/api/simple_open.cocci deleted file mode 100644 index 05962f7be15..00000000000 --- a/scripts/coccinelle/api/simple_open.cocci +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | /// This removes an open coded simple_open() function | ||
2 | /// and replaces file operations references to the function | ||
3 | /// with simple_open() instead. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Comments: | ||
7 | // Options: -no_includes -include_headers | ||
8 | |||
9 | virtual patch | ||
10 | virtual report | ||
11 | |||
12 | @ open depends on patch @ | ||
13 | identifier open_f != simple_open; | ||
14 | identifier i, f; | ||
15 | @@ | ||
16 | -int open_f(struct inode *i, struct file *f) | ||
17 | -{ | ||
18 | ( | ||
19 | -if (i->i_private) | ||
20 | -f->private_data = i->i_private; | ||
21 | | | ||
22 | -f->private_data = i->i_private; | ||
23 | ) | ||
24 | -return 0; | ||
25 | -} | ||
26 | |||
27 | @ has_open depends on open @ | ||
28 | identifier fops; | ||
29 | identifier open.open_f; | ||
30 | @@ | ||
31 | struct file_operations fops = { | ||
32 | ..., | ||
33 | -.open = open_f, | ||
34 | +.open = simple_open, | ||
35 | ... | ||
36 | }; | ||
37 | |||
38 | @ openr depends on report @ | ||
39 | identifier open_f != simple_open; | ||
40 | identifier i, f; | ||
41 | position p; | ||
42 | @@ | ||
43 | int open_f@p(struct inode *i, struct file *f) | ||
44 | { | ||
45 | ( | ||
46 | if (i->i_private) | ||
47 | f->private_data = i->i_private; | ||
48 | | | ||
49 | f->private_data = i->i_private; | ||
50 | ) | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | @ has_openr depends on openr @ | ||
55 | identifier fops; | ||
56 | identifier openr.open_f; | ||
57 | position p; | ||
58 | @@ | ||
59 | struct file_operations fops = { | ||
60 | ..., | ||
61 | .open = open_f@p, | ||
62 | ... | ||
63 | }; | ||
64 | |||
65 | @script:python@ | ||
66 | pf << openr.p; | ||
67 | ps << has_openr.p; | ||
68 | @@ | ||
69 | |||
70 | coccilib.report.print_report(pf[0],"WARNING opportunity for simple_open, see also structure on line %s"%(ps[0].line)) | ||
diff --git a/scripts/coccinelle/free/clk_put.cocci b/scripts/coccinelle/free/clk_put.cocci deleted file mode 100644 index 46747adfd20..00000000000 --- a/scripts/coccinelle/free/clk_put.cocci +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | /// Find missing clk_puts. | ||
2 | /// | ||
3 | //# This only signals a missing clk_put when there is a clk_put later | ||
4 | //# in the same function. | ||
5 | //# False positives can be due to loops. | ||
6 | // | ||
7 | // Confidence: Moderate | ||
8 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
9 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
10 | // URL: http://coccinelle.lip6.fr/ | ||
11 | // Comments: | ||
12 | // Options: | ||
13 | |||
14 | virtual context | ||
15 | virtual org | ||
16 | virtual report | ||
17 | |||
18 | @clk@ | ||
19 | expression e; | ||
20 | statement S,S1; | ||
21 | int ret; | ||
22 | position p1,p2,p3; | ||
23 | @@ | ||
24 | |||
25 | e = clk_get@p1(...) | ||
26 | ... when != clk_put(e) | ||
27 | if (<+...e...+>) S | ||
28 | ... when any | ||
29 | when != clk_put(e) | ||
30 | when != if (...) { ... clk_put(e); ... } | ||
31 | ( | ||
32 | if (ret == 0) S1 | ||
33 | | | ||
34 | if (...) | ||
35 | { ... | ||
36 | return 0; } | ||
37 | | | ||
38 | if (...) | ||
39 | { ... | ||
40 | return <+...e...+>; } | ||
41 | | | ||
42 | *if@p2 (...) | ||
43 | { ... when != clk_put(e) | ||
44 | when forall | ||
45 | return@p3 ...; } | ||
46 | ) | ||
47 | ... when any | ||
48 | clk_put(e); | ||
49 | |||
50 | @script:python depends on org@ | ||
51 | p1 << clk.p1; | ||
52 | p2 << clk.p2; | ||
53 | p3 << clk.p3; | ||
54 | @@ | ||
55 | |||
56 | cocci.print_main("clk_get",p1) | ||
57 | cocci.print_secs("if",p2) | ||
58 | cocci.print_secs("needed clk_put",p3) | ||
59 | |||
60 | @script:python depends on report@ | ||
61 | p1 << clk.p1; | ||
62 | p2 << clk.p2; | ||
63 | p3 << clk.p3; | ||
64 | @@ | ||
65 | |||
66 | msg = "ERROR: missing clk_put; clk_get on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line) | ||
67 | coccilib.report.print_report(p3[0],msg) | ||
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci deleted file mode 100644 index 0a1e36146d7..00000000000 --- a/scripts/coccinelle/free/devm_free.cocci +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /// Find uses of standard freeing functons on values allocated using devm_ | ||
2 | /// functions. Values allocated using the devm_functions are freed when | ||
3 | /// the device is detached, and thus the use of the standard freeing | ||
4 | /// function would cause a double free. | ||
5 | /// See Documentation/driver-model/devres.txt for more information. | ||
6 | /// | ||
7 | /// A difficulty of detecting this problem is that the standard freeing | ||
8 | /// function might be called from a different function than the one | ||
9 | /// containing the allocation function. It is thus necessary to make the | ||
10 | /// connection between the allocation function and the freeing function. | ||
11 | /// Here this is done using the specific argument text, which is prone to | ||
12 | /// false positives. There is no rule for the request_region and | ||
13 | /// request_mem_region variants because this heuristic seems to be a bit | ||
14 | /// less reliable in these cases. | ||
15 | /// | ||
16 | // Confidence: Moderate | ||
17 | // Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. GPLv2. | ||
18 | // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2. | ||
19 | // URL: http://coccinelle.lip6.fr/ | ||
20 | // Comments: | ||
21 | // Options: -no_includes -include_headers | ||
22 | |||
23 | virtual org | ||
24 | virtual report | ||
25 | virtual context | ||
26 | |||
27 | @r depends on context || org || report@ | ||
28 | expression x; | ||
29 | @@ | ||
30 | |||
31 | ( | ||
32 | x = devm_kzalloc(...) | ||
33 | | | ||
34 | x = devm_request_irq(...) | ||
35 | | | ||
36 | x = devm_ioremap(...) | ||
37 | | | ||
38 | x = devm_ioremap_nocache(...) | ||
39 | | | ||
40 | x = devm_ioport_map(...) | ||
41 | ) | ||
42 | |||
43 | @pb@ | ||
44 | expression r.x; | ||
45 | position p; | ||
46 | @@ | ||
47 | |||
48 | ( | ||
49 | * kfree@p(x) | ||
50 | | | ||
51 | * free_irq@p(x) | ||
52 | | | ||
53 | * iounmap@p(x) | ||
54 | | | ||
55 | * ioport_unmap@p(x) | ||
56 | ) | ||
57 | |||
58 | @script:python depends on org@ | ||
59 | p << pb.p; | ||
60 | @@ | ||
61 | |||
62 | msg="WARNING: invalid free of devm_ allocated data" | ||
63 | coccilib.org.print_todo(p[0], msg) | ||
64 | |||
65 | @script:python depends on report@ | ||
66 | p << pb.p; | ||
67 | @@ | ||
68 | |||
69 | msg="WARNING: invalid free of devm_ allocated data" | ||
70 | coccilib.report.print_report(p[0], msg) | ||
71 | |||
diff --git a/scripts/coccinelle/free/iounmap.cocci b/scripts/coccinelle/free/iounmap.cocci deleted file mode 100644 index 5384f4ba119..00000000000 --- a/scripts/coccinelle/free/iounmap.cocci +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | /// Find missing iounmaps. | ||
2 | /// | ||
3 | //# This only signals a missing iounmap when there is an iounmap later | ||
4 | //# in the same function. | ||
5 | //# False positives can be due to loops. | ||
6 | // | ||
7 | // Confidence: Moderate | ||
8 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
9 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
10 | // URL: http://coccinelle.lip6.fr/ | ||
11 | // Comments: | ||
12 | // Options: | ||
13 | |||
14 | virtual context | ||
15 | virtual org | ||
16 | virtual report | ||
17 | |||
18 | @iom@ | ||
19 | expression e; | ||
20 | statement S,S1; | ||
21 | int ret; | ||
22 | position p1,p2,p3; | ||
23 | @@ | ||
24 | |||
25 | e = \(ioremap@p1\|ioremap_nocache@p1\)(...) | ||
26 | ... when != iounmap(e) | ||
27 | if (<+...e...+>) S | ||
28 | ... when any | ||
29 | when != iounmap(e) | ||
30 | when != if (...) { ... iounmap(e); ... } | ||
31 | ( | ||
32 | if (ret == 0) S1 | ||
33 | | | ||
34 | if (...) | ||
35 | { ... | ||
36 | return 0; } | ||
37 | | | ||
38 | if (...) | ||
39 | { ... | ||
40 | return <+...e...+>; } | ||
41 | | | ||
42 | *if@p2 (...) | ||
43 | { ... when != iounmap(e) | ||
44 | when forall | ||
45 | return@p3 ...; } | ||
46 | ) | ||
47 | ... when any | ||
48 | iounmap(e); | ||
49 | |||
50 | @script:python depends on org@ | ||
51 | p1 << iom.p1; | ||
52 | p2 << iom.p2; | ||
53 | p3 << iom.p3; | ||
54 | @@ | ||
55 | |||
56 | cocci.print_main("ioremap",p1) | ||
57 | cocci.print_secs("if",p2) | ||
58 | cocci.print_secs("needed iounmap",p3) | ||
59 | |||
60 | @script:python depends on report@ | ||
61 | p1 << iom.p1; | ||
62 | p2 << iom.p2; | ||
63 | p3 << iom.p3; | ||
64 | @@ | ||
65 | |||
66 | msg = "ERROR: missing iounmap; ioremap on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line) | ||
67 | coccilib.report.print_report(p3[0],msg) | ||
diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci index d9ae6d89c2f..f9f79d9245e 100644 --- a/scripts/coccinelle/free/kfree.cocci +++ b/scripts/coccinelle/free/kfree.cocci | |||
@@ -5,9 +5,9 @@ | |||
5 | //# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument | 5 | //# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument |
6 | /// | 6 | /// |
7 | // Confidence: Moderate | 7 | // Confidence: Moderate |
8 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 8 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
9 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 9 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
10 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 10 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
11 | // URL: http://coccinelle.lip6.fr/ | 11 | // URL: http://coccinelle.lip6.fr/ |
12 | // Comments: | 12 | // Comments: |
13 | // Options: -no_includes -include_headers | 13 | // Options: -no_includes -include_headers |
@@ -23,7 +23,7 @@ position p1; | |||
23 | kfree@p1(E) | 23 | kfree@p1(E) |
24 | 24 | ||
25 | @print expression@ | 25 | @print expression@ |
26 | constant char [] c; | 26 | constant char *c; |
27 | expression free.E,E2; | 27 | expression free.E,E2; |
28 | type T; | 28 | type T; |
29 | position p; | 29 | position p; |
@@ -37,10 +37,6 @@ identifier f; | |||
37 | | | 37 | | |
38 | E@p != E2 | 38 | E@p != E2 |
39 | | | 39 | | |
40 | E2 == E@p | ||
41 | | | ||
42 | E2 != E@p | ||
43 | | | ||
44 | !E@p | 40 | !E@p |
45 | | | 41 | | |
46 | E@p || ... | 42 | E@p || ... |
@@ -117,5 +113,5 @@ p1 << free.p1; | |||
117 | p2 << r.p2; | 113 | p2 << r.p2; |
118 | @@ | 114 | @@ |
119 | 115 | ||
120 | msg = "ERROR: reference preceded by free on line %s" % (p1[0].line) | 116 | msg = "reference preceded by free on line %s" % (p1[0].line) |
121 | coccilib.report.print_report(p2[0],msg) | 117 | coccilib.report.print_report(p2[0],msg) |
diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci index 0a40af828c4..77bc108c3f5 100644 --- a/scripts/coccinelle/iterators/fen.cocci +++ b/scripts/coccinelle/iterators/fen.cocci | |||
@@ -2,19 +2,16 @@ | |||
2 | /// is no point to call of_node_put on the final value. | 2 | /// is no point to call of_node_put on the final value. |
3 | /// | 3 | /// |
4 | // Confidence: High | 4 | // Confidence: High |
5 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 5 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 6 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
7 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 7 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
8 | // URL: http://coccinelle.lip6.fr/ | 8 | // URL: http://coccinelle.lip6.fr/ |
9 | // Comments: | 9 | // Comments: |
10 | // Options: -no_includes -include_headers | 10 | // Options: -no_includes -include_headers |
11 | 11 | ||
12 | virtual patch | 12 | virtual patch |
13 | virtual context | ||
14 | virtual org | ||
15 | virtual report | ||
16 | 13 | ||
17 | @depends on patch@ | 14 | @@ |
18 | iterator name for_each_node_by_name; | 15 | iterator name for_each_node_by_name; |
19 | expression np,E; | 16 | expression np,E; |
20 | identifier l; | 17 | identifier l; |
@@ -27,7 +24,7 @@ for_each_node_by_name(np,...) { | |||
27 | ... when != np = E | 24 | ... when != np = E |
28 | - of_node_put(np); | 25 | - of_node_put(np); |
29 | 26 | ||
30 | @depends on patch@ | 27 | @@ |
31 | iterator name for_each_node_by_type; | 28 | iterator name for_each_node_by_type; |
32 | expression np,E; | 29 | expression np,E; |
33 | identifier l; | 30 | identifier l; |
@@ -40,7 +37,7 @@ for_each_node_by_type(np,...) { | |||
40 | ... when != np = E | 37 | ... when != np = E |
41 | - of_node_put(np); | 38 | - of_node_put(np); |
42 | 39 | ||
43 | @depends on patch@ | 40 | @@ |
44 | iterator name for_each_compatible_node; | 41 | iterator name for_each_compatible_node; |
45 | expression np,E; | 42 | expression np,E; |
46 | identifier l; | 43 | identifier l; |
@@ -53,7 +50,7 @@ for_each_compatible_node(np,...) { | |||
53 | ... when != np = E | 50 | ... when != np = E |
54 | - of_node_put(np); | 51 | - of_node_put(np); |
55 | 52 | ||
56 | @depends on patch@ | 53 | @@ |
57 | iterator name for_each_matching_node; | 54 | iterator name for_each_matching_node; |
58 | expression np,E; | 55 | expression np,E; |
59 | identifier l; | 56 | identifier l; |
@@ -65,59 +62,3 @@ for_each_matching_node(np,...) { | |||
65 | } | 62 | } |
66 | ... when != np = E | 63 | ... when != np = E |
67 | - of_node_put(np); | 64 | - of_node_put(np); |
68 | |||
69 | // ---------------------------------------------------------------------- | ||
70 | |||
71 | @r depends on !patch forall@ | ||
72 | //iterator name for_each_node_by_name; | ||
73 | //iterator name for_each_node_by_type; | ||
74 | //iterator name for_each_compatible_node; | ||
75 | //iterator name for_each_matching_node; | ||
76 | expression np,E; | ||
77 | identifier l; | ||
78 | position p1,p2; | ||
79 | @@ | ||
80 | |||
81 | ( | ||
82 | *for_each_node_by_name@p1(np,...) | ||
83 | { | ||
84 | ... when != break; | ||
85 | when != goto l; | ||
86 | } | ||
87 | | | ||
88 | *for_each_node_by_type@p1(np,...) | ||
89 | { | ||
90 | ... when != break; | ||
91 | when != goto l; | ||
92 | } | ||
93 | | | ||
94 | *for_each_compatible_node@p1(np,...) | ||
95 | { | ||
96 | ... when != break; | ||
97 | when != goto l; | ||
98 | } | ||
99 | | | ||
100 | *for_each_matching_node@p1(np,...) | ||
101 | { | ||
102 | ... when != break; | ||
103 | when != goto l; | ||
104 | } | ||
105 | ) | ||
106 | ... when != np = E | ||
107 | * of_node_put@p2(np); | ||
108 | |||
109 | @script:python depends on org@ | ||
110 | p1 << r.p1; | ||
111 | p2 << r.p2; | ||
112 | @@ | ||
113 | |||
114 | cocci.print_main("unneeded of_node_put",p2) | ||
115 | cocci.print_secs("iterator",p1) | ||
116 | |||
117 | @script:python depends on report@ | ||
118 | p1 << r.p1; | ||
119 | p2 << r.p2; | ||
120 | @@ | ||
121 | |||
122 | msg = "ERROR: of_node_put not needed after iterator on line %s" % (p1[0].line) | ||
123 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/iterators/itnull.cocci b/scripts/coccinelle/iterators/itnull.cocci index 259899f6838..baa4297a4ed 100644 --- a/scripts/coccinelle/iterators/itnull.cocci +++ b/scripts/coccinelle/iterators/itnull.cocci | |||
@@ -1,24 +1,20 @@ | |||
1 | /// Many iterators have the property that the first argument is always bound | 1 | /// Many iterators have the property that the first argument is always bound |
2 | /// to a real list element, never NULL. | 2 | /// to a real list element, never NULL. False positives arise for some |
3 | //# False positives arise for some iterators that do not have this property, | 3 | /// iterators that do not have this property, or in cases when the loop |
4 | //# or in cases when the loop cursor is reassigned. The latter should only | 4 | /// cursor is reassigned. The latter should only happen when the matched |
5 | //# happen when the matched code is on the way to a loop exit (break, goto, | 5 | /// code is on the way to a loop exit (break, goto, or return). |
6 | //# or return). | ||
7 | /// | 6 | /// |
8 | // Confidence: Moderate | 7 | // Confidence: Moderate |
9 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 8 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
10 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 9 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
11 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 10 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
12 | // URL: http://coccinelle.lip6.fr/ | 11 | // URL: http://coccinelle.lip6.fr/ |
13 | // Comments: | 12 | // Comments: |
14 | // Options: -no_includes -include_headers | 13 | // Options: -no_includes -include_headers |
15 | 14 | ||
16 | virtual patch | 15 | virtual patch |
17 | virtual context | ||
18 | virtual org | ||
19 | virtual report | ||
20 | 16 | ||
21 | @depends on patch@ | 17 | @@ |
22 | iterator I; | 18 | iterator I; |
23 | expression x,E,E1,E2; | 19 | expression x,E,E1,E2; |
24 | statement S,S1,S2; | 20 | statement S,S1,S2; |
@@ -59,36 +55,4 @@ I(x,...) { <... | |||
59 | x != NULL | 55 | x != NULL |
60 | + ) | 56 | + ) |
61 | ) | 57 | ) |
62 | ...> } | 58 | ...> } \ No newline at end of file |
63 | |||
64 | @r depends on !patch exists@ | ||
65 | iterator I; | ||
66 | expression x,E; | ||
67 | position p1,p2; | ||
68 | @@ | ||
69 | |||
70 | *I@p1(x,...) | ||
71 | { ... when != x = E | ||
72 | ( | ||
73 | * x@p2 == NULL | ||
74 | | | ||
75 | * x@p2 != NULL | ||
76 | ) | ||
77 | ... when any | ||
78 | } | ||
79 | |||
80 | @script:python depends on org@ | ||
81 | p1 << r.p1; | ||
82 | p2 << r.p2; | ||
83 | @@ | ||
84 | |||
85 | cocci.print_main("iterator-bound variable",p1) | ||
86 | cocci.print_secs("useless NULL test",p2) | ||
87 | |||
88 | @script:python depends on report@ | ||
89 | p1 << r.p1; | ||
90 | p2 << r.p2; | ||
91 | @@ | ||
92 | |||
93 | msg = "ERROR: iterator variable bound on line %s cannot be NULL" % (p1[0].line) | ||
94 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci deleted file mode 100644 index 06284c57a95..00000000000 --- a/scripts/coccinelle/iterators/use_after_iter.cocci +++ /dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | /// If list_for_each_entry, etc complete a traversal of the list, the iterator | ||
2 | /// variable ends up pointing to an address at an offset from the list head, | ||
3 | /// and not a meaningful structure. Thus this value should not be used after | ||
4 | /// the end of the iterator. | ||
5 | //#False positives arise when there is a goto in the iterator and the | ||
6 | //#reported reference is at the label of this goto. Some flag tests | ||
7 | //#may also cause a report to be a false positive. | ||
8 | /// | ||
9 | // Confidence: Moderate | ||
10 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
11 | // Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2. | ||
12 | // URL: http://coccinelle.lip6.fr/ | ||
13 | // Comments: | ||
14 | // Options: -no_includes -include_headers | ||
15 | |||
16 | virtual context | ||
17 | virtual org | ||
18 | virtual report | ||
19 | |||
20 | @r exists@ | ||
21 | identifier c,member; | ||
22 | expression E,x; | ||
23 | iterator name list_for_each_entry; | ||
24 | iterator name list_for_each_entry_reverse; | ||
25 | iterator name list_for_each_entry_continue; | ||
26 | iterator name list_for_each_entry_continue_reverse; | ||
27 | iterator name list_for_each_entry_from; | ||
28 | iterator name list_for_each_entry_safe; | ||
29 | iterator name list_for_each_entry_safe_continue; | ||
30 | iterator name list_for_each_entry_safe_from; | ||
31 | iterator name list_for_each_entry_safe_reverse; | ||
32 | iterator name hlist_for_each_entry; | ||
33 | iterator name hlist_for_each_entry_continue; | ||
34 | iterator name hlist_for_each_entry_from; | ||
35 | iterator name hlist_for_each_entry_safe; | ||
36 | statement S; | ||
37 | position p1,p2; | ||
38 | @@ | ||
39 | |||
40 | ( | ||
41 | list_for_each_entry@p1(c,...,member) { ... when != break; | ||
42 | when forall | ||
43 | when strict | ||
44 | } | ||
45 | | | ||
46 | list_for_each_entry_reverse@p1(c,...,member) { ... when != break; | ||
47 | when forall | ||
48 | when strict | ||
49 | } | ||
50 | | | ||
51 | list_for_each_entry_continue@p1(c,...,member) { ... when != break; | ||
52 | when forall | ||
53 | when strict | ||
54 | } | ||
55 | | | ||
56 | list_for_each_entry_continue_reverse@p1(c,...,member) { ... when != break; | ||
57 | when forall | ||
58 | when strict | ||
59 | } | ||
60 | | | ||
61 | list_for_each_entry_from@p1(c,...,member) { ... when != break; | ||
62 | when forall | ||
63 | when strict | ||
64 | } | ||
65 | | | ||
66 | list_for_each_entry_safe@p1(c,...,member) { ... when != break; | ||
67 | when forall | ||
68 | when strict | ||
69 | } | ||
70 | | | ||
71 | list_for_each_entry_safe_continue@p1(c,...,member) { ... when != break; | ||
72 | when forall | ||
73 | when strict | ||
74 | } | ||
75 | | | ||
76 | list_for_each_entry_safe_from@p1(c,...,member) { ... when != break; | ||
77 | when forall | ||
78 | when strict | ||
79 | } | ||
80 | | | ||
81 | list_for_each_entry_safe_reverse@p1(c,...,member) { ... when != break; | ||
82 | when forall | ||
83 | when strict | ||
84 | } | ||
85 | ) | ||
86 | ... | ||
87 | ( | ||
88 | list_for_each_entry(c,...) S | ||
89 | | | ||
90 | list_for_each_entry_reverse(c,...) S | ||
91 | | | ||
92 | list_for_each_entry_continue(c,...) S | ||
93 | | | ||
94 | list_for_each_entry_continue_reverse(c,...) S | ||
95 | | | ||
96 | list_for_each_entry_from(c,...) S | ||
97 | | | ||
98 | list_for_each_entry_safe(c,...) S | ||
99 | | | ||
100 | list_for_each_entry_safe(x,c,...) S | ||
101 | | | ||
102 | list_for_each_entry_safe_continue(c,...) S | ||
103 | | | ||
104 | list_for_each_entry_safe_continue(x,c,...) S | ||
105 | | | ||
106 | list_for_each_entry_safe_from(c,...) S | ||
107 | | | ||
108 | list_for_each_entry_safe_from(x,c,...) S | ||
109 | | | ||
110 | list_for_each_entry_safe_reverse(c,...) S | ||
111 | | | ||
112 | list_for_each_entry_safe_reverse(x,c,...) S | ||
113 | | | ||
114 | hlist_for_each_entry(c,...) S | ||
115 | | | ||
116 | hlist_for_each_entry_continue(c,...) S | ||
117 | | | ||
118 | hlist_for_each_entry_from(c,...) S | ||
119 | | | ||
120 | hlist_for_each_entry_safe(c,...) S | ||
121 | | | ||
122 | list_remove_head(x,c,...) | ||
123 | | | ||
124 | sizeof(<+...c...+>) | ||
125 | | | ||
126 | &c->member | ||
127 | | | ||
128 | c = E | ||
129 | | | ||
130 | *c@p2 | ||
131 | ) | ||
132 | |||
133 | @script:python depends on org@ | ||
134 | p1 << r.p1; | ||
135 | p2 << r.p2; | ||
136 | @@ | ||
137 | |||
138 | cocci.print_main("invalid iterator index reference",p2) | ||
139 | cocci.print_secs("iterator",p1) | ||
140 | |||
141 | @script:python depends on report@ | ||
142 | p1 << r.p1; | ||
143 | p2 << r.p2; | ||
144 | @@ | ||
145 | |||
146 | msg = "ERROR: invalid reference to the index variable of the iterator on line %s" % (p1[0].line) | ||
147 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/locks/call_kern.cocci b/scripts/coccinelle/locks/call_kern.cocci index 8f10b49603c..00af5344a68 100644 --- a/scripts/coccinelle/locks/call_kern.cocci +++ b/scripts/coccinelle/locks/call_kern.cocci | |||
@@ -1,20 +1,17 @@ | |||
1 | /// Find functions that refer to GFP_KERNEL but are called with locks held. | 1 | /// Find functions that refer to GFP_KERNEL but are called with locks held. |
2 | //# The proposed change of converting the GFP_KERNEL is not necessarily the | 2 | /// The proposed change of converting the GFP_KERNEL is not necessarily the |
3 | //# correct one. It may be desired to unlock the lock, or to not call the | 3 | /// correct one. It may be desired to unlock the lock, or to not call the |
4 | //# function under the lock in the first place. | 4 | /// function under the lock in the first place. |
5 | /// | 5 | /// |
6 | // Confidence: Moderate | 6 | // Confidence: Moderate |
7 | // Copyright: (C) 2012 Nicolas Palix. GPLv2. | 7 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
8 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | 8 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
9 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | 9 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
10 | // URL: http://coccinelle.lip6.fr/ | 10 | // URL: http://coccinelle.lip6.fr/ |
11 | // Comments: | 11 | // Comments: |
12 | // Options: -no_includes -include_headers | 12 | // Options: -no_includes -include_headers |
13 | 13 | ||
14 | virtual patch | 14 | virtual patch |
15 | virtual context | ||
16 | virtual org | ||
17 | virtual report | ||
18 | 15 | ||
19 | @gfp exists@ | 16 | @gfp exists@ |
20 | identifier fn; | 17 | identifier fn; |
@@ -35,29 +32,28 @@ fn(...) { | |||
35 | ... when any | 32 | ... when any |
36 | } | 33 | } |
37 | 34 | ||
38 | @locked exists@ | 35 | @locked@ |
39 | identifier gfp.fn; | 36 | identifier gfp.fn; |
40 | position p1,p2; | ||
41 | @@ | 37 | @@ |
42 | 38 | ||
43 | ( | 39 | ( |
44 | read_lock_irq@p1 | 40 | read_lock_irq |
45 | | | 41 | | |
46 | write_lock_irq@p1 | 42 | write_lock_irq |
47 | | | 43 | | |
48 | read_lock_irqsave@p1 | 44 | read_lock_irqsave |
49 | | | 45 | | |
50 | write_lock_irqsave@p1 | 46 | write_lock_irqsave |
51 | | | 47 | | |
52 | spin_lock@p1 | 48 | spin_lock |
53 | | | 49 | | |
54 | spin_trylock@p1 | 50 | spin_trylock |
55 | | | 51 | | |
56 | spin_lock_irq@p1 | 52 | spin_lock_irq |
57 | | | 53 | | |
58 | spin_lock_irqsave@p1 | 54 | spin_lock_irqsave |
59 | | | 55 | | |
60 | local_irq_disable@p1 | 56 | local_irq_disable |
61 | ) | 57 | ) |
62 | (...) | 58 | (...) |
63 | ... when != read_unlock_irq(...) | 59 | ... when != read_unlock_irq(...) |
@@ -68,38 +64,11 @@ local_irq_disable@p1 | |||
68 | when != spin_unlock_irq(...) | 64 | when != spin_unlock_irq(...) |
69 | when != spin_unlock_irqrestore(...) | 65 | when != spin_unlock_irqrestore(...) |
70 | when != local_irq_enable(...) | 66 | when != local_irq_enable(...) |
71 | fn@p2(...) | 67 | fn(...) |
72 | 68 | ||
73 | @depends on locked && patch@ | 69 | @depends on locked@ |
74 | position gfp.p; | 70 | position gfp.p; |
75 | @@ | 71 | @@ |
76 | 72 | ||
77 | - GFP_KERNEL@p | 73 | - GFP_KERNEL@p |
78 | + GFP_ATOMIC | 74 | + GFP_ATOMIC |
79 | |||
80 | @depends on locked && !patch@ | ||
81 | position gfp.p; | ||
82 | @@ | ||
83 | |||
84 | * GFP_KERNEL@p | ||
85 | |||
86 | @script:python depends on !patch && org@ | ||
87 | p << gfp.p; | ||
88 | fn << gfp.fn; | ||
89 | p1 << locked.p1; | ||
90 | p2 << locked.p2; | ||
91 | @@ | ||
92 | |||
93 | cocci.print_main("lock",p1) | ||
94 | cocci.print_secs("call",p2) | ||
95 | cocci.print_secs("GFP_KERNEL",p) | ||
96 | |||
97 | @script:python depends on !patch && report@ | ||
98 | p << gfp.p; | ||
99 | fn << gfp.fn; | ||
100 | p1 << locked.p1; | ||
101 | p2 << locked.p2; | ||
102 | @@ | ||
103 | |||
104 | msg = "ERROR: function %s called on line %s inside lock on line %s but uses GFP_KERNEL" % (fn,p2[0].line,p1[0].line) | ||
105 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/locks/flags.cocci b/scripts/coccinelle/locks/flags.cocci index 1c4ffe6fd84..b4344d83809 100644 --- a/scripts/coccinelle/locks/flags.cocci +++ b/scripts/coccinelle/locks/flags.cocci | |||
@@ -1,9 +1,9 @@ | |||
1 | /// Find nested lock+irqsave functions that use the same flags variables | 1 | /// Find nested lock+irqsave functions that use the same flags variables |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
@@ -12,7 +12,7 @@ virtual context | |||
12 | virtual org | 12 | virtual org |
13 | virtual report | 13 | virtual report |
14 | 14 | ||
15 | @r exists@ | 15 | @r@ |
16 | expression lock1,lock2,flags; | 16 | expression lock1,lock2,flags; |
17 | position p1,p2; | 17 | position p1,p2; |
18 | @@ | 18 | @@ |
@@ -39,7 +39,7 @@ read_lock_irqsave@p2(lock2,flags) | |||
39 | write_lock_irqsave@p2(lock2,flags) | 39 | write_lock_irqsave@p2(lock2,flags) |
40 | ) | 40 | ) |
41 | 41 | ||
42 | @d exists@ | 42 | @d@ |
43 | expression f <= r.flags; | 43 | expression f <= r.flags; |
44 | expression lock1,lock2,flags; | 44 | expression lock1,lock2,flags; |
45 | position r.p1, r.p2; | 45 | position r.p1, r.p2; |
@@ -76,5 +76,5 @@ p1 << r.p1; | |||
76 | p2 << r.p2; | 76 | p2 << r.p2; |
77 | @@ | 77 | @@ |
78 | 78 | ||
79 | msg="ERROR: nested lock+irqsave that reuses flags from line %s." % (p1[0].line) | 79 | msg="ERROR: nested lock+irqsave that reuses flags from %s." % (p1[0].line) |
80 | coccilib.report.print_report(p2[0], msg) | 80 | coccilib.report.print_report(p2[0], msg) |
diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci index 3267d7410bd..7641a292543 100644 --- a/scripts/coccinelle/locks/mini_lock.cocci +++ b/scripts/coccinelle/locks/mini_lock.cocci | |||
@@ -6,14 +6,13 @@ | |||
6 | /// function call that releases the lock. | 6 | /// function call that releases the lock. |
7 | /// | 7 | /// |
8 | // Confidence: Moderate | 8 | // Confidence: Moderate |
9 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 9 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
10 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 10 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
11 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 11 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
12 | // URL: http://coccinelle.lip6.fr/ | 12 | // URL: http://coccinelle.lip6.fr/ |
13 | // Comments: | 13 | // Comments: |
14 | // Options: -no_includes -include_headers | 14 | // Options: -no_includes -include_headers |
15 | 15 | ||
16 | virtual context | ||
17 | virtual org | 16 | virtual org |
18 | virtual report | 17 | virtual report |
19 | 18 | ||
@@ -58,7 +57,7 @@ position r; | |||
58 | 57 | ||
59 | for(...;...;...) { <+... return@r ...; ...+> } | 58 | for(...;...;...) { <+... return@r ...; ...+> } |
60 | 59 | ||
61 | @err exists@ | 60 | @err@ |
62 | expression E1; | 61 | expression E1; |
63 | position prelocked.p; | 62 | position prelocked.p; |
64 | position up != prelocked.p1; | 63 | position up != prelocked.p1; |
@@ -66,14 +65,14 @@ position r!=looped.r; | |||
66 | identifier lock,unlock; | 65 | identifier lock,unlock; |
67 | @@ | 66 | @@ |
68 | 67 | ||
69 | *lock(E1@p,...); | 68 | lock(E1@p,...); |
70 | <+... when != E1 | 69 | <+... when != E1 |
71 | if (...) { | 70 | if (...) { |
72 | ... when != E1 | 71 | ... when != E1 |
73 | * return@r ...; | 72 | return@r ...; |
74 | } | 73 | } |
75 | ...+> | 74 | ...+> |
76 | *unlock@up(E1,...); | 75 | unlock@up(E1,...); |
77 | 76 | ||
78 | @script:python depends on org@ | 77 | @script:python depends on org@ |
79 | p << prelocked.p1; | 78 | p << prelocked.p1; |
diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci deleted file mode 100644 index 97ce41ce813..00000000000 --- a/scripts/coccinelle/misc/boolinit.cocci +++ /dev/null | |||
@@ -1,178 +0,0 @@ | |||
1 | /// Bool initializations should use true and false. Bool tests don't need | ||
2 | /// comparisons. Based on contributions from Joe Perches, Rusty Russell | ||
3 | /// and Bruce W Allan. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
7 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
8 | // URL: http://coccinelle.lip6.fr/ | ||
9 | // Options: -include_headers | ||
10 | |||
11 | virtual patch | ||
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | |||
16 | @depends on patch@ | ||
17 | bool t; | ||
18 | symbol true; | ||
19 | symbol false; | ||
20 | @@ | ||
21 | |||
22 | ( | ||
23 | - t == true | ||
24 | + t | ||
25 | | | ||
26 | - true == t | ||
27 | + t | ||
28 | | | ||
29 | - t != true | ||
30 | + !t | ||
31 | | | ||
32 | - true != t | ||
33 | + !t | ||
34 | | | ||
35 | - t == false | ||
36 | + !t | ||
37 | | | ||
38 | - false == t | ||
39 | + !t | ||
40 | | | ||
41 | - t != false | ||
42 | + t | ||
43 | | | ||
44 | - false != t | ||
45 | + t | ||
46 | ) | ||
47 | |||
48 | @depends on patch disable is_zero, isnt_zero@ | ||
49 | bool t; | ||
50 | @@ | ||
51 | |||
52 | ( | ||
53 | - t == 1 | ||
54 | + t | ||
55 | | | ||
56 | - t != 1 | ||
57 | + !t | ||
58 | | | ||
59 | - t == 0 | ||
60 | + !t | ||
61 | | | ||
62 | - t != 0 | ||
63 | + t | ||
64 | ) | ||
65 | |||
66 | @depends on patch@ | ||
67 | bool b; | ||
68 | @@ | ||
69 | ( | ||
70 | b = | ||
71 | - 0 | ||
72 | + false | ||
73 | | | ||
74 | b = | ||
75 | - 1 | ||
76 | + true | ||
77 | ) | ||
78 | |||
79 | // --------------------------------------------------------------------- | ||
80 | |||
81 | @r1 depends on !patch@ | ||
82 | bool t; | ||
83 | position p; | ||
84 | @@ | ||
85 | |||
86 | ( | ||
87 | * t@p == true | ||
88 | | | ||
89 | * true == t@p | ||
90 | | | ||
91 | * t@p != true | ||
92 | | | ||
93 | * true != t@p | ||
94 | | | ||
95 | * t@p == false | ||
96 | | | ||
97 | * false == t@p | ||
98 | | | ||
99 | * t@p != false | ||
100 | | | ||
101 | * false != t@p | ||
102 | ) | ||
103 | |||
104 | @r2 depends on !patch disable is_zero, isnt_zero@ | ||
105 | bool t; | ||
106 | position p; | ||
107 | @@ | ||
108 | |||
109 | ( | ||
110 | * t@p == 1 | ||
111 | | | ||
112 | * t@p != 1 | ||
113 | | | ||
114 | * t@p == 0 | ||
115 | | | ||
116 | * t@p != 0 | ||
117 | ) | ||
118 | |||
119 | @r3 depends on !patch@ | ||
120 | bool b; | ||
121 | position p1,p2; | ||
122 | constant c; | ||
123 | @@ | ||
124 | ( | ||
125 | *b@p1 = 0 | ||
126 | | | ||
127 | *b@p1 = 1 | ||
128 | | | ||
129 | *b@p2 = c | ||
130 | ) | ||
131 | |||
132 | @script:python depends on org@ | ||
133 | p << r1.p; | ||
134 | @@ | ||
135 | |||
136 | cocci.print_main("WARNING: Comparison to bool",p) | ||
137 | |||
138 | @script:python depends on org@ | ||
139 | p << r2.p; | ||
140 | @@ | ||
141 | |||
142 | cocci.print_main("WARNING: Comparison of bool to 0/1",p) | ||
143 | |||
144 | @script:python depends on org@ | ||
145 | p1 << r3.p1; | ||
146 | @@ | ||
147 | |||
148 | cocci.print_main("WARNING: Assignment of bool to 0/1",p1) | ||
149 | |||
150 | @script:python depends on org@ | ||
151 | p2 << r3.p2; | ||
152 | @@ | ||
153 | |||
154 | cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2) | ||
155 | |||
156 | @script:python depends on report@ | ||
157 | p << r1.p; | ||
158 | @@ | ||
159 | |||
160 | coccilib.report.print_report(p[0],"WARNING: Comparison to bool") | ||
161 | |||
162 | @script:python depends on report@ | ||
163 | p << r2.p; | ||
164 | @@ | ||
165 | |||
166 | coccilib.report.print_report(p[0],"WARNING: Comparison of bool to 0/1") | ||
167 | |||
168 | @script:python depends on report@ | ||
169 | p1 << r3.p1; | ||
170 | @@ | ||
171 | |||
172 | coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1") | ||
173 | |||
174 | @script:python depends on report@ | ||
175 | p2 << r3.p2; | ||
176 | @@ | ||
177 | |||
178 | coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant") | ||
diff --git a/scripts/coccinelle/misc/cstptr.cocci b/scripts/coccinelle/misc/cstptr.cocci deleted file mode 100644 index d4256448452..00000000000 --- a/scripts/coccinelle/misc/cstptr.cocci +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /// PTR_ERR should be applied before its argument is reassigned, typically | ||
2 | /// to NULL | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Comments: | ||
9 | // Options: -no_includes -include_headers | ||
10 | |||
11 | virtual org | ||
12 | virtual report | ||
13 | virtual context | ||
14 | |||
15 | @r exists@ | ||
16 | expression e,e1; | ||
17 | constant c; | ||
18 | position p1,p2; | ||
19 | @@ | ||
20 | |||
21 | *e@p1 = c | ||
22 | ... when != e = e1 | ||
23 | when != &e | ||
24 | when != true IS_ERR(e) | ||
25 | *PTR_ERR@p2(e) | ||
26 | |||
27 | @script:python depends on org@ | ||
28 | p1 << r.p1; | ||
29 | p2 << r.p2; | ||
30 | @@ | ||
31 | |||
32 | cocci.print_main("PTR_ERR",p2) | ||
33 | cocci.print_secs("assignment",p1) | ||
34 | |||
35 | @script:python depends on report@ | ||
36 | p1 << r.p1; | ||
37 | p2 << r.p2; | ||
38 | @@ | ||
39 | |||
40 | msg = "ERROR: PTR_ERR applied after initialization to constant on line %s" % (p1[0].line) | ||
41 | coccilib.report.print_report(p2[0],msg) | ||
diff --git a/scripts/coccinelle/misc/doubleinit.cocci b/scripts/coccinelle/misc/doubleinit.cocci index cf74a00cf59..156b20adb35 100644 --- a/scripts/coccinelle/misc/doubleinit.cocci +++ b/scripts/coccinelle/misc/doubleinit.cocci | |||
@@ -3,9 +3,9 @@ | |||
3 | /// initialization. | 3 | /// initialization. |
4 | /// | 4 | /// |
5 | // Confidence: Low | 5 | // Confidence: Low |
6 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 6 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
7 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 7 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
8 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 8 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
9 | // URL: http://coccinelle.lip6.fr/ | 9 | // URL: http://coccinelle.lip6.fr/ |
10 | // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise | 10 | // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise |
11 | // Options: -no_includes -include_headers | 11 | // Options: -no_includes -include_headers |
@@ -49,5 +49,5 @@ pr << r.p; | |||
49 | @@ | 49 | @@ |
50 | 50 | ||
51 | if int(ps[0].line) < int(pr[0].line) or (int(ps[0].line) == int(pr[0].line) and int(ps[0].column) < int(pr[0].column)): | 51 | if int(ps[0].line) < int(pr[0].line) or (int(ps[0].line) == int(pr[0].line) and int(ps[0].column) < int(pr[0].column)): |
52 | msg = "%s: first occurrence line %s, second occurrence line %s" % (fld,ps[0].line,pr[0].line) | 52 | msg = "%s: first occurrence %s, second occurrence %s" % (fld,ps[0].line,pr[0].line) |
53 | coccilib.report.print_report(p0[0],msg) | 53 | coccilib.report.print_report(p0[0],msg) |
diff --git a/scripts/coccinelle/misc/ifaddr.cocci b/scripts/coccinelle/misc/ifaddr.cocci deleted file mode 100644 index 3e4089a7700..00000000000 --- a/scripts/coccinelle/misc/ifaddr.cocci +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /// the address of a variable or field is non-zero is likely always to bo | ||
2 | /// non-zero | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Comments: | ||
9 | // Options: -no_includes -include_headers | ||
10 | |||
11 | virtual org | ||
12 | virtual report | ||
13 | virtual context | ||
14 | |||
15 | @r@ | ||
16 | expression x; | ||
17 | statement S1,S2; | ||
18 | position p; | ||
19 | @@ | ||
20 | |||
21 | *if@p (&x) | ||
22 | S1 else S2 | ||
23 | |||
24 | @script:python depends on org@ | ||
25 | p << r.p; | ||
26 | @@ | ||
27 | |||
28 | cocci.print_main("test of a variable/field address",p) | ||
29 | |||
30 | @script:python depends on report@ | ||
31 | p << r.p; | ||
32 | @@ | ||
33 | |||
34 | msg = "ERROR: test of a variable/field address" | ||
35 | coccilib.report.print_report(p[0],msg) | ||
diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci b/scripts/coccinelle/misc/irqf_oneshot.cocci deleted file mode 100644 index 6cfde94be0e..00000000000 --- a/scripts/coccinelle/misc/irqf_oneshot.cocci +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /// Make sure threaded IRQs without a primary handler are always request with | ||
2 | /// IRQF_ONESHOT | ||
3 | /// | ||
4 | // | ||
5 | // Confidence: Good | ||
6 | // Comments: | ||
7 | // Options: --no-includes | ||
8 | |||
9 | virtual patch | ||
10 | virtual context | ||
11 | virtual org | ||
12 | virtual report | ||
13 | |||
14 | @r1@ | ||
15 | expression irq; | ||
16 | expression thread_fn; | ||
17 | expression flags; | ||
18 | position p; | ||
19 | @@ | ||
20 | request_threaded_irq@p(irq, NULL, thread_fn, | ||
21 | ( | ||
22 | flags | IRQF_ONESHOT | ||
23 | | | ||
24 | IRQF_ONESHOT | ||
25 | ) | ||
26 | , ...) | ||
27 | |||
28 | @depends on patch@ | ||
29 | expression irq; | ||
30 | expression thread_fn; | ||
31 | expression flags; | ||
32 | position p != r1.p; | ||
33 | @@ | ||
34 | request_threaded_irq@p(irq, NULL, thread_fn, | ||
35 | ( | ||
36 | -0 | ||
37 | +IRQF_ONESHOT | ||
38 | | | ||
39 | -flags | ||
40 | +flags | IRQF_ONESHOT | ||
41 | ) | ||
42 | , ...) | ||
43 | |||
44 | @depends on context@ | ||
45 | position p != r1.p; | ||
46 | @@ | ||
47 | *request_threaded_irq@p(...) | ||
48 | |||
49 | @match depends on report || org@ | ||
50 | expression irq; | ||
51 | position p != r1.p; | ||
52 | @@ | ||
53 | request_threaded_irq@p(irq, NULL, ...) | ||
54 | |||
55 | @script:python depends on org@ | ||
56 | p << match.p; | ||
57 | @@ | ||
58 | msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT" | ||
59 | coccilib.org.print_todo(p[0],msg) | ||
60 | |||
61 | @script:python depends on report@ | ||
62 | p << match.p; | ||
63 | @@ | ||
64 | msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT" | ||
65 | coccilib.report.print_report(p[0],msg) | ||
diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci deleted file mode 100644 index c1707214e60..00000000000 --- a/scripts/coccinelle/misc/noderef.cocci +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /// sizeof when applied to a pointer typed expression gives the size of | ||
2 | /// the pointer | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Comments: | ||
9 | // Options: -no_includes -include_headers | ||
10 | |||
11 | virtual org | ||
12 | virtual report | ||
13 | virtual context | ||
14 | virtual patch | ||
15 | |||
16 | @depends on patch@ | ||
17 | expression *x; | ||
18 | expression f; | ||
19 | type T; | ||
20 | @@ | ||
21 | |||
22 | ( | ||
23 | x = <+... sizeof( | ||
24 | - x | ||
25 | + *x | ||
26 | ) ...+> | ||
27 | | | ||
28 | f(...,(T)(x),...,sizeof( | ||
29 | - x | ||
30 | + *x | ||
31 | ),...) | ||
32 | | | ||
33 | f(...,sizeof(x),...,(T)( | ||
34 | - x | ||
35 | + *x | ||
36 | ),...) | ||
37 | ) | ||
38 | |||
39 | @r depends on !patch@ | ||
40 | expression *x; | ||
41 | expression f; | ||
42 | position p; | ||
43 | type T; | ||
44 | @@ | ||
45 | |||
46 | ( | ||
47 | *x = <+... sizeof@p(x) ...+> | ||
48 | | | ||
49 | *f(...,(T)(x),...,sizeof@p(x),...) | ||
50 | | | ||
51 | *f(...,sizeof@p(x),...,(T)(x),...) | ||
52 | ) | ||
53 | |||
54 | @script:python depends on org@ | ||
55 | p << r.p; | ||
56 | @@ | ||
57 | |||
58 | cocci.print_main("application of sizeof to pointer",p) | ||
59 | |||
60 | @script:python depends on report@ | ||
61 | p << r.p; | ||
62 | @@ | ||
63 | |||
64 | msg = "ERROR: application of sizeof to pointer" | ||
65 | coccilib.report.print_report(p[0],msg) | ||
diff --git a/scripts/coccinelle/misc/warn.cocci b/scripts/coccinelle/misc/warn.cocci deleted file mode 100644 index fda8c3558e4..00000000000 --- a/scripts/coccinelle/misc/warn.cocci +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | /// Use WARN(1,...) rather than printk followed by WARN_ON(1) | ||
2 | /// | ||
3 | // Confidence: High | ||
4 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
5 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
6 | // URL: http://coccinelle.lip6.fr/ | ||
7 | // Comments: | ||
8 | // Options: -no_includes -include_headers | ||
9 | |||
10 | virtual patch | ||
11 | virtual context | ||
12 | virtual org | ||
13 | virtual report | ||
14 | |||
15 | @bad1@ | ||
16 | position p; | ||
17 | @@ | ||
18 | |||
19 | printk(...); | ||
20 | printk@p(...); | ||
21 | WARN_ON(1); | ||
22 | |||
23 | @r1 depends on context || report || org@ | ||
24 | position p != bad1.p; | ||
25 | @@ | ||
26 | |||
27 | printk@p(...); | ||
28 | *WARN_ON(1); | ||
29 | |||
30 | @script:python depends on org@ | ||
31 | p << r1.p; | ||
32 | @@ | ||
33 | |||
34 | cocci.print_main("printk + WARN_ON can be just WARN",p) | ||
35 | |||
36 | @script:python depends on report@ | ||
37 | p << r1.p; | ||
38 | @@ | ||
39 | |||
40 | msg = "SUGGESTION: printk + WARN_ON can be just WARN" | ||
41 | coccilib.report.print_report(p[0],msg) | ||
42 | |||
43 | @ok1 depends on patch@ | ||
44 | expression list es; | ||
45 | position p != bad1.p; | ||
46 | @@ | ||
47 | |||
48 | -printk@p( | ||
49 | +WARN(1, | ||
50 | es); | ||
51 | -WARN_ON(1); | ||
52 | |||
53 | @depends on patch@ | ||
54 | expression list ok1.es; | ||
55 | @@ | ||
56 | |||
57 | if (...) | ||
58 | - { | ||
59 | WARN(1,es); | ||
60 | - } | ||
61 | |||
62 | // -------------------------------------------------------------------- | ||
63 | |||
64 | @bad2@ | ||
65 | position p; | ||
66 | @@ | ||
67 | |||
68 | printk(...); | ||
69 | printk@p(...); | ||
70 | WARN_ON_ONCE(1); | ||
71 | |||
72 | @r2 depends on context || report || org@ | ||
73 | position p != bad1.p; | ||
74 | @@ | ||
75 | |||
76 | printk@p(...); | ||
77 | *WARN_ON_ONCE(1); | ||
78 | |||
79 | @script:python depends on org@ | ||
80 | p << r2.p; | ||
81 | @@ | ||
82 | |||
83 | cocci.print_main("printk + WARN_ON_ONCE can be just WARN_ONCE",p) | ||
84 | |||
85 | @script:python depends on report@ | ||
86 | p << r2.p; | ||
87 | @@ | ||
88 | |||
89 | msg = "SUGGESTION: printk + WARN_ON_ONCE can be just WARN_ONCE" | ||
90 | coccilib.report.print_report(p[0],msg) | ||
91 | |||
92 | @ok2 depends on patch@ | ||
93 | expression list es; | ||
94 | position p != bad2.p; | ||
95 | @@ | ||
96 | |||
97 | -printk@p( | ||
98 | +WARN_ONCE(1, | ||
99 | es); | ||
100 | -WARN_ON_ONCE(1); | ||
101 | |||
102 | @depends on patch@ | ||
103 | expression list ok2.es; | ||
104 | @@ | ||
105 | |||
106 | if (...) | ||
107 | - { | ||
108 | WARN_ONCE(1,es); | ||
109 | - } | ||
diff --git a/scripts/coccinelle/null/badzero.cocci b/scripts/coccinelle/null/badzero.cocci deleted file mode 100644 index d79baf7220e..00000000000 --- a/scripts/coccinelle/null/badzero.cocci +++ /dev/null | |||
@@ -1,237 +0,0 @@ | |||
1 | /// Compare pointer-typed values to NULL rather than 0 | ||
2 | /// | ||
3 | //# This makes an effort to choose between !x and x == NULL. !x is used | ||
4 | //# if it has previously been used with the function used to initialize x. | ||
5 | //# This relies on type information. More type information can be obtained | ||
6 | //# using the option -all_includes and the option -I to specify an | ||
7 | //# include path. | ||
8 | // | ||
9 | // Confidence: High | ||
10 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
11 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
12 | // URL: http://coccinelle.lip6.fr/ | ||
13 | // Comments: | ||
14 | // Options: | ||
15 | |||
16 | virtual patch | ||
17 | virtual context | ||
18 | virtual org | ||
19 | virtual report | ||
20 | |||
21 | @initialize:ocaml@ | ||
22 | let negtable = Hashtbl.create 101 | ||
23 | |||
24 | @depends on patch@ | ||
25 | expression *E; | ||
26 | identifier f; | ||
27 | @@ | ||
28 | |||
29 | ( | ||
30 | (E = f(...)) == | ||
31 | - 0 | ||
32 | + NULL | ||
33 | | | ||
34 | (E = f(...)) != | ||
35 | - 0 | ||
36 | + NULL | ||
37 | | | ||
38 | - 0 | ||
39 | + NULL | ||
40 | == (E = f(...)) | ||
41 | | | ||
42 | - 0 | ||
43 | + NULL | ||
44 | != (E = f(...)) | ||
45 | ) | ||
46 | |||
47 | |||
48 | @t1 depends on !patch@ | ||
49 | expression *E; | ||
50 | identifier f; | ||
51 | position p; | ||
52 | @@ | ||
53 | |||
54 | ( | ||
55 | (E = f(...)) == | ||
56 | * 0@p | ||
57 | | | ||
58 | (E = f(...)) != | ||
59 | * 0@p | ||
60 | | | ||
61 | * 0@p | ||
62 | == (E = f(...)) | ||
63 | | | ||
64 | * 0@p | ||
65 | != (E = f(...)) | ||
66 | ) | ||
67 | |||
68 | @script:python depends on org@ | ||
69 | p << t1.p; | ||
70 | @@ | ||
71 | |||
72 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0") | ||
73 | |||
74 | @script:python depends on report@ | ||
75 | p << t1.p; | ||
76 | @@ | ||
77 | |||
78 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0") | ||
79 | |||
80 | // Tests of returned values | ||
81 | |||
82 | @s@ | ||
83 | identifier f; | ||
84 | expression E,E1; | ||
85 | @@ | ||
86 | |||
87 | E = f(...) | ||
88 | ... when != E = E1 | ||
89 | !E | ||
90 | |||
91 | @script:ocaml depends on s@ | ||
92 | f << s.f; | ||
93 | @@ | ||
94 | |||
95 | try let _ = Hashtbl.find negtable f in () | ||
96 | with Not_found -> Hashtbl.add negtable f () | ||
97 | |||
98 | @ r disable is_zero,isnt_zero exists @ | ||
99 | expression *E; | ||
100 | identifier f; | ||
101 | @@ | ||
102 | |||
103 | E = f(...) | ||
104 | ... | ||
105 | (E == 0 | ||
106 | |E != 0 | ||
107 | |0 == E | ||
108 | |0 != E | ||
109 | ) | ||
110 | |||
111 | @script:ocaml@ | ||
112 | f << r.f; | ||
113 | @@ | ||
114 | |||
115 | try let _ = Hashtbl.find negtable f in () | ||
116 | with Not_found -> include_match false | ||
117 | |||
118 | // This rule may lead to inconsistent path problems, if E is defined in two | ||
119 | // places | ||
120 | @ depends on patch disable is_zero,isnt_zero @ | ||
121 | expression *E; | ||
122 | expression E1; | ||
123 | identifier r.f; | ||
124 | @@ | ||
125 | |||
126 | E = f(...) | ||
127 | <... | ||
128 | ( | ||
129 | - E == 0 | ||
130 | + !E | ||
131 | | | ||
132 | - E != 0 | ||
133 | + E | ||
134 | | | ||
135 | - 0 == E | ||
136 | + !E | ||
137 | | | ||
138 | - 0 != E | ||
139 | + E | ||
140 | ) | ||
141 | ...> | ||
142 | ?E = E1 | ||
143 | |||
144 | @t2 depends on !patch disable is_zero,isnt_zero @ | ||
145 | expression *E; | ||
146 | expression E1; | ||
147 | identifier r.f; | ||
148 | position p1; | ||
149 | position p2; | ||
150 | @@ | ||
151 | |||
152 | E = f(...) | ||
153 | <... | ||
154 | ( | ||
155 | * E == 0@p1 | ||
156 | | | ||
157 | * E != 0@p2 | ||
158 | | | ||
159 | * 0@p1 == E | ||
160 | | | ||
161 | * 0@p1 != E | ||
162 | ) | ||
163 | ...> | ||
164 | ?E = E1 | ||
165 | |||
166 | @script:python depends on org@ | ||
167 | p << t2.p1; | ||
168 | @@ | ||
169 | |||
170 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0, suggest !E") | ||
171 | |||
172 | @script:python depends on org@ | ||
173 | p << t2.p2; | ||
174 | @@ | ||
175 | |||
176 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0") | ||
177 | |||
178 | @script:python depends on report@ | ||
179 | p << t2.p1; | ||
180 | @@ | ||
181 | |||
182 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0, suggest !E") | ||
183 | |||
184 | @script:python depends on report@ | ||
185 | p << t2.p2; | ||
186 | @@ | ||
187 | |||
188 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0") | ||
189 | |||
190 | @ depends on patch disable is_zero,isnt_zero @ | ||
191 | expression *E; | ||
192 | @@ | ||
193 | |||
194 | ( | ||
195 | E == | ||
196 | - 0 | ||
197 | + NULL | ||
198 | | | ||
199 | E != | ||
200 | - 0 | ||
201 | + NULL | ||
202 | | | ||
203 | - 0 | ||
204 | + NULL | ||
205 | == E | ||
206 | | | ||
207 | - 0 | ||
208 | + NULL | ||
209 | != E | ||
210 | ) | ||
211 | |||
212 | @ t3 depends on !patch disable is_zero,isnt_zero @ | ||
213 | expression *E; | ||
214 | position p; | ||
215 | @@ | ||
216 | |||
217 | ( | ||
218 | * E == 0@p | ||
219 | | | ||
220 | * E != 0@p | ||
221 | | | ||
222 | * 0@p == E | ||
223 | | | ||
224 | * 0@p != E | ||
225 | ) | ||
226 | |||
227 | @script:python depends on org@ | ||
228 | p << t3.p; | ||
229 | @@ | ||
230 | |||
231 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0") | ||
232 | |||
233 | @script:python depends on report@ | ||
234 | p << t3.p; | ||
235 | @@ | ||
236 | |||
237 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0") | ||
diff --git a/scripts/coccinelle/null/eno.cocci b/scripts/coccinelle/null/eno.cocci index ed961a1f7d1..4c9c52b9c41 100644 --- a/scripts/coccinelle/null/eno.cocci +++ b/scripts/coccinelle/null/eno.cocci | |||
@@ -1,19 +1,16 @@ | |||
1 | /// The various basic memory allocation functions don't return ERR_PTR | 1 | /// The various basic memory allocation functions don't return ERR_PTR |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
10 | 10 | ||
11 | virtual patch | 11 | virtual patch |
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | 12 | ||
16 | @depends on patch@ | 13 | @@ |
17 | expression x,E; | 14 | expression x,E; |
18 | @@ | 15 | @@ |
19 | 16 | ||
@@ -21,28 +18,3 @@ x = \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache | |||
21 | ... when != x = E | 18 | ... when != x = E |
22 | - IS_ERR(x) | 19 | - IS_ERR(x) |
23 | + !x | 20 | + !x |
24 | |||
25 | @r depends on !patch exists@ | ||
26 | expression x,E; | ||
27 | position p1,p2; | ||
28 | @@ | ||
29 | |||
30 | *x = \(kmalloc@p1\|kzalloc@p1\|kcalloc@p1\|kmem_cache_alloc@p1\|kmem_cache_zalloc@p1\|kmem_cache_alloc_node@p1\|kmalloc_node@p1\|kzalloc_node@p1\)(...) | ||
31 | ... when != x = E | ||
32 | * IS_ERR@p2(x) | ||
33 | |||
34 | @script:python depends on org@ | ||
35 | p1 << r.p1; | ||
36 | p2 << r.p2; | ||
37 | @@ | ||
38 | |||
39 | cocci.print_main("alloc call",p1) | ||
40 | cocci.print_secs("IS_ERR that should be NULL tests",p2) | ||
41 | |||
42 | @script:python depends on report@ | ||
43 | p1 << r.p1; | ||
44 | p2 << r.p2; | ||
45 | @@ | ||
46 | |||
47 | msg = "ERROR: allocation function on line %s returns NULL not ERR_PTR on failure" % (p1[0].line) | ||
48 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/tests/odd_ptr_err.cocci b/scripts/coccinelle/tests/odd_ptr_err.cocci deleted file mode 100644 index e8dd8a6b28a..00000000000 --- a/scripts/coccinelle/tests/odd_ptr_err.cocci +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /// PTR_ERR should access the value just tested by IS_ERR | ||
2 | //# There can be false positives in the patch case, where it is the call | ||
3 | //# IS_ERR that is wrong. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Copyright: (C) 2012 Julia Lawall, INRIA. GPLv2. | ||
7 | // Copyright: (C) 2012 Gilles Muller, INRIA. GPLv2. | ||
8 | // URL: http://coccinelle.lip6.fr/ | ||
9 | // Comments: | ||
10 | // Options: -no_includes -include_headers | ||
11 | |||
12 | virtual patch | ||
13 | virtual context | ||
14 | virtual org | ||
15 | virtual report | ||
16 | |||
17 | @depends on patch@ | ||
18 | expression e,e1; | ||
19 | @@ | ||
20 | |||
21 | ( | ||
22 | if (IS_ERR(e)) { ... PTR_ERR(e) ... } | ||
23 | | | ||
24 | if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... } | ||
25 | | | ||
26 | if (IS_ERR(e)) | ||
27 | { ... | ||
28 | PTR_ERR( | ||
29 | - e1 | ||
30 | + e | ||
31 | ) | ||
32 | ... } | ||
33 | ) | ||
34 | |||
35 | @r depends on !patch@ | ||
36 | expression e,e1; | ||
37 | position p1,p2; | ||
38 | @@ | ||
39 | |||
40 | ( | ||
41 | if (IS_ERR(e)) { ... PTR_ERR(e) ... } | ||
42 | | | ||
43 | if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... } | ||
44 | | | ||
45 | *if (IS_ERR@p1(e)) | ||
46 | { ... | ||
47 | * PTR_ERR@p2(e1) | ||
48 | ... } | ||
49 | ) | ||
50 | |||
51 | @script:python depends on org@ | ||
52 | p1 << r.p1; | ||
53 | p2 << r.p2; | ||
54 | @@ | ||
55 | |||
56 | cocci.print_main("inconsistent IS_ERR and PTR_ERR",p1) | ||
57 | cocci.print_secs("PTR_ERR",p2) | ||
58 | |||
59 | @script:python depends on report@ | ||
60 | p1 << r.p1; | ||
61 | p2 << r.p2; | ||
62 | @@ | ||
63 | |||
64 | msg = "inconsistent IS_ERR and PTR_ERR, PTR_ERR on line %s" % (p2[0].line) | ||
65 | coccilib.report.print_report(p1[0],msg) | ||
diff --git a/scripts/config b/scripts/config index bb4d3deb6d1..a7c7c4b8e95 100755 --- a/scripts/config +++ b/scripts/config | |||
@@ -1,9 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # Manipulate options in a .config file from the command line | 2 | # Manipulate options in a .config file from the command line |
3 | 3 | ||
4 | # If no prefix forced, use the default CONFIG_ | ||
5 | CONFIG_="${CONFIG_-CONFIG_}" | ||
6 | |||
7 | usage() { | 4 | usage() { |
8 | cat >&2 <<EOL | 5 | cat >&2 <<EOL |
9 | Manipulate options in a .config file from the command line. | 6 | Manipulate options in a .config file from the command line. |
@@ -17,7 +14,6 @@ commands: | |||
17 | Set option to "string" | 14 | Set option to "string" |
18 | --set-val option value | 15 | --set-val option value |
19 | Set option to value | 16 | Set option to value |
20 | --undefine|-u option Undefine option | ||
21 | --state|-s option Print state of option (n,y,m,undef) | 17 | --state|-s option Print state of option (n,y,m,undef) |
22 | 18 | ||
23 | --enable-after|-E beforeopt option | 19 | --enable-after|-E beforeopt option |
@@ -30,17 +26,10 @@ commands: | |||
30 | commands can be repeated multiple times | 26 | commands can be repeated multiple times |
31 | 27 | ||
32 | options: | 28 | options: |
33 | --file config-file .config file to change (default .config) | 29 | --file .config file to change (default .config) |
34 | --keep-case|-k Keep next symbols' case (dont' upper-case it) | ||
35 | 30 | ||
36 | config doesn't check the validity of the .config file. This is done at next | 31 | config doesn't check the validity of the .config file. This is done at next |
37 | make time. | 32 | make time. |
38 | |||
39 | By default, config will upper-case the given symbol. Use --keep-case to keep | ||
40 | the case of all following symbols unchanged. | ||
41 | |||
42 | config uses 'CONFIG_' as the default symbol prefix. Set the environment | ||
43 | variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ... | ||
44 | EOL | 33 | EOL |
45 | exit 1 | 34 | exit 1 |
46 | } | 35 | } |
@@ -51,13 +40,11 @@ checkarg() { | |||
51 | usage | 40 | usage |
52 | fi | 41 | fi |
53 | case "$ARG" in | 42 | case "$ARG" in |
54 | ${CONFIG_}*) | 43 | CONFIG_*) |
55 | ARG="${ARG/${CONFIG_}/}" | 44 | ARG="${ARG/CONFIG_/}" |
56 | ;; | 45 | ;; |
57 | esac | 46 | esac |
58 | if [ "$MUNGE_CASE" = "yes" ] ; then | 47 | ARG="`echo $ARG | tr a-z A-Z`" |
59 | ARG="`echo $ARG | tr a-z A-Z`" | ||
60 | fi | ||
61 | } | 48 | } |
62 | 49 | ||
63 | set_var() { | 50 | set_var() { |
@@ -74,12 +61,6 @@ set_var() { | |||
74 | fi | 61 | fi |
75 | } | 62 | } |
76 | 63 | ||
77 | undef_var() { | ||
78 | local name=$1 | ||
79 | |||
80 | sed -ri "/^($name=|# $name is not set)/d" "$FN" | ||
81 | } | ||
82 | |||
83 | if [ "$1" = "--file" ]; then | 64 | if [ "$1" = "--file" ]; then |
84 | FN="$2" | 65 | FN="$2" |
85 | if [ "$FN" = "" ] ; then | 66 | if [ "$FN" = "" ] ; then |
@@ -94,15 +75,10 @@ if [ "$1" = "" ] ; then | |||
94 | usage | 75 | usage |
95 | fi | 76 | fi |
96 | 77 | ||
97 | MUNGE_CASE=yes | ||
98 | while [ "$1" != "" ] ; do | 78 | while [ "$1" != "" ] ; do |
99 | CMD="$1" | 79 | CMD="$1" |
100 | shift | 80 | shift |
101 | case "$CMD" in | 81 | case "$CMD" in |
102 | --keep-case|-k) | ||
103 | MUNGE_CASE=no | ||
104 | continue | ||
105 | ;; | ||
106 | --refresh) | 82 | --refresh) |
107 | ;; | 83 | ;; |
108 | --*-after) | 84 | --*-after) |
@@ -119,58 +95,52 @@ while [ "$1" != "" ] ; do | |||
119 | esac | 95 | esac |
120 | case "$CMD" in | 96 | case "$CMD" in |
121 | --enable|-e) | 97 | --enable|-e) |
122 | set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y" | 98 | set_var "CONFIG_$ARG" "CONFIG_$ARG=y" |
123 | ;; | 99 | ;; |
124 | 100 | ||
125 | --disable|-d) | 101 | --disable|-d) |
126 | set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set" | 102 | set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set" |
127 | ;; | 103 | ;; |
128 | 104 | ||
129 | --module|-m) | 105 | --module|-m) |
130 | set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m" | 106 | set_var "CONFIG_$ARG" "CONFIG_$ARG=m" |
131 | ;; | 107 | ;; |
132 | 108 | ||
133 | --set-str) | 109 | --set-str) |
134 | # sed swallows one level of escaping, so we need double-escaping | 110 | set_var "CONFIG_$ARG" "CONFIG_$ARG=\"$1\"" |
135 | set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\"" | ||
136 | shift | 111 | shift |
137 | ;; | 112 | ;; |
138 | 113 | ||
139 | --set-val) | 114 | --set-val) |
140 | set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1" | 115 | set_var "CONFIG_$ARG" "CONFIG_$ARG=$1" |
141 | shift | 116 | shift |
142 | ;; | 117 | ;; |
143 | --undefine|-u) | ||
144 | undef_var "${CONFIG_}$ARG" | ||
145 | ;; | ||
146 | 118 | ||
147 | --state|-s) | 119 | --state|-s) |
148 | if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then | 120 | if grep -q "# CONFIG_$ARG is not set" $FN ; then |
149 | echo n | 121 | echo n |
150 | else | 122 | else |
151 | V="$(grep "^${CONFIG_}$ARG=" $FN)" | 123 | V="$(grep "^CONFIG_$ARG=" $FN)" |
152 | if [ $? != 0 ] ; then | 124 | if [ $? != 0 ] ; then |
153 | echo undef | 125 | echo undef |
154 | else | 126 | else |
155 | V="${V/#${CONFIG_}$ARG=/}" | 127 | V="${V/CONFIG_$ARG=/}" |
156 | V="${V/#\"/}" | 128 | V="${V/\"/}" |
157 | V="${V/%\"/}" | 129 | echo "$V" |
158 | V="${V//\\\"/\"}" | ||
159 | echo "${V}" | ||
160 | fi | 130 | fi |
161 | fi | 131 | fi |
162 | ;; | 132 | ;; |
163 | 133 | ||
164 | --enable-after|-E) | 134 | --enable-after|-E) |
165 | set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A" | 135 | set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A" |
166 | ;; | 136 | ;; |
167 | 137 | ||
168 | --disable-after|-D) | 138 | --disable-after|-D) |
169 | set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A" | 139 | set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A" |
170 | ;; | 140 | ;; |
171 | 141 | ||
172 | --module-after|-M) | 142 | --module-after|-M) |
173 | set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A" | 143 | set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A" |
174 | ;; | 144 | ;; |
175 | 145 | ||
176 | # undocumented because it ignores --file (fixme) | 146 | # undocumented because it ignores --file (fixme) |
diff --git a/scripts/decodecode b/scripts/decodecode index 4f8248d5a11..18ba881c341 100755 --- a/scripts/decodecode +++ b/scripts/decodecode | |||
@@ -89,7 +89,7 @@ echo $code >> $T.s | |||
89 | disas $T | 89 | disas $T |
90 | cat $T.dis >> $T.aa | 90 | cat $T.dis >> $T.aa |
91 | 91 | ||
92 | faultline=`cat $T.dis | head -1 | cut -d":" -f2-` | 92 | faultline=`cat $T.dis | head -1 | cut -d":" -f2` |
93 | faultline=`echo "$faultline" | sed -e 's/\[/\\\[/g; s/\]/\\\]/g'` | 93 | faultline=`echo "$faultline" | sed -e 's/\[/\\\[/g; s/\]/\\\]/g'` |
94 | 94 | ||
95 | cat $T.oo | sed -e "s/\($faultline\)/\*\1 <-- trapping instruction/g" | 95 | cat $T.oo | sed -e "s/\($faultline\)/\*\1 <-- trapping instruction/g" |
diff --git a/scripts/depmod.sh b/scripts/depmod.sh index 2ae48170314..a2723568594 100755 --- a/scripts/depmod.sh +++ b/scripts/depmod.sh | |||
@@ -9,6 +9,12 @@ fi | |||
9 | DEPMOD=$1 | 9 | DEPMOD=$1 |
10 | KERNELRELEASE=$2 | 10 | KERNELRELEASE=$2 |
11 | 11 | ||
12 | if ! "$DEPMOD" -V 2>/dev/null | grep -q module-init-tools; then | ||
13 | echo "Warning: you may need to install module-init-tools" >&2 | ||
14 | echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt" >&2 | ||
15 | sleep 1 | ||
16 | fi | ||
17 | |||
12 | if ! test -r System.map -a -x "$DEPMOD"; then | 18 | if ! test -r System.map -a -x "$DEPMOD"; then |
13 | exit 0 | 19 | exit 0 |
14 | fi | 20 | fi |
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 2a48022c41e..6d1c6bb9f22 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile | |||
@@ -27,5 +27,3 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) | |||
27 | # dependencies on generated files need to be listed explicitly | 27 | # dependencies on generated files need to be listed explicitly |
28 | $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h | 28 | $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h |
29 | 29 | ||
30 | # generated files need to be cleaned explicitly | ||
31 | clean-files := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h | ||
diff --git a/scripts/dtc/Makefile.dtc b/scripts/dtc/Makefile.dtc index bece49b3553..6ddf9ecac66 100644 --- a/scripts/dtc/Makefile.dtc +++ b/scripts/dtc/Makefile.dtc | |||
@@ -3,16 +3,7 @@ | |||
3 | # This is not a complete Makefile of itself. Instead, it is designed to | 3 | # This is not a complete Makefile of itself. Instead, it is designed to |
4 | # be easily embeddable into other systems of Makefiles. | 4 | # be easily embeddable into other systems of Makefiles. |
5 | # | 5 | # |
6 | DTC_SRCS = \ | 6 | DTC_SRCS = dtc.c flattree.c fstree.c data.c livetree.c treesource.c srcpos.c \ |
7 | checks.c \ | 7 | checks.c |
8 | data.c \ | ||
9 | dtc.c \ | ||
10 | flattree.c \ | ||
11 | fstree.c \ | ||
12 | livetree.c \ | ||
13 | srcpos.c \ | ||
14 | treesource.c \ | ||
15 | util.c | ||
16 | |||
17 | DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c | 8 | DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c |
18 | DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o) | 9 | DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o) |
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c index ee96a2519ef..a662a004479 100644 --- a/scripts/dtc/checks.c +++ b/scripts/dtc/checks.c | |||
@@ -31,6 +31,12 @@ | |||
31 | #define TRACE(c, fmt, ...) do { } while (0) | 31 | #define TRACE(c, fmt, ...) do { } while (0) |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | enum checklevel { | ||
35 | IGNORE = 0, | ||
36 | WARN = 1, | ||
37 | ERROR = 2, | ||
38 | }; | ||
39 | |||
34 | enum checkstatus { | 40 | enum checkstatus { |
35 | UNCHECKED = 0, | 41 | UNCHECKED = 0, |
36 | PREREQ, | 42 | PREREQ, |
@@ -51,14 +57,14 @@ struct check { | |||
51 | node_check_fn node_fn; | 57 | node_check_fn node_fn; |
52 | prop_check_fn prop_fn; | 58 | prop_check_fn prop_fn; |
53 | void *data; | 59 | void *data; |
54 | bool warn, error; | 60 | enum checklevel level; |
55 | enum checkstatus status; | 61 | enum checkstatus status; |
56 | int inprogress; | 62 | int inprogress; |
57 | int num_prereqs; | 63 | int num_prereqs; |
58 | struct check **prereq; | 64 | struct check **prereq; |
59 | }; | 65 | }; |
60 | 66 | ||
61 | #define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ | 67 | #define CHECK(nm, tfn, nfn, pfn, d, lvl, ...) \ |
62 | static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ | 68 | static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ |
63 | static struct check nm = { \ | 69 | static struct check nm = { \ |
64 | .name = #nm, \ | 70 | .name = #nm, \ |
@@ -66,37 +72,20 @@ struct check { | |||
66 | .node_fn = (nfn), \ | 72 | .node_fn = (nfn), \ |
67 | .prop_fn = (pfn), \ | 73 | .prop_fn = (pfn), \ |
68 | .data = (d), \ | 74 | .data = (d), \ |
69 | .warn = (w), \ | 75 | .level = (lvl), \ |
70 | .error = (e), \ | ||
71 | .status = UNCHECKED, \ | 76 | .status = UNCHECKED, \ |
72 | .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ | 77 | .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ |
73 | .prereq = nm##_prereqs, \ | 78 | .prereq = nm##_prereqs, \ |
74 | }; | 79 | }; |
75 | #define WARNING(nm, tfn, nfn, pfn, d, ...) \ | 80 | |
76 | CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__) | 81 | #define TREE_CHECK(nm, d, lvl, ...) \ |
77 | #define ERROR(nm, tfn, nfn, pfn, d, ...) \ | 82 | CHECK(nm, check_##nm, NULL, NULL, d, lvl, __VA_ARGS__) |
78 | CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, true, __VA_ARGS__) | 83 | #define NODE_CHECK(nm, d, lvl, ...) \ |
79 | #define CHECK(nm, tfn, nfn, pfn, d, ...) \ | 84 | CHECK(nm, NULL, check_##nm, NULL, d, lvl, __VA_ARGS__) |
80 | CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, false, __VA_ARGS__) | 85 | #define PROP_CHECK(nm, d, lvl, ...) \ |
81 | 86 | CHECK(nm, NULL, NULL, check_##nm, d, lvl, __VA_ARGS__) | |
82 | #define TREE_WARNING(nm, d, ...) \ | 87 | #define BATCH_CHECK(nm, lvl, ...) \ |
83 | WARNING(nm, check_##nm, NULL, NULL, d, __VA_ARGS__) | 88 | CHECK(nm, NULL, NULL, NULL, NULL, lvl, __VA_ARGS__) |
84 | #define TREE_ERROR(nm, d, ...) \ | ||
85 | ERROR(nm, check_##nm, NULL, NULL, d, __VA_ARGS__) | ||
86 | #define TREE_CHECK(nm, d, ...) \ | ||
87 | CHECK(nm, check_##nm, NULL, NULL, d, __VA_ARGS__) | ||
88 | #define NODE_WARNING(nm, d, ...) \ | ||
89 | WARNING(nm, NULL, check_##nm, NULL, d, __VA_ARGS__) | ||
90 | #define NODE_ERROR(nm, d, ...) \ | ||
91 | ERROR(nm, NULL, check_##nm, NULL, d, __VA_ARGS__) | ||
92 | #define NODE_CHECK(nm, d, ...) \ | ||
93 | CHECK(nm, NULL, check_##nm, NULL, d, __VA_ARGS__) | ||
94 | #define PROP_WARNING(nm, d, ...) \ | ||
95 | WARNING(nm, NULL, NULL, check_##nm, d, __VA_ARGS__) | ||
96 | #define PROP_ERROR(nm, d, ...) \ | ||
97 | ERROR(nm, NULL, NULL, check_##nm, d, __VA_ARGS__) | ||
98 | #define PROP_CHECK(nm, d, ...) \ | ||
99 | CHECK(nm, NULL, NULL, check_##nm, d, __VA_ARGS__) | ||
100 | 89 | ||
101 | #ifdef __GNUC__ | 90 | #ifdef __GNUC__ |
102 | static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3))); | 91 | static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3))); |
@@ -106,13 +95,13 @@ static inline void check_msg(struct check *c, const char *fmt, ...) | |||
106 | va_list ap; | 95 | va_list ap; |
107 | va_start(ap, fmt); | 96 | va_start(ap, fmt); |
108 | 97 | ||
109 | if ((c->warn && (quiet < 1)) | 98 | if ((c->level < WARN) || (c->level <= quiet)) |
110 | || (c->error && (quiet < 2))) { | 99 | return; /* Suppress message */ |
111 | fprintf(stderr, "%s (%s): ", | 100 | |
112 | (c->error) ? "ERROR" : "Warning", c->name); | 101 | fprintf(stderr, "%s (%s): ", |
113 | vfprintf(stderr, fmt, ap); | 102 | (c->level == ERROR) ? "ERROR" : "Warning", c->name); |
114 | fprintf(stderr, "\n"); | 103 | vfprintf(stderr, fmt, ap); |
115 | } | 104 | fprintf(stderr, "\n"); |
116 | } | 105 | } |
117 | 106 | ||
118 | #define FAIL(c, ...) \ | 107 | #define FAIL(c, ...) \ |
@@ -178,7 +167,7 @@ static int run_check(struct check *c, struct node *dt) | |||
178 | 167 | ||
179 | out: | 168 | out: |
180 | c->inprogress = 0; | 169 | c->inprogress = 0; |
181 | if ((c->status != PASSED) && (c->error)) | 170 | if ((c->status != PASSED) && (c->level == ERROR)) |
182 | error = 1; | 171 | error = 1; |
183 | return error; | 172 | return error; |
184 | } | 173 | } |
@@ -187,13 +176,6 @@ out: | |||
187 | * Utility check functions | 176 | * Utility check functions |
188 | */ | 177 | */ |
189 | 178 | ||
190 | /* A check which always fails, for testing purposes only */ | ||
191 | static inline void check_always_fail(struct check *c, struct node *dt) | ||
192 | { | ||
193 | FAIL(c, "always_fail check"); | ||
194 | } | ||
195 | TREE_CHECK(always_fail, NULL); | ||
196 | |||
197 | static void check_is_string(struct check *c, struct node *root, | 179 | static void check_is_string(struct check *c, struct node *root, |
198 | struct node *node) | 180 | struct node *node) |
199 | { | 181 | { |
@@ -208,10 +190,8 @@ static void check_is_string(struct check *c, struct node *root, | |||
208 | FAIL(c, "\"%s\" property in %s is not a string", | 190 | FAIL(c, "\"%s\" property in %s is not a string", |
209 | propname, node->fullpath); | 191 | propname, node->fullpath); |
210 | } | 192 | } |
211 | #define WARNING_IF_NOT_STRING(nm, propname) \ | 193 | #define CHECK_IS_STRING(nm, propname, lvl) \ |
212 | WARNING(nm, NULL, check_is_string, NULL, (propname)) | 194 | CHECK(nm, NULL, check_is_string, NULL, (propname), (lvl)) |
213 | #define ERROR_IF_NOT_STRING(nm, propname) \ | ||
214 | ERROR(nm, NULL, check_is_string, NULL, (propname)) | ||
215 | 195 | ||
216 | static void check_is_cell(struct check *c, struct node *root, | 196 | static void check_is_cell(struct check *c, struct node *root, |
217 | struct node *node) | 197 | struct node *node) |
@@ -227,10 +207,8 @@ static void check_is_cell(struct check *c, struct node *root, | |||
227 | FAIL(c, "\"%s\" property in %s is not a single cell", | 207 | FAIL(c, "\"%s\" property in %s is not a single cell", |
228 | propname, node->fullpath); | 208 | propname, node->fullpath); |
229 | } | 209 | } |
230 | #define WARNING_IF_NOT_CELL(nm, propname) \ | 210 | #define CHECK_IS_CELL(nm, propname, lvl) \ |
231 | WARNING(nm, NULL, check_is_cell, NULL, (propname)) | 211 | CHECK(nm, NULL, check_is_cell, NULL, (propname), (lvl)) |
232 | #define ERROR_IF_NOT_CELL(nm, propname) \ | ||
233 | ERROR(nm, NULL, check_is_cell, NULL, (propname)) | ||
234 | 212 | ||
235 | /* | 213 | /* |
236 | * Structural check functions | 214 | * Structural check functions |
@@ -249,24 +227,20 @@ static void check_duplicate_node_names(struct check *c, struct node *dt, | |||
249 | FAIL(c, "Duplicate node name %s", | 227 | FAIL(c, "Duplicate node name %s", |
250 | child->fullpath); | 228 | child->fullpath); |
251 | } | 229 | } |
252 | NODE_ERROR(duplicate_node_names, NULL); | 230 | NODE_CHECK(duplicate_node_names, NULL, ERROR); |
253 | 231 | ||
254 | static void check_duplicate_property_names(struct check *c, struct node *dt, | 232 | static void check_duplicate_property_names(struct check *c, struct node *dt, |
255 | struct node *node) | 233 | struct node *node) |
256 | { | 234 | { |
257 | struct property *prop, *prop2; | 235 | struct property *prop, *prop2; |
258 | 236 | ||
259 | for_each_property(node, prop) { | 237 | for_each_property(node, prop) |
260 | for (prop2 = prop->next; prop2; prop2 = prop2->next) { | 238 | for (prop2 = prop->next; prop2; prop2 = prop2->next) |
261 | if (prop2->deleted) | ||
262 | continue; | ||
263 | if (streq(prop->name, prop2->name)) | 239 | if (streq(prop->name, prop2->name)) |
264 | FAIL(c, "Duplicate property name %s in %s", | 240 | FAIL(c, "Duplicate property name %s in %s", |
265 | prop->name, node->fullpath); | 241 | prop->name, node->fullpath); |
266 | } | ||
267 | } | ||
268 | } | 242 | } |
269 | NODE_ERROR(duplicate_property_names, NULL); | 243 | NODE_CHECK(duplicate_property_names, NULL, ERROR); |
270 | 244 | ||
271 | #define LOWERCASE "abcdefghijklmnopqrstuvwxyz" | 245 | #define LOWERCASE "abcdefghijklmnopqrstuvwxyz" |
272 | #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | 246 | #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
@@ -282,7 +256,7 @@ static void check_node_name_chars(struct check *c, struct node *dt, | |||
282 | FAIL(c, "Bad character '%c' in node %s", | 256 | FAIL(c, "Bad character '%c' in node %s", |
283 | node->name[n], node->fullpath); | 257 | node->name[n], node->fullpath); |
284 | } | 258 | } |
285 | NODE_ERROR(node_name_chars, PROPNODECHARS "@"); | 259 | NODE_CHECK(node_name_chars, PROPNODECHARS "@", ERROR); |
286 | 260 | ||
287 | static void check_node_name_format(struct check *c, struct node *dt, | 261 | static void check_node_name_format(struct check *c, struct node *dt, |
288 | struct node *node) | 262 | struct node *node) |
@@ -291,7 +265,7 @@ static void check_node_name_format(struct check *c, struct node *dt, | |||
291 | FAIL(c, "Node %s has multiple '@' characters in name", | 265 | FAIL(c, "Node %s has multiple '@' characters in name", |
292 | node->fullpath); | 266 | node->fullpath); |
293 | } | 267 | } |
294 | NODE_ERROR(node_name_format, NULL, &node_name_chars); | 268 | NODE_CHECK(node_name_format, NULL, ERROR, &node_name_chars); |
295 | 269 | ||
296 | static void check_property_name_chars(struct check *c, struct node *dt, | 270 | static void check_property_name_chars(struct check *c, struct node *dt, |
297 | struct node *node, struct property *prop) | 271 | struct node *node, struct property *prop) |
@@ -302,7 +276,7 @@ static void check_property_name_chars(struct check *c, struct node *dt, | |||
302 | FAIL(c, "Bad character '%c' in property name \"%s\", node %s", | 276 | FAIL(c, "Bad character '%c' in property name \"%s\", node %s", |
303 | prop->name[n], prop->name, node->fullpath); | 277 | prop->name[n], prop->name, node->fullpath); |
304 | } | 278 | } |
305 | PROP_ERROR(property_name_chars, PROPNODECHARS); | 279 | PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR); |
306 | 280 | ||
307 | #define DESCLABEL_FMT "%s%s%s%s%s" | 281 | #define DESCLABEL_FMT "%s%s%s%s%s" |
308 | #define DESCLABEL_ARGS(node,prop,mark) \ | 282 | #define DESCLABEL_ARGS(node,prop,mark) \ |
@@ -357,8 +331,8 @@ static void check_duplicate_label_prop(struct check *c, struct node *dt, | |||
357 | for_each_marker_of_type(m, LABEL) | 331 | for_each_marker_of_type(m, LABEL) |
358 | check_duplicate_label(c, dt, m->ref, node, prop, m); | 332 | check_duplicate_label(c, dt, m->ref, node, prop, m); |
359 | } | 333 | } |
360 | ERROR(duplicate_label, NULL, check_duplicate_label_node, | 334 | CHECK(duplicate_label, NULL, check_duplicate_label_node, |
361 | check_duplicate_label_prop, NULL); | 335 | check_duplicate_label_prop, NULL, ERROR); |
362 | 336 | ||
363 | static void check_explicit_phandles(struct check *c, struct node *root, | 337 | static void check_explicit_phandles(struct check *c, struct node *root, |
364 | struct node *node, struct property *prop) | 338 | struct node *node, struct property *prop) |
@@ -417,7 +391,7 @@ static void check_explicit_phandles(struct check *c, struct node *root, | |||
417 | 391 | ||
418 | node->phandle = phandle; | 392 | node->phandle = phandle; |
419 | } | 393 | } |
420 | PROP_ERROR(explicit_phandles, NULL); | 394 | PROP_CHECK(explicit_phandles, NULL, ERROR); |
421 | 395 | ||
422 | static void check_name_properties(struct check *c, struct node *root, | 396 | static void check_name_properties(struct check *c, struct node *root, |
423 | struct node *node) | 397 | struct node *node) |
@@ -446,8 +420,8 @@ static void check_name_properties(struct check *c, struct node *root, | |||
446 | free(prop); | 420 | free(prop); |
447 | } | 421 | } |
448 | } | 422 | } |
449 | ERROR_IF_NOT_STRING(name_is_string, "name"); | 423 | CHECK_IS_STRING(name_is_string, "name", ERROR); |
450 | NODE_ERROR(name_properties, NULL, &name_is_string); | 424 | NODE_CHECK(name_properties, NULL, ERROR, &name_is_string); |
451 | 425 | ||
452 | /* | 426 | /* |
453 | * Reference fixup functions | 427 | * Reference fixup functions |
@@ -474,7 +448,7 @@ static void fixup_phandle_references(struct check *c, struct node *dt, | |||
474 | *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); | 448 | *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); |
475 | } | 449 | } |
476 | } | 450 | } |
477 | ERROR(phandle_references, NULL, NULL, fixup_phandle_references, NULL, | 451 | CHECK(phandle_references, NULL, NULL, fixup_phandle_references, NULL, ERROR, |
478 | &duplicate_node_names, &explicit_phandles); | 452 | &duplicate_node_names, &explicit_phandles); |
479 | 453 | ||
480 | static void fixup_path_references(struct check *c, struct node *dt, | 454 | static void fixup_path_references(struct check *c, struct node *dt, |
@@ -499,19 +473,19 @@ static void fixup_path_references(struct check *c, struct node *dt, | |||
499 | strlen(path) + 1); | 473 | strlen(path) + 1); |
500 | } | 474 | } |
501 | } | 475 | } |
502 | ERROR(path_references, NULL, NULL, fixup_path_references, NULL, | 476 | CHECK(path_references, NULL, NULL, fixup_path_references, NULL, ERROR, |
503 | &duplicate_node_names); | 477 | &duplicate_node_names); |
504 | 478 | ||
505 | /* | 479 | /* |
506 | * Semantic checks | 480 | * Semantic checks |
507 | */ | 481 | */ |
508 | WARNING_IF_NOT_CELL(address_cells_is_cell, "#address-cells"); | 482 | CHECK_IS_CELL(address_cells_is_cell, "#address-cells", WARN); |
509 | WARNING_IF_NOT_CELL(size_cells_is_cell, "#size-cells"); | 483 | CHECK_IS_CELL(size_cells_is_cell, "#size-cells", WARN); |
510 | WARNING_IF_NOT_CELL(interrupt_cells_is_cell, "#interrupt-cells"); | 484 | CHECK_IS_CELL(interrupt_cells_is_cell, "#interrupt-cells", WARN); |
511 | 485 | ||
512 | WARNING_IF_NOT_STRING(device_type_is_string, "device_type"); | 486 | CHECK_IS_STRING(device_type_is_string, "device_type", WARN); |
513 | WARNING_IF_NOT_STRING(model_is_string, "model"); | 487 | CHECK_IS_STRING(model_is_string, "model", WARN); |
514 | WARNING_IF_NOT_STRING(status_is_string, "status"); | 488 | CHECK_IS_STRING(status_is_string, "status", WARN); |
515 | 489 | ||
516 | static void fixup_addr_size_cells(struct check *c, struct node *dt, | 490 | static void fixup_addr_size_cells(struct check *c, struct node *dt, |
517 | struct node *node) | 491 | struct node *node) |
@@ -529,8 +503,8 @@ static void fixup_addr_size_cells(struct check *c, struct node *dt, | |||
529 | if (prop) | 503 | if (prop) |
530 | node->size_cells = propval_cell(prop); | 504 | node->size_cells = propval_cell(prop); |
531 | } | 505 | } |
532 | WARNING(addr_size_cells, NULL, fixup_addr_size_cells, NULL, NULL, | 506 | CHECK(addr_size_cells, NULL, fixup_addr_size_cells, NULL, NULL, WARN, |
533 | &address_cells_is_cell, &size_cells_is_cell); | 507 | &address_cells_is_cell, &size_cells_is_cell); |
534 | 508 | ||
535 | #define node_addr_cells(n) \ | 509 | #define node_addr_cells(n) \ |
536 | (((n)->addr_cells == -1) ? 2 : (n)->addr_cells) | 510 | (((n)->addr_cells == -1) ? 2 : (n)->addr_cells) |
@@ -564,7 +538,7 @@ static void check_reg_format(struct check *c, struct node *dt, | |||
564 | "(#address-cells == %d, #size-cells == %d)", | 538 | "(#address-cells == %d, #size-cells == %d)", |
565 | node->fullpath, prop->val.len, addr_cells, size_cells); | 539 | node->fullpath, prop->val.len, addr_cells, size_cells); |
566 | } | 540 | } |
567 | NODE_WARNING(reg_format, NULL, &addr_size_cells); | 541 | NODE_CHECK(reg_format, NULL, WARN, &addr_size_cells); |
568 | 542 | ||
569 | static void check_ranges_format(struct check *c, struct node *dt, | 543 | static void check_ranges_format(struct check *c, struct node *dt, |
570 | struct node *node) | 544 | struct node *node) |
@@ -605,7 +579,7 @@ static void check_ranges_format(struct check *c, struct node *dt, | |||
605 | p_addr_cells, c_addr_cells, c_size_cells); | 579 | p_addr_cells, c_addr_cells, c_size_cells); |
606 | } | 580 | } |
607 | } | 581 | } |
608 | NODE_WARNING(ranges_format, NULL, &addr_size_cells); | 582 | NODE_CHECK(ranges_format, NULL, WARN, &addr_size_cells); |
609 | 583 | ||
610 | /* | 584 | /* |
611 | * Style checks | 585 | * Style checks |
@@ -632,7 +606,7 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt, | |||
632 | FAIL(c, "Relying on default #size-cells value for %s", | 606 | FAIL(c, "Relying on default #size-cells value for %s", |
633 | node->fullpath); | 607 | node->fullpath); |
634 | } | 608 | } |
635 | NODE_WARNING(avoid_default_addr_size, NULL, &addr_size_cells); | 609 | NODE_CHECK(avoid_default_addr_size, NULL, WARN, &addr_size_cells); |
636 | 610 | ||
637 | static void check_obsolete_chosen_interrupt_controller(struct check *c, | 611 | static void check_obsolete_chosen_interrupt_controller(struct check *c, |
638 | struct node *dt) | 612 | struct node *dt) |
@@ -649,7 +623,7 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, | |||
649 | FAIL(c, "/chosen has obsolete \"interrupt-controller\" " | 623 | FAIL(c, "/chosen has obsolete \"interrupt-controller\" " |
650 | "property"); | 624 | "property"); |
651 | } | 625 | } |
652 | TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); | 626 | TREE_CHECK(obsolete_chosen_interrupt_controller, NULL, WARN); |
653 | 627 | ||
654 | static struct check *check_table[] = { | 628 | static struct check *check_table[] = { |
655 | &duplicate_node_names, &duplicate_property_names, | 629 | &duplicate_node_names, &duplicate_property_names, |
@@ -668,71 +642,8 @@ static struct check *check_table[] = { | |||
668 | 642 | ||
669 | &avoid_default_addr_size, | 643 | &avoid_default_addr_size, |
670 | &obsolete_chosen_interrupt_controller, | 644 | &obsolete_chosen_interrupt_controller, |
671 | |||
672 | &always_fail, | ||
673 | }; | 645 | }; |
674 | 646 | ||
675 | static void enable_warning_error(struct check *c, bool warn, bool error) | ||
676 | { | ||
677 | int i; | ||
678 | |||
679 | /* Raising level, also raise it for prereqs */ | ||
680 | if ((warn && !c->warn) || (error && !c->error)) | ||
681 | for (i = 0; i < c->num_prereqs; i++) | ||
682 | enable_warning_error(c->prereq[i], warn, error); | ||
683 | |||
684 | c->warn = c->warn || warn; | ||
685 | c->error = c->error || error; | ||
686 | } | ||
687 | |||
688 | static void disable_warning_error(struct check *c, bool warn, bool error) | ||
689 | { | ||
690 | int i; | ||
691 | |||
692 | /* Lowering level, also lower it for things this is the prereq | ||
693 | * for */ | ||
694 | if ((warn && c->warn) || (error && c->error)) { | ||
695 | for (i = 0; i < ARRAY_SIZE(check_table); i++) { | ||
696 | struct check *cc = check_table[i]; | ||
697 | int j; | ||
698 | |||
699 | for (j = 0; j < cc->num_prereqs; j++) | ||
700 | if (cc->prereq[j] == c) | ||
701 | disable_warning_error(cc, warn, error); | ||
702 | } | ||
703 | } | ||
704 | |||
705 | c->warn = c->warn && !warn; | ||
706 | c->error = c->error && !error; | ||
707 | } | ||
708 | |||
709 | void parse_checks_option(bool warn, bool error, const char *optarg) | ||
710 | { | ||
711 | int i; | ||
712 | const char *name = optarg; | ||
713 | bool enable = true; | ||
714 | |||
715 | if ((strncmp(optarg, "no-", 3) == 0) | ||
716 | || (strncmp(optarg, "no_", 3) == 0)) { | ||
717 | name = optarg + 3; | ||
718 | enable = false; | ||
719 | } | ||
720 | |||
721 | for (i = 0; i < ARRAY_SIZE(check_table); i++) { | ||
722 | struct check *c = check_table[i]; | ||
723 | |||
724 | if (streq(c->name, name)) { | ||
725 | if (enable) | ||
726 | enable_warning_error(c, warn, error); | ||
727 | else | ||
728 | disable_warning_error(c, warn, error); | ||
729 | return; | ||
730 | } | ||
731 | } | ||
732 | |||
733 | die("Unrecognized check name \"%s\"\n", name); | ||
734 | } | ||
735 | |||
736 | void process_checks(int force, struct boot_info *bi) | 647 | void process_checks(int force, struct boot_info *bi) |
737 | { | 648 | { |
738 | struct node *dt = bi->dt; | 649 | struct node *dt = bi->dt; |
@@ -742,7 +653,7 @@ void process_checks(int force, struct boot_info *bi) | |||
742 | for (i = 0; i < ARRAY_SIZE(check_table); i++) { | 653 | for (i = 0; i < ARRAY_SIZE(check_table); i++) { |
743 | struct check *c = check_table[i]; | 654 | struct check *c = check_table[i]; |
744 | 655 | ||
745 | if (c->warn || c->error) | 656 | if (c->level != IGNORE) |
746 | error = error || run_check(c, dt); | 657 | error = error || run_check(c, dt); |
747 | } | 658 | } |
748 | 659 | ||
diff --git a/scripts/dtc/data.c b/scripts/dtc/data.c index 4a40c5b9247..fe555e819bf 100644 --- a/scripts/dtc/data.c +++ b/scripts/dtc/data.c | |||
@@ -68,6 +68,40 @@ struct data data_copy_mem(const char *mem, int len) | |||
68 | return d; | 68 | return d; |
69 | } | 69 | } |
70 | 70 | ||
71 | static char get_oct_char(const char *s, int *i) | ||
72 | { | ||
73 | char x[4]; | ||
74 | char *endx; | ||
75 | long val; | ||
76 | |||
77 | x[3] = '\0'; | ||
78 | strncpy(x, s + *i, 3); | ||
79 | |||
80 | val = strtol(x, &endx, 8); | ||
81 | |||
82 | assert(endx > x); | ||
83 | |||
84 | (*i) += endx - x; | ||
85 | return val; | ||
86 | } | ||
87 | |||
88 | static char get_hex_char(const char *s, int *i) | ||
89 | { | ||
90 | char x[3]; | ||
91 | char *endx; | ||
92 | long val; | ||
93 | |||
94 | x[2] = '\0'; | ||
95 | strncpy(x, s + *i, 2); | ||
96 | |||
97 | val = strtol(x, &endx, 16); | ||
98 | if (!(endx > x)) | ||
99 | die("\\x used with no following hex digits\n"); | ||
100 | |||
101 | (*i) += endx - x; | ||
102 | return val; | ||
103 | } | ||
104 | |||
71 | struct data data_copy_escape_string(const char *s, int len) | 105 | struct data data_copy_escape_string(const char *s, int len) |
72 | { | 106 | { |
73 | int i = 0; | 107 | int i = 0; |
@@ -80,10 +114,53 @@ struct data data_copy_escape_string(const char *s, int len) | |||
80 | while (i < len) { | 114 | while (i < len) { |
81 | char c = s[i++]; | 115 | char c = s[i++]; |
82 | 116 | ||
83 | if (c == '\\') | 117 | if (c != '\\') { |
84 | c = get_escape_char(s, &i); | 118 | q[d.len++] = c; |
85 | 119 | continue; | |
86 | q[d.len++] = c; | 120 | } |
121 | |||
122 | c = s[i++]; | ||
123 | assert(c); | ||
124 | switch (c) { | ||
125 | case 'a': | ||
126 | q[d.len++] = '\a'; | ||
127 | break; | ||
128 | case 'b': | ||
129 | q[d.len++] = '\b'; | ||
130 | break; | ||
131 | case 't': | ||
132 | q[d.len++] = '\t'; | ||
133 | break; | ||
134 | case 'n': | ||
135 | q[d.len++] = '\n'; | ||
136 | break; | ||
137 | case 'v': | ||
138 | q[d.len++] = '\v'; | ||
139 | break; | ||
140 | case 'f': | ||
141 | q[d.len++] = '\f'; | ||
142 | break; | ||
143 | case 'r': | ||
144 | q[d.len++] = '\r'; | ||
145 | break; | ||
146 | case '0': | ||
147 | case '1': | ||
148 | case '2': | ||
149 | case '3': | ||
150 | case '4': | ||
151 | case '5': | ||
152 | case '6': | ||
153 | case '7': | ||
154 | i--; /* need to re-read the first digit as | ||
155 | * part of the octal value */ | ||
156 | q[d.len++] = get_oct_char(s, &i); | ||
157 | break; | ||
158 | case 'x': | ||
159 | q[d.len++] = get_hex_char(s, &i); | ||
160 | break; | ||
161 | default: | ||
162 | q[d.len++] = c; | ||
163 | } | ||
87 | } | 164 | } |
88 | 165 | ||
89 | q[d.len++] = '\0'; | 166 | q[d.len++] = '\0'; |
@@ -168,33 +245,11 @@ struct data data_merge(struct data d1, struct data d2) | |||
168 | return d; | 245 | return d; |
169 | } | 246 | } |
170 | 247 | ||
171 | struct data data_append_integer(struct data d, uint64_t value, int bits) | 248 | struct data data_append_cell(struct data d, cell_t word) |
172 | { | 249 | { |
173 | uint8_t value_8; | 250 | cell_t beword = cpu_to_fdt32(word); |
174 | uint16_t value_16; | 251 | |
175 | uint32_t value_32; | 252 | return data_append_data(d, &beword, sizeof(beword)); |
176 | uint64_t value_64; | ||
177 | |||
178 | switch (bits) { | ||
179 | case 8: | ||
180 | value_8 = value; | ||
181 | return data_append_data(d, &value_8, 1); | ||
182 | |||
183 | case 16: | ||
184 | value_16 = cpu_to_fdt16(value); | ||
185 | return data_append_data(d, &value_16, 2); | ||
186 | |||
187 | case 32: | ||
188 | value_32 = cpu_to_fdt32(value); | ||
189 | return data_append_data(d, &value_32, 4); | ||
190 | |||
191 | case 64: | ||
192 | value_64 = cpu_to_fdt64(value); | ||
193 | return data_append_data(d, &value_64, 8); | ||
194 | |||
195 | default: | ||
196 | die("Invalid literal size (%d)\n", bits); | ||
197 | } | ||
198 | } | 253 | } |
199 | 254 | ||
200 | struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) | 255 | struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) |
@@ -207,14 +262,11 @@ struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) | |||
207 | return data_append_data(d, &bere, sizeof(bere)); | 262 | return data_append_data(d, &bere, sizeof(bere)); |
208 | } | 263 | } |
209 | 264 | ||
210 | struct data data_append_cell(struct data d, cell_t word) | ||
211 | { | ||
212 | return data_append_integer(d, word, sizeof(word) * 8); | ||
213 | } | ||
214 | |||
215 | struct data data_append_addr(struct data d, uint64_t addr) | 265 | struct data data_append_addr(struct data d, uint64_t addr) |
216 | { | 266 | { |
217 | return data_append_integer(d, addr, sizeof(addr) * 8); | 267 | uint64_t beaddr = cpu_to_fdt64(addr); |
268 | |||
269 | return data_append_data(d, &beaddr, sizeof(beaddr)); | ||
218 | } | 270 | } |
219 | 271 | ||
220 | struct data data_append_byte(struct data d, uint8_t byte) | 272 | struct data data_append_byte(struct data d, uint8_t byte) |
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l index 254d5af8895..e866ea5166a 100644 --- a/scripts/dtc/dtc-lexer.l +++ b/scripts/dtc/dtc-lexer.l | |||
@@ -29,7 +29,6 @@ PROPNODECHAR [a-zA-Z0-9,._+*#?@-] | |||
29 | PATHCHAR ({PROPNODECHAR}|[/]) | 29 | PATHCHAR ({PROPNODECHAR}|[/]) |
30 | LABEL [a-zA-Z_][a-zA-Z0-9_]* | 30 | LABEL [a-zA-Z_][a-zA-Z0-9_]* |
31 | STRING \"([^\\"]|\\.)*\" | 31 | STRING \"([^\\"]|\\.)*\" |
32 | CHAR_LITERAL '([^']|\\')*' | ||
33 | WS [[:space:]] | 32 | WS [[:space:]] |
34 | COMMENT "/*"([^*]|\*+[^*/])*\*+"/" | 33 | COMMENT "/*"([^*]|\*+[^*/])*\*+"/" |
35 | LINECOMMENT "//".*\n | 34 | LINECOMMENT "//".*\n |
@@ -71,27 +70,6 @@ static int pop_input_file(void); | |||
71 | push_input_file(name); | 70 | push_input_file(name); |
72 | } | 71 | } |
73 | 72 | ||
74 | <*>^"#"(line)?{WS}+[0-9]+{WS}+{STRING}({WS}+[0-9]+)? { | ||
75 | char *line, *tmp, *fn; | ||
76 | /* skip text before line # */ | ||
77 | line = yytext; | ||
78 | while (!isdigit(*line)) | ||
79 | line++; | ||
80 | /* skip digits in line # */ | ||
81 | tmp = line; | ||
82 | while (!isspace(*tmp)) | ||
83 | tmp++; | ||
84 | /* "NULL"-terminate line # */ | ||
85 | *tmp = '\0'; | ||
86 | /* start of filename */ | ||
87 | fn = strchr(tmp + 1, '"') + 1; | ||
88 | /* strip trailing " from filename */ | ||
89 | tmp = strchr(fn, '"'); | ||
90 | *tmp = 0; | ||
91 | /* -1 since #line is the number of the next line */ | ||
92 | srcpos_set_line(xstrdup(fn), atoi(line) - 1); | ||
93 | } | ||
94 | |||
95 | <*><<EOF>> { | 73 | <*><<EOF>> { |
96 | if (!pop_input_file()) { | 74 | if (!pop_input_file()) { |
97 | yyterminate(); | 75 | yyterminate(); |
@@ -118,26 +96,6 @@ static int pop_input_file(void); | |||
118 | return DT_MEMRESERVE; | 96 | return DT_MEMRESERVE; |
119 | } | 97 | } |
120 | 98 | ||
121 | <*>"/bits/" { | ||
122 | DPRINT("Keyword: /bits/\n"); | ||
123 | BEGIN_DEFAULT(); | ||
124 | return DT_BITS; | ||
125 | } | ||
126 | |||
127 | <*>"/delete-property/" { | ||
128 | DPRINT("Keyword: /delete-property/\n"); | ||
129 | DPRINT("<PROPNODENAME>\n"); | ||
130 | BEGIN(PROPNODENAME); | ||
131 | return DT_DEL_PROP; | ||
132 | } | ||
133 | |||
134 | <*>"/delete-node/" { | ||
135 | DPRINT("Keyword: /delete-node/\n"); | ||
136 | DPRINT("<PROPNODENAME>\n"); | ||
137 | BEGIN(PROPNODENAME); | ||
138 | return DT_DEL_NODE; | ||
139 | } | ||
140 | |||
141 | <*>{LABEL}: { | 99 | <*>{LABEL}: { |
142 | DPRINT("Label: %s\n", yytext); | 100 | DPRINT("Label: %s\n", yytext); |
143 | yylval.labelref = xstrdup(yytext); | 101 | yylval.labelref = xstrdup(yytext); |
@@ -145,19 +103,12 @@ static int pop_input_file(void); | |||
145 | return DT_LABEL; | 103 | return DT_LABEL; |
146 | } | 104 | } |
147 | 105 | ||
148 | <V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? { | 106 | <V1>[0-9]+|0[xX][0-9a-fA-F]+ { |
149 | yylval.literal = xstrdup(yytext); | 107 | yylval.literal = xstrdup(yytext); |
150 | DPRINT("Literal: '%s'\n", yylval.literal); | 108 | DPRINT("Literal: '%s'\n", yylval.literal); |
151 | return DT_LITERAL; | 109 | return DT_LITERAL; |
152 | } | 110 | } |
153 | 111 | ||
154 | <*>{CHAR_LITERAL} { | ||
155 | yytext[yyleng-1] = '\0'; | ||
156 | yylval.literal = xstrdup(yytext+1); | ||
157 | DPRINT("Character literal: %s\n", yylval.literal); | ||
158 | return DT_CHAR_LITERAL; | ||
159 | } | ||
160 | |||
161 | <*>\&{LABEL} { /* label reference */ | 112 | <*>\&{LABEL} { /* label reference */ |
162 | DPRINT("Ref: %s\n", yytext+1); | 113 | DPRINT("Ref: %s\n", yytext+1); |
163 | yylval.labelref = xstrdup(yytext+1); | 114 | yylval.labelref = xstrdup(yytext+1); |
@@ -183,10 +134,9 @@ static int pop_input_file(void); | |||
183 | return ']'; | 134 | return ']'; |
184 | } | 135 | } |
185 | 136 | ||
186 | <PROPNODENAME>\\?{PROPNODECHAR}+ { | 137 | <PROPNODENAME>{PROPNODECHAR}+ { |
187 | DPRINT("PropNodeName: %s\n", yytext); | 138 | DPRINT("PropNodeName: %s\n", yytext); |
188 | yylval.propnodename = xstrdup((yytext[0] == '\\') ? | 139 | yylval.propnodename = xstrdup(yytext); |
189 | yytext + 1 : yytext); | ||
190 | BEGIN_DEFAULT(); | 140 | BEGIN_DEFAULT(); |
191 | return DT_PROPNODENAME; | 141 | return DT_PROPNODENAME; |
192 | } | 142 | } |
@@ -200,15 +150,6 @@ static int pop_input_file(void); | |||
200 | <*>{COMMENT}+ /* eat C-style comments */ | 150 | <*>{COMMENT}+ /* eat C-style comments */ |
201 | <*>{LINECOMMENT}+ /* eat C++-style comments */ | 151 | <*>{LINECOMMENT}+ /* eat C++-style comments */ |
202 | 152 | ||
203 | <*>"<<" { return DT_LSHIFT; }; | ||
204 | <*>">>" { return DT_RSHIFT; }; | ||
205 | <*>"<=" { return DT_LE; }; | ||
206 | <*>">=" { return DT_GE; }; | ||
207 | <*>"==" { return DT_EQ; }; | ||
208 | <*>"!=" { return DT_NE; }; | ||
209 | <*>"&&" { return DT_AND; }; | ||
210 | <*>"||" { return DT_OR; }; | ||
211 | |||
212 | <*>. { | 153 | <*>. { |
213 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], | 154 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], |
214 | (unsigned)yytext[0]); | 155 | (unsigned)yytext[0]); |
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped index a6c5fcdfc03..8bbe1281705 100644 --- a/scripts/dtc/dtc-lexer.lex.c_shipped +++ b/scripts/dtc/dtc-lexer.lex.c_shipped | |||
@@ -1,6 +1,5 @@ | |||
1 | #line 2 "dtc-lexer.lex.c" | ||
2 | 1 | ||
3 | #line 4 "dtc-lexer.lex.c" | 2 | #line 3 "scripts/dtc/dtc-lexer.lex.c_shipped" |
4 | 3 | ||
5 | #define YY_INT_ALIGNED short int | 4 | #define YY_INT_ALIGNED short int |
6 | 5 | ||
@@ -54,6 +53,7 @@ typedef int flex_int32_t; | |||
54 | typedef unsigned char flex_uint8_t; | 53 | typedef unsigned char flex_uint8_t; |
55 | typedef unsigned short int flex_uint16_t; | 54 | typedef unsigned short int flex_uint16_t; |
56 | typedef unsigned int flex_uint32_t; | 55 | typedef unsigned int flex_uint32_t; |
56 | #endif /* ! C99 */ | ||
57 | 57 | ||
58 | /* Limits of integral types. */ | 58 | /* Limits of integral types. */ |
59 | #ifndef INT8_MIN | 59 | #ifndef INT8_MIN |
@@ -84,8 +84,6 @@ typedef unsigned int flex_uint32_t; | |||
84 | #define UINT32_MAX (4294967295U) | 84 | #define UINT32_MAX (4294967295U) |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | #endif /* ! C99 */ | ||
88 | |||
89 | #endif /* ! FLEXINT_H */ | 87 | #endif /* ! FLEXINT_H */ |
90 | 88 | ||
91 | #ifdef __cplusplus | 89 | #ifdef __cplusplus |
@@ -142,15 +140,7 @@ typedef unsigned int flex_uint32_t; | |||
142 | 140 | ||
143 | /* Size of default input buffer. */ | 141 | /* Size of default input buffer. */ |
144 | #ifndef YY_BUF_SIZE | 142 | #ifndef YY_BUF_SIZE |
145 | #ifdef __ia64__ | ||
146 | /* On IA-64, the buffer size is 16k, not 8k. | ||
147 | * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. | ||
148 | * Ditto for the __ia64__ case accordingly. | ||
149 | */ | ||
150 | #define YY_BUF_SIZE 32768 | ||
151 | #else | ||
152 | #define YY_BUF_SIZE 16384 | 143 | #define YY_BUF_SIZE 16384 |
153 | #endif /* __ia64__ */ | ||
154 | #endif | 144 | #endif |
155 | 145 | ||
156 | /* The state buf must be large enough to hold one state per character in the main buffer. | 146 | /* The state buf must be large enough to hold one state per character in the main buffer. |
@@ -372,8 +362,8 @@ static void yy_fatal_error (yyconst char msg[] ); | |||
372 | *yy_cp = '\0'; \ | 362 | *yy_cp = '\0'; \ |
373 | (yy_c_buf_p) = yy_cp; | 363 | (yy_c_buf_p) = yy_cp; |
374 | 364 | ||
375 | #define YY_NUM_RULES 30 | 365 | #define YY_NUM_RULES 17 |
376 | #define YY_END_OF_BUFFER 31 | 366 | #define YY_END_OF_BUFFER 18 |
377 | /* This struct is not used in this scanner, | 367 | /* This struct is not used in this scanner, |
378 | but its presence is necessary. */ | 368 | but its presence is necessary. */ |
379 | struct yy_trans_info | 369 | struct yy_trans_info |
@@ -381,25 +371,19 @@ struct yy_trans_info | |||
381 | flex_int32_t yy_verify; | 371 | flex_int32_t yy_verify; |
382 | flex_int32_t yy_nxt; | 372 | flex_int32_t yy_nxt; |
383 | }; | 373 | }; |
384 | static yyconst flex_int16_t yy_accept[161] = | 374 | static yyconst flex_int16_t yy_accept[94] = |
385 | { 0, | 375 | { 0, |
386 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 376 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
387 | 31, 29, 18, 18, 29, 29, 29, 29, 29, 29, | 377 | 18, 16, 13, 13, 16, 16, 16, 16, 16, 16, |
388 | 29, 29, 29, 29, 29, 29, 29, 29, 15, 16, | 378 | 16, 10, 11, 11, 6, 6, 13, 0, 2, 0, |
389 | 16, 29, 16, 10, 10, 18, 26, 0, 3, 0, | 379 | 7, 0, 0, 0, 0, 0, 0, 0, 5, 0, |
390 | 27, 12, 0, 0, 11, 0, 0, 0, 0, 0, | 380 | 9, 9, 11, 11, 6, 0, 7, 0, 0, 0, |
391 | 0, 0, 21, 23, 25, 24, 22, 0, 9, 28, | 381 | 0, 15, 0, 0, 0, 0, 6, 0, 14, 0, |
392 | 0, 0, 0, 14, 14, 16, 16, 16, 10, 10, | 382 | 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, |
393 | 10, 0, 12, 0, 11, 0, 0, 0, 20, 0, | 383 | 0, 0, 0, 0, 0, 0, 0, 0, 3, 12, |
394 | 0, 0, 0, 0, 0, 0, 0, 16, 10, 10, | 384 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, |
395 | 10, 0, 19, 0, 0, 0, 0, 0, 0, 0, | 385 | 0, 4, 0 |
396 | 386 | ||
397 | 0, 0, 16, 13, 0, 0, 0, 0, 0, 0, | ||
398 | 0, 0, 0, 16, 6, 0, 0, 0, 0, 0, | ||
399 | 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, | ||
400 | 4, 17, 0, 0, 2, 0, 0, 0, 0, 0, | ||
401 | 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, | ||
402 | 0, 0, 5, 8, 0, 0, 0, 0, 7, 0 | ||
403 | } ; | 387 | } ; |
404 | 388 | ||
405 | static yyconst flex_int32_t yy_ec[256] = | 389 | static yyconst flex_int32_t yy_ec[256] = |
@@ -407,17 +391,17 @@ static yyconst flex_int32_t yy_ec[256] = | |||
407 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | 391 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, |
408 | 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, | 392 | 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, |
409 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 393 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
410 | 1, 2, 4, 5, 6, 1, 1, 7, 8, 1, | 394 | 1, 2, 1, 4, 5, 1, 1, 6, 1, 1, |
411 | 1, 9, 10, 10, 11, 10, 12, 13, 14, 15, | 395 | 1, 7, 5, 5, 8, 5, 9, 10, 11, 12, |
412 | 15, 15, 15, 15, 15, 15, 15, 16, 1, 17, | 396 | 12, 12, 12, 12, 12, 12, 12, 13, 1, 1, |
413 | 18, 19, 10, 10, 20, 20, 20, 20, 20, 20, | 397 | 1, 1, 5, 5, 14, 14, 14, 14, 14, 14, |
414 | 21, 21, 21, 21, 21, 22, 21, 21, 21, 21, | 398 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, |
415 | 21, 21, 21, 21, 23, 21, 21, 24, 21, 21, | 399 | 15, 15, 15, 15, 15, 15, 15, 16, 15, 15, |
416 | 1, 25, 26, 1, 21, 1, 20, 27, 28, 29, | 400 | 1, 17, 18, 1, 15, 1, 14, 19, 20, 21, |
417 | 401 | ||
418 | 30, 20, 21, 21, 31, 21, 21, 32, 33, 34, | 402 | 22, 14, 15, 15, 23, 15, 15, 24, 25, 26, |
419 | 35, 36, 21, 37, 38, 39, 40, 41, 21, 24, | 403 | 15, 15, 15, 27, 28, 29, 30, 31, 15, 16, |
420 | 42, 21, 43, 44, 45, 1, 1, 1, 1, 1, | 404 | 15, 15, 32, 1, 33, 1, 1, 1, 1, 1, |
421 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 405 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
422 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 406 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
423 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 407 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
@@ -434,163 +418,112 @@ static yyconst flex_int32_t yy_ec[256] = | |||
434 | 1, 1, 1, 1, 1 | 418 | 1, 1, 1, 1, 1 |
435 | } ; | 419 | } ; |
436 | 420 | ||
437 | static yyconst flex_int32_t yy_meta[46] = | 421 | static yyconst flex_int32_t yy_meta[34] = |
438 | { 0, | 422 | { 0, |
439 | 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, | 423 | 1, 1, 1, 1, 2, 1, 2, 2, 3, 4, |
440 | 2, 4, 5, 5, 5, 6, 1, 1, 1, 7, | 424 | 4, 4, 5, 6, 7, 7, 1, 1, 6, 6, |
441 | 8, 8, 8, 8, 1, 1, 7, 7, 7, 7, | 425 | 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, |
442 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, | 426 | 7, 8, 1 |
443 | 8, 8, 3, 1, 1 | ||
444 | } ; | 427 | } ; |
445 | 428 | ||
446 | static yyconst flex_int16_t yy_base[175] = | 429 | static yyconst flex_int16_t yy_base[106] = |
447 | { 0, | 430 | { 0, |
448 | 0, 388, 381, 40, 41, 386, 71, 385, 34, 44, | 431 | 0, 0, 237, 236, 25, 0, 47, 0, 30, 71, |
449 | 390, 395, 60, 62, 371, 112, 111, 111, 111, 104, | 432 | 244, 247, 82, 84, 84, 211, 95, 229, 218, 0, |
450 | 370, 106, 371, 342, 124, 119, 0, 144, 395, 0, | 433 | 111, 247, 0, 84, 83, 95, 106, 86, 247, 237, |
451 | 123, 0, 159, 153, 165, 167, 395, 130, 395, 382, | 434 | 0, 230, 231, 234, 207, 209, 212, 220, 247, 206, |
452 | 395, 0, 372, 122, 395, 157, 374, 379, 350, 21, | 435 | 247, 218, 0, 106, 116, 0, 0, 0, 223, 89, |
453 | 346, 349, 395, 395, 395, 395, 395, 362, 395, 395, | 436 | 226, 219, 199, 206, 200, 204, 0, 190, 213, 212, |
454 | 181, 346, 342, 395, 359, 0, 191, 343, 190, 351, | 437 | 202, 91, 178, 161, 247, 172, 144, 150, 140, 130, |
455 | 350, 0, 0, 0, 173, 362, 177, 367, 357, 329, | 438 | 140, 124, 128, 120, 138, 137, 123, 122, 247, 247, |
456 | 335, 328, 337, 331, 206, 329, 334, 327, 395, 338, | 439 | 134, 114, 132, 86, 135, 125, 90, 136, 247, 97, |
457 | 170, 314, 346, 345, 318, 325, 343, 158, 316, 212, | 440 | 29, 247, 247, 153, 156, 161, 165, 170, 176, 180, |
458 | 441 | ||
459 | 322, 319, 320, 395, 340, 336, 308, 305, 314, 304, | 442 | 187, 195, 200, 205, 212 |
460 | 295, 138, 208, 220, 395, 292, 305, 265, 264, 254, | ||
461 | 201, 222, 285, 275, 273, 270, 236, 235, 225, 115, | ||
462 | 395, 395, 252, 216, 216, 217, 214, 230, 209, 220, | ||
463 | 213, 239, 211, 217, 216, 209, 229, 395, 240, 225, | ||
464 | 206, 169, 395, 395, 116, 106, 99, 54, 395, 395, | ||
465 | 254, 260, 268, 272, 276, 282, 289, 293, 301, 309, | ||
466 | 313, 319, 327, 335 | ||
467 | } ; | 443 | } ; |
468 | 444 | ||
469 | static yyconst flex_int16_t yy_def[175] = | 445 | static yyconst flex_int16_t yy_def[106] = |
470 | { 0, | 446 | { 0, |
471 | 160, 1, 1, 1, 1, 5, 160, 7, 1, 1, | 447 | 93, 1, 1, 1, 1, 5, 93, 7, 1, 1, |
472 | 160, 160, 160, 160, 160, 161, 162, 163, 160, 160, | 448 | 93, 93, 93, 93, 94, 95, 93, 96, 17, 97, |
473 | 160, 160, 164, 160, 160, 160, 165, 164, 160, 166, | 449 | 96, 93, 98, 99, 93, 93, 93, 94, 93, 94, |
474 | 167, 166, 166, 160, 160, 160, 160, 161, 160, 161, | 450 | 100, 93, 101, 102, 93, 93, 93, 96, 93, 93, |
475 | 160, 168, 160, 163, 160, 163, 169, 170, 160, 160, | 451 | 93, 96, 98, 99, 93, 103, 100, 104, 101, 101, |
476 | 160, 160, 160, 160, 160, 160, 160, 164, 160, 160, | 452 | 102, 93, 93, 93, 93, 93, 103, 104, 93, 93, |
477 | 160, 160, 160, 160, 164, 166, 167, 166, 160, 160, | 453 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, |
478 | 160, 171, 168, 172, 163, 169, 169, 170, 160, 160, | 454 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, |
479 | 160, 160, 160, 160, 160, 160, 160, 166, 160, 160, | 455 | 93, 93, 93, 93, 93, 105, 93, 105, 93, 105, |
480 | 171, 172, 160, 160, 160, 160, 160, 160, 160, 160, | 456 | 93, 93, 0, 93, 93, 93, 93, 93, 93, 93, |
481 | 457 | ||
482 | 160, 160, 166, 160, 160, 160, 160, 160, 160, 160, | 458 | 93, 93, 93, 93, 93 |
483 | 160, 173, 160, 166, 160, 160, 160, 160, 160, 160, | ||
484 | 173, 160, 173, 160, 160, 160, 160, 160, 160, 160, | ||
485 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
486 | 160, 160, 174, 160, 160, 160, 174, 160, 174, 160, | ||
487 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 0, | ||
488 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
489 | 160, 160, 160, 160 | ||
490 | } ; | 459 | } ; |
491 | 460 | ||
492 | static yyconst flex_int16_t yy_nxt[441] = | 461 | static yyconst flex_int16_t yy_nxt[281] = |
493 | { 0, | 462 | { 0, |
494 | 12, 13, 14, 15, 16, 12, 17, 18, 12, 12, | 463 | 12, 13, 14, 15, 12, 16, 12, 12, 17, 12, |
495 | 12, 19, 12, 12, 12, 12, 20, 21, 22, 23, | 464 | 12, 12, 12, 18, 18, 18, 12, 12, 18, 18, |
496 | 23, 23, 23, 23, 12, 12, 23, 23, 23, 23, | 465 | 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, |
497 | 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, | 466 | 18, 12, 12, 19, 20, 20, 20, 92, 21, 25, |
498 | 23, 23, 12, 24, 12, 25, 34, 35, 35, 25, | 467 | 26, 26, 22, 21, 21, 21, 21, 12, 13, 14, |
499 | 81, 26, 26, 27, 27, 27, 34, 35, 35, 82, | 468 | 15, 23, 16, 23, 23, 19, 23, 23, 23, 12, |
500 | 28, 36, 36, 36, 36, 159, 29, 28, 28, 28, | 469 | 24, 24, 24, 12, 12, 24, 24, 24, 24, 24, |
501 | 28, 12, 13, 14, 15, 16, 30, 17, 18, 30, | 470 | 24, 24, 24, 24, 24, 24, 24, 24, 12, 12, |
502 | 30, 30, 26, 30, 30, 30, 12, 20, 21, 22, | 471 | 25, 26, 26, 27, 27, 27, 27, 29, 43, 29, |
503 | 31, 31, 31, 31, 31, 32, 12, 31, 31, 31, | 472 | 43, 43, 45, 45, 45, 50, 39, 59, 46, 93, |
504 | 473 | ||
505 | 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, | 474 | 30, 33, 30, 34, 45, 45, 45, 27, 27, 68, |
506 | 31, 31, 31, 12, 24, 12, 39, 41, 45, 47, | 475 | 43, 91, 43, 43, 69, 35, 87, 36, 39, 37, |
507 | 53, 54, 48, 56, 57, 61, 61, 47, 66, 45, | 476 | 42, 42, 42, 39, 42, 45, 45, 45, 89, 42, |
508 | 48, 66, 66, 66, 39, 46, 40, 49, 59, 50, | 477 | 42, 42, 42, 85, 85, 86, 85, 85, 86, 89, |
509 | 158, 51, 122, 52, 157, 49, 46, 50, 136, 63, | 478 | 84, 90, 83, 82, 81, 80, 79, 78, 77, 76, |
510 | 137, 52, 156, 43, 40, 62, 65, 65, 65, 59, | 479 | 75, 74, 90, 28, 28, 28, 28, 28, 28, 28, |
511 | 61, 61, 123, 65, 75, 69, 69, 69, 36, 36, | 480 | 28, 31, 31, 31, 38, 38, 38, 38, 41, 73, |
512 | 65, 65, 65, 65, 70, 71, 72, 69, 69, 69, | 481 | 41, 43, 72, 43, 71, 43, 43, 44, 33, 44, |
513 | 45, 46, 61, 61, 109, 77, 70, 71, 93, 110, | 482 | 44, 44, 44, 47, 69, 47, 47, 49, 49, 49, |
514 | 68, 70, 71, 85, 85, 85, 66, 46, 155, 66, | 483 | 49, 49, 49, 49, 49, 51, 51, 51, 51, 51, |
515 | 484 | ||
516 | 66, 66, 69, 69, 69, 122, 59, 100, 100, 61, | 485 | 51, 51, 51, 57, 70, 57, 58, 58, 58, 67, |
517 | 61, 70, 71, 100, 100, 148, 112, 154, 85, 85, | 486 | 58, 58, 88, 88, 88, 88, 88, 88, 88, 88, |
518 | 85, 61, 61, 129, 129, 123, 129, 129, 135, 135, | 487 | 34, 66, 65, 64, 63, 62, 61, 60, 52, 50, |
519 | 135, 142, 142, 148, 143, 149, 153, 135, 135, 135, | 488 | 39, 56, 39, 55, 54, 53, 52, 50, 48, 93, |
520 | 142, 142, 160, 143, 152, 151, 150, 146, 145, 144, | 489 | 40, 39, 32, 93, 19, 19, 11, 93, 93, 93, |
521 | 141, 140, 139, 149, 38, 38, 38, 38, 38, 38, | 490 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, |
522 | 38, 38, 42, 138, 134, 133, 42, 42, 44, 44, | 491 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, |
523 | 44, 44, 44, 44, 44, 44, 58, 58, 58, 58, | 492 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93 |
524 | 64, 132, 64, 66, 131, 130, 66, 160, 66, 66, | ||
525 | 67, 128, 127, 67, 67, 67, 67, 73, 126, 73, | ||
526 | |||
527 | 73, 76, 76, 76, 76, 76, 76, 76, 76, 78, | ||
528 | 78, 78, 78, 78, 78, 78, 78, 91, 125, 91, | ||
529 | 92, 124, 92, 92, 120, 92, 92, 121, 121, 121, | ||
530 | 121, 121, 121, 121, 121, 147, 147, 147, 147, 147, | ||
531 | 147, 147, 147, 119, 118, 117, 116, 115, 47, 114, | ||
532 | 110, 113, 111, 108, 107, 106, 48, 105, 104, 89, | ||
533 | 103, 102, 101, 99, 98, 97, 96, 95, 94, 79, | ||
534 | 77, 90, 89, 88, 59, 87, 86, 59, 84, 83, | ||
535 | 80, 79, 77, 74, 160, 60, 59, 55, 37, 160, | ||
536 | 33, 25, 26, 25, 11, 160, 160, 160, 160, 160, | ||
537 | |||
538 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
539 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
540 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
541 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 | ||
542 | } ; | 493 | } ; |
543 | 494 | ||
544 | static yyconst flex_int16_t yy_chk[441] = | 495 | static yyconst flex_int16_t yy_chk[281] = |
545 | { 0, | 496 | { 0, |
546 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 497 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
547 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 498 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
548 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 499 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
549 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 500 | 1, 1, 1, 5, 5, 5, 5, 91, 5, 9, |
550 | 1, 1, 1, 1, 1, 4, 9, 9, 9, 10, | 501 | 9, 9, 5, 5, 5, 5, 5, 7, 7, 7, |
551 | 50, 4, 5, 5, 5, 5, 10, 10, 10, 50, | ||
552 | 5, 13, 13, 14, 14, 158, 5, 5, 5, 5, | ||
553 | 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, | ||
554 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | 502 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
555 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | 503 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
556 | |||
557 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | 504 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
558 | 7, 7, 7, 7, 7, 7, 16, 17, 18, 19, | 505 | 10, 10, 10, 13, 13, 14, 14, 15, 24, 28, |
559 | 20, 20, 19, 22, 22, 25, 25, 26, 31, 44, | 506 | 24, 24, 25, 25, 25, 50, 24, 50, 25, 90, |
560 | 26, 31, 31, 31, 38, 18, 16, 19, 31, 19, | 507 | |
561 | 157, 19, 112, 19, 156, 26, 44, 26, 130, 26, | 508 | 15, 17, 28, 17, 26, 26, 26, 27, 27, 62, |
562 | 130, 26, 155, 17, 38, 25, 28, 28, 28, 28, | 509 | 44, 87, 44, 44, 62, 17, 84, 17, 44, 17, |
563 | 33, 33, 112, 28, 46, 34, 34, 34, 36, 36, | 510 | 21, 21, 21, 21, 21, 45, 45, 45, 86, 21, |
564 | 28, 28, 28, 28, 34, 34, 34, 35, 35, 35, | 511 | 21, 21, 21, 83, 83, 83, 85, 85, 85, 88, |
565 | 75, 46, 61, 61, 98, 77, 35, 35, 77, 98, | 512 | 82, 86, 81, 78, 77, 76, 75, 74, 73, 72, |
566 | 33, 91, 91, 61, 61, 61, 67, 75, 152, 67, | 513 | 71, 70, 88, 94, 94, 94, 94, 94, 94, 94, |
567 | 514 | 94, 95, 95, 95, 96, 96, 96, 96, 97, 69, | |
568 | 67, 67, 69, 69, 69, 121, 67, 85, 85, 113, | 515 | 97, 98, 68, 98, 67, 98, 98, 99, 66, 99, |
569 | 113, 69, 69, 100, 100, 143, 100, 151, 85, 85, | 516 | 99, 99, 99, 100, 64, 100, 100, 101, 101, 101, |
570 | 85, 114, 114, 122, 122, 121, 129, 129, 135, 135, | 517 | 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, |
571 | 135, 138, 138, 147, 138, 143, 150, 129, 129, 129, | 518 | |
572 | 142, 142, 149, 142, 146, 145, 144, 141, 140, 139, | 519 | 102, 102, 102, 103, 63, 103, 104, 104, 104, 61, |
573 | 137, 136, 134, 147, 161, 161, 161, 161, 161, 161, | 520 | 104, 104, 105, 105, 105, 105, 105, 105, 105, 105, |
574 | 161, 161, 162, 133, 128, 127, 162, 162, 163, 163, | 521 | 60, 59, 58, 56, 55, 54, 53, 52, 51, 49, |
575 | 163, 163, 163, 163, 163, 163, 164, 164, 164, 164, | 522 | 42, 40, 38, 37, 36, 35, 34, 33, 32, 30, |
576 | 165, 126, 165, 166, 125, 124, 166, 123, 166, 166, | 523 | 19, 18, 16, 11, 4, 3, 93, 93, 93, 93, |
577 | 167, 120, 119, 167, 167, 167, 167, 168, 118, 168, | 524 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, |
578 | 525 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, | |
579 | 168, 169, 169, 169, 169, 169, 169, 169, 169, 170, | 526 | 93, 93, 93, 93, 93, 93, 93, 93, 93, 93 |
580 | 170, 170, 170, 170, 170, 170, 170, 171, 117, 171, | ||
581 | 172, 116, 172, 172, 111, 172, 172, 173, 173, 173, | ||
582 | 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, | ||
583 | 174, 174, 174, 110, 109, 108, 107, 106, 105, 103, | ||
584 | 102, 101, 99, 97, 96, 95, 94, 93, 92, 90, | ||
585 | 88, 87, 86, 84, 83, 82, 81, 80, 79, 78, | ||
586 | 76, 71, 70, 68, 65, 63, 62, 58, 52, 51, | ||
587 | 49, 48, 47, 43, 40, 24, 23, 21, 15, 11, | ||
588 | 8, 6, 3, 2, 160, 160, 160, 160, 160, 160, | ||
589 | |||
590 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
591 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
592 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, | ||
593 | 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 | ||
594 | } ; | 527 | } ; |
595 | 528 | ||
596 | static yy_state_type yy_last_accepting_state; | 529 | static yy_state_type yy_last_accepting_state; |
@@ -607,7 +540,6 @@ int yy_flex_debug = 0; | |||
607 | #define YY_MORE_ADJ 0 | 540 | #define YY_MORE_ADJ 0 |
608 | #define YY_RESTORE_YY_MORE_OFFSET | 541 | #define YY_RESTORE_YY_MORE_OFFSET |
609 | char *yytext; | 542 | char *yytext; |
610 | #line 1 "dtc-lexer.l" | ||
611 | /* | 543 | /* |
612 | * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. | 544 | * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. |
613 | * | 545 | * |
@@ -629,10 +561,6 @@ char *yytext; | |||
629 | */ | 561 | */ |
630 | #define YY_NO_INPUT 1 | 562 | #define YY_NO_INPUT 1 |
631 | 563 | ||
632 | |||
633 | |||
634 | |||
635 | #line 38 "dtc-lexer.l" | ||
636 | #include "dtc.h" | 564 | #include "dtc.h" |
637 | #include "srcpos.h" | 565 | #include "srcpos.h" |
638 | #include "dtc-parser.tab.h" | 566 | #include "dtc-parser.tab.h" |
@@ -660,7 +588,6 @@ static int dts_version = 1; | |||
660 | 588 | ||
661 | static void push_input_file(const char *filename); | 589 | static void push_input_file(const char *filename); |
662 | static int pop_input_file(void); | 590 | static int pop_input_file(void); |
663 | #line 664 "dtc-lexer.lex.c" | ||
664 | 591 | ||
665 | #define INITIAL 0 | 592 | #define INITIAL 0 |
666 | #define INCLUDE 1 | 593 | #define INCLUDE 1 |
@@ -743,12 +670,7 @@ static int input (void ); | |||
743 | 670 | ||
744 | /* Amount of stuff to slurp up with each read. */ | 671 | /* Amount of stuff to slurp up with each read. */ |
745 | #ifndef YY_READ_BUF_SIZE | 672 | #ifndef YY_READ_BUF_SIZE |
746 | #ifdef __ia64__ | ||
747 | /* On IA-64, the buffer size is 16k, not 8k */ | ||
748 | #define YY_READ_BUF_SIZE 16384 | ||
749 | #else | ||
750 | #define YY_READ_BUF_SIZE 8192 | 673 | #define YY_READ_BUF_SIZE 8192 |
751 | #endif /* __ia64__ */ | ||
752 | #endif | 674 | #endif |
753 | 675 | ||
754 | /* Copy whatever the last rule matched to the standard output. */ | 676 | /* Copy whatever the last rule matched to the standard output. */ |
@@ -767,7 +689,7 @@ static int input (void ); | |||
767 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ | 689 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ |
768 | { \ | 690 | { \ |
769 | int c = '*'; \ | 691 | int c = '*'; \ |
770 | size_t n; \ | 692 | unsigned n; \ |
771 | for ( n = 0; n < max_size && \ | 693 | for ( n = 0; n < max_size && \ |
772 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ | 694 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ |
773 | buf[n] = (char) c; \ | 695 | buf[n] = (char) c; \ |
@@ -839,9 +761,6 @@ extern int yylex (void); | |||
839 | #endif | 761 | #endif |
840 | 762 | ||
841 | #define YY_RULE_SETUP \ | 763 | #define YY_RULE_SETUP \ |
842 | if ( yyleng > 0 ) \ | ||
843 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ | ||
844 | (yytext[yyleng - 1] == '\n'); \ | ||
845 | YY_USER_ACTION | 764 | YY_USER_ACTION |
846 | 765 | ||
847 | /** The main scanner function which does all the work. | 766 | /** The main scanner function which does all the work. |
@@ -852,10 +771,6 @@ YY_DECL | |||
852 | register char *yy_cp, *yy_bp; | 771 | register char *yy_cp, *yy_bp; |
853 | register int yy_act; | 772 | register int yy_act; |
854 | 773 | ||
855 | #line 67 "dtc-lexer.l" | ||
856 | |||
857 | #line 858 "dtc-lexer.lex.c" | ||
858 | |||
859 | if ( !(yy_init) ) | 774 | if ( !(yy_init) ) |
860 | { | 775 | { |
861 | (yy_init) = 1; | 776 | (yy_init) = 1; |
@@ -895,7 +810,6 @@ YY_DECL | |||
895 | yy_bp = yy_cp; | 810 | yy_bp = yy_cp; |
896 | 811 | ||
897 | yy_current_state = (yy_start); | 812 | yy_current_state = (yy_start); |
898 | yy_current_state += YY_AT_BOL(); | ||
899 | yy_match: | 813 | yy_match: |
900 | do | 814 | do |
901 | { | 815 | { |
@@ -908,13 +822,13 @@ yy_match: | |||
908 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | 822 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
909 | { | 823 | { |
910 | yy_current_state = (int) yy_def[yy_current_state]; | 824 | yy_current_state = (int) yy_def[yy_current_state]; |
911 | if ( yy_current_state >= 161 ) | 825 | if ( yy_current_state >= 94 ) |
912 | yy_c = yy_meta[(unsigned int) yy_c]; | 826 | yy_c = yy_meta[(unsigned int) yy_c]; |
913 | } | 827 | } |
914 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | 828 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; |
915 | ++yy_cp; | 829 | ++yy_cp; |
916 | } | 830 | } |
917 | while ( yy_current_state != 160 ); | 831 | while ( yy_current_state != 93 ); |
918 | yy_cp = (yy_last_accepting_cpos); | 832 | yy_cp = (yy_last_accepting_cpos); |
919 | yy_current_state = (yy_last_accepting_state); | 833 | yy_current_state = (yy_last_accepting_state); |
920 | 834 | ||
@@ -937,54 +851,26 @@ do_action: /* This label is used only to access EOF actions. */ | |||
937 | case 1: | 851 | case 1: |
938 | /* rule 1 can match eol */ | 852 | /* rule 1 can match eol */ |
939 | YY_RULE_SETUP | 853 | YY_RULE_SETUP |
940 | #line 68 "dtc-lexer.l" | ||
941 | { | 854 | { |
942 | char *name = strchr(yytext, '\"') + 1; | 855 | char *name = strchr(yytext, '\"') + 1; |
943 | yytext[yyleng-1] = '\0'; | 856 | yytext[yyleng-1] = '\0'; |
944 | push_input_file(name); | 857 | push_input_file(name); |
945 | } | 858 | } |
946 | YY_BREAK | 859 | YY_BREAK |
947 | case 2: | ||
948 | /* rule 2 can match eol */ | ||
949 | YY_RULE_SETUP | ||
950 | #line 74 "dtc-lexer.l" | ||
951 | { | ||
952 | char *line, *tmp, *fn; | ||
953 | /* skip text before line # */ | ||
954 | line = yytext; | ||
955 | while (!isdigit(*line)) | ||
956 | line++; | ||
957 | /* skip digits in line # */ | ||
958 | tmp = line; | ||
959 | while (!isspace(*tmp)) | ||
960 | tmp++; | ||
961 | /* "NULL"-terminate line # */ | ||
962 | *tmp = '\0'; | ||
963 | /* start of filename */ | ||
964 | fn = strchr(tmp + 1, '"') + 1; | ||
965 | /* strip trailing " from filename */ | ||
966 | tmp = strchr(fn, '"'); | ||
967 | *tmp = 0; | ||
968 | /* -1 since #line is the number of the next line */ | ||
969 | srcpos_set_line(xstrdup(fn), atoi(line) - 1); | ||
970 | } | ||
971 | YY_BREAK | ||
972 | case YY_STATE_EOF(INITIAL): | 860 | case YY_STATE_EOF(INITIAL): |
973 | case YY_STATE_EOF(INCLUDE): | 861 | case YY_STATE_EOF(INCLUDE): |
974 | case YY_STATE_EOF(BYTESTRING): | 862 | case YY_STATE_EOF(BYTESTRING): |
975 | case YY_STATE_EOF(PROPNODENAME): | 863 | case YY_STATE_EOF(PROPNODENAME): |
976 | case YY_STATE_EOF(V1): | 864 | case YY_STATE_EOF(V1): |
977 | #line 95 "dtc-lexer.l" | ||
978 | { | 865 | { |
979 | if (!pop_input_file()) { | 866 | if (!pop_input_file()) { |
980 | yyterminate(); | 867 | yyterminate(); |
981 | } | 868 | } |
982 | } | 869 | } |
983 | YY_BREAK | 870 | YY_BREAK |
984 | case 3: | 871 | case 2: |
985 | /* rule 3 can match eol */ | 872 | /* rule 2 can match eol */ |
986 | YY_RULE_SETUP | 873 | YY_RULE_SETUP |
987 | #line 101 "dtc-lexer.l" | ||
988 | { | 874 | { |
989 | DPRINT("String: %s\n", yytext); | 875 | DPRINT("String: %s\n", yytext); |
990 | yylval.data = data_copy_escape_string(yytext+1, | 876 | yylval.data = data_copy_escape_string(yytext+1, |
@@ -992,9 +878,8 @@ YY_RULE_SETUP | |||
992 | return DT_STRING; | 878 | return DT_STRING; |
993 | } | 879 | } |
994 | YY_BREAK | 880 | YY_BREAK |
995 | case 4: | 881 | case 3: |
996 | YY_RULE_SETUP | 882 | YY_RULE_SETUP |
997 | #line 108 "dtc-lexer.l" | ||
998 | { | 883 | { |
999 | DPRINT("Keyword: /dts-v1/\n"); | 884 | DPRINT("Keyword: /dts-v1/\n"); |
1000 | dts_version = 1; | 885 | dts_version = 1; |
@@ -1002,47 +887,16 @@ YY_RULE_SETUP | |||
1002 | return DT_V1; | 887 | return DT_V1; |
1003 | } | 888 | } |
1004 | YY_BREAK | 889 | YY_BREAK |
1005 | case 5: | 890 | case 4: |
1006 | YY_RULE_SETUP | 891 | YY_RULE_SETUP |
1007 | #line 115 "dtc-lexer.l" | ||
1008 | { | 892 | { |
1009 | DPRINT("Keyword: /memreserve/\n"); | 893 | DPRINT("Keyword: /memreserve/\n"); |
1010 | BEGIN_DEFAULT(); | 894 | BEGIN_DEFAULT(); |
1011 | return DT_MEMRESERVE; | 895 | return DT_MEMRESERVE; |
1012 | } | 896 | } |
1013 | YY_BREAK | 897 | YY_BREAK |
1014 | case 6: | 898 | case 5: |
1015 | YY_RULE_SETUP | ||
1016 | #line 121 "dtc-lexer.l" | ||
1017 | { | ||
1018 | DPRINT("Keyword: /bits/\n"); | ||
1019 | BEGIN_DEFAULT(); | ||
1020 | return DT_BITS; | ||
1021 | } | ||
1022 | YY_BREAK | ||
1023 | case 7: | ||
1024 | YY_RULE_SETUP | ||
1025 | #line 127 "dtc-lexer.l" | ||
1026 | { | ||
1027 | DPRINT("Keyword: /delete-property/\n"); | ||
1028 | DPRINT("<PROPNODENAME>\n"); | ||
1029 | BEGIN(PROPNODENAME); | ||
1030 | return DT_DEL_PROP; | ||
1031 | } | ||
1032 | YY_BREAK | ||
1033 | case 8: | ||
1034 | YY_RULE_SETUP | ||
1035 | #line 134 "dtc-lexer.l" | ||
1036 | { | ||
1037 | DPRINT("Keyword: /delete-node/\n"); | ||
1038 | DPRINT("<PROPNODENAME>\n"); | ||
1039 | BEGIN(PROPNODENAME); | ||
1040 | return DT_DEL_NODE; | ||
1041 | } | ||
1042 | YY_BREAK | ||
1043 | case 9: | ||
1044 | YY_RULE_SETUP | 899 | YY_RULE_SETUP |
1045 | #line 141 "dtc-lexer.l" | ||
1046 | { | 900 | { |
1047 | DPRINT("Label: %s\n", yytext); | 901 | DPRINT("Label: %s\n", yytext); |
1048 | yylval.labelref = xstrdup(yytext); | 902 | yylval.labelref = xstrdup(yytext); |
@@ -1050,38 +904,24 @@ YY_RULE_SETUP | |||
1050 | return DT_LABEL; | 904 | return DT_LABEL; |
1051 | } | 905 | } |
1052 | YY_BREAK | 906 | YY_BREAK |
1053 | case 10: | 907 | case 6: |
1054 | YY_RULE_SETUP | 908 | YY_RULE_SETUP |
1055 | #line 148 "dtc-lexer.l" | ||
1056 | { | 909 | { |
1057 | yylval.literal = xstrdup(yytext); | 910 | yylval.literal = xstrdup(yytext); |
1058 | DPRINT("Literal: '%s'\n", yylval.literal); | 911 | DPRINT("Literal: '%s'\n", yylval.literal); |
1059 | return DT_LITERAL; | 912 | return DT_LITERAL; |
1060 | } | 913 | } |
1061 | YY_BREAK | 914 | YY_BREAK |
1062 | case 11: | 915 | case 7: |
1063 | /* rule 11 can match eol */ | ||
1064 | YY_RULE_SETUP | ||
1065 | #line 154 "dtc-lexer.l" | ||
1066 | { | ||
1067 | yytext[yyleng-1] = '\0'; | ||
1068 | yylval.literal = xstrdup(yytext+1); | ||
1069 | DPRINT("Character literal: %s\n", yylval.literal); | ||
1070 | return DT_CHAR_LITERAL; | ||
1071 | } | ||
1072 | YY_BREAK | ||
1073 | case 12: | ||
1074 | YY_RULE_SETUP | 916 | YY_RULE_SETUP |
1075 | #line 161 "dtc-lexer.l" | ||
1076 | { /* label reference */ | 917 | { /* label reference */ |
1077 | DPRINT("Ref: %s\n", yytext+1); | 918 | DPRINT("Ref: %s\n", yytext+1); |
1078 | yylval.labelref = xstrdup(yytext+1); | 919 | yylval.labelref = xstrdup(yytext+1); |
1079 | return DT_REF; | 920 | return DT_REF; |
1080 | } | 921 | } |
1081 | YY_BREAK | 922 | YY_BREAK |
1082 | case 13: | 923 | case 8: |
1083 | YY_RULE_SETUP | 924 | YY_RULE_SETUP |
1084 | #line 167 "dtc-lexer.l" | ||
1085 | { /* new-style path reference */ | 925 | { /* new-style path reference */ |
1086 | yytext[yyleng-1] = '\0'; | 926 | yytext[yyleng-1] = '\0'; |
1087 | DPRINT("Ref: %s\n", yytext+2); | 927 | DPRINT("Ref: %s\n", yytext+2); |
@@ -1089,104 +929,55 @@ YY_RULE_SETUP | |||
1089 | return DT_REF; | 929 | return DT_REF; |
1090 | } | 930 | } |
1091 | YY_BREAK | 931 | YY_BREAK |
1092 | case 14: | 932 | case 9: |
1093 | YY_RULE_SETUP | 933 | YY_RULE_SETUP |
1094 | #line 174 "dtc-lexer.l" | ||
1095 | { | 934 | { |
1096 | yylval.byte = strtol(yytext, NULL, 16); | 935 | yylval.byte = strtol(yytext, NULL, 16); |
1097 | DPRINT("Byte: %02x\n", (int)yylval.byte); | 936 | DPRINT("Byte: %02x\n", (int)yylval.byte); |
1098 | return DT_BYTE; | 937 | return DT_BYTE; |
1099 | } | 938 | } |
1100 | YY_BREAK | 939 | YY_BREAK |
1101 | case 15: | 940 | case 10: |
1102 | YY_RULE_SETUP | 941 | YY_RULE_SETUP |
1103 | #line 180 "dtc-lexer.l" | ||
1104 | { | 942 | { |
1105 | DPRINT("/BYTESTRING\n"); | 943 | DPRINT("/BYTESTRING\n"); |
1106 | BEGIN_DEFAULT(); | 944 | BEGIN_DEFAULT(); |
1107 | return ']'; | 945 | return ']'; |
1108 | } | 946 | } |
1109 | YY_BREAK | 947 | YY_BREAK |
1110 | case 16: | 948 | case 11: |
1111 | YY_RULE_SETUP | 949 | YY_RULE_SETUP |
1112 | #line 186 "dtc-lexer.l" | ||
1113 | { | 950 | { |
1114 | DPRINT("PropNodeName: %s\n", yytext); | 951 | DPRINT("PropNodeName: %s\n", yytext); |
1115 | yylval.propnodename = xstrdup((yytext[0] == '\\') ? | 952 | yylval.propnodename = xstrdup(yytext); |
1116 | yytext + 1 : yytext); | ||
1117 | BEGIN_DEFAULT(); | 953 | BEGIN_DEFAULT(); |
1118 | return DT_PROPNODENAME; | 954 | return DT_PROPNODENAME; |
1119 | } | 955 | } |
1120 | YY_BREAK | 956 | YY_BREAK |
1121 | case 17: | 957 | case 12: |
1122 | YY_RULE_SETUP | 958 | YY_RULE_SETUP |
1123 | #line 194 "dtc-lexer.l" | ||
1124 | { | 959 | { |
1125 | DPRINT("Binary Include\n"); | 960 | DPRINT("Binary Include\n"); |
1126 | return DT_INCBIN; | 961 | return DT_INCBIN; |
1127 | } | 962 | } |
1128 | YY_BREAK | 963 | YY_BREAK |
1129 | case 18: | 964 | case 13: |
1130 | /* rule 18 can match eol */ | 965 | /* rule 13 can match eol */ |
1131 | YY_RULE_SETUP | 966 | YY_RULE_SETUP |
1132 | #line 199 "dtc-lexer.l" | ||
1133 | /* eat whitespace */ | 967 | /* eat whitespace */ |
1134 | YY_BREAK | 968 | YY_BREAK |
1135 | case 19: | 969 | case 14: |
1136 | /* rule 19 can match eol */ | 970 | /* rule 14 can match eol */ |
1137 | YY_RULE_SETUP | 971 | YY_RULE_SETUP |
1138 | #line 200 "dtc-lexer.l" | ||
1139 | /* eat C-style comments */ | 972 | /* eat C-style comments */ |
1140 | YY_BREAK | 973 | YY_BREAK |
1141 | case 20: | 974 | case 15: |
1142 | /* rule 20 can match eol */ | 975 | /* rule 15 can match eol */ |
1143 | YY_RULE_SETUP | 976 | YY_RULE_SETUP |
1144 | #line 201 "dtc-lexer.l" | ||
1145 | /* eat C++-style comments */ | 977 | /* eat C++-style comments */ |
1146 | YY_BREAK | 978 | YY_BREAK |
1147 | case 21: | 979 | case 16: |
1148 | YY_RULE_SETUP | ||
1149 | #line 203 "dtc-lexer.l" | ||
1150 | { return DT_LSHIFT; }; | ||
1151 | YY_BREAK | ||
1152 | case 22: | ||
1153 | YY_RULE_SETUP | ||
1154 | #line 204 "dtc-lexer.l" | ||
1155 | { return DT_RSHIFT; }; | ||
1156 | YY_BREAK | ||
1157 | case 23: | ||
1158 | YY_RULE_SETUP | ||
1159 | #line 205 "dtc-lexer.l" | ||
1160 | { return DT_LE; }; | ||
1161 | YY_BREAK | ||
1162 | case 24: | ||
1163 | YY_RULE_SETUP | ||
1164 | #line 206 "dtc-lexer.l" | ||
1165 | { return DT_GE; }; | ||
1166 | YY_BREAK | ||
1167 | case 25: | ||
1168 | YY_RULE_SETUP | ||
1169 | #line 207 "dtc-lexer.l" | ||
1170 | { return DT_EQ; }; | ||
1171 | YY_BREAK | ||
1172 | case 26: | ||
1173 | YY_RULE_SETUP | ||
1174 | #line 208 "dtc-lexer.l" | ||
1175 | { return DT_NE; }; | ||
1176 | YY_BREAK | ||
1177 | case 27: | ||
1178 | YY_RULE_SETUP | ||
1179 | #line 209 "dtc-lexer.l" | ||
1180 | { return DT_AND; }; | ||
1181 | YY_BREAK | ||
1182 | case 28: | ||
1183 | YY_RULE_SETUP | ||
1184 | #line 210 "dtc-lexer.l" | ||
1185 | { return DT_OR; }; | ||
1186 | YY_BREAK | ||
1187 | case 29: | ||
1188 | YY_RULE_SETUP | 980 | YY_RULE_SETUP |
1189 | #line 212 "dtc-lexer.l" | ||
1190 | { | 981 | { |
1191 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], | 982 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], |
1192 | (unsigned)yytext[0]); | 983 | (unsigned)yytext[0]); |
@@ -1202,12 +993,10 @@ YY_RULE_SETUP | |||
1202 | return yytext[0]; | 993 | return yytext[0]; |
1203 | } | 994 | } |
1204 | YY_BREAK | 995 | YY_BREAK |
1205 | case 30: | 996 | case 17: |
1206 | YY_RULE_SETUP | 997 | YY_RULE_SETUP |
1207 | #line 227 "dtc-lexer.l" | ||
1208 | ECHO; | 998 | ECHO; |
1209 | YY_BREAK | 999 | YY_BREAK |
1210 | #line 1211 "dtc-lexer.lex.c" | ||
1211 | 1000 | ||
1212 | case YY_END_OF_BUFFER: | 1001 | case YY_END_OF_BUFFER: |
1213 | { | 1002 | { |
@@ -1486,7 +1275,6 @@ static int yy_get_next_buffer (void) | |||
1486 | register char *yy_cp; | 1275 | register char *yy_cp; |
1487 | 1276 | ||
1488 | yy_current_state = (yy_start); | 1277 | yy_current_state = (yy_start); |
1489 | yy_current_state += YY_AT_BOL(); | ||
1490 | 1278 | ||
1491 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) | 1279 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) |
1492 | { | 1280 | { |
@@ -1499,7 +1287,7 @@ static int yy_get_next_buffer (void) | |||
1499 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | 1287 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
1500 | { | 1288 | { |
1501 | yy_current_state = (int) yy_def[yy_current_state]; | 1289 | yy_current_state = (int) yy_def[yy_current_state]; |
1502 | if ( yy_current_state >= 161 ) | 1290 | if ( yy_current_state >= 94 ) |
1503 | yy_c = yy_meta[(unsigned int) yy_c]; | 1291 | yy_c = yy_meta[(unsigned int) yy_c]; |
1504 | } | 1292 | } |
1505 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | 1293 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; |
@@ -1527,11 +1315,11 @@ static int yy_get_next_buffer (void) | |||
1527 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | 1315 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
1528 | { | 1316 | { |
1529 | yy_current_state = (int) yy_def[yy_current_state]; | 1317 | yy_current_state = (int) yy_def[yy_current_state]; |
1530 | if ( yy_current_state >= 161 ) | 1318 | if ( yy_current_state >= 94 ) |
1531 | yy_c = yy_meta[(unsigned int) yy_c]; | 1319 | yy_c = yy_meta[(unsigned int) yy_c]; |
1532 | } | 1320 | } |
1533 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | 1321 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; |
1534 | yy_is_jam = (yy_current_state == 160); | 1322 | yy_is_jam = (yy_current_state == 93); |
1535 | 1323 | ||
1536 | return yy_is_jam ? 0 : yy_current_state; | 1324 | return yy_is_jam ? 0 : yy_current_state; |
1537 | } | 1325 | } |
@@ -1606,8 +1394,6 @@ static int yy_get_next_buffer (void) | |||
1606 | *(yy_c_buf_p) = '\0'; /* preserve yytext */ | 1394 | *(yy_c_buf_p) = '\0'; /* preserve yytext */ |
1607 | (yy_hold_char) = *++(yy_c_buf_p); | 1395 | (yy_hold_char) = *++(yy_c_buf_p); |
1608 | 1396 | ||
1609 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); | ||
1610 | |||
1611 | return c; | 1397 | return c; |
1612 | } | 1398 | } |
1613 | #endif /* ifndef YY_NO_INPUT */ | 1399 | #endif /* ifndef YY_NO_INPUT */ |
@@ -1926,8 +1712,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) | |||
1926 | 1712 | ||
1927 | /** Setup the input buffer state to scan the given bytes. The next call to yylex() will | 1713 | /** Setup the input buffer state to scan the given bytes. The next call to yylex() will |
1928 | * scan from a @e copy of @a bytes. | 1714 | * scan from a @e copy of @a bytes. |
1929 | * @param yybytes the byte buffer to scan | 1715 | * @param bytes the byte buffer to scan |
1930 | * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. | 1716 | * @param len the number of bytes in the buffer pointed to by @a bytes. |
1931 | * | 1717 | * |
1932 | * @return the newly allocated buffer state object. | 1718 | * @return the newly allocated buffer state object. |
1933 | */ | 1719 | */ |
@@ -2166,10 +1952,6 @@ void yyfree (void * ptr ) | |||
2166 | 1952 | ||
2167 | #define YYTABLES_NAME "yytables" | 1953 | #define YYTABLES_NAME "yytables" |
2168 | 1954 | ||
2169 | #line 227 "dtc-lexer.l" | ||
2170 | |||
2171 | |||
2172 | |||
2173 | static void push_input_file(const char *filename) | 1955 | static void push_input_file(const char *filename) |
2174 | { | 1956 | { |
2175 | assert(filename); | 1957 | assert(filename); |
@@ -2181,7 +1963,6 @@ static void push_input_file(const char *filename) | |||
2181 | yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE)); | 1963 | yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE)); |
2182 | } | 1964 | } |
2183 | 1965 | ||
2184 | |||
2185 | static int pop_input_file(void) | 1966 | static int pop_input_file(void) |
2186 | { | 1967 | { |
2187 | if (srcfile_pop() == 0) | 1968 | if (srcfile_pop() == 0) |
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped index 4af55900a15..b05921e1e84 100644 --- a/scripts/dtc/dtc-parser.tab.c_shipped +++ b/scripts/dtc/dtc-parser.tab.c_shipped | |||
@@ -1,10 +1,9 @@ | |||
1 | 1 | /* A Bison parser, made by GNU Bison 2.4.3. */ | |
2 | /* A Bison parser, made by GNU Bison 2.4.1. */ | ||
3 | 2 | ||
4 | /* Skeleton implementation for Bison's Yacc-like parsers in C | 3 | /* Skeleton implementation for Bison's Yacc-like parsers in C |
5 | 4 | ||
6 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | 5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
7 | Free Software Foundation, Inc. | 6 | 2009, 2010 Free Software Foundation, Inc. |
8 | 7 | ||
9 | This program is free software: you can redistribute it and/or modify | 8 | This program is free software: you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
@@ -46,7 +45,7 @@ | |||
46 | #define YYBISON 1 | 45 | #define YYBISON 1 |
47 | 46 | ||
48 | /* Bison version. */ | 47 | /* Bison version. */ |
49 | #define YYBISON_VERSION "2.4.1" | 48 | #define YYBISON_VERSION "2.4.3" |
50 | 49 | ||
51 | /* Skeleton name. */ | 50 | /* Skeleton name. */ |
52 | #define YYSKELETON_NAME "yacc.c" | 51 | #define YYSKELETON_NAME "yacc.c" |
@@ -67,8 +66,6 @@ | |||
67 | 66 | ||
68 | /* Copy the first part of user declarations. */ | 67 | /* Copy the first part of user declarations. */ |
69 | 68 | ||
70 | /* Line 189 of yacc.c */ | ||
71 | #line 21 "dtc-parser.y" | ||
72 | 69 | ||
73 | #include <stdio.h> | 70 | #include <stdio.h> |
74 | 71 | ||
@@ -85,15 +82,12 @@ extern struct boot_info *the_boot_info; | |||
85 | extern int treesource_error; | 82 | extern int treesource_error; |
86 | 83 | ||
87 | static unsigned long long eval_literal(const char *s, int base, int bits); | 84 | static unsigned long long eval_literal(const char *s, int base, int bits); |
88 | static unsigned char eval_char_literal(const char *s); | ||
89 | 85 | ||
90 | 86 | ||
91 | /* Line 189 of yacc.c */ | ||
92 | #line 93 "dtc-parser.tab.c" | ||
93 | 87 | ||
94 | /* Enabling traces. */ | 88 | /* Enabling traces. */ |
95 | #ifndef YYDEBUG | 89 | #ifndef YYDEBUG |
96 | # define YYDEBUG 0 | 90 | # define YYDEBUG 1 |
97 | #endif | 91 | #endif |
98 | 92 | ||
99 | /* Enabling verbose error messages. */ | 93 | /* Enabling verbose error messages. */ |
@@ -118,26 +112,14 @@ static unsigned char eval_char_literal(const char *s); | |||
118 | enum yytokentype { | 112 | enum yytokentype { |
119 | DT_V1 = 258, | 113 | DT_V1 = 258, |
120 | DT_MEMRESERVE = 259, | 114 | DT_MEMRESERVE = 259, |
121 | DT_LSHIFT = 260, | 115 | DT_PROPNODENAME = 260, |
122 | DT_RSHIFT = 261, | 116 | DT_LITERAL = 261, |
123 | DT_LE = 262, | 117 | DT_BASE = 262, |
124 | DT_GE = 263, | 118 | DT_BYTE = 263, |
125 | DT_EQ = 264, | 119 | DT_STRING = 264, |
126 | DT_NE = 265, | 120 | DT_LABEL = 265, |
127 | DT_AND = 266, | 121 | DT_REF = 266, |
128 | DT_OR = 267, | 122 | DT_INCBIN = 267 |
129 | DT_BITS = 268, | ||
130 | DT_DEL_PROP = 269, | ||
131 | DT_DEL_NODE = 270, | ||
132 | DT_PROPNODENAME = 271, | ||
133 | DT_LITERAL = 272, | ||
134 | DT_CHAR_LITERAL = 273, | ||
135 | DT_BASE = 274, | ||
136 | DT_BYTE = 275, | ||
137 | DT_STRING = 276, | ||
138 | DT_LABEL = 277, | ||
139 | DT_REF = 278, | ||
140 | DT_INCBIN = 279 | ||
141 | }; | 123 | }; |
142 | #endif | 124 | #endif |
143 | 125 | ||
@@ -147,8 +129,6 @@ static unsigned char eval_char_literal(const char *s); | |||
147 | typedef union YYSTYPE | 129 | typedef union YYSTYPE |
148 | { | 130 | { |
149 | 131 | ||
150 | /* Line 214 of yacc.c */ | ||
151 | #line 40 "dtc-parser.y" | ||
152 | 132 | ||
153 | char *propnodename; | 133 | char *propnodename; |
154 | char *literal; | 134 | char *literal; |
@@ -157,22 +137,16 @@ typedef union YYSTYPE | |||
157 | uint8_t byte; | 137 | uint8_t byte; |
158 | struct data data; | 138 | struct data data; |
159 | 139 | ||
160 | struct { | 140 | uint64_t addr; |
161 | struct data data; | 141 | cell_t cell; |
162 | int bits; | ||
163 | } array; | ||
164 | |||
165 | struct property *prop; | 142 | struct property *prop; |
166 | struct property *proplist; | 143 | struct property *proplist; |
167 | struct node *node; | 144 | struct node *node; |
168 | struct node *nodelist; | 145 | struct node *nodelist; |
169 | struct reserve_info *re; | 146 | struct reserve_info *re; |
170 | uint64_t integer; | ||
171 | 147 | ||
172 | 148 | ||
173 | 149 | ||
174 | /* Line 214 of yacc.c */ | ||
175 | #line 176 "dtc-parser.tab.c" | ||
176 | } YYSTYPE; | 150 | } YYSTYPE; |
177 | # define YYSTYPE_IS_TRIVIAL 1 | 151 | # define YYSTYPE_IS_TRIVIAL 1 |
178 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | 152 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
@@ -183,8 +157,6 @@ typedef union YYSTYPE | |||
183 | /* Copy the second part of user declarations. */ | 157 | /* Copy the second part of user declarations. */ |
184 | 158 | ||
185 | 159 | ||
186 | /* Line 264 of yacc.c */ | ||
187 | #line 188 "dtc-parser.tab.c" | ||
188 | 160 | ||
189 | #ifdef short | 161 | #ifdef short |
190 | # undef short | 162 | # undef short |
@@ -234,7 +206,7 @@ typedef short int yytype_int16; | |||
234 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) | 206 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
235 | 207 | ||
236 | #ifndef YY_ | 208 | #ifndef YY_ |
237 | # if YYENABLE_NLS | 209 | # if defined YYENABLE_NLS && YYENABLE_NLS |
238 | # if ENABLE_NLS | 210 | # if ENABLE_NLS |
239 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | 211 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
240 | # define YY_(msgid) dgettext ("bison-runtime", msgid) | 212 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
@@ -399,20 +371,20 @@ union yyalloc | |||
399 | /* YYFINAL -- State number of the termination state. */ | 371 | /* YYFINAL -- State number of the termination state. */ |
400 | #define YYFINAL 4 | 372 | #define YYFINAL 4 |
401 | /* YYLAST -- Last index in YYTABLE. */ | 373 | /* YYLAST -- Last index in YYTABLE. */ |
402 | #define YYLAST 133 | 374 | #define YYLAST 56 |
403 | 375 | ||
404 | /* YYNTOKENS -- Number of terminals. */ | 376 | /* YYNTOKENS -- Number of terminals. */ |
405 | #define YYNTOKENS 48 | 377 | #define YYNTOKENS 25 |
406 | /* YYNNTS -- Number of nonterminals. */ | 378 | /* YYNNTS -- Number of nonterminals. */ |
407 | #define YYNNTS 28 | 379 | #define YYNNTS 16 |
408 | /* YYNRULES -- Number of rules. */ | 380 | /* YYNRULES -- Number of rules. */ |
409 | #define YYNRULES 79 | 381 | #define YYNRULES 39 |
410 | /* YYNRULES -- Number of states. */ | 382 | /* YYNRULES -- Number of states. */ |
411 | #define YYNSTATES 141 | 383 | #define YYNSTATES 67 |
412 | 384 | ||
413 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | 385 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
414 | #define YYUNDEFTOK 2 | 386 | #define YYUNDEFTOK 2 |
415 | #define YYMAXUTOK 279 | 387 | #define YYMAXUTOK 267 |
416 | 388 | ||
417 | #define YYTRANSLATE(YYX) \ | 389 | #define YYTRANSLATE(YYX) \ |
418 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | 390 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
@@ -423,16 +395,16 @@ static const yytype_uint8 yytranslate[] = | |||
423 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 395 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
424 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 396 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
425 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 397 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
426 | 2, 2, 2, 47, 2, 2, 2, 45, 41, 2, | 398 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
427 | 33, 35, 44, 42, 34, 43, 2, 26, 2, 2, | 399 | 22, 24, 2, 2, 23, 2, 2, 14, 2, 2, |
428 | 2, 2, 2, 2, 2, 2, 2, 2, 38, 25, | 400 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, |
429 | 36, 29, 30, 37, 2, 2, 2, 2, 2, 2, | 401 | 18, 17, 19, 2, 2, 2, 2, 2, 2, 2, |
430 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 402 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
431 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 403 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
432 | 2, 31, 2, 32, 40, 2, 2, 2, 2, 2, | 404 | 2, 20, 2, 21, 2, 2, 2, 2, 2, 2, |
433 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 405 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
434 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 406 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
435 | 2, 2, 2, 27, 39, 28, 46, 2, 2, 2, | 407 | 2, 2, 2, 15, 2, 16, 2, 2, 2, 2, |
436 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 408 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
437 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 409 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
438 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 410 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
@@ -446,68 +418,45 @@ static const yytype_uint8 yytranslate[] = | |||
446 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 418 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
447 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 419 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
448 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | 420 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
449 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | 421 | 5, 6, 7, 8, 9, 10, 11, 12 |
450 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 | ||
451 | }; | 422 | }; |
452 | 423 | ||
453 | #if YYDEBUG | 424 | #if YYDEBUG |
454 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | 425 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
455 | YYRHS. */ | 426 | YYRHS. */ |
456 | static const yytype_uint16 yyprhs[] = | 427 | static const yytype_uint8 yyprhs[] = |
457 | { | 428 | { |
458 | 0, 0, 3, 8, 9, 12, 17, 20, 23, 27, | 429 | 0, 0, 3, 8, 9, 12, 17, 20, 22, 25, |
459 | 31, 36, 42, 43, 46, 51, 54, 58, 61, 64, | 430 | 29, 33, 39, 40, 43, 48, 51, 54, 57, 62, |
460 | 68, 73, 76, 86, 92, 95, 96, 99, 102, 106, | 431 | 67, 70, 80, 86, 89, 90, 93, 96, 97, 100, |
461 | 108, 111, 114, 117, 119, 121, 125, 127, 129, 135, | 432 | 103, 106, 108, 109, 112, 115, 116, 119, 122, 125 |
462 | 137, 141, 143, 147, 149, 153, 155, 159, 161, 165, | ||
463 | 167, 171, 175, 177, 181, 185, 189, 193, 197, 201, | ||
464 | 203, 207, 211, 213, 217, 221, 225, 227, 229, 232, | ||
465 | 235, 238, 239, 242, 245, 246, 249, 252, 255, 259 | ||
466 | }; | 433 | }; |
467 | 434 | ||
468 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | 435 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
469 | static const yytype_int8 yyrhs[] = | 436 | static const yytype_int8 yyrhs[] = |
470 | { | 437 | { |
471 | 49, 0, -1, 3, 25, 50, 52, -1, -1, 51, | 438 | 26, 0, -1, 3, 13, 27, 30, -1, -1, 28, |
472 | 50, -1, 4, 59, 59, 25, -1, 22, 51, -1, | 439 | 27, -1, 4, 29, 29, 13, -1, 10, 28, -1, |
473 | 26, 53, -1, 52, 26, 53, -1, 52, 23, 53, | 440 | 6, -1, 14, 31, -1, 30, 14, 31, -1, 30, |
474 | -1, 52, 15, 23, 25, -1, 27, 54, 74, 28, | 441 | 11, 31, -1, 15, 32, 39, 16, 13, -1, -1, |
475 | 25, -1, -1, 54, 55, -1, 16, 29, 56, 25, | 442 | 32, 33, -1, 5, 17, 34, 13, -1, 5, 13, |
476 | -1, 16, 25, -1, 14, 16, 25, -1, 22, 55, | 443 | -1, 10, 33, -1, 35, 9, -1, 35, 18, 36, |
477 | -1, 57, 21, -1, 57, 58, 30, -1, 57, 31, | 444 | 19, -1, 35, 20, 38, 21, -1, 35, 11, -1, |
478 | 73, 32, -1, 57, 23, -1, 57, 24, 33, 21, | 445 | 35, 12, 22, 9, 23, 29, 23, 29, 24, -1, |
479 | 34, 59, 34, 59, 35, -1, 57, 24, 33, 21, | 446 | 35, 12, 22, 9, 24, -1, 34, 10, -1, -1, |
480 | 35, -1, 56, 22, -1, -1, 56, 34, -1, 57, | 447 | 34, 23, -1, 35, 10, -1, -1, 36, 37, -1, |
481 | 22, -1, 13, 17, 36, -1, 36, -1, 58, 59, | 448 | 36, 11, -1, 36, 10, -1, 6, -1, -1, 38, |
482 | -1, 58, 23, -1, 58, 22, -1, 17, -1, 18, | 449 | 8, -1, 38, 10, -1, -1, 40, 39, -1, 40, |
483 | -1, 33, 60, 35, -1, 61, -1, 62, -1, 62, | 450 | 33, -1, 5, 31, -1, 10, 40, -1 |
484 | 37, 60, 38, 61, -1, 63, -1, 62, 12, 63, | ||
485 | -1, 64, -1, 63, 11, 64, -1, 65, -1, 64, | ||
486 | 39, 65, -1, 66, -1, 65, 40, 66, -1, 67, | ||
487 | -1, 66, 41, 67, -1, 68, -1, 67, 9, 68, | ||
488 | -1, 67, 10, 68, -1, 69, -1, 68, 36, 69, | ||
489 | -1, 68, 30, 69, -1, 68, 7, 69, -1, 68, | ||
490 | 8, 69, -1, 69, 5, 70, -1, 69, 6, 70, | ||
491 | -1, 70, -1, 70, 42, 71, -1, 70, 43, 71, | ||
492 | -1, 71, -1, 71, 44, 72, -1, 71, 26, 72, | ||
493 | -1, 71, 45, 72, -1, 72, -1, 59, -1, 43, | ||
494 | 72, -1, 46, 72, -1, 47, 72, -1, -1, 73, | ||
495 | 20, -1, 73, 22, -1, -1, 75, 74, -1, 75, | ||
496 | 55, -1, 16, 53, -1, 15, 16, 25, -1, 22, | ||
497 | 75, -1 | ||
498 | }; | 451 | }; |
499 | 452 | ||
500 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | 453 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
501 | static const yytype_uint16 yyrline[] = | 454 | static const yytype_uint16 yyrline[] = |
502 | { | 455 | { |
503 | 0, 109, 109, 118, 121, 128, 132, 140, 144, 148, | 456 | 0, 86, 86, 95, 98, 105, 109, 117, 124, 128, |
504 | 158, 172, 180, 183, 190, 194, 198, 202, 210, 214, | 457 | 132, 145, 153, 156, 163, 167, 171, 179, 183, 187, |
505 | 218, 222, 226, 243, 253, 261, 264, 268, 275, 290, | 458 | 191, 195, 212, 222, 230, 233, 237, 245, 248, 252, |
506 | 295, 315, 329, 336, 340, 344, 351, 355, 356, 360, | 459 | 257, 264, 272, 275, 279, 287, 290, 294, 302, 306 |
507 | 361, 365, 366, 370, 371, 375, 376, 380, 381, 385, | ||
508 | 386, 387, 391, 392, 393, 394, 395, 399, 400, 401, | ||
509 | 405, 406, 407, 411, 412, 413, 414, 418, 419, 420, | ||
510 | 421, 426, 429, 433, 441, 444, 448, 456, 460, 464 | ||
511 | }; | 460 | }; |
512 | #endif | 461 | #endif |
513 | 462 | ||
@@ -516,19 +465,13 @@ static const yytype_uint16 yyrline[] = | |||
516 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | 465 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
517 | static const char *const yytname[] = | 466 | static const char *const yytname[] = |
518 | { | 467 | { |
519 | "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE", "DT_LSHIFT", | 468 | "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE", |
520 | "DT_RSHIFT", "DT_LE", "DT_GE", "DT_EQ", "DT_NE", "DT_AND", "DT_OR", | 469 | "DT_PROPNODENAME", "DT_LITERAL", "DT_BASE", "DT_BYTE", "DT_STRING", |
521 | "DT_BITS", "DT_DEL_PROP", "DT_DEL_NODE", "DT_PROPNODENAME", "DT_LITERAL", | 470 | "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", |
522 | "DT_CHAR_LITERAL", "DT_BASE", "DT_BYTE", "DT_STRING", "DT_LABEL", | 471 | "'<'", "'>'", "'['", "']'", "'('", "','", "')'", "$accept", "sourcefile", |
523 | "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", "'>'", "'['", | 472 | "memreserves", "memreserve", "addr", "devicetree", "nodedef", "proplist", |
524 | "']'", "'('", "','", "')'", "'<'", "'?'", "':'", "'|'", "'^'", "'&'", | 473 | "propdef", "propdata", "propdataprefix", "celllist", "cellval", |
525 | "'+'", "'-'", "'*'", "'%'", "'~'", "'!'", "$accept", "sourcefile", | 474 | "bytestring", "subnodes", "subnode", 0 |
526 | "memreserves", "memreserve", "devicetree", "nodedef", "proplist", | ||
527 | "propdef", "propdata", "propdataprefix", "arrayprefix", "integer_prim", | ||
528 | "integer_expr", "integer_trinary", "integer_or", "integer_and", | ||
529 | "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq", | ||
530 | "integer_rela", "integer_shift", "integer_add", "integer_mul", | ||
531 | "integer_unary", "bytestring", "subnodes", "subnode", 0 | ||
532 | }; | 475 | }; |
533 | #endif | 476 | #endif |
534 | 477 | ||
@@ -538,37 +481,27 @@ static const char *const yytname[] = | |||
538 | static const yytype_uint16 yytoknum[] = | 481 | static const yytype_uint16 yytoknum[] = |
539 | { | 482 | { |
540 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | 483 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
541 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, | 484 | 265, 266, 267, 59, 47, 123, 125, 61, 60, 62, |
542 | 275, 276, 277, 278, 279, 59, 47, 123, 125, 61, | 485 | 91, 93, 40, 44, 41 |
543 | 62, 91, 93, 40, 44, 41, 60, 63, 58, 124, | ||
544 | 94, 38, 43, 45, 42, 37, 126, 33 | ||
545 | }; | 486 | }; |
546 | # endif | 487 | # endif |
547 | 488 | ||
548 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | 489 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
549 | static const yytype_uint8 yyr1[] = | 490 | static const yytype_uint8 yyr1[] = |
550 | { | 491 | { |
551 | 0, 48, 49, 50, 50, 51, 51, 52, 52, 52, | 492 | 0, 25, 26, 27, 27, 28, 28, 29, 30, 30, |
552 | 52, 53, 54, 54, 55, 55, 55, 55, 56, 56, | 493 | 30, 31, 32, 32, 33, 33, 33, 34, 34, 34, |
553 | 56, 56, 56, 56, 56, 57, 57, 57, 58, 58, | 494 | 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, |
554 | 58, 58, 58, 59, 59, 59, 60, 61, 61, 62, | 495 | 36, 37, 38, 38, 38, 39, 39, 39, 40, 40 |
555 | 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, | ||
556 | 67, 67, 68, 68, 68, 68, 68, 69, 69, 69, | ||
557 | 70, 70, 70, 71, 71, 71, 71, 72, 72, 72, | ||
558 | 72, 73, 73, 73, 74, 74, 74, 75, 75, 75 | ||
559 | }; | 496 | }; |
560 | 497 | ||
561 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | 498 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
562 | static const yytype_uint8 yyr2[] = | 499 | static const yytype_uint8 yyr2[] = |
563 | { | 500 | { |
564 | 0, 2, 4, 0, 2, 4, 2, 2, 3, 3, | 501 | 0, 2, 4, 0, 2, 4, 2, 1, 2, 3, |
565 | 4, 5, 0, 2, 4, 2, 3, 2, 2, 3, | 502 | 3, 5, 0, 2, 4, 2, 2, 2, 4, 4, |
566 | 4, 2, 9, 5, 2, 0, 2, 2, 3, 1, | 503 | 2, 9, 5, 2, 0, 2, 2, 0, 2, 2, |
567 | 2, 2, 2, 1, 1, 3, 1, 1, 5, 1, | 504 | 2, 1, 0, 2, 2, 0, 2, 2, 2, 2 |
568 | 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, | ||
569 | 3, 3, 1, 3, 3, 3, 3, 3, 3, 1, | ||
570 | 3, 3, 1, 3, 3, 3, 1, 1, 2, 2, | ||
571 | 2, 0, 2, 2, 0, 2, 2, 2, 3, 2 | ||
572 | }; | 505 | }; |
573 | 506 | ||
574 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state | 507 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
@@ -576,59 +509,41 @@ static const yytype_uint8 yyr2[] = | |||
576 | means the default is an error. */ | 509 | means the default is an error. */ |
577 | static const yytype_uint8 yydefact[] = | 510 | static const yytype_uint8 yydefact[] = |
578 | { | 511 | { |
579 | 0, 0, 0, 3, 1, 0, 0, 0, 3, 33, | 512 | 0, 0, 0, 3, 1, 0, 0, 0, 3, 7, |
580 | 34, 0, 0, 6, 0, 2, 4, 0, 0, 0, | 513 | 0, 6, 0, 2, 4, 0, 12, 8, 0, 0, |
581 | 67, 0, 36, 37, 39, 41, 43, 45, 47, 49, | 514 | 5, 35, 10, 9, 0, 0, 13, 0, 35, 15, |
582 | 52, 59, 62, 66, 0, 12, 7, 0, 0, 0, | 515 | 24, 38, 16, 39, 0, 37, 36, 0, 0, 11, |
583 | 68, 69, 70, 35, 0, 0, 0, 0, 0, 0, | 516 | 23, 14, 25, 17, 26, 20, 0, 27, 32, 0, |
584 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 517 | 0, 0, 0, 31, 30, 29, 18, 28, 33, 34, |
585 | 0, 0, 0, 5, 74, 0, 9, 8, 40, 0, | 518 | 19, 0, 22, 0, 0, 0, 21 |
586 | 42, 44, 46, 48, 50, 51, 55, 56, 54, 53, | ||
587 | 57, 58, 60, 61, 64, 63, 65, 0, 0, 0, | ||
588 | 0, 13, 0, 74, 10, 0, 0, 0, 15, 25, | ||
589 | 77, 17, 79, 0, 76, 75, 38, 16, 78, 0, | ||
590 | 0, 11, 24, 14, 26, 0, 18, 27, 21, 0, | ||
591 | 71, 29, 0, 0, 0, 0, 32, 31, 19, 30, | ||
592 | 28, 0, 72, 73, 20, 0, 23, 0, 0, 0, | ||
593 | 22 | ||
594 | }; | 519 | }; |
595 | 520 | ||
596 | /* YYDEFGOTO[NTERM-NUM]. */ | 521 | /* YYDEFGOTO[NTERM-NUM]. */ |
597 | static const yytype_int8 yydefgoto[] = | 522 | static const yytype_int8 yydefgoto[] = |
598 | { | 523 | { |
599 | -1, 2, 7, 8, 15, 36, 64, 91, 109, 110, | 524 | -1, 2, 7, 8, 10, 13, 17, 21, 26, 37, |
600 | 122, 20, 21, 22, 23, 24, 25, 26, 27, 28, | 525 | 38, 50, 57, 51, 27, 28 |
601 | 29, 30, 31, 32, 33, 125, 92, 93 | ||
602 | }; | 526 | }; |
603 | 527 | ||
604 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | 528 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
605 | STATE-NUM. */ | 529 | STATE-NUM. */ |
606 | #define YYPACT_NINF -78 | 530 | #define YYPACT_NINF -12 |
607 | static const yytype_int8 yypact[] = | 531 | static const yytype_int8 yypact[] = |
608 | { | 532 | { |
609 | 22, 11, 51, 10, -78, 23, 10, 2, 10, -78, | 533 | 10, -11, 18, -1, -12, 22, -1, 15, -1, -12, |
610 | -78, -9, 23, -78, 30, 38, -78, -9, -9, -9, | 534 | 22, -12, 20, 1, -12, 17, -12, -12, 20, 20, |
611 | -78, 35, -78, -6, 52, 29, 48, 49, 33, 3, | 535 | -12, 6, -12, -12, 21, 6, -12, 23, 6, -12, |
612 | 71, 36, 0, -78, 64, -78, -78, 68, 30, 30, | 536 | -12, -12, -12, -12, 28, -12, -12, -6, 13, -12, |
613 | -78, -78, -78, -78, -9, -9, -9, -9, -9, -9, | 537 | -12, -12, -12, -12, -12, -12, 24, -12, -12, 33, |
614 | -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, | 538 | -5, 0, -4, -12, -12, -12, -12, -12, -12, -12, |
615 | -9, -9, -9, -78, 44, 67, -78, -78, 52, 55, | 539 | -12, 22, -12, 25, 22, 19, -12 |
616 | 29, 48, 49, 33, 3, 3, 71, 71, 71, 71, | ||
617 | 36, 36, 0, 0, -78, -78, -78, 78, 79, 42, | ||
618 | 44, -78, 69, 44, -78, -9, 73, 74, -78, -78, | ||
619 | -78, -78, -78, 75, -78, -78, -78, -78, -78, -7, | ||
620 | -1, -78, -78, -78, -78, 84, -78, -78, -78, 63, | ||
621 | -78, -78, 32, 66, 82, -3, -78, -78, -78, -78, | ||
622 | -78, 46, -78, -78, -78, 23, -78, 70, 23, 72, | ||
623 | -78 | ||
624 | }; | 540 | }; |
625 | 541 | ||
626 | /* YYPGOTO[NTERM-NUM]. */ | 542 | /* YYPGOTO[NTERM-NUM]. */ |
627 | static const yytype_int8 yypgoto[] = | 543 | static const yytype_int8 yypgoto[] = |
628 | { | 544 | { |
629 | -78, -78, 97, 100, -78, -37, -78, -77, -78, -78, | 545 | -12, -12, 36, 39, -10, -12, 8, -12, 12, -12, |
630 | -78, -5, 65, 13, -78, 76, 77, 62, 80, 83, | 546 | -12, -12, -12, -12, 27, 31 |
631 | 34, 20, 26, 28, -14, -78, 18, 24 | ||
632 | }; | 547 | }; |
633 | 548 | ||
634 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | 549 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
@@ -638,59 +553,35 @@ static const yytype_int8 yypgoto[] = | |||
638 | #define YYTABLE_NINF -1 | 553 | #define YYTABLE_NINF -1 |
639 | static const yytype_uint8 yytable[] = | 554 | static const yytype_uint8 yytable[] = |
640 | { | 555 | { |
641 | 12, 66, 67, 40, 41, 42, 44, 34, 9, 10, | 556 | 15, 53, 3, 5, 40, 54, 55, 41, 58, 6, |
642 | 52, 53, 115, 101, 5, 112, 104, 132, 113, 133, | 557 | 59, 24, 18, 1, 56, 19, 25, 42, 4, 61, |
643 | 116, 117, 118, 119, 11, 1, 60, 114, 14, 134, | 558 | 62, 60, 43, 44, 45, 46, 22, 23, 9, 12, |
644 | 120, 45, 6, 54, 17, 121, 3, 18, 19, 55, | 559 | 20, 47, 31, 48, 29, 16, 16, 32, 30, 34, |
645 | 9, 10, 50, 51, 61, 62, 84, 85, 86, 9, | 560 | 35, 39, 52, 66, 14, 11, 49, 0, 64, 0, |
646 | 10, 4, 100, 37, 126, 127, 11, 35, 87, 88, | 561 | 0, 63, 0, 0, 65, 36, 33 |
647 | 89, 38, 128, 46, 39, 11, 90, 98, 47, 35, | ||
648 | 43, 99, 76, 77, 78, 79, 56, 57, 58, 59, | ||
649 | 135, 136, 80, 81, 74, 75, 82, 83, 48, 63, | ||
650 | 49, 65, 94, 95, 96, 97, 124, 103, 107, 108, | ||
651 | 111, 123, 130, 131, 138, 16, 13, 140, 106, 71, | ||
652 | 69, 105, 0, 0, 102, 0, 0, 129, 0, 0, | ||
653 | 68, 0, 0, 70, 0, 0, 0, 0, 72, 0, | ||
654 | 137, 0, 73, 139 | ||
655 | }; | 562 | }; |
656 | 563 | ||
657 | static const yytype_int16 yycheck[] = | 564 | static const yytype_int8 yycheck[] = |
658 | { | 565 | { |
659 | 5, 38, 39, 17, 18, 19, 12, 12, 17, 18, | 566 | 10, 6, 13, 4, 10, 10, 11, 13, 8, 10, |
660 | 7, 8, 13, 90, 4, 22, 93, 20, 25, 22, | 567 | 10, 5, 11, 3, 19, 14, 10, 23, 0, 23, |
661 | 21, 22, 23, 24, 33, 3, 26, 34, 26, 32, | 568 | 24, 21, 9, 10, 11, 12, 18, 19, 6, 14, |
662 | 31, 37, 22, 30, 43, 36, 25, 46, 47, 36, | 569 | 13, 18, 24, 20, 13, 15, 15, 25, 17, 16, |
663 | 17, 18, 9, 10, 44, 45, 60, 61, 62, 17, | 570 | 28, 13, 9, 24, 8, 6, 22, -1, 23, -1, |
664 | 18, 0, 89, 15, 22, 23, 33, 27, 14, 15, | 571 | -1, 61, -1, -1, 64, 28, 25 |
665 | 16, 23, 30, 11, 26, 33, 22, 25, 39, 27, | ||
666 | 35, 29, 52, 53, 54, 55, 5, 6, 42, 43, | ||
667 | 34, 35, 56, 57, 50, 51, 58, 59, 40, 25, | ||
668 | 41, 23, 25, 38, 16, 16, 33, 28, 25, 25, | ||
669 | 25, 17, 36, 21, 34, 8, 6, 35, 95, 47, | ||
670 | 45, 93, -1, -1, 90, -1, -1, 122, -1, -1, | ||
671 | 44, -1, -1, 46, -1, -1, -1, -1, 48, -1, | ||
672 | 135, -1, 49, 138 | ||
673 | }; | 572 | }; |
674 | 573 | ||
675 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | 574 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
676 | symbol of state STATE-NUM. */ | 575 | symbol of state STATE-NUM. */ |
677 | static const yytype_uint8 yystos[] = | 576 | static const yytype_uint8 yystos[] = |
678 | { | 577 | { |
679 | 0, 3, 49, 25, 0, 4, 22, 50, 51, 17, | 578 | 0, 3, 26, 13, 0, 4, 10, 27, 28, 6, |
680 | 18, 33, 59, 51, 26, 52, 50, 43, 46, 47, | 579 | 29, 28, 14, 30, 27, 29, 15, 31, 11, 14, |
681 | 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, | 580 | 13, 32, 31, 31, 5, 10, 33, 39, 40, 13, |
682 | 69, 70, 71, 72, 59, 27, 53, 15, 23, 26, | 581 | 17, 31, 33, 40, 16, 33, 39, 34, 35, 13, |
683 | 72, 72, 72, 35, 12, 37, 11, 39, 40, 41, | 582 | 10, 13, 23, 9, 10, 11, 12, 18, 20, 22, |
684 | 9, 10, 7, 8, 30, 36, 5, 6, 42, 43, | 583 | 36, 38, 9, 6, 10, 11, 19, 37, 8, 10, |
685 | 26, 44, 45, 25, 54, 23, 53, 53, 63, 60, | 584 | 21, 23, 24, 29, 23, 29, 24 |
686 | 64, 65, 66, 67, 68, 68, 69, 69, 69, 69, | ||
687 | 70, 70, 71, 71, 72, 72, 72, 14, 15, 16, | ||
688 | 22, 55, 74, 75, 25, 38, 16, 16, 25, 29, | ||
689 | 53, 55, 75, 28, 55, 74, 61, 25, 25, 56, | ||
690 | 57, 25, 22, 25, 34, 13, 21, 22, 23, 24, | ||
691 | 31, 36, 58, 17, 33, 73, 22, 23, 30, 59, | ||
692 | 36, 21, 20, 22, 32, 34, 35, 59, 34, 59, | ||
693 | 35 | ||
694 | }; | 585 | }; |
695 | 586 | ||
696 | #define yyerrok (yyerrstatus = 0) | 587 | #define yyerrok (yyerrstatus = 0) |
@@ -705,9 +596,18 @@ static const yytype_uint8 yystos[] = | |||
705 | 596 | ||
706 | /* Like YYERROR except do call yyerror. This remains here temporarily | 597 | /* Like YYERROR except do call yyerror. This remains here temporarily |
707 | to ease the transition to the new meaning of YYERROR, for GCC. | 598 | to ease the transition to the new meaning of YYERROR, for GCC. |
708 | Once GCC version 2 has supplanted version 1, this can go. */ | 599 | Once GCC version 2 has supplanted version 1, this can go. However, |
600 | YYFAIL appears to be in use. Nevertheless, it is formally deprecated | ||
601 | in Bison 2.4.2's NEWS entry, where a plan to phase it out is | ||
602 | discussed. */ | ||
709 | 603 | ||
710 | #define YYFAIL goto yyerrlab | 604 | #define YYFAIL goto yyerrlab |
605 | #if defined YYFAIL | ||
606 | /* This is here to suppress warnings from the GCC cpp's | ||
607 | -Wunused-macros. Normally we don't worry about that warning, but | ||
608 | some users do, and we want to make it easy for users to remove | ||
609 | YYFAIL uses, which will produce warnings from Bison 2.5. */ | ||
610 | #endif | ||
711 | 611 | ||
712 | #define YYRECOVERING() (!!yyerrstatus) | 612 | #define YYRECOVERING() (!!yyerrstatus) |
713 | 613 | ||
@@ -764,7 +664,7 @@ while (YYID (0)) | |||
764 | we won't break user code: when these are the locations we know. */ | 664 | we won't break user code: when these are the locations we know. */ |
765 | 665 | ||
766 | #ifndef YY_LOCATION_PRINT | 666 | #ifndef YY_LOCATION_PRINT |
767 | # if YYLTYPE_IS_TRIVIAL | 667 | # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL |
768 | # define YY_LOCATION_PRINT(File, Loc) \ | 668 | # define YY_LOCATION_PRINT(File, Loc) \ |
769 | fprintf (File, "%d.%d-%d.%d", \ | 669 | fprintf (File, "%d.%d-%d.%d", \ |
770 | (Loc).first_line, (Loc).first_column, \ | 670 | (Loc).first_line, (Loc).first_column, \ |
@@ -1503,8 +1403,6 @@ yyreduce: | |||
1503 | { | 1403 | { |
1504 | case 2: | 1404 | case 2: |
1505 | 1405 | ||
1506 | /* Line 1455 of yacc.c */ | ||
1507 | #line 110 "dtc-parser.y" | ||
1508 | { | 1406 | { |
1509 | the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), | 1407 | the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), |
1510 | guess_boot_cpuid((yyvsp[(4) - (4)].node))); | 1408 | guess_boot_cpuid((yyvsp[(4) - (4)].node))); |
@@ -1513,8 +1411,6 @@ yyreduce: | |||
1513 | 1411 | ||
1514 | case 3: | 1412 | case 3: |
1515 | 1413 | ||
1516 | /* Line 1455 of yacc.c */ | ||
1517 | #line 118 "dtc-parser.y" | ||
1518 | { | 1414 | { |
1519 | (yyval.re) = NULL; | 1415 | (yyval.re) = NULL; |
1520 | ;} | 1416 | ;} |
@@ -1522,8 +1418,6 @@ yyreduce: | |||
1522 | 1418 | ||
1523 | case 4: | 1419 | case 4: |
1524 | 1420 | ||
1525 | /* Line 1455 of yacc.c */ | ||
1526 | #line 122 "dtc-parser.y" | ||
1527 | { | 1421 | { |
1528 | (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); | 1422 | (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); |
1529 | ;} | 1423 | ;} |
@@ -1531,17 +1425,13 @@ yyreduce: | |||
1531 | 1425 | ||
1532 | case 5: | 1426 | case 5: |
1533 | 1427 | ||
1534 | /* Line 1455 of yacc.c */ | ||
1535 | #line 129 "dtc-parser.y" | ||
1536 | { | 1428 | { |
1537 | (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); | 1429 | (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].addr), (yyvsp[(3) - (4)].addr)); |
1538 | ;} | 1430 | ;} |
1539 | break; | 1431 | break; |
1540 | 1432 | ||
1541 | case 6: | 1433 | case 6: |
1542 | 1434 | ||
1543 | /* Line 1455 of yacc.c */ | ||
1544 | #line 133 "dtc-parser.y" | ||
1545 | { | 1435 | { |
1546 | add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); | 1436 | add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); |
1547 | (yyval.re) = (yyvsp[(2) - (2)].re); | 1437 | (yyval.re) = (yyvsp[(2) - (2)].re); |
@@ -1550,57 +1440,40 @@ yyreduce: | |||
1550 | 1440 | ||
1551 | case 7: | 1441 | case 7: |
1552 | 1442 | ||
1553 | /* Line 1455 of yacc.c */ | ||
1554 | #line 141 "dtc-parser.y" | ||
1555 | { | 1443 | { |
1556 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); | 1444 | (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); |
1557 | ;} | 1445 | ;} |
1558 | break; | 1446 | break; |
1559 | 1447 | ||
1560 | case 8: | 1448 | case 8: |
1561 | 1449 | ||
1562 | /* Line 1455 of yacc.c */ | ||
1563 | #line 145 "dtc-parser.y" | ||
1564 | { | 1450 | { |
1565 | (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); | 1451 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); |
1566 | ;} | 1452 | ;} |
1567 | break; | 1453 | break; |
1568 | 1454 | ||
1569 | case 9: | 1455 | case 9: |
1570 | 1456 | ||
1571 | /* Line 1455 of yacc.c */ | ||
1572 | #line 149 "dtc-parser.y" | ||
1573 | { | 1457 | { |
1574 | struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); | 1458 | (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); |
1575 | |||
1576 | if (target) | ||
1577 | merge_nodes(target, (yyvsp[(3) - (3)].node)); | ||
1578 | else | ||
1579 | print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref)); | ||
1580 | (yyval.node) = (yyvsp[(1) - (3)].node); | ||
1581 | ;} | 1459 | ;} |
1582 | break; | 1460 | break; |
1583 | 1461 | ||
1584 | case 10: | 1462 | case 10: |
1585 | 1463 | ||
1586 | /* Line 1455 of yacc.c */ | ||
1587 | #line 159 "dtc-parser.y" | ||
1588 | { | 1464 | { |
1589 | struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); | 1465 | struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); |
1590 | 1466 | ||
1591 | if (!target) | 1467 | if (target) |
1592 | print_error("label or path, '%s', not found", (yyvsp[(3) - (4)].labelref)); | 1468 | merge_nodes(target, (yyvsp[(3) - (3)].node)); |
1593 | else | 1469 | else |
1594 | delete_node(target); | 1470 | print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref)); |
1595 | 1471 | (yyval.node) = (yyvsp[(1) - (3)].node); | |
1596 | (yyval.node) = (yyvsp[(1) - (4)].node); | ||
1597 | ;} | 1472 | ;} |
1598 | break; | 1473 | break; |
1599 | 1474 | ||
1600 | case 11: | 1475 | case 11: |
1601 | 1476 | ||
1602 | /* Line 1455 of yacc.c */ | ||
1603 | #line 173 "dtc-parser.y" | ||
1604 | { | 1477 | { |
1605 | (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); | 1478 | (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); |
1606 | ;} | 1479 | ;} |
@@ -1608,8 +1481,6 @@ yyreduce: | |||
1608 | 1481 | ||
1609 | case 12: | 1482 | case 12: |
1610 | 1483 | ||
1611 | /* Line 1455 of yacc.c */ | ||
1612 | #line 180 "dtc-parser.y" | ||
1613 | { | 1484 | { |
1614 | (yyval.proplist) = NULL; | 1485 | (yyval.proplist) = NULL; |
1615 | ;} | 1486 | ;} |
@@ -1617,8 +1488,6 @@ yyreduce: | |||
1617 | 1488 | ||
1618 | case 13: | 1489 | case 13: |
1619 | 1490 | ||
1620 | /* Line 1455 of yacc.c */ | ||
1621 | #line 184 "dtc-parser.y" | ||
1622 | { | 1491 | { |
1623 | (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); | 1492 | (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); |
1624 | ;} | 1493 | ;} |
@@ -1626,8 +1495,6 @@ yyreduce: | |||
1626 | 1495 | ||
1627 | case 14: | 1496 | case 14: |
1628 | 1497 | ||
1629 | /* Line 1455 of yacc.c */ | ||
1630 | #line 191 "dtc-parser.y" | ||
1631 | { | 1498 | { |
1632 | (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); | 1499 | (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); |
1633 | ;} | 1500 | ;} |
@@ -1635,8 +1502,6 @@ yyreduce: | |||
1635 | 1502 | ||
1636 | case 15: | 1503 | case 15: |
1637 | 1504 | ||
1638 | /* Line 1455 of yacc.c */ | ||
1639 | #line 195 "dtc-parser.y" | ||
1640 | { | 1505 | { |
1641 | (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); | 1506 | (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); |
1642 | ;} | 1507 | ;} |
@@ -1644,85 +1509,62 @@ yyreduce: | |||
1644 | 1509 | ||
1645 | case 16: | 1510 | case 16: |
1646 | 1511 | ||
1647 | /* Line 1455 of yacc.c */ | ||
1648 | #line 199 "dtc-parser.y" | ||
1649 | { | ||
1650 | (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); | ||
1651 | ;} | ||
1652 | break; | ||
1653 | |||
1654 | case 17: | ||
1655 | |||
1656 | /* Line 1455 of yacc.c */ | ||
1657 | #line 203 "dtc-parser.y" | ||
1658 | { | 1512 | { |
1659 | add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); | 1513 | add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); |
1660 | (yyval.prop) = (yyvsp[(2) - (2)].prop); | 1514 | (yyval.prop) = (yyvsp[(2) - (2)].prop); |
1661 | ;} | 1515 | ;} |
1662 | break; | 1516 | break; |
1663 | 1517 | ||
1664 | case 18: | 1518 | case 17: |
1665 | 1519 | ||
1666 | /* Line 1455 of yacc.c */ | ||
1667 | #line 211 "dtc-parser.y" | ||
1668 | { | 1520 | { |
1669 | (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); | 1521 | (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); |
1670 | ;} | 1522 | ;} |
1671 | break; | 1523 | break; |
1672 | 1524 | ||
1673 | case 19: | 1525 | case 18: |
1674 | 1526 | ||
1675 | /* Line 1455 of yacc.c */ | ||
1676 | #line 215 "dtc-parser.y" | ||
1677 | { | 1527 | { |
1678 | (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); | 1528 | (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); |
1679 | ;} | 1529 | ;} |
1680 | break; | 1530 | break; |
1681 | 1531 | ||
1682 | case 20: | 1532 | case 19: |
1683 | 1533 | ||
1684 | /* Line 1455 of yacc.c */ | ||
1685 | #line 219 "dtc-parser.y" | ||
1686 | { | 1534 | { |
1687 | (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); | 1535 | (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); |
1688 | ;} | 1536 | ;} |
1689 | break; | 1537 | break; |
1690 | 1538 | ||
1691 | case 21: | 1539 | case 20: |
1692 | 1540 | ||
1693 | /* Line 1455 of yacc.c */ | ||
1694 | #line 223 "dtc-parser.y" | ||
1695 | { | 1541 | { |
1696 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); | 1542 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); |
1697 | ;} | 1543 | ;} |
1698 | break; | 1544 | break; |
1699 | 1545 | ||
1700 | case 22: | 1546 | case 21: |
1701 | 1547 | ||
1702 | /* Line 1455 of yacc.c */ | ||
1703 | #line 227 "dtc-parser.y" | ||
1704 | { | 1548 | { |
1705 | FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); | 1549 | FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); |
1706 | struct data d; | 1550 | struct data d; |
1707 | 1551 | ||
1708 | if ((yyvsp[(6) - (9)].integer) != 0) | 1552 | if ((yyvsp[(6) - (9)].addr) != 0) |
1709 | if (fseek(f, (yyvsp[(6) - (9)].integer), SEEK_SET) != 0) | 1553 | if (fseek(f, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0) |
1710 | print_error("Couldn't seek to offset %llu in \"%s\": %s", | 1554 | print_error("Couldn't seek to offset %llu in \"%s\": %s", |
1711 | (unsigned long long)(yyvsp[(6) - (9)].integer), | 1555 | (unsigned long long)(yyvsp[(6) - (9)].addr), |
1712 | (yyvsp[(4) - (9)].data).val, | 1556 | (yyvsp[(4) - (9)].data).val, |
1713 | strerror(errno)); | 1557 | strerror(errno)); |
1714 | 1558 | ||
1715 | d = data_copy_file(f, (yyvsp[(8) - (9)].integer)); | 1559 | d = data_copy_file(f, (yyvsp[(8) - (9)].addr)); |
1716 | 1560 | ||
1717 | (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); | 1561 | (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); |
1718 | fclose(f); | 1562 | fclose(f); |
1719 | ;} | 1563 | ;} |
1720 | break; | 1564 | break; |
1721 | 1565 | ||
1722 | case 23: | 1566 | case 22: |
1723 | 1567 | ||
1724 | /* Line 1455 of yacc.c */ | ||
1725 | #line 244 "dtc-parser.y" | ||
1726 | { | 1568 | { |
1727 | FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); | 1569 | FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); |
1728 | struct data d = empty_data; | 1570 | struct data d = empty_data; |
@@ -1734,383 +1576,122 @@ yyreduce: | |||
1734 | ;} | 1576 | ;} |
1735 | break; | 1577 | break; |
1736 | 1578 | ||
1737 | case 24: | 1579 | case 23: |
1738 | 1580 | ||
1739 | /* Line 1455 of yacc.c */ | ||
1740 | #line 254 "dtc-parser.y" | ||
1741 | { | 1581 | { |
1742 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); | 1582 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
1743 | ;} | 1583 | ;} |
1744 | break; | 1584 | break; |
1745 | 1585 | ||
1746 | case 25: | 1586 | case 24: |
1747 | 1587 | ||
1748 | /* Line 1455 of yacc.c */ | ||
1749 | #line 261 "dtc-parser.y" | ||
1750 | { | 1588 | { |
1751 | (yyval.data) = empty_data; | 1589 | (yyval.data) = empty_data; |
1752 | ;} | 1590 | ;} |
1753 | break; | 1591 | break; |
1754 | 1592 | ||
1755 | case 26: | 1593 | case 25: |
1756 | 1594 | ||
1757 | /* Line 1455 of yacc.c */ | ||
1758 | #line 265 "dtc-parser.y" | ||
1759 | { | 1595 | { |
1760 | (yyval.data) = (yyvsp[(1) - (2)].data); | 1596 | (yyval.data) = (yyvsp[(1) - (2)].data); |
1761 | ;} | 1597 | ;} |
1762 | break; | 1598 | break; |
1763 | 1599 | ||
1764 | case 27: | 1600 | case 26: |
1765 | 1601 | ||
1766 | /* Line 1455 of yacc.c */ | ||
1767 | #line 269 "dtc-parser.y" | ||
1768 | { | 1602 | { |
1769 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); | 1603 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
1770 | ;} | 1604 | ;} |
1771 | break; | 1605 | break; |
1772 | 1606 | ||
1773 | case 28: | 1607 | case 27: |
1774 | |||
1775 | /* Line 1455 of yacc.c */ | ||
1776 | #line 276 "dtc-parser.y" | ||
1777 | { | ||
1778 | (yyval.array).data = empty_data; | ||
1779 | (yyval.array).bits = eval_literal((yyvsp[(2) - (3)].literal), 0, 7); | ||
1780 | |||
1781 | if (((yyval.array).bits != 8) && | ||
1782 | ((yyval.array).bits != 16) && | ||
1783 | ((yyval.array).bits != 32) && | ||
1784 | ((yyval.array).bits != 64)) | ||
1785 | { | ||
1786 | print_error("Only 8, 16, 32 and 64-bit elements" | ||
1787 | " are currently supported"); | ||
1788 | (yyval.array).bits = 32; | ||
1789 | } | ||
1790 | ;} | ||
1791 | break; | ||
1792 | |||
1793 | case 29: | ||
1794 | |||
1795 | /* Line 1455 of yacc.c */ | ||
1796 | #line 291 "dtc-parser.y" | ||
1797 | { | ||
1798 | (yyval.array).data = empty_data; | ||
1799 | (yyval.array).bits = 32; | ||
1800 | ;} | ||
1801 | break; | ||
1802 | |||
1803 | case 30: | ||
1804 | |||
1805 | /* Line 1455 of yacc.c */ | ||
1806 | #line 296 "dtc-parser.y" | ||
1807 | { | ||
1808 | if ((yyvsp[(1) - (2)].array).bits < 64) { | ||
1809 | uint64_t mask = (1ULL << (yyvsp[(1) - (2)].array).bits) - 1; | ||
1810 | /* | ||
1811 | * Bits above mask must either be all zero | ||
1812 | * (positive within range of mask) or all one | ||
1813 | * (negative and sign-extended). The second | ||
1814 | * condition is true if when we set all bits | ||
1815 | * within the mask to one (i.e. | in the | ||
1816 | * mask), all bits are one. | ||
1817 | */ | ||
1818 | if (((yyvsp[(2) - (2)].integer) > mask) && (((yyvsp[(2) - (2)].integer) | mask) != -1ULL)) | ||
1819 | print_error( | ||
1820 | "integer value out of range " | ||
1821 | "%016lx (%d bits)", (yyvsp[(1) - (2)].array).bits); | ||
1822 | } | ||
1823 | |||
1824 | (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, (yyvsp[(2) - (2)].integer), (yyvsp[(1) - (2)].array).bits); | ||
1825 | ;} | ||
1826 | break; | ||
1827 | |||
1828 | case 31: | ||
1829 | 1608 | ||
1830 | /* Line 1455 of yacc.c */ | ||
1831 | #line 316 "dtc-parser.y" | ||
1832 | { | 1609 | { |
1833 | uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); | 1610 | (yyval.data) = empty_data; |
1834 | |||
1835 | if ((yyvsp[(1) - (2)].array).bits == 32) | ||
1836 | (yyvsp[(1) - (2)].array).data = data_add_marker((yyvsp[(1) - (2)].array).data, | ||
1837 | REF_PHANDLE, | ||
1838 | (yyvsp[(2) - (2)].labelref)); | ||
1839 | else | ||
1840 | print_error("References are only allowed in " | ||
1841 | "arrays with 32-bit elements."); | ||
1842 | |||
1843 | (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, val, (yyvsp[(1) - (2)].array).bits); | ||
1844 | ;} | 1611 | ;} |
1845 | break; | 1612 | break; |
1846 | 1613 | ||
1847 | case 32: | 1614 | case 28: |
1848 | 1615 | ||
1849 | /* Line 1455 of yacc.c */ | ||
1850 | #line 330 "dtc-parser.y" | ||
1851 | { | 1616 | { |
1852 | (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref)); | 1617 | (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell)); |
1853 | ;} | 1618 | ;} |
1854 | break; | 1619 | break; |
1855 | 1620 | ||
1856 | case 33: | 1621 | case 29: |
1857 | 1622 | ||
1858 | /* Line 1455 of yacc.c */ | ||
1859 | #line 337 "dtc-parser.y" | ||
1860 | { | 1623 | { |
1861 | (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); | 1624 | (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE, |
1625 | (yyvsp[(2) - (2)].labelref)), -1); | ||
1862 | ;} | 1626 | ;} |
1863 | break; | 1627 | break; |
1864 | 1628 | ||
1865 | case 34: | 1629 | case 30: |
1866 | 1630 | ||
1867 | /* Line 1455 of yacc.c */ | ||
1868 | #line 341 "dtc-parser.y" | ||
1869 | { | 1631 | { |
1870 | (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); | 1632 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
1871 | ;} | 1633 | ;} |
1872 | break; | 1634 | break; |
1873 | 1635 | ||
1874 | case 35: | 1636 | case 31: |
1875 | 1637 | ||
1876 | /* Line 1455 of yacc.c */ | ||
1877 | #line 345 "dtc-parser.y" | ||
1878 | { | 1638 | { |
1879 | (yyval.integer) = (yyvsp[(2) - (3)].integer); | 1639 | (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32); |
1880 | ;} | 1640 | ;} |
1881 | break; | 1641 | break; |
1882 | 1642 | ||
1883 | case 38: | 1643 | case 32: |
1884 | |||
1885 | /* Line 1455 of yacc.c */ | ||
1886 | #line 356 "dtc-parser.y" | ||
1887 | { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); ;} | ||
1888 | break; | ||
1889 | |||
1890 | case 40: | ||
1891 | |||
1892 | /* Line 1455 of yacc.c */ | ||
1893 | #line 361 "dtc-parser.y" | ||
1894 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); ;} | ||
1895 | break; | ||
1896 | |||
1897 | case 42: | ||
1898 | |||
1899 | /* Line 1455 of yacc.c */ | ||
1900 | #line 366 "dtc-parser.y" | ||
1901 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); ;} | ||
1902 | break; | ||
1903 | |||
1904 | case 44: | ||
1905 | |||
1906 | /* Line 1455 of yacc.c */ | ||
1907 | #line 371 "dtc-parser.y" | ||
1908 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); ;} | ||
1909 | break; | ||
1910 | |||
1911 | case 46: | ||
1912 | |||
1913 | /* Line 1455 of yacc.c */ | ||
1914 | #line 376 "dtc-parser.y" | ||
1915 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); ;} | ||
1916 | break; | ||
1917 | |||
1918 | case 48: | ||
1919 | |||
1920 | /* Line 1455 of yacc.c */ | ||
1921 | #line 381 "dtc-parser.y" | ||
1922 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); ;} | ||
1923 | break; | ||
1924 | |||
1925 | case 50: | ||
1926 | |||
1927 | /* Line 1455 of yacc.c */ | ||
1928 | #line 386 "dtc-parser.y" | ||
1929 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); ;} | ||
1930 | break; | ||
1931 | |||
1932 | case 51: | ||
1933 | |||
1934 | /* Line 1455 of yacc.c */ | ||
1935 | #line 387 "dtc-parser.y" | ||
1936 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); ;} | ||
1937 | break; | ||
1938 | |||
1939 | case 53: | ||
1940 | |||
1941 | /* Line 1455 of yacc.c */ | ||
1942 | #line 392 "dtc-parser.y" | ||
1943 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); ;} | ||
1944 | break; | ||
1945 | |||
1946 | case 54: | ||
1947 | |||
1948 | /* Line 1455 of yacc.c */ | ||
1949 | #line 393 "dtc-parser.y" | ||
1950 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); ;} | ||
1951 | break; | ||
1952 | |||
1953 | case 55: | ||
1954 | |||
1955 | /* Line 1455 of yacc.c */ | ||
1956 | #line 394 "dtc-parser.y" | ||
1957 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); ;} | ||
1958 | break; | ||
1959 | |||
1960 | case 56: | ||
1961 | |||
1962 | /* Line 1455 of yacc.c */ | ||
1963 | #line 395 "dtc-parser.y" | ||
1964 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); ;} | ||
1965 | break; | ||
1966 | |||
1967 | case 57: | ||
1968 | |||
1969 | /* Line 1455 of yacc.c */ | ||
1970 | #line 399 "dtc-parser.y" | ||
1971 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); ;} | ||
1972 | break; | ||
1973 | |||
1974 | case 58: | ||
1975 | |||
1976 | /* Line 1455 of yacc.c */ | ||
1977 | #line 400 "dtc-parser.y" | ||
1978 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); ;} | ||
1979 | break; | ||
1980 | |||
1981 | case 60: | ||
1982 | |||
1983 | /* Line 1455 of yacc.c */ | ||
1984 | #line 405 "dtc-parser.y" | ||
1985 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); ;} | ||
1986 | break; | ||
1987 | |||
1988 | case 61: | ||
1989 | |||
1990 | /* Line 1455 of yacc.c */ | ||
1991 | #line 406 "dtc-parser.y" | ||
1992 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); ;} | ||
1993 | break; | ||
1994 | |||
1995 | case 63: | ||
1996 | |||
1997 | /* Line 1455 of yacc.c */ | ||
1998 | #line 411 "dtc-parser.y" | ||
1999 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); ;} | ||
2000 | break; | ||
2001 | |||
2002 | case 64: | ||
2003 | |||
2004 | /* Line 1455 of yacc.c */ | ||
2005 | #line 412 "dtc-parser.y" | ||
2006 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); ;} | ||
2007 | break; | ||
2008 | |||
2009 | case 65: | ||
2010 | |||
2011 | /* Line 1455 of yacc.c */ | ||
2012 | #line 413 "dtc-parser.y" | ||
2013 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); ;} | ||
2014 | break; | ||
2015 | |||
2016 | case 68: | ||
2017 | |||
2018 | /* Line 1455 of yacc.c */ | ||
2019 | #line 419 "dtc-parser.y" | ||
2020 | { (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;} | ||
2021 | break; | ||
2022 | |||
2023 | case 69: | ||
2024 | |||
2025 | /* Line 1455 of yacc.c */ | ||
2026 | #line 420 "dtc-parser.y" | ||
2027 | { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); ;} | ||
2028 | break; | ||
2029 | |||
2030 | case 70: | ||
2031 | |||
2032 | /* Line 1455 of yacc.c */ | ||
2033 | #line 421 "dtc-parser.y" | ||
2034 | { (yyval.integer) = !(yyvsp[(2) - (2)].integer); ;} | ||
2035 | break; | ||
2036 | |||
2037 | case 71: | ||
2038 | 1644 | ||
2039 | /* Line 1455 of yacc.c */ | ||
2040 | #line 426 "dtc-parser.y" | ||
2041 | { | 1645 | { |
2042 | (yyval.data) = empty_data; | 1646 | (yyval.data) = empty_data; |
2043 | ;} | 1647 | ;} |
2044 | break; | 1648 | break; |
2045 | 1649 | ||
2046 | case 72: | 1650 | case 33: |
2047 | 1651 | ||
2048 | /* Line 1455 of yacc.c */ | ||
2049 | #line 430 "dtc-parser.y" | ||
2050 | { | 1652 | { |
2051 | (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); | 1653 | (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); |
2052 | ;} | 1654 | ;} |
2053 | break; | 1655 | break; |
2054 | 1656 | ||
2055 | case 73: | 1657 | case 34: |
2056 | 1658 | ||
2057 | /* Line 1455 of yacc.c */ | ||
2058 | #line 434 "dtc-parser.y" | ||
2059 | { | 1659 | { |
2060 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); | 1660 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
2061 | ;} | 1661 | ;} |
2062 | break; | 1662 | break; |
2063 | 1663 | ||
2064 | case 74: | 1664 | case 35: |
2065 | 1665 | ||
2066 | /* Line 1455 of yacc.c */ | ||
2067 | #line 441 "dtc-parser.y" | ||
2068 | { | 1666 | { |
2069 | (yyval.nodelist) = NULL; | 1667 | (yyval.nodelist) = NULL; |
2070 | ;} | 1668 | ;} |
2071 | break; | 1669 | break; |
2072 | 1670 | ||
2073 | case 75: | 1671 | case 36: |
2074 | 1672 | ||
2075 | /* Line 1455 of yacc.c */ | ||
2076 | #line 445 "dtc-parser.y" | ||
2077 | { | 1673 | { |
2078 | (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); | 1674 | (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); |
2079 | ;} | 1675 | ;} |
2080 | break; | 1676 | break; |
2081 | 1677 | ||
2082 | case 76: | 1678 | case 37: |
2083 | 1679 | ||
2084 | /* Line 1455 of yacc.c */ | ||
2085 | #line 449 "dtc-parser.y" | ||
2086 | { | 1680 | { |
2087 | print_error("syntax error: properties must precede subnodes"); | 1681 | print_error("syntax error: properties must precede subnodes"); |
2088 | YYERROR; | 1682 | YYERROR; |
2089 | ;} | 1683 | ;} |
2090 | break; | 1684 | break; |
2091 | 1685 | ||
2092 | case 77: | 1686 | case 38: |
2093 | 1687 | ||
2094 | /* Line 1455 of yacc.c */ | ||
2095 | #line 457 "dtc-parser.y" | ||
2096 | { | 1688 | { |
2097 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); | 1689 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); |
2098 | ;} | 1690 | ;} |
2099 | break; | 1691 | break; |
2100 | 1692 | ||
2101 | case 78: | 1693 | case 39: |
2102 | |||
2103 | /* Line 1455 of yacc.c */ | ||
2104 | #line 461 "dtc-parser.y" | ||
2105 | { | ||
2106 | (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); | ||
2107 | ;} | ||
2108 | break; | ||
2109 | |||
2110 | case 79: | ||
2111 | 1694 | ||
2112 | /* Line 1455 of yacc.c */ | ||
2113 | #line 465 "dtc-parser.y" | ||
2114 | { | 1695 | { |
2115 | add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); | 1696 | add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); |
2116 | (yyval.node) = (yyvsp[(2) - (2)].node); | 1697 | (yyval.node) = (yyvsp[(2) - (2)].node); |
@@ -2119,8 +1700,6 @@ yyreduce: | |||
2119 | 1700 | ||
2120 | 1701 | ||
2121 | 1702 | ||
2122 | /* Line 1455 of yacc.c */ | ||
2123 | #line 2124 "dtc-parser.tab.c" | ||
2124 | default: break; | 1703 | default: break; |
2125 | } | 1704 | } |
2126 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); | 1705 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
@@ -2331,8 +1910,6 @@ yyreturn: | |||
2331 | 1910 | ||
2332 | 1911 | ||
2333 | 1912 | ||
2334 | /* Line 1675 of yacc.c */ | ||
2335 | #line 471 "dtc-parser.y" | ||
2336 | 1913 | ||
2337 | 1914 | ||
2338 | void print_error(char const *fmt, ...) | 1915 | void print_error(char const *fmt, ...) |
@@ -2357,12 +1934,9 @@ static unsigned long long eval_literal(const char *s, int base, int bits) | |||
2357 | 1934 | ||
2358 | errno = 0; | 1935 | errno = 0; |
2359 | val = strtoull(s, &e, base); | 1936 | val = strtoull(s, &e, base); |
2360 | if (*e) { | 1937 | if (*e) |
2361 | size_t uls = strspn(e, "UL"); | 1938 | print_error("bad characters in literal"); |
2362 | if (e[uls]) | 1939 | else if ((errno == ERANGE) |
2363 | print_error("bad characters in literal"); | ||
2364 | } | ||
2365 | if ((errno == ERANGE) | ||
2366 | || ((bits < 64) && (val >= (1ULL << bits)))) | 1940 | || ((bits < 64) && (val >= (1ULL << bits)))) |
2367 | print_error("literal out of range"); | 1941 | print_error("literal out of range"); |
2368 | else if (errno != 0) | 1942 | else if (errno != 0) |
@@ -2370,29 +1944,3 @@ static unsigned long long eval_literal(const char *s, int base, int bits) | |||
2370 | return val; | 1944 | return val; |
2371 | } | 1945 | } |
2372 | 1946 | ||
2373 | static unsigned char eval_char_literal(const char *s) | ||
2374 | { | ||
2375 | int i = 1; | ||
2376 | char c = s[0]; | ||
2377 | |||
2378 | if (c == '\0') | ||
2379 | { | ||
2380 | print_error("empty character literal"); | ||
2381 | return 0; | ||
2382 | } | ||
2383 | |||
2384 | /* | ||
2385 | * If the first character in the character literal is a \ then process | ||
2386 | * the remaining characters as an escape encoding. If the first | ||
2387 | * character is neither an escape or a terminator it should be the only | ||
2388 | * character in the literal and will be returned. | ||
2389 | */ | ||
2390 | if (c == '\\') | ||
2391 | c = get_escape_char(s, &i); | ||
2392 | |||
2393 | if (s[i] != '\0') | ||
2394 | print_error("malformed character literal"); | ||
2395 | |||
2396 | return c; | ||
2397 | } | ||
2398 | |||
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped index 9d2dce41211..4ee682bb7d3 100644 --- a/scripts/dtc/dtc-parser.tab.h_shipped +++ b/scripts/dtc/dtc-parser.tab.h_shipped | |||
@@ -1,10 +1,9 @@ | |||
1 | 1 | /* A Bison parser, made by GNU Bison 2.4.3. */ | |
2 | /* A Bison parser, made by GNU Bison 2.4.1. */ | ||
3 | 2 | ||
4 | /* Skeleton interface for Bison's Yacc-like parsers in C | 3 | /* Skeleton interface for Bison's Yacc-like parsers in C |
5 | 4 | ||
6 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | 5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
7 | Free Software Foundation, Inc. | 6 | 2009, 2010 Free Software Foundation, Inc. |
8 | 7 | ||
9 | This program is free software: you can redistribute it and/or modify | 8 | This program is free software: you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
@@ -41,26 +40,14 @@ | |||
41 | enum yytokentype { | 40 | enum yytokentype { |
42 | DT_V1 = 258, | 41 | DT_V1 = 258, |
43 | DT_MEMRESERVE = 259, | 42 | DT_MEMRESERVE = 259, |
44 | DT_LSHIFT = 260, | 43 | DT_PROPNODENAME = 260, |
45 | DT_RSHIFT = 261, | 44 | DT_LITERAL = 261, |
46 | DT_LE = 262, | 45 | DT_BASE = 262, |
47 | DT_GE = 263, | 46 | DT_BYTE = 263, |
48 | DT_EQ = 264, | 47 | DT_STRING = 264, |
49 | DT_NE = 265, | 48 | DT_LABEL = 265, |
50 | DT_AND = 266, | 49 | DT_REF = 266, |
51 | DT_OR = 267, | 50 | DT_INCBIN = 267 |
52 | DT_BITS = 268, | ||
53 | DT_DEL_PROP = 269, | ||
54 | DT_DEL_NODE = 270, | ||
55 | DT_PROPNODENAME = 271, | ||
56 | DT_LITERAL = 272, | ||
57 | DT_CHAR_LITERAL = 273, | ||
58 | DT_BASE = 274, | ||
59 | DT_BYTE = 275, | ||
60 | DT_STRING = 276, | ||
61 | DT_LABEL = 277, | ||
62 | DT_REF = 278, | ||
63 | DT_INCBIN = 279 | ||
64 | }; | 51 | }; |
65 | #endif | 52 | #endif |
66 | 53 | ||
@@ -70,8 +57,6 @@ | |||
70 | typedef union YYSTYPE | 57 | typedef union YYSTYPE |
71 | { | 58 | { |
72 | 59 | ||
73 | /* Line 1676 of yacc.c */ | ||
74 | #line 40 "dtc-parser.y" | ||
75 | 60 | ||
76 | char *propnodename; | 61 | char *propnodename; |
77 | char *literal; | 62 | char *literal; |
@@ -80,22 +65,16 @@ typedef union YYSTYPE | |||
80 | uint8_t byte; | 65 | uint8_t byte; |
81 | struct data data; | 66 | struct data data; |
82 | 67 | ||
83 | struct { | 68 | uint64_t addr; |
84 | struct data data; | 69 | cell_t cell; |
85 | int bits; | ||
86 | } array; | ||
87 | |||
88 | struct property *prop; | 70 | struct property *prop; |
89 | struct property *proplist; | 71 | struct property *proplist; |
90 | struct node *node; | 72 | struct node *node; |
91 | struct node *nodelist; | 73 | struct node *nodelist; |
92 | struct reserve_info *re; | 74 | struct reserve_info *re; |
93 | uint64_t integer; | ||
94 | 75 | ||
95 | 76 | ||
96 | 77 | ||
97 | /* Line 1676 of yacc.c */ | ||
98 | #line 99 "dtc-parser.tab.h" | ||
99 | } YYSTYPE; | 78 | } YYSTYPE; |
100 | # define YYSTYPE_IS_TRIVIAL 1 | 79 | # define YYSTYPE_IS_TRIVIAL 1 |
101 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | 80 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y index f412460f94d..5e84a67fc1d 100644 --- a/scripts/dtc/dtc-parser.y +++ b/scripts/dtc/dtc-parser.y | |||
@@ -34,7 +34,6 @@ extern struct boot_info *the_boot_info; | |||
34 | extern int treesource_error; | 34 | extern int treesource_error; |
35 | 35 | ||
36 | static unsigned long long eval_literal(const char *s, int base, int bits); | 36 | static unsigned long long eval_literal(const char *s, int base, int bits); |
37 | static unsigned char eval_char_literal(const char *s); | ||
38 | %} | 37 | %} |
39 | 38 | ||
40 | %union { | 39 | %union { |
@@ -45,28 +44,19 @@ static unsigned char eval_char_literal(const char *s); | |||
45 | uint8_t byte; | 44 | uint8_t byte; |
46 | struct data data; | 45 | struct data data; |
47 | 46 | ||
48 | struct { | 47 | uint64_t addr; |
49 | struct data data; | 48 | cell_t cell; |
50 | int bits; | ||
51 | } array; | ||
52 | |||
53 | struct property *prop; | 49 | struct property *prop; |
54 | struct property *proplist; | 50 | struct property *proplist; |
55 | struct node *node; | 51 | struct node *node; |
56 | struct node *nodelist; | 52 | struct node *nodelist; |
57 | struct reserve_info *re; | 53 | struct reserve_info *re; |
58 | uint64_t integer; | ||
59 | } | 54 | } |
60 | 55 | ||
61 | %token DT_V1 | 56 | %token DT_V1 |
62 | %token DT_MEMRESERVE | 57 | %token DT_MEMRESERVE |
63 | %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR | ||
64 | %token DT_BITS | ||
65 | %token DT_DEL_PROP | ||
66 | %token DT_DEL_NODE | ||
67 | %token <propnodename> DT_PROPNODENAME | 58 | %token <propnodename> DT_PROPNODENAME |
68 | %token <literal> DT_LITERAL | 59 | %token <literal> DT_LITERAL |
69 | %token <literal> DT_CHAR_LITERAL | ||
70 | %token <cbase> DT_BASE | 60 | %token <cbase> DT_BASE |
71 | %token <byte> DT_BYTE | 61 | %token <byte> DT_BYTE |
72 | %token <data> DT_STRING | 62 | %token <data> DT_STRING |
@@ -78,7 +68,9 @@ static unsigned char eval_char_literal(const char *s); | |||
78 | %type <data> propdataprefix | 68 | %type <data> propdataprefix |
79 | %type <re> memreserve | 69 | %type <re> memreserve |
80 | %type <re> memreserves | 70 | %type <re> memreserves |
81 | %type <array> arrayprefix | 71 | %type <addr> addr |
72 | %type <data> celllist | ||
73 | %type <cell> cellval | ||
82 | %type <data> bytestring | 74 | %type <data> bytestring |
83 | %type <prop> propdef | 75 | %type <prop> propdef |
84 | %type <proplist> proplist | 76 | %type <proplist> proplist |
@@ -88,21 +80,6 @@ static unsigned char eval_char_literal(const char *s); | |||
88 | %type <node> subnode | 80 | %type <node> subnode |
89 | %type <nodelist> subnodes | 81 | %type <nodelist> subnodes |
90 | 82 | ||
91 | %type <integer> integer_prim | ||
92 | %type <integer> integer_unary | ||
93 | %type <integer> integer_mul | ||
94 | %type <integer> integer_add | ||
95 | %type <integer> integer_shift | ||
96 | %type <integer> integer_rela | ||
97 | %type <integer> integer_eq | ||
98 | %type <integer> integer_bitand | ||
99 | %type <integer> integer_bitxor | ||
100 | %type <integer> integer_bitor | ||
101 | %type <integer> integer_and | ||
102 | %type <integer> integer_or | ||
103 | %type <integer> integer_trinary | ||
104 | %type <integer> integer_expr | ||
105 | |||
106 | %% | 83 | %% |
107 | 84 | ||
108 | sourcefile: | 85 | sourcefile: |
@@ -125,7 +102,7 @@ memreserves: | |||
125 | ; | 102 | ; |
126 | 103 | ||
127 | memreserve: | 104 | memreserve: |
128 | DT_MEMRESERVE integer_prim integer_prim ';' | 105 | DT_MEMRESERVE addr addr ';' |
129 | { | 106 | { |
130 | $$ = build_reserve_entry($2, $3); | 107 | $$ = build_reserve_entry($2, $3); |
131 | } | 108 | } |
@@ -136,6 +113,13 @@ memreserve: | |||
136 | } | 113 | } |
137 | ; | 114 | ; |
138 | 115 | ||
116 | addr: | ||
117 | DT_LITERAL | ||
118 | { | ||
119 | $$ = eval_literal($1, 0, 64); | ||
120 | } | ||
121 | ; | ||
122 | |||
139 | devicetree: | 123 | devicetree: |
140 | '/' nodedef | 124 | '/' nodedef |
141 | { | 125 | { |
@@ -155,17 +139,6 @@ devicetree: | |||
155 | print_error("label or path, '%s', not found", $2); | 139 | print_error("label or path, '%s', not found", $2); |
156 | $$ = $1; | 140 | $$ = $1; |
157 | } | 141 | } |
158 | | devicetree DT_DEL_NODE DT_REF ';' | ||
159 | { | ||
160 | struct node *target = get_node_by_ref($1, $3); | ||
161 | |||
162 | if (!target) | ||
163 | print_error("label or path, '%s', not found", $3); | ||
164 | else | ||
165 | delete_node(target); | ||
166 | |||
167 | $$ = $1; | ||
168 | } | ||
169 | ; | 142 | ; |
170 | 143 | ||
171 | nodedef: | 144 | nodedef: |
@@ -195,10 +168,6 @@ propdef: | |||
195 | { | 168 | { |
196 | $$ = build_property($1, empty_data); | 169 | $$ = build_property($1, empty_data); |
197 | } | 170 | } |
198 | | DT_DEL_PROP DT_PROPNODENAME ';' | ||
199 | { | ||
200 | $$ = build_property_delete($2); | ||
201 | } | ||
202 | | DT_LABEL propdef | 171 | | DT_LABEL propdef |
203 | { | 172 | { |
204 | add_label(&$2->labels, $1); | 173 | add_label(&$2->labels, $1); |
@@ -211,9 +180,9 @@ propdata: | |||
211 | { | 180 | { |
212 | $$ = data_merge($1, $2); | 181 | $$ = data_merge($1, $2); |
213 | } | 182 | } |
214 | | propdataprefix arrayprefix '>' | 183 | | propdataprefix '<' celllist '>' |
215 | { | 184 | { |
216 | $$ = data_merge($1, $2.data); | 185 | $$ = data_merge($1, $3); |
217 | } | 186 | } |
218 | | propdataprefix '[' bytestring ']' | 187 | | propdataprefix '[' bytestring ']' |
219 | { | 188 | { |
@@ -223,7 +192,7 @@ propdata: | |||
223 | { | 192 | { |
224 | $$ = data_add_marker($1, REF_PATH, $2); | 193 | $$ = data_add_marker($1, REF_PATH, $2); |
225 | } | 194 | } |
226 | | propdataprefix DT_INCBIN '(' DT_STRING ',' integer_prim ',' integer_prim ')' | 195 | | propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')' |
227 | { | 196 | { |
228 | FILE *f = srcfile_relative_open($4.val, NULL); | 197 | FILE *f = srcfile_relative_open($4.val, NULL); |
229 | struct data d; | 198 | struct data d; |
@@ -271,154 +240,31 @@ propdataprefix: | |||
271 | } | 240 | } |
272 | ; | 241 | ; |
273 | 242 | ||
274 | arrayprefix: | 243 | celllist: |
275 | DT_BITS DT_LITERAL '<' | 244 | /* empty */ |
276 | { | ||
277 | $$.data = empty_data; | ||
278 | $$.bits = eval_literal($2, 0, 7); | ||
279 | |||
280 | if (($$.bits != 8) && | ||
281 | ($$.bits != 16) && | ||
282 | ($$.bits != 32) && | ||
283 | ($$.bits != 64)) | ||
284 | { | ||
285 | print_error("Only 8, 16, 32 and 64-bit elements" | ||
286 | " are currently supported"); | ||
287 | $$.bits = 32; | ||
288 | } | ||
289 | } | ||
290 | | '<' | ||
291 | { | ||
292 | $$.data = empty_data; | ||
293 | $$.bits = 32; | ||
294 | } | ||
295 | | arrayprefix integer_prim | ||
296 | { | ||
297 | if ($1.bits < 64) { | ||
298 | uint64_t mask = (1ULL << $1.bits) - 1; | ||
299 | /* | ||
300 | * Bits above mask must either be all zero | ||
301 | * (positive within range of mask) or all one | ||
302 | * (negative and sign-extended). The second | ||
303 | * condition is true if when we set all bits | ||
304 | * within the mask to one (i.e. | in the | ||
305 | * mask), all bits are one. | ||
306 | */ | ||
307 | if (($2 > mask) && (($2 | mask) != -1ULL)) | ||
308 | print_error( | ||
309 | "integer value out of range " | ||
310 | "%016lx (%d bits)", $1.bits); | ||
311 | } | ||
312 | |||
313 | $$.data = data_append_integer($1.data, $2, $1.bits); | ||
314 | } | ||
315 | | arrayprefix DT_REF | ||
316 | { | ||
317 | uint64_t val = ~0ULL >> (64 - $1.bits); | ||
318 | |||
319 | if ($1.bits == 32) | ||
320 | $1.data = data_add_marker($1.data, | ||
321 | REF_PHANDLE, | ||
322 | $2); | ||
323 | else | ||
324 | print_error("References are only allowed in " | ||
325 | "arrays with 32-bit elements."); | ||
326 | |||
327 | $$.data = data_append_integer($1.data, val, $1.bits); | ||
328 | } | ||
329 | | arrayprefix DT_LABEL | ||
330 | { | 245 | { |
331 | $$.data = data_add_marker($1.data, LABEL, $2); | 246 | $$ = empty_data; |
332 | } | 247 | } |
333 | ; | 248 | | celllist cellval |
334 | |||
335 | integer_prim: | ||
336 | DT_LITERAL | ||
337 | { | 249 | { |
338 | $$ = eval_literal($1, 0, 64); | 250 | $$ = data_append_cell($1, $2); |
339 | } | 251 | } |
340 | | DT_CHAR_LITERAL | 252 | | celllist DT_REF |
341 | { | 253 | { |
342 | $$ = eval_char_literal($1); | 254 | $$ = data_append_cell(data_add_marker($1, REF_PHANDLE, |
255 | $2), -1); | ||
343 | } | 256 | } |
344 | | '(' integer_expr ')' | 257 | | celllist DT_LABEL |
345 | { | 258 | { |
346 | $$ = $2; | 259 | $$ = data_add_marker($1, LABEL, $2); |
347 | } | 260 | } |
348 | ; | 261 | ; |
349 | 262 | ||
350 | integer_expr: | 263 | cellval: |
351 | integer_trinary | 264 | DT_LITERAL |
352 | ; | 265 | { |
353 | 266 | $$ = eval_literal($1, 0, 32); | |
354 | integer_trinary: | 267 | } |
355 | integer_or | ||
356 | | integer_or '?' integer_expr ':' integer_trinary { $$ = $1 ? $3 : $5; } | ||
357 | ; | ||
358 | |||
359 | integer_or: | ||
360 | integer_and | ||
361 | | integer_or DT_OR integer_and { $$ = $1 || $3; } | ||
362 | ; | ||
363 | |||
364 | integer_and: | ||
365 | integer_bitor | ||
366 | | integer_and DT_AND integer_bitor { $$ = $1 && $3; } | ||
367 | ; | ||
368 | |||
369 | integer_bitor: | ||
370 | integer_bitxor | ||
371 | | integer_bitor '|' integer_bitxor { $$ = $1 | $3; } | ||
372 | ; | ||
373 | |||
374 | integer_bitxor: | ||
375 | integer_bitand | ||
376 | | integer_bitxor '^' integer_bitand { $$ = $1 ^ $3; } | ||
377 | ; | ||
378 | |||
379 | integer_bitand: | ||
380 | integer_eq | ||
381 | | integer_bitand '&' integer_eq { $$ = $1 & $3; } | ||
382 | ; | ||
383 | |||
384 | integer_eq: | ||
385 | integer_rela | ||
386 | | integer_eq DT_EQ integer_rela { $$ = $1 == $3; } | ||
387 | | integer_eq DT_NE integer_rela { $$ = $1 != $3; } | ||
388 | ; | ||
389 | |||
390 | integer_rela: | ||
391 | integer_shift | ||
392 | | integer_rela '<' integer_shift { $$ = $1 < $3; } | ||
393 | | integer_rela '>' integer_shift { $$ = $1 > $3; } | ||
394 | | integer_rela DT_LE integer_shift { $$ = $1 <= $3; } | ||
395 | | integer_rela DT_GE integer_shift { $$ = $1 >= $3; } | ||
396 | ; | ||
397 | |||
398 | integer_shift: | ||
399 | integer_shift DT_LSHIFT integer_add { $$ = $1 << $3; } | ||
400 | | integer_shift DT_RSHIFT integer_add { $$ = $1 >> $3; } | ||
401 | | integer_add | ||
402 | ; | ||
403 | |||
404 | integer_add: | ||
405 | integer_add '+' integer_mul { $$ = $1 + $3; } | ||
406 | | integer_add '-' integer_mul { $$ = $1 - $3; } | ||
407 | | integer_mul | ||
408 | ; | ||
409 | |||
410 | integer_mul: | ||
411 | integer_mul '*' integer_unary { $$ = $1 * $3; } | ||
412 | | integer_mul '/' integer_unary { $$ = $1 / $3; } | ||
413 | | integer_mul '%' integer_unary { $$ = $1 % $3; } | ||
414 | | integer_unary | ||
415 | ; | ||
416 | |||
417 | integer_unary: | ||
418 | integer_prim | ||
419 | | '-' integer_unary { $$ = -$2; } | ||
420 | | '~' integer_unary { $$ = ~$2; } | ||
421 | | '!' integer_unary { $$ = !$2; } | ||
422 | ; | 268 | ; |
423 | 269 | ||
424 | bytestring: | 270 | bytestring: |
@@ -457,10 +303,6 @@ subnode: | |||
457 | { | 303 | { |
458 | $$ = name_node($2, $1); | 304 | $$ = name_node($2, $1); |
459 | } | 305 | } |
460 | | DT_DEL_NODE DT_PROPNODENAME ';' | ||
461 | { | ||
462 | $$ = name_node(build_node_delete(), $2); | ||
463 | } | ||
464 | | DT_LABEL subnode | 306 | | DT_LABEL subnode |
465 | { | 307 | { |
466 | add_label(&$2->labels, $1); | 308 | add_label(&$2->labels, $1); |
@@ -492,41 +334,12 @@ static unsigned long long eval_literal(const char *s, int base, int bits) | |||
492 | 334 | ||
493 | errno = 0; | 335 | errno = 0; |
494 | val = strtoull(s, &e, base); | 336 | val = strtoull(s, &e, base); |
495 | if (*e) { | 337 | if (*e) |
496 | size_t uls = strspn(e, "UL"); | 338 | print_error("bad characters in literal"); |
497 | if (e[uls]) | 339 | else if ((errno == ERANGE) |
498 | print_error("bad characters in literal"); | ||
499 | } | ||
500 | if ((errno == ERANGE) | ||
501 | || ((bits < 64) && (val >= (1ULL << bits)))) | 340 | || ((bits < 64) && (val >= (1ULL << bits)))) |
502 | print_error("literal out of range"); | 341 | print_error("literal out of range"); |
503 | else if (errno != 0) | 342 | else if (errno != 0) |
504 | print_error("bad literal"); | 343 | print_error("bad literal"); |
505 | return val; | 344 | return val; |
506 | } | 345 | } |
507 | |||
508 | static unsigned char eval_char_literal(const char *s) | ||
509 | { | ||
510 | int i = 1; | ||
511 | char c = s[0]; | ||
512 | |||
513 | if (c == '\0') | ||
514 | { | ||
515 | print_error("empty character literal"); | ||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | /* | ||
520 | * If the first character in the character literal is a \ then process | ||
521 | * the remaining characters as an escape encoding. If the first | ||
522 | * character is neither an escape or a terminator it should be the only | ||
523 | * character in the literal and will be returned. | ||
524 | */ | ||
525 | if (c == '\\') | ||
526 | c = get_escape_char(s, &i); | ||
527 | |||
528 | if (s[i] != '\0') | ||
529 | print_error("malformed character literal"); | ||
530 | |||
531 | return c; | ||
532 | } | ||
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c index a375683c153..cbc0193098e 100644 --- a/scripts/dtc/dtc.c +++ b/scripts/dtc/dtc.c | |||
@@ -71,7 +71,6 @@ static void __attribute__ ((noreturn)) usage(void) | |||
71 | fprintf(stderr, "\t\t\tasm - assembler source\n"); | 71 | fprintf(stderr, "\t\t\tasm - assembler source\n"); |
72 | fprintf(stderr, "\t-V <output version>\n"); | 72 | fprintf(stderr, "\t-V <output version>\n"); |
73 | fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); | 73 | fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); |
74 | fprintf(stderr, "\t-d <output dependency file>\n"); | ||
75 | fprintf(stderr, "\t-R <number>\n"); | 74 | fprintf(stderr, "\t-R <number>\n"); |
76 | fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n"); | 75 | fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n"); |
77 | fprintf(stderr, "\t-S <bytes>\n"); | 76 | fprintf(stderr, "\t-S <bytes>\n"); |
@@ -82,8 +81,6 @@ static void __attribute__ ((noreturn)) usage(void) | |||
82 | fprintf(stderr, "\t\tSet the physical boot cpu\n"); | 81 | fprintf(stderr, "\t\tSet the physical boot cpu\n"); |
83 | fprintf(stderr, "\t-f\n"); | 82 | fprintf(stderr, "\t-f\n"); |
84 | fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); | 83 | fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); |
85 | fprintf(stderr, "\t-i\n"); | ||
86 | fprintf(stderr, "\t\tAdd a path to search for include files\n"); | ||
87 | fprintf(stderr, "\t-s\n"); | 84 | fprintf(stderr, "\t-s\n"); |
88 | fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n"); | 85 | fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n"); |
89 | fprintf(stderr, "\t-v\n"); | 86 | fprintf(stderr, "\t-v\n"); |
@@ -93,9 +90,6 @@ static void __attribute__ ((noreturn)) usage(void) | |||
93 | fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n"); | 90 | fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n"); |
94 | fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n"); | 91 | fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n"); |
95 | fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n"); | 92 | fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n"); |
96 | fprintf(stderr, "\t-W [no-]<checkname>\n"); | ||
97 | fprintf(stderr, "\t-E [no-]<checkname>\n"); | ||
98 | fprintf(stderr, "\t\t\tenable or disable warnings and errors\n"); | ||
99 | exit(3); | 93 | exit(3); |
100 | } | 94 | } |
101 | 95 | ||
@@ -105,8 +99,7 @@ int main(int argc, char *argv[]) | |||
105 | const char *inform = "dts"; | 99 | const char *inform = "dts"; |
106 | const char *outform = "dts"; | 100 | const char *outform = "dts"; |
107 | const char *outname = "-"; | 101 | const char *outname = "-"; |
108 | const char *depname = NULL; | 102 | int force = 0, check = 0, sort = 0; |
109 | int force = 0, sort = 0; | ||
110 | const char *arg; | 103 | const char *arg; |
111 | int opt; | 104 | int opt; |
112 | FILE *outf = NULL; | 105 | FILE *outf = NULL; |
@@ -118,8 +111,7 @@ int main(int argc, char *argv[]) | |||
118 | minsize = 0; | 111 | minsize = 0; |
119 | padsize = 0; | 112 | padsize = 0; |
120 | 113 | ||
121 | while ((opt = getopt(argc, argv, "hI:O:o:V:d:R:S:p:fqb:i:vH:sW:E:")) | 114 | while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) { |
122 | != EOF) { | ||
123 | switch (opt) { | 115 | switch (opt) { |
124 | case 'I': | 116 | case 'I': |
125 | inform = optarg; | 117 | inform = optarg; |
@@ -133,9 +125,6 @@ int main(int argc, char *argv[]) | |||
133 | case 'V': | 125 | case 'V': |
134 | outversion = strtol(optarg, NULL, 0); | 126 | outversion = strtol(optarg, NULL, 0); |
135 | break; | 127 | break; |
136 | case 'd': | ||
137 | depname = optarg; | ||
138 | break; | ||
139 | case 'R': | 128 | case 'R': |
140 | reservenum = strtol(optarg, NULL, 0); | 129 | reservenum = strtol(optarg, NULL, 0); |
141 | break; | 130 | break; |
@@ -148,15 +137,15 @@ int main(int argc, char *argv[]) | |||
148 | case 'f': | 137 | case 'f': |
149 | force = 1; | 138 | force = 1; |
150 | break; | 139 | break; |
140 | case 'c': | ||
141 | check = 1; | ||
142 | break; | ||
151 | case 'q': | 143 | case 'q': |
152 | quiet++; | 144 | quiet++; |
153 | break; | 145 | break; |
154 | case 'b': | 146 | case 'b': |
155 | cmdline_boot_cpuid = strtoll(optarg, NULL, 0); | 147 | cmdline_boot_cpuid = strtoll(optarg, NULL, 0); |
156 | break; | 148 | break; |
157 | case 'i': | ||
158 | srcfile_add_search_path(optarg); | ||
159 | break; | ||
160 | case 'v': | 149 | case 'v': |
161 | printf("Version: %s\n", DTC_VERSION); | 150 | printf("Version: %s\n", DTC_VERSION); |
162 | exit(0); | 151 | exit(0); |
@@ -176,14 +165,6 @@ int main(int argc, char *argv[]) | |||
176 | sort = 1; | 165 | sort = 1; |
177 | break; | 166 | break; |
178 | 167 | ||
179 | case 'W': | ||
180 | parse_checks_option(true, false, optarg); | ||
181 | break; | ||
182 | |||
183 | case 'E': | ||
184 | parse_checks_option(false, true, optarg); | ||
185 | break; | ||
186 | |||
187 | case 'h': | 168 | case 'h': |
188 | default: | 169 | default: |
189 | usage(); | 170 | usage(); |
@@ -204,13 +185,8 @@ int main(int argc, char *argv[]) | |||
204 | if (minsize) | 185 | if (minsize) |
205 | fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n"); | 186 | fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n"); |
206 | 187 | ||
207 | if (depname) { | 188 | fprintf(stderr, "DTC: %s->%s on file \"%s\"\n", |
208 | depfile = fopen(depname, "w"); | 189 | inform, outform, arg); |
209 | if (!depfile) | ||
210 | die("Couldn't open dependency file %s: %s\n", depname, | ||
211 | strerror(errno)); | ||
212 | fprintf(depfile, "%s:", outname); | ||
213 | } | ||
214 | 190 | ||
215 | if (streq(inform, "dts")) | 191 | if (streq(inform, "dts")) |
216 | bi = dt_from_source(arg); | 192 | bi = dt_from_source(arg); |
@@ -221,11 +197,6 @@ int main(int argc, char *argv[]) | |||
221 | else | 197 | else |
222 | die("Unknown input format \"%s\"\n", inform); | 198 | die("Unknown input format \"%s\"\n", inform); |
223 | 199 | ||
224 | if (depfile) { | ||
225 | fputc('\n', depfile); | ||
226 | fclose(depfile); | ||
227 | } | ||
228 | |||
229 | if (cmdline_boot_cpuid != -1) | 200 | if (cmdline_boot_cpuid != -1) |
230 | bi->boot_cpuid_phys = cmdline_boot_cpuid; | 201 | bi->boot_cpuid_phys = cmdline_boot_cpuid; |
231 | 202 | ||
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index 3e42a071070..f37c97eb3df 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <string.h> | 25 | #include <string.h> |
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <stdint.h> | 27 | #include <stdint.h> |
28 | #include <stdbool.h> | ||
29 | #include <stdarg.h> | 28 | #include <stdarg.h> |
30 | #include <assert.h> | 29 | #include <assert.h> |
31 | #include <ctype.h> | 30 | #include <ctype.h> |
@@ -110,7 +109,6 @@ struct data data_insert_at_marker(struct data d, struct marker *m, | |||
110 | const void *p, int len); | 109 | const void *p, int len); |
111 | struct data data_merge(struct data d1, struct data d2); | 110 | struct data data_merge(struct data d1, struct data d2); |
112 | struct data data_append_cell(struct data d, cell_t word); | 111 | struct data data_append_cell(struct data d, cell_t word); |
113 | struct data data_append_integer(struct data d, uint64_t word, int bits); | ||
114 | struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); | 112 | struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); |
115 | struct data data_append_addr(struct data d, uint64_t addr); | 113 | struct data data_append_addr(struct data d, uint64_t addr); |
116 | struct data data_append_byte(struct data d, uint8_t byte); | 114 | struct data data_append_byte(struct data d, uint8_t byte); |
@@ -128,13 +126,11 @@ int data_is_one_string(struct data d); | |||
128 | 126 | ||
129 | /* Live trees */ | 127 | /* Live trees */ |
130 | struct label { | 128 | struct label { |
131 | int deleted; | ||
132 | char *label; | 129 | char *label; |
133 | struct label *next; | 130 | struct label *next; |
134 | }; | 131 | }; |
135 | 132 | ||
136 | struct property { | 133 | struct property { |
137 | int deleted; | ||
138 | char *name; | 134 | char *name; |
139 | struct data val; | 135 | struct data val; |
140 | 136 | ||
@@ -144,7 +140,6 @@ struct property { | |||
144 | }; | 140 | }; |
145 | 141 | ||
146 | struct node { | 142 | struct node { |
147 | int deleted; | ||
148 | char *name; | 143 | char *name; |
149 | struct property *proplist; | 144 | struct property *proplist; |
150 | struct node *children; | 145 | struct node *children; |
@@ -161,47 +156,28 @@ struct node { | |||
161 | struct label *labels; | 156 | struct label *labels; |
162 | }; | 157 | }; |
163 | 158 | ||
164 | #define for_each_label_withdel(l0, l) \ | ||
165 | for ((l) = (l0); (l); (l) = (l)->next) | ||
166 | |||
167 | #define for_each_label(l0, l) \ | 159 | #define for_each_label(l0, l) \ |
168 | for_each_label_withdel(l0, l) \ | 160 | for ((l) = (l0); (l); (l) = (l)->next) |
169 | if (!(l)->deleted) | ||
170 | |||
171 | #define for_each_property_withdel(n, p) \ | ||
172 | for ((p) = (n)->proplist; (p); (p) = (p)->next) | ||
173 | 161 | ||
174 | #define for_each_property(n, p) \ | 162 | #define for_each_property(n, p) \ |
175 | for_each_property_withdel(n, p) \ | 163 | for ((p) = (n)->proplist; (p); (p) = (p)->next) |
176 | if (!(p)->deleted) | ||
177 | 164 | ||
178 | #define for_each_child_withdel(n, c) \ | 165 | #define for_each_child(n, c) \ |
179 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) | 166 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) |
180 | 167 | ||
181 | #define for_each_child(n, c) \ | ||
182 | for_each_child_withdel(n, c) \ | ||
183 | if (!(c)->deleted) | ||
184 | |||
185 | void add_label(struct label **labels, char *label); | 168 | void add_label(struct label **labels, char *label); |
186 | void delete_labels(struct label **labels); | ||
187 | 169 | ||
188 | struct property *build_property(char *name, struct data val); | 170 | struct property *build_property(char *name, struct data val); |
189 | struct property *build_property_delete(char *name); | ||
190 | struct property *chain_property(struct property *first, struct property *list); | 171 | struct property *chain_property(struct property *first, struct property *list); |
191 | struct property *reverse_properties(struct property *first); | 172 | struct property *reverse_properties(struct property *first); |
192 | 173 | ||
193 | struct node *build_node(struct property *proplist, struct node *children); | 174 | struct node *build_node(struct property *proplist, struct node *children); |
194 | struct node *build_node_delete(void); | ||
195 | struct node *name_node(struct node *node, char *name); | 175 | struct node *name_node(struct node *node, char *name); |
196 | struct node *chain_node(struct node *first, struct node *list); | 176 | struct node *chain_node(struct node *first, struct node *list); |
197 | struct node *merge_nodes(struct node *old_node, struct node *new_node); | 177 | struct node *merge_nodes(struct node *old_node, struct node *new_node); |
198 | 178 | ||
199 | void add_property(struct node *node, struct property *prop); | 179 | void add_property(struct node *node, struct property *prop); |
200 | void delete_property_by_name(struct node *node, char *name); | ||
201 | void delete_property(struct property *prop); | ||
202 | void add_child(struct node *parent, struct node *child); | 180 | void add_child(struct node *parent, struct node *child); |
203 | void delete_node_by_name(struct node *parent, char *name); | ||
204 | void delete_node(struct node *node); | ||
205 | 181 | ||
206 | const char *get_unitname(struct node *node); | 182 | const char *get_unitname(struct node *node); |
207 | struct property *get_property(struct node *node, const char *propname); | 183 | struct property *get_property(struct node *node, const char *propname); |
@@ -248,7 +224,6 @@ void sort_tree(struct boot_info *bi); | |||
248 | 224 | ||
249 | /* Checks */ | 225 | /* Checks */ |
250 | 226 | ||
251 | void parse_checks_option(bool warn, bool error, const char *optarg); | ||
252 | void process_checks(int force, struct boot_info *bi); | 227 | void process_checks(int force, struct boot_info *bi); |
253 | 228 | ||
254 | /* Flattened trees */ | 229 | /* Flattened trees */ |
diff --git a/scripts/dtc/fdtdump.c b/scripts/dtc/fdtdump.c deleted file mode 100644 index 207a46d6486..00000000000 --- a/scripts/dtc/fdtdump.c +++ /dev/null | |||
@@ -1,162 +0,0 @@ | |||
1 | /* | ||
2 | * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com> | ||
3 | */ | ||
4 | |||
5 | #include <stdint.h> | ||
6 | #include <stdio.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <string.h> | ||
9 | #include <ctype.h> | ||
10 | |||
11 | #include <fdt.h> | ||
12 | #include <libfdt_env.h> | ||
13 | |||
14 | #include "util.h" | ||
15 | |||
16 | #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) | ||
17 | #define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) | ||
18 | #define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) | ||
19 | |||
20 | static void print_data(const char *data, int len) | ||
21 | { | ||
22 | int i; | ||
23 | const char *p = data; | ||
24 | |||
25 | /* no data, don't print */ | ||
26 | if (len == 0) | ||
27 | return; | ||
28 | |||
29 | if (util_is_printable_string(data, len)) { | ||
30 | printf(" = \"%s\"", (const char *)data); | ||
31 | } else if ((len % 4) == 0) { | ||
32 | printf(" = <"); | ||
33 | for (i = 0; i < len; i += 4) | ||
34 | printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)), | ||
35 | i < (len - 4) ? " " : ""); | ||
36 | printf(">"); | ||
37 | } else { | ||
38 | printf(" = ["); | ||
39 | for (i = 0; i < len; i++) | ||
40 | printf("%02x%s", *p++, i < len - 1 ? " " : ""); | ||
41 | printf("]"); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | static void dump_blob(void *blob) | ||
46 | { | ||
47 | struct fdt_header *bph = blob; | ||
48 | uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap); | ||
49 | uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct); | ||
50 | uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings); | ||
51 | struct fdt_reserve_entry *p_rsvmap = | ||
52 | (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap); | ||
53 | const char *p_struct = (const char *)blob + off_dt; | ||
54 | const char *p_strings = (const char *)blob + off_str; | ||
55 | uint32_t version = fdt32_to_cpu(bph->version); | ||
56 | uint32_t totalsize = fdt32_to_cpu(bph->totalsize); | ||
57 | uint32_t tag; | ||
58 | const char *p, *s, *t; | ||
59 | int depth, sz, shift; | ||
60 | int i; | ||
61 | uint64_t addr, size; | ||
62 | |||
63 | depth = 0; | ||
64 | shift = 4; | ||
65 | |||
66 | printf("/dts-v1/;\n"); | ||
67 | printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic)); | ||
68 | printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize); | ||
69 | printf("// off_dt_struct:\t0x%x\n", off_dt); | ||
70 | printf("// off_dt_strings:\t0x%x\n", off_str); | ||
71 | printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap); | ||
72 | printf("// version:\t\t%d\n", version); | ||
73 | printf("// last_comp_version:\t%d\n", | ||
74 | fdt32_to_cpu(bph->last_comp_version)); | ||
75 | if (version >= 2) | ||
76 | printf("// boot_cpuid_phys:\t0x%x\n", | ||
77 | fdt32_to_cpu(bph->boot_cpuid_phys)); | ||
78 | |||
79 | if (version >= 3) | ||
80 | printf("// size_dt_strings:\t0x%x\n", | ||
81 | fdt32_to_cpu(bph->size_dt_strings)); | ||
82 | if (version >= 17) | ||
83 | printf("// size_dt_struct:\t0x%x\n", | ||
84 | fdt32_to_cpu(bph->size_dt_struct)); | ||
85 | printf("\n"); | ||
86 | |||
87 | for (i = 0; ; i++) { | ||
88 | addr = fdt64_to_cpu(p_rsvmap[i].address); | ||
89 | size = fdt64_to_cpu(p_rsvmap[i].size); | ||
90 | if (addr == 0 && size == 0) | ||
91 | break; | ||
92 | |||
93 | printf("/memreserve/ %llx %llx;\n", | ||
94 | (unsigned long long)addr, (unsigned long long)size); | ||
95 | } | ||
96 | |||
97 | p = p_struct; | ||
98 | while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { | ||
99 | |||
100 | /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */ | ||
101 | |||
102 | if (tag == FDT_BEGIN_NODE) { | ||
103 | s = p; | ||
104 | p = PALIGN(p + strlen(s) + 1, 4); | ||
105 | |||
106 | if (*s == '\0') | ||
107 | s = "/"; | ||
108 | |||
109 | printf("%*s%s {\n", depth * shift, "", s); | ||
110 | |||
111 | depth++; | ||
112 | continue; | ||
113 | } | ||
114 | |||
115 | if (tag == FDT_END_NODE) { | ||
116 | depth--; | ||
117 | |||
118 | printf("%*s};\n", depth * shift, ""); | ||
119 | continue; | ||
120 | } | ||
121 | |||
122 | if (tag == FDT_NOP) { | ||
123 | printf("%*s// [NOP]\n", depth * shift, ""); | ||
124 | continue; | ||
125 | } | ||
126 | |||
127 | if (tag != FDT_PROP) { | ||
128 | fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag); | ||
129 | break; | ||
130 | } | ||
131 | sz = fdt32_to_cpu(GET_CELL(p)); | ||
132 | s = p_strings + fdt32_to_cpu(GET_CELL(p)); | ||
133 | if (version < 16 && sz >= 8) | ||
134 | p = PALIGN(p, 8); | ||
135 | t = p; | ||
136 | |||
137 | p = PALIGN(p + sz, 4); | ||
138 | |||
139 | printf("%*s%s", depth * shift, "", s); | ||
140 | print_data(t, sz); | ||
141 | printf(";\n"); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | |||
146 | int main(int argc, char *argv[]) | ||
147 | { | ||
148 | char *buf; | ||
149 | |||
150 | if (argc < 2) { | ||
151 | fprintf(stderr, "supply input filename\n"); | ||
152 | return 5; | ||
153 | } | ||
154 | |||
155 | buf = utilfdt_read(argv[1]); | ||
156 | if (buf) | ||
157 | dump_blob(buf); | ||
158 | else | ||
159 | return 10; | ||
160 | |||
161 | return 0; | ||
162 | } | ||
diff --git a/scripts/dtc/fdtget.c b/scripts/dtc/fdtget.c deleted file mode 100644 index c2fbab2a547..00000000000 --- a/scripts/dtc/fdtget.c +++ /dev/null | |||
@@ -1,366 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | ||
3 | * | ||
4 | * Portions from U-Boot cmd_fdt.c (C) Copyright 2007 | ||
5 | * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com | ||
6 | * Based on code written by: | ||
7 | * Pantelis Antoniou <pantelis.antoniou@gmail.com> and | ||
8 | * Matthew McClintock <msm@freescale.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License as | ||
12 | * published by the Free Software Foundation; either version 2 of | ||
13 | * the License, or (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
23 | * MA 02111-1307 USA | ||
24 | */ | ||
25 | |||
26 | #include <assert.h> | ||
27 | #include <ctype.h> | ||
28 | #include <getopt.h> | ||
29 | #include <stdio.h> | ||
30 | #include <stdlib.h> | ||
31 | #include <string.h> | ||
32 | |||
33 | #include <libfdt.h> | ||
34 | |||
35 | #include "util.h" | ||
36 | |||
37 | enum display_mode { | ||
38 | MODE_SHOW_VALUE, /* show values for node properties */ | ||
39 | MODE_LIST_PROPS, /* list the properties for a node */ | ||
40 | MODE_LIST_SUBNODES, /* list the subnodes of a node */ | ||
41 | }; | ||
42 | |||
43 | /* Holds information which controls our output and options */ | ||
44 | struct display_info { | ||
45 | int type; /* data type (s/i/u/x or 0 for default) */ | ||
46 | int size; /* data size (1/2/4) */ | ||
47 | enum display_mode mode; /* display mode that we are using */ | ||
48 | const char *default_val; /* default value if node/property not found */ | ||
49 | }; | ||
50 | |||
51 | static void report_error(const char *where, int err) | ||
52 | { | ||
53 | fprintf(stderr, "Error at '%s': %s\n", where, fdt_strerror(err)); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * Displays data of a given length according to selected options | ||
58 | * | ||
59 | * If a specific data type is provided in disp, then this is used. Otherwise | ||
60 | * we try to guess the data type / size from the contents. | ||
61 | * | ||
62 | * @param disp Display information / options | ||
63 | * @param data Data to display | ||
64 | * @param len Maximum length of buffer | ||
65 | * @return 0 if ok, -1 if data does not match format | ||
66 | */ | ||
67 | static int show_data(struct display_info *disp, const char *data, int len) | ||
68 | { | ||
69 | int i, size; | ||
70 | const uint8_t *p = (const uint8_t *)data; | ||
71 | const char *s; | ||
72 | int value; | ||
73 | int is_string; | ||
74 | char fmt[3]; | ||
75 | |||
76 | /* no data, don't print */ | ||
77 | if (len == 0) | ||
78 | return 0; | ||
79 | |||
80 | is_string = (disp->type) == 's' || | ||
81 | (!disp->type && util_is_printable_string(data, len)); | ||
82 | if (is_string) { | ||
83 | if (data[len - 1] != '\0') { | ||
84 | fprintf(stderr, "Unterminated string\n"); | ||
85 | return -1; | ||
86 | } | ||
87 | for (s = data; s - data < len; s += strlen(s) + 1) { | ||
88 | if (s != data) | ||
89 | printf(" "); | ||
90 | printf("%s", (const char *)s); | ||
91 | } | ||
92 | return 0; | ||
93 | } | ||
94 | size = disp->size; | ||
95 | if (size == -1) { | ||
96 | size = (len % 4) == 0 ? 4 : 1; | ||
97 | } else if (len % size) { | ||
98 | fprintf(stderr, "Property length must be a multiple of " | ||
99 | "selected data size\n"); | ||
100 | return -1; | ||
101 | } | ||
102 | fmt[0] = '%'; | ||
103 | fmt[1] = disp->type ? disp->type : 'd'; | ||
104 | fmt[2] = '\0'; | ||
105 | for (i = 0; i < len; i += size, p += size) { | ||
106 | if (i) | ||
107 | printf(" "); | ||
108 | value = size == 4 ? fdt32_to_cpu(*(const uint32_t *)p) : | ||
109 | size == 2 ? (*p << 8) | p[1] : *p; | ||
110 | printf(fmt, value); | ||
111 | } | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * List all properties in a node, one per line. | ||
117 | * | ||
118 | * @param blob FDT blob | ||
119 | * @param node Node to display | ||
120 | * @return 0 if ok, or FDT_ERR... if not. | ||
121 | */ | ||
122 | static int list_properties(const void *blob, int node) | ||
123 | { | ||
124 | const struct fdt_property *data; | ||
125 | const char *name; | ||
126 | int prop; | ||
127 | |||
128 | prop = fdt_first_property_offset(blob, node); | ||
129 | do { | ||
130 | /* Stop silently when there are no more properties */ | ||
131 | if (prop < 0) | ||
132 | return prop == -FDT_ERR_NOTFOUND ? 0 : prop; | ||
133 | data = fdt_get_property_by_offset(blob, prop, NULL); | ||
134 | name = fdt_string(blob, fdt32_to_cpu(data->nameoff)); | ||
135 | if (name) | ||
136 | puts(name); | ||
137 | prop = fdt_next_property_offset(blob, prop); | ||
138 | } while (1); | ||
139 | } | ||
140 | |||
141 | #define MAX_LEVEL 32 /* how deeply nested we will go */ | ||
142 | |||
143 | /** | ||
144 | * List all subnodes in a node, one per line | ||
145 | * | ||
146 | * @param blob FDT blob | ||
147 | * @param node Node to display | ||
148 | * @return 0 if ok, or FDT_ERR... if not. | ||
149 | */ | ||
150 | static int list_subnodes(const void *blob, int node) | ||
151 | { | ||
152 | int nextoffset; /* next node offset from libfdt */ | ||
153 | uint32_t tag; /* current tag */ | ||
154 | int level = 0; /* keep track of nesting level */ | ||
155 | const char *pathp; | ||
156 | int depth = 1; /* the assumed depth of this node */ | ||
157 | |||
158 | while (level >= 0) { | ||
159 | tag = fdt_next_tag(blob, node, &nextoffset); | ||
160 | switch (tag) { | ||
161 | case FDT_BEGIN_NODE: | ||
162 | pathp = fdt_get_name(blob, node, NULL); | ||
163 | if (level <= depth) { | ||
164 | if (pathp == NULL) | ||
165 | pathp = "/* NULL pointer error */"; | ||
166 | if (*pathp == '\0') | ||
167 | pathp = "/"; /* root is nameless */ | ||
168 | if (level == 1) | ||
169 | puts(pathp); | ||
170 | } | ||
171 | level++; | ||
172 | if (level >= MAX_LEVEL) { | ||
173 | printf("Nested too deep, aborting.\n"); | ||
174 | return 1; | ||
175 | } | ||
176 | break; | ||
177 | case FDT_END_NODE: | ||
178 | level--; | ||
179 | if (level == 0) | ||
180 | level = -1; /* exit the loop */ | ||
181 | break; | ||
182 | case FDT_END: | ||
183 | return 1; | ||
184 | case FDT_PROP: | ||
185 | break; | ||
186 | default: | ||
187 | if (level <= depth) | ||
188 | printf("Unknown tag 0x%08X\n", tag); | ||
189 | return 1; | ||
190 | } | ||
191 | node = nextoffset; | ||
192 | } | ||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Show the data for a given node (and perhaps property) according to the | ||
198 | * display option provided. | ||
199 | * | ||
200 | * @param blob FDT blob | ||
201 | * @param disp Display information / options | ||
202 | * @param node Node to display | ||
203 | * @param property Name of property to display, or NULL if none | ||
204 | * @return 0 if ok, -ve on error | ||
205 | */ | ||
206 | static int show_data_for_item(const void *blob, struct display_info *disp, | ||
207 | int node, const char *property) | ||
208 | { | ||
209 | const void *value = NULL; | ||
210 | int len, err = 0; | ||
211 | |||
212 | switch (disp->mode) { | ||
213 | case MODE_LIST_PROPS: | ||
214 | err = list_properties(blob, node); | ||
215 | break; | ||
216 | |||
217 | case MODE_LIST_SUBNODES: | ||
218 | err = list_subnodes(blob, node); | ||
219 | break; | ||
220 | |||
221 | default: | ||
222 | assert(property); | ||
223 | value = fdt_getprop(blob, node, property, &len); | ||
224 | if (value) { | ||
225 | if (show_data(disp, value, len)) | ||
226 | err = -1; | ||
227 | else | ||
228 | printf("\n"); | ||
229 | } else if (disp->default_val) { | ||
230 | puts(disp->default_val); | ||
231 | } else { | ||
232 | report_error(property, len); | ||
233 | err = -1; | ||
234 | } | ||
235 | break; | ||
236 | } | ||
237 | |||
238 | return err; | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * Run the main fdtget operation, given a filename and valid arguments | ||
243 | * | ||
244 | * @param disp Display information / options | ||
245 | * @param filename Filename of blob file | ||
246 | * @param arg List of arguments to process | ||
247 | * @param arg_count Number of arguments | ||
248 | * @param return 0 if ok, -ve on error | ||
249 | */ | ||
250 | static int do_fdtget(struct display_info *disp, const char *filename, | ||
251 | char **arg, int arg_count, int args_per_step) | ||
252 | { | ||
253 | char *blob; | ||
254 | const char *prop; | ||
255 | int i, node; | ||
256 | |||
257 | blob = utilfdt_read(filename); | ||
258 | if (!blob) | ||
259 | return -1; | ||
260 | |||
261 | for (i = 0; i + args_per_step <= arg_count; i += args_per_step) { | ||
262 | node = fdt_path_offset(blob, arg[i]); | ||
263 | if (node < 0) { | ||
264 | if (disp->default_val) { | ||
265 | puts(disp->default_val); | ||
266 | continue; | ||
267 | } else { | ||
268 | report_error(arg[i], node); | ||
269 | return -1; | ||
270 | } | ||
271 | } | ||
272 | prop = args_per_step == 1 ? NULL : arg[i + 1]; | ||
273 | |||
274 | if (show_data_for_item(blob, disp, node, prop)) | ||
275 | return -1; | ||
276 | } | ||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | static const char *usage_msg = | ||
281 | "fdtget - read values from device tree\n" | ||
282 | "\n" | ||
283 | "Each value is printed on a new line.\n\n" | ||
284 | "Usage:\n" | ||
285 | " fdtget <options> <dt file> [<node> <property>]...\n" | ||
286 | " fdtget -p <options> <dt file> [<node> ]...\n" | ||
287 | "Options:\n" | ||
288 | "\t-t <type>\tType of data\n" | ||
289 | "\t-p\t\tList properties for each node\n" | ||
290 | "\t-l\t\tList subnodes for each node\n" | ||
291 | "\t-d\t\tDefault value to display when the property is " | ||
292 | "missing\n" | ||
293 | "\t-h\t\tPrint this help\n\n" | ||
294 | USAGE_TYPE_MSG; | ||
295 | |||
296 | static void usage(const char *msg) | ||
297 | { | ||
298 | if (msg) | ||
299 | fprintf(stderr, "Error: %s\n\n", msg); | ||
300 | |||
301 | fprintf(stderr, "%s", usage_msg); | ||
302 | exit(2); | ||
303 | } | ||
304 | |||
305 | int main(int argc, char *argv[]) | ||
306 | { | ||
307 | char *filename = NULL; | ||
308 | struct display_info disp; | ||
309 | int args_per_step = 2; | ||
310 | |||
311 | /* set defaults */ | ||
312 | memset(&disp, '\0', sizeof(disp)); | ||
313 | disp.size = -1; | ||
314 | disp.mode = MODE_SHOW_VALUE; | ||
315 | for (;;) { | ||
316 | int c = getopt(argc, argv, "d:hlpt:"); | ||
317 | if (c == -1) | ||
318 | break; | ||
319 | |||
320 | switch (c) { | ||
321 | case 'h': | ||
322 | case '?': | ||
323 | usage(NULL); | ||
324 | |||
325 | case 't': | ||
326 | if (utilfdt_decode_type(optarg, &disp.type, | ||
327 | &disp.size)) | ||
328 | usage("Invalid type string"); | ||
329 | break; | ||
330 | |||
331 | case 'p': | ||
332 | disp.mode = MODE_LIST_PROPS; | ||
333 | args_per_step = 1; | ||
334 | break; | ||
335 | |||
336 | case 'l': | ||
337 | disp.mode = MODE_LIST_SUBNODES; | ||
338 | args_per_step = 1; | ||
339 | break; | ||
340 | |||
341 | case 'd': | ||
342 | disp.default_val = optarg; | ||
343 | break; | ||
344 | } | ||
345 | } | ||
346 | |||
347 | if (optind < argc) | ||
348 | filename = argv[optind++]; | ||
349 | if (!filename) | ||
350 | usage("Missing filename"); | ||
351 | |||
352 | argv += optind; | ||
353 | argc -= optind; | ||
354 | |||
355 | /* Allow no arguments, and silently succeed */ | ||
356 | if (!argc) | ||
357 | return 0; | ||
358 | |||
359 | /* Check for node, property arguments */ | ||
360 | if (args_per_step == 2 && (argc % 2)) | ||
361 | usage("Must have an even number of arguments"); | ||
362 | |||
363 | if (do_fdtget(&disp, filename, argv, argc, args_per_step)) | ||
364 | return 1; | ||
365 | return 0; | ||
366 | } | ||
diff --git a/scripts/dtc/fdtput.c b/scripts/dtc/fdtput.c deleted file mode 100644 index f2197f51930..00000000000 --- a/scripts/dtc/fdtput.c +++ /dev/null | |||
@@ -1,362 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation; either version 2 of | ||
7 | * the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
17 | * MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <assert.h> | ||
21 | #include <ctype.h> | ||
22 | #include <getopt.h> | ||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <string.h> | ||
26 | |||
27 | #include <libfdt.h> | ||
28 | |||
29 | #include "util.h" | ||
30 | |||
31 | /* These are the operations we support */ | ||
32 | enum oper_type { | ||
33 | OPER_WRITE_PROP, /* Write a property in a node */ | ||
34 | OPER_CREATE_NODE, /* Create a new node */ | ||
35 | }; | ||
36 | |||
37 | struct display_info { | ||
38 | enum oper_type oper; /* operation to perform */ | ||
39 | int type; /* data type (s/i/u/x or 0 for default) */ | ||
40 | int size; /* data size (1/2/4) */ | ||
41 | int verbose; /* verbose output */ | ||
42 | int auto_path; /* automatically create all path components */ | ||
43 | }; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Report an error with a particular node. | ||
48 | * | ||
49 | * @param name Node name to report error on | ||
50 | * @param namelen Length of node name, or -1 to use entire string | ||
51 | * @param err Error number to report (-FDT_ERR_...) | ||
52 | */ | ||
53 | static void report_error(const char *name, int namelen, int err) | ||
54 | { | ||
55 | if (namelen == -1) | ||
56 | namelen = strlen(name); | ||
57 | fprintf(stderr, "Error at '%1.*s': %s\n", namelen, name, | ||
58 | fdt_strerror(err)); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Encode a series of arguments in a property value. | ||
63 | * | ||
64 | * @param disp Display information / options | ||
65 | * @param arg List of arguments from command line | ||
66 | * @param arg_count Number of arguments (may be 0) | ||
67 | * @param valuep Returns buffer containing value | ||
68 | * @param *value_len Returns length of value encoded | ||
69 | */ | ||
70 | static int encode_value(struct display_info *disp, char **arg, int arg_count, | ||
71 | char **valuep, int *value_len) | ||
72 | { | ||
73 | char *value = NULL; /* holding area for value */ | ||
74 | int value_size = 0; /* size of holding area */ | ||
75 | char *ptr; /* pointer to current value position */ | ||
76 | int len; /* length of this cell/string/byte */ | ||
77 | int ival; | ||
78 | int upto; /* the number of bytes we have written to buf */ | ||
79 | char fmt[3]; | ||
80 | |||
81 | upto = 0; | ||
82 | |||
83 | if (disp->verbose) | ||
84 | fprintf(stderr, "Decoding value:\n"); | ||
85 | |||
86 | fmt[0] = '%'; | ||
87 | fmt[1] = disp->type ? disp->type : 'd'; | ||
88 | fmt[2] = '\0'; | ||
89 | for (; arg_count > 0; arg++, arg_count--, upto += len) { | ||
90 | /* assume integer unless told otherwise */ | ||
91 | if (disp->type == 's') | ||
92 | len = strlen(*arg) + 1; | ||
93 | else | ||
94 | len = disp->size == -1 ? 4 : disp->size; | ||
95 | |||
96 | /* enlarge our value buffer by a suitable margin if needed */ | ||
97 | if (upto + len > value_size) { | ||
98 | value_size = (upto + len) + 500; | ||
99 | value = realloc(value, value_size); | ||
100 | if (!value) { | ||
101 | fprintf(stderr, "Out of mmory: cannot alloc " | ||
102 | "%d bytes\n", value_size); | ||
103 | return -1; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | ptr = value + upto; | ||
108 | if (disp->type == 's') { | ||
109 | memcpy(ptr, *arg, len); | ||
110 | if (disp->verbose) | ||
111 | fprintf(stderr, "\tstring: '%s'\n", ptr); | ||
112 | } else { | ||
113 | int *iptr = (int *)ptr; | ||
114 | sscanf(*arg, fmt, &ival); | ||
115 | if (len == 4) | ||
116 | *iptr = cpu_to_fdt32(ival); | ||
117 | else | ||
118 | *ptr = (uint8_t)ival; | ||
119 | if (disp->verbose) { | ||
120 | fprintf(stderr, "\t%s: %d\n", | ||
121 | disp->size == 1 ? "byte" : | ||
122 | disp->size == 2 ? "short" : "int", | ||
123 | ival); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | *value_len = upto; | ||
128 | *valuep = value; | ||
129 | if (disp->verbose) | ||
130 | fprintf(stderr, "Value size %d\n", upto); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static int store_key_value(void *blob, const char *node_name, | ||
135 | const char *property, const char *buf, int len) | ||
136 | { | ||
137 | int node; | ||
138 | int err; | ||
139 | |||
140 | node = fdt_path_offset(blob, node_name); | ||
141 | if (node < 0) { | ||
142 | report_error(node_name, -1, node); | ||
143 | return -1; | ||
144 | } | ||
145 | |||
146 | err = fdt_setprop(blob, node, property, buf, len); | ||
147 | if (err) { | ||
148 | report_error(property, -1, err); | ||
149 | return -1; | ||
150 | } | ||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * Create paths as needed for all components of a path | ||
156 | * | ||
157 | * Any components of the path that do not exist are created. Errors are | ||
158 | * reported. | ||
159 | * | ||
160 | * @param blob FDT blob to write into | ||
161 | * @param in_path Path to process | ||
162 | * @return 0 if ok, -1 on error | ||
163 | */ | ||
164 | static int create_paths(void *blob, const char *in_path) | ||
165 | { | ||
166 | const char *path = in_path; | ||
167 | const char *sep; | ||
168 | int node, offset = 0; | ||
169 | |||
170 | /* skip leading '/' */ | ||
171 | while (*path == '/') | ||
172 | path++; | ||
173 | |||
174 | for (sep = path; *sep; path = sep + 1, offset = node) { | ||
175 | /* equivalent to strchrnul(), but it requires _GNU_SOURCE */ | ||
176 | sep = strchr(path, '/'); | ||
177 | if (!sep) | ||
178 | sep = path + strlen(path); | ||
179 | |||
180 | node = fdt_subnode_offset_namelen(blob, offset, path, | ||
181 | sep - path); | ||
182 | if (node == -FDT_ERR_NOTFOUND) { | ||
183 | node = fdt_add_subnode_namelen(blob, offset, path, | ||
184 | sep - path); | ||
185 | } | ||
186 | if (node < 0) { | ||
187 | report_error(path, sep - path, node); | ||
188 | return -1; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Create a new node in the fdt. | ||
197 | * | ||
198 | * This will overwrite the node_name string. Any error is reported. | ||
199 | * | ||
200 | * TODO: Perhaps create fdt_path_offset_namelen() so we don't need to do this. | ||
201 | * | ||
202 | * @param blob FDT blob to write into | ||
203 | * @param node_name Name of node to create | ||
204 | * @return new node offset if found, or -1 on failure | ||
205 | */ | ||
206 | static int create_node(void *blob, const char *node_name) | ||
207 | { | ||
208 | int node = 0; | ||
209 | char *p; | ||
210 | |||
211 | p = strrchr(node_name, '/'); | ||
212 | if (!p) { | ||
213 | report_error(node_name, -1, -FDT_ERR_BADPATH); | ||
214 | return -1; | ||
215 | } | ||
216 | *p = '\0'; | ||
217 | |||
218 | if (p > node_name) { | ||
219 | node = fdt_path_offset(blob, node_name); | ||
220 | if (node < 0) { | ||
221 | report_error(node_name, -1, node); | ||
222 | return -1; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | node = fdt_add_subnode(blob, node, p + 1); | ||
227 | if (node < 0) { | ||
228 | report_error(p + 1, -1, node); | ||
229 | return -1; | ||
230 | } | ||
231 | |||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | static int do_fdtput(struct display_info *disp, const char *filename, | ||
236 | char **arg, int arg_count) | ||
237 | { | ||
238 | char *value; | ||
239 | char *blob; | ||
240 | int len, ret = 0; | ||
241 | |||
242 | blob = utilfdt_read(filename); | ||
243 | if (!blob) | ||
244 | return -1; | ||
245 | |||
246 | switch (disp->oper) { | ||
247 | case OPER_WRITE_PROP: | ||
248 | /* | ||
249 | * Convert the arguments into a single binary value, then | ||
250 | * store them into the property. | ||
251 | */ | ||
252 | assert(arg_count >= 2); | ||
253 | if (disp->auto_path && create_paths(blob, *arg)) | ||
254 | return -1; | ||
255 | if (encode_value(disp, arg + 2, arg_count - 2, &value, &len) || | ||
256 | store_key_value(blob, *arg, arg[1], value, len)) | ||
257 | ret = -1; | ||
258 | break; | ||
259 | case OPER_CREATE_NODE: | ||
260 | for (; ret >= 0 && arg_count--; arg++) { | ||
261 | if (disp->auto_path) | ||
262 | ret = create_paths(blob, *arg); | ||
263 | else | ||
264 | ret = create_node(blob, *arg); | ||
265 | } | ||
266 | break; | ||
267 | } | ||
268 | if (ret >= 0) | ||
269 | ret = utilfdt_write(filename, blob); | ||
270 | |||
271 | free(blob); | ||
272 | return ret; | ||
273 | } | ||
274 | |||
275 | static const char *usage_msg = | ||
276 | "fdtput - write a property value to a device tree\n" | ||
277 | "\n" | ||
278 | "The command line arguments are joined together into a single value.\n" | ||
279 | "\n" | ||
280 | "Usage:\n" | ||
281 | " fdtput <options> <dt file> <node> <property> [<value>...]\n" | ||
282 | " fdtput -c <options> <dt file> [<node>...]\n" | ||
283 | "Options:\n" | ||
284 | "\t-c\t\tCreate nodes if they don't already exist\n" | ||
285 | "\t-p\t\tAutomatically create nodes as needed for the node path\n" | ||
286 | "\t-t <type>\tType of data\n" | ||
287 | "\t-v\t\tVerbose: display each value decoded from command line\n" | ||
288 | "\t-h\t\tPrint this help\n\n" | ||
289 | USAGE_TYPE_MSG; | ||
290 | |||
291 | static void usage(const char *msg) | ||
292 | { | ||
293 | if (msg) | ||
294 | fprintf(stderr, "Error: %s\n\n", msg); | ||
295 | |||
296 | fprintf(stderr, "%s", usage_msg); | ||
297 | exit(2); | ||
298 | } | ||
299 | |||
300 | int main(int argc, char *argv[]) | ||
301 | { | ||
302 | struct display_info disp; | ||
303 | char *filename = NULL; | ||
304 | |||
305 | memset(&disp, '\0', sizeof(disp)); | ||
306 | disp.size = -1; | ||
307 | disp.oper = OPER_WRITE_PROP; | ||
308 | for (;;) { | ||
309 | int c = getopt(argc, argv, "chpt:v"); | ||
310 | if (c == -1) | ||
311 | break; | ||
312 | |||
313 | /* | ||
314 | * TODO: add options to: | ||
315 | * - delete property | ||
316 | * - delete node (optionally recursively) | ||
317 | * - rename node | ||
318 | * - pack fdt before writing | ||
319 | * - set amount of free space when writing | ||
320 | * - expand fdt if value doesn't fit | ||
321 | */ | ||
322 | switch (c) { | ||
323 | case 'c': | ||
324 | disp.oper = OPER_CREATE_NODE; | ||
325 | break; | ||
326 | case 'h': | ||
327 | case '?': | ||
328 | usage(NULL); | ||
329 | case 'p': | ||
330 | disp.auto_path = 1; | ||
331 | break; | ||
332 | case 't': | ||
333 | if (utilfdt_decode_type(optarg, &disp.type, | ||
334 | &disp.size)) | ||
335 | usage("Invalid type string"); | ||
336 | break; | ||
337 | |||
338 | case 'v': | ||
339 | disp.verbose = 1; | ||
340 | break; | ||
341 | } | ||
342 | } | ||
343 | |||
344 | if (optind < argc) | ||
345 | filename = argv[optind++]; | ||
346 | if (!filename) | ||
347 | usage("Missing filename"); | ||
348 | |||
349 | argv += optind; | ||
350 | argc -= optind; | ||
351 | |||
352 | if (disp.oper == OPER_WRITE_PROP) { | ||
353 | if (argc < 1) | ||
354 | usage("Missing node"); | ||
355 | if (argc < 2) | ||
356 | usage("Missing property"); | ||
357 | } | ||
358 | |||
359 | if (do_fdtput(&disp, filename, argv, argc)) | ||
360 | return 1; | ||
361 | return 0; | ||
362 | } | ||
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c index 665dad7bb46..ead0332c87e 100644 --- a/scripts/dtc/flattree.c +++ b/scripts/dtc/flattree.c | |||
@@ -263,9 +263,6 @@ static void flatten_tree(struct node *tree, struct emitter *emit, | |||
263 | struct node *child; | 263 | struct node *child; |
264 | int seen_name_prop = 0; | 264 | int seen_name_prop = 0; |
265 | 265 | ||
266 | if (tree->deleted) | ||
267 | return; | ||
268 | |||
269 | emit->beginnode(etarget, tree->labels); | 266 | emit->beginnode(etarget, tree->labels); |
270 | 267 | ||
271 | if (vi->flags & FTF_FULLPATH) | 268 | if (vi->flags & FTF_FULLPATH) |
@@ -700,6 +697,7 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) | |||
700 | { | 697 | { |
701 | struct reserve_info *reservelist = NULL; | 698 | struct reserve_info *reservelist = NULL; |
702 | struct reserve_info *new; | 699 | struct reserve_info *new; |
700 | const char *p; | ||
703 | struct fdt_reserve_entry re; | 701 | struct fdt_reserve_entry re; |
704 | 702 | ||
705 | /* | 703 | /* |
@@ -708,6 +706,7 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) | |||
708 | * | 706 | * |
709 | * First pass, count entries. | 707 | * First pass, count entries. |
710 | */ | 708 | */ |
709 | p = inb->ptr; | ||
711 | while (1) { | 710 | while (1) { |
712 | flat_read_chunk(inb, &re, sizeof(re)); | 711 | flat_read_chunk(inb, &re, sizeof(re)); |
713 | re.address = fdt64_to_cpu(re.address); | 712 | re.address = fdt64_to_cpu(re.address); |
diff --git a/scripts/dtc/libfdt/Makefile.libfdt b/scripts/dtc/libfdt/Makefile.libfdt index 91126c000a1..6c42acfa21e 100644 --- a/scripts/dtc/libfdt/Makefile.libfdt +++ b/scripts/dtc/libfdt/Makefile.libfdt | |||
@@ -3,8 +3,6 @@ | |||
3 | # This is not a complete Makefile of itself. Instead, it is designed to | 3 | # This is not a complete Makefile of itself. Instead, it is designed to |
4 | # be easily embeddable into other systems of Makefiles. | 4 | # be easily embeddable into other systems of Makefiles. |
5 | # | 5 | # |
6 | LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1 | 6 | LIBFDT_INCLUDES = fdt.h libfdt.h |
7 | LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h | 7 | LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c |
8 | LIBFDT_VERSION = version.lds | ||
9 | LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c | ||
10 | LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) | 8 | LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) |
diff --git a/scripts/dtc/libfdt/fdt.c b/scripts/dtc/libfdt/fdt.c index e56833ae9b6..2acaec5923a 100644 --- a/scripts/dtc/libfdt/fdt.c +++ b/scripts/dtc/libfdt/fdt.c | |||
@@ -74,7 +74,7 @@ int fdt_check_header(const void *fdt) | |||
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) | 77 | const void *fdt_offset_ptr(const void *fdt, int offset, int len) |
78 | { | 78 | { |
79 | const char *p; | 79 | const char *p; |
80 | 80 | ||
@@ -90,53 +90,42 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) | |||
90 | return p; | 90 | return p; |
91 | } | 91 | } |
92 | 92 | ||
93 | uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) | 93 | uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset) |
94 | { | 94 | { |
95 | const uint32_t *tagp, *lenp; | 95 | const uint32_t *tagp, *lenp; |
96 | uint32_t tag; | 96 | uint32_t tag; |
97 | int offset = startoffset; | ||
98 | const char *p; | 97 | const char *p; |
99 | 98 | ||
100 | *nextoffset = -FDT_ERR_TRUNCATED; | 99 | if (offset % FDT_TAGSIZE) |
100 | return -1; | ||
101 | |||
101 | tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE); | 102 | tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE); |
102 | if (!tagp) | 103 | if (! tagp) |
103 | return FDT_END; /* premature end */ | 104 | return FDT_END; /* premature end */ |
104 | tag = fdt32_to_cpu(*tagp); | 105 | tag = fdt32_to_cpu(*tagp); |
105 | offset += FDT_TAGSIZE; | 106 | offset += FDT_TAGSIZE; |
106 | 107 | ||
107 | *nextoffset = -FDT_ERR_BADSTRUCTURE; | ||
108 | switch (tag) { | 108 | switch (tag) { |
109 | case FDT_BEGIN_NODE: | 109 | case FDT_BEGIN_NODE: |
110 | /* skip name */ | 110 | /* skip name */ |
111 | do { | 111 | do { |
112 | p = fdt_offset_ptr(fdt, offset++, 1); | 112 | p = fdt_offset_ptr(fdt, offset++, 1); |
113 | } while (p && (*p != '\0')); | 113 | } while (p && (*p != '\0')); |
114 | if (!p) | 114 | if (! p) |
115 | return FDT_END; /* premature end */ | 115 | return FDT_END; |
116 | break; | 116 | break; |
117 | |||
118 | case FDT_PROP: | 117 | case FDT_PROP: |
119 | lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp)); | 118 | lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp)); |
120 | if (!lenp) | 119 | if (! lenp) |
121 | return FDT_END; /* premature end */ | 120 | return FDT_END; |
122 | /* skip-name offset, length and value */ | 121 | /* skip name offset, length and value */ |
123 | offset += sizeof(struct fdt_property) - FDT_TAGSIZE | 122 | offset += 2*FDT_TAGSIZE + fdt32_to_cpu(*lenp); |
124 | + fdt32_to_cpu(*lenp); | ||
125 | break; | ||
126 | |||
127 | case FDT_END: | ||
128 | case FDT_END_NODE: | ||
129 | case FDT_NOP: | ||
130 | break; | 123 | break; |
131 | |||
132 | default: | ||
133 | return FDT_END; | ||
134 | } | 124 | } |
135 | 125 | ||
136 | if (!fdt_offset_ptr(fdt, startoffset, offset - startoffset)) | 126 | if (nextoffset) |
137 | return FDT_END; /* premature end */ | 127 | *nextoffset = FDT_TAGALIGN(offset); |
138 | 128 | ||
139 | *nextoffset = FDT_TAGALIGN(offset); | ||
140 | return tag; | 129 | return tag; |
141 | } | 130 | } |
142 | 131 | ||
@@ -149,15 +138,6 @@ int _fdt_check_node_offset(const void *fdt, int offset) | |||
149 | return offset; | 138 | return offset; |
150 | } | 139 | } |
151 | 140 | ||
152 | int _fdt_check_prop_offset(const void *fdt, int offset) | ||
153 | { | ||
154 | if ((offset < 0) || (offset % FDT_TAGSIZE) | ||
155 | || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) | ||
156 | return -FDT_ERR_BADOFFSET; | ||
157 | |||
158 | return offset; | ||
159 | } | ||
160 | |||
161 | int fdt_next_node(const void *fdt, int offset, int *depth) | 141 | int fdt_next_node(const void *fdt, int offset, int *depth) |
162 | { | 142 | { |
163 | int nextoffset = 0; | 143 | int nextoffset = 0; |
@@ -182,16 +162,15 @@ int fdt_next_node(const void *fdt, int offset, int *depth) | |||
182 | break; | 162 | break; |
183 | 163 | ||
184 | case FDT_END_NODE: | 164 | case FDT_END_NODE: |
185 | if (depth && ((--(*depth)) < 0)) | 165 | if (depth) |
186 | return nextoffset; | 166 | (*depth)--; |
187 | break; | 167 | break; |
188 | 168 | ||
189 | case FDT_END: | 169 | case FDT_END: |
190 | if ((nextoffset >= 0) | 170 | return -FDT_ERR_NOTFOUND; |
191 | || ((nextoffset == -FDT_ERR_TRUNCATED) && !depth)) | 171 | |
192 | return -FDT_ERR_NOTFOUND; | 172 | default: |
193 | else | 173 | return -FDT_ERR_BADSTRUCTURE; |
194 | return nextoffset; | ||
195 | } | 174 | } |
196 | } while (tag != FDT_BEGIN_NODE); | 175 | } while (tag != FDT_BEGIN_NODE); |
197 | 176 | ||
diff --git a/scripts/dtc/libfdt/fdt_empty_tree.c b/scripts/dtc/libfdt/fdt_empty_tree.c deleted file mode 100644 index f72d13b1d19..00000000000 --- a/scripts/dtc/libfdt/fdt_empty_tree.c +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* | ||
2 | * libfdt - Flat Device Tree manipulation | ||
3 | * Copyright (C) 2012 David Gibson, IBM Corporation. | ||
4 | * | ||
5 | * libfdt is dual licensed: you can use it either under the terms of | ||
6 | * the GPL, or the BSD license, at your option. | ||
7 | * | ||
8 | * a) This library is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License as | ||
10 | * published by the Free Software Foundation; either version 2 of the | ||
11 | * License, or (at your option) any later version. | ||
12 | * | ||
13 | * This library is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public | ||
19 | * License along with this library; if not, write to the Free | ||
20 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, | ||
21 | * MA 02110-1301 USA | ||
22 | * | ||
23 | * Alternatively, | ||
24 | * | ||
25 | * b) Redistribution and use in source and binary forms, with or | ||
26 | * without modification, are permitted provided that the following | ||
27 | * conditions are met: | ||
28 | * | ||
29 | * 1. Redistributions of source code must retain the above | ||
30 | * copyright notice, this list of conditions and the following | ||
31 | * disclaimer. | ||
32 | * 2. Redistributions in binary form must reproduce the above | ||
33 | * copyright notice, this list of conditions and the following | ||
34 | * disclaimer in the documentation and/or other materials | ||
35 | * provided with the distribution. | ||
36 | * | ||
37 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
38 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
39 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
40 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
41 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
42 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
43 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
44 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
45 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
46 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
47 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
48 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
49 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
50 | */ | ||
51 | #include "libfdt_env.h" | ||
52 | |||
53 | #include <fdt.h> | ||
54 | #include <libfdt.h> | ||
55 | |||
56 | #include "libfdt_internal.h" | ||
57 | |||
58 | int fdt_create_empty_tree(void *buf, int bufsize) | ||
59 | { | ||
60 | int err; | ||
61 | |||
62 | err = fdt_create(buf, bufsize); | ||
63 | if (err) | ||
64 | return err; | ||
65 | |||
66 | err = fdt_finish_reservemap(buf); | ||
67 | if (err) | ||
68 | return err; | ||
69 | |||
70 | err = fdt_begin_node(buf, ""); | ||
71 | if (err) | ||
72 | return err; | ||
73 | |||
74 | err = fdt_end_node(buf); | ||
75 | if (err) | ||
76 | return err; | ||
77 | |||
78 | err = fdt_finish(buf); | ||
79 | if (err) | ||
80 | return err; | ||
81 | |||
82 | return fdt_open_into(buf, buf, bufsize); | ||
83 | } | ||
84 | |||
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c index 02b6d687537..22e692919ff 100644 --- a/scripts/dtc/libfdt/fdt_ro.c +++ b/scripts/dtc/libfdt/fdt_ro.c | |||
@@ -80,14 +80,6 @@ const char *fdt_string(const void *fdt, int stroffset) | |||
80 | return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset; | 80 | return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset; |
81 | } | 81 | } |
82 | 82 | ||
83 | static int _fdt_string_eq(const void *fdt, int stroffset, | ||
84 | const char *s, int len) | ||
85 | { | ||
86 | const char *p = fdt_string(fdt, stroffset); | ||
87 | |||
88 | return (strlen(p) == len) && (memcmp(p, s, len) == 0); | ||
89 | } | ||
90 | |||
91 | int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) | 83 | int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) |
92 | { | 84 | { |
93 | FDT_CHECK_HEADER(fdt); | 85 | FDT_CHECK_HEADER(fdt); |
@@ -105,30 +97,6 @@ int fdt_num_mem_rsv(const void *fdt) | |||
105 | return i; | 97 | return i; |
106 | } | 98 | } |
107 | 99 | ||
108 | static int _nextprop(const void *fdt, int offset) | ||
109 | { | ||
110 | uint32_t tag; | ||
111 | int nextoffset; | ||
112 | |||
113 | do { | ||
114 | tag = fdt_next_tag(fdt, offset, &nextoffset); | ||
115 | |||
116 | switch (tag) { | ||
117 | case FDT_END: | ||
118 | if (nextoffset >= 0) | ||
119 | return -FDT_ERR_BADSTRUCTURE; | ||
120 | else | ||
121 | return nextoffset; | ||
122 | |||
123 | case FDT_PROP: | ||
124 | return offset; | ||
125 | } | ||
126 | offset = nextoffset; | ||
127 | } while (tag == FDT_NOP); | ||
128 | |||
129 | return -FDT_ERR_NOTFOUND; | ||
130 | } | ||
131 | |||
132 | int fdt_subnode_offset_namelen(const void *fdt, int offset, | 100 | int fdt_subnode_offset_namelen(const void *fdt, int offset, |
133 | const char *name, int namelen) | 101 | const char *name, int namelen) |
134 | { | 102 | { |
@@ -136,16 +104,20 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset, | |||
136 | 104 | ||
137 | FDT_CHECK_HEADER(fdt); | 105 | FDT_CHECK_HEADER(fdt); |
138 | 106 | ||
139 | for (depth = 0; | 107 | for (depth = 0, offset = fdt_next_node(fdt, offset, &depth); |
140 | (offset >= 0) && (depth >= 0); | 108 | (offset >= 0) && (depth > 0); |
141 | offset = fdt_next_node(fdt, offset, &depth)) | 109 | offset = fdt_next_node(fdt, offset, &depth)) { |
142 | if ((depth == 1) | 110 | if (depth < 0) |
143 | && _fdt_nodename_eq(fdt, offset, name, namelen)) | 111 | return -FDT_ERR_NOTFOUND; |
112 | else if ((depth == 1) | ||
113 | && _fdt_nodename_eq(fdt, offset, name, namelen)) | ||
144 | return offset; | 114 | return offset; |
115 | } | ||
145 | 116 | ||
146 | if (depth < 0) | 117 | if (offset < 0) |
118 | return offset; /* error */ | ||
119 | else | ||
147 | return -FDT_ERR_NOTFOUND; | 120 | return -FDT_ERR_NOTFOUND; |
148 | return offset; /* error */ | ||
149 | } | 121 | } |
150 | 122 | ||
151 | int fdt_subnode_offset(const void *fdt, int parentoffset, | 123 | int fdt_subnode_offset(const void *fdt, int parentoffset, |
@@ -162,20 +134,8 @@ int fdt_path_offset(const void *fdt, const char *path) | |||
162 | 134 | ||
163 | FDT_CHECK_HEADER(fdt); | 135 | FDT_CHECK_HEADER(fdt); |
164 | 136 | ||
165 | /* see if we have an alias */ | 137 | if (*path != '/') |
166 | if (*path != '/') { | 138 | return -FDT_ERR_BADPATH; |
167 | const char *q = strchr(path, '/'); | ||
168 | |||
169 | if (!q) | ||
170 | q = end; | ||
171 | |||
172 | p = fdt_get_alias_namelen(fdt, p, q - p); | ||
173 | if (!p) | ||
174 | return -FDT_ERR_BADPATH; | ||
175 | offset = fdt_path_offset(fdt, p); | ||
176 | |||
177 | p = q; | ||
178 | } | ||
179 | 139 | ||
180 | while (*p) { | 140 | while (*p) { |
181 | const char *q; | 141 | const char *q; |
@@ -218,142 +178,93 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) | |||
218 | return NULL; | 178 | return NULL; |
219 | } | 179 | } |
220 | 180 | ||
221 | int fdt_first_property_offset(const void *fdt, int nodeoffset) | 181 | const struct fdt_property *fdt_get_property(const void *fdt, |
222 | { | 182 | int nodeoffset, |
223 | int offset; | 183 | const char *name, int *lenp) |
224 | |||
225 | if ((offset = _fdt_check_node_offset(fdt, nodeoffset)) < 0) | ||
226 | return offset; | ||
227 | |||
228 | return _nextprop(fdt, offset); | ||
229 | } | ||
230 | |||
231 | int fdt_next_property_offset(const void *fdt, int offset) | ||
232 | { | ||
233 | if ((offset = _fdt_check_prop_offset(fdt, offset)) < 0) | ||
234 | return offset; | ||
235 | |||
236 | return _nextprop(fdt, offset); | ||
237 | } | ||
238 | |||
239 | const struct fdt_property *fdt_get_property_by_offset(const void *fdt, | ||
240 | int offset, | ||
241 | int *lenp) | ||
242 | { | 184 | { |
243 | int err; | 185 | uint32_t tag; |
244 | const struct fdt_property *prop; | 186 | const struct fdt_property *prop; |
187 | int namestroff; | ||
188 | int offset, nextoffset; | ||
189 | int err; | ||
245 | 190 | ||
246 | if ((err = _fdt_check_prop_offset(fdt, offset)) < 0) { | 191 | if (((err = fdt_check_header(fdt)) != 0) |
247 | if (lenp) | 192 | || ((err = _fdt_check_node_offset(fdt, nodeoffset)) < 0)) |
248 | *lenp = err; | 193 | goto fail; |
249 | return NULL; | ||
250 | } | ||
251 | |||
252 | prop = _fdt_offset_ptr(fdt, offset); | ||
253 | 194 | ||
254 | if (lenp) | 195 | nextoffset = err; |
255 | *lenp = fdt32_to_cpu(prop->len); | 196 | do { |
197 | offset = nextoffset; | ||
256 | 198 | ||
257 | return prop; | 199 | tag = fdt_next_tag(fdt, offset, &nextoffset); |
258 | } | 200 | switch (tag) { |
201 | case FDT_END: | ||
202 | err = -FDT_ERR_TRUNCATED; | ||
203 | goto fail; | ||
259 | 204 | ||
260 | const struct fdt_property *fdt_get_property_namelen(const void *fdt, | 205 | case FDT_BEGIN_NODE: |
261 | int offset, | 206 | case FDT_END_NODE: |
262 | const char *name, | 207 | case FDT_NOP: |
263 | int namelen, int *lenp) | 208 | break; |
264 | { | ||
265 | for (offset = fdt_first_property_offset(fdt, offset); | ||
266 | (offset >= 0); | ||
267 | (offset = fdt_next_property_offset(fdt, offset))) { | ||
268 | const struct fdt_property *prop; | ||
269 | 209 | ||
270 | if (!(prop = fdt_get_property_by_offset(fdt, offset, lenp))) { | 210 | case FDT_PROP: |
271 | offset = -FDT_ERR_INTERNAL; | 211 | err = -FDT_ERR_BADSTRUCTURE; |
212 | prop = fdt_offset_ptr(fdt, offset, sizeof(*prop)); | ||
213 | if (! prop) | ||
214 | goto fail; | ||
215 | namestroff = fdt32_to_cpu(prop->nameoff); | ||
216 | if (strcmp(fdt_string(fdt, namestroff), name) == 0) { | ||
217 | /* Found it! */ | ||
218 | int len = fdt32_to_cpu(prop->len); | ||
219 | prop = fdt_offset_ptr(fdt, offset, | ||
220 | sizeof(*prop)+len); | ||
221 | if (! prop) | ||
222 | goto fail; | ||
223 | |||
224 | if (lenp) | ||
225 | *lenp = len; | ||
226 | |||
227 | return prop; | ||
228 | } | ||
272 | break; | 229 | break; |
230 | |||
231 | default: | ||
232 | err = -FDT_ERR_BADSTRUCTURE; | ||
233 | goto fail; | ||
273 | } | 234 | } |
274 | if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->nameoff), | 235 | } while ((tag != FDT_BEGIN_NODE) && (tag != FDT_END_NODE)); |
275 | name, namelen)) | ||
276 | return prop; | ||
277 | } | ||
278 | 236 | ||
237 | err = -FDT_ERR_NOTFOUND; | ||
238 | fail: | ||
279 | if (lenp) | 239 | if (lenp) |
280 | *lenp = offset; | 240 | *lenp = err; |
281 | return NULL; | 241 | return NULL; |
282 | } | 242 | } |
283 | 243 | ||
284 | const struct fdt_property *fdt_get_property(const void *fdt, | 244 | const void *fdt_getprop(const void *fdt, int nodeoffset, |
285 | int nodeoffset, | 245 | const char *name, int *lenp) |
286 | const char *name, int *lenp) | ||
287 | { | ||
288 | return fdt_get_property_namelen(fdt, nodeoffset, name, | ||
289 | strlen(name), lenp); | ||
290 | } | ||
291 | |||
292 | const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, | ||
293 | const char *name, int namelen, int *lenp) | ||
294 | { | 246 | { |
295 | const struct fdt_property *prop; | 247 | const struct fdt_property *prop; |
296 | 248 | ||
297 | prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp); | 249 | prop = fdt_get_property(fdt, nodeoffset, name, lenp); |
298 | if (! prop) | 250 | if (! prop) |
299 | return NULL; | 251 | return NULL; |
300 | 252 | ||
301 | return prop->data; | 253 | return prop->data; |
302 | } | 254 | } |
303 | 255 | ||
304 | const void *fdt_getprop_by_offset(const void *fdt, int offset, | ||
305 | const char **namep, int *lenp) | ||
306 | { | ||
307 | const struct fdt_property *prop; | ||
308 | |||
309 | prop = fdt_get_property_by_offset(fdt, offset, lenp); | ||
310 | if (!prop) | ||
311 | return NULL; | ||
312 | if (namep) | ||
313 | *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); | ||
314 | return prop->data; | ||
315 | } | ||
316 | |||
317 | const void *fdt_getprop(const void *fdt, int nodeoffset, | ||
318 | const char *name, int *lenp) | ||
319 | { | ||
320 | return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp); | ||
321 | } | ||
322 | |||
323 | uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) | 256 | uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) |
324 | { | 257 | { |
325 | const uint32_t *php; | 258 | const uint32_t *php; |
326 | int len; | 259 | int len; |
327 | 260 | ||
328 | /* FIXME: This is a bit sub-optimal, since we potentially scan | 261 | php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len); |
329 | * over all the properties twice. */ | 262 | if (!php || (len != sizeof(*php))) |
330 | php = fdt_getprop(fdt, nodeoffset, "phandle", &len); | 263 | return 0; |
331 | if (!php || (len != sizeof(*php))) { | ||
332 | php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len); | ||
333 | if (!php || (len != sizeof(*php))) | ||
334 | return 0; | ||
335 | } | ||
336 | 264 | ||
337 | return fdt32_to_cpu(*php); | 265 | return fdt32_to_cpu(*php); |
338 | } | 266 | } |
339 | 267 | ||
340 | const char *fdt_get_alias_namelen(const void *fdt, | ||
341 | const char *name, int namelen) | ||
342 | { | ||
343 | int aliasoffset; | ||
344 | |||
345 | aliasoffset = fdt_path_offset(fdt, "/aliases"); | ||
346 | if (aliasoffset < 0) | ||
347 | return NULL; | ||
348 | |||
349 | return fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL); | ||
350 | } | ||
351 | |||
352 | const char *fdt_get_alias(const void *fdt, const char *name) | ||
353 | { | ||
354 | return fdt_get_alias_namelen(fdt, name, strlen(name)); | ||
355 | } | ||
356 | |||
357 | int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) | 268 | int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) |
358 | { | 269 | { |
359 | int pdepth = 0, p = 0; | 270 | int pdepth = 0, p = 0; |
@@ -368,6 +279,9 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) | |||
368 | for (offset = 0, depth = 0; | 279 | for (offset = 0, depth = 0; |
369 | (offset >= 0) && (offset <= nodeoffset); | 280 | (offset >= 0) && (offset <= nodeoffset); |
370 | offset = fdt_next_node(fdt, offset, &depth)) { | 281 | offset = fdt_next_node(fdt, offset, &depth)) { |
282 | if (pdepth < depth) | ||
283 | continue; /* overflowed buffer */ | ||
284 | |||
371 | while (pdepth > depth) { | 285 | while (pdepth > depth) { |
372 | do { | 286 | do { |
373 | p--; | 287 | p--; |
@@ -375,16 +289,14 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) | |||
375 | pdepth--; | 289 | pdepth--; |
376 | } | 290 | } |
377 | 291 | ||
378 | if (pdepth >= depth) { | 292 | name = fdt_get_name(fdt, offset, &namelen); |
379 | name = fdt_get_name(fdt, offset, &namelen); | 293 | if (!name) |
380 | if (!name) | 294 | return namelen; |
381 | return namelen; | 295 | if ((p + namelen + 1) <= buflen) { |
382 | if ((p + namelen + 1) <= buflen) { | 296 | memcpy(buf + p, name, namelen); |
383 | memcpy(buf + p, name, namelen); | 297 | p += namelen; |
384 | p += namelen; | 298 | buf[p++] = '/'; |
385 | buf[p++] = '/'; | 299 | pdepth++; |
386 | pdepth++; | ||
387 | } | ||
388 | } | 300 | } |
389 | 301 | ||
390 | if (offset == nodeoffset) { | 302 | if (offset == nodeoffset) { |
@@ -394,7 +306,7 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) | |||
394 | if (p > 1) /* special case so that root path is "/", not "" */ | 306 | if (p > 1) /* special case so that root path is "/", not "" */ |
395 | p--; | 307 | p--; |
396 | buf[p] = '\0'; | 308 | buf[p] = '\0'; |
397 | return 0; | 309 | return p; |
398 | } | 310 | } |
399 | } | 311 | } |
400 | 312 | ||
@@ -492,31 +404,14 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, | |||
492 | 404 | ||
493 | int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) | 405 | int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) |
494 | { | 406 | { |
495 | int offset; | ||
496 | |||
497 | if ((phandle == 0) || (phandle == -1)) | 407 | if ((phandle == 0) || (phandle == -1)) |
498 | return -FDT_ERR_BADPHANDLE; | 408 | return -FDT_ERR_BADPHANDLE; |
499 | 409 | phandle = cpu_to_fdt32(phandle); | |
500 | FDT_CHECK_HEADER(fdt); | 410 | return fdt_node_offset_by_prop_value(fdt, -1, "linux,phandle", |
501 | 411 | &phandle, sizeof(phandle)); | |
502 | /* FIXME: The algorithm here is pretty horrible: we | ||
503 | * potentially scan each property of a node in | ||
504 | * fdt_get_phandle(), then if that didn't find what | ||
505 | * we want, we scan over them again making our way to the next | ||
506 | * node. Still it's the easiest to implement approach; | ||
507 | * performance can come later. */ | ||
508 | for (offset = fdt_next_node(fdt, -1, NULL); | ||
509 | offset >= 0; | ||
510 | offset = fdt_next_node(fdt, offset, NULL)) { | ||
511 | if (fdt_get_phandle(fdt, offset) == phandle) | ||
512 | return offset; | ||
513 | } | ||
514 | |||
515 | return offset; /* error from fdt_next_node() */ | ||
516 | } | 412 | } |
517 | 413 | ||
518 | static int _fdt_stringlist_contains(const char *strlist, int listlen, | 414 | static int _stringlist_contains(const char *strlist, int listlen, const char *str) |
519 | const char *str) | ||
520 | { | 415 | { |
521 | int len = strlen(str); | 416 | int len = strlen(str); |
522 | const char *p; | 417 | const char *p; |
@@ -542,7 +437,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, | |||
542 | prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); | 437 | prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); |
543 | if (!prop) | 438 | if (!prop) |
544 | return len; | 439 | return len; |
545 | if (_fdt_stringlist_contains(prop, len, compatible)) | 440 | if (_stringlist_contains(prop, len, compatible)) |
546 | return 0; | 441 | return 0; |
547 | else | 442 | else |
548 | return 1; | 443 | return 1; |
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c index 24437dfc32b..8e7ec4cb7bc 100644 --- a/scripts/dtc/libfdt/fdt_rw.c +++ b/scripts/dtc/libfdt/fdt_rw.c | |||
@@ -289,33 +289,6 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, | |||
289 | return 0; | 289 | return 0; |
290 | } | 290 | } |
291 | 291 | ||
292 | int fdt_appendprop(void *fdt, int nodeoffset, const char *name, | ||
293 | const void *val, int len) | ||
294 | { | ||
295 | struct fdt_property *prop; | ||
296 | int err, oldlen, newlen; | ||
297 | |||
298 | FDT_RW_CHECK_HEADER(fdt); | ||
299 | |||
300 | prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); | ||
301 | if (prop) { | ||
302 | newlen = len + oldlen; | ||
303 | err = _fdt_splice_struct(fdt, prop->data, | ||
304 | FDT_TAGALIGN(oldlen), | ||
305 | FDT_TAGALIGN(newlen)); | ||
306 | if (err) | ||
307 | return err; | ||
308 | prop->len = cpu_to_fdt32(newlen); | ||
309 | memcpy(prop->data + oldlen, val, len); | ||
310 | } else { | ||
311 | err = _fdt_add_property(fdt, nodeoffset, name, len, &prop); | ||
312 | if (err) | ||
313 | return err; | ||
314 | memcpy(prop->data, val, len); | ||
315 | } | ||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | int fdt_delprop(void *fdt, int nodeoffset, const char *name) | 292 | int fdt_delprop(void *fdt, int nodeoffset, const char *name) |
320 | { | 293 | { |
321 | struct fdt_property *prop; | 294 | struct fdt_property *prop; |
@@ -433,8 +406,6 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) | |||
433 | struct_size = 0; | 406 | struct_size = 0; |
434 | while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END) | 407 | while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END) |
435 | ; | 408 | ; |
436 | if (struct_size < 0) | ||
437 | return struct_size; | ||
438 | } | 409 | } |
439 | 410 | ||
440 | if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) { | 411 | if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) { |
diff --git a/scripts/dtc/libfdt/fdt_sw.c b/scripts/dtc/libfdt/fdt_sw.c index 55ebebf1eb2..698329e0cca 100644 --- a/scripts/dtc/libfdt/fdt_sw.c +++ b/scripts/dtc/libfdt/fdt_sw.c | |||
@@ -70,7 +70,7 @@ static int _fdt_sw_check_header(void *fdt) | |||
70 | return err; \ | 70 | return err; \ |
71 | } | 71 | } |
72 | 72 | ||
73 | static void *_fdt_grab_space(void *fdt, size_t len) | 73 | static void *_fdt_grab_space(void *fdt, int len) |
74 | { | 74 | { |
75 | int offset = fdt_size_dt_struct(fdt); | 75 | int offset = fdt_size_dt_struct(fdt); |
76 | int spaceleft; | 76 | int spaceleft; |
@@ -82,7 +82,7 @@ static void *_fdt_grab_space(void *fdt, size_t len) | |||
82 | return NULL; | 82 | return NULL; |
83 | 83 | ||
84 | fdt_set_size_dt_struct(fdt, offset + len); | 84 | fdt_set_size_dt_struct(fdt, offset + len); |
85 | return _fdt_offset_ptr_w(fdt, offset); | 85 | return fdt_offset_ptr_w(fdt, offset, len); |
86 | } | 86 | } |
87 | 87 | ||
88 | int fdt_create(void *buf, int bufsize) | 88 | int fdt_create(void *buf, int bufsize) |
@@ -237,17 +237,18 @@ int fdt_finish(void *fdt) | |||
237 | while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) { | 237 | while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) { |
238 | if (tag == FDT_PROP) { | 238 | if (tag == FDT_PROP) { |
239 | struct fdt_property *prop = | 239 | struct fdt_property *prop = |
240 | _fdt_offset_ptr_w(fdt, offset); | 240 | fdt_offset_ptr_w(fdt, offset, sizeof(*prop)); |
241 | int nameoff; | 241 | int nameoff; |
242 | 242 | ||
243 | if (! prop) | ||
244 | return -FDT_ERR_BADSTRUCTURE; | ||
245 | |||
243 | nameoff = fdt32_to_cpu(prop->nameoff); | 246 | nameoff = fdt32_to_cpu(prop->nameoff); |
244 | nameoff += fdt_size_dt_strings(fdt); | 247 | nameoff += fdt_size_dt_strings(fdt); |
245 | prop->nameoff = cpu_to_fdt32(nameoff); | 248 | prop->nameoff = cpu_to_fdt32(nameoff); |
246 | } | 249 | } |
247 | offset = nextoffset; | 250 | offset = nextoffset; |
248 | } | 251 | } |
249 | if (nextoffset < 0) | ||
250 | return nextoffset; | ||
251 | 252 | ||
252 | /* Finally, adjust the header */ | 253 | /* Finally, adjust the header */ |
253 | fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt)); | 254 | fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt)); |
diff --git a/scripts/dtc/libfdt/fdt_wip.c b/scripts/dtc/libfdt/fdt_wip.c index 6025fa1fe8f..a4652c6e787 100644 --- a/scripts/dtc/libfdt/fdt_wip.c +++ b/scripts/dtc/libfdt/fdt_wip.c | |||
@@ -94,14 +94,41 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name) | |||
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
96 | 96 | ||
97 | int _fdt_node_end_offset(void *fdt, int offset) | 97 | int _fdt_node_end_offset(void *fdt, int nodeoffset) |
98 | { | 98 | { |
99 | int depth = 0; | 99 | int level = 0; |
100 | 100 | uint32_t tag; | |
101 | while ((offset >= 0) && (depth >= 0)) | 101 | int offset, nextoffset; |
102 | offset = fdt_next_node(fdt, offset, &depth); | 102 | |
103 | 103 | tag = fdt_next_tag(fdt, nodeoffset, &nextoffset); | |
104 | return offset; | 104 | if (tag != FDT_BEGIN_NODE) |
105 | return -FDT_ERR_BADOFFSET; | ||
106 | do { | ||
107 | offset = nextoffset; | ||
108 | tag = fdt_next_tag(fdt, offset, &nextoffset); | ||
109 | |||
110 | switch (tag) { | ||
111 | case FDT_END: | ||
112 | return offset; | ||
113 | |||
114 | case FDT_BEGIN_NODE: | ||
115 | level++; | ||
116 | break; | ||
117 | |||
118 | case FDT_END_NODE: | ||
119 | level--; | ||
120 | break; | ||
121 | |||
122 | case FDT_PROP: | ||
123 | case FDT_NOP: | ||
124 | break; | ||
125 | |||
126 | default: | ||
127 | return -FDT_ERR_BADSTRUCTURE; | ||
128 | } | ||
129 | } while (level >= 0); | ||
130 | |||
131 | return nextoffset; | ||
105 | } | 132 | } |
106 | 133 | ||
107 | int fdt_nop_node(void *fdt, int nodeoffset) | 134 | int fdt_nop_node(void *fdt, int nodeoffset) |
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h index 73f49759a5e..ff6246f000c 100644 --- a/scripts/dtc/libfdt/libfdt.h +++ b/scripts/dtc/libfdt/libfdt.h | |||
@@ -61,7 +61,7 @@ | |||
61 | #define FDT_ERR_NOTFOUND 1 | 61 | #define FDT_ERR_NOTFOUND 1 |
62 | /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ | 62 | /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ |
63 | #define FDT_ERR_EXISTS 2 | 63 | #define FDT_ERR_EXISTS 2 |
64 | /* FDT_ERR_EXISTS: Attemped to create a node or property which | 64 | /* FDT_ERR_EXISTS: Attempted to create a node or property which |
65 | * already exists */ | 65 | * already exists */ |
66 | #define FDT_ERR_NOSPACE 3 | 66 | #define FDT_ERR_NOSPACE 3 |
67 | /* FDT_ERR_NOSPACE: Operation needed to expand the device | 67 | /* FDT_ERR_NOSPACE: Operation needed to expand the device |
@@ -122,7 +122,7 @@ | |||
122 | /* Low-level functions (you probably don't need these) */ | 122 | /* Low-level functions (you probably don't need these) */ |
123 | /**********************************************************************/ | 123 | /**********************************************************************/ |
124 | 124 | ||
125 | const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen); | 125 | const void *fdt_offset_ptr(const void *fdt, int offset, int checklen); |
126 | static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) | 126 | static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) |
127 | { | 127 | { |
128 | return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); | 128 | return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); |
@@ -156,7 +156,7 @@ int fdt_next_node(const void *fdt, int offset, int *depth); | |||
156 | #define __fdt_set_hdr(name) \ | 156 | #define __fdt_set_hdr(name) \ |
157 | static inline void fdt_set_##name(void *fdt, uint32_t val) \ | 157 | static inline void fdt_set_##name(void *fdt, uint32_t val) \ |
158 | { \ | 158 | { \ |
159 | struct fdt_header *fdth = (struct fdt_header*)fdt; \ | 159 | struct fdt_header *fdth = fdt; \ |
160 | fdth->name = cpu_to_fdt32(val); \ | 160 | fdth->name = cpu_to_fdt32(val); \ |
161 | } | 161 | } |
162 | __fdt_set_hdr(magic); | 162 | __fdt_set_hdr(magic); |
@@ -343,91 +343,6 @@ int fdt_path_offset(const void *fdt, const char *path); | |||
343 | const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); | 343 | const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); |
344 | 344 | ||
345 | /** | 345 | /** |
346 | * fdt_first_property_offset - find the offset of a node's first property | ||
347 | * @fdt: pointer to the device tree blob | ||
348 | * @nodeoffset: structure block offset of a node | ||
349 | * | ||
350 | * fdt_first_property_offset() finds the first property of the node at | ||
351 | * the given structure block offset. | ||
352 | * | ||
353 | * returns: | ||
354 | * structure block offset of the property (>=0), on success | ||
355 | * -FDT_ERR_NOTFOUND, if the requested node has no properties | ||
356 | * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag | ||
357 | * -FDT_ERR_BADMAGIC, | ||
358 | * -FDT_ERR_BADVERSION, | ||
359 | * -FDT_ERR_BADSTATE, | ||
360 | * -FDT_ERR_BADSTRUCTURE, | ||
361 | * -FDT_ERR_TRUNCATED, standard meanings. | ||
362 | */ | ||
363 | int fdt_first_property_offset(const void *fdt, int nodeoffset); | ||
364 | |||
365 | /** | ||
366 | * fdt_next_property_offset - step through a node's properties | ||
367 | * @fdt: pointer to the device tree blob | ||
368 | * @offset: structure block offset of a property | ||
369 | * | ||
370 | * fdt_next_property_offset() finds the property immediately after the | ||
371 | * one at the given structure block offset. This will be a property | ||
372 | * of the same node as the given property. | ||
373 | * | ||
374 | * returns: | ||
375 | * structure block offset of the next property (>=0), on success | ||
376 | * -FDT_ERR_NOTFOUND, if the given property is the last in its node | ||
377 | * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag | ||
378 | * -FDT_ERR_BADMAGIC, | ||
379 | * -FDT_ERR_BADVERSION, | ||
380 | * -FDT_ERR_BADSTATE, | ||
381 | * -FDT_ERR_BADSTRUCTURE, | ||
382 | * -FDT_ERR_TRUNCATED, standard meanings. | ||
383 | */ | ||
384 | int fdt_next_property_offset(const void *fdt, int offset); | ||
385 | |||
386 | /** | ||
387 | * fdt_get_property_by_offset - retrieve the property at a given offset | ||
388 | * @fdt: pointer to the device tree blob | ||
389 | * @offset: offset of the property to retrieve | ||
390 | * @lenp: pointer to an integer variable (will be overwritten) or NULL | ||
391 | * | ||
392 | * fdt_get_property_by_offset() retrieves a pointer to the | ||
393 | * fdt_property structure within the device tree blob at the given | ||
394 | * offset. If lenp is non-NULL, the length of the property value is | ||
395 | * also returned, in the integer pointed to by lenp. | ||
396 | * | ||
397 | * returns: | ||
398 | * pointer to the structure representing the property | ||
399 | * if lenp is non-NULL, *lenp contains the length of the property | ||
400 | * value (>=0) | ||
401 | * NULL, on error | ||
402 | * if lenp is non-NULL, *lenp contains an error code (<0): | ||
403 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag | ||
404 | * -FDT_ERR_BADMAGIC, | ||
405 | * -FDT_ERR_BADVERSION, | ||
406 | * -FDT_ERR_BADSTATE, | ||
407 | * -FDT_ERR_BADSTRUCTURE, | ||
408 | * -FDT_ERR_TRUNCATED, standard meanings | ||
409 | */ | ||
410 | const struct fdt_property *fdt_get_property_by_offset(const void *fdt, | ||
411 | int offset, | ||
412 | int *lenp); | ||
413 | |||
414 | /** | ||
415 | * fdt_get_property_namelen - find a property based on substring | ||
416 | * @fdt: pointer to the device tree blob | ||
417 | * @nodeoffset: offset of the node whose property to find | ||
418 | * @name: name of the property to find | ||
419 | * @namelen: number of characters of name to consider | ||
420 | * @lenp: pointer to an integer variable (will be overwritten) or NULL | ||
421 | * | ||
422 | * Identical to fdt_get_property_namelen(), but only examine the first | ||
423 | * namelen characters of name for matching the property name. | ||
424 | */ | ||
425 | const struct fdt_property *fdt_get_property_namelen(const void *fdt, | ||
426 | int nodeoffset, | ||
427 | const char *name, | ||
428 | int namelen, int *lenp); | ||
429 | |||
430 | /** | ||
431 | * fdt_get_property - find a given property in a given node | 346 | * fdt_get_property - find a given property in a given node |
432 | * @fdt: pointer to the device tree blob | 347 | * @fdt: pointer to the device tree blob |
433 | * @nodeoffset: offset of the node whose property to find | 348 | * @nodeoffset: offset of the node whose property to find |
@@ -465,54 +380,6 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset, | |||
465 | } | 380 | } |
466 | 381 | ||
467 | /** | 382 | /** |
468 | * fdt_getprop_by_offset - retrieve the value of a property at a given offset | ||
469 | * @fdt: pointer to the device tree blob | ||
470 | * @ffset: offset of the property to read | ||
471 | * @namep: pointer to a string variable (will be overwritten) or NULL | ||
472 | * @lenp: pointer to an integer variable (will be overwritten) or NULL | ||
473 | * | ||
474 | * fdt_getprop_by_offset() retrieves a pointer to the value of the | ||
475 | * property at structure block offset 'offset' (this will be a pointer | ||
476 | * to within the device blob itself, not a copy of the value). If | ||
477 | * lenp is non-NULL, the length of the property value is also | ||
478 | * returned, in the integer pointed to by lenp. If namep is non-NULL, | ||
479 | * the property's namne will also be returned in the char * pointed to | ||
480 | * by namep (this will be a pointer to within the device tree's string | ||
481 | * block, not a new copy of the name). | ||
482 | * | ||
483 | * returns: | ||
484 | * pointer to the property's value | ||
485 | * if lenp is non-NULL, *lenp contains the length of the property | ||
486 | * value (>=0) | ||
487 | * if namep is non-NULL *namep contiains a pointer to the property | ||
488 | * name. | ||
489 | * NULL, on error | ||
490 | * if lenp is non-NULL, *lenp contains an error code (<0): | ||
491 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag | ||
492 | * -FDT_ERR_BADMAGIC, | ||
493 | * -FDT_ERR_BADVERSION, | ||
494 | * -FDT_ERR_BADSTATE, | ||
495 | * -FDT_ERR_BADSTRUCTURE, | ||
496 | * -FDT_ERR_TRUNCATED, standard meanings | ||
497 | */ | ||
498 | const void *fdt_getprop_by_offset(const void *fdt, int offset, | ||
499 | const char **namep, int *lenp); | ||
500 | |||
501 | /** | ||
502 | * fdt_getprop_namelen - get property value based on substring | ||
503 | * @fdt: pointer to the device tree blob | ||
504 | * @nodeoffset: offset of the node whose property to find | ||
505 | * @name: name of the property to find | ||
506 | * @namelen: number of characters of name to consider | ||
507 | * @lenp: pointer to an integer variable (will be overwritten) or NULL | ||
508 | * | ||
509 | * Identical to fdt_getprop(), but only examine the first namelen | ||
510 | * characters of name for matching the property name. | ||
511 | */ | ||
512 | const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, | ||
513 | const char *name, int namelen, int *lenp); | ||
514 | |||
515 | /** | ||
516 | * fdt_getprop - retrieve the value of a given property | 383 | * fdt_getprop - retrieve the value of a given property |
517 | * @fdt: pointer to the device tree blob | 384 | * @fdt: pointer to the device tree blob |
518 | * @nodeoffset: offset of the node whose property to find | 385 | * @nodeoffset: offset of the node whose property to find |
@@ -562,32 +429,6 @@ static inline void *fdt_getprop_w(void *fdt, int nodeoffset, | |||
562 | uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); | 429 | uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); |
563 | 430 | ||
564 | /** | 431 | /** |
565 | * fdt_get_alias_namelen - get alias based on substring | ||
566 | * @fdt: pointer to the device tree blob | ||
567 | * @name: name of the alias th look up | ||
568 | * @namelen: number of characters of name to consider | ||
569 | * | ||
570 | * Identical to fdt_get_alias(), but only examine the first namelen | ||
571 | * characters of name for matching the alias name. | ||
572 | */ | ||
573 | const char *fdt_get_alias_namelen(const void *fdt, | ||
574 | const char *name, int namelen); | ||
575 | |||
576 | /** | ||
577 | * fdt_get_alias - retreive the path referenced by a given alias | ||
578 | * @fdt: pointer to the device tree blob | ||
579 | * @name: name of the alias th look up | ||
580 | * | ||
581 | * fdt_get_alias() retrieves the value of a given alias. That is, the | ||
582 | * value of the property named 'name' in the node /aliases. | ||
583 | * | ||
584 | * returns: | ||
585 | * a pointer to the expansion of the alias named 'name', of it exists | ||
586 | * NULL, if the given alias or the /aliases node does not exist | ||
587 | */ | ||
588 | const char *fdt_get_alias(const void *fdt, const char *name); | ||
589 | |||
590 | /** | ||
591 | * fdt_get_path - determine the full path of a node | 432 | * fdt_get_path - determine the full path of a node |
592 | * @fdt: pointer to the device tree blob | 433 | * @fdt: pointer to the device tree blob |
593 | * @nodeoffset: offset of the node whose path to find | 434 | * @nodeoffset: offset of the node whose path to find |
@@ -852,17 +693,17 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, | |||
852 | const void *val, int len); | 693 | const void *val, int len); |
853 | 694 | ||
854 | /** | 695 | /** |
855 | * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property | 696 | * fdt_setprop_inplace_cell - change the value of a single-cell property |
856 | * @fdt: pointer to the device tree blob | 697 | * @fdt: pointer to the device tree blob |
857 | * @nodeoffset: offset of the node whose property to change | 698 | * @nodeoffset: offset of the node whose property to change |
858 | * @name: name of the property to change | 699 | * @name: name of the property to change |
859 | * @val: 32-bit integer value to replace the property with | 700 | * @val: cell (32-bit integer) value to replace the property with |
860 | * | 701 | * |
861 | * fdt_setprop_inplace_u32() replaces the value of a given property | 702 | * fdt_setprop_inplace_cell() replaces the value of a given property |
862 | * with the 32-bit integer value in val, converting val to big-endian | 703 | * with the 32-bit integer cell value in val, converting val to |
863 | * if necessary. This function cannot change the size of a property, | 704 | * big-endian if necessary. This function cannot change the size of a |
864 | * and so will only work if the property already exists and has length | 705 | * property, and so will only work if the property already exists and |
865 | * 4. | 706 | * has length 4. |
866 | * | 707 | * |
867 | * This function will alter only the bytes in the blob which contain | 708 | * This function will alter only the bytes in the blob which contain |
868 | * the given property value, and will not alter or move any other part | 709 | * the given property value, and will not alter or move any other part |
@@ -871,42 +712,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, | |||
871 | * returns: | 712 | * returns: |
872 | * 0, on success | 713 | * 0, on success |
873 | * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 | 714 | * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 |
874 | * -FDT_ERR_NOTFOUND, node does not have the named property | 715 | * -FDT_ERR_NOTFOUND, node does not have the named property |
875 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | ||
876 | * -FDT_ERR_BADMAGIC, | ||
877 | * -FDT_ERR_BADVERSION, | ||
878 | * -FDT_ERR_BADSTATE, | ||
879 | * -FDT_ERR_BADSTRUCTURE, | ||
880 | * -FDT_ERR_TRUNCATED, standard meanings | ||
881 | */ | ||
882 | static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, | ||
883 | const char *name, uint32_t val) | ||
884 | { | ||
885 | val = cpu_to_fdt32(val); | ||
886 | return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); | ||
887 | } | ||
888 | |||
889 | /** | ||
890 | * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property | ||
891 | * @fdt: pointer to the device tree blob | ||
892 | * @nodeoffset: offset of the node whose property to change | ||
893 | * @name: name of the property to change | ||
894 | * @val: 64-bit integer value to replace the property with | ||
895 | * | ||
896 | * fdt_setprop_inplace_u64() replaces the value of a given property | ||
897 | * with the 64-bit integer value in val, converting val to big-endian | ||
898 | * if necessary. This function cannot change the size of a property, | ||
899 | * and so will only work if the property already exists and has length | ||
900 | * 8. | ||
901 | * | ||
902 | * This function will alter only the bytes in the blob which contain | ||
903 | * the given property value, and will not alter or move any other part | ||
904 | * of the tree. | ||
905 | * | ||
906 | * returns: | ||
907 | * 0, on success | ||
908 | * -FDT_ERR_NOSPACE, if the property's length is not equal to 8 | ||
909 | * -FDT_ERR_NOTFOUND, node does not have the named property | ||
910 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | 716 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag |
911 | * -FDT_ERR_BADMAGIC, | 717 | * -FDT_ERR_BADMAGIC, |
912 | * -FDT_ERR_BADVERSION, | 718 | * -FDT_ERR_BADVERSION, |
@@ -914,22 +720,11 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, | |||
914 | * -FDT_ERR_BADSTRUCTURE, | 720 | * -FDT_ERR_BADSTRUCTURE, |
915 | * -FDT_ERR_TRUNCATED, standard meanings | 721 | * -FDT_ERR_TRUNCATED, standard meanings |
916 | */ | 722 | */ |
917 | static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, | ||
918 | const char *name, uint64_t val) | ||
919 | { | ||
920 | val = cpu_to_fdt64(val); | ||
921 | return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); | ||
922 | } | ||
923 | |||
924 | /** | ||
925 | * fdt_setprop_inplace_cell - change the value of a single-cell property | ||
926 | * | ||
927 | * This is an alternative name for fdt_setprop_inplace_u32() | ||
928 | */ | ||
929 | static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, | 723 | static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, |
930 | const char *name, uint32_t val) | 724 | const char *name, uint32_t val) |
931 | { | 725 | { |
932 | return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val); | 726 | val = cpu_to_fdt32(val); |
727 | return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); | ||
933 | } | 728 | } |
934 | 729 | ||
935 | /** | 730 | /** |
@@ -991,20 +786,11 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); | |||
991 | int fdt_finish_reservemap(void *fdt); | 786 | int fdt_finish_reservemap(void *fdt); |
992 | int fdt_begin_node(void *fdt, const char *name); | 787 | int fdt_begin_node(void *fdt, const char *name); |
993 | int fdt_property(void *fdt, const char *name, const void *val, int len); | 788 | int fdt_property(void *fdt, const char *name, const void *val, int len); |
994 | static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val) | 789 | static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) |
995 | { | 790 | { |
996 | val = cpu_to_fdt32(val); | 791 | val = cpu_to_fdt32(val); |
997 | return fdt_property(fdt, name, &val, sizeof(val)); | 792 | return fdt_property(fdt, name, &val, sizeof(val)); |
998 | } | 793 | } |
999 | static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) | ||
1000 | { | ||
1001 | val = cpu_to_fdt64(val); | ||
1002 | return fdt_property(fdt, name, &val, sizeof(val)); | ||
1003 | } | ||
1004 | static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) | ||
1005 | { | ||
1006 | return fdt_property_u32(fdt, name, val); | ||
1007 | } | ||
1008 | #define fdt_property_string(fdt, name, str) \ | 794 | #define fdt_property_string(fdt, name, str) \ |
1009 | fdt_property(fdt, name, str, strlen(str)+1) | 795 | fdt_property(fdt, name, str, strlen(str)+1) |
1010 | int fdt_end_node(void *fdt); | 796 | int fdt_end_node(void *fdt); |
@@ -1014,7 +800,6 @@ int fdt_finish(void *fdt); | |||
1014 | /* Read-write functions */ | 800 | /* Read-write functions */ |
1015 | /**********************************************************************/ | 801 | /**********************************************************************/ |
1016 | 802 | ||
1017 | int fdt_create_empty_tree(void *buf, int bufsize); | ||
1018 | int fdt_open_into(const void *fdt, void *buf, int bufsize); | 803 | int fdt_open_into(const void *fdt, void *buf, int bufsize); |
1019 | int fdt_pack(void *fdt); | 804 | int fdt_pack(void *fdt); |
1020 | 805 | ||
@@ -1124,14 +909,14 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, | |||
1124 | const void *val, int len); | 909 | const void *val, int len); |
1125 | 910 | ||
1126 | /** | 911 | /** |
1127 | * fdt_setprop_u32 - set a property to a 32-bit integer | 912 | * fdt_setprop_cell - set a property to a single cell value |
1128 | * @fdt: pointer to the device tree blob | 913 | * @fdt: pointer to the device tree blob |
1129 | * @nodeoffset: offset of the node whose property to change | 914 | * @nodeoffset: offset of the node whose property to change |
1130 | * @name: name of the property to change | 915 | * @name: name of the property to change |
1131 | * @val: 32-bit integer value for the property (native endian) | 916 | * @val: 32-bit integer value for the property (native endian) |
1132 | * | 917 | * |
1133 | * fdt_setprop_u32() sets the value of the named property in the given | 918 | * fdt_setprop_cell() sets the value of the named property in the |
1134 | * node to the given 32-bit integer value (converting to big-endian if | 919 | * given node to the given cell value (converting to big-endian if |
1135 | * necessary), or creates a new property with that value if it does | 920 | * necessary), or creates a new property with that value if it does |
1136 | * not already exist. | 921 | * not already exist. |
1137 | * | 922 | * |
@@ -1151,57 +936,11 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, | |||
1151 | * -FDT_ERR_BADLAYOUT, | 936 | * -FDT_ERR_BADLAYOUT, |
1152 | * -FDT_ERR_TRUNCATED, standard meanings | 937 | * -FDT_ERR_TRUNCATED, standard meanings |
1153 | */ | 938 | */ |
1154 | static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, | ||
1155 | uint32_t val) | ||
1156 | { | ||
1157 | val = cpu_to_fdt32(val); | ||
1158 | return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); | ||
1159 | } | ||
1160 | |||
1161 | /** | ||
1162 | * fdt_setprop_u64 - set a property to a 64-bit integer | ||
1163 | * @fdt: pointer to the device tree blob | ||
1164 | * @nodeoffset: offset of the node whose property to change | ||
1165 | * @name: name of the property to change | ||
1166 | * @val: 64-bit integer value for the property (native endian) | ||
1167 | * | ||
1168 | * fdt_setprop_u64() sets the value of the named property in the given | ||
1169 | * node to the given 64-bit integer value (converting to big-endian if | ||
1170 | * necessary), or creates a new property with that value if it does | ||
1171 | * not already exist. | ||
1172 | * | ||
1173 | * This function may insert or delete data from the blob, and will | ||
1174 | * therefore change the offsets of some existing nodes. | ||
1175 | * | ||
1176 | * returns: | ||
1177 | * 0, on success | ||
1178 | * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to | ||
1179 | * contain the new property value | ||
1180 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | ||
1181 | * -FDT_ERR_BADLAYOUT, | ||
1182 | * -FDT_ERR_BADMAGIC, | ||
1183 | * -FDT_ERR_BADVERSION, | ||
1184 | * -FDT_ERR_BADSTATE, | ||
1185 | * -FDT_ERR_BADSTRUCTURE, | ||
1186 | * -FDT_ERR_BADLAYOUT, | ||
1187 | * -FDT_ERR_TRUNCATED, standard meanings | ||
1188 | */ | ||
1189 | static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, | ||
1190 | uint64_t val) | ||
1191 | { | ||
1192 | val = cpu_to_fdt64(val); | ||
1193 | return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); | ||
1194 | } | ||
1195 | |||
1196 | /** | ||
1197 | * fdt_setprop_cell - set a property to a single cell value | ||
1198 | * | ||
1199 | * This is an alternative name for fdt_setprop_u32() | ||
1200 | */ | ||
1201 | static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, | 939 | static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, |
1202 | uint32_t val) | 940 | uint32_t val) |
1203 | { | 941 | { |
1204 | return fdt_setprop_u32(fdt, nodeoffset, name, val); | 942 | val = cpu_to_fdt32(val); |
943 | return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); | ||
1205 | } | 944 | } |
1206 | 945 | ||
1207 | /** | 946 | /** |
@@ -1236,147 +975,6 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, | |||
1236 | fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) | 975 | fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) |
1237 | 976 | ||
1238 | /** | 977 | /** |
1239 | * fdt_appendprop - append to or create a property | ||
1240 | * @fdt: pointer to the device tree blob | ||
1241 | * @nodeoffset: offset of the node whose property to change | ||
1242 | * @name: name of the property to append to | ||
1243 | * @val: pointer to data to append to the property value | ||
1244 | * @len: length of the data to append to the property value | ||
1245 | * | ||
1246 | * fdt_appendprop() appends the value to the named property in the | ||
1247 | * given node, creating the property if it does not already exist. | ||
1248 | * | ||
1249 | * This function may insert data into the blob, and will therefore | ||
1250 | * change the offsets of some existing nodes. | ||
1251 | * | ||
1252 | * returns: | ||
1253 | * 0, on success | ||
1254 | * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to | ||
1255 | * contain the new property value | ||
1256 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | ||
1257 | * -FDT_ERR_BADLAYOUT, | ||
1258 | * -FDT_ERR_BADMAGIC, | ||
1259 | * -FDT_ERR_BADVERSION, | ||
1260 | * -FDT_ERR_BADSTATE, | ||
1261 | * -FDT_ERR_BADSTRUCTURE, | ||
1262 | * -FDT_ERR_BADLAYOUT, | ||
1263 | * -FDT_ERR_TRUNCATED, standard meanings | ||
1264 | */ | ||
1265 | int fdt_appendprop(void *fdt, int nodeoffset, const char *name, | ||
1266 | const void *val, int len); | ||
1267 | |||
1268 | /** | ||
1269 | * fdt_appendprop_u32 - append a 32-bit integer value to a property | ||
1270 | * @fdt: pointer to the device tree blob | ||
1271 | * @nodeoffset: offset of the node whose property to change | ||
1272 | * @name: name of the property to change | ||
1273 | * @val: 32-bit integer value to append to the property (native endian) | ||
1274 | * | ||
1275 | * fdt_appendprop_u32() appends the given 32-bit integer value | ||
1276 | * (converting to big-endian if necessary) to the value of the named | ||
1277 | * property in the given node, or creates a new property with that | ||
1278 | * value if it does not already exist. | ||
1279 | * | ||
1280 | * This function may insert data into the blob, and will therefore | ||
1281 | * change the offsets of some existing nodes. | ||
1282 | * | ||
1283 | * returns: | ||
1284 | * 0, on success | ||
1285 | * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to | ||
1286 | * contain the new property value | ||
1287 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | ||
1288 | * -FDT_ERR_BADLAYOUT, | ||
1289 | * -FDT_ERR_BADMAGIC, | ||
1290 | * -FDT_ERR_BADVERSION, | ||
1291 | * -FDT_ERR_BADSTATE, | ||
1292 | * -FDT_ERR_BADSTRUCTURE, | ||
1293 | * -FDT_ERR_BADLAYOUT, | ||
1294 | * -FDT_ERR_TRUNCATED, standard meanings | ||
1295 | */ | ||
1296 | static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, | ||
1297 | const char *name, uint32_t val) | ||
1298 | { | ||
1299 | val = cpu_to_fdt32(val); | ||
1300 | return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val)); | ||
1301 | } | ||
1302 | |||
1303 | /** | ||
1304 | * fdt_appendprop_u64 - append a 64-bit integer value to a property | ||
1305 | * @fdt: pointer to the device tree blob | ||
1306 | * @nodeoffset: offset of the node whose property to change | ||
1307 | * @name: name of the property to change | ||
1308 | * @val: 64-bit integer value to append to the property (native endian) | ||
1309 | * | ||
1310 | * fdt_appendprop_u64() appends the given 64-bit integer value | ||
1311 | * (converting to big-endian if necessary) to the value of the named | ||
1312 | * property in the given node, or creates a new property with that | ||
1313 | * value if it does not already exist. | ||
1314 | * | ||
1315 | * This function may insert data into the blob, and will therefore | ||
1316 | * change the offsets of some existing nodes. | ||
1317 | * | ||
1318 | * returns: | ||
1319 | * 0, on success | ||
1320 | * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to | ||
1321 | * contain the new property value | ||
1322 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | ||
1323 | * -FDT_ERR_BADLAYOUT, | ||
1324 | * -FDT_ERR_BADMAGIC, | ||
1325 | * -FDT_ERR_BADVERSION, | ||
1326 | * -FDT_ERR_BADSTATE, | ||
1327 | * -FDT_ERR_BADSTRUCTURE, | ||
1328 | * -FDT_ERR_BADLAYOUT, | ||
1329 | * -FDT_ERR_TRUNCATED, standard meanings | ||
1330 | */ | ||
1331 | static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, | ||
1332 | const char *name, uint64_t val) | ||
1333 | { | ||
1334 | val = cpu_to_fdt64(val); | ||
1335 | return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val)); | ||
1336 | } | ||
1337 | |||
1338 | /** | ||
1339 | * fdt_appendprop_cell - append a single cell value to a property | ||
1340 | * | ||
1341 | * This is an alternative name for fdt_appendprop_u32() | ||
1342 | */ | ||
1343 | static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, | ||
1344 | const char *name, uint32_t val) | ||
1345 | { | ||
1346 | return fdt_appendprop_u32(fdt, nodeoffset, name, val); | ||
1347 | } | ||
1348 | |||
1349 | /** | ||
1350 | * fdt_appendprop_string - append a string to a property | ||
1351 | * @fdt: pointer to the device tree blob | ||
1352 | * @nodeoffset: offset of the node whose property to change | ||
1353 | * @name: name of the property to change | ||
1354 | * @str: string value to append to the property | ||
1355 | * | ||
1356 | * fdt_appendprop_string() appends the given string to the value of | ||
1357 | * the named property in the given node, or creates a new property | ||
1358 | * with that value if it does not already exist. | ||
1359 | * | ||
1360 | * This function may insert data into the blob, and will therefore | ||
1361 | * change the offsets of some existing nodes. | ||
1362 | * | ||
1363 | * returns: | ||
1364 | * 0, on success | ||
1365 | * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to | ||
1366 | * contain the new property value | ||
1367 | * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | ||
1368 | * -FDT_ERR_BADLAYOUT, | ||
1369 | * -FDT_ERR_BADMAGIC, | ||
1370 | * -FDT_ERR_BADVERSION, | ||
1371 | * -FDT_ERR_BADSTATE, | ||
1372 | * -FDT_ERR_BADSTRUCTURE, | ||
1373 | * -FDT_ERR_BADLAYOUT, | ||
1374 | * -FDT_ERR_TRUNCATED, standard meanings | ||
1375 | */ | ||
1376 | #define fdt_appendprop_string(fdt, nodeoffset, name, str) \ | ||
1377 | fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) | ||
1378 | |||
1379 | /** | ||
1380 | * fdt_delprop - delete a property | 978 | * fdt_delprop - delete a property |
1381 | * @fdt: pointer to the device tree blob | 979 | * @fdt: pointer to the device tree blob |
1382 | * @nodeoffset: offset of the node whose property to nop | 980 | * @nodeoffset: offset of the node whose property to nop |
diff --git a/scripts/dtc/libfdt/libfdt_env.h b/scripts/dtc/libfdt/libfdt_env.h index 213d7fb81c4..449bf602daf 100644 --- a/scripts/dtc/libfdt/libfdt_env.h +++ b/scripts/dtc/libfdt/libfdt_env.h | |||
@@ -5,25 +5,19 @@ | |||
5 | #include <stdint.h> | 5 | #include <stdint.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | 7 | ||
8 | #define EXTRACT_BYTE(n) ((unsigned long long)((uint8_t *)&x)[n]) | 8 | #define _B(n) ((unsigned long long)((uint8_t *)&x)[n]) |
9 | static inline uint16_t fdt16_to_cpu(uint16_t x) | ||
10 | { | ||
11 | return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1); | ||
12 | } | ||
13 | #define cpu_to_fdt16(x) fdt16_to_cpu(x) | ||
14 | |||
15 | static inline uint32_t fdt32_to_cpu(uint32_t x) | 9 | static inline uint32_t fdt32_to_cpu(uint32_t x) |
16 | { | 10 | { |
17 | return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3); | 11 | return (_B(0) << 24) | (_B(1) << 16) | (_B(2) << 8) | _B(3); |
18 | } | 12 | } |
19 | #define cpu_to_fdt32(x) fdt32_to_cpu(x) | 13 | #define cpu_to_fdt32(x) fdt32_to_cpu(x) |
20 | 14 | ||
21 | static inline uint64_t fdt64_to_cpu(uint64_t x) | 15 | static inline uint64_t fdt64_to_cpu(uint64_t x) |
22 | { | 16 | { |
23 | return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32) | 17 | return (_B(0) << 56) | (_B(1) << 48) | (_B(2) << 40) | (_B(3) << 32) |
24 | | (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7); | 18 | | (_B(4) << 24) | (_B(5) << 16) | (_B(6) << 8) | _B(7); |
25 | } | 19 | } |
26 | #define cpu_to_fdt64(x) fdt64_to_cpu(x) | 20 | #define cpu_to_fdt64(x) fdt64_to_cpu(x) |
27 | #undef EXTRACT_BYTE | 21 | #undef _B |
28 | 22 | ||
29 | #endif /* _LIBFDT_ENV_H */ | 23 | #endif /* _LIBFDT_ENV_H */ |
diff --git a/scripts/dtc/libfdt/libfdt_internal.h b/scripts/dtc/libfdt/libfdt_internal.h index 381133ba81d..46eb93e4af5 100644 --- a/scripts/dtc/libfdt/libfdt_internal.h +++ b/scripts/dtc/libfdt/libfdt_internal.h | |||
@@ -62,8 +62,8 @@ | |||
62 | return err; \ | 62 | return err; \ |
63 | } | 63 | } |
64 | 64 | ||
65 | uint32_t _fdt_next_tag(const void *fdt, int startoffset, int *nextoffset); | ||
65 | int _fdt_check_node_offset(const void *fdt, int offset); | 66 | int _fdt_check_node_offset(const void *fdt, int offset); |
66 | int _fdt_check_prop_offset(const void *fdt, int offset); | ||
67 | const char *_fdt_find_string(const char *strtab, int tabsize, const char *s); | 67 | const char *_fdt_find_string(const char *strtab, int tabsize, const char *s); |
68 | int _fdt_node_end_offset(void *fdt, int nodeoffset); | 68 | int _fdt_node_end_offset(void *fdt, int nodeoffset); |
69 | 69 | ||
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c index b61465fb2f3..26d0e1e60c0 100644 --- a/scripts/dtc/livetree.c +++ b/scripts/dtc/livetree.c | |||
@@ -29,27 +29,16 @@ void add_label(struct label **labels, char *label) | |||
29 | struct label *new; | 29 | struct label *new; |
30 | 30 | ||
31 | /* Make sure the label isn't already there */ | 31 | /* Make sure the label isn't already there */ |
32 | for_each_label_withdel(*labels, new) | 32 | for_each_label(*labels, new) |
33 | if (streq(new->label, label)) { | 33 | if (streq(new->label, label)) |
34 | new->deleted = 0; | ||
35 | return; | 34 | return; |
36 | } | ||
37 | 35 | ||
38 | new = xmalloc(sizeof(*new)); | 36 | new = xmalloc(sizeof(*new)); |
39 | memset(new, 0, sizeof(*new)); | ||
40 | new->label = label; | 37 | new->label = label; |
41 | new->next = *labels; | 38 | new->next = *labels; |
42 | *labels = new; | 39 | *labels = new; |
43 | } | 40 | } |
44 | 41 | ||
45 | void delete_labels(struct label **labels) | ||
46 | { | ||
47 | struct label *label; | ||
48 | |||
49 | for_each_label(*labels, label) | ||
50 | label->deleted = 1; | ||
51 | } | ||
52 | |||
53 | struct property *build_property(char *name, struct data val) | 42 | struct property *build_property(char *name, struct data val) |
54 | { | 43 | { |
55 | struct property *new = xmalloc(sizeof(*new)); | 44 | struct property *new = xmalloc(sizeof(*new)); |
@@ -62,18 +51,6 @@ struct property *build_property(char *name, struct data val) | |||
62 | return new; | 51 | return new; |
63 | } | 52 | } |
64 | 53 | ||
65 | struct property *build_property_delete(char *name) | ||
66 | { | ||
67 | struct property *new = xmalloc(sizeof(*new)); | ||
68 | |||
69 | memset(new, 0, sizeof(*new)); | ||
70 | |||
71 | new->name = name; | ||
72 | new->deleted = 1; | ||
73 | |||
74 | return new; | ||
75 | } | ||
76 | |||
77 | struct property *chain_property(struct property *first, struct property *list) | 54 | struct property *chain_property(struct property *first, struct property *list) |
78 | { | 55 | { |
79 | assert(first->next == NULL); | 56 | assert(first->next == NULL); |
@@ -114,17 +91,6 @@ struct node *build_node(struct property *proplist, struct node *children) | |||
114 | return new; | 91 | return new; |
115 | } | 92 | } |
116 | 93 | ||
117 | struct node *build_node_delete(void) | ||
118 | { | ||
119 | struct node *new = xmalloc(sizeof(*new)); | ||
120 | |||
121 | memset(new, 0, sizeof(*new)); | ||
122 | |||
123 | new->deleted = 1; | ||
124 | |||
125 | return new; | ||
126 | } | ||
127 | |||
128 | struct node *name_node(struct node *node, char *name) | 94 | struct node *name_node(struct node *node, char *name) |
129 | { | 95 | { |
130 | assert(node->name == NULL); | 96 | assert(node->name == NULL); |
@@ -140,10 +106,8 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |||
140 | struct node *new_child, *old_child; | 106 | struct node *new_child, *old_child; |
141 | struct label *l; | 107 | struct label *l; |
142 | 108 | ||
143 | old_node->deleted = 0; | ||
144 | |||
145 | /* Add new node labels to old node */ | 109 | /* Add new node labels to old node */ |
146 | for_each_label_withdel(new_node->labels, l) | 110 | for_each_label(new_node->labels, l) |
147 | add_label(&old_node->labels, l->label); | 111 | add_label(&old_node->labels, l->label); |
148 | 112 | ||
149 | /* Move properties from the new node to the old node. If there | 113 | /* Move properties from the new node to the old node. If there |
@@ -154,21 +118,14 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |||
154 | new_node->proplist = new_prop->next; | 118 | new_node->proplist = new_prop->next; |
155 | new_prop->next = NULL; | 119 | new_prop->next = NULL; |
156 | 120 | ||
157 | if (new_prop->deleted) { | ||
158 | delete_property_by_name(old_node, new_prop->name); | ||
159 | free(new_prop); | ||
160 | continue; | ||
161 | } | ||
162 | |||
163 | /* Look for a collision, set new value if there is */ | 121 | /* Look for a collision, set new value if there is */ |
164 | for_each_property_withdel(old_node, old_prop) { | 122 | for_each_property(old_node, old_prop) { |
165 | if (streq(old_prop->name, new_prop->name)) { | 123 | if (streq(old_prop->name, new_prop->name)) { |
166 | /* Add new labels to old property */ | 124 | /* Add new labels to old property */ |
167 | for_each_label_withdel(new_prop->labels, l) | 125 | for_each_label(new_prop->labels, l) |
168 | add_label(&old_prop->labels, l->label); | 126 | add_label(&old_prop->labels, l->label); |
169 | 127 | ||
170 | old_prop->val = new_prop->val; | 128 | old_prop->val = new_prop->val; |
171 | old_prop->deleted = 0; | ||
172 | free(new_prop); | 129 | free(new_prop); |
173 | new_prop = NULL; | 130 | new_prop = NULL; |
174 | break; | 131 | break; |
@@ -189,14 +146,8 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |||
189 | new_child->parent = NULL; | 146 | new_child->parent = NULL; |
190 | new_child->next_sibling = NULL; | 147 | new_child->next_sibling = NULL; |
191 | 148 | ||
192 | if (new_child->deleted) { | ||
193 | delete_node_by_name(old_node, new_child->name); | ||
194 | free(new_child); | ||
195 | continue; | ||
196 | } | ||
197 | |||
198 | /* Search for a collision. Merge if there is */ | 149 | /* Search for a collision. Merge if there is */ |
199 | for_each_child_withdel(old_node, old_child) { | 150 | for_each_child(old_node, old_child) { |
200 | if (streq(old_child->name, new_child->name)) { | 151 | if (streq(old_child->name, new_child->name)) { |
201 | merge_nodes(old_child, new_child); | 152 | merge_nodes(old_child, new_child); |
202 | new_child = NULL; | 153 | new_child = NULL; |
@@ -204,7 +155,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |||
204 | } | 155 | } |
205 | } | 156 | } |
206 | 157 | ||
207 | /* if no collision occured, add child to the old node. */ | 158 | /* if no collision occurred, add child to the old node. */ |
208 | if (new_child) | 159 | if (new_child) |
209 | add_child(old_node, new_child); | 160 | add_child(old_node, new_child); |
210 | } | 161 | } |
@@ -237,25 +188,6 @@ void add_property(struct node *node, struct property *prop) | |||
237 | *p = prop; | 188 | *p = prop; |
238 | } | 189 | } |
239 | 190 | ||
240 | void delete_property_by_name(struct node *node, char *name) | ||
241 | { | ||
242 | struct property *prop = node->proplist; | ||
243 | |||
244 | while (prop) { | ||
245 | if (!strcmp(prop->name, name)) { | ||
246 | delete_property(prop); | ||
247 | return; | ||
248 | } | ||
249 | prop = prop->next; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | void delete_property(struct property *prop) | ||
254 | { | ||
255 | prop->deleted = 1; | ||
256 | delete_labels(&prop->labels); | ||
257 | } | ||
258 | |||
259 | void add_child(struct node *parent, struct node *child) | 191 | void add_child(struct node *parent, struct node *child) |
260 | { | 192 | { |
261 | struct node **p; | 193 | struct node **p; |
@@ -270,32 +202,6 @@ void add_child(struct node *parent, struct node *child) | |||
270 | *p = child; | 202 | *p = child; |
271 | } | 203 | } |
272 | 204 | ||
273 | void delete_node_by_name(struct node *parent, char *name) | ||
274 | { | ||
275 | struct node *node = parent->children; | ||
276 | |||
277 | while (node) { | ||
278 | if (!strcmp(node->name, name)) { | ||
279 | delete_node(node); | ||
280 | return; | ||
281 | } | ||
282 | node = node->next_sibling; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | void delete_node(struct node *node) | ||
287 | { | ||
288 | struct property *prop; | ||
289 | struct node *child; | ||
290 | |||
291 | node->deleted = 1; | ||
292 | for_each_child(node, child) | ||
293 | delete_node(child); | ||
294 | for_each_property(node, prop) | ||
295 | delete_property(prop); | ||
296 | delete_labels(&node->labels); | ||
297 | } | ||
298 | |||
299 | struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size) | 205 | struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size) |
300 | { | 206 | { |
301 | struct reserve_info *new = xmalloc(sizeof(*new)); | 207 | struct reserve_info *new = xmalloc(sizeof(*new)); |
@@ -447,11 +353,8 @@ struct node *get_node_by_path(struct node *tree, const char *path) | |||
447 | const char *p; | 353 | const char *p; |
448 | struct node *child; | 354 | struct node *child; |
449 | 355 | ||
450 | if (!path || ! (*path)) { | 356 | if (!path || ! (*path)) |
451 | if (tree->deleted) | ||
452 | return NULL; | ||
453 | return tree; | 357 | return tree; |
454 | } | ||
455 | 358 | ||
456 | while (path[0] == '/') | 359 | while (path[0] == '/') |
457 | path++; | 360 | path++; |
@@ -494,11 +397,8 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle) | |||
494 | 397 | ||
495 | assert((phandle != 0) && (phandle != -1)); | 398 | assert((phandle != 0) && (phandle != -1)); |
496 | 399 | ||
497 | if (tree->phandle == phandle) { | 400 | if (tree->phandle == phandle) |
498 | if (tree->deleted) | ||
499 | return NULL; | ||
500 | return tree; | 401 | return tree; |
501 | } | ||
502 | 402 | ||
503 | for_each_child(tree, child) { | 403 | for_each_child(tree, child) { |
504 | node = get_node_by_phandle(child, phandle); | 404 | node = get_node_by_phandle(child, phandle); |
@@ -635,7 +535,7 @@ static void sort_properties(struct node *node) | |||
635 | int n = 0, i = 0; | 535 | int n = 0, i = 0; |
636 | struct property *prop, **tbl; | 536 | struct property *prop, **tbl; |
637 | 537 | ||
638 | for_each_property_withdel(node, prop) | 538 | for_each_property(node, prop) |
639 | n++; | 539 | n++; |
640 | 540 | ||
641 | if (n == 0) | 541 | if (n == 0) |
@@ -643,7 +543,7 @@ static void sort_properties(struct node *node) | |||
643 | 543 | ||
644 | tbl = xmalloc(n * sizeof(*tbl)); | 544 | tbl = xmalloc(n * sizeof(*tbl)); |
645 | 545 | ||
646 | for_each_property_withdel(node, prop) | 546 | for_each_property(node, prop) |
647 | tbl[i++] = prop; | 547 | tbl[i++] = prop; |
648 | 548 | ||
649 | qsort(tbl, n, sizeof(*tbl), cmp_prop); | 549 | qsort(tbl, n, sizeof(*tbl), cmp_prop); |
@@ -671,7 +571,7 @@ static void sort_subnodes(struct node *node) | |||
671 | int n = 0, i = 0; | 571 | int n = 0, i = 0; |
672 | struct node *subnode, **tbl; | 572 | struct node *subnode, **tbl; |
673 | 573 | ||
674 | for_each_child_withdel(node, subnode) | 574 | for_each_child(node, subnode) |
675 | n++; | 575 | n++; |
676 | 576 | ||
677 | if (n == 0) | 577 | if (n == 0) |
@@ -679,7 +579,7 @@ static void sort_subnodes(struct node *node) | |||
679 | 579 | ||
680 | tbl = xmalloc(n * sizeof(*tbl)); | 580 | tbl = xmalloc(n * sizeof(*tbl)); |
681 | 581 | ||
682 | for_each_child_withdel(node, subnode) | 582 | for_each_child(node, subnode) |
683 | tbl[i++] = subnode; | 583 | tbl[i++] = subnode; |
684 | 584 | ||
685 | qsort(tbl, n, sizeof(*tbl), cmp_subnode); | 585 | qsort(tbl, n, sizeof(*tbl), cmp_subnode); |
@@ -698,7 +598,7 @@ static void sort_node(struct node *node) | |||
698 | 598 | ||
699 | sort_properties(node); | 599 | sort_properties(node); |
700 | sort_subnodes(node); | 600 | sort_subnodes(node); |
701 | for_each_child_withdel(node, c) | 601 | for_each_child(node, c) |
702 | sort_node(c); | 602 | sort_node(c); |
703 | } | 603 | } |
704 | 604 | ||
diff --git a/scripts/dtc/srcpos.c b/scripts/dtc/srcpos.c index 246ab4bc0d9..2dbc874288c 100644 --- a/scripts/dtc/srcpos.c +++ b/scripts/dtc/srcpos.c | |||
@@ -24,15 +24,6 @@ | |||
24 | #include "dtc.h" | 24 | #include "dtc.h" |
25 | #include "srcpos.h" | 25 | #include "srcpos.h" |
26 | 26 | ||
27 | /* A node in our list of directories to search for source/include files */ | ||
28 | struct search_path { | ||
29 | struct search_path *next; /* next node in list, NULL for end */ | ||
30 | const char *dirname; /* name of directory to search */ | ||
31 | }; | ||
32 | |||
33 | /* This is the list of directories that we search for source files */ | ||
34 | static struct search_path *search_path_head, **search_path_tail; | ||
35 | |||
36 | 27 | ||
37 | static char *dirname(const char *path) | 28 | static char *dirname(const char *path) |
38 | { | 29 | { |
@@ -49,71 +40,12 @@ static char *dirname(const char *path) | |||
49 | return NULL; | 40 | return NULL; |
50 | } | 41 | } |
51 | 42 | ||
52 | FILE *depfile; /* = NULL */ | ||
53 | struct srcfile_state *current_srcfile; /* = NULL */ | 43 | struct srcfile_state *current_srcfile; /* = NULL */ |
54 | 44 | ||
55 | /* Detect infinite include recursion. */ | 45 | /* Detect infinite include recursion. */ |
56 | #define MAX_SRCFILE_DEPTH (100) | 46 | #define MAX_SRCFILE_DEPTH (100) |
57 | static int srcfile_depth; /* = 0 */ | 47 | static int srcfile_depth; /* = 0 */ |
58 | 48 | ||
59 | |||
60 | /** | ||
61 | * Try to open a file in a given directory. | ||
62 | * | ||
63 | * If the filename is an absolute path, then dirname is ignored. If it is a | ||
64 | * relative path, then we look in that directory for the file. | ||
65 | * | ||
66 | * @param dirname Directory to look in, or NULL for none | ||
67 | * @param fname Filename to look for | ||
68 | * @param fp Set to NULL if file did not open | ||
69 | * @return allocated filename on success (caller must free), NULL on failure | ||
70 | */ | ||
71 | static char *try_open(const char *dirname, const char *fname, FILE **fp) | ||
72 | { | ||
73 | char *fullname; | ||
74 | |||
75 | if (!dirname || fname[0] == '/') | ||
76 | fullname = xstrdup(fname); | ||
77 | else | ||
78 | fullname = join_path(dirname, fname); | ||
79 | |||
80 | *fp = fopen(fullname, "r"); | ||
81 | if (!*fp) { | ||
82 | free(fullname); | ||
83 | fullname = NULL; | ||
84 | } | ||
85 | |||
86 | return fullname; | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * Open a file for read access | ||
91 | * | ||
92 | * If it is a relative filename, we search the full search path for it. | ||
93 | * | ||
94 | * @param fname Filename to open | ||
95 | * @param fp Returns pointer to opened FILE, or NULL on failure | ||
96 | * @return pointer to allocated filename, which caller must free | ||
97 | */ | ||
98 | static char *fopen_any_on_path(const char *fname, FILE **fp) | ||
99 | { | ||
100 | const char *cur_dir = NULL; | ||
101 | struct search_path *node; | ||
102 | char *fullname; | ||
103 | |||
104 | /* Try current directory first */ | ||
105 | assert(fp); | ||
106 | if (current_srcfile) | ||
107 | cur_dir = current_srcfile->dir; | ||
108 | fullname = try_open(cur_dir, fname, fp); | ||
109 | |||
110 | /* Failing that, try each search path in turn */ | ||
111 | for (node = search_path_head; !*fp && node; node = node->next) | ||
112 | fullname = try_open(node->dirname, fname, fp); | ||
113 | |||
114 | return fullname; | ||
115 | } | ||
116 | |||
117 | FILE *srcfile_relative_open(const char *fname, char **fullnamep) | 49 | FILE *srcfile_relative_open(const char *fname, char **fullnamep) |
118 | { | 50 | { |
119 | FILE *f; | 51 | FILE *f; |
@@ -123,15 +55,18 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep) | |||
123 | f = stdin; | 55 | f = stdin; |
124 | fullname = xstrdup("<stdin>"); | 56 | fullname = xstrdup("<stdin>"); |
125 | } else { | 57 | } else { |
126 | fullname = fopen_any_on_path(fname, &f); | 58 | if (!current_srcfile || !current_srcfile->dir |
59 | || (fname[0] == '/')) | ||
60 | fullname = xstrdup(fname); | ||
61 | else | ||
62 | fullname = join_path(current_srcfile->dir, fname); | ||
63 | |||
64 | f = fopen(fullname, "r"); | ||
127 | if (!f) | 65 | if (!f) |
128 | die("Couldn't open \"%s\": %s\n", fname, | 66 | die("Couldn't open \"%s\": %s\n", fname, |
129 | strerror(errno)); | 67 | strerror(errno)); |
130 | } | 68 | } |
131 | 69 | ||
132 | if (depfile) | ||
133 | fprintf(depfile, " %s", fullname); | ||
134 | |||
135 | if (fullnamep) | 70 | if (fullnamep) |
136 | *fullnamep = fullname; | 71 | *fullnamep = fullname; |
137 | else | 72 | else |
@@ -180,23 +115,6 @@ int srcfile_pop(void) | |||
180 | return current_srcfile ? 1 : 0; | 115 | return current_srcfile ? 1 : 0; |
181 | } | 116 | } |
182 | 117 | ||
183 | void srcfile_add_search_path(const char *dirname) | ||
184 | { | ||
185 | struct search_path *node; | ||
186 | |||
187 | /* Create the node */ | ||
188 | node = xmalloc(sizeof(*node)); | ||
189 | node->next = NULL; | ||
190 | node->dirname = xstrdup(dirname); | ||
191 | |||
192 | /* Add to the end of our list */ | ||
193 | if (search_path_tail) | ||
194 | *search_path_tail = node; | ||
195 | else | ||
196 | search_path_head = node; | ||
197 | search_path_tail = &node->next; | ||
198 | } | ||
199 | |||
200 | /* | 118 | /* |
201 | * The empty source position. | 119 | * The empty source position. |
202 | */ | 120 | */ |
@@ -328,9 +246,3 @@ srcpos_warn(struct srcpos *pos, char const *fmt, ...) | |||
328 | 246 | ||
329 | va_end(va); | 247 | va_end(va); |
330 | } | 248 | } |
331 | |||
332 | void srcpos_set_line(char *f, int l) | ||
333 | { | ||
334 | current_srcfile->name = f; | ||
335 | current_srcfile->lineno = l; | ||
336 | } | ||
diff --git a/scripts/dtc/srcpos.h b/scripts/dtc/srcpos.h index 93a27123c2e..bd7966e56a5 100644 --- a/scripts/dtc/srcpos.h +++ b/scripts/dtc/srcpos.h | |||
@@ -30,42 +30,12 @@ struct srcfile_state { | |||
30 | struct srcfile_state *prev; | 30 | struct srcfile_state *prev; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | extern FILE *depfile; /* = NULL */ | ||
34 | extern struct srcfile_state *current_srcfile; /* = NULL */ | 33 | extern struct srcfile_state *current_srcfile; /* = NULL */ |
35 | 34 | ||
36 | /** | ||
37 | * Open a source file. | ||
38 | * | ||
39 | * If the source file is a relative pathname, then it is searched for in the | ||
40 | * current directory (the directory of the last source file read) and after | ||
41 | * that in the search path. | ||
42 | * | ||
43 | * We work through the search path in order from the first path specified to | ||
44 | * the last. | ||
45 | * | ||
46 | * If the file is not found, then this function does not return, but calls | ||
47 | * die(). | ||
48 | * | ||
49 | * @param fname Filename to search | ||
50 | * @param fullnamep If non-NULL, it is set to the allocated filename of the | ||
51 | * file that was opened. The caller is then responsible | ||
52 | * for freeing the pointer. | ||
53 | * @return pointer to opened FILE | ||
54 | */ | ||
55 | FILE *srcfile_relative_open(const char *fname, char **fullnamep); | 35 | FILE *srcfile_relative_open(const char *fname, char **fullnamep); |
56 | |||
57 | void srcfile_push(const char *fname); | 36 | void srcfile_push(const char *fname); |
58 | int srcfile_pop(void); | 37 | int srcfile_pop(void); |
59 | 38 | ||
60 | /** | ||
61 | * Add a new directory to the search path for input files | ||
62 | * | ||
63 | * The new path is added at the end of the list. | ||
64 | * | ||
65 | * @param dirname Directory to add | ||
66 | */ | ||
67 | void srcfile_add_search_path(const char *dirname); | ||
68 | |||
69 | struct srcpos { | 39 | struct srcpos { |
70 | int first_line; | 40 | int first_line; |
71 | int first_column; | 41 | int first_column; |
@@ -113,6 +83,4 @@ extern void srcpos_error(struct srcpos *pos, char const *, ...) | |||
113 | extern void srcpos_warn(struct srcpos *pos, char const *, ...) | 83 | extern void srcpos_warn(struct srcpos *pos, char const *, ...) |
114 | __attribute__((format(printf, 2, 3))); | 84 | __attribute__((format(printf, 2, 3))); |
115 | 85 | ||
116 | extern void srcpos_set_line(char *f, int l); | ||
117 | |||
118 | #endif /* _SRCPOS_H_ */ | 86 | #endif /* _SRCPOS_H_ */ |
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c index 33eeba55fb4..c09aafade31 100644 --- a/scripts/dtc/treesource.c +++ b/scripts/dtc/treesource.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | extern FILE *yyin; | 24 | extern FILE *yyin; |
25 | extern int yyparse(void); | 25 | extern int yyparse(void); |
26 | extern YYLTYPE yylloc; | ||
27 | 26 | ||
28 | struct boot_info *the_boot_info; | 27 | struct boot_info *the_boot_info; |
29 | int treesource_error; | 28 | int treesource_error; |
@@ -35,7 +34,6 @@ struct boot_info *dt_from_source(const char *fname) | |||
35 | 34 | ||
36 | srcfile_push(fname); | 35 | srcfile_push(fname); |
37 | yyin = current_srcfile->f; | 36 | yyin = current_srcfile->f; |
38 | yylloc.file = current_srcfile; | ||
39 | 37 | ||
40 | if (yyparse() != 0) | 38 | if (yyparse() != 0) |
41 | die("Unable to parse input tree\n"); | 39 | die("Unable to parse input tree\n"); |
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c index 2422c34e11d..d7ac27d2ae1 100644 --- a/scripts/dtc/util.c +++ b/scripts/dtc/util.c | |||
@@ -1,10 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2011 The Chromium Authors, All Rights Reserved. | ||
3 | * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. | 2 | * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. |
4 | * | 3 | * |
5 | * util_is_printable_string contributed by | ||
6 | * Pantelis Antoniou <pantelis.antoniou AT gmail.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | 4 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 5 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of the | 6 | * published by the Free Software Foundation; either version 2 of the |
@@ -21,18 +17,11 @@ | |||
21 | * USA | 17 | * USA |
22 | */ | 18 | */ |
23 | 19 | ||
24 | #include <ctype.h> | ||
25 | #include <stdio.h> | 20 | #include <stdio.h> |
26 | #include <stdlib.h> | 21 | #include <stdlib.h> |
27 | #include <stdarg.h> | 22 | #include <stdarg.h> |
28 | #include <string.h> | 23 | #include <string.h> |
29 | #include <assert.h> | ||
30 | |||
31 | #include <errno.h> | ||
32 | #include <fcntl.h> | ||
33 | #include <unistd.h> | ||
34 | 24 | ||
35 | #include "libfdt.h" | ||
36 | #include "util.h" | 25 | #include "util.h" |
37 | 26 | ||
38 | char *xstrdup(const char *s) | 27 | char *xstrdup(const char *s) |
@@ -68,264 +57,3 @@ char *join_path(const char *path, const char *name) | |||
68 | memcpy(str+lenp, name, lenn+1); | 57 | memcpy(str+lenp, name, lenn+1); |
69 | return str; | 58 | return str; |
70 | } | 59 | } |
71 | |||
72 | int util_is_printable_string(const void *data, int len) | ||
73 | { | ||
74 | const char *s = data; | ||
75 | const char *ss; | ||
76 | |||
77 | /* zero length is not */ | ||
78 | if (len == 0) | ||
79 | return 0; | ||
80 | |||
81 | /* must terminate with zero */ | ||
82 | if (s[len - 1] != '\0') | ||
83 | return 0; | ||
84 | |||
85 | ss = s; | ||
86 | while (*s && isprint(*s)) | ||
87 | s++; | ||
88 | |||
89 | /* not zero, or not done yet */ | ||
90 | if (*s != '\0' || (s + 1 - ss) < len) | ||
91 | return 0; | ||
92 | |||
93 | return 1; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Parse a octal encoded character starting at index i in string s. The | ||
98 | * resulting character will be returned and the index i will be updated to | ||
99 | * point at the character directly after the end of the encoding, this may be | ||
100 | * the '\0' terminator of the string. | ||
101 | */ | ||
102 | static char get_oct_char(const char *s, int *i) | ||
103 | { | ||
104 | char x[4]; | ||
105 | char *endx; | ||
106 | long val; | ||
107 | |||
108 | x[3] = '\0'; | ||
109 | strncpy(x, s + *i, 3); | ||
110 | |||
111 | val = strtol(x, &endx, 8); | ||
112 | |||
113 | assert(endx > x); | ||
114 | |||
115 | (*i) += endx - x; | ||
116 | return val; | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * Parse a hexadecimal encoded character starting at index i in string s. The | ||
121 | * resulting character will be returned and the index i will be updated to | ||
122 | * point at the character directly after the end of the encoding, this may be | ||
123 | * the '\0' terminator of the string. | ||
124 | */ | ||
125 | static char get_hex_char(const char *s, int *i) | ||
126 | { | ||
127 | char x[3]; | ||
128 | char *endx; | ||
129 | long val; | ||
130 | |||
131 | x[2] = '\0'; | ||
132 | strncpy(x, s + *i, 2); | ||
133 | |||
134 | val = strtol(x, &endx, 16); | ||
135 | if (!(endx > x)) | ||
136 | die("\\x used with no following hex digits\n"); | ||
137 | |||
138 | (*i) += endx - x; | ||
139 | return val; | ||
140 | } | ||
141 | |||
142 | char get_escape_char(const char *s, int *i) | ||
143 | { | ||
144 | char c = s[*i]; | ||
145 | int j = *i + 1; | ||
146 | char val; | ||
147 | |||
148 | assert(c); | ||
149 | switch (c) { | ||
150 | case 'a': | ||
151 | val = '\a'; | ||
152 | break; | ||
153 | case 'b': | ||
154 | val = '\b'; | ||
155 | break; | ||
156 | case 't': | ||
157 | val = '\t'; | ||
158 | break; | ||
159 | case 'n': | ||
160 | val = '\n'; | ||
161 | break; | ||
162 | case 'v': | ||
163 | val = '\v'; | ||
164 | break; | ||
165 | case 'f': | ||
166 | val = '\f'; | ||
167 | break; | ||
168 | case 'r': | ||
169 | val = '\r'; | ||
170 | break; | ||
171 | case '0': | ||
172 | case '1': | ||
173 | case '2': | ||
174 | case '3': | ||
175 | case '4': | ||
176 | case '5': | ||
177 | case '6': | ||
178 | case '7': | ||
179 | j--; /* need to re-read the first digit as | ||
180 | * part of the octal value */ | ||
181 | val = get_oct_char(s, &j); | ||
182 | break; | ||
183 | case 'x': | ||
184 | val = get_hex_char(s, &j); | ||
185 | break; | ||
186 | default: | ||
187 | val = c; | ||
188 | } | ||
189 | |||
190 | (*i) = j; | ||
191 | return val; | ||
192 | } | ||
193 | |||
194 | int utilfdt_read_err(const char *filename, char **buffp) | ||
195 | { | ||
196 | int fd = 0; /* assume stdin */ | ||
197 | char *buf = NULL; | ||
198 | off_t bufsize = 1024, offset = 0; | ||
199 | int ret = 0; | ||
200 | |||
201 | *buffp = NULL; | ||
202 | if (strcmp(filename, "-") != 0) { | ||
203 | fd = open(filename, O_RDONLY); | ||
204 | if (fd < 0) | ||
205 | return errno; | ||
206 | } | ||
207 | |||
208 | /* Loop until we have read everything */ | ||
209 | buf = malloc(bufsize); | ||
210 | do { | ||
211 | /* Expand the buffer to hold the next chunk */ | ||
212 | if (offset == bufsize) { | ||
213 | bufsize *= 2; | ||
214 | buf = realloc(buf, bufsize); | ||
215 | if (!buf) { | ||
216 | ret = ENOMEM; | ||
217 | break; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | ret = read(fd, &buf[offset], bufsize - offset); | ||
222 | if (ret < 0) { | ||
223 | ret = errno; | ||
224 | break; | ||
225 | } | ||
226 | offset += ret; | ||
227 | } while (ret != 0); | ||
228 | |||
229 | /* Clean up, including closing stdin; return errno on error */ | ||
230 | close(fd); | ||
231 | if (ret) | ||
232 | free(buf); | ||
233 | else | ||
234 | *buffp = buf; | ||
235 | return ret; | ||
236 | } | ||
237 | |||
238 | char *utilfdt_read(const char *filename) | ||
239 | { | ||
240 | char *buff; | ||
241 | int ret = utilfdt_read_err(filename, &buff); | ||
242 | |||
243 | if (ret) { | ||
244 | fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, | ||
245 | strerror(ret)); | ||
246 | return NULL; | ||
247 | } | ||
248 | /* Successful read */ | ||
249 | return buff; | ||
250 | } | ||
251 | |||
252 | int utilfdt_write_err(const char *filename, const void *blob) | ||
253 | { | ||
254 | int fd = 1; /* assume stdout */ | ||
255 | int totalsize; | ||
256 | int offset; | ||
257 | int ret = 0; | ||
258 | const char *ptr = blob; | ||
259 | |||
260 | if (strcmp(filename, "-") != 0) { | ||
261 | fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); | ||
262 | if (fd < 0) | ||
263 | return errno; | ||
264 | } | ||
265 | |||
266 | totalsize = fdt_totalsize(blob); | ||
267 | offset = 0; | ||
268 | |||
269 | while (offset < totalsize) { | ||
270 | ret = write(fd, ptr + offset, totalsize - offset); | ||
271 | if (ret < 0) { | ||
272 | ret = -errno; | ||
273 | break; | ||
274 | } | ||
275 | offset += ret; | ||
276 | } | ||
277 | /* Close the file/stdin; return errno on error */ | ||
278 | if (fd != 1) | ||
279 | close(fd); | ||
280 | return ret < 0 ? -ret : 0; | ||
281 | } | ||
282 | |||
283 | |||
284 | int utilfdt_write(const char *filename, const void *blob) | ||
285 | { | ||
286 | int ret = utilfdt_write_err(filename, blob); | ||
287 | |||
288 | if (ret) { | ||
289 | fprintf(stderr, "Couldn't write blob to '%s': %s\n", filename, | ||
290 | strerror(ret)); | ||
291 | } | ||
292 | return ret ? -1 : 0; | ||
293 | } | ||
294 | |||
295 | int utilfdt_decode_type(const char *fmt, int *type, int *size) | ||
296 | { | ||
297 | int qualifier = 0; | ||
298 | |||
299 | if (!*fmt) | ||
300 | return -1; | ||
301 | |||
302 | /* get the conversion qualifier */ | ||
303 | *size = -1; | ||
304 | if (strchr("hlLb", *fmt)) { | ||
305 | qualifier = *fmt++; | ||
306 | if (qualifier == *fmt) { | ||
307 | switch (*fmt++) { | ||
308 | /* TODO: case 'l': qualifier = 'L'; break;*/ | ||
309 | case 'h': | ||
310 | qualifier = 'b'; | ||
311 | break; | ||
312 | } | ||
313 | } | ||
314 | } | ||
315 | |||
316 | /* we should now have a type */ | ||
317 | if ((*fmt == '\0') || !strchr("iuxs", *fmt)) | ||
318 | return -1; | ||
319 | |||
320 | /* convert qualifier (bhL) to byte size */ | ||
321 | if (*fmt != 's') | ||
322 | *size = qualifier == 'b' ? 1 : | ||
323 | qualifier == 'h' ? 2 : | ||
324 | qualifier == 'l' ? 4 : -1; | ||
325 | *type = *fmt++; | ||
326 | |||
327 | /* that should be it! */ | ||
328 | if (*fmt) | ||
329 | return -1; | ||
330 | return 0; | ||
331 | } | ||
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h index c8eb45d9f04..9cead842c11 100644 --- a/scripts/dtc/util.h +++ b/scripts/dtc/util.h | |||
@@ -1,10 +1,7 @@ | |||
1 | #ifndef _UTIL_H | 1 | #ifndef _UTIL_H |
2 | #define _UTIL_H | 2 | #define _UTIL_H |
3 | 3 | ||
4 | #include <stdarg.h> | ||
5 | |||
6 | /* | 4 | /* |
7 | * Copyright 2011 The Chromium Authors, All Rights Reserved. | ||
8 | * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. | 5 | * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. |
9 | * | 6 | * |
10 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
@@ -56,98 +53,4 @@ static inline void *xrealloc(void *p, size_t len) | |||
56 | extern char *xstrdup(const char *s); | 53 | extern char *xstrdup(const char *s); |
57 | extern char *join_path(const char *path, const char *name); | 54 | extern char *join_path(const char *path, const char *name); |
58 | 55 | ||
59 | /** | ||
60 | * Check a string of a given length to see if it is all printable and | ||
61 | * has a valid terminator. | ||
62 | * | ||
63 | * @param data The string to check | ||
64 | * @param len The string length including terminator | ||
65 | * @return 1 if a valid printable string, 0 if not */ | ||
66 | int util_is_printable_string(const void *data, int len); | ||
67 | |||
68 | /* | ||
69 | * Parse an escaped character starting at index i in string s. The resulting | ||
70 | * character will be returned and the index i will be updated to point at the | ||
71 | * character directly after the end of the encoding, this may be the '\0' | ||
72 | * terminator of the string. | ||
73 | */ | ||
74 | char get_escape_char(const char *s, int *i); | ||
75 | |||
76 | /** | ||
77 | * Read a device tree file into a buffer. This will report any errors on | ||
78 | * stderr. | ||
79 | * | ||
80 | * @param filename The filename to read, or - for stdin | ||
81 | * @return Pointer to allocated buffer containing fdt, or NULL on error | ||
82 | */ | ||
83 | char *utilfdt_read(const char *filename); | ||
84 | |||
85 | /** | ||
86 | * Read a device tree file into a buffer. Does not report errors, but only | ||
87 | * returns them. The value returned can be passed to strerror() to obtain | ||
88 | * an error message for the user. | ||
89 | * | ||
90 | * @param filename The filename to read, or - for stdin | ||
91 | * @param buffp Returns pointer to buffer containing fdt | ||
92 | * @return 0 if ok, else an errno value representing the error | ||
93 | */ | ||
94 | int utilfdt_read_err(const char *filename, char **buffp); | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Write a device tree buffer to a file. This will report any errors on | ||
99 | * stderr. | ||
100 | * | ||
101 | * @param filename The filename to write, or - for stdout | ||
102 | * @param blob Poiner to buffer containing fdt | ||
103 | * @return 0 if ok, -1 on error | ||
104 | */ | ||
105 | int utilfdt_write(const char *filename, const void *blob); | ||
106 | |||
107 | /** | ||
108 | * Write a device tree buffer to a file. Does not report errors, but only | ||
109 | * returns them. The value returned can be passed to strerror() to obtain | ||
110 | * an error message for the user. | ||
111 | * | ||
112 | * @param filename The filename to write, or - for stdout | ||
113 | * @param blob Poiner to buffer containing fdt | ||
114 | * @return 0 if ok, else an errno value representing the error | ||
115 | */ | ||
116 | int utilfdt_write_err(const char *filename, const void *blob); | ||
117 | |||
118 | /** | ||
119 | * Decode a data type string. The purpose of this string | ||
120 | * | ||
121 | * The string consists of an optional character followed by the type: | ||
122 | * Modifier characters: | ||
123 | * hh or b 1 byte | ||
124 | * h 2 byte | ||
125 | * l 4 byte, default | ||
126 | * | ||
127 | * Type character: | ||
128 | * s string | ||
129 | * i signed integer | ||
130 | * u unsigned integer | ||
131 | * x hex | ||
132 | * | ||
133 | * TODO: Implement ll modifier (8 bytes) | ||
134 | * TODO: Implement o type (octal) | ||
135 | * | ||
136 | * @param fmt Format string to process | ||
137 | * @param type Returns type found(s/d/u/x), or 0 if none | ||
138 | * @param size Returns size found(1,2,4,8) or 4 if none | ||
139 | * @return 0 if ok, -1 on error (no type given, or other invalid format) | ||
140 | */ | ||
141 | int utilfdt_decode_type(const char *fmt, int *type, int *size); | ||
142 | |||
143 | /* | ||
144 | * This is a usage message fragment for the -t option. It is the format | ||
145 | * supported by utilfdt_decode_type. | ||
146 | */ | ||
147 | |||
148 | #define USAGE_TYPE_MSG \ | ||
149 | "<type>\ts=string, i=int, u=unsigned, x=hex\n" \ | ||
150 | "\tOptional modifier prefix:\n" \ | ||
151 | "\t\thh or b=byte, h=2 byte, l=4 byte (default)\n"; | ||
152 | |||
153 | #endif /* _UTIL_H */ | 56 | #endif /* _UTIL_H */ |
diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux deleted file mode 100755 index 5061abcc254..00000000000 --- a/scripts/extract-vmlinux +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # ---------------------------------------------------------------------- | ||
3 | # extract-vmlinux - Extract uncompressed vmlinux from a kernel image | ||
4 | # | ||
5 | # Inspired from extract-ikconfig | ||
6 | # (c) 2009,2010 Dick Streefland <dick@streefland.net> | ||
7 | # | ||
8 | # (c) 2011 Corentin Chary <corentin.chary@gmail.com> | ||
9 | # | ||
10 | # Licensed under the GNU General Public License, version 2 (GPLv2). | ||
11 | # ---------------------------------------------------------------------- | ||
12 | |||
13 | check_vmlinux() | ||
14 | { | ||
15 | # Use readelf to check if it's a valid ELF | ||
16 | # TODO: find a better to way to check that it's really vmlinux | ||
17 | # and not just an elf | ||
18 | readelf -h $1 > /dev/null 2>&1 || return 1 | ||
19 | |||
20 | cat $1 | ||
21 | exit 0 | ||
22 | } | ||
23 | |||
24 | try_decompress() | ||
25 | { | ||
26 | # The obscure use of the "tr" filter is to work around older versions of | ||
27 | # "grep" that report the byte offset of the line instead of the pattern. | ||
28 | |||
29 | # Try to find the header ($1) and decompress from here | ||
30 | for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"` | ||
31 | do | ||
32 | pos=${pos%%:*} | ||
33 | tail -c+$pos "$img" | $3 > $tmp 2> /dev/null | ||
34 | check_vmlinux $tmp | ||
35 | done | ||
36 | } | ||
37 | |||
38 | # Check invocation: | ||
39 | me=${0##*/} | ||
40 | img=$1 | ||
41 | if [ $# -ne 1 -o ! -s "$img" ] | ||
42 | then | ||
43 | echo "Usage: $me <kernel-image>" >&2 | ||
44 | exit 2 | ||
45 | fi | ||
46 | |||
47 | # Prepare temp files: | ||
48 | tmp=$(mktemp /tmp/vmlinux-XXX) | ||
49 | trap "rm -f $tmp" 0 | ||
50 | |||
51 | # Initial attempt for uncompressed images or objects: | ||
52 | check_vmlinux $img | ||
53 | |||
54 | # That didn't work, so retry after decompression. | ||
55 | try_decompress '\037\213\010' xy gunzip | ||
56 | try_decompress '\3757zXZ\000' abcde unxz | ||
57 | try_decompress 'BZh' xy bunzip2 | ||
58 | try_decompress '\135\0\0\0' xxx unlzma | ||
59 | try_decompress '\211\114\132' xy 'lzop -d' | ||
60 | |||
61 | # Bail out: | ||
62 | echo "$me: Cannot find vmlinux." >&2 | ||
diff --git a/scripts/gcc-goto.sh b/scripts/gcc-goto.sh index a2af2e88daf..98cffcb941e 100644 --- a/scripts/gcc-goto.sh +++ b/scripts/gcc-goto.sh | |||
@@ -2,20 +2,4 @@ | |||
2 | # Test for gcc 'asm goto' support | 2 | # Test for gcc 'asm goto' support |
3 | # Copyright (C) 2010, Jason Baron <jbaron@redhat.com> | 3 | # Copyright (C) 2010, Jason Baron <jbaron@redhat.com> |
4 | 4 | ||
5 | cat << "END" | $@ -x c - -c -o /dev/null >/dev/null 2>&1 && echo "y" | 5 | echo "int main(void) { entry: asm goto (\"\"::::entry); return 0; }" | $@ -x c - -c -o /dev/null >/dev/null 2>&1 && echo "y" |
6 | int main(void) | ||
7 | { | ||
8 | #ifdef __arm__ | ||
9 | /* | ||
10 | * Not related to asm goto, but used by jump label | ||
11 | * and broken on some ARM GCC versions (see GCC Bug 48637). | ||
12 | */ | ||
13 | static struct { int dummy; int state; } tp; | ||
14 | asm (".long %c0" :: "i" (&tp.state)); | ||
15 | #endif | ||
16 | |||
17 | entry: | ||
18 | asm goto ("" :::: entry); | ||
19 | return 0; | ||
20 | } | ||
21 | END | ||
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh index 7f2126df91f..debecb5561c 100644 --- a/scripts/gcc-version.sh +++ b/scripts/gcc-version.sh | |||
@@ -22,10 +22,10 @@ if [ ${#compiler} -eq 0 ]; then | |||
22 | exit 1 | 22 | exit 1 |
23 | fi | 23 | fi |
24 | 24 | ||
25 | MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) | 25 | MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1) |
26 | MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) | 26 | MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) |
27 | if [ "x$with_patchlevel" != "x" ] ; then | 27 | if [ "x$with_patchlevel" != "x" ] ; then |
28 | PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) | 28 | PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1) |
29 | printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL | 29 | printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL |
30 | else | 30 | else |
31 | printf "%02d%02d\\n" $MAJOR $MINOR | 31 | printf "%02d%02d\\n" $MAJOR $MINOR |
diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh index 12dbd0b11ea..29493dc4528 100644 --- a/scripts/gcc-x86_32-has-stack-protector.sh +++ b/scripts/gcc-x86_32-has-stack-protector.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" | 3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" |
4 | if [ "$?" -eq "0" ] ; then | 4 | if [ "$?" -eq "0" ] ; then |
5 | echo y | 5 | echo y |
6 | else | 6 | else |
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh index 973e8c14156..afaec618b39 100644 --- a/scripts/gcc-x86_64-has-stack-protector.sh +++ b/scripts/gcc-x86_64-has-stack-protector.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs" | 3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs" |
4 | if [ "$?" -eq "0" ] ; then | 4 | if [ "$?" -eq "0" ] ; then |
5 | echo y | 5 | echo y |
6 | else | 6 | else |
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 8b673dd4627..4594f334105 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
@@ -83,8 +83,6 @@ push(@signature_tags, "Signed-off-by:"); | |||
83 | push(@signature_tags, "Reviewed-by:"); | 83 | push(@signature_tags, "Reviewed-by:"); |
84 | push(@signature_tags, "Acked-by:"); | 84 | push(@signature_tags, "Acked-by:"); |
85 | 85 | ||
86 | my $signature_pattern = "\(" . join("|", @signature_tags) . "\)"; | ||
87 | |||
88 | # rfc822 email address - preloaded methods go here. | 86 | # rfc822 email address - preloaded methods go here. |
89 | my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; | 87 | my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; |
90 | my $rfc822_char = '[\\000-\\377]'; | 88 | my $rfc822_char = '[\\000-\\377]'; |
@@ -97,7 +95,7 @@ my %VCS_cmds_git = ( | |||
97 | "execute_cmd" => \&git_execute_cmd, | 95 | "execute_cmd" => \&git_execute_cmd, |
98 | "available" => '(which("git") ne "") && (-d ".git")', | 96 | "available" => '(which("git") ne "") && (-d ".git")', |
99 | "find_signers_cmd" => | 97 | "find_signers_cmd" => |
100 | "git log --no-color --follow --since=\$email_git_since " . | 98 | "git log --no-color --since=\$email_git_since " . |
101 | '--format="GitCommit: %H%n' . | 99 | '--format="GitCommit: %H%n' . |
102 | 'GitAuthor: %an <%ae>%n' . | 100 | 'GitAuthor: %an <%ae>%n' . |
103 | 'GitDate: %aD%n' . | 101 | 'GitDate: %aD%n' . |
@@ -475,6 +473,7 @@ my @subsystem = (); | |||
475 | my @status = (); | 473 | my @status = (); |
476 | my %deduplicate_name_hash = (); | 474 | my %deduplicate_name_hash = (); |
477 | my %deduplicate_address_hash = (); | 475 | my %deduplicate_address_hash = (); |
476 | my $signature_pattern; | ||
478 | 477 | ||
479 | my @maintainers = get_maintainers(); | 478 | my @maintainers = get_maintainers(); |
480 | 479 | ||
@@ -932,7 +931,7 @@ sub get_maintainer_role { | |||
932 | my $start = find_starting_index($index); | 931 | my $start = find_starting_index($index); |
933 | my $end = find_ending_index($index); | 932 | my $end = find_ending_index($index); |
934 | 933 | ||
935 | my $role = "unknown"; | 934 | my $role; |
936 | my $subsystem = $typevalue[$start]; | 935 | my $subsystem = $typevalue[$start]; |
937 | if (length($subsystem) > 20) { | 936 | if (length($subsystem) > 20) { |
938 | $subsystem = substr($subsystem, 0, 17); | 937 | $subsystem = substr($subsystem, 0, 17); |
@@ -1028,13 +1027,8 @@ sub add_categories { | |||
1028 | if ($email_list) { | 1027 | if ($email_list) { |
1029 | if (!$hash_list_to{lc($list_address)}) { | 1028 | if (!$hash_list_to{lc($list_address)}) { |
1030 | $hash_list_to{lc($list_address)} = 1; | 1029 | $hash_list_to{lc($list_address)} = 1; |
1031 | if ($list_additional =~ m/moderated/) { | 1030 | push(@list_to, [$list_address, |
1032 | push(@list_to, [$list_address, | 1031 | "open list${list_role}"]); |
1033 | "moderated list${list_role}"]); | ||
1034 | } else { | ||
1035 | push(@list_to, [$list_address, | ||
1036 | "open list${list_role}"]); | ||
1037 | } | ||
1038 | } | 1032 | } |
1039 | } | 1033 | } |
1040 | } | 1034 | } |
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl index 64ac2380e4d..7957e7a5166 100644 --- a/scripts/headers_check.pl +++ b/scripts/headers_check.pl | |||
@@ -19,7 +19,6 @@ | |||
19 | # 3) Check for leaked CONFIG_ symbols | 19 | # 3) Check for leaked CONFIG_ symbols |
20 | 20 | ||
21 | use strict; | 21 | use strict; |
22 | use File::Basename; | ||
23 | 22 | ||
24 | my ($dir, $arch, @files) = @ARGV; | 23 | my ($dir, $arch, @files) = @ARGV; |
25 | 24 | ||
@@ -100,39 +99,6 @@ sub check_asm_types | |||
100 | } | 99 | } |
101 | 100 | ||
102 | my $linux_types; | 101 | my $linux_types; |
103 | my %import_stack = (); | ||
104 | sub check_include_typesh | ||
105 | { | ||
106 | my $path = $_[0]; | ||
107 | my $import_path; | ||
108 | |||
109 | my $fh; | ||
110 | my @file_paths = ($path, $dir . "/" . $path, dirname($filename) . "/" . $path); | ||
111 | for my $possible ( @file_paths ) { | ||
112 | if (not $import_stack{$possible} and open($fh, '<', $possible)) { | ||
113 | $import_path = $possible; | ||
114 | $import_stack{$import_path} = 1; | ||
115 | last; | ||
116 | } | ||
117 | } | ||
118 | if (eof $fh) { | ||
119 | return; | ||
120 | } | ||
121 | |||
122 | my $line; | ||
123 | while ($line = <$fh>) { | ||
124 | if ($line =~ m/^\s*#\s*include\s+<linux\/types.h>/) { | ||
125 | $linux_types = 1; | ||
126 | last; | ||
127 | } | ||
128 | if (my $included = ($line =~ /^\s*#\s*include\s+[<"](\S+)[>"]/)[0]) { | ||
129 | check_include_typesh($included); | ||
130 | } | ||
131 | } | ||
132 | close $fh; | ||
133 | delete $import_stack{$import_path}; | ||
134 | } | ||
135 | |||
136 | sub check_sizetypes | 102 | sub check_sizetypes |
137 | { | 103 | { |
138 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { | 104 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { |
@@ -147,9 +113,6 @@ sub check_sizetypes | |||
147 | $linux_types = 1; | 113 | $linux_types = 1; |
148 | return; | 114 | return; |
149 | } | 115 | } |
150 | if (my $included = ($line =~ /^\s*#\s*include\s+[<"](\S+)[>"]/)[0]) { | ||
151 | check_include_typesh($included); | ||
152 | } | ||
153 | if ($line =~ m/__[us](8|16|32|64)\b/) { | 116 | if ($line =~ m/__[us](8|16|32|64)\b/) { |
154 | printf STDERR "$filename:$lineno: " . | 117 | printf STDERR "$filename:$lineno: " . |
155 | "found __[us]{8,16,32,64} type " . | 118 | "found __[us]{8,16,32,64} type " . |
@@ -159,3 +122,4 @@ sub check_sizetypes | |||
159 | #$ret = 1; | 122 | #$ret = 1; |
160 | } | 123 | } |
161 | } | 124 | } |
125 | |||
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index 581ca99c96f..48462be328b 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl | |||
@@ -4,7 +4,8 @@ | |||
4 | # user space and copy the files to their destination. | 4 | # user space and copy the files to their destination. |
5 | # | 5 | # |
6 | # Usage: headers_install.pl readdir installdir arch [files...] | 6 | # Usage: headers_install.pl readdir installdir arch [files...] |
7 | # installdir: dir to install the files to | 7 | # readdir: dir to open files |
8 | # installdir: dir to install the files | ||
8 | # arch: current architecture | 9 | # arch: current architecture |
9 | # arch is used to force a reinstallation when the arch | 10 | # arch is used to force a reinstallation when the arch |
10 | # changes because kbuild then detect a command line change. | 11 | # changes because kbuild then detect a command line change. |
@@ -17,18 +18,15 @@ | |||
17 | 18 | ||
18 | use strict; | 19 | use strict; |
19 | 20 | ||
20 | my ($installdir, $arch, @files) = @ARGV; | 21 | my ($readdir, $installdir, $arch, @files) = @ARGV; |
21 | 22 | ||
22 | my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__"; | 23 | my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__"; |
23 | 24 | ||
24 | foreach my $filename (@files) { | 25 | foreach my $file (@files) { |
25 | my $file = $filename; | ||
26 | $file =~ s!^.*/!!; | ||
27 | |||
28 | my $tmpfile = "$installdir/$file.tmp"; | 26 | my $tmpfile = "$installdir/$file.tmp"; |
29 | 27 | ||
30 | open(my $in, '<', $filename) | 28 | open(my $in, '<', "$readdir/$file") |
31 | or die "$filename: $!\n"; | 29 | or die "$readdir/$file: $!\n"; |
32 | open(my $out, '>', $tmpfile) | 30 | open(my $out, '>', $tmpfile) |
33 | or die "$tmpfile: $!\n"; | 31 | or die "$tmpfile: $!\n"; |
34 | while (my $line = <$in>) { | 32 | while (my $line = <$in>) { |
@@ -42,9 +40,6 @@ foreach my $filename (@files) { | |||
42 | $line =~ s/(^|\s)(inline)\b/$1__$2__/g; | 40 | $line =~ s/(^|\s)(inline)\b/$1__$2__/g; |
43 | $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; | 41 | $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; |
44 | $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; | 42 | $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; |
45 | $line =~ s/#ifndef\s+_UAPI/#ifndef /; | ||
46 | $line =~ s/#define\s+_UAPI/#define /; | ||
47 | $line =~ s!#endif\s+/[*]\s*_UAPI!#endif /* !; | ||
48 | printf {$out} "%s", $line; | 43 | printf {$out} "%s", $line; |
49 | } | 44 | } |
50 | close $out; | 45 | close $out; |
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 3091794e935..82d2eb285b7 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
@@ -33,9 +33,17 @@ silentoldconfig: $(obj)/conf | |||
33 | $(Q)mkdir -p include/generated | 33 | $(Q)mkdir -p include/generated |
34 | $< --$@ $(Kconfig) | 34 | $< --$@ $(Kconfig) |
35 | 35 | ||
36 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | 36 | # if no path is given, then use src directory to find file |
37 | ifdef LSMOD | ||
38 | LSMOD_F := $(LSMOD) | ||
39 | ifeq ($(findstring /,$(LSMOD)),) | ||
40 | LSMOD_F := $(objtree)/$(LSMOD) | ||
41 | endif | ||
42 | endif | ||
43 | |||
44 | localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | ||
37 | $(Q)mkdir -p include/generated | 45 | $(Q)mkdir -p include/generated |
38 | $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config | 46 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config |
39 | $(Q)if [ -f .config ]; then \ | 47 | $(Q)if [ -f .config ]; then \ |
40 | cmp -s .tmp.config .config || \ | 48 | cmp -s .tmp.config .config || \ |
41 | (mv -f .config .config.old.1; \ | 49 | (mv -f .config .config.old.1; \ |
@@ -48,10 +56,27 @@ localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | |||
48 | fi | 56 | fi |
49 | $(Q)rm -f .tmp.config | 57 | $(Q)rm -f .tmp.config |
50 | 58 | ||
59 | localyesconfig: $(obj)/streamline_config.pl $(obj)/conf | ||
60 | $(Q)mkdir -p include/generated | ||
61 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config | ||
62 | $(Q)sed -i s/=m/=y/ .tmp.config | ||
63 | $(Q)if [ -f .config ]; then \ | ||
64 | cmp -s .tmp.config .config || \ | ||
65 | (mv -f .config .config.old.1; \ | ||
66 | mv -f .tmp.config .config; \ | ||
67 | $(obj)/conf --silentoldconfig $(Kconfig); \ | ||
68 | mv -f .config.old.1 .config.old) \ | ||
69 | else \ | ||
70 | mv -f .tmp.config .config; \ | ||
71 | $(obj)/conf --silentoldconfig $(Kconfig); \ | ||
72 | fi | ||
73 | $(Q)rm -f .tmp.config | ||
74 | |||
51 | # Create new linux.pot file | 75 | # Create new linux.pot file |
52 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files | 76 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files |
77 | # The symlink is used to repair a deficiency in arch/um | ||
53 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | 78 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h |
54 | $(Q)echo " GEN config.pot" | 79 | $(Q)echo " GEN config" |
55 | $(Q)xgettext --default-domain=linux \ | 80 | $(Q)xgettext --default-domain=linux \ |
56 | --add-comments --keyword=_ --keyword=N_ \ | 81 | --add-comments --keyword=_ --keyword=N_ \ |
57 | --from-code=UTF-8 \ | 82 | --from-code=UTF-8 \ |
@@ -59,16 +84,16 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | |||
59 | --directory=$(srctree) --directory=$(objtree) \ | 84 | --directory=$(srctree) --directory=$(objtree) \ |
60 | --output $(obj)/config.pot | 85 | --output $(obj)/config.pot |
61 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot | 86 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot |
62 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ | 87 | $(Q)ln -fs Kconfig.x86 arch/um/Kconfig |
63 | $(srctree)/arch/*/um/Kconfig`; \ | 88 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig`; \ |
64 | do \ | 89 | do \ |
65 | echo " GEN $$i"; \ | 90 | echo " GEN $$i"; \ |
66 | $(obj)/kxgettext $$i \ | 91 | $(obj)/kxgettext $$i \ |
67 | >> $(obj)/config.pot; \ | 92 | >> $(obj)/config.pot; \ |
68 | done ) | 93 | done ) |
69 | $(Q)echo " GEN linux.pot" | ||
70 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ | 94 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ |
71 | --output $(obj)/linux.pot | 95 | --output $(obj)/linux.pot |
96 | $(Q)rm -f $(srctree)/arch/um/Kconfig | ||
72 | $(Q)rm -f $(obj)/config.pot | 97 | $(Q)rm -f $(obj)/config.pot |
73 | 98 | ||
74 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig | 99 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig |
@@ -76,17 +101,11 @@ PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig | |||
76 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf | 101 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf |
77 | $< --$@ $(Kconfig) | 102 | $< --$@ $(Kconfig) |
78 | 103 | ||
79 | PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig | 104 | PHONY += listnewconfig oldnoconfig savedefconfig defconfig |
80 | 105 | ||
81 | listnewconfig olddefconfig: $(obj)/conf | 106 | listnewconfig oldnoconfig: $(obj)/conf |
82 | $< --$@ $(Kconfig) | 107 | $< --$@ $(Kconfig) |
83 | 108 | ||
84 | # oldnoconfig is an alias of olddefconfig, because people already are dependent | ||
85 | # on its behavior(sets new symbols to their default value but not 'n') with the | ||
86 | # counter-intuitive name. | ||
87 | oldnoconfig: $(obj)/conf | ||
88 | $< --olddefconfig $(Kconfig) | ||
89 | |||
90 | savedefconfig: $(obj)/conf | 109 | savedefconfig: $(obj)/conf |
91 | $< --$@=defconfig $(Kconfig) | 110 | $< --$@=defconfig $(Kconfig) |
92 | 111 | ||
@@ -120,7 +139,7 @@ help: | |||
120 | @echo ' alldefconfig - New config with all symbols set to default' | 139 | @echo ' alldefconfig - New config with all symbols set to default' |
121 | @echo ' randconfig - New config with random answer to all options' | 140 | @echo ' randconfig - New config with random answer to all options' |
122 | @echo ' listnewconfig - List new options' | 141 | @echo ' listnewconfig - List new options' |
123 | @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value' | 142 | @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)' |
124 | 143 | ||
125 | # lxdialog stuff | 144 | # lxdialog stuff |
126 | check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh | 145 | check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh |
@@ -240,12 +259,12 @@ $(obj)/.tmp_qtcheck: | |||
240 | if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ | 259 | if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ |
241 | done; \ | 260 | done; \ |
242 | if [ -z "$$dir" ]; then \ | 261 | if [ -z "$$dir" ]; then \ |
243 | echo >&2 "*"; \ | 262 | echo "*"; \ |
244 | echo >&2 "* Unable to find any QT installation. Please make sure that"; \ | 263 | echo "* Unable to find any QT installation. Please make sure that"; \ |
245 | echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \ | 264 | echo "* the QT4 or QT3 development package is correctly installed and"; \ |
246 | echo >&2 "* either qmake can be found or install pkg-config or set"; \ | 265 | echo "* either qmake can be found or install pkg-config or set"; \ |
247 | echo >&2 "* the QTDIR environment variable to the correct location."; \ | 266 | echo "* the QTDIR environment variable to the correct location."; \ |
248 | echo >&2 "*"; \ | 267 | echo "*"; \ |
249 | false; \ | 268 | false; \ |
250 | fi; \ | 269 | fi; \ |
251 | libpath=$$dir/lib; lib=qt; osdir=""; \ | 270 | libpath=$$dir/lib; lib=qt; osdir=""; \ |
@@ -266,8 +285,8 @@ $(obj)/.tmp_qtcheck: | |||
266 | else \ | 285 | else \ |
267 | cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ | 286 | cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ |
268 | libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ | 287 | libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ |
269 | moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \ | 288 | binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \ |
270 | [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \ | 289 | moc="$$binpath/bin/moc"; \ |
271 | fi; \ | 290 | fi; \ |
272 | echo "KC_QT_CFLAGS=$$cflags" > $@; \ | 291 | echo "KC_QT_CFLAGS=$$cflags" > $@; \ |
273 | echo "KC_QT_LIBS=$$libs" >> $@; \ | 292 | echo "KC_QT_LIBS=$$libs" >> $@; \ |
@@ -285,17 +304,17 @@ $(obj)/.tmp_gtkcheck: | |||
285 | if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ | 304 | if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ |
286 | touch $@; \ | 305 | touch $@; \ |
287 | else \ | 306 | else \ |
288 | echo >&2 "*"; \ | 307 | echo "*"; \ |
289 | echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \ | 308 | echo "* GTK+ is present but version >= 2.0.0 is required."; \ |
290 | echo >&2 "*"; \ | 309 | echo "*"; \ |
291 | false; \ | 310 | false; \ |
292 | fi \ | 311 | fi \ |
293 | else \ | 312 | else \ |
294 | echo >&2 "*"; \ | 313 | echo "*"; \ |
295 | echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \ | 314 | echo "* Unable to find the GTK+ installation. Please make sure that"; \ |
296 | echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \ | 315 | echo "* the GTK+ 2.0 development package is correctly installed..."; \ |
297 | echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ | 316 | echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ |
298 | echo >&2 "*"; \ | 317 | echo "*"; \ |
299 | false; \ | 318 | false; \ |
300 | fi | 319 | fi |
301 | endif | 320 | endif |
@@ -304,11 +323,8 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c | |||
304 | 323 | ||
305 | $(obj)/qconf.o: $(obj)/qconf.moc | 324 | $(obj)/qconf.o: $(obj)/qconf.moc |
306 | 325 | ||
307 | quiet_cmd_moc = MOC $@ | 326 | $(obj)/%.moc: $(src)/%.h |
308 | cmd_moc = $(KC_QT_MOC) -i $< -o $@ | 327 | $(KC_QT_MOC) -i $< -o $@ |
309 | |||
310 | $(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck | ||
311 | $(call cmd,moc) | ||
312 | 328 | ||
313 | # Extract gconf menu items for I18N support | 329 | # Extract gconf menu items for I18N support |
314 | $(obj)/gconf.glade.h: $(obj)/gconf.glade | 330 | $(obj)/gconf.glade.h: $(obj)/gconf.glade |
diff --git a/scripts/kconfig/check.sh b/scripts/kconfig/check.sh index 854d9c7c675..fa59cbf9d62 100755 --- a/scripts/kconfig/check.sh +++ b/scripts/kconfig/check.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # Needed for systems without gettext | 2 | # Needed for systems without gettext |
3 | $* -x c -o /dev/null - > /dev/null 2>&1 << EOF | 3 | $* -xc -o /dev/null - > /dev/null 2>&1 << EOF |
4 | #include <libintl.h> | 4 | #include <libintl.h> |
5 | int main() | 5 | int main() |
6 | { | 6 | { |
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 4da3b4adfad..f208f900ed3 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -32,7 +32,7 @@ enum input_mode { | |||
32 | defconfig, | 32 | defconfig, |
33 | savedefconfig, | 33 | savedefconfig, |
34 | listnewconfig, | 34 | listnewconfig, |
35 | olddefconfig, | 35 | oldnoconfig, |
36 | } input_mode = oldaskconfig; | 36 | } input_mode = oldaskconfig; |
37 | 37 | ||
38 | static int indent = 1; | 38 | static int indent = 1; |
@@ -365,7 +365,7 @@ static void conf(struct menu *menu) | |||
365 | case P_MENU: | 365 | case P_MENU: |
366 | if ((input_mode == silentoldconfig || | 366 | if ((input_mode == silentoldconfig || |
367 | input_mode == listnewconfig || | 367 | input_mode == listnewconfig || |
368 | input_mode == olddefconfig) && | 368 | input_mode == oldnoconfig) && |
369 | rootEntry != menu) { | 369 | rootEntry != menu) { |
370 | check_conf(menu); | 370 | check_conf(menu); |
371 | return; | 371 | return; |
@@ -429,7 +429,7 @@ static void check_conf(struct menu *menu) | |||
429 | if (sym->name && !sym_is_choice_value(sym)) { | 429 | if (sym->name && !sym_is_choice_value(sym)) { |
430 | printf("%s%s\n", CONFIG_, sym->name); | 430 | printf("%s%s\n", CONFIG_, sym->name); |
431 | } | 431 | } |
432 | } else if (input_mode != olddefconfig) { | 432 | } else if (input_mode != oldnoconfig) { |
433 | if (!conf_cnt++) | 433 | if (!conf_cnt++) |
434 | printf(_("*\n* Restart config...\n*\n")); | 434 | printf(_("*\n* Restart config...\n*\n")); |
435 | rootEntry = menu_get_parent_menu(menu); | 435 | rootEntry = menu_get_parent_menu(menu); |
@@ -454,13 +454,7 @@ static struct option long_opts[] = { | |||
454 | {"alldefconfig", no_argument, NULL, alldefconfig}, | 454 | {"alldefconfig", no_argument, NULL, alldefconfig}, |
455 | {"randconfig", no_argument, NULL, randconfig}, | 455 | {"randconfig", no_argument, NULL, randconfig}, |
456 | {"listnewconfig", no_argument, NULL, listnewconfig}, | 456 | {"listnewconfig", no_argument, NULL, listnewconfig}, |
457 | {"olddefconfig", no_argument, NULL, olddefconfig}, | 457 | {"oldnoconfig", no_argument, NULL, oldnoconfig}, |
458 | /* | ||
459 | * oldnoconfig is an alias of olddefconfig, because people already | ||
460 | * are dependent on its behavior(sets new symbols to their default | ||
461 | * value but not 'n') with the counter-intuitive name. | ||
462 | */ | ||
463 | {"oldnoconfig", no_argument, NULL, olddefconfig}, | ||
464 | {NULL, 0, NULL, 0} | 458 | {NULL, 0, NULL, 0} |
465 | }; | 459 | }; |
466 | 460 | ||
@@ -473,8 +467,7 @@ static void conf_usage(const char *progname) | |||
473 | printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); | 467 | printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); |
474 | printf(" --oldconfig Update a configuration using a provided .config as base\n"); | 468 | printf(" --oldconfig Update a configuration using a provided .config as base\n"); |
475 | printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); | 469 | printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); |
476 | printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n"); | 470 | printf(" --oldnoconfig Same as silentoldconfig but set new symbols to no\n"); |
477 | printf(" --oldnoconfig An alias of olddefconfig\n"); | ||
478 | printf(" --defconfig <file> New config with default defined in <file>\n"); | 471 | printf(" --defconfig <file> New config with default defined in <file>\n"); |
479 | printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); | 472 | printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); |
480 | printf(" --allnoconfig New config where all options are answered with no\n"); | 473 | printf(" --allnoconfig New config where all options are answered with no\n"); |
@@ -527,7 +520,7 @@ int main(int ac, char **av) | |||
527 | case allmodconfig: | 520 | case allmodconfig: |
528 | case alldefconfig: | 521 | case alldefconfig: |
529 | case listnewconfig: | 522 | case listnewconfig: |
530 | case olddefconfig: | 523 | case oldnoconfig: |
531 | break; | 524 | break; |
532 | case '?': | 525 | case '?': |
533 | conf_usage(progname); | 526 | conf_usage(progname); |
@@ -572,7 +565,7 @@ int main(int ac, char **av) | |||
572 | case oldaskconfig: | 565 | case oldaskconfig: |
573 | case oldconfig: | 566 | case oldconfig: |
574 | case listnewconfig: | 567 | case listnewconfig: |
575 | case olddefconfig: | 568 | case oldnoconfig: |
576 | conf_read(NULL); | 569 | conf_read(NULL); |
577 | break; | 570 | break; |
578 | case allnoconfig: | 571 | case allnoconfig: |
@@ -581,15 +574,8 @@ int main(int ac, char **av) | |||
581 | case alldefconfig: | 574 | case alldefconfig: |
582 | case randconfig: | 575 | case randconfig: |
583 | name = getenv("KCONFIG_ALLCONFIG"); | 576 | name = getenv("KCONFIG_ALLCONFIG"); |
584 | if (!name) | 577 | if (name && !stat(name, &tmpstat)) { |
585 | break; | 578 | conf_read_simple(name, S_DEF_USER); |
586 | if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { | ||
587 | if (conf_read_simple(name, S_DEF_USER)) { | ||
588 | fprintf(stderr, | ||
589 | _("*** Can't read seed configuration \"%s\"!\n"), | ||
590 | name); | ||
591 | exit(1); | ||
592 | } | ||
593 | break; | 579 | break; |
594 | } | 580 | } |
595 | switch (input_mode) { | 581 | switch (input_mode) { |
@@ -600,13 +586,10 @@ int main(int ac, char **av) | |||
600 | case randconfig: name = "allrandom.config"; break; | 586 | case randconfig: name = "allrandom.config"; break; |
601 | default: break; | 587 | default: break; |
602 | } | 588 | } |
603 | if (conf_read_simple(name, S_DEF_USER) && | 589 | if (!stat(name, &tmpstat)) |
604 | conf_read_simple("all.config", S_DEF_USER)) { | 590 | conf_read_simple(name, S_DEF_USER); |
605 | fprintf(stderr, | 591 | else if (!stat("all.config", &tmpstat)) |
606 | _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"), | 592 | conf_read_simple("all.config", S_DEF_USER); |
607 | name); | ||
608 | exit(1); | ||
609 | } | ||
610 | break; | 593 | break; |
611 | default: | 594 | default: |
612 | break; | 595 | break; |
@@ -652,7 +635,7 @@ int main(int ac, char **av) | |||
652 | /* fall through */ | 635 | /* fall through */ |
653 | case oldconfig: | 636 | case oldconfig: |
654 | case listnewconfig: | 637 | case listnewconfig: |
655 | case olddefconfig: | 638 | case oldnoconfig: |
656 | case silentoldconfig: | 639 | case silentoldconfig: |
657 | /* Update until a loop caused no more changes */ | 640 | /* Update until a loop caused no more changes */ |
658 | do { | 641 | do { |
@@ -660,7 +643,7 @@ int main(int ac, char **av) | |||
660 | check_conf(&rootmenu); | 643 | check_conf(&rootmenu); |
661 | } while (conf_cnt && | 644 | } while (conf_cnt && |
662 | (input_mode != listnewconfig && | 645 | (input_mode != listnewconfig && |
663 | input_mode != olddefconfig)); | 646 | input_mode != oldnoconfig)); |
664 | break; | 647 | break; |
665 | } | 648 | } |
666 | 649 | ||
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 13ddf1126c2..59b667cae5f 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -182,66 +182,10 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) | |||
182 | return 0; | 182 | return 0; |
183 | } | 183 | } |
184 | 184 | ||
185 | #define LINE_GROWTH 16 | ||
186 | static int add_byte(int c, char **lineptr, size_t slen, size_t *n) | ||
187 | { | ||
188 | char *nline; | ||
189 | size_t new_size = slen + 1; | ||
190 | if (new_size > *n) { | ||
191 | new_size += LINE_GROWTH - 1; | ||
192 | new_size *= 2; | ||
193 | nline = realloc(*lineptr, new_size); | ||
194 | if (!nline) | ||
195 | return -1; | ||
196 | |||
197 | *lineptr = nline; | ||
198 | *n = new_size; | ||
199 | } | ||
200 | |||
201 | (*lineptr)[slen] = c; | ||
202 | |||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream) | ||
207 | { | ||
208 | char *line = *lineptr; | ||
209 | size_t slen = 0; | ||
210 | |||
211 | for (;;) { | ||
212 | int c = getc(stream); | ||
213 | |||
214 | switch (c) { | ||
215 | case '\n': | ||
216 | if (add_byte(c, &line, slen, n) < 0) | ||
217 | goto e_out; | ||
218 | slen++; | ||
219 | /* fall through */ | ||
220 | case EOF: | ||
221 | if (add_byte('\0', &line, slen, n) < 0) | ||
222 | goto e_out; | ||
223 | *lineptr = line; | ||
224 | if (slen == 0) | ||
225 | return -1; | ||
226 | return slen; | ||
227 | default: | ||
228 | if (add_byte(c, &line, slen, n) < 0) | ||
229 | goto e_out; | ||
230 | slen++; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | e_out: | ||
235 | line[slen-1] = '\0'; | ||
236 | *lineptr = line; | ||
237 | return -1; | ||
238 | } | ||
239 | |||
240 | int conf_read_simple(const char *name, int def) | 185 | int conf_read_simple(const char *name, int def) |
241 | { | 186 | { |
242 | FILE *in = NULL; | 187 | FILE *in = NULL; |
243 | char *line = NULL; | 188 | char line[1024]; |
244 | size_t line_asize = 0; | ||
245 | char *p, *p2; | 189 | char *p, *p2; |
246 | struct symbol *sym; | 190 | struct symbol *sym; |
247 | int i, def_flags; | 191 | int i, def_flags; |
@@ -303,7 +247,7 @@ load: | |||
303 | } | 247 | } |
304 | } | 248 | } |
305 | 249 | ||
306 | while (compat_getline(&line, &line_asize, in) != -1) { | 250 | while (fgets(line, sizeof(line), in)) { |
307 | conf_lineno++; | 251 | conf_lineno++; |
308 | sym = NULL; | 252 | sym = NULL; |
309 | if (line[0] == '#') { | 253 | if (line[0] == '#') { |
@@ -391,7 +335,6 @@ setsym: | |||
391 | cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); | 335 | cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); |
392 | } | 336 | } |
393 | } | 337 | } |
394 | free(line); | ||
395 | fclose(in); | 338 | fclose(in); |
396 | 339 | ||
397 | if (modules_sym) | 340 | if (modules_sym) |
@@ -401,8 +344,10 @@ setsym: | |||
401 | 344 | ||
402 | int conf_read(const char *name) | 345 | int conf_read(const char *name) |
403 | { | 346 | { |
404 | struct symbol *sym; | 347 | struct symbol *sym, *choice_sym; |
405 | int i; | 348 | struct property *prop; |
349 | struct expr *e; | ||
350 | int i, flags; | ||
406 | 351 | ||
407 | sym_set_change_count(0); | 352 | sym_set_change_count(0); |
408 | 353 | ||
@@ -412,7 +357,7 @@ int conf_read(const char *name) | |||
412 | for_all_symbols(i, sym) { | 357 | for_all_symbols(i, sym) { |
413 | sym_calc_value(sym); | 358 | sym_calc_value(sym); |
414 | if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) | 359 | if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) |
415 | continue; | 360 | goto sym_ok; |
416 | if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) { | 361 | if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) { |
417 | /* check that calculated value agrees with saved value */ | 362 | /* check that calculated value agrees with saved value */ |
418 | switch (sym->type) { | 363 | switch (sym->type) { |
@@ -421,18 +366,30 @@ int conf_read(const char *name) | |||
421 | if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym)) | 366 | if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym)) |
422 | break; | 367 | break; |
423 | if (!sym_is_choice(sym)) | 368 | if (!sym_is_choice(sym)) |
424 | continue; | 369 | goto sym_ok; |
425 | /* fall through */ | 370 | /* fall through */ |
426 | default: | 371 | default: |
427 | if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) | 372 | if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) |
428 | continue; | 373 | goto sym_ok; |
429 | break; | 374 | break; |
430 | } | 375 | } |
431 | } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE)) | 376 | } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE)) |
432 | /* no previous value and not saved */ | 377 | /* no previous value and not saved */ |
433 | continue; | 378 | goto sym_ok; |
434 | conf_unsaved++; | 379 | conf_unsaved++; |
435 | /* maybe print value in verbose mode... */ | 380 | /* maybe print value in verbose mode... */ |
381 | sym_ok: | ||
382 | if (!sym_is_choice(sym)) | ||
383 | continue; | ||
384 | /* The choice symbol only has a set value (and thus is not new) | ||
385 | * if all its visible childs have values. | ||
386 | */ | ||
387 | prop = sym_get_choice_prop(sym); | ||
388 | flags = sym->flags; | ||
389 | expr_list_for_each_sym(prop->expr, e, choice_sym) | ||
390 | if (choice_sym->visible != no) | ||
391 | flags &= choice_sym->flags; | ||
392 | sym->flags &= flags | ~SYMBOL_DEF_USER; | ||
436 | } | 393 | } |
437 | 394 | ||
438 | for_all_symbols(i, sym) { | 395 | for_all_symbols(i, sym) { |
@@ -507,7 +464,7 @@ kconfig_print_comment(FILE *fp, const char *value, void *arg) | |||
507 | fprintf(fp, "#"); | 464 | fprintf(fp, "#"); |
508 | if (l) { | 465 | if (l) { |
509 | fprintf(fp, " "); | 466 | fprintf(fp, " "); |
510 | xfwrite(p, l, 1, fp); | 467 | fwrite(p, l, 1, fp); |
511 | p += l; | 468 | p += l; |
512 | } | 469 | } |
513 | fprintf(fp, "\n"); | 470 | fprintf(fp, "\n"); |
@@ -546,6 +503,17 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) | |||
546 | fprintf(fp, "#define %s%s%s 1\n", | 503 | fprintf(fp, "#define %s%s%s 1\n", |
547 | CONFIG_, sym->name, suffix); | 504 | CONFIG_, sym->name, suffix); |
548 | } | 505 | } |
506 | /* | ||
507 | * Generate the __enabled_CONFIG_* and | ||
508 | * __enabled_CONFIG_*_MODULE macros for use by the | ||
509 | * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is | ||
510 | * generated even for booleans so that the IS_ENABLED() macro | ||
511 | * works. | ||
512 | */ | ||
513 | fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n", | ||
514 | sym->name, (*value == 'y')); | ||
515 | fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n", | ||
516 | sym->name, (*value == 'm')); | ||
549 | break; | 517 | break; |
550 | } | 518 | } |
551 | case S_HEX: { | 519 | case S_HEX: { |
@@ -580,7 +548,7 @@ header_print_comment(FILE *fp, const char *value, void *arg) | |||
580 | fprintf(fp, " *"); | 548 | fprintf(fp, " *"); |
581 | if (l) { | 549 | if (l) { |
582 | fprintf(fp, " "); | 550 | fprintf(fp, " "); |
583 | xfwrite(p, l, 1, fp); | 551 | fwrite(p, l, 1, fp); |
584 | p += l; | 552 | p += l; |
585 | } | 553 | } |
586 | fprintf(fp, "\n"); | 554 | fprintf(fp, "\n"); |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index cdd48600e02..80fce57080c 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -10,9 +10,7 @@ | |||
10 | extern "C" { | 10 | extern "C" { |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | #include <assert.h> | ||
14 | #include <stdio.h> | 13 | #include <stdio.h> |
15 | #include "list.h" | ||
16 | #ifndef __cplusplus | 14 | #ifndef __cplusplus |
17 | #include <stdbool.h> | 15 | #include <stdbool.h> |
18 | #endif | 16 | #endif |
@@ -174,15 +172,6 @@ struct menu { | |||
174 | #define MENU_CHANGED 0x0001 | 172 | #define MENU_CHANGED 0x0001 |
175 | #define MENU_ROOT 0x0002 | 173 | #define MENU_ROOT 0x0002 |
176 | 174 | ||
177 | struct jump_key { | ||
178 | struct list_head entries; | ||
179 | size_t offset; | ||
180 | struct menu *target; | ||
181 | int index; | ||
182 | }; | ||
183 | |||
184 | #define JUMP_NB 9 | ||
185 | |||
186 | extern struct file *file_list; | 175 | extern struct file *file_list; |
187 | extern struct file *current_file; | 176 | extern struct file *current_file; |
188 | struct file *lookup_file(const char *name); | 177 | struct file *lookup_file(const char *name); |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index adc230638c5..9f4438027df 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
@@ -683,7 +683,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) | |||
683 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), | 683 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), |
684 | GTK_DIALOG_DESTROY_WITH_PARENT, | 684 | GTK_DIALOG_DESTROY_WITH_PARENT, |
685 | GTK_MESSAGE_INFO, | 685 | GTK_MESSAGE_INFO, |
686 | GTK_BUTTONS_CLOSE, "%s", intro_text); | 686 | GTK_BUTTONS_CLOSE, intro_text); |
687 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", | 687 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", |
688 | G_CALLBACK(gtk_widget_destroy), | 688 | G_CALLBACK(gtk_widget_destroy), |
689 | GTK_OBJECT(dialog)); | 689 | GTK_OBJECT(dialog)); |
@@ -701,7 +701,7 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data) | |||
701 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), | 701 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), |
702 | GTK_DIALOG_DESTROY_WITH_PARENT, | 702 | GTK_DIALOG_DESTROY_WITH_PARENT, |
703 | GTK_MESSAGE_INFO, | 703 | GTK_MESSAGE_INFO, |
704 | GTK_BUTTONS_CLOSE, "%s", about_text); | 704 | GTK_BUTTONS_CLOSE, about_text); |
705 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", | 705 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", |
706 | G_CALLBACK(gtk_widget_destroy), | 706 | G_CALLBACK(gtk_widget_destroy), |
707 | GTK_OBJECT(dialog)); | 707 | GTK_OBJECT(dialog)); |
@@ -720,7 +720,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data) | |||
720 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), | 720 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), |
721 | GTK_DIALOG_DESTROY_WITH_PARENT, | 721 | GTK_DIALOG_DESTROY_WITH_PARENT, |
722 | GTK_MESSAGE_INFO, | 722 | GTK_MESSAGE_INFO, |
723 | GTK_BUTTONS_CLOSE, "%s", license_text); | 723 | GTK_BUTTONS_CLOSE, license_text); |
724 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", | 724 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", |
725 | G_CALLBACK(gtk_widget_destroy), | 725 | G_CALLBACK(gtk_widget_destroy), |
726 | GTK_OBJECT(dialog)); | 726 | GTK_OBJECT(dialog)); |
@@ -830,7 +830,7 @@ static void renderer_edited(GtkCellRendererText * cell, | |||
830 | static void change_sym_value(struct menu *menu, gint col) | 830 | static void change_sym_value(struct menu *menu, gint col) |
831 | { | 831 | { |
832 | struct symbol *sym = menu->sym; | 832 | struct symbol *sym = menu->sym; |
833 | tristate newval; | 833 | tristate oldval, newval; |
834 | 834 | ||
835 | if (!sym) | 835 | if (!sym) |
836 | return; | 836 | return; |
@@ -847,6 +847,7 @@ static void change_sym_value(struct menu *menu, gint col) | |||
847 | switch (sym_get_type(sym)) { | 847 | switch (sym_get_type(sym)) { |
848 | case S_BOOLEAN: | 848 | case S_BOOLEAN: |
849 | case S_TRISTATE: | 849 | case S_TRISTATE: |
850 | oldval = sym_get_tristate_value(sym); | ||
850 | if (!sym_tristate_within_range(sym, newval)) | 851 | if (!sym_tristate_within_range(sym, newval)) |
851 | newval = yes; | 852 | newval = yes; |
852 | sym_set_tristate_value(sym, newval); | 853 | sym_set_tristate_value(sym, newval); |
@@ -1277,6 +1278,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst) | |||
1277 | gboolean valid; | 1278 | gboolean valid; |
1278 | GtkTreeIter *sibling; | 1279 | GtkTreeIter *sibling; |
1279 | struct symbol *sym; | 1280 | struct symbol *sym; |
1281 | struct property *prop; | ||
1280 | struct menu *menu1, *menu2; | 1282 | struct menu *menu1, *menu2; |
1281 | 1283 | ||
1282 | if (src == &rootmenu) | 1284 | if (src == &rootmenu) |
@@ -1285,6 +1287,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst) | |||
1285 | valid = gtk_tree_model_iter_children(model2, child2, dst); | 1287 | valid = gtk_tree_model_iter_children(model2, child2, dst); |
1286 | for (child1 = src->list; child1; child1 = child1->next) { | 1288 | for (child1 = src->list; child1; child1 = child1->next) { |
1287 | 1289 | ||
1290 | prop = child1->prompt; | ||
1288 | sym = child1->sym; | 1291 | sym = child1->sym; |
1289 | 1292 | ||
1290 | reparse: | 1293 | reparse: |
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h deleted file mode 100644 index 0ae730be5f4..00000000000 --- a/scripts/kconfig/list.h +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | #ifndef LIST_H | ||
2 | #define LIST_H | ||
3 | |||
4 | /* | ||
5 | * Copied from include/linux/... | ||
6 | */ | ||
7 | |||
8 | #undef offsetof | ||
9 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | ||
10 | |||
11 | /** | ||
12 | * container_of - cast a member of a structure out to the containing structure | ||
13 | * @ptr: the pointer to the member. | ||
14 | * @type: the type of the container struct this is embedded in. | ||
15 | * @member: the name of the member within the struct. | ||
16 | * | ||
17 | */ | ||
18 | #define container_of(ptr, type, member) ({ \ | ||
19 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
20 | (type *)( (char *)__mptr - offsetof(type,member) );}) | ||
21 | |||
22 | |||
23 | struct list_head { | ||
24 | struct list_head *next, *prev; | ||
25 | }; | ||
26 | |||
27 | |||
28 | #define LIST_HEAD_INIT(name) { &(name), &(name) } | ||
29 | |||
30 | #define LIST_HEAD(name) \ | ||
31 | struct list_head name = LIST_HEAD_INIT(name) | ||
32 | |||
33 | /** | ||
34 | * list_entry - get the struct for this entry | ||
35 | * @ptr: the &struct list_head pointer. | ||
36 | * @type: the type of the struct this is embedded in. | ||
37 | * @member: the name of the list_struct within the struct. | ||
38 | */ | ||
39 | #define list_entry(ptr, type, member) \ | ||
40 | container_of(ptr, type, member) | ||
41 | |||
42 | /** | ||
43 | * list_for_each_entry - iterate over list of given type | ||
44 | * @pos: the type * to use as a loop cursor. | ||
45 | * @head: the head for your list. | ||
46 | * @member: the name of the list_struct within the struct. | ||
47 | */ | ||
48 | #define list_for_each_entry(pos, head, member) \ | ||
49 | for (pos = list_entry((head)->next, typeof(*pos), member); \ | ||
50 | &pos->member != (head); \ | ||
51 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
52 | |||
53 | /** | ||
54 | * list_empty - tests whether a list is empty | ||
55 | * @head: the list to test. | ||
56 | */ | ||
57 | static inline int list_empty(const struct list_head *head) | ||
58 | { | ||
59 | return head->next == head; | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * Insert a new entry between two known consecutive entries. | ||
64 | * | ||
65 | * This is only for internal list manipulation where we know | ||
66 | * the prev/next entries already! | ||
67 | */ | ||
68 | static inline void __list_add(struct list_head *_new, | ||
69 | struct list_head *prev, | ||
70 | struct list_head *next) | ||
71 | { | ||
72 | next->prev = _new; | ||
73 | _new->next = next; | ||
74 | _new->prev = prev; | ||
75 | prev->next = _new; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * list_add_tail - add a new entry | ||
80 | * @new: new entry to be added | ||
81 | * @head: list head to add it before | ||
82 | * | ||
83 | * Insert a new entry before the specified head. | ||
84 | * This is useful for implementing queues. | ||
85 | */ | ||
86 | static inline void list_add_tail(struct list_head *_new, struct list_head *head) | ||
87 | { | ||
88 | __list_add(_new, head->prev, head); | ||
89 | } | ||
90 | |||
91 | #endif | ||
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index c18f2bd9c09..b633bdb9f3d 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -90,10 +90,8 @@ struct conf_printer { | |||
90 | /* confdata.c and expr.c */ | 90 | /* confdata.c and expr.c */ |
91 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) | 91 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) |
92 | { | 92 | { |
93 | assert(len != 0); | 93 | if (fwrite(str, len, count, out) < count) |
94 | 94 | fprintf(stderr, "\nError in writing or end of file.\n"); | |
95 | if (fwrite(str, len, count, out) != count) | ||
96 | fprintf(stderr, "Error in writing or end of file.\n"); | ||
97 | } | 95 | } |
98 | 96 | ||
99 | /* menu.c */ | 97 | /* menu.c */ |
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index ef1a7381f95..47fe9c340f9 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -21,10 +21,8 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); | |||
21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); | 21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); |
22 | P(menu_has_help,bool,(struct menu *menu)); | 22 | P(menu_has_help,bool,(struct menu *menu)); |
23 | P(menu_get_help,const char *,(struct menu *menu)); | 23 | P(menu_get_help,const char *,(struct menu *menu)); |
24 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head | 24 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym)); |
25 | *head)); | 25 | P(get_relations_str, struct gstr, (struct symbol **sym_arr)); |
26 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head | ||
27 | *head)); | ||
28 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); | 26 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); |
29 | 27 | ||
30 | /* symbol.c */ | 28 | /* symbol.c */ |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 53975cf8760..820d2b6800f 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <stdarg.h> | 15 | #include <stdarg.h> |
16 | #include <stdlib.h> | 16 | #include <stdlib.h> |
17 | #include <string.h> | 17 | #include <string.h> |
18 | #include <signal.h> | ||
19 | #include <unistd.h> | 18 | #include <unistd.h> |
20 | #include <locale.h> | 19 | #include <locale.h> |
21 | 20 | ||
@@ -105,10 +104,10 @@ static const char mconf_readme[] = N_( | |||
105 | "Text Box (Help Window)\n" | 104 | "Text Box (Help Window)\n" |
106 | "--------\n" | 105 | "--------\n" |
107 | "o Use the cursor keys to scroll up/down/left/right. The VI editor\n" | 106 | "o Use the cursor keys to scroll up/down/left/right. The VI editor\n" |
108 | " keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for \n" | 107 | " keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n" |
109 | " those who are familiar with less and lynx.\n" | 108 | " who are familiar with less and lynx.\n" |
110 | "\n" | 109 | "\n" |
111 | "o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n" | 110 | "o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n" |
112 | "\n" | 111 | "\n" |
113 | "\n" | 112 | "\n" |
114 | "Alternate Configuration Files\n" | 113 | "Alternate Configuration Files\n" |
@@ -236,19 +235,16 @@ search_help[] = N_( | |||
236 | "Result:\n" | 235 | "Result:\n" |
237 | "-----------------------------------------------------------------\n" | 236 | "-----------------------------------------------------------------\n" |
238 | "Symbol: FOO [=m]\n" | 237 | "Symbol: FOO [=m]\n" |
239 | "Type : tristate\n" | ||
240 | "Prompt: Foo bus is used to drive the bar HW\n" | 238 | "Prompt: Foo bus is used to drive the bar HW\n" |
241 | " Defined at drivers/pci/Kconfig:47\n" | 239 | "Defined at drivers/pci/Kconfig:47\n" |
242 | " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" | 240 | "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" |
243 | " Location:\n" | 241 | "Location:\n" |
244 | " -> Bus options (PCI, PCMCIA, EISA, ISA)\n" | 242 | " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" |
245 | " -> PCI support (PCI [=y])\n" | 243 | " -> PCI support (PCI [=y])\n" |
246 | "(1) -> PCI access mode (<choice> [=y])\n" | 244 | " -> PCI access mode (<choice> [=y])\n" |
247 | " Selects: LIBCRC32\n" | 245 | "Selects: LIBCRC32\n" |
248 | " Selected by: BAR\n" | 246 | "Selected by: BAR\n" |
249 | "-----------------------------------------------------------------\n" | 247 | "-----------------------------------------------------------------\n" |
250 | "o The line 'Type:' shows the type of the configuration option for\n" | ||
251 | " this symbol (boolean, tristate, string, ...)\n" | ||
252 | "o The line 'Prompt:' shows the text used in the menu structure for\n" | 248 | "o The line 'Prompt:' shows the text used in the menu structure for\n" |
253 | " this symbol\n" | 249 | " this symbol\n" |
254 | "o The 'Defined at' line tell at what file / line number the symbol\n" | 250 | "o The 'Defined at' line tell at what file / line number the symbol\n" |
@@ -257,12 +253,8 @@ search_help[] = N_( | |||
257 | " this symbol to be visible in the menu (selectable)\n" | 253 | " this symbol to be visible in the menu (selectable)\n" |
258 | "o The 'Location:' lines tell where in the menu structure this symbol\n" | 254 | "o The 'Location:' lines tell where in the menu structure this symbol\n" |
259 | " is located\n" | 255 | " is located\n" |
260 | " A location followed by a [=y] indicates that this is a\n" | 256 | " A location followed by a [=y] indicate that this is a selectable\n" |
261 | " selectable menu item - and the current value is displayed inside\n" | 257 | " menu item - and current value is displayed inside brackets.\n" |
262 | " brackets.\n" | ||
263 | " Press the key in the (#) prefix to jump directly to that\n" | ||
264 | " location. You will be returned to the current search results\n" | ||
265 | " after exiting this new menu.\n" | ||
266 | "o The 'Selects:' line tell what symbol will be automatically\n" | 258 | "o The 'Selects:' line tell what symbol will be automatically\n" |
267 | " selected if this symbol is selected (y or m)\n" | 259 | " selected if this symbol is selected (y or m)\n" |
268 | "o The 'Selected by' line tell what symbol has selected this symbol\n" | 260 | "o The 'Selected by' line tell what symbol has selected this symbol\n" |
@@ -281,14 +273,11 @@ static int child_count; | |||
281 | static int single_menu_mode; | 273 | static int single_menu_mode; |
282 | static int show_all_options; | 274 | static int show_all_options; |
283 | 275 | ||
284 | static void conf(struct menu *menu, struct menu *active_menu); | 276 | static void conf(struct menu *menu); |
285 | static void conf_choice(struct menu *menu); | 277 | static void conf_choice(struct menu *menu); |
286 | static void conf_string(struct menu *menu); | 278 | static void conf_string(struct menu *menu); |
287 | static void conf_load(void); | 279 | static void conf_load(void); |
288 | static void conf_save(void); | 280 | static void conf_save(void); |
289 | static int show_textbox_ext(const char *title, char *text, int r, int c, | ||
290 | int *keys, int *vscroll, int *hscroll, | ||
291 | update_text_fn update_text, void *data); | ||
292 | static void show_textbox(const char *title, const char *text, int r, int c); | 281 | static void show_textbox(const char *title, const char *text, int r, int c); |
293 | static void show_helptext(const char *title, const char *text); | 282 | static void show_helptext(const char *title, const char *text); |
294 | static void show_help(struct menu *menu); | 283 | static void show_help(struct menu *menu); |
@@ -311,47 +300,12 @@ static void set_config_filename(const char *config_filename) | |||
311 | } | 300 | } |
312 | 301 | ||
313 | 302 | ||
314 | struct search_data { | ||
315 | struct list_head *head; | ||
316 | struct menu **targets; | ||
317 | int *keys; | ||
318 | }; | ||
319 | |||
320 | static void update_text(char *buf, size_t start, size_t end, void *_data) | ||
321 | { | ||
322 | struct search_data *data = _data; | ||
323 | struct jump_key *pos; | ||
324 | int k = 0; | ||
325 | |||
326 | list_for_each_entry(pos, data->head, entries) { | ||
327 | if (pos->offset >= start && pos->offset < end) { | ||
328 | char header[4]; | ||
329 | |||
330 | if (k < JUMP_NB) { | ||
331 | int key = '0' + (pos->index % JUMP_NB) + 1; | ||
332 | |||
333 | sprintf(header, "(%c)", key); | ||
334 | data->keys[k] = key; | ||
335 | data->targets[k] = pos->target; | ||
336 | k++; | ||
337 | } else { | ||
338 | sprintf(header, " "); | ||
339 | } | ||
340 | |||
341 | memcpy(buf + pos->offset, header, sizeof(header) - 1); | ||
342 | } | ||
343 | } | ||
344 | data->keys[k] = 0; | ||
345 | } | ||
346 | |||
347 | static void search_conf(void) | 303 | static void search_conf(void) |
348 | { | 304 | { |
349 | struct symbol **sym_arr; | 305 | struct symbol **sym_arr; |
350 | struct gstr res; | 306 | struct gstr res; |
351 | char *dialog_input; | 307 | char *dialog_input; |
352 | int dres, vscroll = 0, hscroll = 0; | 308 | int dres; |
353 | bool again; | ||
354 | |||
355 | again: | 309 | again: |
356 | dialog_clear(); | 310 | dialog_clear(); |
357 | dres = dialog_inputbox(_("Search Configuration Parameter"), | 311 | dres = dialog_inputbox(_("Search Configuration Parameter"), |
@@ -374,30 +328,10 @@ again: | |||
374 | dialog_input += strlen(CONFIG_); | 328 | dialog_input += strlen(CONFIG_); |
375 | 329 | ||
376 | sym_arr = sym_re_search(dialog_input); | 330 | sym_arr = sym_re_search(dialog_input); |
377 | do { | 331 | res = get_relations_str(sym_arr); |
378 | LIST_HEAD(head); | ||
379 | struct menu *targets[JUMP_NB]; | ||
380 | int keys[JUMP_NB + 1], i; | ||
381 | struct search_data data = { | ||
382 | .head = &head, | ||
383 | .targets = targets, | ||
384 | .keys = keys, | ||
385 | }; | ||
386 | |||
387 | res = get_relations_str(sym_arr, &head); | ||
388 | dres = show_textbox_ext(_("Search Results"), (char *) | ||
389 | str_get(&res), 0, 0, keys, &vscroll, | ||
390 | &hscroll, &update_text, (void *) | ||
391 | &data); | ||
392 | again = false; | ||
393 | for (i = 0; i < JUMP_NB && keys[i]; i++) | ||
394 | if (dres == keys[i]) { | ||
395 | conf(targets[i]->parent, targets[i]); | ||
396 | again = true; | ||
397 | } | ||
398 | str_free(&res); | ||
399 | } while (again); | ||
400 | free(sym_arr); | 332 | free(sym_arr); |
333 | show_textbox(_("Search Results"), str_get(&res), 0, 0); | ||
334 | str_free(&res); | ||
401 | } | 335 | } |
402 | 336 | ||
403 | static void build_conf(struct menu *menu) | 337 | static void build_conf(struct menu *menu) |
@@ -578,11 +512,12 @@ conf_childs: | |||
578 | indent -= doint; | 512 | indent -= doint; |
579 | } | 513 | } |
580 | 514 | ||
581 | static void conf(struct menu *menu, struct menu *active_menu) | 515 | static void conf(struct menu *menu) |
582 | { | 516 | { |
583 | struct menu *submenu; | 517 | struct menu *submenu; |
584 | const char *prompt = menu_get_prompt(menu); | 518 | const char *prompt = menu_get_prompt(menu); |
585 | struct symbol *sym; | 519 | struct symbol *sym; |
520 | struct menu *active_menu = NULL; | ||
586 | int res; | 521 | int res; |
587 | int s_scroll = 0; | 522 | int s_scroll = 0; |
588 | 523 | ||
@@ -625,13 +560,13 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
625 | if (single_menu_mode) | 560 | if (single_menu_mode) |
626 | submenu->data = (void *) (long) !submenu->data; | 561 | submenu->data = (void *) (long) !submenu->data; |
627 | else | 562 | else |
628 | conf(submenu, NULL); | 563 | conf(submenu); |
629 | break; | 564 | break; |
630 | case 't': | 565 | case 't': |
631 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) | 566 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) |
632 | conf_choice(submenu); | 567 | conf_choice(submenu); |
633 | else if (submenu->prompt->type == P_MENU) | 568 | else if (submenu->prompt->type == P_MENU) |
634 | conf(submenu, NULL); | 569 | conf(submenu); |
635 | break; | 570 | break; |
636 | case 's': | 571 | case 's': |
637 | conf_string(submenu); | 572 | conf_string(submenu); |
@@ -670,7 +605,7 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
670 | if (item_is_tag('t')) | 605 | if (item_is_tag('t')) |
671 | sym_toggle_tristate_value(sym); | 606 | sym_toggle_tristate_value(sym); |
672 | else if (item_is_tag('m')) | 607 | else if (item_is_tag('m')) |
673 | conf(submenu, NULL); | 608 | conf(submenu); |
674 | break; | 609 | break; |
675 | case 7: | 610 | case 7: |
676 | search_conf(); | 611 | search_conf(); |
@@ -682,19 +617,10 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
682 | } | 617 | } |
683 | } | 618 | } |
684 | 619 | ||
685 | static int show_textbox_ext(const char *title, char *text, int r, int c, int | ||
686 | *keys, int *vscroll, int *hscroll, update_text_fn | ||
687 | update_text, void *data) | ||
688 | { | ||
689 | dialog_clear(); | ||
690 | return dialog_textbox(title, text, r, c, keys, vscroll, hscroll, | ||
691 | update_text, data); | ||
692 | } | ||
693 | |||
694 | static void show_textbox(const char *title, const char *text, int r, int c) | 620 | static void show_textbox(const char *title, const char *text, int r, int c) |
695 | { | 621 | { |
696 | show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL, | 622 | dialog_clear(); |
697 | NULL, NULL); | 623 | dialog_textbox(title, text, r, c); |
698 | } | 624 | } |
699 | 625 | ||
700 | static void show_helptext(const char *title, const char *text) | 626 | static void show_helptext(const char *title, const char *text) |
@@ -866,56 +792,9 @@ static void conf_save(void) | |||
866 | } | 792 | } |
867 | } | 793 | } |
868 | 794 | ||
869 | static int handle_exit(void) | ||
870 | { | ||
871 | int res; | ||
872 | |||
873 | dialog_clear(); | ||
874 | if (conf_get_changed()) | ||
875 | res = dialog_yesno(NULL, | ||
876 | _("Do you wish to save your new configuration ?\n" | ||
877 | "<ESC><ESC> to continue."), | ||
878 | 6, 60); | ||
879 | else | ||
880 | res = -1; | ||
881 | |||
882 | end_dialog(saved_x, saved_y); | ||
883 | |||
884 | switch (res) { | ||
885 | case 0: | ||
886 | if (conf_write(filename)) { | ||
887 | fprintf(stderr, _("\n\n" | ||
888 | "Error while writing of the configuration.\n" | ||
889 | "Your configuration changes were NOT saved." | ||
890 | "\n\n")); | ||
891 | return 1; | ||
892 | } | ||
893 | /* fall through */ | ||
894 | case -1: | ||
895 | printf(_("\n\n" | ||
896 | "*** End of the configuration.\n" | ||
897 | "*** Execute 'make' to start the build or try 'make help'." | ||
898 | "\n\n")); | ||
899 | res = 0; | ||
900 | break; | ||
901 | default: | ||
902 | fprintf(stderr, _("\n\n" | ||
903 | "Your configuration changes were NOT saved." | ||
904 | "\n\n")); | ||
905 | if (res != KEY_ESC) | ||
906 | res = 0; | ||
907 | } | ||
908 | |||
909 | return res; | ||
910 | } | ||
911 | |||
912 | static void sig_handler(int signo) | ||
913 | { | ||
914 | exit(handle_exit()); | ||
915 | } | ||
916 | |||
917 | int main(int ac, char **av) | 795 | int main(int ac, char **av) |
918 | { | 796 | { |
797 | int saved_x, saved_y; | ||
919 | char *mode; | 798 | char *mode; |
920 | int res; | 799 | int res; |
921 | 800 | ||
@@ -923,8 +802,6 @@ int main(int ac, char **av) | |||
923 | bindtextdomain(PACKAGE, LOCALEDIR); | 802 | bindtextdomain(PACKAGE, LOCALEDIR); |
924 | textdomain(PACKAGE); | 803 | textdomain(PACKAGE); |
925 | 804 | ||
926 | signal(SIGINT, sig_handler); | ||
927 | |||
928 | conf_parse(av[1]); | 805 | conf_parse(av[1]); |
929 | conf_read(NULL); | 806 | conf_read(NULL); |
930 | 807 | ||
@@ -934,6 +811,9 @@ int main(int ac, char **av) | |||
934 | single_menu_mode = 1; | 811 | single_menu_mode = 1; |
935 | } | 812 | } |
936 | 813 | ||
814 | initscr(); | ||
815 | |||
816 | getyx(stdscr, saved_y, saved_x); | ||
937 | if (init_dialog(NULL)) { | 817 | if (init_dialog(NULL)) { |
938 | fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); | 818 | fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); |
939 | fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); | 819 | fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); |
@@ -942,10 +822,41 @@ int main(int ac, char **av) | |||
942 | 822 | ||
943 | set_config_filename(conf_get_configname()); | 823 | set_config_filename(conf_get_configname()); |
944 | do { | 824 | do { |
945 | conf(&rootmenu, NULL); | 825 | conf(&rootmenu); |
946 | res = handle_exit(); | 826 | dialog_clear(); |
827 | if (conf_get_changed()) | ||
828 | res = dialog_yesno(NULL, | ||
829 | _("Do you wish to save your " | ||
830 | "new configuration?\n" | ||
831 | "<ESC><ESC> to continue."), | ||
832 | 6, 60); | ||
833 | else | ||
834 | res = -1; | ||
947 | } while (res == KEY_ESC); | 835 | } while (res == KEY_ESC); |
836 | end_dialog(saved_x, saved_y); | ||
837 | |||
838 | switch (res) { | ||
839 | case 0: | ||
840 | if (conf_write(filename)) { | ||
841 | fprintf(stderr, _("\n\n" | ||
842 | "Error while writing of the configuration.\n" | ||
843 | "Your configuration changes were NOT saved." | ||
844 | "\n\n")); | ||
845 | return 1; | ||
846 | } | ||
847 | /* fall through */ | ||
848 | case -1: | ||
849 | printf(_("\n\n" | ||
850 | "*** End of the configuration.\n" | ||
851 | "*** Execute 'make' to start the build or try 'make help'." | ||
852 | "\n\n")); | ||
853 | break; | ||
854 | default: | ||
855 | fprintf(stderr, _("\n\n" | ||
856 | "Your configuration changes were NOT saved." | ||
857 | "\n\n")); | ||
858 | } | ||
948 | 859 | ||
949 | return res; | 860 | return 0; |
950 | } | 861 | } |
951 | 862 | ||
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e98a05c8e50..beeb92e75f8 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -10,7 +10,8 @@ | |||
10 | 10 | ||
11 | #include "lkc.h" | 11 | #include "lkc.h" |
12 | 12 | ||
13 | static const char nohelp_text[] = "There is no help available for this option."; | 13 | static const char nohelp_text[] = N_( |
14 | "There is no help available for this option.\n"); | ||
14 | 15 | ||
15 | struct menu rootmenu; | 16 | struct menu rootmenu; |
16 | static struct menu **last_entry_ptr; | 17 | static struct menu **last_entry_ptr; |
@@ -507,12 +508,10 @@ const char *menu_get_help(struct menu *menu) | |||
507 | return ""; | 508 | return ""; |
508 | } | 509 | } |
509 | 510 | ||
510 | static void get_prompt_str(struct gstr *r, struct property *prop, | 511 | static void get_prompt_str(struct gstr *r, struct property *prop) |
511 | struct list_head *head) | ||
512 | { | 512 | { |
513 | int i, j; | 513 | int i, j; |
514 | struct menu *submenu[8], *menu, *location = NULL; | 514 | struct menu *submenu[8], *menu; |
515 | struct jump_key *jump; | ||
516 | 515 | ||
517 | str_printf(r, _("Prompt: %s\n"), _(prop->text)); | 516 | str_printf(r, _("Prompt: %s\n"), _(prop->text)); |
518 | str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, | 517 | str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, |
@@ -523,44 +522,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop, | |||
523 | str_append(r, "\n"); | 522 | str_append(r, "\n"); |
524 | } | 523 | } |
525 | menu = prop->menu->parent; | 524 | menu = prop->menu->parent; |
526 | for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { | 525 | for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) |
527 | bool accessible = menu_is_visible(menu); | ||
528 | |||
529 | submenu[i++] = menu; | 526 | submenu[i++] = menu; |
530 | if (location == NULL && accessible) | ||
531 | location = menu; | ||
532 | } | ||
533 | if (head && location) { | ||
534 | jump = malloc(sizeof(struct jump_key)); | ||
535 | |||
536 | if (menu_is_visible(prop->menu)) { | ||
537 | /* | ||
538 | * There is not enough room to put the hint at the | ||
539 | * beginning of the "Prompt" line. Put the hint on the | ||
540 | * last "Location" line even when it would belong on | ||
541 | * the former. | ||
542 | */ | ||
543 | jump->target = prop->menu; | ||
544 | } else | ||
545 | jump->target = location; | ||
546 | |||
547 | if (list_empty(head)) | ||
548 | jump->index = 0; | ||
549 | else | ||
550 | jump->index = list_entry(head->prev, struct jump_key, | ||
551 | entries)->index + 1; | ||
552 | |||
553 | list_add_tail(&jump->entries, head); | ||
554 | } | ||
555 | |||
556 | if (i > 0) { | 527 | if (i > 0) { |
557 | str_printf(r, _(" Location:\n")); | 528 | str_printf(r, _(" Location:\n")); |
558 | for (j = 4; --i >= 0; j += 2) { | 529 | for (j = 4; --i >= 0; j += 2) { |
559 | menu = submenu[i]; | 530 | menu = submenu[i]; |
560 | if (head && location && menu == location) | 531 | str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu))); |
561 | jump->offset = r->len - 1; | ||
562 | str_printf(r, "%*c-> %s", j, ' ', | ||
563 | _(menu_get_prompt(menu))); | ||
564 | if (menu->sym) { | 532 | if (menu->sym) { |
565 | str_printf(r, " (%s [=%s])", menu->sym->name ? | 533 | str_printf(r, " (%s [=%s])", menu->sym->name ? |
566 | menu->sym->name : _("<choice>"), | 534 | menu->sym->name : _("<choice>"), |
@@ -571,11 +539,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, | |||
571 | } | 539 | } |
572 | } | 540 | } |
573 | 541 | ||
574 | /* | 542 | void get_symbol_str(struct gstr *r, struct symbol *sym) |
575 | * head is optional and may be NULL | ||
576 | */ | ||
577 | void get_symbol_str(struct gstr *r, struct symbol *sym, | ||
578 | struct list_head *head) | ||
579 | { | 543 | { |
580 | bool hit; | 544 | bool hit; |
581 | struct property *prop; | 545 | struct property *prop; |
@@ -594,7 +558,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, | |||
594 | } | 558 | } |
595 | } | 559 | } |
596 | for_all_prompts(sym, prop) | 560 | for_all_prompts(sym, prop) |
597 | get_prompt_str(r, prop, head); | 561 | get_prompt_str(r, prop); |
598 | hit = false; | 562 | hit = false; |
599 | for_all_properties(sym, prop, P_SELECT) { | 563 | for_all_properties(sym, prop, P_SELECT) { |
600 | if (!hit) { | 564 | if (!hit) { |
@@ -614,14 +578,14 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, | |||
614 | str_append(r, "\n\n"); | 578 | str_append(r, "\n\n"); |
615 | } | 579 | } |
616 | 580 | ||
617 | struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head) | 581 | struct gstr get_relations_str(struct symbol **sym_arr) |
618 | { | 582 | { |
619 | struct symbol *sym; | 583 | struct symbol *sym; |
620 | struct gstr res = str_new(); | 584 | struct gstr res = str_new(); |
621 | int i; | 585 | int i; |
622 | 586 | ||
623 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) | 587 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) |
624 | get_symbol_str(&res, sym, head); | 588 | get_symbol_str(&res, sym); |
625 | if (!i) | 589 | if (!i) |
626 | str_append(&res, _("No matches found.\n")); | 590 | str_append(&res, _("No matches found.\n")); |
627 | return res; | 591 | return res; |
@@ -631,14 +595,15 @@ struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head) | |||
631 | void menu_get_ext_help(struct menu *menu, struct gstr *help) | 595 | void menu_get_ext_help(struct menu *menu, struct gstr *help) |
632 | { | 596 | { |
633 | struct symbol *sym = menu->sym; | 597 | struct symbol *sym = menu->sym; |
634 | const char *help_text = nohelp_text; | ||
635 | 598 | ||
636 | if (menu_has_help(menu)) { | 599 | if (menu_has_help(menu)) { |
637 | if (sym->name) | 600 | if (sym->name) |
638 | str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); | 601 | str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); |
639 | help_text = menu_get_help(menu); | 602 | str_append(help, _(menu_get_help(menu))); |
603 | str_append(help, "\n"); | ||
604 | } else { | ||
605 | str_append(help, nohelp_text); | ||
640 | } | 606 | } |
641 | str_printf(help, "%s\n", _(help_text)); | ||
642 | if (sym) | 607 | if (sym) |
643 | get_symbol_str(help, sym, NULL); | 608 | get_symbol_str(help, sym); |
644 | } | 609 | } |
diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh deleted file mode 100755 index 974d5cb7e30..00000000000 --- a/scripts/kconfig/merge_config.sh +++ /dev/null | |||
@@ -1,130 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # merge_config.sh - Takes a list of config fragment values, and merges | ||
3 | # them one by one. Provides warnings on overridden values, and specified | ||
4 | # values that did not make it to the resulting .config file (due to missed | ||
5 | # dependencies or config symbol removal). | ||
6 | # | ||
7 | # Portions reused from kconf_check and generate_cfg: | ||
8 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/kconf_check | ||
9 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/generate_cfg | ||
10 | # | ||
11 | # Copyright (c) 2009-2010 Wind River Systems, Inc. | ||
12 | # Copyright 2011 Linaro | ||
13 | # | ||
14 | # This program is free software; you can redistribute it and/or modify | ||
15 | # it under the terms of the GNU General Public License version 2 as | ||
16 | # published by the Free Software Foundation. | ||
17 | # | ||
18 | # This program is distributed in the hope that it will be useful, | ||
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | # See the GNU General Public License for more details. | ||
22 | |||
23 | clean_up() { | ||
24 | rm -f $TMP_FILE | ||
25 | exit | ||
26 | } | ||
27 | trap clean_up HUP INT TERM | ||
28 | |||
29 | usage() { | ||
30 | echo "Usage: $0 [OPTIONS] [CONFIG [...]]" | ||
31 | echo " -h display this help text" | ||
32 | echo " -m only merge the fragments, do not execute the make command" | ||
33 | echo " -n use allnoconfig instead of alldefconfig" | ||
34 | echo " -r list redundant entries when merging fragments" | ||
35 | } | ||
36 | |||
37 | MAKE=true | ||
38 | ALLTARGET=alldefconfig | ||
39 | WARNREDUN=false | ||
40 | |||
41 | while true; do | ||
42 | case $1 in | ||
43 | "-n") | ||
44 | ALLTARGET=allnoconfig | ||
45 | shift | ||
46 | continue | ||
47 | ;; | ||
48 | "-m") | ||
49 | MAKE=false | ||
50 | shift | ||
51 | continue | ||
52 | ;; | ||
53 | "-h") | ||
54 | usage | ||
55 | exit | ||
56 | ;; | ||
57 | "-r") | ||
58 | WARNREDUN=true | ||
59 | shift | ||
60 | continue | ||
61 | ;; | ||
62 | *) | ||
63 | break | ||
64 | ;; | ||
65 | esac | ||
66 | done | ||
67 | |||
68 | INITFILE=$1 | ||
69 | shift; | ||
70 | |||
71 | MERGE_LIST=$* | ||
72 | SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" | ||
73 | TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) | ||
74 | |||
75 | echo "Using $INITFILE as base" | ||
76 | cat $INITFILE > $TMP_FILE | ||
77 | |||
78 | # Merge files, printing warnings on overrided values | ||
79 | for MERGE_FILE in $MERGE_LIST ; do | ||
80 | echo "Merging $MERGE_FILE" | ||
81 | CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) | ||
82 | |||
83 | for CFG in $CFG_LIST ; do | ||
84 | grep -q -w $CFG $TMP_FILE | ||
85 | if [ $? -eq 0 ] ; then | ||
86 | PREV_VAL=$(grep -w $CFG $TMP_FILE) | ||
87 | NEW_VAL=$(grep -w $CFG $MERGE_FILE) | ||
88 | if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then | ||
89 | echo Value of $CFG is redefined by fragment $MERGE_FILE: | ||
90 | echo Previous value: $PREV_VAL | ||
91 | echo New value: $NEW_VAL | ||
92 | echo | ||
93 | elif [ "$WARNREDUN" = "true" ]; then | ||
94 | echo Value of $CFG is redundant by fragment $MERGE_FILE: | ||
95 | fi | ||
96 | sed -i "/$CFG[ =]/d" $TMP_FILE | ||
97 | fi | ||
98 | done | ||
99 | cat $MERGE_FILE >> $TMP_FILE | ||
100 | done | ||
101 | |||
102 | if [ "$MAKE" = "false" ]; then | ||
103 | cp $TMP_FILE .config | ||
104 | echo "#" | ||
105 | echo "# merged configuration written to .config (needs make)" | ||
106 | echo "#" | ||
107 | clean_up | ||
108 | exit | ||
109 | fi | ||
110 | |||
111 | # Use the merged file as the starting point for: | ||
112 | # alldefconfig: Fills in any missing symbols with Kconfig default | ||
113 | # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set | ||
114 | make KCONFIG_ALLCONFIG=$TMP_FILE $ALLTARGET | ||
115 | |||
116 | |||
117 | # Check all specified config values took (might have missed-dependency issues) | ||
118 | for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do | ||
119 | |||
120 | REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) | ||
121 | ACTUAL_VAL=$(grep -w -e "$CFG" .config) | ||
122 | if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then | ||
123 | echo "Value requested for $CFG not in final .config" | ||
124 | echo "Requested value: $REQUESTED_VAL" | ||
125 | echo "Actual value: $ACTUAL_VAL" | ||
126 | echo "" | ||
127 | fi | ||
128 | done | ||
129 | |||
130 | clean_up | ||
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 87d4b15da95..39ca1f1640e 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
@@ -83,10 +83,10 @@ static const char nconf_readme[] = N_( | |||
83 | "Text Box (Help Window)\n" | 83 | "Text Box (Help Window)\n" |
84 | "--------\n" | 84 | "--------\n" |
85 | "o Use the cursor keys to scroll up/down/left/right. The VI editor\n" | 85 | "o Use the cursor keys to scroll up/down/left/right. The VI editor\n" |
86 | " keys h,j,k,l function here as do <u>, <d> and <SPACE BAR> for\n" | 86 | " keys h,j,k,l function here as do <SPACE BAR> for those\n" |
87 | " those who are familiar with less and lynx.\n" | 87 | " who are familiar with less and lynx.\n" |
88 | "\n" | 88 | "\n" |
89 | "o Press <Enter>, <F1>, <F5>, <F9>, <q> or <Esc> to exit.\n" | 89 | "o Press <Enter>, <F1>, <F5>, <F7> or <Esc> to exit.\n" |
90 | "\n" | 90 | "\n" |
91 | "\n" | 91 | "\n" |
92 | "Alternate Configuration Files\n" | 92 | "Alternate Configuration Files\n" |
@@ -182,6 +182,8 @@ setmod_text[] = N_( | |||
182 | "This feature depends on another which\n" | 182 | "This feature depends on another which\n" |
183 | "has been configured as a module.\n" | 183 | "has been configured as a module.\n" |
184 | "As a result, this feature will be built as a module."), | 184 | "As a result, this feature will be built as a module."), |
185 | nohelp_text[] = N_( | ||
186 | "There is no help available for this option.\n"), | ||
185 | load_config_text[] = N_( | 187 | load_config_text[] = N_( |
186 | "Enter the name of the configuration file you wish to load.\n" | 188 | "Enter the name of the configuration file you wish to load.\n" |
187 | "Accept the name shown to restore the configuration you\n" | 189 | "Accept the name shown to restore the configuration you\n" |
@@ -223,7 +225,7 @@ search_help[] = N_( | |||
223 | "Defined at drivers/pci/Kconfig:47\n" | 225 | "Defined at drivers/pci/Kconfig:47\n" |
224 | "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" | 226 | "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" |
225 | "Location:\n" | 227 | "Location:\n" |
226 | " -> Bus options (PCI, PCMCIA, EISA, ISA)\n" | 228 | " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" |
227 | " -> PCI support (PCI [ = y])\n" | 229 | " -> PCI support (PCI [ = y])\n" |
228 | " -> PCI access mode (<choice> [ = y])\n" | 230 | " -> PCI access mode (<choice> [ = y])\n" |
229 | "Selects: LIBCRC32\n" | 231 | "Selects: LIBCRC32\n" |
@@ -278,9 +280,6 @@ static int global_exit; | |||
278 | /* the currently selected button */ | 280 | /* the currently selected button */ |
279 | const char *current_instructions = menu_instructions; | 281 | const char *current_instructions = menu_instructions; |
280 | 282 | ||
281 | static char *dialog_input_result; | ||
282 | static int dialog_input_result_len; | ||
283 | |||
284 | static void conf(struct menu *menu); | 283 | static void conf(struct menu *menu); |
285 | static void conf_choice(struct menu *menu); | 284 | static void conf_choice(struct menu *menu); |
286 | static void conf_string(struct menu *menu); | 285 | static void conf_string(struct menu *menu); |
@@ -696,6 +695,7 @@ static void search_conf(void) | |||
696 | { | 695 | { |
697 | struct symbol **sym_arr; | 696 | struct symbol **sym_arr; |
698 | struct gstr res; | 697 | struct gstr res; |
698 | char dialog_input_result[100]; | ||
699 | char *dialog_input; | 699 | char *dialog_input; |
700 | int dres; | 700 | int dres; |
701 | again: | 701 | again: |
@@ -703,7 +703,7 @@ again: | |||
703 | _("Search Configuration Parameter"), | 703 | _("Search Configuration Parameter"), |
704 | _("Enter " CONFIG_ " (sub)string to search for " | 704 | _("Enter " CONFIG_ " (sub)string to search for " |
705 | "(with or without \"" CONFIG_ "\")"), | 705 | "(with or without \"" CONFIG_ "\")"), |
706 | "", &dialog_input_result, &dialog_input_result_len); | 706 | "", dialog_input_result, 99); |
707 | switch (dres) { | 707 | switch (dres) { |
708 | case 0: | 708 | case 0: |
709 | break; | 709 | break; |
@@ -721,7 +721,7 @@ again: | |||
721 | dialog_input += strlen(CONFIG_); | 721 | dialog_input += strlen(CONFIG_); |
722 | 722 | ||
723 | sym_arr = sym_re_search(dialog_input); | 723 | sym_arr = sym_re_search(dialog_input); |
724 | res = get_relations_str(sym_arr, NULL); | 724 | res = get_relations_str(sym_arr); |
725 | free(sym_arr); | 725 | free(sym_arr); |
726 | show_scroll_win(main_window, | 726 | show_scroll_win(main_window, |
727 | _("Search Results"), str_get(&res)); | 727 | _("Search Results"), str_get(&res)); |
@@ -1348,6 +1348,7 @@ static void conf_choice(struct menu *menu) | |||
1348 | static void conf_string(struct menu *menu) | 1348 | static void conf_string(struct menu *menu) |
1349 | { | 1349 | { |
1350 | const char *prompt = menu_get_prompt(menu); | 1350 | const char *prompt = menu_get_prompt(menu); |
1351 | char dialog_input_result[256]; | ||
1351 | 1352 | ||
1352 | while (1) { | 1353 | while (1) { |
1353 | int res; | 1354 | int res; |
@@ -1370,8 +1371,8 @@ static void conf_string(struct menu *menu) | |||
1370 | prompt ? _(prompt) : _("Main Menu"), | 1371 | prompt ? _(prompt) : _("Main Menu"), |
1371 | heading, | 1372 | heading, |
1372 | sym_get_string_value(menu->sym), | 1373 | sym_get_string_value(menu->sym), |
1373 | &dialog_input_result, | 1374 | dialog_input_result, |
1374 | &dialog_input_result_len); | 1375 | sizeof(dialog_input_result)); |
1375 | switch (res) { | 1376 | switch (res) { |
1376 | case 0: | 1377 | case 0: |
1377 | if (sym_set_string_value(menu->sym, | 1378 | if (sym_set_string_value(menu->sym, |
@@ -1391,13 +1392,14 @@ static void conf_string(struct menu *menu) | |||
1391 | 1392 | ||
1392 | static void conf_load(void) | 1393 | static void conf_load(void) |
1393 | { | 1394 | { |
1395 | char dialog_input_result[256]; | ||
1394 | while (1) { | 1396 | while (1) { |
1395 | int res; | 1397 | int res; |
1396 | res = dialog_inputbox(main_window, | 1398 | res = dialog_inputbox(main_window, |
1397 | NULL, load_config_text, | 1399 | NULL, load_config_text, |
1398 | filename, | 1400 | filename, |
1399 | &dialog_input_result, | 1401 | dialog_input_result, |
1400 | &dialog_input_result_len); | 1402 | sizeof(dialog_input_result)); |
1401 | switch (res) { | 1403 | switch (res) { |
1402 | case 0: | 1404 | case 0: |
1403 | if (!dialog_input_result[0]) | 1405 | if (!dialog_input_result[0]) |
@@ -1422,13 +1424,14 @@ static void conf_load(void) | |||
1422 | 1424 | ||
1423 | static void conf_save(void) | 1425 | static void conf_save(void) |
1424 | { | 1426 | { |
1427 | char dialog_input_result[256]; | ||
1425 | while (1) { | 1428 | while (1) { |
1426 | int res; | 1429 | int res; |
1427 | res = dialog_inputbox(main_window, | 1430 | res = dialog_inputbox(main_window, |
1428 | NULL, save_config_text, | 1431 | NULL, save_config_text, |
1429 | filename, | 1432 | filename, |
1430 | &dialog_input_result, | 1433 | dialog_input_result, |
1431 | &dialog_input_result_len); | 1434 | sizeof(dialog_input_result)); |
1432 | switch (res) { | 1435 | switch (res) { |
1433 | case 0: | 1436 | case 0: |
1434 | if (!dialog_input_result[0]) | 1437 | if (!dialog_input_result[0]) |
@@ -1503,11 +1506,7 @@ int main(int ac, char **av) | |||
1503 | } | 1506 | } |
1504 | 1507 | ||
1505 | notimeout(stdscr, FALSE); | 1508 | notimeout(stdscr, FALSE); |
1506 | #if NCURSES_REENTRANT | ||
1507 | set_escdelay(1); | ||
1508 | #else | ||
1509 | ESCDELAY = 1; | 1509 | ESCDELAY = 1; |
1510 | #endif | ||
1511 | 1510 | ||
1512 | /* set btns menu */ | 1511 | /* set btns menu */ |
1513 | curses_menu = new_menu(curses_menu_items); | 1512 | curses_menu = new_menu(curses_menu_items); |
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 379003c7a2b..f8137b3a538 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c | |||
@@ -356,7 +356,7 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...) | |||
356 | 356 | ||
357 | int dialog_inputbox(WINDOW *main_window, | 357 | int dialog_inputbox(WINDOW *main_window, |
358 | const char *title, const char *prompt, | 358 | const char *title, const char *prompt, |
359 | const char *init, char **resultp, int *result_len) | 359 | const char *init, char *result, int result_len) |
360 | { | 360 | { |
361 | int prompt_lines = 0; | 361 | int prompt_lines = 0; |
362 | int prompt_width = 0; | 362 | int prompt_width = 0; |
@@ -367,13 +367,7 @@ int dialog_inputbox(WINDOW *main_window, | |||
367 | int i, x, y; | 367 | int i, x, y; |
368 | int res = -1; | 368 | int res = -1; |
369 | int cursor_position = strlen(init); | 369 | int cursor_position = strlen(init); |
370 | int cursor_form_win; | ||
371 | char *result = *resultp; | ||
372 | 370 | ||
373 | if (strlen(init)+1 > *result_len) { | ||
374 | *result_len = strlen(init)+1; | ||
375 | *resultp = result = realloc(result, *result_len); | ||
376 | } | ||
377 | 371 | ||
378 | /* find the widest line of msg: */ | 372 | /* find the widest line of msg: */ |
379 | prompt_lines = get_line_no(prompt); | 373 | prompt_lines = get_line_no(prompt); |
@@ -390,7 +384,7 @@ int dialog_inputbox(WINDOW *main_window, | |||
390 | y = (LINES-(prompt_lines+4))/2; | 384 | y = (LINES-(prompt_lines+4))/2; |
391 | x = (COLS-(prompt_width+4))/2; | 385 | x = (COLS-(prompt_width+4))/2; |
392 | 386 | ||
393 | strncpy(result, init, *result_len); | 387 | strncpy(result, init, result_len); |
394 | 388 | ||
395 | /* create the windows */ | 389 | /* create the windows */ |
396 | win = newwin(prompt_lines+6, prompt_width+7, y, x); | 390 | win = newwin(prompt_lines+6, prompt_width+7, y, x); |
@@ -411,9 +405,7 @@ int dialog_inputbox(WINDOW *main_window, | |||
411 | fill_window(prompt_win, prompt); | 405 | fill_window(prompt_win, prompt); |
412 | 406 | ||
413 | mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); | 407 | mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); |
414 | cursor_form_win = min(cursor_position, prompt_width-1); | 408 | mvwprintw(form_win, 0, 0, "%s", result); |
415 | mvwprintw(form_win, 0, 0, "%s", | ||
416 | result + cursor_position-cursor_form_win); | ||
417 | 409 | ||
418 | /* create panels */ | 410 | /* create panels */ |
419 | panel = new_panel(win); | 411 | panel = new_panel(win); |
@@ -439,8 +431,6 @@ int dialog_inputbox(WINDOW *main_window, | |||
439 | &result[cursor_position], | 431 | &result[cursor_position], |
440 | len-cursor_position+1); | 432 | len-cursor_position+1); |
441 | cursor_position--; | 433 | cursor_position--; |
442 | cursor_form_win--; | ||
443 | len--; | ||
444 | } | 434 | } |
445 | break; | 435 | break; |
446 | case KEY_DC: | 436 | case KEY_DC: |
@@ -448,63 +438,38 @@ int dialog_inputbox(WINDOW *main_window, | |||
448 | memmove(&result[cursor_position], | 438 | memmove(&result[cursor_position], |
449 | &result[cursor_position+1], | 439 | &result[cursor_position+1], |
450 | len-cursor_position+1); | 440 | len-cursor_position+1); |
451 | len--; | ||
452 | } | 441 | } |
453 | break; | 442 | break; |
454 | case KEY_UP: | 443 | case KEY_UP: |
455 | case KEY_RIGHT: | 444 | case KEY_RIGHT: |
456 | if (cursor_position < len) { | 445 | if (cursor_position < len && |
446 | cursor_position < min(result_len, prompt_width)) | ||
457 | cursor_position++; | 447 | cursor_position++; |
458 | cursor_form_win++; | ||
459 | } | ||
460 | break; | 448 | break; |
461 | case KEY_DOWN: | 449 | case KEY_DOWN: |
462 | case KEY_LEFT: | 450 | case KEY_LEFT: |
463 | if (cursor_position > 0) { | 451 | if (cursor_position > 0) |
464 | cursor_position--; | 452 | cursor_position--; |
465 | cursor_form_win--; | ||
466 | } | ||
467 | break; | ||
468 | case KEY_HOME: | ||
469 | cursor_position = 0; | ||
470 | cursor_form_win = 0; | ||
471 | break; | ||
472 | case KEY_END: | ||
473 | cursor_position = len; | ||
474 | cursor_form_win = min(cursor_position, prompt_width-1); | ||
475 | break; | 453 | break; |
476 | default: | 454 | default: |
477 | if ((isgraph(res) || isspace(res))) { | 455 | if ((isgraph(res) || isspace(res)) && |
478 | /* one for new char, one for '\0' */ | 456 | len-2 < result_len) { |
479 | if (len+2 > *result_len) { | ||
480 | *result_len = len+2; | ||
481 | *resultp = result = realloc(result, | ||
482 | *result_len); | ||
483 | } | ||
484 | /* insert the char at the proper position */ | 457 | /* insert the char at the proper position */ |
485 | memmove(&result[cursor_position+1], | 458 | memmove(&result[cursor_position+1], |
486 | &result[cursor_position], | 459 | &result[cursor_position], |
487 | len-cursor_position+1); | 460 | len+1); |
488 | result[cursor_position] = res; | 461 | result[cursor_position] = res; |
489 | cursor_position++; | 462 | cursor_position++; |
490 | cursor_form_win++; | ||
491 | len++; | ||
492 | } else { | 463 | } else { |
493 | mvprintw(0, 0, "unknown key: %d\n", res); | 464 | mvprintw(0, 0, "unknow key: %d\n", res); |
494 | } | 465 | } |
495 | break; | 466 | break; |
496 | } | 467 | } |
497 | if (cursor_form_win < 0) | ||
498 | cursor_form_win = 0; | ||
499 | else if (cursor_form_win > prompt_width-1) | ||
500 | cursor_form_win = prompt_width-1; | ||
501 | |||
502 | wmove(form_win, 0, 0); | 468 | wmove(form_win, 0, 0); |
503 | wclrtoeol(form_win); | 469 | wclrtoeol(form_win); |
504 | mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); | 470 | mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); |
505 | mvwprintw(form_win, 0, 0, "%s", | 471 | mvwprintw(form_win, 0, 0, "%s", result); |
506 | result + cursor_position-cursor_form_win); | 472 | wmove(form_win, 0, cursor_position); |
507 | wmove(form_win, 0, cursor_form_win); | ||
508 | touchwin(win); | 473 | touchwin(win); |
509 | refresh_all_windows(main_window); | 474 | refresh_all_windows(main_window); |
510 | 475 | ||
@@ -604,11 +569,9 @@ void show_scroll_win(WINDOW *main_window, | |||
604 | switch (res) { | 569 | switch (res) { |
605 | case KEY_NPAGE: | 570 | case KEY_NPAGE: |
606 | case ' ': | 571 | case ' ': |
607 | case 'd': | ||
608 | start_y += text_lines-2; | 572 | start_y += text_lines-2; |
609 | break; | 573 | break; |
610 | case KEY_PPAGE: | 574 | case KEY_PPAGE: |
611 | case 'u': | ||
612 | start_y -= text_lines+2; | 575 | start_y -= text_lines+2; |
613 | break; | 576 | break; |
614 | case KEY_HOME: | 577 | case KEY_HOME: |
@@ -634,10 +597,10 @@ void show_scroll_win(WINDOW *main_window, | |||
634 | start_x++; | 597 | start_x++; |
635 | break; | 598 | break; |
636 | } | 599 | } |
637 | if (res == 10 || res == 27 || res == 'q' || | 600 | if (res == 10 || res == 27 || res == 'q' |
638 | res == KEY_F(F_HELP) || res == KEY_F(F_BACK) || | 601 | || res == KEY_F(F_BACK) || res == KEY_F(F_EXIT)) { |
639 | res == KEY_F(F_EXIT)) | ||
640 | break; | 602 | break; |
603 | } | ||
641 | if (start_y < 0) | 604 | if (start_y < 0) |
642 | start_y = 0; | 605 | start_y = 0; |
643 | if (start_y >= total_lines-text_lines) | 606 | if (start_y >= total_lines-text_lines) |
diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h index 0d5261705ef..58fbda8fc0d 100644 --- a/scripts/kconfig/nconf.h +++ b/scripts/kconfig/nconf.h | |||
@@ -89,7 +89,7 @@ void fill_window(WINDOW *win, const char *text); | |||
89 | int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); | 89 | int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); |
90 | int dialog_inputbox(WINDOW *main_window, | 90 | int dialog_inputbox(WINDOW *main_window, |
91 | const char *title, const char *prompt, | 91 | const char *title, const char *prompt, |
92 | const char *init, char **resultp, int *result_len); | 92 | const char *init, char *result, int result_len); |
93 | void refresh_all_windows(WINDOW *main_window); | 93 | void refresh_all_windows(WINDOW *main_window); |
94 | void show_scroll_win(WINDOW *main_window, | 94 | void show_scroll_win(WINDOW *main_window, |
95 | const char *title, | 95 | const char *title, |
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 33689396953..a4fe923c013 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
@@ -43,17 +43,6 @@ | |||
43 | # make oldconfig | 43 | # make oldconfig |
44 | # | 44 | # |
45 | use strict; | 45 | use strict; |
46 | use Getopt::Long; | ||
47 | |||
48 | # set the environment variable LOCALMODCONFIG_DEBUG to get | ||
49 | # debug output. | ||
50 | my $debugprint = 0; | ||
51 | $debugprint = 1 if (defined($ENV{LOCALMODCONFIG_DEBUG})); | ||
52 | |||
53 | sub dprint { | ||
54 | return if (!$debugprint); | ||
55 | print STDERR @_; | ||
56 | } | ||
57 | 46 | ||
58 | my $config = ".config"; | 47 | my $config = ".config"; |
59 | 48 | ||
@@ -100,7 +89,7 @@ my @searchconfigs = ( | |||
100 | }, | 89 | }, |
101 | ); | 90 | ); |
102 | 91 | ||
103 | sub read_config { | 92 | sub find_config { |
104 | foreach my $conf (@searchconfigs) { | 93 | foreach my $conf (@searchconfigs) { |
105 | my $file = $conf->{"file"}; | 94 | my $file = $conf->{"file"}; |
106 | 95 | ||
@@ -115,27 +104,18 @@ sub read_config { | |||
115 | 104 | ||
116 | print STDERR "using config: '$file'\n"; | 105 | print STDERR "using config: '$file'\n"; |
117 | 106 | ||
118 | open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file"; | 107 | open(CIN, "$exec $file |") || die "Failed to run $exec $file"; |
119 | my @x = <$infile>; | 108 | return; |
120 | close $infile; | ||
121 | return @x; | ||
122 | } | 109 | } |
123 | die "No config file found"; | 110 | die "No config file found"; |
124 | } | 111 | } |
125 | 112 | ||
126 | my @config_file = read_config; | 113 | find_config; |
127 | |||
128 | # Parse options | ||
129 | my $localmodconfig = 0; | ||
130 | my $localyesconfig = 0; | ||
131 | |||
132 | GetOptions("localmodconfig" => \$localmodconfig, | ||
133 | "localyesconfig" => \$localyesconfig); | ||
134 | 114 | ||
135 | # Get the build source and top level Kconfig file (passed in) | 115 | # Get the build source and top level Kconfig file (passed in) |
136 | my $ksource = ($ARGV[0] ? $ARGV[0] : '.'); | 116 | my $ksource = $ARGV[0]; |
137 | my $kconfig = $ARGV[1]; | 117 | my $kconfig = $ARGV[1]; |
138 | my $lsmod_file = $ENV{'LSMOD'}; | 118 | my $lsmod_file = $ARGV[2]; |
139 | 119 | ||
140 | my @makefiles = `find $ksource -name Makefile 2>/dev/null`; | 120 | my @makefiles = `find $ksource -name Makefile 2>/dev/null`; |
141 | chomp @makefiles; | 121 | chomp @makefiles; |
@@ -171,8 +151,8 @@ sub read_kconfig { | |||
171 | $source =~ s/\$$env/$ENV{$env}/; | 151 | $source =~ s/\$$env/$ENV{$env}/; |
172 | } | 152 | } |
173 | 153 | ||
174 | open(my $kinfile, '<', $source) || die "Can't open $kconfig"; | 154 | open(KIN, "$source") || die "Can't open $kconfig"; |
175 | while (<$kinfile>) { | 155 | while (<KIN>) { |
176 | chomp; | 156 | chomp; |
177 | 157 | ||
178 | # Make sure that lines ending with \ continue | 158 | # Make sure that lines ending with \ continue |
@@ -198,7 +178,6 @@ sub read_kconfig { | |||
198 | $state = "NEW"; | 178 | $state = "NEW"; |
199 | $config = $2; | 179 | $config = $2; |
200 | 180 | ||
201 | # Add depends for 'if' nesting | ||
202 | for (my $i = 0; $i < $iflevel; $i++) { | 181 | for (my $i = 0; $i < $iflevel; $i++) { |
203 | if ($i) { | 182 | if ($i) { |
204 | $depends{$config} .= " " . $ifdeps[$i]; | 183 | $depends{$config} .= " " . $ifdeps[$i]; |
@@ -217,11 +196,10 @@ sub read_kconfig { | |||
217 | 196 | ||
218 | # Get the configs that select this config | 197 | # Get the configs that select this config |
219 | } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) { | 198 | } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) { |
220 | my $conf = $1; | 199 | if (defined($selects{$1})) { |
221 | if (defined($selects{$conf})) { | 200 | $selects{$1} .= " " . $config; |
222 | $selects{$conf} .= " " . $config; | ||
223 | } else { | 201 | } else { |
224 | $selects{$conf} = $config; | 202 | $selects{$1} = $config; |
225 | } | 203 | } |
226 | 204 | ||
227 | # configs without prompts must be selected | 205 | # configs without prompts must be selected |
@@ -249,10 +227,10 @@ sub read_kconfig { | |||
249 | $state = "NONE"; | 227 | $state = "NONE"; |
250 | } | 228 | } |
251 | } | 229 | } |
252 | close($kinfile); | 230 | close(KIN); |
253 | 231 | ||
254 | # read in any configs that were found. | 232 | # read in any configs that were found. |
255 | foreach my $kconfig (@kconfigs) { | 233 | foreach $kconfig (@kconfigs) { |
256 | if (!defined($read_kconfigs{$kconfig})) { | 234 | if (!defined($read_kconfigs{$kconfig})) { |
257 | $read_kconfigs{$kconfig} = 1; | 235 | $read_kconfigs{$kconfig} = 1; |
258 | read_kconfig($kconfig); | 236 | read_kconfig($kconfig); |
@@ -264,63 +242,33 @@ if ($kconfig) { | |||
264 | read_kconfig($kconfig); | 242 | read_kconfig($kconfig); |
265 | } | 243 | } |
266 | 244 | ||
267 | # Makefiles can use variables to define their dependencies | ||
268 | sub convert_vars { | ||
269 | my ($line, %vars) = @_; | ||
270 | |||
271 | my $process = ""; | ||
272 | |||
273 | while ($line =~ s/^(.*?)(\$\((.*?)\))//) { | ||
274 | my $start = $1; | ||
275 | my $variable = $2; | ||
276 | my $var = $3; | ||
277 | |||
278 | if (defined($vars{$var})) { | ||
279 | $process .= $start . $vars{$var}; | ||
280 | } else { | ||
281 | $process .= $start . $variable; | ||
282 | } | ||
283 | } | ||
284 | |||
285 | $process .= $line; | ||
286 | |||
287 | return $process; | ||
288 | } | ||
289 | |||
290 | # Read all Makefiles to map the configs to the objects | 245 | # Read all Makefiles to map the configs to the objects |
291 | foreach my $makefile (@makefiles) { | 246 | foreach my $makefile (@makefiles) { |
292 | 247 | ||
293 | my $line = ""; | 248 | my $cont = 0; |
294 | my %make_vars; | ||
295 | |||
296 | open(my $infile, '<', $makefile) || die "Can't open $makefile"; | ||
297 | while (<$infile>) { | ||
298 | # if this line ends with a backslash, continue | ||
299 | chomp; | ||
300 | if (/^(.*)\\$/) { | ||
301 | $line .= $1; | ||
302 | next; | ||
303 | } | ||
304 | |||
305 | $line .= $_; | ||
306 | $_ = $line; | ||
307 | $line = ""; | ||
308 | 249 | ||
250 | open(MIN,$makefile) || die "Can't open $makefile"; | ||
251 | while (<MIN>) { | ||
309 | my $objs; | 252 | my $objs; |
310 | 253 | ||
311 | # Convert variables in a line (could define configs) | 254 | # is this a line after a line with a backslash? |
312 | $_ = convert_vars($_, %make_vars); | 255 | if ($cont && /(\S.*)$/) { |
256 | $objs = $1; | ||
257 | } | ||
258 | $cont = 0; | ||
313 | 259 | ||
314 | # collect objects after obj-$(CONFIG_FOO_BAR) | 260 | # collect objects after obj-$(CONFIG_FOO_BAR) |
315 | if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { | 261 | if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { |
316 | $var = $1; | 262 | $var = $1; |
317 | $objs = $2; | 263 | $objs = $2; |
318 | |||
319 | # check if variables are set | ||
320 | } elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) { | ||
321 | $make_vars{$1} = $2; | ||
322 | } | 264 | } |
323 | if (defined($objs)) { | 265 | if (defined($objs)) { |
266 | # test if the line ends with a backslash | ||
267 | if ($objs =~ m,(.*)\\$,) { | ||
268 | $objs = $1; | ||
269 | $cont = 1; | ||
270 | } | ||
271 | |||
324 | foreach my $obj (split /\s+/,$objs) { | 272 | foreach my $obj (split /\s+/,$objs) { |
325 | $obj =~ s/-/_/g; | 273 | $obj =~ s/-/_/g; |
326 | if ($obj =~ /(.*)\.o$/) { | 274 | if ($obj =~ /(.*)\.o$/) { |
@@ -341,24 +289,22 @@ foreach my $makefile (@makefiles) { | |||
341 | } | 289 | } |
342 | } | 290 | } |
343 | } | 291 | } |
344 | close($infile); | 292 | close(MIN); |
345 | } | 293 | } |
346 | 294 | ||
347 | my %modules; | 295 | my %modules; |
348 | my $linfile; | ||
349 | 296 | ||
350 | if (defined($lsmod_file)) { | 297 | if (defined($lsmod_file)) { |
351 | if ( ! -f $lsmod_file) { | 298 | if ( ! -f $lsmod_file) { |
352 | if ( -f $ENV{'objtree'}."/".$lsmod_file) { | 299 | die "$lsmod_file not found"; |
353 | $lsmod_file = $ENV{'objtree'}."/".$lsmod_file; | 300 | } |
354 | } else { | 301 | if ( -x $lsmod_file) { |
355 | die "$lsmod_file not found"; | 302 | # the file is executable, run it |
356 | } | 303 | open(LIN, "$lsmod_file|"); |
304 | } else { | ||
305 | # Just read the contents | ||
306 | open(LIN, "$lsmod_file"); | ||
357 | } | 307 | } |
358 | |||
359 | my $otype = ( -x $lsmod_file) ? '-|' : '<'; | ||
360 | open($linfile, $otype, $lsmod_file); | ||
361 | |||
362 | } else { | 308 | } else { |
363 | 309 | ||
364 | # see what modules are loaded on this system | 310 | # see what modules are loaded on this system |
@@ -375,27 +321,25 @@ if (defined($lsmod_file)) { | |||
375 | $lsmod = "lsmod"; | 321 | $lsmod = "lsmod"; |
376 | } | 322 | } |
377 | 323 | ||
378 | open($linfile, '-|', $lsmod) || die "Can not call lsmod with $lsmod"; | 324 | open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod"; |
379 | } | 325 | } |
380 | 326 | ||
381 | while (<$linfile>) { | 327 | while (<LIN>) { |
382 | next if (/^Module/); # Skip the first line. | 328 | next if (/^Module/); # Skip the first line. |
383 | if (/^(\S+)/) { | 329 | if (/^(\S+)/) { |
384 | $modules{$1} = 1; | 330 | $modules{$1} = 1; |
385 | } | 331 | } |
386 | } | 332 | } |
387 | close ($linfile); | 333 | close (LIN); |
388 | 334 | ||
389 | # add to the configs hash all configs that are needed to enable | 335 | # add to the configs hash all configs that are needed to enable |
390 | # a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o | 336 | # a loaded module. |
391 | # where we know we need bar.o so we add FOO to the list. | ||
392 | my %configs; | 337 | my %configs; |
393 | foreach my $module (keys(%modules)) { | 338 | foreach my $module (keys(%modules)) { |
394 | if (defined($objects{$module})) { | 339 | if (defined($objects{$module})) { |
395 | my @arr = @{$objects{$module}}; | 340 | my @arr = @{$objects{$module}}; |
396 | foreach my $conf (@arr) { | 341 | foreach my $conf (@arr) { |
397 | $configs{$conf} = $module; | 342 | $configs{$conf} = $module; |
398 | dprint "$conf added by direct ($module)\n"; | ||
399 | } | 343 | } |
400 | } else { | 344 | } else { |
401 | # Most likely, someone has a custom (binary?) module loaded. | 345 | # Most likely, someone has a custom (binary?) module loaded. |
@@ -403,24 +347,9 @@ foreach my $module (keys(%modules)) { | |||
403 | } | 347 | } |
404 | } | 348 | } |
405 | 349 | ||
406 | # Read the current config, and see what is enabled. We want to | ||
407 | # ignore configs that we would not enable anyway. | ||
408 | |||
409 | my %orig_configs; | ||
410 | my $valid = "A-Za-z_0-9"; | 350 | my $valid = "A-Za-z_0-9"; |
411 | |||
412 | foreach my $line (@config_file) { | ||
413 | $_ = $line; | ||
414 | |||
415 | if (/(CONFIG_[$valid]*)=(m|y)/) { | ||
416 | $orig_configs{$1} = $2; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | my $repeat = 1; | 351 | my $repeat = 1; |
421 | 352 | ||
422 | my $depconfig; | ||
423 | |||
424 | # | 353 | # |
425 | # Note, we do not care about operands (like: &&, ||, !) we want to add any | 354 | # Note, we do not care about operands (like: &&, ||, !) we want to add any |
426 | # config that is in the depend list of another config. This script does | 355 | # config that is in the depend list of another config. This script does |
@@ -429,7 +358,7 @@ my $depconfig; | |||
429 | # to keep on. If A was on in the original config, B would not have been | 358 | # to keep on. If A was on in the original config, B would not have been |
430 | # and B would not be turned on by this script. | 359 | # and B would not be turned on by this script. |
431 | # | 360 | # |
432 | sub parse_config_depends | 361 | sub parse_config_dep_select |
433 | { | 362 | { |
434 | my ($p) = @_; | 363 | my ($p) = @_; |
435 | 364 | ||
@@ -440,16 +369,10 @@ sub parse_config_depends | |||
440 | 369 | ||
441 | $p =~ s/^[^$valid]*[$valid]+//; | 370 | $p =~ s/^[^$valid]*[$valid]+//; |
442 | 371 | ||
443 | # We only need to process if the depend config is a module | ||
444 | if (!defined($orig_configs{$conf}) || !$orig_configs{conf} eq "m") { | ||
445 | next; | ||
446 | } | ||
447 | |||
448 | if (!defined($configs{$conf})) { | 372 | if (!defined($configs{$conf})) { |
449 | # We must make sure that this config has its | 373 | # We must make sure that this config has its |
450 | # dependencies met. | 374 | # dependencies met. |
451 | $repeat = 1; # do again | 375 | $repeat = 1; # do again |
452 | dprint "$conf selected by depend $depconfig\n"; | ||
453 | $configs{$conf} = 1; | 376 | $configs{$conf} = 1; |
454 | } | 377 | } |
455 | } else { | 378 | } else { |
@@ -458,132 +381,31 @@ sub parse_config_depends | |||
458 | } | 381 | } |
459 | } | 382 | } |
460 | 383 | ||
461 | # Select is treated a bit differently than depends. We call this | 384 | while ($repeat) { |
462 | # when a config has no prompt and requires another config to be | 385 | $repeat = 0; |
463 | # selected. We use to just select all configs that selected this | ||
464 | # config, but found that that can balloon into enabling hundreds | ||
465 | # of configs that we do not care about. | ||
466 | # | ||
467 | # The idea is we look at all the configs that select it. If one | ||
468 | # is already in our list of configs to enable, then there's nothing | ||
469 | # else to do. If there isn't, we pick the first config that was | ||
470 | # enabled in the orignal config and use that. | ||
471 | sub parse_config_selects | ||
472 | { | ||
473 | my ($config, $p) = @_; | ||
474 | |||
475 | my $next_config; | ||
476 | |||
477 | while ($p =~ /[$valid]/) { | ||
478 | |||
479 | if ($p =~ /^[^$valid]*([$valid]+)/) { | ||
480 | my $conf = "CONFIG_" . $1; | ||
481 | |||
482 | $p =~ s/^[^$valid]*[$valid]+//; | ||
483 | 386 | ||
484 | # Make sure that this config exists in the current .config file | 387 | foreach my $config (keys %configs) { |
485 | if (!defined($orig_configs{$conf})) { | 388 | $config =~ s/^CONFIG_//; |
486 | dprint "$conf not set for $config select\n"; | ||
487 | next; | ||
488 | } | ||
489 | 389 | ||
490 | # Check if something other than a module selects this config | 390 | if (defined($depends{$config})) { |
491 | if (defined($orig_configs{$conf}) && $orig_configs{$conf} ne "m") { | 391 | # This config has dependencies. Make sure they are also included |
492 | dprint "$conf (non module) selects config, we are good\n"; | 392 | parse_config_dep_select $depends{$config}; |
493 | # we are good with this | ||
494 | return; | ||
495 | } | ||
496 | if (defined($configs{$conf})) { | ||
497 | dprint "$conf selects $config so we are good\n"; | ||
498 | # A set config selects this config, we are good | ||
499 | return; | ||
500 | } | ||
501 | # Set this config to be selected | ||
502 | if (!defined($next_config)) { | ||
503 | $next_config = $conf; | ||
504 | } | ||
505 | } else { | ||
506 | die "this should never happen"; | ||
507 | } | 393 | } |
508 | } | ||
509 | |||
510 | # If no possible config selected this, then something happened. | ||
511 | if (!defined($next_config)) { | ||
512 | print STDERR "WARNING: $config is required, but nothing in the\n"; | ||
513 | print STDERR " current config selects it.\n"; | ||
514 | return; | ||
515 | } | ||
516 | |||
517 | # If we are here, then we found no config that is set and | ||
518 | # selects this config. Repeat. | ||
519 | $repeat = 1; | ||
520 | # Make this config need to be selected | ||
521 | $configs{$next_config} = 1; | ||
522 | dprint "$next_config selected by select $config\n"; | ||
523 | } | ||
524 | |||
525 | my %process_selects; | ||
526 | |||
527 | # loop through all configs, select their dependencies. | ||
528 | sub loop_depend { | ||
529 | $repeat = 1; | ||
530 | 394 | ||
531 | while ($repeat) { | 395 | if (defined($prompts{$config}) || !defined($selects{$config})) { |
532 | $repeat = 0; | 396 | next; |
533 | |||
534 | forloop: | ||
535 | foreach my $config (keys %configs) { | ||
536 | |||
537 | # If this config is not a module, we do not need to process it | ||
538 | if (defined($orig_configs{$config}) && $orig_configs{$config} ne "m") { | ||
539 | next forloop; | ||
540 | } | ||
541 | |||
542 | $config =~ s/^CONFIG_//; | ||
543 | $depconfig = $config; | ||
544 | |||
545 | if (defined($depends{$config})) { | ||
546 | # This config has dependencies. Make sure they are also included | ||
547 | parse_config_depends $depends{$config}; | ||
548 | } | ||
549 | |||
550 | # If the config has no prompt, then we need to check if a config | ||
551 | # that is enabled selected it. Or if we need to enable one. | ||
552 | if (!defined($prompts{$config}) && defined($selects{$config})) { | ||
553 | $process_selects{$config} = 1; | ||
554 | } | ||
555 | } | 397 | } |
556 | } | ||
557 | } | ||
558 | |||
559 | sub loop_select { | ||
560 | |||
561 | foreach my $config (keys %process_selects) { | ||
562 | $config =~ s/^CONFIG_//; | ||
563 | |||
564 | dprint "Process select $config\n"; | ||
565 | 398 | ||
566 | # config has no prompt and must be selected. | 399 | # config has no prompt and must be selected. |
567 | parse_config_selects $config, $selects{$config}; | 400 | parse_config_dep_select $selects{$config}; |
568 | } | 401 | } |
569 | } | 402 | } |
570 | 403 | ||
571 | while ($repeat) { | ||
572 | # Get the first set of configs and their dependencies. | ||
573 | loop_depend; | ||
574 | |||
575 | $repeat = 0; | ||
576 | |||
577 | # Now we need to see if we have to check selects; | ||
578 | loop_select; | ||
579 | } | ||
580 | |||
581 | my %setconfigs; | 404 | my %setconfigs; |
582 | 405 | ||
583 | # Finally, read the .config file and turn off any module enabled that | 406 | # Finally, read the .config file and turn off any module enabled that |
584 | # we could not find a reason to keep enabled. | 407 | # we could not find a reason to keep enabled. |
585 | foreach my $line (@config_file) { | 408 | while(<CIN>) { |
586 | $_ = $line; | ||
587 | 409 | ||
588 | if (/CONFIG_IKCONFIG/) { | 410 | if (/CONFIG_IKCONFIG/) { |
589 | if (/# CONFIG_IKCONFIG is not set/) { | 411 | if (/# CONFIG_IKCONFIG is not set/) { |
@@ -599,13 +421,7 @@ foreach my $line (@config_file) { | |||
599 | 421 | ||
600 | if (/^(CONFIG.*)=(m|y)/) { | 422 | if (/^(CONFIG.*)=(m|y)/) { |
601 | if (defined($configs{$1})) { | 423 | if (defined($configs{$1})) { |
602 | if ($localyesconfig) { | 424 | $setconfigs{$1} = $2; |
603 | $setconfigs{$1} = 'y'; | ||
604 | print "$1=y\n"; | ||
605 | next; | ||
606 | } else { | ||
607 | $setconfigs{$1} = $2; | ||
608 | } | ||
609 | } elsif ($2 eq "m") { | 425 | } elsif ($2 eq "m") { |
610 | print "# $1 is not set\n"; | 426 | print "# $1 is not set\n"; |
611 | next; | 427 | next; |
@@ -613,6 +429,7 @@ foreach my $line (@config_file) { | |||
613 | } | 429 | } |
614 | print; | 430 | print; |
615 | } | 431 | } |
432 | close(CIN); | ||
616 | 433 | ||
617 | # Integrity check, make sure all modules that we want enabled do | 434 | # Integrity check, make sure all modules that we want enabled do |
618 | # indeed have their configs set. | 435 | # indeed have their configs set. |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 22a3c400fc4..071f00c3046 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -262,18 +262,11 @@ static struct symbol *sym_calc_choice(struct symbol *sym) | |||
262 | struct symbol *def_sym; | 262 | struct symbol *def_sym; |
263 | struct property *prop; | 263 | struct property *prop; |
264 | struct expr *e; | 264 | struct expr *e; |
265 | int flags; | ||
266 | 265 | ||
267 | /* first calculate all choice values' visibilities */ | 266 | /* first calculate all choice values' visibilities */ |
268 | flags = sym->flags; | ||
269 | prop = sym_get_choice_prop(sym); | 267 | prop = sym_get_choice_prop(sym); |
270 | expr_list_for_each_sym(prop->expr, e, def_sym) { | 268 | expr_list_for_each_sym(prop->expr, e, def_sym) |
271 | sym_calc_visibility(def_sym); | 269 | sym_calc_visibility(def_sym); |
272 | if (def_sym->visible != no) | ||
273 | flags &= def_sym->flags; | ||
274 | } | ||
275 | |||
276 | sym->flags &= flags | ~SYMBOL_DEF_USER; | ||
277 | 270 | ||
278 | /* is the user choice visible? */ | 271 | /* is the user choice visible? */ |
279 | def_sym = sym->def[S_DEF_USER].val; | 272 | def_sym = sym->def[S_DEF_USER].val; |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index f565536a2be..d793001929c 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -5,8 +5,7 @@ use strict; | |||
5 | ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## | 5 | ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## |
6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## | 6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## |
7 | ## Copyright (C) 2001 Simon Huggins ## | 7 | ## Copyright (C) 2001 Simon Huggins ## |
8 | ## Copyright (C) 2005-2012 Randy Dunlap ## | 8 | ## Copyright (C) 2005-2010 Randy Dunlap ## |
9 | ## Copyright (C) 2012 Dan Luedtke ## | ||
10 | ## ## | 9 | ## ## |
11 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## | 10 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## |
12 | ## Copyright (c) 2000 MontaVista Software, Inc. ## | 11 | ## Copyright (c) 2000 MontaVista Software, Inc. ## |
@@ -36,8 +35,6 @@ use strict; | |||
36 | # Small fixes (like spaces vs. \s in regex) | 35 | # Small fixes (like spaces vs. \s in regex) |
37 | # -- Tim Jansen <tim@tjansen.de> | 36 | # -- Tim Jansen <tim@tjansen.de> |
38 | 37 | ||
39 | # 25/07/2012 - Added support for HTML5 | ||
40 | # -- Dan Luedtke <mail@danrl.de> | ||
41 | 38 | ||
42 | # | 39 | # |
43 | # This will read a 'c' file and scan for embedded comments in the | 40 | # This will read a 'c' file and scan for embedded comments in the |
@@ -47,16 +44,12 @@ use strict; | |||
47 | # Note: This only supports 'c'. | 44 | # Note: This only supports 'c'. |
48 | 45 | ||
49 | # usage: | 46 | # usage: |
50 | # kernel-doc [ -docbook | -html | -html5 | -text | -man | -list ] | 47 | # kernel-doc [ -docbook | -html | -text | -man | -list ] [ -no-doc-sections ] |
51 | # [ -no-doc-sections ] | 48 | # [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile |
52 | # [ -function funcname [ -function funcname ...] ] | ||
53 | # c file(s)s > outputfile | ||
54 | # or | 49 | # or |
55 | # [ -nofunction funcname [ -function funcname ...] ] | 50 | # [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile |
56 | # c file(s)s > outputfile | ||
57 | # | 51 | # |
58 | # Set output format using one of -docbook -html -html5 -text or -man. | 52 | # Set output format using one of -docbook -html -text or -man. Default is man. |
59 | # Default is man. | ||
60 | # The -list format is for internal use by docproc. | 53 | # The -list format is for internal use by docproc. |
61 | # | 54 | # |
62 | # -no-doc-sections | 55 | # -no-doc-sections |
@@ -137,8 +130,6 @@ use strict; | |||
137 | # should document the "Context:" of the function, e.g. whether the functions | 130 | # should document the "Context:" of the function, e.g. whether the functions |
138 | # can be called form interrupts. Unlike other sections you can end it with an | 131 | # can be called form interrupts. Unlike other sections you can end it with an |
139 | # empty line. | 132 | # empty line. |
140 | # A non-void function should have a "Return:" section describing the return | ||
141 | # value(s). | ||
142 | # Example-sections should contain the string EXAMPLE so that they are marked | 133 | # Example-sections should contain the string EXAMPLE so that they are marked |
143 | # appropriately in DocBook. | 134 | # appropriately in DocBook. |
144 | # | 135 | # |
@@ -191,14 +182,6 @@ my $local_lt = "\\\\\\\\lt:"; | |||
191 | my $local_gt = "\\\\\\\\gt:"; | 182 | my $local_gt = "\\\\\\\\gt:"; |
192 | my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" | 183 | my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" |
193 | 184 | ||
194 | # html version 5 | ||
195 | my %highlights_html5 = ( $type_constant, "<span class=\"const\">\$1</span>", | ||
196 | $type_func, "<span class=\"func\">\$1</span>", | ||
197 | $type_struct_xml, "<span class=\"struct\">\$1</span>", | ||
198 | $type_env, "<span class=\"env\">\$1</span>", | ||
199 | $type_param, "<span class=\"param\">\$1</span>" ); | ||
200 | my $blankline_html5 = $local_lt . "br /" . $local_gt; | ||
201 | |||
202 | # XML, docbook format | 185 | # XML, docbook format |
203 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", | 186 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", |
204 | $type_constant, "<constant>\$1</constant>", | 187 | $type_constant, "<constant>\$1</constant>", |
@@ -247,7 +230,6 @@ my $dohighlight = ""; | |||
247 | 230 | ||
248 | my $verbose = 0; | 231 | my $verbose = 0; |
249 | my $output_mode = "man"; | 232 | my $output_mode = "man"; |
250 | my $output_preformatted = 0; | ||
251 | my $no_doc_sections = 0; | 233 | my $no_doc_sections = 0; |
252 | my %highlights = %highlights_man; | 234 | my %highlights = %highlights_man; |
253 | my $blankline = $blankline_man; | 235 | my $blankline = $blankline_man; |
@@ -298,10 +280,9 @@ my $doc_special = "\@\%\$\&"; | |||
298 | my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start. | 280 | my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start. |
299 | my $doc_end = '\*/'; | 281 | my $doc_end = '\*/'; |
300 | my $doc_com = '\s*\*\s*'; | 282 | my $doc_com = '\s*\*\s*'; |
301 | my $doc_com_body = '\s*\* ?'; | ||
302 | my $doc_decl = $doc_com . '(\w+)'; | 283 | my $doc_decl = $doc_com . '(\w+)'; |
303 | my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)'; | 284 | my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)'; |
304 | my $doc_content = $doc_com_body . '(.*)'; | 285 | my $doc_content = $doc_com . '(.*)'; |
305 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; | 286 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; |
306 | 287 | ||
307 | my %constants; | 288 | my %constants; |
@@ -317,7 +298,6 @@ my $section_default = "Description"; # default section | |||
317 | my $section_intro = "Introduction"; | 298 | my $section_intro = "Introduction"; |
318 | my $section = $section_default; | 299 | my $section = $section_default; |
319 | my $section_context = "Context"; | 300 | my $section_context = "Context"; |
320 | my $section_return = "Return"; | ||
321 | 301 | ||
322 | my $undescribed = "-- undescribed --"; | 302 | my $undescribed = "-- undescribed --"; |
323 | 303 | ||
@@ -329,10 +309,6 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
329 | $output_mode = "html"; | 309 | $output_mode = "html"; |
330 | %highlights = %highlights_html; | 310 | %highlights = %highlights_html; |
331 | $blankline = $blankline_html; | 311 | $blankline = $blankline_html; |
332 | } elsif ($cmd eq "-html5") { | ||
333 | $output_mode = "html5"; | ||
334 | %highlights = %highlights_html5; | ||
335 | $blankline = $blankline_html5; | ||
336 | } elsif ($cmd eq "-man") { | 312 | } elsif ($cmd eq "-man") { |
337 | $output_mode = "man"; | 313 | $output_mode = "man"; |
338 | %highlights = %highlights_man; | 314 | %highlights = %highlights_man; |
@@ -375,11 +351,10 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
375 | # continue execution near EOF; | 351 | # continue execution near EOF; |
376 | 352 | ||
377 | sub usage { | 353 | sub usage { |
378 | print "Usage: $0 [ -docbook | -html | -html5 | -text | -man | -list ]\n"; | 354 | print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -list ]\n"; |
379 | print " [ -no-doc-sections ]\n"; | 355 | print " [ -no-doc-sections ]\n"; |
380 | print " [ -function funcname [ -function funcname ...] ]\n"; | 356 | print " [ -function funcname [ -function funcname ...] ]\n"; |
381 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; | 357 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; |
382 | print " [ -v ]\n"; | ||
383 | print " c source file(s) > outputfile\n"; | 358 | print " c source file(s) > outputfile\n"; |
384 | print " -v : verbose output, more warnings & other info listed\n"; | 359 | print " -v : verbose output, more warnings & other info listed\n"; |
385 | exit 1; | 360 | exit 1; |
@@ -473,8 +448,7 @@ sub output_highlight { | |||
473 | # confess "output_highlight got called with no args?\n"; | 448 | # confess "output_highlight got called with no args?\n"; |
474 | # } | 449 | # } |
475 | 450 | ||
476 | if ($output_mode eq "html" || $output_mode eq "html5" || | 451 | if ($output_mode eq "html" || $output_mode eq "xml") { |
477 | $output_mode eq "xml") { | ||
478 | $contents = local_unescape($contents); | 452 | $contents = local_unescape($contents); |
479 | # convert data read & converted thru xml_escape() into &xyz; format: | 453 | # convert data read & converted thru xml_escape() into &xyz; format: |
480 | $contents =~ s/\\\\\\/\&/g; | 454 | $contents =~ s/\\\\\\/\&/g; |
@@ -484,19 +458,9 @@ sub output_highlight { | |||
484 | die $@ if $@; | 458 | die $@ if $@; |
485 | # print STDERR "contents af:$contents\n"; | 459 | # print STDERR "contents af:$contents\n"; |
486 | 460 | ||
487 | # strip whitespaces when generating html5 | ||
488 | if ($output_mode eq "html5") { | ||
489 | $contents =~ s/^\s+//; | ||
490 | $contents =~ s/\s+$//; | ||
491 | } | ||
492 | foreach $line (split "\n", $contents) { | 461 | foreach $line (split "\n", $contents) { |
493 | if (! $output_preformatted) { | ||
494 | $line =~ s/^\s*//; | ||
495 | } | ||
496 | if ($line eq ""){ | 462 | if ($line eq ""){ |
497 | if (! $output_preformatted) { | 463 | print $lineprefix, local_unescape($blankline); |
498 | print $lineprefix, local_unescape($blankline); | ||
499 | } | ||
500 | } else { | 464 | } else { |
501 | $line =~ s/\\\\\\/\&/g; | 465 | $line =~ s/\\\\\\/\&/g; |
502 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { | 466 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { |
@@ -509,7 +473,7 @@ sub output_highlight { | |||
509 | } | 473 | } |
510 | } | 474 | } |
511 | 475 | ||
512 | # output sections in html | 476 | #output sections in html |
513 | sub output_section_html(%) { | 477 | sub output_section_html(%) { |
514 | my %args = %{$_[0]}; | 478 | my %args = %{$_[0]}; |
515 | my $section; | 479 | my $section; |
@@ -669,239 +633,6 @@ sub output_blockhead_html(%) { | |||
669 | print "<hr>\n"; | 633 | print "<hr>\n"; |
670 | } | 634 | } |
671 | 635 | ||
672 | # output sections in html5 | ||
673 | sub output_section_html5(%) { | ||
674 | my %args = %{$_[0]}; | ||
675 | my $section; | ||
676 | |||
677 | foreach $section (@{$args{'sectionlist'}}) { | ||
678 | print "<section>\n"; | ||
679 | print "<h1>$section</h1>\n"; | ||
680 | print "<p>\n"; | ||
681 | output_highlight($args{'sections'}{$section}); | ||
682 | print "</p>\n"; | ||
683 | print "</section>\n"; | ||
684 | } | ||
685 | } | ||
686 | |||
687 | # output enum in html5 | ||
688 | sub output_enum_html5(%) { | ||
689 | my %args = %{$_[0]}; | ||
690 | my ($parameter); | ||
691 | my $count; | ||
692 | my $html5id; | ||
693 | |||
694 | $html5id = $args{'enum'}; | ||
695 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
696 | print "<article class=\"enum\" id=\"enum:". $html5id . "\">"; | ||
697 | print "<h1>enum " . $args{'enum'} . "</h1>\n"; | ||
698 | print "<ol class=\"code\">\n"; | ||
699 | print "<li>"; | ||
700 | print "<span class=\"keyword\">enum</span> "; | ||
701 | print "<span class=\"identifier\">" . $args{'enum'} . "</span> {"; | ||
702 | print "</li>\n"; | ||
703 | $count = 0; | ||
704 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
705 | print "<li class=\"indent\">"; | ||
706 | print "<span class=\"param\">" . $parameter . "</span>"; | ||
707 | if ($count != $#{$args{'parameterlist'}}) { | ||
708 | $count++; | ||
709 | print ","; | ||
710 | } | ||
711 | print "</li>\n"; | ||
712 | } | ||
713 | print "<li>};</li>\n"; | ||
714 | print "</ol>\n"; | ||
715 | |||
716 | print "<section>\n"; | ||
717 | print "<h1>Constants</h1>\n"; | ||
718 | print "<dl>\n"; | ||
719 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
720 | print "<dt>" . $parameter . "</dt>\n"; | ||
721 | print "<dd>"; | ||
722 | output_highlight($args{'parameterdescs'}{$parameter}); | ||
723 | print "</dd>\n"; | ||
724 | } | ||
725 | print "</dl>\n"; | ||
726 | print "</section>\n"; | ||
727 | output_section_html5(@_); | ||
728 | print "</article>\n"; | ||
729 | } | ||
730 | |||
731 | # output typedef in html5 | ||
732 | sub output_typedef_html5(%) { | ||
733 | my %args = %{$_[0]}; | ||
734 | my ($parameter); | ||
735 | my $count; | ||
736 | my $html5id; | ||
737 | |||
738 | $html5id = $args{'typedef'}; | ||
739 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
740 | print "<article class=\"typedef\" id=\"typedef:" . $html5id . "\">\n"; | ||
741 | print "<h1>typedef " . $args{'typedef'} . "</h1>\n"; | ||
742 | |||
743 | print "<ol class=\"code\">\n"; | ||
744 | print "<li>"; | ||
745 | print "<span class=\"keyword\">typedef</span> "; | ||
746 | print "<span class=\"identifier\">" . $args{'typedef'} . "</span>"; | ||
747 | print "</li>\n"; | ||
748 | print "</ol>\n"; | ||
749 | output_section_html5(@_); | ||
750 | print "</article>\n"; | ||
751 | } | ||
752 | |||
753 | # output struct in html5 | ||
754 | sub output_struct_html5(%) { | ||
755 | my %args = %{$_[0]}; | ||
756 | my ($parameter); | ||
757 | my $html5id; | ||
758 | |||
759 | $html5id = $args{'struct'}; | ||
760 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
761 | print "<article class=\"struct\" id=\"struct:" . $html5id . "\">\n"; | ||
762 | print "<hgroup>\n"; | ||
763 | print "<h1>" . $args{'type'} . " " . $args{'struct'} . "</h1>"; | ||
764 | print "<h2>". $args{'purpose'} . "</h2>\n"; | ||
765 | print "</hgroup>\n"; | ||
766 | print "<ol class=\"code\">\n"; | ||
767 | print "<li>"; | ||
768 | print "<span class=\"type\">" . $args{'type'} . "</span> "; | ||
769 | print "<span class=\"identifier\">" . $args{'struct'} . "</span> {"; | ||
770 | print "</li>\n"; | ||
771 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
772 | print "<li class=\"indent\">"; | ||
773 | if ($parameter =~ /^#/) { | ||
774 | print "<span class=\"param\">" . $parameter ."</span>\n"; | ||
775 | print "</li>\n"; | ||
776 | next; | ||
777 | } | ||
778 | my $parameter_name = $parameter; | ||
779 | $parameter_name =~ s/\[.*//; | ||
780 | |||
781 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
782 | $type = $args{'parametertypes'}{$parameter}; | ||
783 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { | ||
784 | # pointer-to-function | ||
785 | print "<span class=\"type\">$1</span> "; | ||
786 | print "<span class=\"param\">$parameter</span>"; | ||
787 | print "<span class=\"type\">)</span> "; | ||
788 | print "(<span class=\"args\">$2</span>);"; | ||
789 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { | ||
790 | # bitfield | ||
791 | print "<span class=\"type\">$1</span> "; | ||
792 | print "<span class=\"param\">$parameter</span>"; | ||
793 | print "<span class=\"bits\">$2</span>;"; | ||
794 | } else { | ||
795 | print "<span class=\"type\">$type</span> "; | ||
796 | print "<span class=\"param\">$parameter</span>;"; | ||
797 | } | ||
798 | print "</li>\n"; | ||
799 | } | ||
800 | print "<li>};</li>\n"; | ||
801 | print "</ol>\n"; | ||
802 | |||
803 | print "<section>\n"; | ||
804 | print "<h1>Members</h1>\n"; | ||
805 | print "<dl>\n"; | ||
806 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
807 | ($parameter =~ /^#/) && next; | ||
808 | |||
809 | my $parameter_name = $parameter; | ||
810 | $parameter_name =~ s/\[.*//; | ||
811 | |||
812 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
813 | print "<dt>" . $parameter . "</dt>\n"; | ||
814 | print "<dd>"; | ||
815 | output_highlight($args{'parameterdescs'}{$parameter_name}); | ||
816 | print "</dd>\n"; | ||
817 | } | ||
818 | print "</dl>\n"; | ||
819 | print "</section>\n"; | ||
820 | output_section_html5(@_); | ||
821 | print "</article>\n"; | ||
822 | } | ||
823 | |||
824 | # output function in html5 | ||
825 | sub output_function_html5(%) { | ||
826 | my %args = %{$_[0]}; | ||
827 | my ($parameter, $section); | ||
828 | my $count; | ||
829 | my $html5id; | ||
830 | |||
831 | $html5id = $args{'function'}; | ||
832 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
833 | print "<article class=\"function\" id=\"func:". $html5id . "\">\n"; | ||
834 | print "<hgroup>\n"; | ||
835 | print "<h1>" . $args{'function'} . "</h1>"; | ||
836 | print "<h2>" . $args{'purpose'} . "</h2>\n"; | ||
837 | print "</hgroup>\n"; | ||
838 | print "<ol class=\"code\">\n"; | ||
839 | print "<li>"; | ||
840 | print "<span class=\"type\">" . $args{'functiontype'} . "</span> "; | ||
841 | print "<span class=\"identifier\">" . $args{'function'} . "</span> ("; | ||
842 | print "</li>"; | ||
843 | $count = 0; | ||
844 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
845 | print "<li class=\"indent\">"; | ||
846 | $type = $args{'parametertypes'}{$parameter}; | ||
847 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { | ||
848 | # pointer-to-function | ||
849 | print "<span class=\"type\">$1</span> "; | ||
850 | print "<span class=\"param\">$parameter</span>"; | ||
851 | print "<span class=\"type\">)</span> "; | ||
852 | print "(<span class=\"args\">$2</span>)"; | ||
853 | } else { | ||
854 | print "<span class=\"type\">$type</span> "; | ||
855 | print "<span class=\"param\">$parameter</span>"; | ||
856 | } | ||
857 | if ($count != $#{$args{'parameterlist'}}) { | ||
858 | $count++; | ||
859 | print ","; | ||
860 | } | ||
861 | print "</li>\n"; | ||
862 | } | ||
863 | print "<li>)</li>\n"; | ||
864 | print "</ol>\n"; | ||
865 | |||
866 | print "<section>\n"; | ||
867 | print "<h1>Arguments</h1>\n"; | ||
868 | print "<p>\n"; | ||
869 | print "<dl>\n"; | ||
870 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
871 | my $parameter_name = $parameter; | ||
872 | $parameter_name =~ s/\[.*//; | ||
873 | |||
874 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
875 | print "<dt>" . $parameter . "</dt>\n"; | ||
876 | print "<dd>"; | ||
877 | output_highlight($args{'parameterdescs'}{$parameter_name}); | ||
878 | print "</dd>\n"; | ||
879 | } | ||
880 | print "</dl>\n"; | ||
881 | print "</section>\n"; | ||
882 | output_section_html5(@_); | ||
883 | print "</article>\n"; | ||
884 | } | ||
885 | |||
886 | # output DOC: block header in html5 | ||
887 | sub output_blockhead_html5(%) { | ||
888 | my %args = %{$_[0]}; | ||
889 | my ($parameter, $section); | ||
890 | my $count; | ||
891 | my $html5id; | ||
892 | |||
893 | foreach $section (@{$args{'sectionlist'}}) { | ||
894 | $html5id = $section; | ||
895 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
896 | print "<article class=\"doc\" id=\"doc:". $html5id . "\">\n"; | ||
897 | print "<h1>$section</h1>\n"; | ||
898 | print "<p>\n"; | ||
899 | output_highlight($args{'sections'}{$section}); | ||
900 | print "</p>\n"; | ||
901 | } | ||
902 | print "</article>\n"; | ||
903 | } | ||
904 | |||
905 | sub output_section_xml(%) { | 636 | sub output_section_xml(%) { |
906 | my %args = %{$_[0]}; | 637 | my %args = %{$_[0]}; |
907 | my $section; | 638 | my $section; |
@@ -912,12 +643,10 @@ sub output_section_xml(%) { | |||
912 | print "<title>$section</title>\n"; | 643 | print "<title>$section</title>\n"; |
913 | if ($section =~ m/EXAMPLE/i) { | 644 | if ($section =~ m/EXAMPLE/i) { |
914 | print "<informalexample><programlisting>\n"; | 645 | print "<informalexample><programlisting>\n"; |
915 | $output_preformatted = 1; | ||
916 | } else { | 646 | } else { |
917 | print "<para>\n"; | 647 | print "<para>\n"; |
918 | } | 648 | } |
919 | output_highlight($args{'sections'}{$section}); | 649 | output_highlight($args{'sections'}{$section}); |
920 | $output_preformatted = 0; | ||
921 | if ($section =~ m/EXAMPLE/i) { | 650 | if ($section =~ m/EXAMPLE/i) { |
922 | print "</programlisting></informalexample>\n"; | 651 | print "</programlisting></informalexample>\n"; |
923 | } else { | 652 | } else { |
@@ -1220,12 +949,10 @@ sub output_blockhead_xml(%) { | |||
1220 | } | 949 | } |
1221 | if ($section =~ m/EXAMPLE/i) { | 950 | if ($section =~ m/EXAMPLE/i) { |
1222 | print "<example><para>\n"; | 951 | print "<example><para>\n"; |
1223 | $output_preformatted = 1; | ||
1224 | } else { | 952 | } else { |
1225 | print "<para>\n"; | 953 | print "<para>\n"; |
1226 | } | 954 | } |
1227 | output_highlight($args{'sections'}{$section}); | 955 | output_highlight($args{'sections'}{$section}); |
1228 | $output_preformatted = 0; | ||
1229 | if ($section =~ m/EXAMPLE/i) { | 956 | if ($section =~ m/EXAMPLE/i) { |
1230 | print "</para></example>\n"; | 957 | print "</para></example>\n"; |
1231 | } else { | 958 | } else { |
@@ -1301,12 +1028,10 @@ sub output_function_gnome { | |||
1301 | print "<simplesect>\n <title>$section</title>\n"; | 1028 | print "<simplesect>\n <title>$section</title>\n"; |
1302 | if ($section =~ m/EXAMPLE/i) { | 1029 | if ($section =~ m/EXAMPLE/i) { |
1303 | print "<example><programlisting>\n"; | 1030 | print "<example><programlisting>\n"; |
1304 | $output_preformatted = 1; | ||
1305 | } else { | 1031 | } else { |
1306 | } | 1032 | } |
1307 | print "<para>\n"; | 1033 | print "<para>\n"; |
1308 | output_highlight($args{'sections'}{$section}); | 1034 | output_highlight($args{'sections'}{$section}); |
1309 | $output_preformatted = 0; | ||
1310 | print "</para>\n"; | 1035 | print "</para>\n"; |
1311 | if ($section =~ m/EXAMPLE/i) { | 1036 | if ($section =~ m/EXAMPLE/i) { |
1312 | print "</programlisting></example>\n"; | 1037 | print "</programlisting></example>\n"; |
@@ -2042,28 +1767,6 @@ sub check_sections($$$$$$) { | |||
2042 | } | 1767 | } |
2043 | 1768 | ||
2044 | ## | 1769 | ## |
2045 | # Checks the section describing the return value of a function. | ||
2046 | sub check_return_section { | ||
2047 | my $file = shift; | ||
2048 | my $declaration_name = shift; | ||
2049 | my $return_type = shift; | ||
2050 | |||
2051 | # Ignore an empty return type (It's a macro) | ||
2052 | # Ignore functions with a "void" return type. (But don't ignore "void *") | ||
2053 | if (($return_type eq "") || ($return_type =~ /void\s*\w*\s*$/)) { | ||
2054 | return; | ||
2055 | } | ||
2056 | |||
2057 | if (!defined($sections{$section_return}) || | ||
2058 | $sections{$section_return} eq "") { | ||
2059 | print STDERR "Warning(${file}:$.): " . | ||
2060 | "No description found for return value of " . | ||
2061 | "'$declaration_name'\n"; | ||
2062 | ++$warnings; | ||
2063 | } | ||
2064 | } | ||
2065 | |||
2066 | ## | ||
2067 | # takes a function prototype and the name of the current file being | 1770 | # takes a function prototype and the name of the current file being |
2068 | # processed and spits out all the details stored in the global | 1771 | # processed and spits out all the details stored in the global |
2069 | # arrays/hashes. | 1772 | # arrays/hashes. |
@@ -2079,10 +1782,9 @@ sub dump_function($$) { | |||
2079 | $prototype =~ s/^__inline +//; | 1782 | $prototype =~ s/^__inline +//; |
2080 | $prototype =~ s/^__always_inline +//; | 1783 | $prototype =~ s/^__always_inline +//; |
2081 | $prototype =~ s/^noinline +//; | 1784 | $prototype =~ s/^noinline +//; |
1785 | $prototype =~ s/__devinit +//; | ||
2082 | $prototype =~ s/__init +//; | 1786 | $prototype =~ s/__init +//; |
2083 | $prototype =~ s/__init_or_module +//; | 1787 | $prototype =~ s/__init_or_module +//; |
2084 | $prototype =~ s/__must_check +//; | ||
2085 | $prototype =~ s/__weak +//; | ||
2086 | $prototype =~ s/^#\s*define\s+//; #ak added | 1788 | $prototype =~ s/^#\s*define\s+//; #ak added |
2087 | $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; | 1789 | $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; |
2088 | 1790 | ||
@@ -2133,15 +1835,6 @@ sub dump_function($$) { | |||
2133 | my $prms = join " ", @parameterlist; | 1835 | my $prms = join " ", @parameterlist; |
2134 | check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); | 1836 | check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); |
2135 | 1837 | ||
2136 | # This check emits a lot of warnings at the moment, because many | ||
2137 | # functions don't have a 'Return' doc section. So until the number | ||
2138 | # of warnings goes sufficiently down, the check is only performed in | ||
2139 | # verbose mode. | ||
2140 | # TODO: always perform the check. | ||
2141 | if ($verbose) { | ||
2142 | check_return_section($file, $declaration_name, $return_type); | ||
2143 | } | ||
2144 | |||
2145 | output_declaration($declaration_name, | 1838 | output_declaration($declaration_name, |
2146 | 'function', | 1839 | 'function', |
2147 | {'function' => $declaration_name, | 1840 | {'function' => $declaration_name, |
@@ -2351,9 +2044,6 @@ sub process_file($) { | |||
2351 | 2044 | ||
2352 | $section_counter = 0; | 2045 | $section_counter = 0; |
2353 | while (<IN>) { | 2046 | while (<IN>) { |
2354 | while (s/\\\s*$//) { | ||
2355 | $_ .= <IN>; | ||
2356 | } | ||
2357 | if ($state == 0) { | 2047 | if ($state == 0) { |
2358 | if (/$doc_start/o) { | 2048 | if (/$doc_start/o) { |
2359 | $state = 1; # next line is always the function name | 2049 | $state = 1; # next line is always the function name |
@@ -2381,7 +2071,7 @@ sub process_file($) { | |||
2381 | $descr= $1; | 2071 | $descr= $1; |
2382 | $descr =~ s/^\s*//; | 2072 | $descr =~ s/^\s*//; |
2383 | $descr =~ s/\s*$//; | 2073 | $descr =~ s/\s*$//; |
2384 | $descr =~ s/\s+/ /g; | 2074 | $descr =~ s/\s+/ /; |
2385 | $declaration_purpose = xml_escape($descr); | 2075 | $declaration_purpose = xml_escape($descr); |
2386 | $in_purpose = 1; | 2076 | $in_purpose = 1; |
2387 | } else { | 2077 | } else { |
@@ -2473,7 +2163,6 @@ sub process_file($) { | |||
2473 | # Continued declaration purpose | 2163 | # Continued declaration purpose |
2474 | chomp($declaration_purpose); | 2164 | chomp($declaration_purpose); |
2475 | $declaration_purpose .= " " . xml_escape($1); | 2165 | $declaration_purpose .= " " . xml_escape($1); |
2476 | $declaration_purpose =~ s/\s+/ /g; | ||
2477 | } else { | 2166 | } else { |
2478 | $contents .= $1 . "\n"; | 2167 | $contents .= $1 . "\n"; |
2479 | } | 2168 | } |
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh deleted file mode 100644 index b3d907eb93a..00000000000 --- a/scripts/link-vmlinux.sh +++ /dev/null | |||
@@ -1,226 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # link vmlinux | ||
4 | # | ||
5 | # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and | ||
6 | # $(KBUILD_VMLINUX_MAIN). Most are built-in.o files from top-level directories | ||
7 | # in the kernel tree, others are specified in arch/$(ARCH)/Makefile. | ||
8 | # Ordering when linking is important, and $(KBUILD_VMLINUX_INIT) must be first. | ||
9 | # | ||
10 | # vmlinux | ||
11 | # ^ | ||
12 | # | | ||
13 | # +-< $(KBUILD_VMLINUX_INIT) | ||
14 | # | +--< init/version.o + more | ||
15 | # | | ||
16 | # +--< $(KBUILD_VMLINUX_MAIN) | ||
17 | # | +--< drivers/built-in.o mm/built-in.o + more | ||
18 | # | | ||
19 | # +-< ${kallsymso} (see description in KALLSYMS section) | ||
20 | # | ||
21 | # vmlinux version (uname -v) cannot be updated during normal | ||
22 | # descending-into-subdirs phase since we do not yet know if we need to | ||
23 | # update vmlinux. | ||
24 | # Therefore this step is delayed until just before final link of vmlinux. | ||
25 | # | ||
26 | # System.map is generated to document addresses of all kernel symbols | ||
27 | |||
28 | # Error out on error | ||
29 | set -e | ||
30 | |||
31 | # Nice output in kbuild format | ||
32 | # Will be supressed by "make -s" | ||
33 | info() | ||
34 | { | ||
35 | if [ "${quiet}" != "silent_" ]; then | ||
36 | printf " %-7s %s\n" ${1} ${2} | ||
37 | fi | ||
38 | } | ||
39 | |||
40 | # Link of vmlinux.o used for section mismatch analysis | ||
41 | # ${1} output file | ||
42 | modpost_link() | ||
43 | { | ||
44 | ${LD} ${LDFLAGS} -r -o ${1} ${KBUILD_VMLINUX_INIT} \ | ||
45 | --start-group ${KBUILD_VMLINUX_MAIN} --end-group | ||
46 | } | ||
47 | |||
48 | # Link of vmlinux | ||
49 | # ${1} - optional extra .o files | ||
50 | # ${2} - output file | ||
51 | vmlinux_link() | ||
52 | { | ||
53 | local lds="${objtree}/${KBUILD_LDS}" | ||
54 | |||
55 | if [ "${SRCARCH}" != "um" ]; then | ||
56 | ${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \ | ||
57 | -T ${lds} ${KBUILD_VMLINUX_INIT} \ | ||
58 | --start-group ${KBUILD_VMLINUX_MAIN} --end-group ${1} | ||
59 | else | ||
60 | ${CC} ${CFLAGS_vmlinux} -o ${2} \ | ||
61 | -Wl,-T,${lds} ${KBUILD_VMLINUX_INIT} \ | ||
62 | -Wl,--start-group \ | ||
63 | ${KBUILD_VMLINUX_MAIN} \ | ||
64 | -Wl,--end-group \ | ||
65 | -lutil ${1} | ||
66 | rm -f linux | ||
67 | fi | ||
68 | } | ||
69 | |||
70 | |||
71 | # Create ${2} .o file with all symbols from the ${1} object file | ||
72 | kallsyms() | ||
73 | { | ||
74 | info KSYM ${2} | ||
75 | local kallsymopt; | ||
76 | |||
77 | if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then | ||
78 | kallsymopt="${kallsymopt} \ | ||
79 | --symbol-prefix=${CONFIG_SYMBOL_PREFIX}" | ||
80 | fi | ||
81 | |||
82 | if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then | ||
83 | kallsymopt="${kallsymopt} --all-symbols" | ||
84 | fi | ||
85 | |||
86 | local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ | ||
87 | ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}" | ||
88 | |||
89 | ${NM} -n ${1} | \ | ||
90 | scripts/kallsyms ${kallsymopt} | \ | ||
91 | ${CC} ${aflags} -c -o ${2} -x assembler-with-cpp - | ||
92 | } | ||
93 | |||
94 | # Create map file with all symbols from ${1} | ||
95 | # See mksymap for additional details | ||
96 | mksysmap() | ||
97 | { | ||
98 | ${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2} | ||
99 | } | ||
100 | |||
101 | sortextable() | ||
102 | { | ||
103 | ${objtree}/scripts/sortextable ${1} | ||
104 | } | ||
105 | |||
106 | # Delete output files in case of error | ||
107 | trap cleanup SIGHUP SIGINT SIGQUIT SIGTERM ERR | ||
108 | cleanup() | ||
109 | { | ||
110 | rm -f .old_version | ||
111 | rm -f .tmp_System.map | ||
112 | rm -f .tmp_kallsyms* | ||
113 | rm -f .tmp_version | ||
114 | rm -f .tmp_vmlinux* | ||
115 | rm -f System.map | ||
116 | rm -f vmlinux | ||
117 | rm -f vmlinux.o | ||
118 | } | ||
119 | |||
120 | # | ||
121 | # | ||
122 | # Use "make V=1" to debug this script | ||
123 | case "${KBUILD_VERBOSE}" in | ||
124 | *1*) | ||
125 | set -x | ||
126 | ;; | ||
127 | esac | ||
128 | |||
129 | if [ "$1" = "clean" ]; then | ||
130 | cleanup | ||
131 | exit 0 | ||
132 | fi | ||
133 | |||
134 | # We need access to CONFIG_ symbols | ||
135 | . ./.config | ||
136 | |||
137 | #link vmlinux.o | ||
138 | info LD vmlinux.o | ||
139 | modpost_link vmlinux.o | ||
140 | |||
141 | # modpost vmlinux.o to check for section mismatches | ||
142 | ${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o | ||
143 | |||
144 | # Update version | ||
145 | info GEN .version | ||
146 | if [ ! -r .version ]; then | ||
147 | rm -f .version; | ||
148 | echo 1 >.version; | ||
149 | else | ||
150 | mv .version .old_version; | ||
151 | expr 0$(cat .old_version) + 1 >.version; | ||
152 | fi; | ||
153 | |||
154 | # final build of init/ | ||
155 | ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init | ||
156 | |||
157 | kallsymso="" | ||
158 | kallsyms_vmlinux="" | ||
159 | if [ -n "${CONFIG_KALLSYMS}" ]; then | ||
160 | |||
161 | # kallsyms support | ||
162 | # Generate section listing all symbols and add it into vmlinux | ||
163 | # It's a three step process: | ||
164 | # 1) Link .tmp_vmlinux1 so it has all symbols and sections, | ||
165 | # but __kallsyms is empty. | ||
166 | # Running kallsyms on that gives us .tmp_kallsyms1.o with | ||
167 | # the right size | ||
168 | # 2) Link .tmp_vmlinux2 so it now has a __kallsyms section of | ||
169 | # the right size, but due to the added section, some | ||
170 | # addresses have shifted. | ||
171 | # From here, we generate a correct .tmp_kallsyms2.o | ||
172 | # 2a) We may use an extra pass as this has been necessary to | ||
173 | # woraround some alignment related bugs. | ||
174 | # KALLSYMS_EXTRA_PASS=1 is used to trigger this. | ||
175 | # 3) The correct ${kallsymso} is linked into the final vmlinux. | ||
176 | # | ||
177 | # a) Verify that the System.map from vmlinux matches the map from | ||
178 | # ${kallsymso}. | ||
179 | |||
180 | kallsymso=.tmp_kallsyms2.o | ||
181 | kallsyms_vmlinux=.tmp_vmlinux2 | ||
182 | |||
183 | # step 1 | ||
184 | vmlinux_link "" .tmp_vmlinux1 | ||
185 | kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o | ||
186 | |||
187 | # step 2 | ||
188 | vmlinux_link .tmp_kallsyms1.o .tmp_vmlinux2 | ||
189 | kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o | ||
190 | |||
191 | # step 2a | ||
192 | if [ -n "${KALLSYMS_EXTRA_PASS}" ]; then | ||
193 | kallsymso=.tmp_kallsyms3.o | ||
194 | kallsyms_vmlinux=.tmp_vmlinux3 | ||
195 | |||
196 | vmlinux_link .tmp_kallsyms2.o .tmp_vmlinux3 | ||
197 | |||
198 | kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o | ||
199 | fi | ||
200 | fi | ||
201 | |||
202 | info LD vmlinux | ||
203 | vmlinux_link "${kallsymso}" vmlinux | ||
204 | |||
205 | if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then | ||
206 | info SORTEX vmlinux | ||
207 | sortextable vmlinux | ||
208 | fi | ||
209 | |||
210 | info SYSMAP System.map | ||
211 | mksysmap vmlinux System.map | ||
212 | |||
213 | # step a (see comment above) | ||
214 | if [ -n "${CONFIG_KALLSYMS}" ]; then | ||
215 | mksysmap ${kallsyms_vmlinux} .tmp_System.map | ||
216 | |||
217 | if ! cmp -s System.map .tmp_System.map; then | ||
218 | echo >&2 Inconsistent kallsyms data | ||
219 | echo >&2 Try "make KALLSYMS_EXTRA_PASS=1" as a workaround | ||
220 | cleanup | ||
221 | exit 1 | ||
222 | fi | ||
223 | fi | ||
224 | |||
225 | # We made a new kernel - delete old version file | ||
226 | rm -f .old_version | ||
diff --git a/scripts/mksysmap b/scripts/mksysmap index c1b6191ef87..6e133a0bae7 100644 --- a/scripts/mksysmap +++ b/scripts/mksysmap | |||
@@ -16,7 +16,7 @@ | |||
16 | # The second row specify the type of the symbol: | 16 | # The second row specify the type of the symbol: |
17 | # A = Absolute | 17 | # A = Absolute |
18 | # B = Uninitialised data (.bss) | 18 | # B = Uninitialised data (.bss) |
19 | # C = Common symbol | 19 | # C = Comon symbol |
20 | # D = Initialised data | 20 | # D = Initialised data |
21 | # G = Initialised data for small objects | 21 | # G = Initialised data for small objects |
22 | # I = Indirect reference to another symbol | 22 | # I = Indirect reference to another symbol |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index df4fc23dd83..e26e2fb462d 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -28,7 +28,6 @@ typedef Elf64_Addr kernel_ulong_t; | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <ctype.h> | 30 | #include <ctype.h> |
31 | #include <stdbool.h> | ||
32 | 31 | ||
33 | typedef uint32_t __u32; | 32 | typedef uint32_t __u32; |
34 | typedef uint16_t __u16; | 33 | typedef uint16_t __u16; |
@@ -39,61 +38,6 @@ typedef unsigned char __u8; | |||
39 | * we handle those differences explicitly below */ | 38 | * we handle those differences explicitly below */ |
40 | #include "../../include/linux/mod_devicetable.h" | 39 | #include "../../include/linux/mod_devicetable.h" |
41 | 40 | ||
42 | /* This array collects all instances that use the generic do_table */ | ||
43 | struct devtable { | ||
44 | const char *device_id; /* name of table, __mod_<name>_device_table. */ | ||
45 | unsigned long id_size; | ||
46 | void *function; | ||
47 | }; | ||
48 | |||
49 | #define ___cat(a,b) a ## b | ||
50 | #define __cat(a,b) ___cat(a,b) | ||
51 | |||
52 | /* we need some special handling for this host tool running eventually on | ||
53 | * Darwin. The Mach-O section handling is a bit different than ELF section | ||
54 | * handling. The differnces in detail are: | ||
55 | * a) we have segments which have sections | ||
56 | * b) we need a API call to get the respective section symbols */ | ||
57 | #if defined(__MACH__) | ||
58 | #include <mach-o/getsect.h> | ||
59 | |||
60 | #define INIT_SECTION(name) do { \ | ||
61 | unsigned long name ## _len; \ | ||
62 | char *__cat(pstart_,name) = getsectdata("__TEXT", \ | ||
63 | #name, &__cat(name,_len)); \ | ||
64 | char *__cat(pstop_,name) = __cat(pstart_,name) + \ | ||
65 | __cat(name, _len); \ | ||
66 | __cat(__start_,name) = (void *)__cat(pstart_,name); \ | ||
67 | __cat(__stop_,name) = (void *)__cat(pstop_,name); \ | ||
68 | } while (0) | ||
69 | #define SECTION(name) __attribute__((section("__TEXT, " #name))) | ||
70 | |||
71 | struct devtable **__start___devtable, **__stop___devtable; | ||
72 | #else | ||
73 | #define INIT_SECTION(name) /* no-op for ELF */ | ||
74 | #define SECTION(name) __attribute__((section(#name))) | ||
75 | |||
76 | /* We construct a table of pointers in an ELF section (pointers generally | ||
77 | * go unpadded by gcc). ld creates boundary syms for us. */ | ||
78 | extern struct devtable *__start___devtable[], *__stop___devtable[]; | ||
79 | #endif /* __MACH__ */ | ||
80 | |||
81 | #if __GNUC__ == 3 && __GNUC_MINOR__ < 3 | ||
82 | # define __used __attribute__((__unused__)) | ||
83 | #else | ||
84 | # define __used __attribute__((__used__)) | ||
85 | #endif | ||
86 | |||
87 | /* Add a table entry. We test function type matches while we're here. */ | ||
88 | #define ADD_TO_DEVTABLE(device_id, type, function) \ | ||
89 | static struct devtable __cat(devtable,__LINE__) = { \ | ||
90 | device_id + 0*sizeof((function)((const char *)NULL, \ | ||
91 | (type *)NULL, \ | ||
92 | (char *)NULL)), \ | ||
93 | sizeof(type), (function) }; \ | ||
94 | static struct devtable *SECTION(__devtable) __used \ | ||
95 | __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) | ||
96 | |||
97 | #define ADD(str, sep, cond, field) \ | 41 | #define ADD(str, sep, cond, field) \ |
98 | do { \ | 42 | do { \ |
99 | strcat(str, sep); \ | 43 | strcat(str, sep); \ |
@@ -156,7 +100,7 @@ static void device_id_check(const char *modname, const char *device_id, | |||
156 | } | 100 | } |
157 | 101 | ||
158 | /* USB is special because the bcdDevice can be matched against a numeric range */ | 102 | /* USB is special because the bcdDevice can be matched against a numeric range */ |
159 | /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */ | 103 | /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */ |
160 | static void do_usb_entry(struct usb_device_id *id, | 104 | static void do_usb_entry(struct usb_device_id *id, |
161 | unsigned int bcdDevice_initial, int bcdDevice_initial_digits, | 105 | unsigned int bcdDevice_initial, int bcdDevice_initial_digits, |
162 | unsigned char range_lo, unsigned char range_hi, | 106 | unsigned char range_lo, unsigned char range_hi, |
@@ -210,9 +154,6 @@ static void do_usb_entry(struct usb_device_id *id, | |||
210 | ADD(alias, "ip", | 154 | ADD(alias, "ip", |
211 | id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, | 155 | id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, |
212 | id->bInterfaceProtocol); | 156 | id->bInterfaceProtocol); |
213 | ADD(alias, "in", | ||
214 | id->match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, | ||
215 | id->bInterfaceNumber); | ||
216 | 157 | ||
217 | add_wildcard(alias); | 158 | add_wildcard(alias); |
218 | buf_printf(&mod->dev_table_buf, | 159 | buf_printf(&mod->dev_table_buf, |
@@ -339,19 +280,15 @@ static int do_hid_entry(const char *filename, | |||
339 | struct hid_device_id *id, char *alias) | 280 | struct hid_device_id *id, char *alias) |
340 | { | 281 | { |
341 | id->bus = TO_NATIVE(id->bus); | 282 | id->bus = TO_NATIVE(id->bus); |
342 | id->group = TO_NATIVE(id->group); | ||
343 | id->vendor = TO_NATIVE(id->vendor); | 283 | id->vendor = TO_NATIVE(id->vendor); |
344 | id->product = TO_NATIVE(id->product); | 284 | id->product = TO_NATIVE(id->product); |
345 | 285 | ||
346 | sprintf(alias, "hid:"); | 286 | sprintf(alias, "hid:b%04X", id->bus); |
347 | ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus); | ||
348 | ADD(alias, "g", id->group != HID_GROUP_ANY, id->group); | ||
349 | ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); | 287 | ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); |
350 | ADD(alias, "p", id->product != HID_ANY_ID, id->product); | 288 | ADD(alias, "p", id->product != HID_ANY_ID, id->product); |
351 | 289 | ||
352 | return 1; | 290 | return 1; |
353 | } | 291 | } |
354 | ADD_TO_DEVTABLE("hid", struct hid_device_id, do_hid_entry); | ||
355 | 292 | ||
356 | /* Looks like: ieee1394:venNmoNspNverN */ | 293 | /* Looks like: ieee1394:venNmoNspNverN */ |
357 | static int do_ieee1394_entry(const char *filename, | 294 | static int do_ieee1394_entry(const char *filename, |
@@ -376,7 +313,6 @@ static int do_ieee1394_entry(const char *filename, | |||
376 | add_wildcard(alias); | 313 | add_wildcard(alias); |
377 | return 1; | 314 | return 1; |
378 | } | 315 | } |
379 | ADD_TO_DEVTABLE("ieee1394", struct ieee1394_device_id, do_ieee1394_entry); | ||
380 | 316 | ||
381 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ | 317 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ |
382 | static int do_pci_entry(const char *filename, | 318 | static int do_pci_entry(const char *filename, |
@@ -420,7 +356,6 @@ static int do_pci_entry(const char *filename, | |||
420 | add_wildcard(alias); | 356 | add_wildcard(alias); |
421 | return 1; | 357 | return 1; |
422 | } | 358 | } |
423 | ADD_TO_DEVTABLE("pci", struct pci_device_id, do_pci_entry); | ||
424 | 359 | ||
425 | /* looks like: "ccw:tNmNdtNdmN" */ | 360 | /* looks like: "ccw:tNmNdtNdmN" */ |
426 | static int do_ccw_entry(const char *filename, | 361 | static int do_ccw_entry(const char *filename, |
@@ -444,7 +379,6 @@ static int do_ccw_entry(const char *filename, | |||
444 | add_wildcard(alias); | 379 | add_wildcard(alias); |
445 | return 1; | 380 | return 1; |
446 | } | 381 | } |
447 | ADD_TO_DEVTABLE("ccw", struct ccw_device_id, do_ccw_entry); | ||
448 | 382 | ||
449 | /* looks like: "ap:tN" */ | 383 | /* looks like: "ap:tN" */ |
450 | static int do_ap_entry(const char *filename, | 384 | static int do_ap_entry(const char *filename, |
@@ -453,7 +387,6 @@ static int do_ap_entry(const char *filename, | |||
453 | sprintf(alias, "ap:t%02X*", id->dev_type); | 387 | sprintf(alias, "ap:t%02X*", id->dev_type); |
454 | return 1; | 388 | return 1; |
455 | } | 389 | } |
456 | ADD_TO_DEVTABLE("ap", struct ap_device_id, do_ap_entry); | ||
457 | 390 | ||
458 | /* looks like: "css:tN" */ | 391 | /* looks like: "css:tN" */ |
459 | static int do_css_entry(const char *filename, | 392 | static int do_css_entry(const char *filename, |
@@ -462,7 +395,6 @@ static int do_css_entry(const char *filename, | |||
462 | sprintf(alias, "css:t%01X", id->type); | 395 | sprintf(alias, "css:t%01X", id->type); |
463 | return 1; | 396 | return 1; |
464 | } | 397 | } |
465 | ADD_TO_DEVTABLE("css", struct css_device_id, do_css_entry); | ||
466 | 398 | ||
467 | /* Looks like: "serio:tyNprNidNexN" */ | 399 | /* Looks like: "serio:tyNprNidNexN" */ |
468 | static int do_serio_entry(const char *filename, | 400 | static int do_serio_entry(const char *filename, |
@@ -482,7 +414,6 @@ static int do_serio_entry(const char *filename, | |||
482 | add_wildcard(alias); | 414 | add_wildcard(alias); |
483 | return 1; | 415 | return 1; |
484 | } | 416 | } |
485 | ADD_TO_DEVTABLE("serio", struct serio_device_id, do_serio_entry); | ||
486 | 417 | ||
487 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ | 418 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ |
488 | static int do_acpi_entry(const char *filename, | 419 | static int do_acpi_entry(const char *filename, |
@@ -491,7 +422,6 @@ static int do_acpi_entry(const char *filename, | |||
491 | sprintf(alias, "acpi*:%s:*", id->id); | 422 | sprintf(alias, "acpi*:%s:*", id->id); |
492 | return 1; | 423 | return 1; |
493 | } | 424 | } |
494 | ADD_TO_DEVTABLE("acpi", struct acpi_device_id, do_acpi_entry); | ||
495 | 425 | ||
496 | /* looks like: "pnp:dD" */ | 426 | /* looks like: "pnp:dD" */ |
497 | static void do_pnp_device_entry(void *symval, unsigned long size, | 427 | static void do_pnp_device_entry(void *symval, unsigned long size, |
@@ -614,7 +544,8 @@ static int do_pcmcia_entry(const char *filename, | |||
614 | add_wildcard(alias); | 544 | add_wildcard(alias); |
615 | return 1; | 545 | return 1; |
616 | } | 546 | } |
617 | ADD_TO_DEVTABLE("pcmcia", struct pcmcia_device_id, do_pcmcia_entry); | 547 | |
548 | |||
618 | 549 | ||
619 | static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) | 550 | static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) |
620 | { | 551 | { |
@@ -637,7 +568,6 @@ static int do_of_entry (const char *filename, struct of_device_id *of, char *ali | |||
637 | add_wildcard(alias); | 568 | add_wildcard(alias); |
638 | return 1; | 569 | return 1; |
639 | } | 570 | } |
640 | ADD_TO_DEVTABLE("of", struct of_device_id, do_of_entry); | ||
641 | 571 | ||
642 | static int do_vio_entry(const char *filename, struct vio_device_id *vio, | 572 | static int do_vio_entry(const char *filename, struct vio_device_id *vio, |
643 | char *alias) | 573 | char *alias) |
@@ -655,7 +585,6 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, | |||
655 | add_wildcard(alias); | 585 | add_wildcard(alias); |
656 | return 1; | 586 | return 1; |
657 | } | 587 | } |
658 | ADD_TO_DEVTABLE("vio", struct vio_device_id, do_vio_entry); | ||
659 | 588 | ||
660 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 589 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
661 | 590 | ||
@@ -711,7 +640,6 @@ static int do_input_entry(const char *filename, struct input_device_id *id, | |||
711 | do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); | 640 | do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); |
712 | return 1; | 641 | return 1; |
713 | } | 642 | } |
714 | ADD_TO_DEVTABLE("input", struct input_device_id, do_input_entry); | ||
715 | 643 | ||
716 | static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, | 644 | static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, |
717 | char *alias) | 645 | char *alias) |
@@ -722,7 +650,6 @@ static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, | |||
722 | strcat(alias, "*"); | 650 | strcat(alias, "*"); |
723 | return 1; | 651 | return 1; |
724 | } | 652 | } |
725 | ADD_TO_DEVTABLE("eisa", struct eisa_device_id, do_eisa_entry); | ||
726 | 653 | ||
727 | /* Looks like: parisc:tNhvNrevNsvN */ | 654 | /* Looks like: parisc:tNhvNrevNsvN */ |
728 | static int do_parisc_entry(const char *filename, struct parisc_device_id *id, | 655 | static int do_parisc_entry(const char *filename, struct parisc_device_id *id, |
@@ -742,7 +669,6 @@ static int do_parisc_entry(const char *filename, struct parisc_device_id *id, | |||
742 | add_wildcard(alias); | 669 | add_wildcard(alias); |
743 | return 1; | 670 | return 1; |
744 | } | 671 | } |
745 | ADD_TO_DEVTABLE("parisc", struct parisc_device_id, do_parisc_entry); | ||
746 | 672 | ||
747 | /* Looks like: sdio:cNvNdN. */ | 673 | /* Looks like: sdio:cNvNdN. */ |
748 | static int do_sdio_entry(const char *filename, | 674 | static int do_sdio_entry(const char *filename, |
@@ -759,7 +685,6 @@ static int do_sdio_entry(const char *filename, | |||
759 | add_wildcard(alias); | 685 | add_wildcard(alias); |
760 | return 1; | 686 | return 1; |
761 | } | 687 | } |
762 | ADD_TO_DEVTABLE("sdio", struct sdio_device_id, do_sdio_entry); | ||
763 | 688 | ||
764 | /* Looks like: ssb:vNidNrevN. */ | 689 | /* Looks like: ssb:vNidNrevN. */ |
765 | static int do_ssb_entry(const char *filename, | 690 | static int do_ssb_entry(const char *filename, |
@@ -776,7 +701,6 @@ static int do_ssb_entry(const char *filename, | |||
776 | add_wildcard(alias); | 701 | add_wildcard(alias); |
777 | return 1; | 702 | return 1; |
778 | } | 703 | } |
779 | ADD_TO_DEVTABLE("ssb", struct ssb_device_id, do_ssb_entry); | ||
780 | 704 | ||
781 | /* Looks like: bcma:mNidNrevNclN. */ | 705 | /* Looks like: bcma:mNidNrevNclN. */ |
782 | static int do_bcma_entry(const char *filename, | 706 | static int do_bcma_entry(const char *filename, |
@@ -795,7 +719,6 @@ static int do_bcma_entry(const char *filename, | |||
795 | add_wildcard(alias); | 719 | add_wildcard(alias); |
796 | return 1; | 720 | return 1; |
797 | } | 721 | } |
798 | ADD_TO_DEVTABLE("bcma", struct bcma_device_id, do_bcma_entry); | ||
799 | 722 | ||
800 | /* Looks like: virtio:dNvN */ | 723 | /* Looks like: virtio:dNvN */ |
801 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | 724 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, |
@@ -811,29 +734,6 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | |||
811 | add_wildcard(alias); | 734 | add_wildcard(alias); |
812 | return 1; | 735 | return 1; |
813 | } | 736 | } |
814 | ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); | ||
815 | |||
816 | /* | ||
817 | * Looks like: vmbus:guid | ||
818 | * Each byte of the guid will be represented by two hex characters | ||
819 | * in the name. | ||
820 | */ | ||
821 | |||
822 | static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, | ||
823 | char *alias) | ||
824 | { | ||
825 | int i; | ||
826 | char guid_name[((sizeof(id->guid) + 1)) * 2]; | ||
827 | |||
828 | for (i = 0; i < (sizeof(id->guid) * 2); i += 2) | ||
829 | sprintf(&guid_name[i], "%02x", id->guid[i/2]); | ||
830 | |||
831 | strcpy(alias, "vmbus:"); | ||
832 | strcat(alias, guid_name); | ||
833 | |||
834 | return 1; | ||
835 | } | ||
836 | ADD_TO_DEVTABLE("vmbus", struct hv_vmbus_device_id, do_vmbus_entry); | ||
837 | 737 | ||
838 | /* Looks like: i2c:S */ | 738 | /* Looks like: i2c:S */ |
839 | static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | 739 | static int do_i2c_entry(const char *filename, struct i2c_device_id *id, |
@@ -843,7 +743,6 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | |||
843 | 743 | ||
844 | return 1; | 744 | return 1; |
845 | } | 745 | } |
846 | ADD_TO_DEVTABLE("i2c", struct i2c_device_id, do_i2c_entry); | ||
847 | 746 | ||
848 | /* Looks like: spi:S */ | 747 | /* Looks like: spi:S */ |
849 | static int do_spi_entry(const char *filename, struct spi_device_id *id, | 748 | static int do_spi_entry(const char *filename, struct spi_device_id *id, |
@@ -853,7 +752,6 @@ static int do_spi_entry(const char *filename, struct spi_device_id *id, | |||
853 | 752 | ||
854 | return 1; | 753 | return 1; |
855 | } | 754 | } |
856 | ADD_TO_DEVTABLE("spi", struct spi_device_id, do_spi_entry); | ||
857 | 755 | ||
858 | static const struct dmifield { | 756 | static const struct dmifield { |
859 | const char *prefix; | 757 | const char *prefix; |
@@ -908,7 +806,6 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | |||
908 | strcat(alias, ":"); | 806 | strcat(alias, ":"); |
909 | return 1; | 807 | return 1; |
910 | } | 808 | } |
911 | ADD_TO_DEVTABLE("dmi", struct dmi_system_id, do_dmi_entry); | ||
912 | 809 | ||
913 | static int do_platform_entry(const char *filename, | 810 | static int do_platform_entry(const char *filename, |
914 | struct platform_device_id *id, char *alias) | 811 | struct platform_device_id *id, char *alias) |
@@ -916,7 +813,6 @@ static int do_platform_entry(const char *filename, | |||
916 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); | 813 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); |
917 | return 1; | 814 | return 1; |
918 | } | 815 | } |
919 | ADD_TO_DEVTABLE("platform", struct platform_device_id, do_platform_entry); | ||
920 | 816 | ||
921 | static int do_mdio_entry(const char *filename, | 817 | static int do_mdio_entry(const char *filename, |
922 | struct mdio_device_id *id, char *alias) | 818 | struct mdio_device_id *id, char *alias) |
@@ -939,7 +835,6 @@ static int do_mdio_entry(const char *filename, | |||
939 | 835 | ||
940 | return 1; | 836 | return 1; |
941 | } | 837 | } |
942 | ADD_TO_DEVTABLE("mdio", struct mdio_device_id, do_mdio_entry); | ||
943 | 838 | ||
944 | /* Looks like: zorro:iN. */ | 839 | /* Looks like: zorro:iN. */ |
945 | static int do_zorro_entry(const char *filename, struct zorro_device_id *id, | 840 | static int do_zorro_entry(const char *filename, struct zorro_device_id *id, |
@@ -950,7 +845,6 @@ static int do_zorro_entry(const char *filename, struct zorro_device_id *id, | |||
950 | ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); | 845 | ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); |
951 | return 1; | 846 | return 1; |
952 | } | 847 | } |
953 | ADD_TO_DEVTABLE("zorro", struct zorro_device_id, do_zorro_entry); | ||
954 | 848 | ||
955 | /* looks like: "pnp:dD" */ | 849 | /* looks like: "pnp:dD" */ |
956 | static int do_isapnp_entry(const char *filename, | 850 | static int do_isapnp_entry(const char *filename, |
@@ -964,124 +858,16 @@ static int do_isapnp_entry(const char *filename, | |||
964 | (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); | 858 | (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); |
965 | return 1; | 859 | return 1; |
966 | } | 860 | } |
967 | ADD_TO_DEVTABLE("isapnp", struct isapnp_device_id, do_isapnp_entry); | ||
968 | 861 | ||
969 | /* Looks like: "ipack:fNvNdN". */ | 862 | /* Ignore any prefix, eg. some architectures prepend _ */ |
970 | static int do_ipack_entry(const char *filename, | 863 | static inline int sym_is(const char *symbol, const char *name) |
971 | struct ipack_device_id *id, char *alias) | ||
972 | { | 864 | { |
973 | id->vendor = TO_NATIVE(id->vendor); | 865 | const char *match; |
974 | id->device = TO_NATIVE(id->device); | ||
975 | strcpy(alias, "ipack:"); | ||
976 | ADD(alias, "f", id->format != IPACK_ANY_FORMAT, id->format); | ||
977 | ADD(alias, "v", id->vendor != IPACK_ANY_ID, id->vendor); | ||
978 | ADD(alias, "d", id->device != IPACK_ANY_ID, id->device); | ||
979 | add_wildcard(alias); | ||
980 | return 1; | ||
981 | } | ||
982 | ADD_TO_DEVTABLE("ipack", struct ipack_device_id, do_ipack_entry); | ||
983 | |||
984 | /* | ||
985 | * Append a match expression for a single masked hex digit. | ||
986 | * outp points to a pointer to the character at which to append. | ||
987 | * *outp is updated on return to point just after the appended text, | ||
988 | * to facilitate further appending. | ||
989 | */ | ||
990 | static void append_nibble_mask(char **outp, | ||
991 | unsigned int nibble, unsigned int mask) | ||
992 | { | ||
993 | char *p = *outp; | ||
994 | unsigned int i; | ||
995 | |||
996 | switch (mask) { | ||
997 | case 0: | ||
998 | *p++ = '?'; | ||
999 | break; | ||
1000 | |||
1001 | case 0xf: | ||
1002 | p += sprintf(p, "%X", nibble); | ||
1003 | break; | ||
1004 | |||
1005 | default: | ||
1006 | /* | ||
1007 | * Dumbly emit a match pattern for all possible matching | ||
1008 | * digits. This could be improved in some cases using ranges, | ||
1009 | * but it has the advantage of being trivially correct, and is | ||
1010 | * often optimal. | ||
1011 | */ | ||
1012 | *p++ = '['; | ||
1013 | for (i = 0; i < 0x10; i++) | ||
1014 | if ((i & mask) == nibble) | ||
1015 | p += sprintf(p, "%X", i); | ||
1016 | *p++ = ']'; | ||
1017 | } | ||
1018 | |||
1019 | /* Ensure that the string remains NUL-terminated: */ | ||
1020 | *p = '\0'; | ||
1021 | 866 | ||
1022 | /* Advance the caller's end-of-string pointer: */ | 867 | match = strstr(symbol, name); |
1023 | *outp = p; | 868 | if (!match) |
1024 | } | 869 | return 0; |
1025 | 870 | return match[strlen(name)] == '\0'; | |
1026 | /* | ||
1027 | * looks like: "amba:dN" | ||
1028 | * | ||
1029 | * N is exactly 8 digits, where each is an upper-case hex digit, or | ||
1030 | * a ? or [] pattern matching exactly one digit. | ||
1031 | */ | ||
1032 | static int do_amba_entry(const char *filename, | ||
1033 | struct amba_id *id, char *alias) | ||
1034 | { | ||
1035 | unsigned int digit; | ||
1036 | char *p = alias; | ||
1037 | |||
1038 | if ((id->id & id->mask) != id->id) | ||
1039 | fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " | ||
1040 | "id=0x%08X, mask=0x%08X. Please fix this driver.\n", | ||
1041 | filename, id->id, id->mask); | ||
1042 | |||
1043 | p += sprintf(alias, "amba:d"); | ||
1044 | for (digit = 0; digit < 8; digit++) | ||
1045 | append_nibble_mask(&p, | ||
1046 | (id->id >> (4 * (7 - digit))) & 0xf, | ||
1047 | (id->mask >> (4 * (7 - digit))) & 0xf); | ||
1048 | |||
1049 | return 1; | ||
1050 | } | ||
1051 | ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); | ||
1052 | |||
1053 | /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* | ||
1054 | * All fields are numbers. It would be nicer to use strings for vendor | ||
1055 | * and feature, but getting those out of the build system here is too | ||
1056 | * complicated. | ||
1057 | */ | ||
1058 | |||
1059 | static int do_x86cpu_entry(const char *filename, struct x86_cpu_id *id, | ||
1060 | char *alias) | ||
1061 | { | ||
1062 | id->feature = TO_NATIVE(id->feature); | ||
1063 | id->family = TO_NATIVE(id->family); | ||
1064 | id->model = TO_NATIVE(id->model); | ||
1065 | id->vendor = TO_NATIVE(id->vendor); | ||
1066 | |||
1067 | strcpy(alias, "x86cpu:"); | ||
1068 | ADD(alias, "vendor:", id->vendor != X86_VENDOR_ANY, id->vendor); | ||
1069 | ADD(alias, ":family:", id->family != X86_FAMILY_ANY, id->family); | ||
1070 | ADD(alias, ":model:", id->model != X86_MODEL_ANY, id->model); | ||
1071 | strcat(alias, ":feature:*"); | ||
1072 | if (id->feature != X86_FEATURE_ANY) | ||
1073 | sprintf(alias + strlen(alias), "%04X*", id->feature); | ||
1074 | return 1; | ||
1075 | } | ||
1076 | ADD_TO_DEVTABLE("x86cpu", struct x86_cpu_id, do_x86cpu_entry); | ||
1077 | |||
1078 | /* Does namelen bytes of name exactly match the symbol? */ | ||
1079 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) | ||
1080 | { | ||
1081 | if (namelen != strlen(symbol)) | ||
1082 | return false; | ||
1083 | |||
1084 | return memcmp(name, symbol, namelen) == 0; | ||
1085 | } | 871 | } |
1086 | 872 | ||
1087 | static void do_table(void *symval, unsigned long size, | 873 | static void do_table(void *symval, unsigned long size, |
@@ -1114,29 +900,11 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1114 | { | 900 | { |
1115 | void *symval; | 901 | void *symval; |
1116 | char *zeros = NULL; | 902 | char *zeros = NULL; |
1117 | const char *name; | ||
1118 | unsigned int namelen; | ||
1119 | 903 | ||
1120 | /* We're looking for a section relative symbol */ | 904 | /* We're looking for a section relative symbol */ |
1121 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) | 905 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) |
1122 | return; | 906 | return; |
1123 | 907 | ||
1124 | /* We're looking for an object */ | ||
1125 | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) | ||
1126 | return; | ||
1127 | |||
1128 | /* All our symbols are of form <prefix>__mod_XXX_device_table. */ | ||
1129 | name = strstr(symname, "__mod_"); | ||
1130 | if (!name) | ||
1131 | return; | ||
1132 | name += strlen("__mod_"); | ||
1133 | namelen = strlen(name); | ||
1134 | if (namelen < strlen("_device_table")) | ||
1135 | return; | ||
1136 | if (strcmp(name + namelen - strlen("_device_table"), "_device_table")) | ||
1137 | return; | ||
1138 | namelen -= strlen("_device_table"); | ||
1139 | |||
1140 | /* Handle all-NULL symbols allocated into .bss */ | 908 | /* Handle all-NULL symbols allocated into .bss */ |
1141 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { | 909 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { |
1142 | zeros = calloc(1, sym->st_size); | 910 | zeros = calloc(1, sym->st_size); |
@@ -1147,25 +915,113 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1147 | + sym->st_value; | 915 | + sym->st_value; |
1148 | } | 916 | } |
1149 | 917 | ||
1150 | /* First handle the "special" cases */ | 918 | if (sym_is(symname, "__mod_pci_device_table")) |
1151 | if (sym_is(name, namelen, "usb")) | 919 | do_table(symval, sym->st_size, |
920 | sizeof(struct pci_device_id), "pci", | ||
921 | do_pci_entry, mod); | ||
922 | else if (sym_is(symname, "__mod_usb_device_table")) | ||
923 | /* special case to handle bcdDevice ranges */ | ||
1152 | do_usb_table(symval, sym->st_size, mod); | 924 | do_usb_table(symval, sym->st_size, mod); |
1153 | else if (sym_is(name, namelen, "pnp")) | 925 | else if (sym_is(symname, "__mod_hid_device_table")) |
926 | do_table(symval, sym->st_size, | ||
927 | sizeof(struct hid_device_id), "hid", | ||
928 | do_hid_entry, mod); | ||
929 | else if (sym_is(symname, "__mod_ieee1394_device_table")) | ||
930 | do_table(symval, sym->st_size, | ||
931 | sizeof(struct ieee1394_device_id), "ieee1394", | ||
932 | do_ieee1394_entry, mod); | ||
933 | else if (sym_is(symname, "__mod_ccw_device_table")) | ||
934 | do_table(symval, sym->st_size, | ||
935 | sizeof(struct ccw_device_id), "ccw", | ||
936 | do_ccw_entry, mod); | ||
937 | else if (sym_is(symname, "__mod_ap_device_table")) | ||
938 | do_table(symval, sym->st_size, | ||
939 | sizeof(struct ap_device_id), "ap", | ||
940 | do_ap_entry, mod); | ||
941 | else if (sym_is(symname, "__mod_css_device_table")) | ||
942 | do_table(symval, sym->st_size, | ||
943 | sizeof(struct css_device_id), "css", | ||
944 | do_css_entry, mod); | ||
945 | else if (sym_is(symname, "__mod_serio_device_table")) | ||
946 | do_table(symval, sym->st_size, | ||
947 | sizeof(struct serio_device_id), "serio", | ||
948 | do_serio_entry, mod); | ||
949 | else if (sym_is(symname, "__mod_acpi_device_table")) | ||
950 | do_table(symval, sym->st_size, | ||
951 | sizeof(struct acpi_device_id), "acpi", | ||
952 | do_acpi_entry, mod); | ||
953 | else if (sym_is(symname, "__mod_pnp_device_table")) | ||
1154 | do_pnp_device_entry(symval, sym->st_size, mod); | 954 | do_pnp_device_entry(symval, sym->st_size, mod); |
1155 | else if (sym_is(name, namelen, "pnp_card")) | 955 | else if (sym_is(symname, "__mod_pnp_card_device_table")) |
1156 | do_pnp_card_entries(symval, sym->st_size, mod); | 956 | do_pnp_card_entries(symval, sym->st_size, mod); |
1157 | else { | 957 | else if (sym_is(symname, "__mod_pcmcia_device_table")) |
1158 | struct devtable **p; | 958 | do_table(symval, sym->st_size, |
1159 | INIT_SECTION(__devtable); | 959 | sizeof(struct pcmcia_device_id), "pcmcia", |
1160 | 960 | do_pcmcia_entry, mod); | |
1161 | for (p = __start___devtable; p < __stop___devtable; p++) { | 961 | else if (sym_is(symname, "__mod_of_device_table")) |
1162 | if (sym_is(name, namelen, (*p)->device_id)) { | 962 | do_table(symval, sym->st_size, |
1163 | do_table(symval, sym->st_size, (*p)->id_size, | 963 | sizeof(struct of_device_id), "of", |
1164 | (*p)->device_id, (*p)->function, mod); | 964 | do_of_entry, mod); |
1165 | break; | 965 | else if (sym_is(symname, "__mod_vio_device_table")) |
1166 | } | 966 | do_table(symval, sym->st_size, |
1167 | } | 967 | sizeof(struct vio_device_id), "vio", |
1168 | } | 968 | do_vio_entry, mod); |
969 | else if (sym_is(symname, "__mod_input_device_table")) | ||
970 | do_table(symval, sym->st_size, | ||
971 | sizeof(struct input_device_id), "input", | ||
972 | do_input_entry, mod); | ||
973 | else if (sym_is(symname, "__mod_eisa_device_table")) | ||
974 | do_table(symval, sym->st_size, | ||
975 | sizeof(struct eisa_device_id), "eisa", | ||
976 | do_eisa_entry, mod); | ||
977 | else if (sym_is(symname, "__mod_parisc_device_table")) | ||
978 | do_table(symval, sym->st_size, | ||
979 | sizeof(struct parisc_device_id), "parisc", | ||
980 | do_parisc_entry, mod); | ||
981 | else if (sym_is(symname, "__mod_sdio_device_table")) | ||
982 | do_table(symval, sym->st_size, | ||
983 | sizeof(struct sdio_device_id), "sdio", | ||
984 | do_sdio_entry, mod); | ||
985 | else if (sym_is(symname, "__mod_ssb_device_table")) | ||
986 | do_table(symval, sym->st_size, | ||
987 | sizeof(struct ssb_device_id), "ssb", | ||
988 | do_ssb_entry, mod); | ||
989 | else if (sym_is(symname, "__mod_bcma_device_table")) | ||
990 | do_table(symval, sym->st_size, | ||
991 | sizeof(struct bcma_device_id), "bcma", | ||
992 | do_bcma_entry, mod); | ||
993 | else if (sym_is(symname, "__mod_virtio_device_table")) | ||
994 | do_table(symval, sym->st_size, | ||
995 | sizeof(struct virtio_device_id), "virtio", | ||
996 | do_virtio_entry, mod); | ||
997 | else if (sym_is(symname, "__mod_i2c_device_table")) | ||
998 | do_table(symval, sym->st_size, | ||
999 | sizeof(struct i2c_device_id), "i2c", | ||
1000 | do_i2c_entry, mod); | ||
1001 | else if (sym_is(symname, "__mod_spi_device_table")) | ||
1002 | do_table(symval, sym->st_size, | ||
1003 | sizeof(struct spi_device_id), "spi", | ||
1004 | do_spi_entry, mod); | ||
1005 | else if (sym_is(symname, "__mod_dmi_device_table")) | ||
1006 | do_table(symval, sym->st_size, | ||
1007 | sizeof(struct dmi_system_id), "dmi", | ||
1008 | do_dmi_entry, mod); | ||
1009 | else if (sym_is(symname, "__mod_platform_device_table")) | ||
1010 | do_table(symval, sym->st_size, | ||
1011 | sizeof(struct platform_device_id), "platform", | ||
1012 | do_platform_entry, mod); | ||
1013 | else if (sym_is(symname, "__mod_mdio_device_table")) | ||
1014 | do_table(symval, sym->st_size, | ||
1015 | sizeof(struct mdio_device_id), "mdio", | ||
1016 | do_mdio_entry, mod); | ||
1017 | else if (sym_is(symname, "__mod_zorro_device_table")) | ||
1018 | do_table(symval, sym->st_size, | ||
1019 | sizeof(struct zorro_device_id), "zorro", | ||
1020 | do_zorro_entry, mod); | ||
1021 | else if (sym_is(symname, "__mod_isapnp_device_table")) | ||
1022 | do_table(symval, sym->st_size, | ||
1023 | sizeof(struct isapnp_device_id), "isa", | ||
1024 | do_isapnp_entry, mod); | ||
1169 | free(zeros); | 1025 | free(zeros); |
1170 | } | 1026 | } |
1171 | 1027 | ||
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index ff36c508a10..a509ff8f32f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -132,10 +132,8 @@ static struct module *new_module(char *modname) | |||
132 | /* strip trailing .o */ | 132 | /* strip trailing .o */ |
133 | s = strrchr(p, '.'); | 133 | s = strrchr(p, '.'); |
134 | if (s != NULL) | 134 | if (s != NULL) |
135 | if (strcmp(s, ".o") == 0) { | 135 | if (strcmp(s, ".o") == 0) |
136 | *s = '\0'; | 136 | *s = '\0'; |
137 | mod->is_dot_o = 1; | ||
138 | } | ||
139 | 137 | ||
140 | /* add to list */ | 138 | /* add to list */ |
141 | mod->name = p; | 139 | mod->name = p; |
@@ -337,20 +335,17 @@ static void sym_update_crc(const char *name, struct module *mod, | |||
337 | void *grab_file(const char *filename, unsigned long *size) | 335 | void *grab_file(const char *filename, unsigned long *size) |
338 | { | 336 | { |
339 | struct stat st; | 337 | struct stat st; |
340 | void *map = MAP_FAILED; | 338 | void *map; |
341 | int fd; | 339 | int fd; |
342 | 340 | ||
343 | fd = open(filename, O_RDONLY); | 341 | fd = open(filename, O_RDONLY); |
344 | if (fd < 0) | 342 | if (fd < 0 || fstat(fd, &st) != 0) |
345 | return NULL; | 343 | return NULL; |
346 | if (fstat(fd, &st)) | ||
347 | goto failed; | ||
348 | 344 | ||
349 | *size = st.st_size; | 345 | *size = st.st_size; |
350 | map = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); | 346 | map = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); |
351 | |||
352 | failed: | ||
353 | close(fd); | 347 | close(fd); |
348 | |||
354 | if (map == MAP_FAILED) | 349 | if (map == MAP_FAILED) |
355 | return NULL; | 350 | return NULL; |
356 | return map; | 351 | return map; |
@@ -592,8 +587,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
592 | unsigned int crc; | 587 | unsigned int crc; |
593 | enum export export; | 588 | enum export export; |
594 | 589 | ||
595 | if ((!is_vmlinux(mod->name) || mod->is_dot_o) && | 590 | if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0) |
596 | strncmp(symname, "__ksymtab", 9) == 0) | ||
597 | export = export_from_secname(info, get_secindex(info, sym)); | 591 | export = export_from_secname(info, get_secindex(info, sym)); |
598 | else | 592 | else |
599 | export = export_from_sec(info, get_secindex(info, sym)); | 593 | export = export_from_sec(info, get_secindex(info, sym)); |
@@ -821,15 +815,12 @@ static const char *section_white_list[] = | |||
821 | ".debug*", | 815 | ".debug*", |
822 | ".zdebug*", /* Compressed debug sections. */ | 816 | ".zdebug*", /* Compressed debug sections. */ |
823 | ".GCC-command-line", /* mn10300 */ | 817 | ".GCC-command-line", /* mn10300 */ |
824 | ".GCC.command.line", /* record-gcc-switches, non mn10300 */ | ||
825 | ".mdebug*", /* alpha, score, mips etc. */ | 818 | ".mdebug*", /* alpha, score, mips etc. */ |
826 | ".pdr", /* alpha, score, mips etc. */ | 819 | ".pdr", /* alpha, score, mips etc. */ |
827 | ".stab*", | 820 | ".stab*", |
828 | ".note*", | 821 | ".note*", |
829 | ".got*", | 822 | ".got*", |
830 | ".toc*", | 823 | ".toc*", |
831 | ".xt.prop", /* xtensa */ | ||
832 | ".xt.lit", /* xtensa */ | ||
833 | NULL | 824 | NULL |
834 | }; | 825 | }; |
835 | 826 | ||
@@ -858,23 +849,20 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
858 | 849 | ||
859 | #define ALL_INIT_DATA_SECTIONS \ | 850 | #define ALL_INIT_DATA_SECTIONS \ |
860 | ".init.setup$", ".init.rodata$", \ | 851 | ".init.setup$", ".init.rodata$", \ |
861 | ".cpuinit.rodata$", ".meminit.rodata$", \ | 852 | ".devinit.rodata$", ".cpuinit.rodata$", ".meminit.rodata$" \ |
862 | ".init.data$", ".cpuinit.data$", ".meminit.data$" | 853 | ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$" |
863 | #define ALL_EXIT_DATA_SECTIONS \ | 854 | #define ALL_EXIT_DATA_SECTIONS \ |
864 | ".exit.data$", ".cpuexit.data$", ".memexit.data$" | 855 | ".exit.data$", ".devexit.data$", ".cpuexit.data$", ".memexit.data$" |
865 | 856 | ||
866 | #define ALL_INIT_TEXT_SECTIONS \ | 857 | #define ALL_INIT_TEXT_SECTIONS \ |
867 | ".init.text$", ".cpuinit.text$", ".meminit.text$" | 858 | ".init.text$", ".devinit.text$", ".cpuinit.text$", ".meminit.text$" |
868 | #define ALL_EXIT_TEXT_SECTIONS \ | 859 | #define ALL_EXIT_TEXT_SECTIONS \ |
869 | ".exit.text$", ".cpuexit.text$", ".memexit.text$" | 860 | ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$" |
870 | |||
871 | #define ALL_PCI_INIT_SECTIONS \ | ||
872 | ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ | ||
873 | ".pci_fixup_enable$", ".pci_fixup_resume$", \ | ||
874 | ".pci_fixup_resume_early$", ".pci_fixup_suspend$" | ||
875 | 861 | ||
876 | #define ALL_XXXINIT_SECTIONS CPU_INIT_SECTIONS, MEM_INIT_SECTIONS | 862 | #define ALL_XXXINIT_SECTIONS DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, \ |
877 | #define ALL_XXXEXIT_SECTIONS CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS | 863 | MEM_INIT_SECTIONS |
864 | #define ALL_XXXEXIT_SECTIONS DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, \ | ||
865 | MEM_EXIT_SECTIONS | ||
878 | 866 | ||
879 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS | 867 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS |
880 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS | 868 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS |
@@ -883,10 +871,12 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
883 | #define TEXT_SECTIONS ".text$" | 871 | #define TEXT_SECTIONS ".text$" |
884 | 872 | ||
885 | #define INIT_SECTIONS ".init.*" | 873 | #define INIT_SECTIONS ".init.*" |
874 | #define DEV_INIT_SECTIONS ".devinit.*" | ||
886 | #define CPU_INIT_SECTIONS ".cpuinit.*" | 875 | #define CPU_INIT_SECTIONS ".cpuinit.*" |
887 | #define MEM_INIT_SECTIONS ".meminit.*" | 876 | #define MEM_INIT_SECTIONS ".meminit.*" |
888 | 877 | ||
889 | #define EXIT_SECTIONS ".exit.*" | 878 | #define EXIT_SECTIONS ".exit.*" |
879 | #define DEV_EXIT_SECTIONS ".devexit.*" | ||
890 | #define CPU_EXIT_SECTIONS ".cpuexit.*" | 880 | #define CPU_EXIT_SECTIONS ".cpuexit.*" |
891 | #define MEM_EXIT_SECTIONS ".memexit.*" | 881 | #define MEM_EXIT_SECTIONS ".memexit.*" |
892 | 882 | ||
@@ -975,7 +965,7 @@ const struct sectioncheck sectioncheck[] = { | |||
975 | .mismatch = DATA_TO_ANY_EXIT, | 965 | .mismatch = DATA_TO_ANY_EXIT, |
976 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 966 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
977 | }, | 967 | }, |
978 | /* Do not reference init code/data from cpuinit/meminit code/data */ | 968 | /* Do not reference init code/data from devinit/cpuinit/meminit code/data */ |
979 | { | 969 | { |
980 | .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, | 970 | .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, |
981 | .tosec = { INIT_SECTIONS, NULL }, | 971 | .tosec = { INIT_SECTIONS, NULL }, |
@@ -996,7 +986,7 @@ const struct sectioncheck sectioncheck[] = { | |||
996 | .mismatch = XXXINIT_TO_SOME_INIT, | 986 | .mismatch = XXXINIT_TO_SOME_INIT, |
997 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 987 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
998 | }, | 988 | }, |
999 | /* Do not reference exit code/data from cpuexit/memexit code/data */ | 989 | /* Do not reference exit code/data from devexit/cpuexit/memexit code/data */ |
1000 | { | 990 | { |
1001 | .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, | 991 | .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, |
1002 | .tosec = { EXIT_SECTIONS, NULL }, | 992 | .tosec = { EXIT_SECTIONS, NULL }, |
@@ -1031,12 +1021,6 @@ const struct sectioncheck sectioncheck[] = { | |||
1031 | .mismatch = ANY_EXIT_TO_ANY_INIT, | 1021 | .mismatch = ANY_EXIT_TO_ANY_INIT, |
1032 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1022 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
1033 | }, | 1023 | }, |
1034 | { | ||
1035 | .fromsec = { ALL_PCI_INIT_SECTIONS, NULL }, | ||
1036 | .tosec = { INIT_SECTIONS, NULL }, | ||
1037 | .mismatch = ANY_INIT_TO_ANY_EXIT, | ||
1038 | .symbol_white_list = { NULL }, | ||
1039 | }, | ||
1040 | /* Do not export init/exit functions or data */ | 1024 | /* Do not export init/exit functions or data */ |
1041 | { | 1025 | { |
1042 | .fromsec = { "__ksymtab*", NULL }, | 1026 | .fromsec = { "__ksymtab*", NULL }, |
@@ -1085,7 +1069,7 @@ static const struct sectioncheck *section_mismatch( | |||
1085 | * Pattern 2: | 1069 | * Pattern 2: |
1086 | * Many drivers utilise a *driver container with references to | 1070 | * Many drivers utilise a *driver container with references to |
1087 | * add, remove, probe functions etc. | 1071 | * add, remove, probe functions etc. |
1088 | * These functions may often be marked __cpuinit and we do not want to | 1072 | * These functions may often be marked __devinit and we do not want to |
1089 | * warn here. | 1073 | * warn here. |
1090 | * the pattern is identified by: | 1074 | * the pattern is identified by: |
1091 | * tosec = init or exit section | 1075 | * tosec = init or exit section |
@@ -1510,13 +1494,6 @@ static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) | |||
1510 | return 0; | 1494 | return 0; |
1511 | } | 1495 | } |
1512 | 1496 | ||
1513 | #ifndef R_ARM_CALL | ||
1514 | #define R_ARM_CALL 28 | ||
1515 | #endif | ||
1516 | #ifndef R_ARM_JUMP24 | ||
1517 | #define R_ARM_JUMP24 29 | ||
1518 | #endif | ||
1519 | |||
1520 | static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) | 1497 | static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) |
1521 | { | 1498 | { |
1522 | unsigned int r_typ = ELF_R_TYPE(r->r_info); | 1499 | unsigned int r_typ = ELF_R_TYPE(r->r_info); |
@@ -1528,8 +1505,6 @@ static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) | |||
1528 | (elf->symtab_start + ELF_R_SYM(r->r_info)); | 1505 | (elf->symtab_start + ELF_R_SYM(r->r_info)); |
1529 | break; | 1506 | break; |
1530 | case R_ARM_PC24: | 1507 | case R_ARM_PC24: |
1531 | case R_ARM_CALL: | ||
1532 | case R_ARM_JUMP24: | ||
1533 | /* From ARM ABI: ((S + A) | T) - P */ | 1508 | /* From ARM ABI: ((S + A) | T) - P */ |
1534 | r->r_addend = (int)(long)(elf->hdr + | 1509 | r->r_addend = (int)(long)(elf->hdr + |
1535 | sechdr->sh_offset + | 1510 | sechdr->sh_offset + |
@@ -1863,23 +1838,17 @@ static void add_header(struct buffer *b, struct module *mod) | |||
1863 | buf_printf(b, "\n"); | 1838 | buf_printf(b, "\n"); |
1864 | buf_printf(b, "struct module __this_module\n"); | 1839 | buf_printf(b, "struct module __this_module\n"); |
1865 | buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); | 1840 | buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); |
1866 | buf_printf(b, "\t.name = KBUILD_MODNAME,\n"); | 1841 | buf_printf(b, " .name = KBUILD_MODNAME,\n"); |
1867 | if (mod->has_init) | 1842 | if (mod->has_init) |
1868 | buf_printf(b, "\t.init = init_module,\n"); | 1843 | buf_printf(b, " .init = init_module,\n"); |
1869 | if (mod->has_cleanup) | 1844 | if (mod->has_cleanup) |
1870 | buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n" | 1845 | buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n" |
1871 | "\t.exit = cleanup_module,\n" | 1846 | " .exit = cleanup_module,\n" |
1872 | "#endif\n"); | 1847 | "#endif\n"); |
1873 | buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n"); | 1848 | buf_printf(b, " .arch = MODULE_ARCH_INIT,\n"); |
1874 | buf_printf(b, "};\n"); | 1849 | buf_printf(b, "};\n"); |
1875 | } | 1850 | } |
1876 | 1851 | ||
1877 | static void add_intree_flag(struct buffer *b, int is_intree) | ||
1878 | { | ||
1879 | if (is_intree) | ||
1880 | buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); | ||
1881 | } | ||
1882 | |||
1883 | static void add_staging_flag(struct buffer *b, const char *name) | 1852 | static void add_staging_flag(struct buffer *b, const char *name) |
1884 | { | 1853 | { |
1885 | static const char *staging_dir = "drivers/staging"; | 1854 | static const char *staging_dir = "drivers/staging"; |
@@ -2200,7 +2169,6 @@ int main(int argc, char **argv) | |||
2200 | buf.pos = 0; | 2169 | buf.pos = 0; |
2201 | 2170 | ||
2202 | add_header(&buf, mod); | 2171 | add_header(&buf, mod); |
2203 | add_intree_flag(&buf, !external_module); | ||
2204 | add_staging_flag(&buf, mod->name); | 2172 | add_staging_flag(&buf, mod->name); |
2205 | err |= add_versions(&buf, mod); | 2173 | err |= add_versions(&buf, mod); |
2206 | add_depends(&buf, mod, modules); | 2174 | add_depends(&buf, mod, modules); |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 51207e4d5f8..2031119080d 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -113,7 +113,6 @@ struct module { | |||
113 | int has_cleanup; | 113 | int has_cleanup; |
114 | struct buffer dev_table_buf; | 114 | struct buffer dev_table_buf; |
115 | char srcversion[25]; | 115 | char srcversion[25]; |
116 | int is_dot_o; | ||
117 | }; | 116 | }; |
118 | 117 | ||
119 | struct elf_info { | 118 | struct elf_info { |
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 87bf08076b1..bc6aa003860 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
@@ -141,7 +141,7 @@ perf-%pkg: FORCE | |||
141 | help: FORCE | 141 | help: FORCE |
142 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' | 142 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' |
143 | @echo ' binrpm-pkg - Build only the binary kernel package' | 143 | @echo ' binrpm-pkg - Build only the binary kernel package' |
144 | @echo ' deb-pkg - Build the kernel as a deb package' | 144 | @echo ' deb-pkg - Build the kernel as an deb package' |
145 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' | 145 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' |
146 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' | 146 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' |
147 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' | 147 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' |
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index acb86507828..f6cbc3ddb68 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
@@ -92,12 +92,11 @@ rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" | |||
92 | mkdir -m 755 -p "$tmpdir/DEBIAN" | 92 | mkdir -m 755 -p "$tmpdir/DEBIAN" |
93 | mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" | 93 | mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" |
94 | mkdir -m 755 -p "$fwdir/DEBIAN" | 94 | mkdir -m 755 -p "$fwdir/DEBIAN" |
95 | mkdir -p "$fwdir/lib/firmware/$version/" "$fwdir/usr/share/doc/$fwpackagename" | 95 | mkdir -p "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename" |
96 | mkdir -m 755 -p "$libc_headers_dir/DEBIAN" | 96 | mkdir -m 755 -p "$libc_headers_dir/DEBIAN" |
97 | mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename" | 97 | mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename" |
98 | mkdir -m 755 -p "$kernel_headers_dir/DEBIAN" | 98 | mkdir -m 755 -p "$kernel_headers_dir/DEBIAN" |
99 | mkdir -p "$kernel_headers_dir/usr/share/doc/$kernel_headers_packagename" | 99 | mkdir -p "$kernel_headers_dir/usr/share/doc/$kernel_headers_packagename" |
100 | mkdir -p "$kernel_headers_dir/lib/modules/$version/" | ||
101 | if [ "$ARCH" = "um" ] ; then | 100 | if [ "$ARCH" = "um" ] ; then |
102 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" | 101 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" |
103 | fi | 102 | fi |
@@ -121,19 +120,15 @@ else | |||
121 | fi | 120 | fi |
122 | 121 | ||
123 | if grep -q '^CONFIG_MODULES=y' .config ; then | 122 | if grep -q '^CONFIG_MODULES=y' .config ; then |
124 | INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install | 123 | INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install |
125 | rm -f "$tmpdir/lib/modules/$version/build" | ||
126 | rm -f "$tmpdir/lib/modules/$version/source" | ||
127 | if [ "$ARCH" = "um" ] ; then | 124 | if [ "$ARCH" = "um" ] ; then |
128 | mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" | 125 | mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" |
129 | rmdir "$tmpdir/lib/modules/$version" | 126 | rmdir "$tmpdir/lib/modules/$version" |
130 | fi | 127 | fi |
131 | fi | 128 | fi |
132 | 129 | ||
133 | if [ "$ARCH" != "um" ]; then | 130 | make headers_check |
134 | $MAKE headers_check KBUILD_SRC= | 131 | make headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr" |
135 | $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" | ||
136 | fi | ||
137 | 132 | ||
138 | # Install the maintainer scripts | 133 | # Install the maintainer scripts |
139 | # Note: hook scripts under /etc/kernel are also executed by official Debian | 134 | # Note: hook scripts under /etc/kernel are also executed by official Debian |
@@ -243,15 +238,14 @@ EOF | |||
243 | fi | 238 | fi |
244 | 239 | ||
245 | # Build header package | 240 | # Build header package |
246 | (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") | 241 | (cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$) |
247 | (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles") | 242 | (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> /tmp/files$$) |
248 | (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") | 243 | (cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$) |
249 | destdir=$kernel_headers_dir/usr/src/linux-headers-$version | 244 | destdir=$kernel_headers_dir/usr/src/linux-headers-$version |
250 | mkdir -p "$destdir" | 245 | mkdir -p "$destdir" |
251 | (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -) | 246 | (cd $srctree; tar -c -f - -T /tmp/files$$) | (cd $destdir; tar -xf -) |
252 | (cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -) | 247 | (cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -) |
253 | ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" | 248 | rm -f /tmp/files$$ /tmp/objfiles$$ |
254 | rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" | ||
255 | arch=$(dpkg --print-architecture) | 249 | arch=$(dpkg --print-architecture) |
256 | 250 | ||
257 | cat <<EOF >> debian/control | 251 | cat <<EOF >> debian/control |
@@ -265,10 +259,11 @@ Description: Linux kernel headers for $KERNELRELEASE on $arch | |||
265 | This is useful for people who need to build external modules | 259 | This is useful for people who need to build external modules |
266 | EOF | 260 | EOF |
267 | 261 | ||
262 | create_package "$kernel_headers_packagename" "$kernel_headers_dir" | ||
263 | |||
268 | # Do we have firmware? Move it out of the way and build it into a package. | 264 | # Do we have firmware? Move it out of the way and build it into a package. |
269 | if [ -e "$tmpdir/lib/firmware" ]; then | 265 | if [ -e "$tmpdir/lib/firmware" ]; then |
270 | mv "$tmpdir/lib/firmware"/* "$fwdir/lib/firmware/$version/" | 266 | mv "$tmpdir/lib/firmware" "$fwdir/lib/" |
271 | rmdir "$tmpdir/lib/firmware" | ||
272 | 267 | ||
273 | cat <<EOF >> debian/control | 268 | cat <<EOF >> debian/control |
274 | 269 | ||
@@ -292,11 +287,7 @@ Description: Linux support headers for userspace development | |||
292 | are used by the installed headers for GNU glibc and other system libraries. | 287 | are used by the installed headers for GNU glibc and other system libraries. |
293 | EOF | 288 | EOF |
294 | 289 | ||
295 | if [ "$ARCH" != "um" ]; then | 290 | create_package "$libc_headers_packagename" "$libc_headers_dir" |
296 | create_package "$kernel_headers_packagename" "$kernel_headers_dir" | ||
297 | create_package "$libc_headers_packagename" "$libc_headers_dir" | ||
298 | fi | ||
299 | |||
300 | create_package "$packagename" "$tmpdir" | 291 | create_package "$packagename" "$tmpdir" |
301 | 292 | ||
302 | exit 0 | 293 | exit 0 |
diff --git a/scripts/package/buildtar b/scripts/package/buildtar index 62d8234f878..8a7b15598ea 100644 --- a/scripts/package/buildtar +++ b/scripts/package/buildtar | |||
@@ -28,15 +28,15 @@ case "${1}" in | |||
28 | file_ext="" | 28 | file_ext="" |
29 | ;; | 29 | ;; |
30 | targz-pkg) | 30 | targz-pkg) |
31 | compress="gzip" | 31 | compress="gzip -c9" |
32 | file_ext=".gz" | 32 | file_ext=".gz" |
33 | ;; | 33 | ;; |
34 | tarbz2-pkg) | 34 | tarbz2-pkg) |
35 | compress="bzip2" | 35 | compress="bzip2 -c9" |
36 | file_ext=".bz2" | 36 | file_ext=".bz2" |
37 | ;; | 37 | ;; |
38 | tarxz-pkg) | 38 | tarxz-pkg) |
39 | compress="xz" | 39 | compress="xz -c9" |
40 | file_ext=".xz" | 40 | file_ext=".xz" |
41 | ;; | 41 | ;; |
42 | *) | 42 | *) |
@@ -109,7 +109,7 @@ esac | |||
109 | if tar --owner=root --group=root --help >/dev/null 2>&1; then | 109 | if tar --owner=root --group=root --help >/dev/null 2>&1; then |
110 | opts="--owner=root --group=root" | 110 | opts="--owner=root --group=root" |
111 | fi | 111 | fi |
112 | tar cf - boot/* lib/* $opts | ${compress} > "${tarball}${file_ext}" | 112 | tar cf - . $opts | ${compress} > "${tarball}${file_ext}" |
113 | ) | 113 | ) |
114 | 114 | ||
115 | echo "Tarball successfully created in ${tarball}${file_ext}" | 115 | echo "Tarball successfully created in ${tarball}${file_ext}" |
diff --git a/scripts/patch-kernel b/scripts/patch-kernel index d000ea3a41f..20fb25c2338 100755 --- a/scripts/patch-kernel +++ b/scripts/patch-kernel | |||
@@ -116,10 +116,6 @@ findFile () { | |||
116 | ext=".bz2" | 116 | ext=".bz2" |
117 | name="bzip2" | 117 | name="bzip2" |
118 | uncomp="bunzip2 -dc" | 118 | uncomp="bunzip2 -dc" |
119 | elif [ -r ${filebase}.xz ]; then | ||
120 | ext=".xz" | ||
121 | name="xz" | ||
122 | uncomp="xz -dc" | ||
123 | elif [ -r ${filebase}.zip ]; then | 119 | elif [ -r ${filebase}.zip ]; then |
124 | ext=".zip" | 120 | ext=".zip" |
125 | name="zip" | 121 | name="zip" |
diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c index 68bb4efc5af..5c113123ed9 100644 --- a/scripts/pnmtologo.c +++ b/scripts/pnmtologo.c | |||
@@ -74,7 +74,6 @@ static unsigned int logo_height; | |||
74 | static struct color **logo_data; | 74 | static struct color **logo_data; |
75 | static struct color logo_clut[MAX_LINUX_LOGO_COLORS]; | 75 | static struct color logo_clut[MAX_LINUX_LOGO_COLORS]; |
76 | static unsigned int logo_clutsize; | 76 | static unsigned int logo_clutsize; |
77 | static int is_plain_pbm = 0; | ||
78 | 77 | ||
79 | static void die(const char *fmt, ...) | 78 | static void die(const char *fmt, ...) |
80 | __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); | 79 | __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); |
@@ -104,11 +103,6 @@ static unsigned int get_number(FILE *fp) | |||
104 | val = 0; | 103 | val = 0; |
105 | while (isdigit(c)) { | 104 | while (isdigit(c)) { |
106 | val = 10*val+c-'0'; | 105 | val = 10*val+c-'0'; |
107 | /* some PBM are 'broken'; GiMP for example exports a PBM without space | ||
108 | * between the digits. This is Ok cause we know a PBM can only have a '1' | ||
109 | * or a '0' for the digit. */ | ||
110 | if (is_plain_pbm) | ||
111 | break; | ||
112 | c = fgetc(fp); | 106 | c = fgetc(fp); |
113 | if (c == EOF) | 107 | if (c == EOF) |
114 | die("%s: end of file\n", filename); | 108 | die("%s: end of file\n", filename); |
@@ -173,7 +167,6 @@ static void read_image(void) | |||
173 | switch (magic) { | 167 | switch (magic) { |
174 | case '1': | 168 | case '1': |
175 | /* Plain PBM */ | 169 | /* Plain PBM */ |
176 | is_plain_pbm = 1; | ||
177 | for (i = 0; i < logo_height; i++) | 170 | for (i = 0; i < logo_height; i++) |
178 | for (j = 0; j < logo_width; j++) | 171 | for (j = 0; j < logo_width; j++) |
179 | logo_data[i][j].red = logo_data[i][j].green = | 172 | logo_data[i][j].red = logo_data[i][j].green = |
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h index 9d1421e63ff..f40a6af6bf4 100644 --- a/scripts/recordmcount.h +++ b/scripts/recordmcount.h | |||
@@ -261,13 +261,11 @@ static unsigned get_mcountsym(Elf_Sym const *const sym0, | |||
261 | &sym0[Elf_r_sym(relp)]; | 261 | &sym0[Elf_r_sym(relp)]; |
262 | char const *symname = &str0[w(symp->st_name)]; | 262 | char const *symname = &str0[w(symp->st_name)]; |
263 | char const *mcount = gpfx == '_' ? "_mcount" : "mcount"; | 263 | char const *mcount = gpfx == '_' ? "_mcount" : "mcount"; |
264 | char const *fentry = "__fentry__"; | ||
265 | 264 | ||
266 | if (symname[0] == '.') | 265 | if (symname[0] == '.') |
267 | ++symname; /* ppc64 hack */ | 266 | ++symname; /* ppc64 hack */ |
268 | if (strcmp(mcount, symname) == 0 || | 267 | if (strcmp(mcount, symname) == 0 || |
269 | (altmcount && strcmp(altmcount, symname) == 0) || | 268 | (altmcount && strcmp(altmcount, symname) == 0)) |
270 | (strcmp(fentry, symname) == 0)) | ||
271 | mcountsym = Elf_r_sym(relp); | 269 | mcountsym = Elf_r_sym(relp); |
272 | 270 | ||
273 | return mcountsym; | 271 | return mcountsym; |
@@ -464,7 +462,7 @@ __has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */ | |||
464 | succeed_file(); | 462 | succeed_file(); |
465 | } | 463 | } |
466 | if (w(txthdr->sh_type) != SHT_PROGBITS || | 464 | if (w(txthdr->sh_type) != SHT_PROGBITS || |
467 | !(_w(txthdr->sh_flags) & SHF_EXECINSTR)) | 465 | !(w(txthdr->sh_flags) & SHF_EXECINSTR)) |
468 | return NULL; | 466 | return NULL; |
469 | return txtname; | 467 | return txtname; |
470 | } | 468 | } |
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index bd6dca8a0ab..8d9a5edd9c6 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion | |||
@@ -33,6 +33,12 @@ scm_version() | |||
33 | local short | 33 | local short |
34 | short=false | 34 | short=false |
35 | 35 | ||
36 | system=`echo $TARGET_SYSTEM` | ||
37 | if [ "$system" = "CARMA" ]; then | ||
38 | printf '%s' -carma | ||
39 | return | ||
40 | fi | ||
41 | |||
36 | cd "$srctree" | 42 | cd "$srctree" |
37 | if test -e .scmversion; then | 43 | if test -e .scmversion; then |
38 | cat .scmversion | 44 | cat .scmversion |
@@ -75,7 +81,8 @@ scm_version() | |||
75 | [ -w . ] && git update-index --refresh --unmerged > /dev/null | 81 | [ -w . ] && git update-index --refresh --unmerged > /dev/null |
76 | 82 | ||
77 | # Check for uncommitted changes | 83 | # Check for uncommitted changes |
78 | if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then | 84 | if git diff-index --name-only HEAD | grep -v "^scripts/package" \ |
85 | | read dummy; then | ||
79 | printf '%s' -dirty | 86 | printf '%s' -dirty |
80 | fi | 87 | fi |
81 | 88 | ||
diff --git a/scripts/sign-file b/scripts/sign-file deleted file mode 100755 index 974a20b661b..00000000000 --- a/scripts/sign-file +++ /dev/null | |||
@@ -1,429 +0,0 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # | ||
3 | # Sign a module file using the given key. | ||
4 | # | ||
5 | # Format: | ||
6 | # | ||
7 | # ./scripts/sign-file [-v] <key> <x509> <module> [<dest>] | ||
8 | # | ||
9 | # | ||
10 | use strict; | ||
11 | use FileHandle; | ||
12 | use IPC::Open2; | ||
13 | |||
14 | my $verbose = 0; | ||
15 | if ($#ARGV >= 0 && $ARGV[0] eq "-v") { | ||
16 | $verbose = 1; | ||
17 | shift; | ||
18 | } | ||
19 | |||
20 | die "Format: ./scripts/sign-file [-v] <key> <x509> <module> [<dest>]\n" | ||
21 | if ($#ARGV != 2 && $#ARGV != 3); | ||
22 | |||
23 | my $private_key = $ARGV[0]; | ||
24 | my $x509 = $ARGV[1]; | ||
25 | my $module = $ARGV[2]; | ||
26 | my $dest = ($#ARGV == 3) ? $ARGV[3] : $ARGV[2] . "~"; | ||
27 | |||
28 | die "Can't read private key\n" unless (-r $private_key); | ||
29 | die "Can't read X.509 certificate\n" unless (-r $x509); | ||
30 | die "Can't read module\n" unless (-r $module); | ||
31 | |||
32 | # | ||
33 | # Read the kernel configuration | ||
34 | # | ||
35 | my %config = ( | ||
36 | CONFIG_MODULE_SIG_SHA512 => 1 | ||
37 | ); | ||
38 | |||
39 | if (-r ".config") { | ||
40 | open(FD, "<.config") || die ".config"; | ||
41 | while (<FD>) { | ||
42 | if ($_ =~ /^(CONFIG_.*)=[ym]/) { | ||
43 | $config{$1} = 1; | ||
44 | } | ||
45 | } | ||
46 | close(FD); | ||
47 | } | ||
48 | |||
49 | # | ||
50 | # Function to read the contents of a file into a variable. | ||
51 | # | ||
52 | sub read_file($) | ||
53 | { | ||
54 | my ($file) = @_; | ||
55 | my $contents; | ||
56 | my $len; | ||
57 | |||
58 | open(FD, "<$file") || die $file; | ||
59 | binmode FD; | ||
60 | my @st = stat(FD); | ||
61 | die $file if (!@st); | ||
62 | $len = read(FD, $contents, $st[7]) || die $file; | ||
63 | close(FD) || die $file; | ||
64 | die "$file: Wanted length ", $st[7], ", got ", $len, "\n" | ||
65 | if ($len != $st[7]); | ||
66 | return $contents; | ||
67 | } | ||
68 | |||
69 | ############################################################################### | ||
70 | # | ||
71 | # First of all, we have to parse the X.509 certificate to find certain details | ||
72 | # about it. | ||
73 | # | ||
74 | # We read the DER-encoded X509 certificate and parse it to extract the Subject | ||
75 | # name and Subject Key Identifier. Theis provides the data we need to build | ||
76 | # the certificate identifier. | ||
77 | # | ||
78 | # The signer's name part of the identifier is fabricated from the commonName, | ||
79 | # the organizationName or the emailAddress components of the X.509 subject | ||
80 | # name. | ||
81 | # | ||
82 | # The subject key ID is used to select which of that signer's certificates | ||
83 | # we're intending to use to sign the module. | ||
84 | # | ||
85 | ############################################################################### | ||
86 | my $x509_certificate = read_file($x509); | ||
87 | |||
88 | my $UNIV = 0 << 6; | ||
89 | my $APPL = 1 << 6; | ||
90 | my $CONT = 2 << 6; | ||
91 | my $PRIV = 3 << 6; | ||
92 | |||
93 | my $CONS = 0x20; | ||
94 | |||
95 | my $BOOLEAN = 0x01; | ||
96 | my $INTEGER = 0x02; | ||
97 | my $BIT_STRING = 0x03; | ||
98 | my $OCTET_STRING = 0x04; | ||
99 | my $NULL = 0x05; | ||
100 | my $OBJ_ID = 0x06; | ||
101 | my $UTF8String = 0x0c; | ||
102 | my $SEQUENCE = 0x10; | ||
103 | my $SET = 0x11; | ||
104 | my $UTCTime = 0x17; | ||
105 | my $GeneralizedTime = 0x18; | ||
106 | |||
107 | my %OIDs = ( | ||
108 | pack("CCC", 85, 4, 3) => "commonName", | ||
109 | pack("CCC", 85, 4, 6) => "countryName", | ||
110 | pack("CCC", 85, 4, 10) => "organizationName", | ||
111 | pack("CCC", 85, 4, 11) => "organizationUnitName", | ||
112 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 1) => "rsaEncryption", | ||
113 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 5) => "sha1WithRSAEncryption", | ||
114 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 9, 1) => "emailAddress", | ||
115 | pack("CCC", 85, 29, 35) => "authorityKeyIdentifier", | ||
116 | pack("CCC", 85, 29, 14) => "subjectKeyIdentifier", | ||
117 | pack("CCC", 85, 29, 19) => "basicConstraints" | ||
118 | ); | ||
119 | |||
120 | ############################################################################### | ||
121 | # | ||
122 | # Extract an ASN.1 element from a string and return information about it. | ||
123 | # | ||
124 | ############################################################################### | ||
125 | sub asn1_extract($$@) | ||
126 | { | ||
127 | my ($cursor, $expected_tag, $optional) = @_; | ||
128 | |||
129 | return [ -1 ] | ||
130 | if ($cursor->[1] == 0 && $optional); | ||
131 | |||
132 | die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (elem ", $cursor->[1], ")\n" | ||
133 | if ($cursor->[1] < 2); | ||
134 | |||
135 | my ($tag, $len) = unpack("CC", substr(${$cursor->[2]}, $cursor->[0], 2)); | ||
136 | |||
137 | if ($expected_tag != -1 && $tag != $expected_tag) { | ||
138 | return [ -1 ] | ||
139 | if ($optional); | ||
140 | die $x509, ": ", $cursor->[0], ": ASN.1 unexpected tag (", $tag, | ||
141 | " not ", $expected_tag, ")\n"; | ||
142 | } | ||
143 | |||
144 | $cursor->[0] += 2; | ||
145 | $cursor->[1] -= 2; | ||
146 | |||
147 | die $x509, ": ", $cursor->[0], ": ASN.1 long tag\n" | ||
148 | if (($tag & 0x1f) == 0x1f); | ||
149 | die $x509, ": ", $cursor->[0], ": ASN.1 indefinite length\n" | ||
150 | if ($len == 0x80); | ||
151 | |||
152 | if ($len > 0x80) { | ||
153 | my $l = $len - 0x80; | ||
154 | die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (len len $l)\n" | ||
155 | if ($cursor->[1] < $l); | ||
156 | |||
157 | if ($l == 0x1) { | ||
158 | $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)); | ||
159 | } elsif ($l == 0x2) { | ||
160 | $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2)); | ||
161 | } elsif ($l == 0x3) { | ||
162 | $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16; | ||
163 | $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2)); | ||
164 | } elsif ($l == 0x4) { | ||
165 | $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4)); | ||
166 | } else { | ||
167 | die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n"; | ||
168 | } | ||
169 | |||
170 | $cursor->[0] += $l; | ||
171 | $cursor->[1] -= $l; | ||
172 | } | ||
173 | |||
174 | die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (", $len, ")\n" | ||
175 | if ($cursor->[1] < $len); | ||
176 | |||
177 | my $ret = [ $tag, [ $cursor->[0], $len, $cursor->[2] ] ]; | ||
178 | $cursor->[0] += $len; | ||
179 | $cursor->[1] -= $len; | ||
180 | |||
181 | return $ret; | ||
182 | } | ||
183 | |||
184 | ############################################################################### | ||
185 | # | ||
186 | # Retrieve the data referred to by a cursor | ||
187 | # | ||
188 | ############################################################################### | ||
189 | sub asn1_retrieve($) | ||
190 | { | ||
191 | my ($cursor) = @_; | ||
192 | my ($offset, $len, $data) = @$cursor; | ||
193 | return substr($$data, $offset, $len); | ||
194 | } | ||
195 | |||
196 | ############################################################################### | ||
197 | # | ||
198 | # Roughly parse the X.509 certificate | ||
199 | # | ||
200 | ############################################################################### | ||
201 | my $cursor = [ 0, length($x509_certificate), \$x509_certificate ]; | ||
202 | |||
203 | my $cert = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE); | ||
204 | my $tbs = asn1_extract($cert->[1], $UNIV | $CONS | $SEQUENCE); | ||
205 | my $version = asn1_extract($tbs->[1], $CONT | $CONS | 0, 1); | ||
206 | my $serial_number = asn1_extract($tbs->[1], $UNIV | $INTEGER); | ||
207 | my $sig_type = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
208 | my $issuer = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
209 | my $validity = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
210 | my $subject = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
211 | my $key = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
212 | my $issuer_uid = asn1_extract($tbs->[1], $CONT | $CONS | 1, 1); | ||
213 | my $subject_uid = asn1_extract($tbs->[1], $CONT | $CONS | 2, 1); | ||
214 | my $extension_list = asn1_extract($tbs->[1], $CONT | $CONS | 3, 1); | ||
215 | |||
216 | my $subject_key_id = (); | ||
217 | my $authority_key_id = (); | ||
218 | |||
219 | # | ||
220 | # Parse the extension list | ||
221 | # | ||
222 | if ($extension_list->[0] != -1) { | ||
223 | my $extensions = asn1_extract($extension_list->[1], $UNIV | $CONS | $SEQUENCE); | ||
224 | |||
225 | while ($extensions->[1]->[1] > 0) { | ||
226 | my $ext = asn1_extract($extensions->[1], $UNIV | $CONS | $SEQUENCE); | ||
227 | my $x_oid = asn1_extract($ext->[1], $UNIV | $OBJ_ID); | ||
228 | my $x_crit = asn1_extract($ext->[1], $UNIV | $BOOLEAN, 1); | ||
229 | my $x_val = asn1_extract($ext->[1], $UNIV | $OCTET_STRING); | ||
230 | |||
231 | my $raw_oid = asn1_retrieve($x_oid->[1]); | ||
232 | next if (!exists($OIDs{$raw_oid})); | ||
233 | my $x_type = $OIDs{$raw_oid}; | ||
234 | |||
235 | my $raw_value = asn1_retrieve($x_val->[1]); | ||
236 | |||
237 | if ($x_type eq "subjectKeyIdentifier") { | ||
238 | my $vcursor = [ 0, length($raw_value), \$raw_value ]; | ||
239 | |||
240 | $subject_key_id = asn1_extract($vcursor, $UNIV | $OCTET_STRING); | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | |||
245 | ############################################################################### | ||
246 | # | ||
247 | # Determine what we're going to use as the signer's name. In order of | ||
248 | # preference, take one of: commonName, organizationName or emailAddress. | ||
249 | # | ||
250 | ############################################################################### | ||
251 | my $org = ""; | ||
252 | my $cn = ""; | ||
253 | my $email = ""; | ||
254 | |||
255 | while ($subject->[1]->[1] > 0) { | ||
256 | my $rdn = asn1_extract($subject->[1], $UNIV | $CONS | $SET); | ||
257 | my $attr = asn1_extract($rdn->[1], $UNIV | $CONS | $SEQUENCE); | ||
258 | my $n_oid = asn1_extract($attr->[1], $UNIV | $OBJ_ID); | ||
259 | my $n_val = asn1_extract($attr->[1], -1); | ||
260 | |||
261 | my $raw_oid = asn1_retrieve($n_oid->[1]); | ||
262 | next if (!exists($OIDs{$raw_oid})); | ||
263 | my $n_type = $OIDs{$raw_oid}; | ||
264 | |||
265 | my $raw_value = asn1_retrieve($n_val->[1]); | ||
266 | |||
267 | if ($n_type eq "organizationName") { | ||
268 | $org = $raw_value; | ||
269 | } elsif ($n_type eq "commonName") { | ||
270 | $cn = $raw_value; | ||
271 | } elsif ($n_type eq "emailAddress") { | ||
272 | $email = $raw_value; | ||
273 | } | ||
274 | } | ||
275 | |||
276 | my $signers_name = $email; | ||
277 | |||
278 | if ($org && $cn) { | ||
279 | # Don't use the organizationName if the commonName repeats it | ||
280 | if (length($org) <= length($cn) && | ||
281 | substr($cn, 0, length($org)) eq $org) { | ||
282 | $signers_name = $cn; | ||
283 | goto got_id_name; | ||
284 | } | ||
285 | |||
286 | # Or a signifcant chunk of it | ||
287 | if (length($org) >= 7 && | ||
288 | length($cn) >= 7 && | ||
289 | substr($cn, 0, 7) eq substr($org, 0, 7)) { | ||
290 | $signers_name = $cn; | ||
291 | goto got_id_name; | ||
292 | } | ||
293 | |||
294 | $signers_name = $org . ": " . $cn; | ||
295 | } elsif ($org) { | ||
296 | $signers_name = $org; | ||
297 | } elsif ($cn) { | ||
298 | $signers_name = $cn; | ||
299 | } | ||
300 | |||
301 | got_id_name: | ||
302 | |||
303 | die $x509, ": ", "X.509: Couldn't find the Subject Key Identifier extension\n" | ||
304 | if (!$subject_key_id); | ||
305 | |||
306 | my $key_identifier = asn1_retrieve($subject_key_id->[1]); | ||
307 | |||
308 | ############################################################################### | ||
309 | # | ||
310 | # Create and attach the module signature | ||
311 | # | ||
312 | ############################################################################### | ||
313 | |||
314 | # | ||
315 | # Signature parameters | ||
316 | # | ||
317 | my $algo = 1; # Public-key crypto algorithm: RSA | ||
318 | my $hash = 0; # Digest algorithm | ||
319 | my $id_type = 1; # Identifier type: X.509 | ||
320 | |||
321 | # | ||
322 | # Digest the data | ||
323 | # | ||
324 | my ($dgst, $prologue) = (); | ||
325 | if (exists $config{"CONFIG_MODULE_SIG_SHA1"}) { | ||
326 | $prologue = pack("C*", | ||
327 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | ||
328 | 0x2B, 0x0E, 0x03, 0x02, 0x1A, | ||
329 | 0x05, 0x00, 0x04, 0x14); | ||
330 | $dgst = "-sha1"; | ||
331 | $hash = 2; | ||
332 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA224"}) { | ||
333 | $prologue = pack("C*", | ||
334 | 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, | ||
335 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, | ||
336 | 0x05, 0x00, 0x04, 0x1C); | ||
337 | $dgst = "-sha224"; | ||
338 | $hash = 7; | ||
339 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA256"}) { | ||
340 | $prologue = pack("C*", | ||
341 | 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, | ||
342 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, | ||
343 | 0x05, 0x00, 0x04, 0x20); | ||
344 | $dgst = "-sha256"; | ||
345 | $hash = 4; | ||
346 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA384"}) { | ||
347 | $prologue = pack("C*", | ||
348 | 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, | ||
349 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, | ||
350 | 0x05, 0x00, 0x04, 0x30); | ||
351 | $dgst = "-sha384"; | ||
352 | $hash = 5; | ||
353 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA512"}) { | ||
354 | $prologue = pack("C*", | ||
355 | 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, | ||
356 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, | ||
357 | 0x05, 0x00, 0x04, 0x40); | ||
358 | $dgst = "-sha512"; | ||
359 | $hash = 6; | ||
360 | } else { | ||
361 | die "Can't determine hash algorithm"; | ||
362 | } | ||
363 | |||
364 | # | ||
365 | # Generate the digest and read from openssl's stdout | ||
366 | # | ||
367 | my $digest; | ||
368 | $digest = readpipe("openssl dgst $dgst -binary $module") || die "openssl dgst"; | ||
369 | |||
370 | # | ||
371 | # Generate the binary signature, which will be just the integer that comprises | ||
372 | # the signature with no metadata attached. | ||
373 | # | ||
374 | my $pid; | ||
375 | $pid = open2(*read_from, *write_to, | ||
376 | "openssl rsautl -sign -inkey $private_key -keyform PEM") || | ||
377 | die "openssl rsautl"; | ||
378 | binmode write_to; | ||
379 | print write_to $prologue . $digest || die "pipe to openssl rsautl"; | ||
380 | close(write_to) || die "pipe to openssl rsautl"; | ||
381 | |||
382 | binmode read_from; | ||
383 | my $signature; | ||
384 | read(read_from, $signature, 4096) || die "pipe from openssl rsautl"; | ||
385 | close(read_from) || die "pipe from openssl rsautl"; | ||
386 | $signature = pack("n", length($signature)) . $signature, | ||
387 | |||
388 | waitpid($pid, 0) || die; | ||
389 | die "openssl rsautl died: $?" if ($? >> 8); | ||
390 | |||
391 | # | ||
392 | # Build the signed binary | ||
393 | # | ||
394 | my $unsigned_module = read_file($module); | ||
395 | |||
396 | my $magic_number = "~Module signature appended~\n"; | ||
397 | |||
398 | my $info = pack("CCCCCxxxN", | ||
399 | $algo, $hash, $id_type, | ||
400 | length($signers_name), | ||
401 | length($key_identifier), | ||
402 | length($signature)); | ||
403 | |||
404 | if ($verbose) { | ||
405 | print "Size of unsigned module: ", length($unsigned_module), "\n"; | ||
406 | print "Size of signer's name : ", length($signers_name), "\n"; | ||
407 | print "Size of key identifier : ", length($key_identifier), "\n"; | ||
408 | print "Size of signature : ", length($signature), "\n"; | ||
409 | print "Size of informaton : ", length($info), "\n"; | ||
410 | print "Size of magic number : ", length($magic_number), "\n"; | ||
411 | print "Signer's name : '", $signers_name, "'\n"; | ||
412 | print "Digest : $dgst\n"; | ||
413 | } | ||
414 | |||
415 | open(FD, ">$dest") || die $dest; | ||
416 | binmode FD; | ||
417 | print FD | ||
418 | $unsigned_module, | ||
419 | $signers_name, | ||
420 | $key_identifier, | ||
421 | $signature, | ||
422 | $info, | ||
423 | $magic_number | ||
424 | ; | ||
425 | close FD || die $dest; | ||
426 | |||
427 | if ($#ARGV != 3) { | ||
428 | rename($dest, $module) || die $module; | ||
429 | } | ||
diff --git a/scripts/sortextable.c b/scripts/sortextable.c deleted file mode 100644 index 1f10e89d15b..00000000000 --- a/scripts/sortextable.c +++ /dev/null | |||
@@ -1,324 +0,0 @@ | |||
1 | /* | ||
2 | * sortextable.c: Sort the kernel's exception table | ||
3 | * | ||
4 | * Copyright 2011 - 2012 Cavium, Inc. | ||
5 | * | ||
6 | * Based on code taken from recortmcount.c which is: | ||
7 | * | ||
8 | * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>. All rights reserved. | ||
9 | * Licensed under the GNU General Public License, version 2 (GPLv2). | ||
10 | * | ||
11 | * Restructured to fit Linux format, as well as other updates: | ||
12 | * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc. | ||
13 | */ | ||
14 | |||
15 | /* | ||
16 | * Strategy: alter the vmlinux file in-place. | ||
17 | */ | ||
18 | |||
19 | #include <sys/types.h> | ||
20 | #include <sys/mman.h> | ||
21 | #include <sys/stat.h> | ||
22 | #include <getopt.h> | ||
23 | #include <elf.h> | ||
24 | #include <fcntl.h> | ||
25 | #include <setjmp.h> | ||
26 | #include <stdio.h> | ||
27 | #include <stdlib.h> | ||
28 | #include <string.h> | ||
29 | #include <unistd.h> | ||
30 | |||
31 | #include <tools/be_byteshift.h> | ||
32 | #include <tools/le_byteshift.h> | ||
33 | |||
34 | static int fd_map; /* File descriptor for file being modified. */ | ||
35 | static int mmap_failed; /* Boolean flag. */ | ||
36 | static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */ | ||
37 | static struct stat sb; /* Remember .st_size, etc. */ | ||
38 | static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */ | ||
39 | |||
40 | /* setjmp() return values */ | ||
41 | enum { | ||
42 | SJ_SETJMP = 0, /* hardwired first return */ | ||
43 | SJ_FAIL, | ||
44 | SJ_SUCCEED | ||
45 | }; | ||
46 | |||
47 | /* Per-file resource cleanup when multiple files. */ | ||
48 | static void | ||
49 | cleanup(void) | ||
50 | { | ||
51 | if (!mmap_failed) | ||
52 | munmap(ehdr_curr, sb.st_size); | ||
53 | close(fd_map); | ||
54 | } | ||
55 | |||
56 | static void __attribute__((noreturn)) | ||
57 | fail_file(void) | ||
58 | { | ||
59 | cleanup(); | ||
60 | longjmp(jmpenv, SJ_FAIL); | ||
61 | } | ||
62 | |||
63 | static void __attribute__((noreturn)) | ||
64 | succeed_file(void) | ||
65 | { | ||
66 | cleanup(); | ||
67 | longjmp(jmpenv, SJ_SUCCEED); | ||
68 | } | ||
69 | |||
70 | |||
71 | /* | ||
72 | * Get the whole file as a programming convenience in order to avoid | ||
73 | * malloc+lseek+read+free of many pieces. If successful, then mmap | ||
74 | * avoids copying unused pieces; else just read the whole file. | ||
75 | * Open for both read and write. | ||
76 | */ | ||
77 | static void *mmap_file(char const *fname) | ||
78 | { | ||
79 | void *addr; | ||
80 | |||
81 | fd_map = open(fname, O_RDWR); | ||
82 | if (fd_map < 0 || fstat(fd_map, &sb) < 0) { | ||
83 | perror(fname); | ||
84 | fail_file(); | ||
85 | } | ||
86 | if (!S_ISREG(sb.st_mode)) { | ||
87 | fprintf(stderr, "not a regular file: %s\n", fname); | ||
88 | fail_file(); | ||
89 | } | ||
90 | addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, | ||
91 | fd_map, 0); | ||
92 | if (addr == MAP_FAILED) { | ||
93 | mmap_failed = 1; | ||
94 | fprintf(stderr, "Could not mmap file: %s\n", fname); | ||
95 | fail_file(); | ||
96 | } | ||
97 | return addr; | ||
98 | } | ||
99 | |||
100 | static uint64_t r8be(const uint64_t *x) | ||
101 | { | ||
102 | return get_unaligned_be64(x); | ||
103 | } | ||
104 | static uint32_t rbe(const uint32_t *x) | ||
105 | { | ||
106 | return get_unaligned_be32(x); | ||
107 | } | ||
108 | static uint16_t r2be(const uint16_t *x) | ||
109 | { | ||
110 | return get_unaligned_be16(x); | ||
111 | } | ||
112 | static uint64_t r8le(const uint64_t *x) | ||
113 | { | ||
114 | return get_unaligned_le64(x); | ||
115 | } | ||
116 | static uint32_t rle(const uint32_t *x) | ||
117 | { | ||
118 | return get_unaligned_le32(x); | ||
119 | } | ||
120 | static uint16_t r2le(const uint16_t *x) | ||
121 | { | ||
122 | return get_unaligned_le16(x); | ||
123 | } | ||
124 | |||
125 | static void w8be(uint64_t val, uint64_t *x) | ||
126 | { | ||
127 | put_unaligned_be64(val, x); | ||
128 | } | ||
129 | static void wbe(uint32_t val, uint32_t *x) | ||
130 | { | ||
131 | put_unaligned_be32(val, x); | ||
132 | } | ||
133 | static void w2be(uint16_t val, uint16_t *x) | ||
134 | { | ||
135 | put_unaligned_be16(val, x); | ||
136 | } | ||
137 | static void w8le(uint64_t val, uint64_t *x) | ||
138 | { | ||
139 | put_unaligned_le64(val, x); | ||
140 | } | ||
141 | static void wle(uint32_t val, uint32_t *x) | ||
142 | { | ||
143 | put_unaligned_le32(val, x); | ||
144 | } | ||
145 | static void w2le(uint16_t val, uint16_t *x) | ||
146 | { | ||
147 | put_unaligned_le16(val, x); | ||
148 | } | ||
149 | |||
150 | static uint64_t (*r8)(const uint64_t *); | ||
151 | static uint32_t (*r)(const uint32_t *); | ||
152 | static uint16_t (*r2)(const uint16_t *); | ||
153 | static void (*w8)(uint64_t, uint64_t *); | ||
154 | static void (*w)(uint32_t, uint32_t *); | ||
155 | static void (*w2)(uint16_t, uint16_t *); | ||
156 | |||
157 | typedef void (*table_sort_t)(char *, int); | ||
158 | |||
159 | /* 32 bit and 64 bit are very similar */ | ||
160 | #include "sortextable.h" | ||
161 | #define SORTEXTABLE_64 | ||
162 | #include "sortextable.h" | ||
163 | |||
164 | static int compare_relative_table(const void *a, const void *b) | ||
165 | { | ||
166 | int32_t av = (int32_t)r(a); | ||
167 | int32_t bv = (int32_t)r(b); | ||
168 | |||
169 | if (av < bv) | ||
170 | return -1; | ||
171 | if (av > bv) | ||
172 | return 1; | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static void sort_relative_table(char *extab_image, int image_size) | ||
177 | { | ||
178 | int i; | ||
179 | |||
180 | /* | ||
181 | * Do the same thing the runtime sort does, first normalize to | ||
182 | * being relative to the start of the section. | ||
183 | */ | ||
184 | i = 0; | ||
185 | while (i < image_size) { | ||
186 | uint32_t *loc = (uint32_t *)(extab_image + i); | ||
187 | w(r(loc) + i, loc); | ||
188 | i += 4; | ||
189 | } | ||
190 | |||
191 | qsort(extab_image, image_size / 8, 8, compare_relative_table); | ||
192 | |||
193 | /* Now denormalize. */ | ||
194 | i = 0; | ||
195 | while (i < image_size) { | ||
196 | uint32_t *loc = (uint32_t *)(extab_image + i); | ||
197 | w(r(loc) - i, loc); | ||
198 | i += 4; | ||
199 | } | ||
200 | } | ||
201 | |||
202 | static void | ||
203 | do_file(char const *const fname) | ||
204 | { | ||
205 | table_sort_t custom_sort; | ||
206 | Elf32_Ehdr *ehdr = mmap_file(fname); | ||
207 | |||
208 | ehdr_curr = ehdr; | ||
209 | switch (ehdr->e_ident[EI_DATA]) { | ||
210 | default: | ||
211 | fprintf(stderr, "unrecognized ELF data encoding %d: %s\n", | ||
212 | ehdr->e_ident[EI_DATA], fname); | ||
213 | fail_file(); | ||
214 | break; | ||
215 | case ELFDATA2LSB: | ||
216 | r = rle; | ||
217 | r2 = r2le; | ||
218 | r8 = r8le; | ||
219 | w = wle; | ||
220 | w2 = w2le; | ||
221 | w8 = w8le; | ||
222 | break; | ||
223 | case ELFDATA2MSB: | ||
224 | r = rbe; | ||
225 | r2 = r2be; | ||
226 | r8 = r8be; | ||
227 | w = wbe; | ||
228 | w2 = w2be; | ||
229 | w8 = w8be; | ||
230 | break; | ||
231 | } /* end switch */ | ||
232 | if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 | ||
233 | || r2(&ehdr->e_type) != ET_EXEC | ||
234 | || ehdr->e_ident[EI_VERSION] != EV_CURRENT) { | ||
235 | fprintf(stderr, "unrecognized ET_EXEC file %s\n", fname); | ||
236 | fail_file(); | ||
237 | } | ||
238 | |||
239 | custom_sort = NULL; | ||
240 | switch (r2(&ehdr->e_machine)) { | ||
241 | default: | ||
242 | fprintf(stderr, "unrecognized e_machine %d %s\n", | ||
243 | r2(&ehdr->e_machine), fname); | ||
244 | fail_file(); | ||
245 | break; | ||
246 | case EM_386: | ||
247 | case EM_X86_64: | ||
248 | case EM_S390: | ||
249 | custom_sort = sort_relative_table; | ||
250 | break; | ||
251 | case EM_ARM: | ||
252 | case EM_MIPS: | ||
253 | break; | ||
254 | } /* end switch */ | ||
255 | |||
256 | switch (ehdr->e_ident[EI_CLASS]) { | ||
257 | default: | ||
258 | fprintf(stderr, "unrecognized ELF class %d %s\n", | ||
259 | ehdr->e_ident[EI_CLASS], fname); | ||
260 | fail_file(); | ||
261 | break; | ||
262 | case ELFCLASS32: | ||
263 | if (r2(&ehdr->e_ehsize) != sizeof(Elf32_Ehdr) | ||
264 | || r2(&ehdr->e_shentsize) != sizeof(Elf32_Shdr)) { | ||
265 | fprintf(stderr, | ||
266 | "unrecognized ET_EXEC file: %s\n", fname); | ||
267 | fail_file(); | ||
268 | } | ||
269 | do32(ehdr, fname, custom_sort); | ||
270 | break; | ||
271 | case ELFCLASS64: { | ||
272 | Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr; | ||
273 | if (r2(&ghdr->e_ehsize) != sizeof(Elf64_Ehdr) | ||
274 | || r2(&ghdr->e_shentsize) != sizeof(Elf64_Shdr)) { | ||
275 | fprintf(stderr, | ||
276 | "unrecognized ET_EXEC file: %s\n", fname); | ||
277 | fail_file(); | ||
278 | } | ||
279 | do64(ghdr, fname, custom_sort); | ||
280 | break; | ||
281 | } | ||
282 | } /* end switch */ | ||
283 | |||
284 | cleanup(); | ||
285 | } | ||
286 | |||
287 | int | ||
288 | main(int argc, char *argv[]) | ||
289 | { | ||
290 | int n_error = 0; /* gcc-4.3.0 false positive complaint */ | ||
291 | int i; | ||
292 | |||
293 | if (argc < 2) { | ||
294 | fprintf(stderr, "usage: sortextable vmlinux...\n"); | ||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | /* Process each file in turn, allowing deep failure. */ | ||
299 | for (i = 1; i < argc; i++) { | ||
300 | char *file = argv[i]; | ||
301 | int const sjval = setjmp(jmpenv); | ||
302 | |||
303 | switch (sjval) { | ||
304 | default: | ||
305 | fprintf(stderr, "internal error: %s\n", file); | ||
306 | exit(1); | ||
307 | break; | ||
308 | case SJ_SETJMP: /* normal sequence */ | ||
309 | /* Avoid problems if early cleanup() */ | ||
310 | fd_map = -1; | ||
311 | ehdr_curr = NULL; | ||
312 | mmap_failed = 1; | ||
313 | do_file(file); | ||
314 | break; | ||
315 | case SJ_FAIL: /* error in do_file or below */ | ||
316 | ++n_error; | ||
317 | break; | ||
318 | case SJ_SUCCEED: /* premature success */ | ||
319 | /* do nothing */ | ||
320 | break; | ||
321 | } /* end switch */ | ||
322 | } | ||
323 | return !!n_error; | ||
324 | } | ||
diff --git a/scripts/sortextable.h b/scripts/sortextable.h deleted file mode 100644 index e4fd45b7e45..00000000000 --- a/scripts/sortextable.h +++ /dev/null | |||
@@ -1,191 +0,0 @@ | |||
1 | /* | ||
2 | * sortextable.h | ||
3 | * | ||
4 | * Copyright 2011 - 2012 Cavium, Inc. | ||
5 | * | ||
6 | * Some of this code was taken out of recordmcount.h written by: | ||
7 | * | ||
8 | * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>. All rights reserved. | ||
9 | * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc. | ||
10 | * | ||
11 | * | ||
12 | * Licensed under the GNU General Public License, version 2 (GPLv2). | ||
13 | */ | ||
14 | |||
15 | #undef extable_ent_size | ||
16 | #undef compare_extable | ||
17 | #undef do_func | ||
18 | #undef Elf_Addr | ||
19 | #undef Elf_Ehdr | ||
20 | #undef Elf_Shdr | ||
21 | #undef Elf_Rel | ||
22 | #undef Elf_Rela | ||
23 | #undef Elf_Sym | ||
24 | #undef ELF_R_SYM | ||
25 | #undef Elf_r_sym | ||
26 | #undef ELF_R_INFO | ||
27 | #undef Elf_r_info | ||
28 | #undef ELF_ST_BIND | ||
29 | #undef ELF_ST_TYPE | ||
30 | #undef fn_ELF_R_SYM | ||
31 | #undef fn_ELF_R_INFO | ||
32 | #undef uint_t | ||
33 | #undef _r | ||
34 | #undef _w | ||
35 | |||
36 | #ifdef SORTEXTABLE_64 | ||
37 | # define extable_ent_size 16 | ||
38 | # define compare_extable compare_extable_64 | ||
39 | # define do_func do64 | ||
40 | # define Elf_Addr Elf64_Addr | ||
41 | # define Elf_Ehdr Elf64_Ehdr | ||
42 | # define Elf_Shdr Elf64_Shdr | ||
43 | # define Elf_Rel Elf64_Rel | ||
44 | # define Elf_Rela Elf64_Rela | ||
45 | # define Elf_Sym Elf64_Sym | ||
46 | # define ELF_R_SYM ELF64_R_SYM | ||
47 | # define Elf_r_sym Elf64_r_sym | ||
48 | # define ELF_R_INFO ELF64_R_INFO | ||
49 | # define Elf_r_info Elf64_r_info | ||
50 | # define ELF_ST_BIND ELF64_ST_BIND | ||
51 | # define ELF_ST_TYPE ELF64_ST_TYPE | ||
52 | # define fn_ELF_R_SYM fn_ELF64_R_SYM | ||
53 | # define fn_ELF_R_INFO fn_ELF64_R_INFO | ||
54 | # define uint_t uint64_t | ||
55 | # define _r r8 | ||
56 | # define _w w8 | ||
57 | #else | ||
58 | # define extable_ent_size 8 | ||
59 | # define compare_extable compare_extable_32 | ||
60 | # define do_func do32 | ||
61 | # define Elf_Addr Elf32_Addr | ||
62 | # define Elf_Ehdr Elf32_Ehdr | ||
63 | # define Elf_Shdr Elf32_Shdr | ||
64 | # define Elf_Rel Elf32_Rel | ||
65 | # define Elf_Rela Elf32_Rela | ||
66 | # define Elf_Sym Elf32_Sym | ||
67 | # define ELF_R_SYM ELF32_R_SYM | ||
68 | # define Elf_r_sym Elf32_r_sym | ||
69 | # define ELF_R_INFO ELF32_R_INFO | ||
70 | # define Elf_r_info Elf32_r_info | ||
71 | # define ELF_ST_BIND ELF32_ST_BIND | ||
72 | # define ELF_ST_TYPE ELF32_ST_TYPE | ||
73 | # define fn_ELF_R_SYM fn_ELF32_R_SYM | ||
74 | # define fn_ELF_R_INFO fn_ELF32_R_INFO | ||
75 | # define uint_t uint32_t | ||
76 | # define _r r | ||
77 | # define _w w | ||
78 | #endif | ||
79 | |||
80 | static int compare_extable(const void *a, const void *b) | ||
81 | { | ||
82 | Elf_Addr av = _r(a); | ||
83 | Elf_Addr bv = _r(b); | ||
84 | |||
85 | if (av < bv) | ||
86 | return -1; | ||
87 | if (av > bv) | ||
88 | return 1; | ||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static void | ||
93 | do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort) | ||
94 | { | ||
95 | Elf_Shdr *shdr; | ||
96 | Elf_Shdr *shstrtab_sec; | ||
97 | Elf_Shdr *strtab_sec = NULL; | ||
98 | Elf_Shdr *symtab_sec = NULL; | ||
99 | Elf_Shdr *extab_sec = NULL; | ||
100 | Elf_Sym *sym; | ||
101 | Elf_Sym *sort_needed_sym; | ||
102 | Elf_Shdr *sort_needed_sec; | ||
103 | Elf_Rel *relocs = NULL; | ||
104 | int relocs_size; | ||
105 | uint32_t *sort_done_location; | ||
106 | const char *secstrtab; | ||
107 | const char *strtab; | ||
108 | char *extab_image; | ||
109 | int extab_index = 0; | ||
110 | int i; | ||
111 | int idx; | ||
112 | |||
113 | shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff)); | ||
114 | shstrtab_sec = shdr + r2(&ehdr->e_shstrndx); | ||
115 | secstrtab = (const char *)ehdr + _r(&shstrtab_sec->sh_offset); | ||
116 | for (i = 0; i < r2(&ehdr->e_shnum); i++) { | ||
117 | idx = r(&shdr[i].sh_name); | ||
118 | if (strcmp(secstrtab + idx, "__ex_table") == 0) { | ||
119 | extab_sec = shdr + i; | ||
120 | extab_index = i; | ||
121 | } | ||
122 | if ((r(&shdr[i].sh_type) == SHT_REL || | ||
123 | r(&shdr[i].sh_type) == SHT_RELA) && | ||
124 | r(&shdr[i].sh_info) == extab_index) { | ||
125 | relocs = (void *)ehdr + _r(&shdr[i].sh_offset); | ||
126 | relocs_size = _r(&shdr[i].sh_size); | ||
127 | } | ||
128 | if (strcmp(secstrtab + idx, ".symtab") == 0) | ||
129 | symtab_sec = shdr + i; | ||
130 | if (strcmp(secstrtab + idx, ".strtab") == 0) | ||
131 | strtab_sec = shdr + i; | ||
132 | } | ||
133 | if (strtab_sec == NULL) { | ||
134 | fprintf(stderr, "no .strtab in file: %s\n", fname); | ||
135 | fail_file(); | ||
136 | } | ||
137 | if (symtab_sec == NULL) { | ||
138 | fprintf(stderr, "no .symtab in file: %s\n", fname); | ||
139 | fail_file(); | ||
140 | } | ||
141 | if (extab_sec == NULL) { | ||
142 | fprintf(stderr, "no __ex_table in file: %s\n", fname); | ||
143 | fail_file(); | ||
144 | } | ||
145 | strtab = (const char *)ehdr + _r(&strtab_sec->sh_offset); | ||
146 | |||
147 | extab_image = (void *)ehdr + _r(&extab_sec->sh_offset); | ||
148 | |||
149 | if (custom_sort) { | ||
150 | custom_sort(extab_image, _r(&extab_sec->sh_size)); | ||
151 | } else { | ||
152 | int num_entries = _r(&extab_sec->sh_size) / extable_ent_size; | ||
153 | qsort(extab_image, num_entries, | ||
154 | extable_ent_size, compare_extable); | ||
155 | } | ||
156 | /* If there were relocations, we no longer need them. */ | ||
157 | if (relocs) | ||
158 | memset(relocs, 0, relocs_size); | ||
159 | |||
160 | /* find main_extable_sort_needed */ | ||
161 | sort_needed_sym = NULL; | ||
162 | for (i = 0; i < _r(&symtab_sec->sh_size) / sizeof(Elf_Sym); i++) { | ||
163 | sym = (void *)ehdr + _r(&symtab_sec->sh_offset); | ||
164 | sym += i; | ||
165 | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) | ||
166 | continue; | ||
167 | idx = r(&sym->st_name); | ||
168 | if (strcmp(strtab + idx, "main_extable_sort_needed") == 0) { | ||
169 | sort_needed_sym = sym; | ||
170 | break; | ||
171 | } | ||
172 | } | ||
173 | if (sort_needed_sym == NULL) { | ||
174 | fprintf(stderr, | ||
175 | "no main_extable_sort_needed symbol in file: %s\n", | ||
176 | fname); | ||
177 | fail_file(); | ||
178 | } | ||
179 | sort_needed_sec = &shdr[r2(&sort_needed_sym->st_shndx)]; | ||
180 | sort_done_location = (void *)ehdr + | ||
181 | _r(&sort_needed_sec->sh_offset) + | ||
182 | _r(&sort_needed_sym->st_value) - | ||
183 | _r(&sort_needed_sec->sh_addr); | ||
184 | |||
185 | #if 1 | ||
186 | printf("sort done marker at %lx\n", | ||
187 | (unsigned long)((char *)sort_done_location - (char *)ehdr)); | ||
188 | #endif | ||
189 | /* We sorted it, clear the flag. */ | ||
190 | w(0, sort_done_location); | ||
191 | } | ||
diff --git a/scripts/tags.sh b/scripts/tags.sh index 08f06c00745..75c5d24f199 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh | |||
@@ -48,14 +48,13 @@ find_arch_sources() | |||
48 | for i in $archincludedir; do | 48 | for i in $archincludedir; do |
49 | prune="$prune -wholename $i -prune -o" | 49 | prune="$prune -wholename $i -prune -o" |
50 | done | 50 | done |
51 | find ${tree}arch/$1 $ignore $subarchprune $prune -name "$2" -print; | 51 | find ${tree}arch/$1 $ignore $prune -name "$2" -print; |
52 | } | 52 | } |
53 | 53 | ||
54 | # find sources in arch/$1/include | 54 | # find sources in arch/$1/include |
55 | find_arch_include_sources() | 55 | find_arch_include_sources() |
56 | { | 56 | { |
57 | include=$(find ${tree}arch/$1/ $subarchprune \ | 57 | include=$(find ${tree}arch/$1/ -name include -type d); |
58 | -name include -type d -print); | ||
59 | if [ -n "$include" ]; then | 58 | if [ -n "$include" ]; then |
60 | archincludedir="$archincludedir $include" | 59 | archincludedir="$archincludedir $include" |
61 | find $include $ignore -name "$2" -print; | 60 | find $include $ignore -name "$2" -print; |
@@ -96,32 +95,6 @@ all_sources() | |||
96 | find_other_sources '*.[chS]' | 95 | find_other_sources '*.[chS]' |
97 | } | 96 | } |
98 | 97 | ||
99 | all_compiled_sources() | ||
100 | { | ||
101 | for i in $(all_sources); do | ||
102 | case "$i" in | ||
103 | *.[cS]) | ||
104 | j=${i/\.[cS]/\.o} | ||
105 | if [ -e $j ]; then | ||
106 | echo $i | ||
107 | fi | ||
108 | ;; | ||
109 | *) | ||
110 | echo $i | ||
111 | ;; | ||
112 | esac | ||
113 | done | ||
114 | } | ||
115 | |||
116 | all_target_sources() | ||
117 | { | ||
118 | if [ -n "$COMPILED_SOURCE" ]; then | ||
119 | all_compiled_sources | ||
120 | else | ||
121 | all_sources | ||
122 | fi | ||
123 | } | ||
124 | |||
125 | all_kconfigs() | 98 | all_kconfigs() |
126 | { | 99 | { |
127 | for arch in $ALLSOURCE_ARCHS; do | 100 | for arch in $ALLSOURCE_ARCHS; do |
@@ -137,18 +110,18 @@ all_defconfigs() | |||
137 | 110 | ||
138 | docscope() | 111 | docscope() |
139 | { | 112 | { |
140 | (echo \-k; echo \-q; all_target_sources) > cscope.files | 113 | (echo \-k; echo \-q; all_sources) > cscope.files |
141 | cscope -b -f cscope.out | 114 | cscope -b -f cscope.out |
142 | } | 115 | } |
143 | 116 | ||
144 | dogtags() | 117 | dogtags() |
145 | { | 118 | { |
146 | all_target_sources | gtags -i -f - | 119 | all_sources | gtags -f - |
147 | } | 120 | } |
148 | 121 | ||
149 | exuberant() | 122 | exuberant() |
150 | { | 123 | { |
151 | all_target_sources | xargs $1 -a \ | 124 | all_sources | xargs $1 -a \ |
152 | -I __initdata,__exitdata,__acquires,__releases \ | 125 | -I __initdata,__exitdata,__acquires,__releases \ |
153 | -I __read_mostly,____cacheline_aligned \ | 126 | -I __read_mostly,____cacheline_aligned \ |
154 | -I ____cacheline_aligned_in_smp \ | 127 | -I ____cacheline_aligned_in_smp \ |
@@ -156,34 +129,10 @@ exuberant() | |||
156 | -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ | 129 | -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ |
157 | -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ | 130 | -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ |
158 | --extra=+f --c-kinds=+px \ | 131 | --extra=+f --c-kinds=+px \ |
159 | --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ | 132 | --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ |
160 | --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ | 133 | --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ |
161 | --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ | 134 | --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ |
162 | --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' \ | 135 | --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' |
163 | --regex-c++='/PAGEFLAG\(([^,)]*).*/Page\1/' \ | ||
164 | --regex-c++='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \ | ||
165 | --regex-c++='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \ | ||
166 | --regex-c++='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \ | ||
167 | --regex-c++='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \ | ||
168 | --regex-c++='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \ | ||
169 | --regex-c++='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \ | ||
170 | --regex-c++='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ | ||
171 | --regex-c++='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ | ||
172 | --regex-c++='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \ | ||
173 | --regex-c++='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ | ||
174 | --regex-c++='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \ | ||
175 | --regex-c++='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ | ||
176 | --regex-c++='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \ | ||
177 | --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \ | ||
178 | --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \ | ||
179 | --regex-c++='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \ | ||
180 | --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ | ||
181 | --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ | ||
182 | --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ | ||
183 | --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ | ||
184 | --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ | ||
185 | --regex-c='/PCI_OP_READ\(([a-z]*[a-z]).*[1-4]\)/pci_bus_read_config_\1/' \ | ||
186 | --regex-c='/PCI_OP_WRITE\(([a-z]*[a-z]).*[1-4]\)/pci_bus_write_config_\1/' | ||
187 | 136 | ||
188 | all_kconfigs | xargs $1 -a \ | 137 | all_kconfigs | xargs $1 -a \ |
189 | --langdef=kconfig --language-force=kconfig \ | 138 | --langdef=kconfig --language-force=kconfig \ |
@@ -196,39 +145,16 @@ exuberant() | |||
196 | all_defconfigs | xargs -r $1 -a \ | 145 | all_defconfigs | xargs -r $1 -a \ |
197 | --langdef=dotconfig --language-force=dotconfig \ | 146 | --langdef=dotconfig --language-force=dotconfig \ |
198 | --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' | 147 | --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' |
148 | |||
199 | } | 149 | } |
200 | 150 | ||
201 | emacs() | 151 | emacs() |
202 | { | 152 | { |
203 | all_target_sources | xargs $1 -a \ | 153 | all_sources | xargs $1 -a \ |
204 | --regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \ | 154 | --regex='/^ENTRY(\([^)]*\)).*/\1/' \ |
205 | --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ | 155 | --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ |
206 | --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ | 156 | --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ |
207 | --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \ | 157 | --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' |
208 | --regex='/PAGEFLAG\(([^,)]*).*/Page\1/' \ | ||
209 | --regex='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \ | ||
210 | --regex='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \ | ||
211 | --regex='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \ | ||
212 | --regex='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \ | ||
213 | --regex='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \ | ||
214 | --regex='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \ | ||
215 | --regex='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ | ||
216 | --regex='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ | ||
217 | --regex='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \ | ||
218 | --regex='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ | ||
219 | --regex='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \ | ||
220 | --regex='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ | ||
221 | --regex='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \ | ||
222 | --regex='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \ | ||
223 | --regex='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \ | ||
224 | --regex='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \ | ||
225 | --regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ | ||
226 | --regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ | ||
227 | --regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ | ||
228 | --regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ | ||
229 | --regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ | ||
230 | --regex='/PCI_OP_READ\(([a-z]*[a-z]).*[1-4]\)/pci_bus_read_config_\1/' \ | ||
231 | --regex='/PCI_OP_WRITE\(([a-z]*[a-z]).*[1-4]\)/pci_bus_write_config_\1/' | ||
232 | 158 | ||
233 | all_kconfigs | xargs $1 -a \ | 159 | all_kconfigs | xargs $1 -a \ |
234 | --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' | 160 | --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' |
@@ -247,10 +173,11 @@ xtags() | |||
247 | elif $1 --version 2>&1 | grep -iq emacs; then | 173 | elif $1 --version 2>&1 | grep -iq emacs; then |
248 | emacs $1 | 174 | emacs $1 |
249 | else | 175 | else |
250 | all_target_sources | xargs $1 -a | 176 | all_sources | xargs $1 -a |
251 | fi | 177 | fi |
252 | } | 178 | } |
253 | 179 | ||
180 | |||
254 | # Support um (which uses SUBARCH) | 181 | # Support um (which uses SUBARCH) |
255 | if [ "${ARCH}" = "um" ]; then | 182 | if [ "${ARCH}" = "um" ]; then |
256 | if [ "$SUBARCH" = "i386" ]; then | 183 | if [ "$SUBARCH" = "i386" ]; then |
@@ -260,24 +187,8 @@ if [ "${ARCH}" = "um" ]; then | |||
260 | else | 187 | else |
261 | archinclude=${SUBARCH} | 188 | archinclude=${SUBARCH} |
262 | fi | 189 | fi |
263 | elif [ "${SRCARCH}" = "arm" -a "${SUBARCH}" != "" ]; then | ||
264 | subarchdir=$(find ${tree}arch/$SRCARCH/ -name "mach-*" -type d -o \ | ||
265 | -name "plat-*" -type d); | ||
266 | for i in $subarchdir; do | ||
267 | case "$i" in | ||
268 | *"mach-"${SUBARCH}) | ||
269 | ;; | ||
270 | *"plat-"${SUBARCH}) | ||
271 | ;; | ||
272 | *) | ||
273 | subarchprune="$subarchprune \ | ||
274 | -wholename $i -prune -o" | ||
275 | ;; | ||
276 | esac | ||
277 | done | ||
278 | fi | 190 | fi |
279 | 191 | ||
280 | remove_structs= | ||
281 | case "$1" in | 192 | case "$1" in |
282 | "cscope") | 193 | "cscope") |
283 | docscope | 194 | docscope |
@@ -290,17 +201,10 @@ case "$1" in | |||
290 | "tags") | 201 | "tags") |
291 | rm -f tags | 202 | rm -f tags |
292 | xtags ctags | 203 | xtags ctags |
293 | remove_structs=y | ||
294 | ;; | 204 | ;; |
295 | 205 | ||
296 | "TAGS") | 206 | "TAGS") |
297 | rm -f TAGS | 207 | rm -f TAGS |
298 | xtags etags | 208 | xtags etags |
299 | remove_structs=y | ||
300 | ;; | 209 | ;; |
301 | esac | 210 | esac |
302 | |||
303 | # Remove structure forward declarations. | ||
304 | if [ -n "$remove_structs" ]; then | ||
305 | LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 | ||
306 | fi | ||
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh index 7a2d372f488..17a5798c29d 100644 --- a/scripts/xz_wrap.sh +++ b/scripts/xz_wrap.sh | |||
@@ -12,8 +12,8 @@ | |||
12 | BCJ= | 12 | BCJ= |
13 | LZMA2OPTS= | 13 | LZMA2OPTS= |
14 | 14 | ||
15 | case $SRCARCH in | 15 | case $ARCH in |
16 | x86) BCJ=--x86 ;; | 16 | x86|x86_64) BCJ=--x86 ;; |
17 | powerpc) BCJ=--powerpc ;; | 17 | powerpc) BCJ=--powerpc ;; |
18 | ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;; | 18 | ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;; |
19 | arm) BCJ=--arm ;; | 19 | arm) BCJ=--arm ;; |