mass revert: clean
Revert "drivers: staging: Include qcacld-3.0 source" Revert "qcacld: nuke Kconfig-based configuration entirely" Revert "qcacld-3.0: Always force user build." Revert "qcacld: drop -Werror" Revert "qcacld-3.0: Fix MAC address fallback when generation fails" Revert "qcacld-3.0: Discard wlan_boot sysfs code on !CONFIG_MODULES" Revert "qcacld: nuke rx_wakelock code entirely" Revert "qcacld-3.0: Defer HDD initialization and rely on userspace writing to /dev/wlan" Revert "qcacld: disable debugging bloat as much as possible" Revert "qcacld-3.0: Only call hdd_debugfs_process_mib_stats if debugfs is enabled." Revert "qcacld-3.0: Fallback to default WCNSS config path for MIUI" Revert "Revert "scripts: gcc-wrapper: Use wrapper to check compiler warnings"" Revert "build-dtbo: Support base dtbs which located in foreign folder" Revert "dtbo.img: build device tree overlay partition image" Revert "scripts: Makefile: suppress DTC compiler warnings" Revert "scripts: use aosp python mkdtboimg for cmd_mkdtimg" Revert ".gitignore: Exclude qcom devicetree from gitignore" Revert "BACKPORT: scripts/dtc: Add yamltree.c to dtc sources" Revert "BACKPORT: scripts/dtc: Update to upstream version v1.4.7-14-gc86da84d30e4" Revert "BACKPORT: kbuild: consolidate Devicetree dtb build rules" Revert "BACKPORT: scripts/dtc: Update to upstream version v1.4.7-57-gf267e674d145" Revert "BACKPORT: of: add dtc annotations functionality to dtx_diff" Revert "BACKPORT: treewide: prefix header search paths with $(srctree)/" Revert "BACKPORT: scripts/dtc: Update to upstream version v1.5.0-23-g87963ee20693" Revert "BACKPORT: scripts/dtc: Update to upstream version v1.5.0-30-g702c1b6c0e73" Revert "BACKPORT: dtc: Use pkg-config to locate libyaml" Revert "BACKPORT: scripts/dtc: only append to HOST_EXTRACFLAGS instead of overwriting"
This commit is contained in:
parent
c1c5a45275
commit
496d723f58
5
.gitignore
vendored
5
.gitignore
vendored
@ -136,5 +136,8 @@ all.config
|
||||
# fetched Android config fragments
|
||||
kernel/configs/android-*.cfg
|
||||
|
||||
# vendor device tree directories
|
||||
arch/arm64/boot/dts/vendor/
|
||||
|
||||
# Tech package directories
|
||||
#techpack/
|
||||
techpack/
|
||||
|
47
Makefile
47
Makefile
@ -385,7 +385,7 @@ READELF = llvm-readelf
|
||||
OBJSIZE = llvm-size
|
||||
STRIP = llvm-strip
|
||||
else
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
REAL_CC = $(CROSS_COMPILE)gcc
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
NM = $(CROSS_COMPILE)nm
|
||||
@ -407,6 +407,10 @@ PYTHON2 = python2
|
||||
PYTHON3 = python3
|
||||
CHECK = sparse
|
||||
|
||||
# Use the wrapper for the compiler. This wrapper scans for new
|
||||
# warnings and causes the build to stop upon encountering them
|
||||
CC = $(PYTHON) $(srctree)/scripts/gcc-wrapper.py $(REAL_CC)
|
||||
|
||||
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
|
||||
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
|
||||
NOSTDINC_FLAGS =
|
||||
@ -1207,7 +1211,7 @@ include/config/kernel.release: $(srctree)/Makefile FORCE
|
||||
# Carefully list dependencies so we do not try to build scripts twice
|
||||
# in parallel
|
||||
PHONY += scripts
|
||||
scripts: scripts_basic scripts_dtc asm-generic gcc-plugins $(autoksyms_h)
|
||||
scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h)
|
||||
$(Q)$(MAKE) $(build)=$(@)
|
||||
|
||||
# Things we need to do before we recursively start building the kernel
|
||||
@ -1340,7 +1344,7 @@ headers_install: __headers
|
||||
$(error Headers not exportable for the $(SRCARCH) architecture))
|
||||
$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include
|
||||
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst)
|
||||
$(Q)$(MAKE) $(hdr-inst)=techpack/audio/include/uapi dst=techpack/audio/include
|
||||
$(Q)$(MAKE) $(hdr-inst)=techpack
|
||||
|
||||
PHONY += headers_check_all
|
||||
headers_check_all: headers_install_all
|
||||
@ -1350,7 +1354,7 @@ PHONY += headers_check
|
||||
headers_check: headers_install
|
||||
$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1
|
||||
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) HDRCHECK=1
|
||||
$(Q)$(MAKE) $(hdr-inst)=techpack/audio/include/uapi dst=techpack/audio/include HDRCHECK=1
|
||||
$(Q)$(MAKE) $(hdr-inst)=techpack HDRCHECK=1
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Kernel selftest
|
||||
@ -1371,35 +1375,6 @@ kselftest-merge:
|
||||
$(srctree)/tools/testing/selftests/*/config
|
||||
+$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Devicetree files
|
||||
|
||||
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
|
||||
dtstree := arch/$(SRCARCH)/boot/dts
|
||||
endif
|
||||
|
||||
ifneq ($(dtstree),)
|
||||
|
||||
%.dtb: prepare3 scripts_dtc
|
||||
$(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
|
||||
|
||||
PHONY += dtbs dtbs_install
|
||||
dtbs: prepare3 scripts_dtc
|
||||
$(Q)$(MAKE) $(build)=$(dtstree)
|
||||
|
||||
dtbs_install:
|
||||
$(Q)$(MAKE) $(dtbinst)=$(dtstree)
|
||||
|
||||
ifdef CONFIG_OF_EARLY_FLATTREE
|
||||
all: dtbs
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
PHONY += scripts_dtc
|
||||
scripts_dtc: scripts_basic
|
||||
$(Q)$(MAKE) $(build)=scripts/dtc
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Modules
|
||||
|
||||
@ -1609,12 +1584,6 @@ help:
|
||||
@echo ' kselftest-merge - Merge all the config dependencies of kselftest to existing'
|
||||
@echo ' .config.'
|
||||
@echo ''
|
||||
@$(if $(dtstree), \
|
||||
echo 'Devicetree:'; \
|
||||
echo '* dtbs - Build device tree blobs for enabled boards'; \
|
||||
echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
|
||||
echo '')
|
||||
|
||||
@echo 'Userspace tools targets:'
|
||||
@echo ' use "make tools/help"'
|
||||
@echo ' or "cd tools; make help"'
|
||||
|
@ -97,5 +97,11 @@ PHONY += $(boot_targets)
|
||||
$(boot_targets): vmlinux
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||
|
||||
%.dtb %.dtb.S %.dtb.o: scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
|
||||
|
||||
dtbs: scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts
|
||||
|
||||
archclean:
|
||||
$(Q)$(MAKE) $(clean)=$(boot)
|
||||
|
@ -324,7 +324,14 @@ else
|
||||
KBUILD_IMAGE := $(boot)/zImage
|
||||
endif
|
||||
|
||||
all: $(notdir $(KBUILD_IMAGE))
|
||||
# Build the DT binary blobs if we have OF configured
|
||||
ifeq ($(CONFIG_USE_OF),y)
|
||||
KBUILD_DTBS := dtbs
|
||||
endif
|
||||
|
||||
DTSSUBDIR := vendor/qcom
|
||||
|
||||
all: $(notdir $(KBUILD_IMAGE)) $(KBUILD_DTBS)
|
||||
|
||||
|
||||
archheaders:
|
||||
@ -351,6 +358,18 @@ $(BOOT_TARGETS): vmlinux
|
||||
$(INSTALL_TARGETS):
|
||||
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
|
||||
|
||||
%.dtb: | scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@
|
||||
|
||||
PHONY += dtbs dtbs_install
|
||||
|
||||
dtbs: prepare scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts
|
||||
$(foreach DIR, $(DTSSUBDIR), $(Q)$(MAKE) $(build)=$(boot)/dts/$(DIR) MACHINE=$(MACHINE) dtbs)
|
||||
|
||||
dtbs_install:
|
||||
$(Q)$(MAKE) $(dtbinst)=$(boot)/dts
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
ifeq ($(CONFIG_VDSO),y)
|
||||
@ -378,6 +397,8 @@ define archhelp
|
||||
echo ' uImage - U-Boot wrapped zImage'
|
||||
echo ' bootpImage - Combined zImage and initial RAM disk'
|
||||
echo ' (supply initrd image via make variable INITRD=<path>)'
|
||||
echo '* dtbs - Build device tree blobs for enabled boards'
|
||||
echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
|
||||
echo ' install - Install uncompressed kernel'
|
||||
echo ' zinstall - Install compressed kernel'
|
||||
echo ' uinstall - Install U-Boot wrapped compressed kernel'
|
||||
|
@ -146,7 +146,7 @@ KBUILD_TARGET := $(KBUILD_IMAGE)
|
||||
KBUILD_IMAGE := $(boot)/$(KBUILD_IMAGE)
|
||||
endif
|
||||
|
||||
KBUILD_DTBO_IMG := dtbo.img
|
||||
KBUILD_DTBS := dtbs
|
||||
|
||||
ifeq ($(CONFIG_BUILD_ARM64_DT_OVERLAY),y)
|
||||
export DTC_FLAGS := -@
|
||||
@ -163,19 +163,23 @@ Image.%: Image
|
||||
zinstall install:
|
||||
$(Q)$(MAKE) $(build)=$(boot) $@
|
||||
|
||||
%.dtb: scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
|
||||
|
||||
PHONY += dtbs dtbs_install
|
||||
|
||||
dtbs: prepare scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts
|
||||
|
||||
dtbs_install:
|
||||
$(Q)$(MAKE) $(dtbinst)=$(boot)/dts
|
||||
|
||||
Image-dtb: vmlinux scripts dtbs
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||
|
||||
Image.gz-dtb: vmlinux scripts dtbs Image.gz
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||
|
||||
ifeq ($(CONFIG_BUILD_ARM64_DT_OVERLAY),y)
|
||||
$(KBUILD_DTBO_IMG): dtbs
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||
|
||||
all: $(KBUILD_DTBO_IMG)
|
||||
endif
|
||||
|
||||
PHONY += vdso_install
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
|
||||
@ -184,6 +188,7 @@ vdso_install:
|
||||
# We use MRPROPER_FILES and CLEAN_FILES now
|
||||
archclean:
|
||||
$(Q)$(MAKE) $(clean)=$(boot)
|
||||
$(Q)$(MAKE) $(clean)=$(boot)/dts
|
||||
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
# We need to generate vdso-offsets.h before compiling certain files in kernel/.
|
||||
@ -203,6 +208,8 @@ endif
|
||||
define archhelp
|
||||
echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
|
||||
echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
|
||||
echo '* dtbs - Build device tree blobs for enabled boards'
|
||||
echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
|
||||
echo ' install - Install uncompressed kernel'
|
||||
echo ' zinstall - Install compressed kernel'
|
||||
echo ' Install using (your) ~/bin/installkernel or'
|
||||
|
1
arch/arm64/boot/.gitignore
vendored
1
arch/arm64/boot/.gitignore
vendored
@ -2,4 +2,3 @@ Image
|
||||
Image-dtb
|
||||
Image.gz
|
||||
Image.gz-dtb
|
||||
dtbo.img
|
||||
|
@ -18,7 +18,7 @@ include $(srctree)/arch/arm64/boot/dts/Makefile
|
||||
|
||||
OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
|
||||
|
||||
targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo dtbo.img
|
||||
targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo
|
||||
|
||||
DTB_NAMES := $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES))
|
||||
ifneq ($(DTB_NAMES),)
|
||||
@ -28,8 +28,6 @@ DTB_LIST := $(dtb-y)
|
||||
endif
|
||||
DTB_OBJS := $(shell find $(obj)/dts/ -name \*.dtb)
|
||||
|
||||
DTBO_OBJS := $(shell find $(obj)/dts/ -name \*.dtbo)
|
||||
|
||||
# Add RTIC DTB to the DTB list if RTIC MPGen is enabled
|
||||
# Note, we keep this for compatibility with
|
||||
# BUILD_ARM64_APPENDED_DTB_IMAGE targets.
|
||||
@ -70,9 +68,6 @@ $(obj)/Image.lzo: $(obj)/Image FORCE
|
||||
$(obj)/Image.gz-dtb: $(obj)/Image.gz $(DTB_OBJS) FORCE
|
||||
$(call if_changed,cat)
|
||||
|
||||
$(obj)/dtbo.img: $(DTBO_OBJS) FORCE
|
||||
$(call if_changed,mkdtimg)
|
||||
|
||||
install:
|
||||
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
|
||||
$(obj)/Image System.map "$(INSTALL_PATH)"
|
||||
|
@ -40,7 +40,9 @@ boot := arch/$(ARCH)/boot
|
||||
DTB:=$(subst dtbImage.,,$(filter dtbImage.%, $(MAKECMDGOALS)))
|
||||
export DTB
|
||||
|
||||
ifneq ($(DTB),)
|
||||
core-y += $(boot)/dts/
|
||||
endif
|
||||
|
||||
# With make 3.82 we cannot mix normal and wildcard targets
|
||||
|
||||
|
@ -31,12 +31,21 @@ CROSS_COMPILE := $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-)
|
||||
endif
|
||||
|
||||
core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/
|
||||
core-y += arch/$(ARCH)/boot/dts/
|
||||
ifneq '$(CONFIG_H8300_BUILTIN_DTB)' '""'
|
||||
core-y += arch/h8300/boot/dts/
|
||||
endif
|
||||
|
||||
libs-y += arch/$(ARCH)/lib/
|
||||
|
||||
boot := arch/h8300/boot
|
||||
|
||||
%.dtb %.dtb.S %.dtb.o: | scripts
|
||||
$(Q)$(MAKE) $(build)=arch/h8300/boot/dts arch/h8300/boot/dts/$@
|
||||
|
||||
PHONY += dtbs
|
||||
dtbs: scripts
|
||||
$(Q)$(MAKE) $(build)=arch/h8300/boot/dts
|
||||
|
||||
archmrproper:
|
||||
|
||||
archclean:
|
||||
|
@ -65,7 +65,9 @@ boot := arch/microblaze/boot
|
||||
# Are we making a simpleImage.<boardname> target? If so, crack out the boardname
|
||||
DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))
|
||||
|
||||
core-y += $(boot)/dts/
|
||||
ifneq ($(DTB),)
|
||||
core-y += $(boot)/dts/
|
||||
endif
|
||||
|
||||
# defines filename extension depending memory management type
|
||||
ifeq ($(CONFIG_MMU),)
|
||||
|
@ -1,7 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
|
||||
ifneq ($(DTB),)
|
||||
obj-y += linked_dtb.o
|
||||
|
||||
# Ensure system.dtb exists
|
||||
@ -12,7 +11,6 @@ ifneq ($(DTB),system)
|
||||
$(obj)/system.dtb: $(obj)/$(DTB).dtb
|
||||
$(call if_changed,cp)
|
||||
endif
|
||||
endif
|
||||
|
||||
quiet_cmd_cp = CP $< $@$2
|
||||
cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
|
||||
|
@ -419,7 +419,18 @@ endif
|
||||
CLEAN_FILES += vmlinux.32 vmlinux.64
|
||||
|
||||
# device-trees
|
||||
core-y += arch/mips/boot/dts/
|
||||
core-$(CONFIG_BUILTIN_DTB) += arch/mips/boot/dts/
|
||||
|
||||
%.dtb %.dtb.S %.dtb.o: | scripts
|
||||
$(Q)$(MAKE) $(build)=arch/mips/boot/dts arch/mips/boot/dts/$@
|
||||
|
||||
PHONY += dtbs
|
||||
dtbs: scripts
|
||||
$(Q)$(MAKE) $(build)=arch/mips/boot/dts
|
||||
|
||||
PHONY += dtbs_install
|
||||
dtbs_install:
|
||||
$(Q)$(MAKE) $(dtbinst)=arch/mips/boot/dts
|
||||
|
||||
archprepare:
|
||||
ifdef CONFIG_MIPS32_N32
|
||||
@ -462,6 +473,8 @@ define archhelp
|
||||
echo ' uImage.lzma - U-Boot image (lzma)'
|
||||
echo ' uImage.lzo - U-Boot image (lzo)'
|
||||
echo ' uzImage.bin - U-Boot image (self-extracting)'
|
||||
echo ' dtbs - Device-tree blobs for enabled boards'
|
||||
echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
|
||||
echo
|
||||
echo ' These will be default as appropriate for a configured platform.'
|
||||
echo
|
||||
|
@ -1,5 +1,5 @@
|
||||
# NXP STB225
|
||||
platform-$(CONFIG_SOC_PNX833X) += pnx833x/
|
||||
cflags-$(CONFIG_SOC_PNX833X) += -I $(srctree)/arch/mips/include/asm/mach-pnx833x
|
||||
cflags-$(CONFIG_SOC_PNX833X) += -Iarch/mips/include/asm/mach-pnx833x
|
||||
load-$(CONFIG_NXP_STB220) += 0xffffffff80001000
|
||||
load-$(CONFIG_NXP_STB225) += 0xffffffff80001000
|
||||
|
@ -47,7 +47,7 @@ CHECKFLAGS += -D__NDS32_EB__
|
||||
endif
|
||||
|
||||
boot := arch/nds32/boot
|
||||
core-y += $(boot)/dts/
|
||||
core-$(BUILTIN_DTB) += $(boot)/dts/
|
||||
|
||||
.PHONY: FORCE
|
||||
|
||||
|
@ -58,6 +58,12 @@ all: vmImage
|
||||
archclean:
|
||||
$(Q)$(MAKE) $(clean)=$(nios2-boot)
|
||||
|
||||
%.dtb: | scripts
|
||||
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@
|
||||
|
||||
dtbs:
|
||||
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@
|
||||
|
||||
$(BOOT_TARGETS): vmlinux
|
||||
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@
|
||||
|
||||
@ -70,4 +76,5 @@ define archhelp
|
||||
echo ' (your) ~/bin/$(INSTALLKERNEL) or'
|
||||
echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
|
||||
echo ' install to $$(INSTALL_PATH)'
|
||||
echo ' dtbs - Build device tree blobs for enabled boards'
|
||||
endef
|
||||
|
@ -45,5 +45,13 @@ $(obj)/linked_dtb.o: $(obj)/system.dtb
|
||||
|
||||
obj-$(CONFIG_NIOS2_DTB_SOURCE_BOOL) += linked_dtb.o
|
||||
|
||||
targets += $(dtb-y)
|
||||
|
||||
# Rule to build device tree blobs with make command
|
||||
$(obj)/%.dtb: $(src)/dts/%.dts FORCE
|
||||
$(call if_changed_dep,dtc)
|
||||
|
||||
$(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y))
|
||||
|
||||
install:
|
||||
sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
|
||||
|
@ -205,8 +205,8 @@ endif
|
||||
|
||||
asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
|
||||
|
||||
KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr)
|
||||
KBUILD_AFLAGS += -I $(srctree)/arch/$(ARCH) $(AFLAGS-y)
|
||||
KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr)
|
||||
KBUILD_AFLAGS += -Iarch/$(ARCH) $(AFLAGS-y)
|
||||
KBUILD_CFLAGS += $(call cc-option,-msoft-float)
|
||||
KBUILD_CFLAGS += -pipe -Iarch/$(ARCH) $(CFLAGS-y)
|
||||
CPP = $(CC) -E $(KBUILD_CFLAGS)
|
||||
@ -311,6 +311,9 @@ $(BOOT_TARGETS2): vmlinux
|
||||
bootwrapper_install:
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
|
||||
|
||||
%.dtb: scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
|
||||
|
||||
# Used to create 'merged defconfigs'
|
||||
# To use it $(call) it with the first argument as the base defconfig
|
||||
# and the second argument as a space separated list of .config files to merge,
|
||||
|
@ -191,8 +191,8 @@ cpuincdir-y += cpu-common # Must be last
|
||||
drivers-y += arch/sh/drivers/
|
||||
drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/
|
||||
|
||||
cflags-y += $(foreach d, $(cpuincdir-y), -I $(srctree)/arch/sh/include/$(d)) \
|
||||
$(foreach d, $(machdir-y), -I $(srctree)/arch/sh/include/$(d))
|
||||
cflags-y += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \
|
||||
$(foreach d, $(machdir-y), -Iarch/sh/include/$(d))
|
||||
|
||||
KBUILD_CFLAGS += -pipe $(cflags-y)
|
||||
KBUILD_CPPFLAGS += $(cflags-y)
|
||||
|
@ -42,7 +42,7 @@ endif
|
||||
# non-deterministic coverage.
|
||||
KCOV_INSTRUMENT := n
|
||||
|
||||
CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace
|
||||
CFLAGS_irq.o := -I$(src)/../include/asm/trace
|
||||
|
||||
obj-y := process_$(BITS).o signal.o
|
||||
obj-$(CONFIG_COMPAT) += signal_compat.o
|
||||
|
@ -21,7 +21,7 @@ CFLAGS_physaddr.o := $(nostackp)
|
||||
CFLAGS_setup_nx.o := $(nostackp)
|
||||
CFLAGS_mem_encrypt_identity.o := $(nostackp)
|
||||
|
||||
CFLAGS_fault.o := -I $(srctree)/$(src)/../include/asm/trace
|
||||
CFLAGS_fault.o := -I$(src)/../include/asm/trace
|
||||
|
||||
obj-$(CONFIG_X86_PAT) += pat_rbtree.o
|
||||
|
||||
|
@ -80,18 +80,28 @@ LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
|
||||
head-y := arch/xtensa/kernel/head.o
|
||||
core-y += arch/xtensa/kernel/ arch/xtensa/mm/
|
||||
core-y += $(buildvar) $(buildplf)
|
||||
core-y += arch/xtensa/boot/dts/
|
||||
|
||||
libs-y += arch/xtensa/lib/ $(LIBGCC)
|
||||
drivers-$(CONFIG_OPROFILE) += arch/xtensa/oprofile/
|
||||
|
||||
ifneq ($(CONFIG_BUILTIN_DTB),"")
|
||||
core-$(CONFIG_OF) += arch/xtensa/boot/dts/
|
||||
endif
|
||||
|
||||
boot := arch/xtensa/boot
|
||||
|
||||
all Image zImage uImage: vmlinux
|
||||
$(Q)$(MAKE) $(build)=$(boot) $@
|
||||
|
||||
%.dtb:
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
|
||||
|
||||
dtbs: scripts
|
||||
$(Q)$(MAKE) $(build)=$(boot)/dts
|
||||
|
||||
define archhelp
|
||||
@echo '* Image - Kernel ELF image with reset vector'
|
||||
@echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)'
|
||||
@echo '* uImage - U-Boot wrapped image'
|
||||
@echo ' dtbs - Build device tree blobs for enabled boards'
|
||||
endef
|
||||
|
@ -7,7 +7,7 @@ zlib := inffast.c inflate.c inftrees.c
|
||||
|
||||
lib-y += $(zlib:.c=.o) zmem.o
|
||||
|
||||
ccflags-y := -I $(srctree)/lib/zlib_inflate
|
||||
ccflags-y := -Ilib/zlib_inflate
|
||||
ifdef CONFIG_FUNCTION_TRACER
|
||||
CFLAGS_REMOVE_inflate.o = -pg
|
||||
CFLAGS_REMOVE_zmem.o = -pg
|
||||
|
@ -20,4 +20,4 @@ obj-$(CONFIG_INTEL_ISH_HID) += intel-ishtp-hid.o
|
||||
intel-ishtp-hid-objs := ishtp-hid.o
|
||||
intel-ishtp-hid-objs += ishtp-hid-client.o
|
||||
|
||||
ccflags-y += -I $(srctree)/$(src)/ishtp
|
||||
ccflags-y += -Idrivers/hid/intel-ish-hid/ishtp
|
||||
|
@ -1,4 +1,4 @@
|
||||
ccflags-y := -I $(srctree)/$(src)/../cxgb4
|
||||
ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb4
|
||||
|
||||
obj-$(CONFIG_CHELSIO_LIB) += libcxgb.o
|
||||
|
||||
|
@ -124,6 +124,4 @@ source "drivers/staging/axis-fifo/Kconfig"
|
||||
|
||||
source "drivers/staging/erofs/Kconfig"
|
||||
|
||||
source "drivers/staging/qcacld-3.0/Kconfig"
|
||||
|
||||
endif # STAGING
|
||||
|
@ -52,4 +52,3 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/
|
||||
obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/
|
||||
obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/
|
||||
obj-$(CONFIG_EROFS_FS) += erofs/
|
||||
obj-$(CONFIG_QCA_CLD_WLAN) += qcacld-3.0/
|
||||
|
@ -10589,10 +10589,8 @@ static QDF_STATUS dp_runtime_suspend(struct cdp_soc_t *soc_hdl, uint8_t pdev_id)
|
||||
|
||||
/* perform a force flush if tx is pending */
|
||||
for (i = 0; i < soc->num_tcl_data_rings; i++) {
|
||||
#ifdef IPA_OFFLOAD
|
||||
if (i == IPA_TCL_DATA_RING_IDX)
|
||||
continue;
|
||||
#endif
|
||||
hal_srng_set_event(soc->tcl_data_ring[i].hal_srng,
|
||||
HAL_SRNG_FLUSH_EVENT);
|
||||
dp_flush_ring_hptp(soc, soc->tcl_data_ring[i].hal_srng);
|
||||
|
@ -229,7 +229,7 @@ dp_rx_link_desc_return_by_addr(struct dp_soc *soc,
|
||||
src_srng_desc, link_desc_addr, bm_action);
|
||||
status = QDF_STATUS_SUCCESS;
|
||||
} else {
|
||||
__maybe_unused struct hal_srng *srng = (struct hal_srng *)wbm_rel_srng;
|
||||
struct hal_srng *srng = (struct hal_srng *)wbm_rel_srng;
|
||||
|
||||
DP_STATS_INC(soc, rx.err.hal_ring_access_full_fail, 1);
|
||||
|
||||
|
@ -556,7 +556,7 @@ static void hal_rx_dump_msdu_start_tlv_6390(void *msdustart, uint8_t dbg_level)
|
||||
static void hal_rx_dump_msdu_end_tlv_6390(void *msduend,
|
||||
uint8_t dbg_level)
|
||||
{
|
||||
__maybe_unused struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend;
|
||||
struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend;
|
||||
|
||||
__QDF_TRACE_RL(dbg_level, QDF_MODULE_ID_DP,
|
||||
"rx_msdu_end tlv (1/2) - "
|
||||
|
@ -235,7 +235,7 @@ void hal_rx_proc_phyrx_other_receive_info_tlv_6490(void *rx_tlv_hdr,
|
||||
*/
|
||||
static void hal_rx_dump_msdu_start_tlv_6490(void *msdustart, uint8_t dbg_level)
|
||||
{
|
||||
__maybe_unused struct rx_msdu_start *msdu_start = (struct rx_msdu_start *)msdustart;
|
||||
struct rx_msdu_start *msdu_start = (struct rx_msdu_start *)msdustart;
|
||||
|
||||
__QDF_TRACE_RL(dbg_level, QDF_MODULE_ID_DP,
|
||||
"rx_msdu_start tlv (1/2) - "
|
||||
@ -313,7 +313,7 @@ static void hal_rx_dump_msdu_start_tlv_6490(void *msdustart, uint8_t dbg_level)
|
||||
static void hal_rx_dump_msdu_end_tlv_6490(void *msduend,
|
||||
uint8_t dbg_level)
|
||||
{
|
||||
__maybe_unused struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend;
|
||||
struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend;
|
||||
|
||||
__QDF_TRACE_RL(dbg_level, QDF_MODULE_ID_DP,
|
||||
"rx_msdu_end tlv (1/3) - "
|
||||
|
@ -244,4 +244,10 @@ void athdiag_procfs_remove(void)
|
||||
proc_dir = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int athdiag_procfs_init(void *scn)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void athdiag_procfs_remove(void) {}
|
||||
#endif
|
||||
|
@ -335,16 +335,8 @@ void hif_unconfig_ce(struct hif_softc *scn);
|
||||
void hif_ce_prepare_config(struct hif_softc *scn);
|
||||
QDF_STATUS hif_ce_open(struct hif_softc *scn);
|
||||
void hif_ce_close(struct hif_softc *scn);
|
||||
#if defined(CONFIG_ATH_PROCFS_DIAG_SUPPORT)
|
||||
int athdiag_procfs_init(void *scn);
|
||||
void athdiag_procfs_remove(void);
|
||||
#else
|
||||
static inline int athdiag_procfs_init(void *scn)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void athdiag_procfs_remove(void) {}
|
||||
#endif
|
||||
/* routine to modify the initial buffer count to be allocated on an os
|
||||
* platform basis. Platform owner will need to modify this as needed
|
||||
*/
|
||||
|
@ -1165,7 +1165,6 @@ qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
|
||||
|
||||
#endif /* TSOSEG_DEBUG */
|
||||
|
||||
#ifdef QDF_ENABLE_TRACING
|
||||
/**
|
||||
* qdf_trace_hex_dump() - externally called hex dump function
|
||||
* @module: Module identifier a member of the QDF_MODULE_ID enumeration that
|
||||
@ -1199,12 +1198,6 @@ void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
|
||||
*/
|
||||
void qdf_trace_hex_ascii_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
|
||||
void *data, int buf_len);
|
||||
#else
|
||||
static inline void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
|
||||
void *data, int buf_len) {}
|
||||
static inline void qdf_trace_hex_ascii_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
|
||||
void *data, int buf_len) {}
|
||||
#endif
|
||||
|
||||
#define ERROR_CODE -1
|
||||
#define QDF_MAX_NAME_SIZE 32
|
||||
|
@ -258,7 +258,7 @@ static inline void __qdf_trace_hexdump_dummy(QDF_MODULE_ID module,
|
||||
#define QDF_TRACE_EXIT(params...) __qdf_trace_noop(params)
|
||||
#endif
|
||||
|
||||
// #define QDF_ENABLE_TRACING
|
||||
#define QDF_ENABLE_TRACING
|
||||
#define qdf_scnprintf scnprintf
|
||||
|
||||
#ifdef QDF_ENABLE_TRACING
|
||||
|
@ -72,8 +72,7 @@ extern "C" {
|
||||
#ifdef FEATURE_FW_LOG_PARSING
|
||||
/*
|
||||
* set the dbglog parser type
|
||||
*/
|
||||
int
|
||||
*/int
|
||||
dbglog_parser_type_init(wmi_unified_t wmi_handle, int type);
|
||||
|
||||
/** dbglog_int - Registers a WMI event handle for WMI_DBGMSG_EVENT
|
||||
|
@ -110,53 +110,6 @@ struct wmi_ext_dbg_msg {
|
||||
};
|
||||
#endif /*WMI_EXT_DBG */
|
||||
|
||||
#ifdef WLAN_DEBUG
|
||||
|
||||
#define wmi_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_WMI, ## params)
|
||||
|
||||
#define wmi_nofl_alert(params...) \
|
||||
QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_err(params...) \
|
||||
QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_warn(params...) \
|
||||
QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_info(params...) \
|
||||
QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_debug(params...) \
|
||||
QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
|
||||
#define wmi_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_WMI, params)
|
||||
|
||||
#else
|
||||
|
||||
#define wmi_alert(params...) ((void)0)
|
||||
#define wmi_err(params...) ((void)0)
|
||||
#define wmi_warn(params...) ((void)0)
|
||||
#define wmi_info(params...) ((void)0)
|
||||
#define wmi_debug(params...) ((void)0)
|
||||
|
||||
#define wmi_nofl_alert(params...) ((void)0)
|
||||
#define wmi_nofl_err(params...) ((void)0)
|
||||
#define wmi_nofl_warn(params...) ((void)0)
|
||||
#define wmi_nofl_info(params...) ((void)0)
|
||||
#define wmi_nofl_debug(params...) ((void)0)
|
||||
|
||||
#define wmi_alert_rl(params...) ((void)0)
|
||||
#define wmi_err_rl(params...) ((void)0)
|
||||
#define wmi_warn_rl(params...) ((void)0)
|
||||
#define wmi_info_rl(params...) ((void)0)
|
||||
#define wmi_debug_rl(params...) ((void)0)
|
||||
|
||||
#endif /* WLAN_DEBUG */
|
||||
|
||||
#ifdef WMI_INTERFACE_EVENT_LOGGING
|
||||
|
||||
#ifndef WMI_EVENT_DEBUG_MAX_ENTRY
|
||||
@ -186,6 +139,29 @@ struct wmi_ext_dbg_msg {
|
||||
#endif
|
||||
#endif /* WMI_INTERFACE_FILTERED_EVENT_LOGGING */
|
||||
|
||||
#define wmi_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_WMI, ## params)
|
||||
|
||||
#define wmi_nofl_alert(params...) \
|
||||
QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_err(params...) \
|
||||
QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_warn(params...) \
|
||||
QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_info(params...) \
|
||||
QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
#define wmi_nofl_debug(params...) \
|
||||
QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_WMI, ## params)
|
||||
|
||||
#define wmi_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_WMI, params)
|
||||
#define wmi_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_WMI, params)
|
||||
|
||||
/**
|
||||
* struct wmi_command_debug - WMI command log buffer data type
|
||||
* @ command - Store WMI Command id
|
||||
|
@ -1361,7 +1361,7 @@ static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
|
||||
* Return: string conversion of sar 2 result, if match found;
|
||||
* "Unknown response" otherwise.
|
||||
*/
|
||||
__maybe_unused static const char *wmi_sar2_result_string(uint32_t result)
|
||||
static const char *wmi_sar2_result_string(uint32_t result)
|
||||
{
|
||||
switch (result) {
|
||||
CASE_RETURN_STRING(WMI_SAR2_SUCCESS);
|
||||
|
180
drivers/staging/qcacld-3.0/Android.mk
Normal file
180
drivers/staging/qcacld-3.0/Android.mk
Normal file
@ -0,0 +1,180 @@
|
||||
ENABLE_QCACLD := true
|
||||
ifeq ($(TARGET_USES_QMAA), true)
|
||||
ifneq ($(TARGET_USES_QMAA_OVERRIDE_WLAN), true)
|
||||
ENABLE_QCACLD := false
|
||||
else
|
||||
ENABLE_QCACLD := true
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_QCACLD), true)
|
||||
# Android makefile for the WLAN Module
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
# Assume no targets will be supported
|
||||
WLAN_CHIPSET :=
|
||||
|
||||
ifeq ($(BOARD_HAS_QCOM_WLAN), true)
|
||||
|
||||
# Check if this driver needs be built for current target
|
||||
ifneq ($(findstring qca_cld3,$(WIFI_DRIVER_BUILT)),)
|
||||
WLAN_CHIPSET := qca_cld3
|
||||
WLAN_SELECT := CONFIG_QCA_CLD_WLAN=m
|
||||
endif
|
||||
|
||||
# Build/Package only in case of supported target
|
||||
ifneq ($(WLAN_CHIPSET),)
|
||||
|
||||
# This makefile is only for DLKM
|
||||
ifneq ($(findstring vendor,$(LOCAL_PATH)),)
|
||||
|
||||
ifneq ($(findstring opensource,$(LOCAL_PATH)),)
|
||||
WLAN_BLD_DIR := vendor/qcom/opensource/wlan
|
||||
endif # opensource
|
||||
|
||||
# Multi-ko check
|
||||
LOCAL_DEV_NAME := $(patsubst .%,%,\
|
||||
$(lastword $(strip $(subst /, ,$(LOCAL_PATH)))))
|
||||
|
||||
ifeq (1, $(strip $(shell expr $(words $(strip $(TARGET_WLAN_CHIP))) \>= 2)))
|
||||
|
||||
ifeq ($(LOCAL_DEV_NAME), qcacld-3.0)
|
||||
LOCAL_MULTI_KO := true
|
||||
else
|
||||
LOCAL_MULTI_KO := false
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(LOCAL_MULTI_KO), true)
|
||||
LOCAL_ANDROID_ROOT := $(shell pwd)
|
||||
LOCAL_WLAN_BLD_DIR := $(LOCAL_ANDROID_ROOT)/$(WLAN_BLD_DIR)
|
||||
$(shell find $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/ -maxdepth 1 \
|
||||
-name '.*' ! -name '.git' -exec rm -rf {} +)
|
||||
|
||||
$(foreach chip, $(TARGET_WLAN_CHIP), \
|
||||
$($(shell mkdir -p $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/.$(chip); \
|
||||
ln -sf $(LOCAL_WLAN_BLD_DIR)/qca-wifi-host-cmn \
|
||||
$(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/.$(chip)/qca-wifi-host-cmn); \
|
||||
$(foreach node, \
|
||||
$(shell find $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/ -maxdepth 1 \
|
||||
! -name '.*' ! -name '*~' \
|
||||
! -name '.' ! -name 'qcacld-3.0'), \
|
||||
$(shell ln -sf $(node) \
|
||||
$(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/.$(chip)/$(lastword $(strip $(subst /, ,$(node)))) \
|
||||
))))
|
||||
|
||||
include $(foreach chip, $(TARGET_WLAN_CHIP), $(LOCAL_PATH)/.$(chip)/Android.mk)
|
||||
|
||||
else # Multi-ok check
|
||||
|
||||
ifeq ($(WLAN_PROFILE),)
|
||||
WLAN_PROFILE := default
|
||||
endif
|
||||
|
||||
ifeq ($(LOCAL_DEV_NAME), qcacld-3.0)
|
||||
|
||||
LOCAL_DEV_NAME := wlan
|
||||
LOCAL_MOD_NAME := wlan
|
||||
CMN_OFFSET := ..
|
||||
LOCAL_SRC_DIR :=
|
||||
TARGET_FW_DIR := firmware/wlan/qca_cld
|
||||
TARGET_CFG_PATH := /vendor/etc/wifi
|
||||
TARGET_MAC_BIN_PATH := /mnt/vendor/persist
|
||||
|
||||
else
|
||||
|
||||
LOCAL_SRC_DIR := .$(LOCAL_DEV_NAME)
|
||||
CMN_OFFSET := .
|
||||
# Use default profile if WLAN_CFG_USE_DEFAULT defined.
|
||||
ifeq ($(WLAN_CFG_USE_DEFAULT),)
|
||||
WLAN_PROFILE := $(LOCAL_DEV_NAME)
|
||||
endif
|
||||
TARGET_FW_DIR := firmware/wlan/qca_cld/$(LOCAL_DEV_NAME)
|
||||
TARGET_CFG_PATH := /vendor/etc/wifi/$(LOCAL_DEV_NAME)
|
||||
TARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_DEV_NAME)
|
||||
|
||||
ifneq ($(TARGET_MULTI_WLAN), true)
|
||||
LOCAL_MOD_NAME := wlan
|
||||
DYNAMIC_SINGLE_CHIP := $(LOCAL_DEV_NAME)
|
||||
else
|
||||
LOCAL_MOD_NAME := $(LOCAL_DEV_NAME)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# DLKM_DIR was moved for JELLY_BEAN (PLATFORM_SDK 16)
|
||||
ifeq ($(call is-platform-sdk-version-at-least,16),true)
|
||||
DLKM_DIR := $(TOP)/device/qcom/common/dlkm
|
||||
else
|
||||
DLKM_DIR := build/dlkm
|
||||
endif # platform-sdk-version
|
||||
|
||||
# Build wlan.ko as $(WLAN_CHIPSET)_wlan.ko
|
||||
###########################################################
|
||||
# This is set once per LOCAL_PATH, not per (kernel) module
|
||||
KBUILD_OPTIONS := WLAN_ROOT=$(WLAN_BLD_DIR)/qcacld-3.0/$(LOCAL_SRC_DIR)
|
||||
KBUILD_OPTIONS += WLAN_COMMON_ROOT=$(CMN_OFFSET)/qca-wifi-host-cmn
|
||||
KBUILD_OPTIONS += WLAN_COMMON_INC=$(WLAN_BLD_DIR)/qca-wifi-host-cmn
|
||||
KBUILD_OPTIONS += WLAN_FW_API=$(WLAN_BLD_DIR)/fw-api
|
||||
KBUILD_OPTIONS += WLAN_PROFILE=$(WLAN_PROFILE)
|
||||
KBUILD_OPTIONS += DYNAMIC_SINGLE_CHIP=$(DYNAMIC_SINGLE_CHIP)
|
||||
|
||||
# We are actually building wlan.ko here, as per the
|
||||
# requirement we are specifying <chipset>_wlan.ko as LOCAL_MODULE.
|
||||
# This means we need to rename the module to <chipset>_wlan.ko
|
||||
# after wlan.ko is built.
|
||||
KBUILD_OPTIONS += MODNAME=$(LOCAL_MOD_NAME)
|
||||
KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
|
||||
KBUILD_OPTIONS += $(WLAN_SELECT)
|
||||
|
||||
ifneq ($(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME)),)
|
||||
KBUILD_OPTIONS += WLAN_CFG_OVERRIDE="$(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME))"
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := $(WLAN_CHIPSET)_$(LOCAL_DEV_NAME).ko
|
||||
LOCAL_MODULE_KBUILD_NAME := $(LOCAL_MOD_NAME).ko
|
||||
LOCAL_MODULE_DEBUG_ENABLE := true
|
||||
ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
|
||||
ifeq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
else
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)
|
||||
endif
|
||||
else
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/modules/$(WLAN_CHIPSET)
|
||||
endif
|
||||
|
||||
include $(DLKM_DIR)/AndroidKernelModule.mk
|
||||
###########################################################
|
||||
|
||||
# Create Symbolic link
|
||||
ifneq ($(findstring $(WLAN_CHIPSET),$(WIFI_DRIVER_DEFAULT)),)
|
||||
ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
|
||||
ifneq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),)
|
||||
$(shell mkdir -p $(TARGET_OUT_VENDOR)/lib/modules; \
|
||||
ln -sf /$(TARGET_COPY_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE) $(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE))
|
||||
endif
|
||||
else
|
||||
$(shell mkdir -p $(TARGET_OUT)/lib/modules; \
|
||||
ln -sf /system/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE) $(TARGET_OUT)/lib/modules/$(LOCAL_MODULE))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
|
||||
TARGET_FW_PATH := $(TARGET_OUT_VENDOR)/$(TARGET_FW_DIR)
|
||||
else
|
||||
TARGET_FW_PATH := $(TARGET_OUT_ETC)/$(TARGET_FW_DIR)
|
||||
endif
|
||||
|
||||
$(shell mkdir -p $(TARGET_FW_PATH); \
|
||||
ln -sf $(TARGET_MAC_BIN_PATH)/wlan_mac.bin $(TARGET_FW_PATH)/wlan_mac.bin)
|
||||
ifneq ($(GENERIC_ODM_IMAGE),true)
|
||||
$(shell ln -sf $(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
|
||||
endif
|
||||
endif # Multi-ko check
|
||||
endif # DLKM check
|
||||
endif # supported target check
|
||||
endif # WLAN enabled check
|
||||
endif # ENABLE_QCACLD
|
@ -5,10 +5,6 @@ ifeq ($(MODNAME),)
|
||||
else
|
||||
KERNEL_BUILD := n
|
||||
endif
|
||||
|
||||
# Force user build
|
||||
TARGET_BUILD_VARIANT := user
|
||||
|
||||
ifeq ($(KERNEL_BUILD), y)
|
||||
# These are provided in external module based builds
|
||||
# Need to explicitly define for Kernel-based builds
|
||||
@ -42,6 +38,7 @@ endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# add configurations in WLAN_CFG_OVERRIDE
|
||||
ifneq ($(WLAN_CFG_OVERRIDE),)
|
||||
WLAN_CFG_OVERRIDE_FILE := $(WLAN_ROOT)/.wlan_cfg_override
|
||||
@ -54,7 +51,7 @@ include $(WLAN_CFG_OVERRIDE_FILE)
|
||||
$(warning "Overriding WLAN config with: $(shell cat $(WLAN_CFG_OVERRIDE_FILE))")
|
||||
endif
|
||||
|
||||
include $(WLAN_ROOT)/configs/$(patsubst "%",%,$(CONFIG_QCA_CLD_WLAN_PROFILE))_defconfig
|
||||
include $(WLAN_ROOT)/configs/$(CONFIG_QCA_CLD_WLAN_PROFILE)_defconfig
|
||||
|
||||
############ UAPI ############
|
||||
UAPI_DIR := uapi
|
||||
@ -586,10 +583,8 @@ WLAN_LOGGING_INC_DIR := $(WLAN_LOGGING_DIR)/inc
|
||||
WLAN_LOGGING_SRC_DIR := $(WLAN_LOGGING_DIR)/src
|
||||
|
||||
WLAN_LOGGING_INC := -I$(WLAN_ROOT)/$(WLAN_LOGGING_INC_DIR)
|
||||
ifeq ($(BUILD_DEBUG_VERSION), 1)
|
||||
WLAN_LOGGING_OBJS := $(WLAN_LOGGING_SRC_DIR)/wlan_logging_sock_svc.o \
|
||||
$(WLAN_LOGGING_SRC_DIR)/wlan_roam_debug.o
|
||||
endif
|
||||
|
||||
############ SYS ############
|
||||
SYS_DIR := core/mac/src/sys
|
||||
@ -2301,6 +2296,7 @@ ccflags-y += $(INCS)
|
||||
|
||||
cppflags-y += -DANI_OS_TYPE_ANDROID=6 \
|
||||
-Wall\
|
||||
-Werror\
|
||||
-D__linux__
|
||||
|
||||
cppflags-$(CONFIG_PTT_SOCK_SVC_ENABLE) += -DPTT_SOCK_SVC_ENABLE
|
||||
|
@ -9,12 +9,146 @@ config QCA_CLD_WLAN
|
||||
|
||||
if QCA_CLD_WLAN != n
|
||||
|
||||
config QCA_CLD_WLAN_PROFILE
|
||||
string "Configuration profile for Qualcomm Atheros CLD WLAN module"
|
||||
default "default"
|
||||
help
|
||||
Specify which configuration profile to be used for building
|
||||
this module.
|
||||
Profiles are located at drivers/staging/qcacld-3.0/configs.
|
||||
config QCACLD_WLAN_LFR3
|
||||
bool "Enable the WLAN Legacy Fast Roaming feature Version 3"
|
||||
default n
|
||||
|
||||
config PRIMA_WLAN_OKC
|
||||
bool "Enable the Prima WLAN Opportunistic Key Caching feature"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_11W
|
||||
bool "Enable the WLAN 802.11w Protected Management Frames feature"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_LPSS
|
||||
bool "Enable the WLAN LPSS feature"
|
||||
default n
|
||||
|
||||
config QCOM_VOWIFI_11R
|
||||
bool "Enable Fast Transition (11r) feature"
|
||||
default n
|
||||
|
||||
config QCACLD_FEATURE_NAN
|
||||
bool "Enable NAN feature"
|
||||
default n
|
||||
|
||||
config QCACLD_FEATURE_GREEN_AP
|
||||
bool "Enable Green AP feature"
|
||||
default n
|
||||
|
||||
config HELIUMPLUS
|
||||
bool "Enable Beeliner based descriptor structures for Helium"
|
||||
default n
|
||||
|
||||
config 64BIT_PADDR
|
||||
bool "Enable 37-bit physical/bus addresses"
|
||||
depends on HELIUMPLUS
|
||||
default n
|
||||
|
||||
config QCOM_TDLS
|
||||
bool "Enable TDLS feature"
|
||||
default n
|
||||
|
||||
config QCOM_LTE_COEX
|
||||
bool "Enable QCOM LTE Coex feature"
|
||||
default n
|
||||
|
||||
config MPC_UT_FRAMEWORK
|
||||
bool "Enable Unit test framework for multiport concurrency"
|
||||
default n
|
||||
|
||||
config WLAN_OFFLOAD_PACKETS
|
||||
bool "Enable offload packets feature"
|
||||
default n
|
||||
|
||||
config FEATURE_TSO
|
||||
bool "Enable TCP Segmentation Offload"
|
||||
depends on HELIUMPLUS
|
||||
default n
|
||||
|
||||
config FEATURE_TSO_DEBUG
|
||||
bool "Enable TCP Segmentation Offload with debug"
|
||||
depends on FEATURE_TSO
|
||||
default n
|
||||
|
||||
config WLAN_FASTPATH
|
||||
bool "Enable fastpath for datapackets"
|
||||
default n
|
||||
|
||||
config WLAN_NAPI
|
||||
bool "Enable NAPI - datapath rx"
|
||||
default n
|
||||
|
||||
config WLAN_NAPI_DEBUG
|
||||
bool "Enable debug logging on NAPI"
|
||||
depends on WLAN_NAPI
|
||||
default n
|
||||
|
||||
config WLAN_TX_FLOW_CONTROL_V2
|
||||
bool "Enable tx flow control version:2"
|
||||
default n
|
||||
|
||||
config WLAN_LRO
|
||||
bool "Enable Large Receive Offload"
|
||||
depends on HELIUMPLUS
|
||||
depends on INET_LRO
|
||||
default n
|
||||
|
||||
config WLAN_SYNC_TSF
|
||||
bool "Enable QCOM sync multi devices tsf feature"
|
||||
default n
|
||||
|
||||
config LFR_SUBNET_DETECTION
|
||||
bool "Enable LFR Subnet Change Detection"
|
||||
default n
|
||||
|
||||
config MCC_TO_SCC_SWITCH
|
||||
bool "Enable MCC to SCC Switch Logic"
|
||||
default n
|
||||
|
||||
config QCACLD_WLAN_LFR2
|
||||
bool "Enable the WLAN Legacy Fast Roaming feature Version 2"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_DISA
|
||||
bool "Enable DISA certification feature"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_FIPS
|
||||
bool "Enable FIPS certification feature"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_11AX
|
||||
bool "Enable 11AX(High Efficiency) feature"
|
||||
default n
|
||||
|
||||
config ICMP_DISABLE_PS
|
||||
bool "Enable ICMP packet disable powersave feature"
|
||||
default n
|
||||
|
||||
config BUILD_TIMESTAMP
|
||||
bool "Embed timestamp in wlan version"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_FILS
|
||||
bool "Enable FILS feature"
|
||||
default n
|
||||
|
||||
config NAN_CONVERGENCE
|
||||
bool "Enable NAN_CONVERGENCE feature"
|
||||
default n
|
||||
|
||||
config WLAN_OBJMGR_DEBUG
|
||||
bool "Enable WLAN Obj Mgr Debug services"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_DFS_OFFLOAD
|
||||
bool "Enable dfs offload feature"
|
||||
default n
|
||||
|
||||
config WLAN_FEATURE_SARV1_TO_SARV2
|
||||
bool "Enable conversion of SAR v1 to v2 feature"
|
||||
default n
|
||||
|
||||
endif # QCA_CLD_WLAN
|
||||
|
@ -59,6 +59,7 @@ ifeq ($(CONFIG_ICNSS), y)
|
||||
CONFIG_HELIUMPLUS := y
|
||||
CONFIG_64BIT_PADDR := y
|
||||
CONFIG_FEATURE_TSO := y
|
||||
CONFIG_FEATURE_TSO_DEBUG := y
|
||||
ifeq ($(CONFIG_INET_LRO), y)
|
||||
CONFIG_WLAN_LRO := y
|
||||
else
|
||||
@ -66,7 +67,6 @@ ifeq ($(CONFIG_ICNSS), y)
|
||||
endif
|
||||
endif
|
||||
|
||||
DEVELOPER_DISABLE_BUILD_TIMESTAMP := y
|
||||
ifneq ($(DEVELOPER_DISABLE_BUILD_TIMESTAMP), y)
|
||||
ifneq ($(WLAN_DISABLE_BUILD_TAG), y)
|
||||
CONFIG_BUILD_TAG := y
|
||||
@ -212,7 +212,7 @@ ifeq ($(CONFIG_ROME_IF),usb)
|
||||
endif
|
||||
|
||||
|
||||
CONFIG_FEATURE_EPPING := n
|
||||
CONFIG_FEATURE_EPPING := y
|
||||
|
||||
#Flag to enable offload packets feature
|
||||
CONFIG_WLAN_OFFLOAD_PACKETS := y
|
||||
@ -293,8 +293,8 @@ CONFIG_QMI_SUPPORT := y
|
||||
ifeq ($(CONFIG_ICNSS), y)
|
||||
CONFIG_WIFI_3_0_ADRASTEA := y
|
||||
CONFIG_ADRASTEA_RRI_ON_DDR := y
|
||||
# Disable athdiag procfs debug support for adrastea
|
||||
CONFIG_ATH_PROCFS_DIAG_SUPPORT := n
|
||||
# Enable athdiag procfs debug support for adrastea
|
||||
CONFIG_ATH_PROCFS_DIAG_SUPPORT := y
|
||||
# Enable 11AC TX compact feature for adrastea
|
||||
CONFIG_ATH_11AC_TXCOMPACT := y
|
||||
ifeq ($(CONFIG_QMI_SUPPORT), y)
|
||||
@ -336,7 +336,9 @@ CONFIG_QCA_WIFI_QCA8074 := y
|
||||
CONFIG_QCA_WIFI_QCA8074_VP := y
|
||||
CONFIG_DP_INTR_POLL_BASED := y
|
||||
CONFIG_TX_PER_PDEV_DESC_POOL := y
|
||||
CONFIG_DP_TRACE := y
|
||||
CONFIG_FEATURE_TSO := y
|
||||
CONFIG_TSO_DEBUG_LOG_ENABLE := y
|
||||
CONFIG_DP_LFR := y
|
||||
CONFIG_HTT_PADDR64 := y
|
||||
CONFIG_RX_OL := y
|
||||
@ -369,24 +371,21 @@ ifneq ($(TARGET_BUILD_VARIANT),user)
|
||||
endif
|
||||
|
||||
#Enable WLAN/Power debugfs feature only if debug_fs is enabled
|
||||
# ifeq ($(CONFIG_DEBUG_FS), y)
|
||||
ifeq ($(CONFIG_DEBUG_FS), y)
|
||||
# Flag to enable debugfs. Depends on CONFIG_DEBUG_FS in kernel
|
||||
# configuration.
|
||||
# CONFIG_WLAN_DEBUGFS := y
|
||||
CONFIG_WLAN_DEBUGFS := y
|
||||
|
||||
# CONFIG_WLAN_POWER_DEBUGFS := y
|
||||
# endif
|
||||
|
||||
#Disable WLAN/Power debugging
|
||||
CONFIG_WLAN_POWER_DEBUG := n
|
||||
CONFIG_WLAN_POWER_DEBUGFS := y
|
||||
endif
|
||||
|
||||
# Feature flags which are not (currently) configurable via Kconfig
|
||||
|
||||
#Whether to build debug version
|
||||
BUILD_DEBUG_VERSION := n
|
||||
BUILD_DEBUG_VERSION := y
|
||||
|
||||
#Enable this flag to build driver in diag version
|
||||
BUILD_DIAG_VERSION := n
|
||||
BUILD_DIAG_VERSION := y
|
||||
|
||||
ifeq ($(CONFIG_SLUB_DEBUG), y)
|
||||
PANIC_ON_BUG := y
|
||||
@ -404,12 +403,15 @@ CONFIG_WLAN_LOG_FATAL := y
|
||||
CONFIG_WLAN_LOG_ERROR := y
|
||||
CONFIG_WLAN_LOG_WARN := y
|
||||
CONFIG_WLAN_LOG_INFO := y
|
||||
CONFIG_WLAN_LOG_DEBUG := y
|
||||
CONFIG_WLAN_LOG_ENTER := y
|
||||
CONFIG_WLAN_LOG_EXIT := y
|
||||
|
||||
#Enable OL debug and wmi unified functions
|
||||
CONFIG_ATH_PERF_PWR_OFFLOAD := y
|
||||
|
||||
#Disable packet log
|
||||
CONFIG_REMOVE_PKT_LOG := y
|
||||
CONFIG_REMOVE_PKT_LOG := n
|
||||
|
||||
#Enable 11AC TX
|
||||
ifeq ($(CONFIG_ROME_IF),pci)
|
||||
@ -565,8 +567,8 @@ CONFIG_QCA_SIGNED_SPLIT_BINARY_SUPPORT := n
|
||||
#Enable single firmware binary format
|
||||
CONFIG_QCA_SINGLE_BINARY_SUPPORT := n
|
||||
|
||||
#Disable collecting target RAM dump after kernel panic
|
||||
CONFIG_TARGET_RAMDUMP_AFTER_KERNEL_PANIC := n
|
||||
#Enable collecting target RAM dump after kernel panic
|
||||
CONFIG_TARGET_RAMDUMP_AFTER_KERNEL_PANIC := y
|
||||
|
||||
#Flag to enable/disable secure firmware feature
|
||||
CONFIG_FEATURE_SECURE_FIRMWARE := n
|
||||
@ -582,13 +584,13 @@ CONFIG_WLAN_DFS_STATIC_MEM_ALLOC := y
|
||||
CONFIG_FEATURE_HTC_CREDIT_HISTORY := y
|
||||
|
||||
#Flag to enable MTRACE feature
|
||||
CONFIG_TRACE_RECORD_FEATURE := n
|
||||
CONFIG_TRACE_RECORD_FEATURE := y
|
||||
|
||||
#Flag to enable p2p debug feature
|
||||
CONFIG_WLAN_FEATURE_P2P_DEBUG := n
|
||||
CONFIG_WLAN_FEATURE_P2P_DEBUG := y
|
||||
|
||||
#Flag to enable roam debug log
|
||||
CONFIG_FEATURE_ROAM_DEBUG := n
|
||||
CONFIG_FEATURE_ROAM_DEBUG := y
|
||||
|
||||
#Flag to enable DFS Master feature
|
||||
CONFIG_WLAN_DFS_MASTER_ENABLE := y
|
||||
@ -597,10 +599,10 @@ CONFIG_WLAN_DFS_MASTER_ENABLE := y
|
||||
CONFIG_WLAN_WEXT_SUPPORT_ENABLE := y
|
||||
|
||||
#Flag to enable/disable MTRACE feature
|
||||
CONFIG_ENABLE_MTRACE_LOG := n
|
||||
CONFIG_ENABLE_MTRACE_LOG := y
|
||||
|
||||
#Flag to enable nud tracking feature
|
||||
CONFIG_WLAN_NUD_TRACKING := n
|
||||
CONFIG_WLAN_NUD_TRACKING := y
|
||||
|
||||
#Flag to enable wbuff feature
|
||||
CONFIG_WLAN_WBUFF := y
|
||||
@ -623,7 +625,7 @@ CONFIG_FEATURE_WLAN_WAPI := y
|
||||
CONFIG_AGEIE_ON_SCAN_RESULTS := y
|
||||
|
||||
#Flag to enable FW log parsing support feature
|
||||
CONFIG_FEATURE_FW_LOG_PARSING := n
|
||||
CONFIG_FEATURE_FW_LOG_PARSING := y
|
||||
|
||||
CONFIG_PTT_SOCK_SVC_ENABLE := y
|
||||
CONFIG_SOFTAP_CHANNEL_RANGE := y
|
||||
@ -633,7 +635,7 @@ CONFIG_WLAN_NS_OFFLOAD := y
|
||||
CONFIG_FEATURE_WLAN_RA_FILTERING:= y
|
||||
CONFIG_FEATURE_WLAN_LPHB := y
|
||||
CONFIG_QCA_SUPPORT_TX_THROTTLE := y
|
||||
CONFIG_WMI_INTERFACE_EVENT_LOGGING := n
|
||||
CONFIG_WMI_INTERFACE_EVENT_LOGGING := y
|
||||
CONFIG_WLAN_FEATURE_LINK_LAYER_STATS := y
|
||||
CONFIG_WLAN_FEATURE_MIB_STATS := y
|
||||
CONFIG_FEATURE_WLAN_EXTSCAN := n
|
||||
@ -712,7 +714,7 @@ ifeq ($(CONFIG_LITHIUM), y)
|
||||
endif
|
||||
|
||||
#Flag to enable hdd memory dump feature
|
||||
CONFIG_FEATURE_MEMDUMP_ENABLE := n
|
||||
CONFIG_FEATURE_MEMDUMP_ENABLE := y
|
||||
|
||||
#Flag to enable/disable WLAN D0-WOW
|
||||
ifeq ($(CONFIG_PCI_MSM), y)
|
||||
@ -736,7 +738,9 @@ ifeq ($(CONFIG_ARCH_SDXPRAIRIE), y)
|
||||
endif
|
||||
endif
|
||||
|
||||
CONFIG_WLAN_LOGGING_SOCK_SVC := n
|
||||
ifneq ($(CONFIG_HIF_USB), y)
|
||||
CONFIG_WLAN_LOGGING_SOCK_SVC := y
|
||||
endif
|
||||
|
||||
ifneq ($(TARGET_BUILD_VARIANT),user)
|
||||
CONFIG_DESC_DUP_DETECT_DEBUG := y
|
||||
@ -771,8 +775,8 @@ endif
|
||||
CONFIG_SM_ENG_HIST := n
|
||||
|
||||
ifeq ($(CONFIG_WLAN_SYSFS), y)
|
||||
#Disable Beacon Reception Stats
|
||||
CONFIG_FEATURE_BECN_STATS := n
|
||||
#Enable Beacon Reception Stats
|
||||
CONFIG_FEATURE_BECN_STATS := y
|
||||
endif
|
||||
|
||||
ifeq (y,$(findstring y,$(CONFIG_ARCH_MSM) $(CONFIG_ARCH_QCOM)))
|
||||
|
@ -616,9 +616,7 @@ int ol_copy_ramdump(struct hif_opaque_softc *scn)
|
||||
|
||||
static void __ramdump_work_handler(void *data)
|
||||
{
|
||||
#ifdef WLAN_DEBUG
|
||||
int ret;
|
||||
#endif
|
||||
uint32_t host_interest_address;
|
||||
uint32_t dram_dump_values[4];
|
||||
uint32_t target_type;
|
||||
|
@ -2338,7 +2338,6 @@ void htt_rx_detach(struct htt_pdev_t *pdev)
|
||||
qdf_spinlock_destroy(&pdev->rx_ring.refill_lock);
|
||||
}
|
||||
|
||||
#ifndef REMOVE_PKT_LOG
|
||||
static QDF_STATUS htt_rx_hash_smmu_map(bool map, struct htt_pdev_t *pdev)
|
||||
{
|
||||
uint32_t i;
|
||||
@ -2412,4 +2411,3 @@ QDF_STATUS htt_rx_update_smmu_map(struct htt_pdev_t *pdev, bool map)
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
@ -1000,7 +1000,6 @@ htt_rx_offload_paddr_msdu_pop_ll(htt_pdev_handle pdev,
|
||||
|
||||
uint32_t htt_rx_amsdu_rx_in_order_get_pktlog(qdf_nbuf_t rx_ind_msg);
|
||||
|
||||
#ifndef REMOVE_PKT_LOG
|
||||
/**
|
||||
* htt_rx_update_smmu_map() - set smmu map/unmap for rx buffers
|
||||
* @pdev: htt pdev handle
|
||||
@ -1009,12 +1008,6 @@ uint32_t htt_rx_amsdu_rx_in_order_get_pktlog(qdf_nbuf_t rx_ind_msg);
|
||||
* Return: QDF_STATUS
|
||||
*/
|
||||
QDF_STATUS htt_rx_update_smmu_map(struct htt_pdev_t *pdev, bool map);
|
||||
#else
|
||||
static inline QDF_STATUS htt_rx_update_smmu_map(struct htt_pdev_t *pdev, bool map)
|
||||
{
|
||||
return QDF_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** htt_tx_enable_ppdu_end
|
||||
* @enable_ppdu_end - set it to 1 if WLAN_FEATURE_TSF_PLUS is defined,
|
||||
|
@ -1101,6 +1101,30 @@
|
||||
CFG_INI_BOOL("enable_multicast_replay_filter", \
|
||||
true, "Enable filtering of replayed multicast packets")
|
||||
|
||||
/*
|
||||
* <ini>
|
||||
* rx_wakelock_timeout - Amount of time to hold wakelock for RX unicast packets
|
||||
* @Min: 0
|
||||
* @Max: 100
|
||||
* @Default: 50
|
||||
*
|
||||
* This ini item configures the amount of time, in milliseconds, that the driver
|
||||
* should prevent system power collapse after receiving an RX unicast packet.
|
||||
* A conigured value of 0 disables the RX Wakelock feature completely.
|
||||
*
|
||||
* Related: None.
|
||||
*
|
||||
* Supported Feature: RX Wakelock
|
||||
*
|
||||
* Usage: Internal/External
|
||||
*
|
||||
* </ini>
|
||||
*/
|
||||
#define CFG_DP_RX_WAKELOCK_TIMEOUT \
|
||||
CFG_INI_UINT("rx_wakelock_timeout", \
|
||||
0, 100, 50, CFG_VALUE_OR_DEFAULT, \
|
||||
"Amount of time to hold wakelock for RX unicast packets")
|
||||
|
||||
/*
|
||||
* <ini>
|
||||
* num_dp_rx_threads - Control to set the number of dp rx threads
|
||||
@ -1418,6 +1442,7 @@
|
||||
CFG(CFG_DP_CE_SERVICE_MAX_YIELD_TIME) \
|
||||
CFG(CFG_DP_ENABLE_TCP_PARAM_UPDATE) \
|
||||
CFG(CFG_DP_FILTER_MULTICAST_REPLAY) \
|
||||
CFG(CFG_DP_RX_WAKELOCK_TIMEOUT) \
|
||||
CFG(CFG_DP_NUM_DP_RX_THREADS) \
|
||||
CFG(CFG_DP_HTC_WMI_CREDIT_CNT) \
|
||||
CFG_DP_ENABLE_FASTPATH_ALL \
|
||||
|
@ -199,6 +199,7 @@ struct hdd_config {
|
||||
uint32_t rx_thread_affinity_mask;
|
||||
uint8_t cpu_map_list[CFG_DP_RPS_RX_QUEUE_CPU_MAP_LIST_LEN];
|
||||
bool multicast_replay_filter;
|
||||
uint32_t rx_wakelock_timeout;
|
||||
uint8_t num_dp_rx_threads;
|
||||
#ifdef CONFIG_DP_TRACE
|
||||
bool enable_dp_trace;
|
||||
|
@ -1877,6 +1877,7 @@ struct hdd_context {
|
||||
/** P2P Device MAC Address for the adapter */
|
||||
struct qdf_mac_addr p2p_device_address;
|
||||
|
||||
qdf_wake_lock_t rx_wake_lock;
|
||||
qdf_wake_lock_t sap_wake_lock;
|
||||
|
||||
/* Flag keeps track of wiphy suspend/resume */
|
||||
|
@ -43,7 +43,6 @@
|
||||
|
||||
#ifdef MSM_PLATFORM
|
||||
#define WLAN_INI_FILE "wlan/qca_cld/" PREFIX "WCNSS_qcom_cfg.ini"
|
||||
#define WLAN_INI_FILE_DEFAULT "wlan/qca_cld/qca6390/" PREFIX "WCNSS_qcom_cfg.ini"
|
||||
#define WLAN_MAC_FILE "wlan/qca_cld/" PREFIX "wlan_mac.bin"
|
||||
#else
|
||||
#define WLAN_INI_FILE "wlan/" PREFIX "qcom_cfg.ini"
|
||||
|
@ -2384,11 +2384,9 @@ QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter,
|
||||
hdd_conn_set_authenticated(adapter, true);
|
||||
hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, true);
|
||||
} else {
|
||||
#ifdef WLAN_DEBUG
|
||||
hdd_debug("ULA auth Sta: " QDF_MAC_ADDR_FMT
|
||||
" Changing TL state to CONNECTED at Join time",
|
||||
QDF_MAC_ADDR_REF(txrx_desc.peer_addr.bytes));
|
||||
#endif
|
||||
|
||||
qdf_status = hdd_conn_change_peer_state(
|
||||
adapter, roam_info,
|
||||
|
@ -232,7 +232,32 @@ static unsigned int dev_num = 1;
|
||||
static struct cdev wlan_hdd_state_cdev;
|
||||
static struct class *class;
|
||||
static dev_t device;
|
||||
static bool hdd_loaded = false;
|
||||
#ifndef MODULE
|
||||
static struct gwlan_loader *wlan_loader;
|
||||
static ssize_t wlan_boot_cb(struct kobject *kobj,
|
||||
struct kobj_attribute *attr,
|
||||
const char *buf, size_t count);
|
||||
struct gwlan_loader {
|
||||
bool loaded_state;
|
||||
struct kobject *boot_wlan_obj;
|
||||
struct attribute_group *attr_group;
|
||||
};
|
||||
|
||||
static struct kobj_attribute wlan_boot_attribute =
|
||||
__ATTR(boot_wlan, 0220, NULL, wlan_boot_cb);
|
||||
|
||||
static struct attribute *attrs[] = {
|
||||
&wlan_boot_attribute.attr,
|
||||
NULL,
|
||||
};
|
||||
#define MODULE_INITIALIZED 1
|
||||
|
||||
#ifdef MULTI_IF_NAME
|
||||
#define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME
|
||||
#else
|
||||
#define WLAN_LOADER_NAME "boot_wlan"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* the Android framework expects this param even though we don't use it */
|
||||
#define BUF_LEN 20
|
||||
@ -8734,6 +8759,32 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_rx_wake_lock_destroy() - Destroy RX wakelock
|
||||
* @hdd_ctx: HDD context.
|
||||
*
|
||||
* Destroy RX wakelock.
|
||||
*
|
||||
* Return: None.
|
||||
*/
|
||||
static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx)
|
||||
{
|
||||
qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_rx_wake_lock_create() - Create RX wakelock
|
||||
* @hdd_ctx: HDD context.
|
||||
*
|
||||
* Create RX wakelock.
|
||||
*
|
||||
* Return: None.
|
||||
*/
|
||||
static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx)
|
||||
{
|
||||
qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock");
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_context_deinit() - Deinitialize HDD context
|
||||
* @hdd_ctx: HDD context.
|
||||
@ -8752,6 +8803,8 @@ static int hdd_context_deinit(struct hdd_context *hdd_ctx)
|
||||
|
||||
hdd_sap_context_destroy(hdd_ctx);
|
||||
|
||||
hdd_rx_wake_lock_destroy(hdd_ctx);
|
||||
|
||||
hdd_scan_context_destroy(hdd_ctx);
|
||||
|
||||
qdf_list_destroy(&hdd_ctx->hdd_adapters);
|
||||
@ -11359,6 +11412,8 @@ static int hdd_context_init(struct hdd_context *hdd_ctx)
|
||||
if (ret)
|
||||
goto list_destroy;
|
||||
|
||||
hdd_rx_wake_lock_create(hdd_ctx);
|
||||
|
||||
ret = hdd_sap_context_init(hdd_ctx);
|
||||
if (ret)
|
||||
goto scan_destroy;
|
||||
@ -11382,6 +11437,7 @@ sap_destroy:
|
||||
|
||||
scan_destroy:
|
||||
hdd_scan_context_destroy(hdd_ctx);
|
||||
hdd_rx_wake_lock_destroy(hdd_ctx);
|
||||
list_destroy:
|
||||
qdf_list_destroy(&hdd_ctx->hdd_adapters);
|
||||
|
||||
@ -11850,10 +11906,6 @@ struct hdd_context *hdd_context_create(struct device *dev)
|
||||
}
|
||||
|
||||
status = cfg_parse(WLAN_INI_FILE);
|
||||
if (!QDF_IS_STATUS_ERROR(status))
|
||||
goto cfg_exit;
|
||||
|
||||
status = cfg_parse(WLAN_INI_FILE_DEFAULT);
|
||||
if (QDF_IS_STATUS_ERROR(status)) {
|
||||
hdd_err("Failed to parse cfg %s; status:%d\n",
|
||||
WLAN_INI_FILE, status);
|
||||
@ -11861,7 +11913,6 @@ struct hdd_context *hdd_context_create(struct device *dev)
|
||||
goto err_free_config;
|
||||
}
|
||||
|
||||
cfg_exit:
|
||||
ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID);
|
||||
if (ret) {
|
||||
QDF_DEBUG_PANIC("Psoc creation fails!");
|
||||
@ -12674,17 +12725,6 @@ static int hdd_update_mac_addr_to_fw(struct hdd_context *hdd_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void reverse_byte_array(uint8_t *arr, int len)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < len / 2; i++) {
|
||||
char temp = arr[i];
|
||||
arr[i] = arr[len - i - 1];
|
||||
arr[len - i - 1] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_initialize_mac_address() - API to get wlan mac addresses
|
||||
* @hdd_ctx: HDD Context
|
||||
@ -12720,7 +12760,6 @@ static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx)
|
||||
|
||||
/* Use fw provided MAC */
|
||||
if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) {
|
||||
reverse_byte_array(&hdd_ctx->hw_macaddr.bytes[0], 6);
|
||||
hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false);
|
||||
update_mac_addr_to_fw = false;
|
||||
return 0;
|
||||
@ -15578,8 +15617,6 @@ static void __hdd_inform_wifi_off(void)
|
||||
ucfg_blm_wifi_off(hdd_ctx->pdev);
|
||||
}
|
||||
|
||||
static int hdd_driver_load(void);
|
||||
|
||||
static void hdd_inform_wifi_off(void)
|
||||
{
|
||||
int ret;
|
||||
@ -15670,13 +15707,6 @@ static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!hdd_loaded) {
|
||||
if (hdd_driver_load()) {
|
||||
pr_err("%s: Failed to init hdd module\n", __func__);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cds_is_driver_loaded() || cds_is_driver_recovering()) {
|
||||
rc = wait_for_completion_timeout(&wlan_start_comp,
|
||||
msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME));
|
||||
@ -16536,10 +16566,16 @@ static int hdd_driver_load(void)
|
||||
|
||||
hdd_set_conparam(con_mode);
|
||||
|
||||
errno = wlan_hdd_state_ctrl_param_create();
|
||||
if (errno) {
|
||||
hdd_err("Failed to create ctrl param; errno:%d", errno);
|
||||
goto wakelock_destroy;
|
||||
}
|
||||
|
||||
errno = pld_init();
|
||||
if (errno) {
|
||||
hdd_err("Failed to init PLD; errno:%d", errno);
|
||||
goto wakelock_destroy;
|
||||
goto param_destroy;
|
||||
}
|
||||
|
||||
hdd_driver_mode_change_register();
|
||||
@ -16554,7 +16590,6 @@ static int hdd_driver_load(void)
|
||||
goto pld_deinit;
|
||||
}
|
||||
|
||||
hdd_loaded = true;
|
||||
hdd_debug("%s: driver loaded", WLAN_MODULE_NAME);
|
||||
|
||||
return 0;
|
||||
@ -16573,6 +16608,8 @@ pld_deinit:
|
||||
/* Wait for any ref taken on /dev/wlan to be released */
|
||||
while (qdf_atomic_read(&wlan_hdd_state_fops_ref))
|
||||
;
|
||||
param_destroy:
|
||||
wlan_hdd_state_ctrl_param_destroy();
|
||||
wakelock_destroy:
|
||||
qdf_wake_lock_destroy(&wlan_wake_lock);
|
||||
comp_deinit:
|
||||
@ -16678,6 +16715,133 @@ static void hdd_driver_unload(void)
|
||||
hdd_qdf_deinit();
|
||||
}
|
||||
|
||||
#ifndef MODULE
|
||||
/**
|
||||
* wlan_boot_cb() - Wlan boot callback
|
||||
* @kobj: object whose directory we're creating the link in.
|
||||
* @attr: attribute the user is interacting with
|
||||
* @buff: the buffer containing the user data
|
||||
* @count: number of bytes in the buffer
|
||||
*
|
||||
* This callback is invoked when the fs is ready to start the
|
||||
* wlan driver initialization.
|
||||
*
|
||||
* Return: 'count' on success or a negative error code in case of failure
|
||||
*/
|
||||
static ssize_t wlan_boot_cb(struct kobject *kobj,
|
||||
struct kobj_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
|
||||
if (wlan_loader->loaded_state) {
|
||||
hdd_err("wlan driver already initialized");
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
if (hdd_driver_load())
|
||||
return -EIO;
|
||||
|
||||
wlan_loader->loaded_state = MODULE_INITIALIZED;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_sysfs_cleanup() - cleanup sysfs
|
||||
*
|
||||
* Return: None
|
||||
*
|
||||
*/
|
||||
static void hdd_sysfs_cleanup(void)
|
||||
{
|
||||
/* remove from group */
|
||||
if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group)
|
||||
sysfs_remove_group(wlan_loader->boot_wlan_obj,
|
||||
wlan_loader->attr_group);
|
||||
|
||||
/* unlink the object from parent */
|
||||
kobject_del(wlan_loader->boot_wlan_obj);
|
||||
|
||||
/* free the object */
|
||||
kobject_put(wlan_loader->boot_wlan_obj);
|
||||
|
||||
kfree(wlan_loader->attr_group);
|
||||
kfree(wlan_loader);
|
||||
|
||||
wlan_loader = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is
|
||||
* ready
|
||||
*
|
||||
* This is creates the syfs entry boot_wlan. Which shall be invoked
|
||||
* when the filesystem is ready.
|
||||
*
|
||||
* QDF API cannot be used here since this function is called even before
|
||||
* initializing WLAN driver.
|
||||
*
|
||||
* Return: 0 for success, errno on failure
|
||||
*/
|
||||
static int wlan_init_sysfs(void)
|
||||
{
|
||||
int ret = -ENOMEM;
|
||||
|
||||
wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL);
|
||||
if (!wlan_loader)
|
||||
return -ENOMEM;
|
||||
|
||||
wlan_loader->boot_wlan_obj = NULL;
|
||||
wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)),
|
||||
GFP_KERNEL);
|
||||
if (!wlan_loader->attr_group)
|
||||
goto error_return;
|
||||
|
||||
wlan_loader->loaded_state = 0;
|
||||
wlan_loader->attr_group->attrs = attrs;
|
||||
|
||||
wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME,
|
||||
kernel_kobj);
|
||||
if (!wlan_loader->boot_wlan_obj) {
|
||||
hdd_err("sysfs create and add failed");
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
ret = sysfs_create_group(wlan_loader->boot_wlan_obj,
|
||||
wlan_loader->attr_group);
|
||||
if (ret) {
|
||||
hdd_err("sysfs create group failed; errno:%d", ret);
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error_return:
|
||||
hdd_sysfs_cleanup();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan
|
||||
*
|
||||
* Return: 0 on success or errno on failure
|
||||
*/
|
||||
static int wlan_deinit_sysfs(void)
|
||||
{
|
||||
if (!wlan_loader) {
|
||||
hdd_err("wlan_loader is null");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hdd_sysfs_cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
/**
|
||||
* hdd_module_init() - Module init helper
|
||||
*
|
||||
@ -16687,15 +16851,26 @@ static void hdd_driver_unload(void)
|
||||
*/
|
||||
static int hdd_module_init(void)
|
||||
{
|
||||
int ret;
|
||||
if (hdd_driver_load())
|
||||
return -EINVAL;
|
||||
|
||||
ret = wlan_hdd_state_ctrl_param_create();
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int __init hdd_module_init(void)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
ret = wlan_init_sysfs();
|
||||
if (ret)
|
||||
pr_err("wlan_hdd_state_create:%x\n", ret);
|
||||
hdd_err("Failed to create sysfs entry");
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MODULE
|
||||
/**
|
||||
* hdd_module_exit() - Exit function
|
||||
*
|
||||
@ -16707,6 +16882,13 @@ static void __exit hdd_module_exit(void)
|
||||
{
|
||||
hdd_driver_unload();
|
||||
}
|
||||
#else
|
||||
static void __exit hdd_module_exit(void)
|
||||
{
|
||||
hdd_driver_unload();
|
||||
wlan_deinit_sysfs();
|
||||
}
|
||||
#endif
|
||||
|
||||
static int fwpath_changed_handler(const char *kmessage,
|
||||
const struct kernel_param *kp)
|
||||
|
@ -1125,6 +1125,19 @@ QDF_STATUS hdd_softap_rx_packet_cbk(void *adapter_context, qdf_nbuf_t rx_buf)
|
||||
|
||||
skb->protocol = eth_type_trans(skb, skb->dev);
|
||||
|
||||
/* hold configurable wakelock for unicast traffic */
|
||||
if (!hdd_is_current_high_throughput(hdd_ctx) &&
|
||||
hdd_ctx->config->rx_wakelock_timeout &&
|
||||
skb->pkt_type != PACKET_BROADCAST &&
|
||||
skb->pkt_type != PACKET_MULTICAST) {
|
||||
cds_host_diag_log_work(&hdd_ctx->rx_wake_lock,
|
||||
hdd_ctx->config->rx_wakelock_timeout,
|
||||
WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
|
||||
qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock,
|
||||
hdd_ctx->config->
|
||||
rx_wakelock_timeout);
|
||||
}
|
||||
|
||||
/* Remove SKB from internal tracking table before submitting
|
||||
* it to stack
|
||||
*/
|
||||
|
@ -5602,9 +5602,7 @@ QDF_STATUS wlan_hdd_get_mib_stats(struct hdd_adapter *adapter)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef WLAN_DEBUGFS
|
||||
hdd_debugfs_process_mib_stats(adapter, stats);
|
||||
#endif
|
||||
|
||||
wlan_cfg80211_mc_cp_stats_free_stats_event(stats);
|
||||
return ret;
|
||||
|
@ -724,9 +724,6 @@ void hdd_sysfs_destroy_driver_root_obj(void)
|
||||
driver_kobject = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void hdd_sysfs_destroy_driver_root_obj(void) {}
|
||||
void hdd_sysfs_create_driver_root_obj(void) {}
|
||||
#endif
|
||||
|
||||
#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
|
||||
|
@ -1483,6 +1483,73 @@ static bool hdd_is_mcast_replay(struct sk_buff *skb)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_is_arp_local() - check if local or non local arp
|
||||
* @skb: pointer to sk_buff
|
||||
*
|
||||
* Return: true if local arp or false otherwise.
|
||||
*/
|
||||
static bool hdd_is_arp_local(struct sk_buff *skb)
|
||||
{
|
||||
struct arphdr *arp;
|
||||
struct in_ifaddr **ifap = NULL;
|
||||
struct in_ifaddr *ifa = NULL;
|
||||
struct in_device *in_dev;
|
||||
unsigned char *arp_ptr;
|
||||
__be32 tip;
|
||||
|
||||
arp = (struct arphdr *)skb->data;
|
||||
if (arp->ar_op == htons(ARPOP_REQUEST)) {
|
||||
/* if fail to acquire rtnl lock, assume it's local arp */
|
||||
if (!rtnl_trylock())
|
||||
return true;
|
||||
|
||||
in_dev = __in_dev_get_rtnl(skb->dev);
|
||||
if (in_dev) {
|
||||
for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
|
||||
ifap = &ifa->ifa_next) {
|
||||
if (!strcmp(skb->dev->name, ifa->ifa_label))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ifa && ifa->ifa_local) {
|
||||
arp_ptr = (unsigned char *)(arp + 1);
|
||||
arp_ptr += (skb->dev->addr_len + 4 +
|
||||
skb->dev->addr_len);
|
||||
memcpy(&tip, arp_ptr, 4);
|
||||
hdd_debug("ARP packet: local IP: %x dest IP: %x",
|
||||
ifa->ifa_local, tip);
|
||||
if (ifa->ifa_local == tip) {
|
||||
rtnl_unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rtnl_unlock();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_is_rx_wake_lock_needed() - check if wake lock is needed
|
||||
* @skb: pointer to sk_buff
|
||||
*
|
||||
* RX wake lock is needed for:
|
||||
* 1) Unicast data packet OR
|
||||
* 2) Local ARP data packet
|
||||
*
|
||||
* Return: true if wake lock is needed or false otherwise.
|
||||
*/
|
||||
static bool hdd_is_rx_wake_lock_needed(struct sk_buff *skb)
|
||||
{
|
||||
if ((skb->pkt_type != PACKET_BROADCAST &&
|
||||
skb->pkt_type != PACKET_MULTICAST) || hdd_is_arp_local(skb))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef RECEIVE_OFFLOAD
|
||||
/**
|
||||
* hdd_resolve_rx_ol_mode() - Resolve Rx offload method, LRO or GRO
|
||||
@ -2255,6 +2322,7 @@ QDF_STATUS hdd_rx_packet_cbk(void *adapter_context,
|
||||
struct hdd_station_ctx *sta_ctx = NULL;
|
||||
unsigned int cpu_index;
|
||||
struct qdf_mac_addr *mac_addr, *dest_mac_addr;
|
||||
bool wake_lock = false;
|
||||
uint8_t pkt_type = 0;
|
||||
bool track_arp = false;
|
||||
struct wlan_objmgr_vdev *vdev;
|
||||
@ -2364,6 +2432,21 @@ QDF_STATUS hdd_rx_packet_cbk(void *adapter_context,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* hold configurable wakelock for unicast traffic */
|
||||
if (!hdd_is_current_high_throughput(hdd_ctx) &&
|
||||
hdd_ctx->config->rx_wakelock_timeout &&
|
||||
sta_ctx->conn_info.is_authenticated)
|
||||
wake_lock = hdd_is_rx_wake_lock_needed(skb);
|
||||
|
||||
if (wake_lock) {
|
||||
cds_host_diag_log_work(&hdd_ctx->rx_wake_lock,
|
||||
hdd_ctx->config->rx_wakelock_timeout,
|
||||
WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
|
||||
qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock,
|
||||
hdd_ctx->config->
|
||||
rx_wakelock_timeout);
|
||||
}
|
||||
|
||||
/* Remove SKB from internal tracking table before submitting
|
||||
* it to stack
|
||||
*/
|
||||
@ -3440,6 +3523,8 @@ void hdd_dp_cfg_update(struct wlan_objmgr_psoc *psoc,
|
||||
hdd_set_rx_mode_value(hdd_ctx);
|
||||
config->multicast_replay_filter =
|
||||
cfg_get(psoc, CFG_DP_FILTER_MULTICAST_REPLAY);
|
||||
config->rx_wakelock_timeout =
|
||||
cfg_get(psoc, CFG_DP_RX_WAKELOCK_TIMEOUT);
|
||||
config->num_dp_rx_threads = cfg_get(psoc, CFG_DP_NUM_DP_RX_THREADS);
|
||||
config->cfg_wmi_credit_cnt = cfg_get(psoc, CFG_DP_HTC_WMI_CREDIT_CNT);
|
||||
hdd_dp_dp_trace_cfg_update(config, psoc);
|
||||
|
@ -50,11 +50,11 @@ static inline void mac_trace(struct mac_context *mac_ctx, uint8_t code,
|
||||
qdf_trace(QDF_MODULE_ID_PE, code, session, data);
|
||||
}
|
||||
|
||||
#ifdef TRACE_RECORD
|
||||
|
||||
#define eLOG_NODROP_MISSED_BEACON_SCENARIO 0
|
||||
#define eLOG_PROC_DEAUTH_FRAME_SCENARIO 1
|
||||
|
||||
#ifdef TRACE_RECORD
|
||||
|
||||
uint8_t *mac_trace_get_lim_msg_string(uint16_t limMsg);
|
||||
uint8_t *mac_trace_get_sme_msg_string(uint16_t smeMsg);
|
||||
uint8_t *mac_trace_get_info_log_string(uint16_t infoLog);
|
||||
|
@ -13633,20 +13633,16 @@ static QDF_STATUS csr_roam_start_wait_for_key_timer(
|
||||
{
|
||||
QDF_STATUS status;
|
||||
uint8_t session_id = mac->roam.WaitForKeyTimerInfo.vdev_id;
|
||||
#ifdef WLAN_DEBUG
|
||||
tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
|
||||
&mac->roam.neighborRoamInfo[session_id];
|
||||
#endif
|
||||
|
||||
if (csr_neighbor_roam_is_handoff_in_progress(mac, session_id)) {
|
||||
/* Disable heartbeat timer when hand-off is in progress */
|
||||
#ifdef WLAN_DEBUG
|
||||
sme_debug("disabling HB timer in state: %s sub-state: %s",
|
||||
mac_trace_get_neighbour_roam_state(
|
||||
pNeighborRoamInfo->neighborRoamState),
|
||||
mac_trace_getcsr_roam_sub_state(
|
||||
mac->roam.curSubState[session_id]));
|
||||
#endif
|
||||
mac->mlme_cfg->timeouts.heart_beat_threshold = 0;
|
||||
}
|
||||
sme_debug("csrScanStartWaitForKeyTimer");
|
||||
|
@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
ccflags-y := -I $(srctree)/drivers/net/ethernet/chelsio/cxgb4
|
||||
ccflags-y += -I $(srctree)/drivers/net/ethernet/chelsio/libcxgb
|
||||
ccflags-y += -I $(srctree)/drivers/target/iscsi
|
||||
ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb4
|
||||
ccflags-y += -Idrivers/net/ethernet/chelsio/libcxgb
|
||||
ccflags-y += -Idrivers/target/iscsi
|
||||
|
||||
obj-$(CONFIG_ISCSI_TARGET_CXGB4) += cxgbit.o
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Rewritten to use lists instead of if-statements.
|
||||
#
|
||||
|
||||
ccflags-y := -I $(srctree)/drivers/scsi
|
||||
ccflags-y := -Idrivers/scsi
|
||||
|
||||
obj-$(CONFIG_USB_UAS) += uas.o
|
||||
obj-$(CONFIG_USB_STORAGE) += usb-storage.o
|
||||
|
@ -1,6 +1,7 @@
|
||||
ccflags-y := -I $(srctree)/$(src)/..
|
||||
ccflags-y := -I$(src)/..
|
||||
|
||||
obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o
|
||||
|
||||
ocfs2_dlm-objs := dlmdomain.o dlmdebug.o dlmthread.o dlmrecovery.o \
|
||||
dlmmaster.o dlmast.o dlmconvert.o dlmlock.o dlmunlock.o
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
ccflags-y := -I $(srctree)/$(src)/..
|
||||
ccflags-y := -I$(src)/..
|
||||
|
||||
obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
# All Rights Reserved.
|
||||
#
|
||||
|
||||
ccflags-y += -I $(srctree)/$(src) # needed for trace events
|
||||
ccflags-y += -I $(srctree)/$(src)/libxfs
|
||||
ccflags-y += -I$(src) # needed for trace events
|
||||
ccflags-y += -I$(src)/libxfs
|
||||
|
||||
ccflags-$(CONFIG_XFS_DEBUG) += -g
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
hostprogs-y := bpfilter_umh
|
||||
bpfilter_umh-objs := main.o
|
||||
KBUILD_HOSTCFLAGS += -I $(srctree)/. -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi
|
||||
KBUILD_HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
|
||||
HOSTCC := $(CC)
|
||||
|
||||
ifeq ($(CONFIG_BPFILTER_UMH), y)
|
||||
|
@ -46,7 +46,8 @@ build_unifdef: $(obj)/unifdef
|
||||
subdir-$(CONFIG_MODVERSIONS) += genksyms
|
||||
subdir-y += mod
|
||||
subdir-$(CONFIG_SECURITY_SELINUX) += selinux
|
||||
subdir-$(CONFIG_DTC) += dtc
|
||||
subdir-$(CONFIG_GDB_SCRIPTS) += gdb
|
||||
|
||||
# Let clean descend into subdirs
|
||||
subdir- += basic dtc kconfig package gcc-plugins
|
||||
subdir- += basic kconfig package gcc-plugins
|
||||
|
@ -15,7 +15,7 @@ cmd_dtbo_verify = $(foreach m,\
|
||||
$(addprefix $(obj)/,$($(@F)-base)),\
|
||||
$(if $(m),\
|
||||
$(DTC_OVERLAY_TEST) $(m) $@ \
|
||||
$(dot-target).$(subst /,-,$(patsubst $(obj)/%.dtb,%,$(m))).tmp;))\
|
||||
$(dot-target).$(patsubst $(obj)/%.dtb,%,$(m)).tmp;))\
|
||||
true
|
||||
else
|
||||
cmd_dtbo_verify = true
|
||||
|
@ -304,8 +304,8 @@ endif
|
||||
|
||||
quiet_cmd_dtc = DTC $@
|
||||
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
|
||||
$(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
|
||||
$(DTC) -q -O dtb -o $@ -b 0 \
|
||||
$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
|
||||
$(DTC) -O dtb -o $@ -b 0 \
|
||||
$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
|
||||
-d $(depfile).dtc.tmp $(dtc-tmp) ; \
|
||||
cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
|
||||
@ -315,11 +315,6 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
|
||||
|
||||
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
|
||||
|
||||
# mkdtimg
|
||||
#----------------------------------------------------------------------------
|
||||
quiet_cmd_mkdtimg = DTBOIMG $@
|
||||
cmd_mkdtimg = $(PYTHON) $(srctree)/scripts/mkdtboimg.py create $@ --page_size=4096 $(filter-out FORCE,$^)
|
||||
|
||||
# cat
|
||||
# ---------------------------------------------------------------------------
|
||||
# Concatentate multiple files together
|
||||
|
@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# scripts/dtc makefile
|
||||
|
||||
hostprogs-$(CONFIG_DTC) := dtc
|
||||
hostprogs-y := dtc
|
||||
ifeq ($(DTC_EXT),)
|
||||
always := $(hostprogs-y)
|
||||
endif
|
||||
@ -11,18 +11,11 @@ dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
|
||||
dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
|
||||
|
||||
# Source files need to get at the userspace version of libfdt_env.h to compile
|
||||
HOST_EXTRACFLAGS += -I $(srctree)/$(src)/libfdt
|
||||
|
||||
ifeq ($(shell pkg-config --exists yaml-0.1 2>/dev/null && echo yes),)
|
||||
HOST_EXTRACFLAGS += -DNO_YAML
|
||||
else
|
||||
dtc-objs += yamltree.o
|
||||
HOSTLDLIBS_dtc := $(shell pkg-config yaml-0.1 --libs)
|
||||
endif
|
||||
HOST_EXTRACFLAGS := -I$(src)/libfdt
|
||||
|
||||
# Generated files need one more search path to include headers in source tree
|
||||
HOSTCFLAGS_dtc-lexer.lex.o := -I $(srctree)/$(src)
|
||||
HOSTCFLAGS_dtc-parser.tab.o := -I $(srctree)/$(src)
|
||||
HOSTCFLAGS_dtc-lexer.lex.o := -I$(src)
|
||||
HOSTCFLAGS_dtc-parser.tab.o := -I$(src)
|
||||
|
||||
# dependencies on generated files need to be listed explicitly
|
||||
$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
|
||||
|
@ -1,4 +1,3 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Makefile.dtc
|
||||
#
|
||||
# This is not a complete Makefile of itself. Instead, it is designed to
|
||||
@ -15,9 +14,5 @@ DTC_SRCS = \
|
||||
treesource.c \
|
||||
util.c
|
||||
|
||||
ifneq ($(NO_YAML),1)
|
||||
DTC_SRCS += yamltree.c
|
||||
endif
|
||||
|
||||
DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c
|
||||
DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o)
|
||||
|
@ -1,10 +1,24 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2007.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include "dtc.h"
|
||||
#include "srcpos.h"
|
||||
|
||||
#ifdef TRACE_CHECKS
|
||||
#define TRACE(c, ...) \
|
||||
@ -64,56 +78,23 @@ static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *str = NULL;
|
||||
struct srcpos *pos = NULL;
|
||||
char *file_str;
|
||||
|
||||
if (!(c->warn && (quiet < 1)) && !(c->error && (quiet < 2)))
|
||||
return;
|
||||
|
||||
if (prop && prop->srcpos)
|
||||
pos = prop->srcpos;
|
||||
else if (node && node->srcpos)
|
||||
pos = node->srcpos;
|
||||
|
||||
if (pos) {
|
||||
file_str = srcpos_string(pos);
|
||||
xasprintf(&str, "%s", file_str);
|
||||
free(file_str);
|
||||
} else if (streq(dti->outname, "-")) {
|
||||
xasprintf(&str, "<stdout>");
|
||||
} else {
|
||||
xasprintf(&str, "%s", dti->outname);
|
||||
}
|
||||
|
||||
xasprintf_append(&str, ": %s (%s): ",
|
||||
(c->error) ? "ERROR" : "Warning", c->name);
|
||||
|
||||
if (node) {
|
||||
if (prop)
|
||||
xasprintf_append(&str, "%s:%s: ", node->fullpath, prop->name);
|
||||
else
|
||||
xasprintf_append(&str, "%s: ", node->fullpath);
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
xavsprintf_append(&str, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
xasprintf_append(&str, "\n");
|
||||
|
||||
if (!prop && pos) {
|
||||
pos = node->srcpos;
|
||||
while (pos->next) {
|
||||
pos = pos->next;
|
||||
|
||||
file_str = srcpos_string(pos);
|
||||
xasprintf_append(&str, " also defined at %s\n", file_str);
|
||||
free(file_str);
|
||||
if ((c->warn && (quiet < 1))
|
||||
|| (c->error && (quiet < 2))) {
|
||||
fprintf(stderr, "%s: %s (%s): ",
|
||||
strcmp(dti->outname, "-") ? dti->outname : "<stdout>",
|
||||
(c->error) ? "ERROR" : "Warning", c->name);
|
||||
if (node) {
|
||||
fprintf(stderr, "%s", node->fullpath);
|
||||
if (prop)
|
||||
fprintf(stderr, ":%s", prop->name);
|
||||
fputs(": ", stderr);
|
||||
}
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fputs(str, stderr);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#define FAIL(c, dti, node, ...) \
|
||||
@ -645,8 +626,6 @@ ERROR(path_references, fixup_path_references, NULL, &duplicate_node_names);
|
||||
static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
if (generate_symbols && node->labels)
|
||||
return;
|
||||
if (node->omit_if_unused && !node->is_referenced)
|
||||
delete_node(node);
|
||||
}
|
||||
@ -931,7 +910,7 @@ static bool node_is_compatible(struct node *node, const char *compat)
|
||||
|
||||
for (str = prop->val.val, end = str + prop->val.len; str < end;
|
||||
str += strnlen(str, end - str) + 1) {
|
||||
if (streq(str, compat))
|
||||
if (strprefixeq(str, end - str, compat))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -942,8 +921,7 @@ static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct
|
||||
if (node_is_compatible(node, "simple-bus"))
|
||||
node->bus = &simple_bus;
|
||||
}
|
||||
WARNING(simple_bus_bridge, check_simple_bus_bridge, NULL,
|
||||
&addr_size_cells, &compatible_is_string_list);
|
||||
WARNING(simple_bus_bridge, check_simple_bus_bridge, NULL, &addr_size_cells);
|
||||
|
||||
static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
|
||||
{
|
||||
@ -984,149 +962,6 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
|
||||
}
|
||||
WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge);
|
||||
|
||||
static const struct bus_type i2c_bus = {
|
||||
.name = "i2c-bus",
|
||||
};
|
||||
|
||||
static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
|
||||
{
|
||||
if (strprefixeq(node->name, node->basenamelen, "i2c-bus") ||
|
||||
strprefixeq(node->name, node->basenamelen, "i2c-arb")) {
|
||||
node->bus = &i2c_bus;
|
||||
} else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
|
||||
struct node *child;
|
||||
for_each_child(node, child) {
|
||||
if (strprefixeq(child->name, node->basenamelen, "i2c-bus"))
|
||||
return;
|
||||
}
|
||||
node->bus = &i2c_bus;
|
||||
} else
|
||||
return;
|
||||
|
||||
if (!node->children)
|
||||
return;
|
||||
|
||||
if (node_addr_cells(node) != 1)
|
||||
FAIL(c, dti, node, "incorrect #address-cells for I2C bus");
|
||||
if (node_size_cells(node) != 0)
|
||||
FAIL(c, dti, node, "incorrect #size-cells for I2C bus");
|
||||
|
||||
}
|
||||
WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells);
|
||||
|
||||
static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
|
||||
{
|
||||
struct property *prop;
|
||||
const char *unitname = get_unitname(node);
|
||||
char unit_addr[17];
|
||||
uint32_t reg = 0;
|
||||
int len;
|
||||
cell_t *cells = NULL;
|
||||
|
||||
if (!node->parent || (node->parent->bus != &i2c_bus))
|
||||
return;
|
||||
|
||||
prop = get_property(node, "reg");
|
||||
if (prop)
|
||||
cells = (cell_t *)prop->val.val;
|
||||
|
||||
if (!cells) {
|
||||
FAIL(c, dti, node, "missing or empty reg property");
|
||||
return;
|
||||
}
|
||||
|
||||
reg = fdt32_to_cpu(*cells);
|
||||
snprintf(unit_addr, sizeof(unit_addr), "%x", reg);
|
||||
if (!streq(unitname, unit_addr))
|
||||
FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
|
||||
unit_addr);
|
||||
|
||||
for (len = prop->val.len; len > 0; len -= 4) {
|
||||
reg = fdt32_to_cpu(*(cells++));
|
||||
if (reg > 0x3ff)
|
||||
FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
|
||||
reg);
|
||||
|
||||
}
|
||||
}
|
||||
WARNING(i2c_bus_reg, check_i2c_bus_reg, NULL, ®_format, &i2c_bus_bridge);
|
||||
|
||||
static const struct bus_type spi_bus = {
|
||||
.name = "spi-bus",
|
||||
};
|
||||
|
||||
static void check_spi_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
|
||||
{
|
||||
int spi_addr_cells = 1;
|
||||
|
||||
if (strprefixeq(node->name, node->basenamelen, "spi")) {
|
||||
node->bus = &spi_bus;
|
||||
} else {
|
||||
/* Try to detect SPI buses which don't have proper node name */
|
||||
struct node *child;
|
||||
|
||||
if (node_addr_cells(node) != 1 || node_size_cells(node) != 0)
|
||||
return;
|
||||
|
||||
for_each_child(node, child) {
|
||||
struct property *prop;
|
||||
for_each_property(child, prop) {
|
||||
if (strprefixeq(prop->name, 4, "spi-")) {
|
||||
node->bus = &spi_bus;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (node->bus == &spi_bus)
|
||||
break;
|
||||
}
|
||||
|
||||
if (node->bus == &spi_bus && get_property(node, "reg"))
|
||||
FAIL(c, dti, node, "node name for SPI buses should be 'spi'");
|
||||
}
|
||||
if (node->bus != &spi_bus || !node->children)
|
||||
return;
|
||||
|
||||
if (get_property(node, "spi-slave"))
|
||||
spi_addr_cells = 0;
|
||||
if (node_addr_cells(node) != spi_addr_cells)
|
||||
FAIL(c, dti, node, "incorrect #address-cells for SPI bus");
|
||||
if (node_size_cells(node) != 0)
|
||||
FAIL(c, dti, node, "incorrect #size-cells for SPI bus");
|
||||
|
||||
}
|
||||
WARNING(spi_bus_bridge, check_spi_bus_bridge, NULL, &addr_size_cells);
|
||||
|
||||
static void check_spi_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
|
||||
{
|
||||
struct property *prop;
|
||||
const char *unitname = get_unitname(node);
|
||||
char unit_addr[9];
|
||||
uint32_t reg = 0;
|
||||
cell_t *cells = NULL;
|
||||
|
||||
if (!node->parent || (node->parent->bus != &spi_bus))
|
||||
return;
|
||||
|
||||
if (get_property(node->parent, "spi-slave"))
|
||||
return;
|
||||
|
||||
prop = get_property(node, "reg");
|
||||
if (prop)
|
||||
cells = (cell_t *)prop->val.val;
|
||||
|
||||
if (!cells) {
|
||||
FAIL(c, dti, node, "missing or empty reg property");
|
||||
return;
|
||||
}
|
||||
|
||||
reg = fdt32_to_cpu(*cells);
|
||||
snprintf(unit_addr, sizeof(unit_addr), "%x", reg);
|
||||
if (!streq(unitname, unit_addr))
|
||||
FAIL(c, dti, node, "SPI bus unit address format error, expected \"%s\"",
|
||||
unit_addr);
|
||||
}
|
||||
WARNING(spi_bus_reg, check_spi_bus_reg, NULL, ®_format, &spi_bus_bridge);
|
||||
|
||||
static void check_unit_address_format(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
@ -1199,24 +1034,8 @@ static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *d
|
||||
}
|
||||
WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size);
|
||||
|
||||
static bool node_is_disabled(struct node *node)
|
||||
{
|
||||
struct property *prop;
|
||||
|
||||
prop = get_property(node, "status");
|
||||
if (prop) {
|
||||
char *str = prop->val.val;
|
||||
if (streq("disabled", str))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void check_unique_unit_address_common(struct check *c,
|
||||
struct dt_info *dti,
|
||||
struct node *node,
|
||||
bool disable_check)
|
||||
static void check_unique_unit_address(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
struct node *childa;
|
||||
|
||||
@ -1233,38 +1052,18 @@ static void check_unique_unit_address_common(struct check *c,
|
||||
if (!strlen(addr_a))
|
||||
continue;
|
||||
|
||||
if (disable_check && node_is_disabled(childa))
|
||||
continue;
|
||||
|
||||
for_each_child(node, childb) {
|
||||
const char *addr_b = get_unitname(childb);
|
||||
if (childa == childb)
|
||||
break;
|
||||
|
||||
if (disable_check && node_is_disabled(childb))
|
||||
continue;
|
||||
|
||||
if (streq(addr_a, addr_b))
|
||||
FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void check_unique_unit_address(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
check_unique_unit_address_common(c, dti, node, false);
|
||||
}
|
||||
WARNING(unique_unit_address, check_unique_unit_address, NULL, &avoid_default_addr_size);
|
||||
|
||||
static void check_unique_unit_address_if_enabled(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
check_unique_unit_address_common(c, dti, node, true);
|
||||
}
|
||||
CHECK_ENTRY(unique_unit_address_if_enabled, check_unique_unit_address_if_enabled,
|
||||
NULL, false, false, &avoid_default_addr_size);
|
||||
|
||||
static void check_obsolete_chosen_interrupt_controller(struct check *c,
|
||||
struct dt_info *dti,
|
||||
struct node *node)
|
||||
@ -1565,14 +1364,10 @@ static void check_interrupts_property(struct check *c,
|
||||
prop = get_property(parent, "interrupt-parent");
|
||||
if (prop) {
|
||||
phandle = propval_cell(prop);
|
||||
if ((phandle == 0) || (phandle == -1)) {
|
||||
/* Give up if this is an overlay with
|
||||
* external references */
|
||||
if (dti->dtsflags & DTSF_PLUGIN)
|
||||
/* Give up if this is an overlay with external references */
|
||||
if ((phandle == 0 || phandle == -1) &&
|
||||
(dti->dtsflags & DTSF_PLUGIN))
|
||||
return;
|
||||
FAIL_PROP(c, dti, parent, prop, "Invalid phandle");
|
||||
continue;
|
||||
}
|
||||
|
||||
irq_node = get_node_by_phandle(root, phandle);
|
||||
if (!irq_node) {
|
||||
@ -1741,7 +1536,7 @@ static void check_graph_endpoint(struct check *c, struct dt_info *dti,
|
||||
return;
|
||||
|
||||
if (!strprefixeq(node->name, node->basenamelen, "endpoint"))
|
||||
FAIL(c, dti, node, "graph endpoint node name should be 'endpoint'");
|
||||
FAIL(c, dti, node, "graph endpont node name should be 'endpoint'");
|
||||
|
||||
check_graph_reg(c, dti, node);
|
||||
|
||||
@ -1787,16 +1582,9 @@ static struct check *check_table[] = {
|
||||
&simple_bus_bridge,
|
||||
&simple_bus_reg,
|
||||
|
||||
&i2c_bus_bridge,
|
||||
&i2c_bus_reg,
|
||||
|
||||
&spi_bus_bridge,
|
||||
&spi_bus_reg,
|
||||
|
||||
&avoid_default_addr_size,
|
||||
&avoid_unnecessary_addr_size,
|
||||
&unique_unit_address,
|
||||
&unique_unit_address_if_enabled,
|
||||
&obsolete_chosen_interrupt_controller,
|
||||
&chosen_node_is_root, &chosen_node_bootargs, &chosen_node_stdout_path,
|
||||
|
||||
|
@ -1,6 +1,21 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include "dtc.h"
|
||||
@ -59,8 +74,7 @@ struct data data_copy_escape_string(const char *s, int len)
|
||||
struct data d;
|
||||
char *q;
|
||||
|
||||
d = data_add_marker(empty_data, TYPE_STRING, NULL);
|
||||
d = data_grow_for(d, len + 1);
|
||||
d = data_grow_for(empty_data, len + 1);
|
||||
|
||||
q = d.val;
|
||||
while (i < len) {
|
||||
@ -80,7 +94,6 @@ struct data data_copy_file(FILE *f, size_t maxlen)
|
||||
{
|
||||
struct data d = empty_data;
|
||||
|
||||
d = data_add_marker(d, TYPE_NONE, NULL);
|
||||
while (!feof(f) && (d.len < maxlen)) {
|
||||
size_t chunksize, ret;
|
||||
|
||||
|
@ -1,6 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
%option noyywrap nounput noinput never-interactive
|
||||
@ -197,14 +212,14 @@ static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
|
||||
<*>\&{LABEL} { /* label reference */
|
||||
DPRINT("Ref: %s\n", yytext+1);
|
||||
yylval.labelref = xstrdup(yytext+1);
|
||||
return DT_LABEL_REF;
|
||||
return DT_REF;
|
||||
}
|
||||
|
||||
<*>"&{/"{PATHCHAR}*\} { /* new-style path reference */
|
||||
yytext[yyleng-1] = '\0';
|
||||
DPRINT("Ref: %s\n", yytext+2);
|
||||
yylval.labelref = xstrdup(yytext+2);
|
||||
return DT_PATH_REF;
|
||||
return DT_REF;
|
||||
}
|
||||
|
||||
<BYTESTRING>[0-9a-fA-F]{2} {
|
||||
|
@ -1,6 +1,21 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
%{
|
||||
#include <stdio.h>
|
||||
@ -55,8 +70,7 @@ extern bool treesource_error;
|
||||
%token <byte> DT_BYTE
|
||||
%token <data> DT_STRING
|
||||
%token <labelref> DT_LABEL
|
||||
%token <labelref> DT_LABEL_REF
|
||||
%token <labelref> DT_PATH_REF
|
||||
%token <labelref> DT_REF
|
||||
%token DT_INCBIN
|
||||
|
||||
%type <data> propdata
|
||||
@ -69,7 +83,6 @@ extern bool treesource_error;
|
||||
%type <data> bytestring
|
||||
%type <prop> propdef
|
||||
%type <proplist> proplist
|
||||
%type <labelref> dt_ref
|
||||
|
||||
%type <node> devicetree
|
||||
%type <node> nodedef
|
||||
@ -145,8 +158,6 @@ memreserve:
|
||||
}
|
||||
;
|
||||
|
||||
dt_ref: DT_LABEL_REF | DT_PATH_REF;
|
||||
|
||||
devicetree:
|
||||
'/' nodedef
|
||||
{
|
||||
@ -156,7 +167,7 @@ devicetree:
|
||||
{
|
||||
$$ = merge_nodes($1, $3);
|
||||
}
|
||||
| dt_ref nodedef
|
||||
| DT_REF nodedef
|
||||
{
|
||||
/*
|
||||
* We rely on the rule being always:
|
||||
@ -165,12 +176,9 @@ devicetree:
|
||||
*/
|
||||
if (!($<flags>-1 & DTSF_PLUGIN))
|
||||
ERROR(&@2, "Label or path %s not found", $1);
|
||||
$$ = add_orphan_node(
|
||||
name_node(build_node(NULL, NULL, NULL),
|
||||
""),
|
||||
$2, $1);
|
||||
$$ = add_orphan_node(name_node(build_node(NULL, NULL), ""), $2, $1);
|
||||
}
|
||||
| devicetree DT_LABEL dt_ref nodedef
|
||||
| devicetree DT_LABEL DT_REF nodedef
|
||||
{
|
||||
struct node *target = get_node_by_ref($1, $3);
|
||||
|
||||
@ -181,7 +189,7 @@ devicetree:
|
||||
ERROR(&@3, "Label or path %s not found", $3);
|
||||
$$ = $1;
|
||||
}
|
||||
| devicetree DT_PATH_REF nodedef
|
||||
| devicetree DT_REF nodedef
|
||||
{
|
||||
/*
|
||||
* We rely on the rule being always:
|
||||
@ -200,26 +208,7 @@ devicetree:
|
||||
}
|
||||
$$ = $1;
|
||||
}
|
||||
| devicetree DT_LABEL_REF nodedef
|
||||
{
|
||||
struct node *target = get_node_by_ref($1, $2);
|
||||
|
||||
if (target) {
|
||||
merge_nodes(target, $3);
|
||||
} else {
|
||||
/*
|
||||
* We rely on the rule being always:
|
||||
* versioninfo plugindecl memreserves devicetree
|
||||
* so $-1 is what we want (plugindecl)
|
||||
*/
|
||||
if ($<flags>-1 & DTSF_PLUGIN)
|
||||
add_orphan_node($1, $3, $2);
|
||||
else
|
||||
ERROR(&@2, "Label or path %s not found", $2);
|
||||
}
|
||||
$$ = $1;
|
||||
}
|
||||
| devicetree DT_DEL_NODE dt_ref ';'
|
||||
| devicetree DT_DEL_NODE DT_REF ';'
|
||||
{
|
||||
struct node *target = get_node_by_ref($1, $3);
|
||||
|
||||
@ -231,7 +220,7 @@ devicetree:
|
||||
|
||||
$$ = $1;
|
||||
}
|
||||
| devicetree DT_OMIT_NO_REF dt_ref ';'
|
||||
| devicetree DT_OMIT_NO_REF DT_REF ';'
|
||||
{
|
||||
struct node *target = get_node_by_ref($1, $3);
|
||||
|
||||
@ -248,7 +237,7 @@ devicetree:
|
||||
nodedef:
|
||||
'{' proplist subnodes '}' ';'
|
||||
{
|
||||
$$ = build_node($2, $3, &@$);
|
||||
$$ = build_node($2, $3);
|
||||
}
|
||||
;
|
||||
|
||||
@ -266,11 +255,11 @@ proplist:
|
||||
propdef:
|
||||
DT_PROPNODENAME '=' propdata ';'
|
||||
{
|
||||
$$ = build_property($1, $3, &@$);
|
||||
$$ = build_property($1, $3);
|
||||
}
|
||||
| DT_PROPNODENAME ';'
|
||||
{
|
||||
$$ = build_property($1, empty_data, &@$);
|
||||
$$ = build_property($1, empty_data);
|
||||
}
|
||||
| DT_DEL_PROP DT_PROPNODENAME ';'
|
||||
{
|
||||
@ -296,9 +285,8 @@ propdata:
|
||||
{
|
||||
$$ = data_merge($1, $3);
|
||||
}
|
||||
| propdataprefix dt_ref
|
||||
| propdataprefix DT_REF
|
||||
{
|
||||
$1 = data_add_marker($1, TYPE_STRING, $2);
|
||||
$$ = data_add_marker($1, REF_PATH, $2);
|
||||
}
|
||||
| propdataprefix DT_INCBIN '(' DT_STRING ',' integer_prim ',' integer_prim ')'
|
||||
@ -352,27 +340,22 @@ arrayprefix:
|
||||
DT_BITS DT_LITERAL '<'
|
||||
{
|
||||
unsigned long long bits;
|
||||
enum markertype type = TYPE_UINT32;
|
||||
|
||||
bits = $2;
|
||||
|
||||
switch (bits) {
|
||||
case 8: type = TYPE_UINT8; break;
|
||||
case 16: type = TYPE_UINT16; break;
|
||||
case 32: type = TYPE_UINT32; break;
|
||||
case 64: type = TYPE_UINT64; break;
|
||||
default:
|
||||
if ((bits != 8) && (bits != 16) &&
|
||||
(bits != 32) && (bits != 64)) {
|
||||
ERROR(&@2, "Array elements must be"
|
||||
" 8, 16, 32 or 64-bits");
|
||||
bits = 32;
|
||||
}
|
||||
|
||||
$$.data = data_add_marker(empty_data, type, NULL);
|
||||
$$.data = empty_data;
|
||||
$$.bits = bits;
|
||||
}
|
||||
| '<'
|
||||
{
|
||||
$$.data = data_add_marker(empty_data, TYPE_UINT32, NULL);
|
||||
$$.data = empty_data;
|
||||
$$.bits = 32;
|
||||
}
|
||||
| arrayprefix integer_prim
|
||||
@ -394,7 +377,7 @@ arrayprefix:
|
||||
|
||||
$$.data = data_append_integer($1.data, $2, $1.bits);
|
||||
}
|
||||
| arrayprefix dt_ref
|
||||
| arrayprefix DT_REF
|
||||
{
|
||||
uint64_t val = ~0ULL >> (64 - $1.bits);
|
||||
|
||||
@ -516,7 +499,7 @@ integer_unary:
|
||||
bytestring:
|
||||
/* empty */
|
||||
{
|
||||
$$ = data_add_marker(empty_data, TYPE_UINT8, NULL);
|
||||
$$ = empty_data;
|
||||
}
|
||||
| bytestring DT_BYTE
|
||||
{
|
||||
@ -551,7 +534,7 @@ subnode:
|
||||
}
|
||||
| DT_DEL_NODE DT_PROPNODENAME ';'
|
||||
{
|
||||
$$ = name_node(build_node_delete(&@$), $2);
|
||||
$$ = name_node(build_node_delete(), $2);
|
||||
}
|
||||
| DT_OMIT_NO_REF subnode
|
||||
{
|
||||
|
@ -1,6 +1,21 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
@ -20,8 +35,6 @@ int phandle_format = PHANDLE_EPAPR; /* Use linux,phandle or phandle properties *
|
||||
int generate_symbols; /* enable symbols & fixup support */
|
||||
int generate_fixups; /* suppress generation of fixups on symbol support */
|
||||
int auto_label_aliases; /* auto generate labels -> aliases */
|
||||
int annotate; /* Level of annotation: 1 for input source location
|
||||
>1 for full input source location. */
|
||||
|
||||
static int is_power_of_2(int x)
|
||||
{
|
||||
@ -47,7 +60,7 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
|
||||
|
||||
/* Usage related data. */
|
||||
static const char usage_synopsis[] = "dtc [options] <input file>";
|
||||
static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AThv";
|
||||
static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv";
|
||||
static struct option const usage_long_opts[] = {
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"in-format", a_argument, NULL, 'I'},
|
||||
@ -68,7 +81,6 @@ static struct option const usage_long_opts[] = {
|
||||
{"error", a_argument, NULL, 'E'},
|
||||
{"symbols", no_argument, NULL, '@'},
|
||||
{"auto-alias", no_argument, NULL, 'A'},
|
||||
{"annotate", no_argument, NULL, 'T'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{NULL, no_argument, NULL, 0x0},
|
||||
@ -83,9 +95,6 @@ static const char * const usage_opts_help[] = {
|
||||
"\n\tOutput formats are:\n"
|
||||
"\t\tdts - device tree source text\n"
|
||||
"\t\tdtb - device tree blob\n"
|
||||
#ifndef NO_YAML
|
||||
"\t\tyaml - device tree encoded as YAML\n"
|
||||
#endif
|
||||
"\t\tasm - assembler source",
|
||||
"\n\tBlob version to produce, defaults to "stringify(DEFAULT_FDT_VERSION)" (for dtb and asm output)",
|
||||
"\n\tOutput dependency file",
|
||||
@ -105,7 +114,6 @@ static const char * const usage_opts_help[] = {
|
||||
"\n\tEnable/disable errors (prefix with \"no-\")",
|
||||
"\n\tEnable generation of symbols",
|
||||
"\n\tEnable auto-alias of labels",
|
||||
"\n\tAnnotate output .dts with input source file and line (-T -T for more details)",
|
||||
"\n\tPrint this help and exit",
|
||||
"\n\tPrint version and exit",
|
||||
NULL,
|
||||
@ -120,8 +128,6 @@ static const char *guess_type_by_name(const char *fname, const char *fallback)
|
||||
return fallback;
|
||||
if (!strcasecmp(s, ".dts"))
|
||||
return "dts";
|
||||
if (!strcasecmp(s, ".yaml"))
|
||||
return "yaml";
|
||||
if (!strcasecmp(s, ".dtb"))
|
||||
return "dtb";
|
||||
return fallback;
|
||||
@ -253,9 +259,6 @@ int main(int argc, char *argv[])
|
||||
case 'A':
|
||||
auto_label_aliases = 1;
|
||||
break;
|
||||
case 'T':
|
||||
annotate++;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage(NULL);
|
||||
@ -294,8 +297,6 @@ int main(int argc, char *argv[])
|
||||
outform = "dts";
|
||||
}
|
||||
}
|
||||
if (annotate && (!streq(inform, "dts") || !streq(outform, "dts")))
|
||||
die("--annotate requires -I dts -O dts\n");
|
||||
if (streq(inform, "dts"))
|
||||
dti = dt_from_source(arg);
|
||||
else if (streq(inform, "fs"))
|
||||
@ -349,12 +350,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (streq(outform, "dts")) {
|
||||
dt_to_source(outf, dti);
|
||||
#ifndef NO_YAML
|
||||
} else if (streq(outform, "yaml")) {
|
||||
if (!streq(inform, "dts"))
|
||||
die("YAML output format requires dts input format\n");
|
||||
dt_to_yaml(outf, dti);
|
||||
#endif
|
||||
} else if (streq(outform, "dtb")) {
|
||||
dt_to_blob(outf, dti, outversion);
|
||||
} else if (streq(outform, "asm")) {
|
||||
|
@ -1,9 +1,24 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#ifndef DTC_H
|
||||
#define DTC_H
|
||||
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -43,7 +58,6 @@ extern int phandle_format; /* Use linux,phandle or phandle properties */
|
||||
extern int generate_symbols; /* generate symbols for nodes with labels */
|
||||
extern int generate_fixups; /* generate fixups */
|
||||
extern int auto_label_aliases; /* auto generate labels -> aliases */
|
||||
extern int annotate; /* annotate .dts with input source location */
|
||||
|
||||
#define PHANDLE_LEGACY 0x1
|
||||
#define PHANDLE_EPAPR 0x2
|
||||
@ -60,17 +74,10 @@ typedef uint32_t cell_t;
|
||||
|
||||
/* Data blobs */
|
||||
enum markertype {
|
||||
TYPE_NONE,
|
||||
REF_PHANDLE,
|
||||
REF_PATH,
|
||||
LABEL,
|
||||
TYPE_UINT8,
|
||||
TYPE_UINT16,
|
||||
TYPE_UINT32,
|
||||
TYPE_UINT64,
|
||||
TYPE_STRING,
|
||||
};
|
||||
extern const char *markername(enum markertype markertype);
|
||||
|
||||
struct marker {
|
||||
enum markertype type;
|
||||
@ -94,8 +101,6 @@ struct data {
|
||||
for_each_marker(m) \
|
||||
if ((m)->type == (t))
|
||||
|
||||
size_t type_marker_length(struct marker *m);
|
||||
|
||||
void data_free(struct data d);
|
||||
|
||||
struct data data_grow_for(struct data d, int xlen);
|
||||
@ -144,7 +149,6 @@ struct property {
|
||||
struct property *next;
|
||||
|
||||
struct label *labels;
|
||||
struct srcpos *srcpos;
|
||||
};
|
||||
|
||||
struct node {
|
||||
@ -164,7 +168,6 @@ struct node {
|
||||
|
||||
struct label *labels;
|
||||
const struct bus_type *bus;
|
||||
struct srcpos *srcpos;
|
||||
|
||||
bool omit_if_unused, is_referenced;
|
||||
};
|
||||
@ -193,15 +196,13 @@ struct node {
|
||||
void add_label(struct label **labels, char *label);
|
||||
void delete_labels(struct label **labels);
|
||||
|
||||
struct property *build_property(char *name, struct data val,
|
||||
struct srcpos *srcpos);
|
||||
struct property *build_property(char *name, struct data val);
|
||||
struct property *build_property_delete(char *name);
|
||||
struct property *chain_property(struct property *first, struct property *list);
|
||||
struct property *reverse_properties(struct property *first);
|
||||
|
||||
struct node *build_node(struct property *proplist, struct node *children,
|
||||
struct srcpos *srcpos);
|
||||
struct node *build_node_delete(struct srcpos *srcpos);
|
||||
struct node *build_node(struct property *proplist, struct node *children);
|
||||
struct node *build_node_delete(void);
|
||||
struct node *name_node(struct node *node, char *name);
|
||||
struct node *omit_node_if_unused(struct node *node);
|
||||
struct node *reference_node(struct node *node);
|
||||
@ -216,8 +217,7 @@ void add_child(struct node *parent, struct node *child);
|
||||
void delete_node_by_name(struct node *parent, char *name);
|
||||
void delete_node(struct node *node);
|
||||
void append_to_property(struct node *node,
|
||||
char *name, const void *data, int len,
|
||||
enum markertype type);
|
||||
char *name, const void *data, int len);
|
||||
|
||||
const char *get_unitname(struct node *node);
|
||||
struct property *get_property(struct node *node, const char *propname);
|
||||
@ -290,10 +290,6 @@ struct dt_info *dt_from_blob(const char *fname);
|
||||
void dt_to_source(FILE *f, struct dt_info *dti);
|
||||
struct dt_info *dt_from_source(const char *f);
|
||||
|
||||
/* YAML source */
|
||||
|
||||
void dt_to_yaml(FILE *f, struct dt_info *dti);
|
||||
|
||||
/* FS trees */
|
||||
|
||||
struct dt_info *dt_from_fs(const char *dirname);
|
||||
|
@ -21,7 +21,6 @@ Usage:
|
||||
diff DTx_1 and DTx_2
|
||||
|
||||
|
||||
--annotate synonym for -T
|
||||
-f print full dts in diff (--unified=99999)
|
||||
-h synonym for --help
|
||||
-help synonym for --help
|
||||
@ -29,7 +28,6 @@ Usage:
|
||||
-s SRCTREE linux kernel source tree is at path SRCTREE
|
||||
(default is current directory)
|
||||
-S linux kernel source tree is at root of current git repo
|
||||
-T Annotate output .dts with input source file and line (-T -T for more details)
|
||||
-u unsorted, do not sort DTx
|
||||
|
||||
|
||||
@ -172,7 +170,6 @@ compile_to_dts() {
|
||||
|
||||
# ----- start of script
|
||||
|
||||
annotate=""
|
||||
cmd_diff=0
|
||||
diff_flags="-u"
|
||||
dtx_file_1=""
|
||||
@ -207,14 +204,6 @@ while [ $# -gt 0 ] ; do
|
||||
shift
|
||||
;;
|
||||
|
||||
-T | --annotate )
|
||||
if [ "${annotate}" = "" ] ; then
|
||||
annotate="-T"
|
||||
elif [ "${annotate}" = "-T" ] ; then
|
||||
annotate="-T -T"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
-u )
|
||||
dtc_sort=""
|
||||
shift
|
||||
@ -334,7 +323,7 @@ cpp_flags="\
|
||||
DTC="\
|
||||
${DTC} \
|
||||
-i ${srctree}/scripts/dtc/include-prefixes \
|
||||
-O dts -qq -f ${dtc_sort} ${annotate} -o -"
|
||||
-O dts -qq -f ${dtc_sort} -o -"
|
||||
|
||||
|
||||
# ----- do the diff or decompile
|
||||
|
@ -1,6 +1,21 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include "dtc.h"
|
||||
@ -378,7 +393,7 @@ void dt_to_blob(FILE *f, struct dt_info *dti, int version)
|
||||
padlen = 0;
|
||||
if (quiet < 1)
|
||||
fprintf(stderr,
|
||||
"Warning: blob size %"PRIu32" >= minimum size %d\n",
|
||||
"Warning: blob size %d >= minimum size %d\n",
|
||||
fdt32_to_cpu(fdt.totalsize), minsize);
|
||||
}
|
||||
}
|
||||
@ -510,7 +525,7 @@ void dt_to_asm(FILE *f, struct dt_info *dti, int version)
|
||||
fprintf(f, "/* Memory reserve map from source file */\n");
|
||||
|
||||
/*
|
||||
* Use .long on high and low halves of u64s to avoid .quad
|
||||
* Use .long on high and low halfs of u64s to avoid .quad
|
||||
* as it appears .quad isn't available in some assemblers.
|
||||
*/
|
||||
for (re = dti->reservelist; re; re = re->next) {
|
||||
@ -677,7 +692,7 @@ static struct property *flat_read_property(struct inbuf *dtbuf,
|
||||
|
||||
val = flat_read_data(dtbuf, proplen);
|
||||
|
||||
return build_property(name, val, NULL);
|
||||
return build_property(name, val);
|
||||
}
|
||||
|
||||
|
||||
@ -735,7 +750,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
|
||||
char *flatname;
|
||||
uint32_t val;
|
||||
|
||||
node = build_node(NULL, NULL, NULL);
|
||||
node = build_node(NULL, NULL);
|
||||
|
||||
flatname = flat_read_string(dtbuf);
|
||||
|
||||
|
@ -1,6 +1,21 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include "dtc.h"
|
||||
@ -19,7 +34,7 @@ static struct node *read_fstree(const char *dirname)
|
||||
if (!d)
|
||||
die("Couldn't opendir() \"%s\": %s\n", dirname, strerror(errno));
|
||||
|
||||
tree = build_node(NULL, NULL, NULL);
|
||||
tree = build_node(NULL, NULL);
|
||||
|
||||
while ((de = readdir(d)) != NULL) {
|
||||
char *tmpname;
|
||||
@ -45,8 +60,7 @@ static struct node *read_fstree(const char *dirname)
|
||||
} else {
|
||||
prop = build_property(xstrdup(de->d_name),
|
||||
data_copy_file(pfile,
|
||||
st.st_size),
|
||||
NULL);
|
||||
st.st_size));
|
||||
add_property(tree, prop);
|
||||
fclose(pfile);
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
# Makefile.libfdt
|
||||
#
|
||||
# This is not a complete Makefile of itself. Instead, it is designed to
|
||||
@ -10,9 +9,3 @@ LIBFDT_VERSION = version.lds
|
||||
LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \
|
||||
fdt_addresses.c fdt_overlay.c
|
||||
LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
|
||||
LIBFDT_LIB = libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT)
|
||||
|
||||
libfdt_clean:
|
||||
@$(VECHO) CLEAN "(libfdt)"
|
||||
rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%)
|
||||
rm -f $(LIBFDT_dir)/$(LIBFDT_soname)
|
||||
|
@ -1,7 +1,52 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
@ -10,12 +55,7 @@
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
/*
|
||||
* Minimal sanity check for a read-only tree. fdt_ro_probe_() checks
|
||||
* that the given buffer contains what appears to be a flattened
|
||||
* device tree with sane information in its header.
|
||||
*/
|
||||
int fdt_ro_probe_(const void *fdt)
|
||||
int fdt_check_header(const void *fdt)
|
||||
{
|
||||
if (fdt_magic(fdt) == FDT_MAGIC) {
|
||||
/* Complete tree */
|
||||
@ -48,78 +88,6 @@ int fdt_ro_probe_(const void *fdt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_off_(uint32_t hdrsize, uint32_t totalsize, uint32_t off)
|
||||
{
|
||||
return (off >= hdrsize) && (off <= totalsize);
|
||||
}
|
||||
|
||||
static int check_block_(uint32_t hdrsize, uint32_t totalsize,
|
||||
uint32_t base, uint32_t size)
|
||||
{
|
||||
if (!check_off_(hdrsize, totalsize, base))
|
||||
return 0; /* block start out of bounds */
|
||||
if ((base + size) < base)
|
||||
return 0; /* overflow */
|
||||
if (!check_off_(hdrsize, totalsize, base + size))
|
||||
return 0; /* block end out of bounds */
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t fdt_header_size_(uint32_t version)
|
||||
{
|
||||
if (version <= 1)
|
||||
return FDT_V1_SIZE;
|
||||
else if (version <= 2)
|
||||
return FDT_V2_SIZE;
|
||||
else if (version <= 3)
|
||||
return FDT_V3_SIZE;
|
||||
else if (version <= 16)
|
||||
return FDT_V16_SIZE;
|
||||
else
|
||||
return FDT_V17_SIZE;
|
||||
}
|
||||
|
||||
int fdt_check_header(const void *fdt)
|
||||
{
|
||||
size_t hdrsize;
|
||||
|
||||
if (fdt_magic(fdt) != FDT_MAGIC)
|
||||
return -FDT_ERR_BADMAGIC;
|
||||
hdrsize = fdt_header_size(fdt);
|
||||
if ((fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
|
||||
|| (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION))
|
||||
return -FDT_ERR_BADVERSION;
|
||||
if (fdt_version(fdt) < fdt_last_comp_version(fdt))
|
||||
return -FDT_ERR_BADVERSION;
|
||||
|
||||
if ((fdt_totalsize(fdt) < hdrsize)
|
||||
|| (fdt_totalsize(fdt) > INT_MAX))
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
|
||||
/* Bounds check memrsv block */
|
||||
if (!check_off_(hdrsize, fdt_totalsize(fdt), fdt_off_mem_rsvmap(fdt)))
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
|
||||
/* Bounds check structure block */
|
||||
if (fdt_version(fdt) < 17) {
|
||||
if (!check_off_(hdrsize, fdt_totalsize(fdt),
|
||||
fdt_off_dt_struct(fdt)))
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
} else {
|
||||
if (!check_block_(hdrsize, fdt_totalsize(fdt),
|
||||
fdt_off_dt_struct(fdt),
|
||||
fdt_size_dt_struct(fdt)))
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
}
|
||||
|
||||
/* Bounds check strings block */
|
||||
if (!check_block_(hdrsize, fdt_totalsize(fdt),
|
||||
fdt_off_dt_strings(fdt), fdt_size_dt_strings(fdt)))
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
|
||||
{
|
||||
unsigned absoffset = offset + fdt_off_dt_struct(fdt);
|
||||
@ -290,7 +258,7 @@ const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
|
||||
|
||||
int fdt_move(const void *fdt, void *buf, int bufsize)
|
||||
{
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_totalsize(fdt) > bufsize)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
@ -1,10 +1,55 @@
|
||||
/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
|
||||
#ifndef FDT_H
|
||||
#define FDT_H
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
* Copyright 2012 Kim Phillips, Freescale Semiconductor.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
@ -1,8 +1,52 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au>
|
||||
* Copyright (C) 2018 embedded brains GmbH
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
@ -11,89 +55,42 @@
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
static int fdt_cells(const void *fdt, int nodeoffset, const char *name)
|
||||
int fdt_address_cells(const void *fdt, int nodeoffset)
|
||||
{
|
||||
const fdt32_t *c;
|
||||
const fdt32_t *ac;
|
||||
int val;
|
||||
int len;
|
||||
|
||||
c = fdt_getprop(fdt, nodeoffset, name, &len);
|
||||
if (!c)
|
||||
return len;
|
||||
ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
|
||||
if (!ac)
|
||||
return 2;
|
||||
|
||||
if (len != sizeof(*c))
|
||||
if (len != sizeof(*ac))
|
||||
return -FDT_ERR_BADNCELLS;
|
||||
|
||||
val = fdt32_to_cpu(*c);
|
||||
val = fdt32_to_cpu(*ac);
|
||||
if ((val <= 0) || (val > FDT_MAX_NCELLS))
|
||||
return -FDT_ERR_BADNCELLS;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
int fdt_address_cells(const void *fdt, int nodeoffset)
|
||||
{
|
||||
int val;
|
||||
|
||||
val = fdt_cells(fdt, nodeoffset, "#address-cells");
|
||||
if (val == -FDT_ERR_NOTFOUND)
|
||||
return 2;
|
||||
return val;
|
||||
}
|
||||
|
||||
int fdt_size_cells(const void *fdt, int nodeoffset)
|
||||
{
|
||||
const fdt32_t *sc;
|
||||
int val;
|
||||
int len;
|
||||
|
||||
sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
|
||||
if (!sc)
|
||||
return 2;
|
||||
|
||||
if (len != sizeof(*sc))
|
||||
return -FDT_ERR_BADNCELLS;
|
||||
|
||||
val = fdt32_to_cpu(*sc);
|
||||
if ((val < 0) || (val > FDT_MAX_NCELLS))
|
||||
return -FDT_ERR_BADNCELLS;
|
||||
|
||||
val = fdt_cells(fdt, nodeoffset, "#size-cells");
|
||||
if (val == -FDT_ERR_NOTFOUND)
|
||||
return 1;
|
||||
return val;
|
||||
}
|
||||
|
||||
/* This function assumes that [address|size]_cells is 1 or 2 */
|
||||
int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,
|
||||
const char *name, uint64_t addr, uint64_t size)
|
||||
{
|
||||
int addr_cells, size_cells, ret;
|
||||
uint8_t data[sizeof(fdt64_t) * 2], *prop;
|
||||
|
||||
ret = fdt_address_cells(fdt, parent);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
addr_cells = ret;
|
||||
|
||||
ret = fdt_size_cells(fdt, parent);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
size_cells = ret;
|
||||
|
||||
/* check validity of address */
|
||||
prop = data;
|
||||
if (addr_cells == 1) {
|
||||
if ((addr > UINT32_MAX) || ((UINT32_MAX + 1 - addr) < size))
|
||||
return -FDT_ERR_BADVALUE;
|
||||
|
||||
fdt32_st(prop, (uint32_t)addr);
|
||||
} else if (addr_cells == 2) {
|
||||
fdt64_st(prop, addr);
|
||||
} else {
|
||||
return -FDT_ERR_BADNCELLS;
|
||||
}
|
||||
|
||||
/* check validity of size */
|
||||
prop += addr_cells * sizeof(fdt32_t);
|
||||
if (size_cells == 1) {
|
||||
if (size > UINT32_MAX)
|
||||
return -FDT_ERR_BADVALUE;
|
||||
|
||||
fdt32_st(prop, (uint32_t)size);
|
||||
} else if (size_cells == 2) {
|
||||
fdt64_st(prop, size);
|
||||
} else {
|
||||
return -FDT_ERR_BADNCELLS;
|
||||
}
|
||||
|
||||
return fdt_appendprop(fdt, nodeoffset, name, data,
|
||||
(addr_cells + size_cells) * sizeof(fdt32_t));
|
||||
}
|
||||
|
@ -1,7 +1,52 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2012 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
|
@ -1,8 +1,53 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2016 Free Electrons
|
||||
* Copyright (C) 2016 NextThing Co.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
@ -48,11 +93,11 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
|
||||
* @pathp: pointer which receives the path of the target (or NULL)
|
||||
*
|
||||
* overlay_get_target() retrieves the target offset in the base
|
||||
* device tree of a fragment, no matter how the actual targeting is
|
||||
* device tree of a fragment, no matter how the actual targetting is
|
||||
* done (through a phandle or a path)
|
||||
*
|
||||
* returns:
|
||||
* the targeted node offset in the base device tree
|
||||
* the targetted node offset in the base device tree
|
||||
* Negative error code on error
|
||||
*/
|
||||
static int overlay_get_target(const void *fdt, const void *fdto,
|
||||
@ -652,7 +697,7 @@ static int get_path_len(const void *fdt, int nodeoffset)
|
||||
int len = 0, namelen;
|
||||
const char *name;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
for (;;) {
|
||||
name = fdt_get_name(fdt, nodeoffset, &namelen);
|
||||
@ -818,15 +863,11 @@ static int overlay_symbol_update(void *fdt, void *fdto)
|
||||
|
||||
int fdt_overlay_apply(void *fdt, void *fdto)
|
||||
{
|
||||
uint32_t delta;
|
||||
uint32_t delta = fdt_get_max_phandle(fdt);
|
||||
int ret;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_RO_PROBE(fdto);
|
||||
|
||||
ret = fdt_find_max_phandle(fdt, &delta);
|
||||
if (ret)
|
||||
goto err;
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
FDT_CHECK_HEADER(fdto);
|
||||
|
||||
ret = overlay_adjust_local_phandles(fdto, delta);
|
||||
if (ret)
|
||||
|
@ -1,7 +1,52 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
@ -31,156 +76,60 @@ static int fdt_nodename_eq_(const void *fdt, int offset,
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
|
||||
{
|
||||
uint32_t absoffset = stroffset + fdt_off_dt_strings(fdt);
|
||||
size_t len;
|
||||
int err;
|
||||
const char *s, *n;
|
||||
|
||||
err = fdt_ro_probe_(fdt);
|
||||
if (err != 0)
|
||||
goto fail;
|
||||
|
||||
err = -FDT_ERR_BADOFFSET;
|
||||
if (absoffset >= fdt_totalsize(fdt))
|
||||
goto fail;
|
||||
len = fdt_totalsize(fdt) - absoffset;
|
||||
|
||||
if (fdt_magic(fdt) == FDT_MAGIC) {
|
||||
if (stroffset < 0)
|
||||
goto fail;
|
||||
if (fdt_version(fdt) >= 17) {
|
||||
if (stroffset >= fdt_size_dt_strings(fdt))
|
||||
goto fail;
|
||||
if ((fdt_size_dt_strings(fdt) - stroffset) < len)
|
||||
len = fdt_size_dt_strings(fdt) - stroffset;
|
||||
}
|
||||
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
|
||||
if ((stroffset >= 0)
|
||||
|| (stroffset < -fdt_size_dt_strings(fdt)))
|
||||
goto fail;
|
||||
if ((-stroffset) < len)
|
||||
len = -stroffset;
|
||||
} else {
|
||||
err = -FDT_ERR_INTERNAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
s = (const char *)fdt + absoffset;
|
||||
n = memchr(s, '\0', len);
|
||||
if (!n) {
|
||||
/* missing terminating NULL */
|
||||
err = -FDT_ERR_TRUNCATED;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (lenp)
|
||||
*lenp = n - s;
|
||||
return s;
|
||||
|
||||
fail:
|
||||
if (lenp)
|
||||
*lenp = err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *fdt_string(const void *fdt, int stroffset)
|
||||
{
|
||||
return fdt_get_string(fdt, stroffset, NULL);
|
||||
return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
|
||||
}
|
||||
|
||||
static int fdt_string_eq_(const void *fdt, int stroffset,
|
||||
const char *s, int len)
|
||||
{
|
||||
int slen;
|
||||
const char *p = fdt_get_string(fdt, stroffset, &slen);
|
||||
const char *p = fdt_string(fdt, stroffset);
|
||||
|
||||
return p && (slen == len) && (memcmp(p, s, len) == 0);
|
||||
return (strlen(p) == len) && (memcmp(p, s, len) == 0);
|
||||
}
|
||||
|
||||
int fdt_find_max_phandle(const void *fdt, uint32_t *phandle)
|
||||
uint32_t fdt_get_max_phandle(const void *fdt)
|
||||
{
|
||||
uint32_t max = 0;
|
||||
int offset = -1;
|
||||
uint32_t max_phandle = 0;
|
||||
int offset;
|
||||
|
||||
while (true) {
|
||||
uint32_t value;
|
||||
for (offset = fdt_next_node(fdt, -1, NULL);;
|
||||
offset = fdt_next_node(fdt, offset, NULL)) {
|
||||
uint32_t phandle;
|
||||
|
||||
offset = fdt_next_node(fdt, offset, NULL);
|
||||
if (offset < 0) {
|
||||
if (offset == -FDT_ERR_NOTFOUND)
|
||||
break;
|
||||
if (offset == -FDT_ERR_NOTFOUND)
|
||||
return max_phandle;
|
||||
|
||||
return offset;
|
||||
}
|
||||
if (offset < 0)
|
||||
return (uint32_t)-1;
|
||||
|
||||
value = fdt_get_phandle(fdt, offset);
|
||||
phandle = fdt_get_phandle(fdt, offset);
|
||||
if (phandle == (uint32_t)-1)
|
||||
continue;
|
||||
|
||||
if (value > max)
|
||||
max = value;
|
||||
if (phandle > max_phandle)
|
||||
max_phandle = phandle;
|
||||
}
|
||||
|
||||
if (phandle)
|
||||
*phandle = max;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_generate_phandle(const void *fdt, uint32_t *phandle)
|
||||
{
|
||||
uint32_t max;
|
||||
int err;
|
||||
|
||||
err = fdt_find_max_phandle(fdt, &max);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
if (max == FDT_MAX_PHANDLE)
|
||||
return -FDT_ERR_NOPHANDLES;
|
||||
|
||||
if (phandle)
|
||||
*phandle = max + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n)
|
||||
{
|
||||
int offset = n * sizeof(struct fdt_reserve_entry);
|
||||
int absoffset = fdt_off_mem_rsvmap(fdt) + offset;
|
||||
|
||||
if (absoffset < fdt_off_mem_rsvmap(fdt))
|
||||
return NULL;
|
||||
if (absoffset > fdt_totalsize(fdt) - sizeof(struct fdt_reserve_entry))
|
||||
return NULL;
|
||||
return fdt_mem_rsv_(fdt, n);
|
||||
}
|
||||
|
||||
int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
|
||||
{
|
||||
const struct fdt_reserve_entry *re;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
re = fdt_mem_rsv(fdt, n);
|
||||
if (!re)
|
||||
return -FDT_ERR_BADOFFSET;
|
||||
|
||||
*address = fdt64_ld(&re->address);
|
||||
*size = fdt64_ld(&re->size);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
*address = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->address);
|
||||
*size = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_num_mem_rsv(const void *fdt)
|
||||
{
|
||||
int i;
|
||||
const struct fdt_reserve_entry *re;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) {
|
||||
if (fdt64_ld(&re->size) == 0)
|
||||
return i;
|
||||
}
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
while (fdt64_to_cpu(fdt_mem_rsv_(fdt, i)->size) != 0)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
static int nextprop_(const void *fdt, int offset)
|
||||
@ -212,7 +161,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
|
||||
{
|
||||
int depth;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
for (depth = 0;
|
||||
(offset >= 0) && (depth >= 0);
|
||||
@ -238,7 +187,7 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
|
||||
const char *p = path;
|
||||
int offset = 0;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
/* see if we have an alias */
|
||||
if (*path != '/') {
|
||||
@ -288,7 +237,7 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
|
||||
const char *nameptr;
|
||||
int err;
|
||||
|
||||
if (((err = fdt_ro_probe_(fdt)) != 0)
|
||||
if (((err = fdt_check_header(fdt)) != 0)
|
||||
|| ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0))
|
||||
goto fail;
|
||||
|
||||
@ -354,7 +303,7 @@ static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt,
|
||||
prop = fdt_offset_ptr_(fdt, offset);
|
||||
|
||||
if (lenp)
|
||||
*lenp = fdt32_ld(&prop->len);
|
||||
*lenp = fdt32_to_cpu(prop->len);
|
||||
|
||||
return prop;
|
||||
}
|
||||
@ -391,7 +340,7 @@ static const struct fdt_property *fdt_get_property_namelen_(const void *fdt,
|
||||
offset = -FDT_ERR_INTERNAL;
|
||||
break;
|
||||
}
|
||||
if (fdt_string_eq_(fdt, fdt32_ld(&prop->nameoff),
|
||||
if (fdt_string_eq_(fdt, fdt32_to_cpu(prop->nameoff),
|
||||
name, namelen)) {
|
||||
if (poffset)
|
||||
*poffset = offset;
|
||||
@ -444,7 +393,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
|
||||
|
||||
/* Handle realignment */
|
||||
if (fdt_version(fdt) < 0x10 && (poffset + sizeof(*prop)) % 8 &&
|
||||
fdt32_ld(&prop->len) >= 8)
|
||||
fdt32_to_cpu(prop->len) >= 8)
|
||||
return prop->data + 4;
|
||||
return prop->data;
|
||||
}
|
||||
@ -457,22 +406,12 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
|
||||
prop = fdt_get_property_by_offset_(fdt, offset, lenp);
|
||||
if (!prop)
|
||||
return NULL;
|
||||
if (namep) {
|
||||
const char *name;
|
||||
int namelen;
|
||||
name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff),
|
||||
&namelen);
|
||||
if (!name) {
|
||||
if (lenp)
|
||||
*lenp = namelen;
|
||||
return NULL;
|
||||
}
|
||||
*namep = name;
|
||||
}
|
||||
if (namep)
|
||||
*namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
|
||||
|
||||
/* Handle realignment */
|
||||
if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 &&
|
||||
fdt32_ld(&prop->len) >= 8)
|
||||
fdt32_to_cpu(prop->len) >= 8)
|
||||
return prop->data + 4;
|
||||
return prop->data;
|
||||
}
|
||||
@ -497,7 +436,7 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return fdt32_ld(php);
|
||||
return fdt32_to_cpu(*php);
|
||||
}
|
||||
|
||||
const char *fdt_get_alias_namelen(const void *fdt,
|
||||
@ -523,7 +462,7 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
|
||||
int offset, depth, namelen;
|
||||
const char *name;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (buflen < 2)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
@ -575,7 +514,7 @@ int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
|
||||
int offset, depth;
|
||||
int supernodeoffset = -FDT_ERR_INTERNAL;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (supernodedepth < 0)
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
@ -634,7 +573,7 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
|
||||
const void *val;
|
||||
int len;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
/* FIXME: The algorithm here is pretty horrible: we scan each
|
||||
* property of a node in fdt_getprop(), then if that didn't
|
||||
@ -660,7 +599,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
|
||||
if ((phandle == 0) || (phandle == -1))
|
||||
return -FDT_ERR_BADPHANDLE;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
/* FIXME: The algorithm here is pretty horrible: we
|
||||
* potentially scan each property of a node in
|
||||
@ -813,7 +752,7 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
|
||||
{
|
||||
int offset, err;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
/* FIXME: The algorithm here is pretty horrible: we scan each
|
||||
* property of a node in fdt_node_check_compatible(), then if
|
||||
@ -832,66 +771,3 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
|
||||
|
||||
return offset; /* error from fdt_next_node() */
|
||||
}
|
||||
|
||||
int fdt_check_full(const void *fdt, size_t bufsize)
|
||||
{
|
||||
int err;
|
||||
int num_memrsv;
|
||||
int offset, nextoffset = 0;
|
||||
uint32_t tag;
|
||||
unsigned depth = 0;
|
||||
const void *prop;
|
||||
const char *propname;
|
||||
|
||||
if (bufsize < FDT_V1_SIZE)
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
err = fdt_check_header(fdt);
|
||||
if (err != 0)
|
||||
return err;
|
||||
if (bufsize < fdt_totalsize(fdt))
|
||||
return -FDT_ERR_TRUNCATED;
|
||||
|
||||
num_memrsv = fdt_num_mem_rsv(fdt);
|
||||
if (num_memrsv < 0)
|
||||
return num_memrsv;
|
||||
|
||||
while (1) {
|
||||
offset = nextoffset;
|
||||
tag = fdt_next_tag(fdt, offset, &nextoffset);
|
||||
|
||||
if (nextoffset < 0)
|
||||
return nextoffset;
|
||||
|
||||
switch (tag) {
|
||||
case FDT_NOP:
|
||||
break;
|
||||
|
||||
case FDT_END:
|
||||
if (depth != 0)
|
||||
return -FDT_ERR_BADSTRUCTURE;
|
||||
return 0;
|
||||
|
||||
case FDT_BEGIN_NODE:
|
||||
depth++;
|
||||
if (depth > INT_MAX)
|
||||
return -FDT_ERR_BADSTRUCTURE;
|
||||
break;
|
||||
|
||||
case FDT_END_NODE:
|
||||
if (depth == 0)
|
||||
return -FDT_ERR_BADSTRUCTURE;
|
||||
depth--;
|
||||
break;
|
||||
|
||||
case FDT_PROP:
|
||||
prop = fdt_getprop_by_offset(fdt, offset, &propname,
|
||||
&err);
|
||||
if (!prop)
|
||||
return err;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -FDT_ERR_INTERNAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,52 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
@ -22,9 +67,9 @@ static int fdt_blocks_misordered_(const void *fdt,
|
||||
(fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));
|
||||
}
|
||||
|
||||
static int fdt_rw_probe_(void *fdt)
|
||||
static int fdt_rw_check_header_(void *fdt)
|
||||
{
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_version(fdt) < 17)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
@ -37,10 +82,10 @@ static int fdt_rw_probe_(void *fdt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_RW_PROBE(fdt) \
|
||||
#define FDT_RW_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err_; \
|
||||
if ((err_ = fdt_rw_probe_(fdt)) != 0) \
|
||||
if ((err_ = fdt_rw_check_header_(fdt)) != 0) \
|
||||
return err_; \
|
||||
}
|
||||
|
||||
@ -91,14 +136,6 @@ static int fdt_splice_struct_(void *fdt, void *p,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Must only be used to roll back in case of error */
|
||||
static void fdt_del_last_string_(void *fdt, const char *s)
|
||||
{
|
||||
int newlen = strlen(s) + 1;
|
||||
|
||||
fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) - newlen);
|
||||
}
|
||||
|
||||
static int fdt_splice_string_(void *fdt, int newlen)
|
||||
{
|
||||
void *p = (char *)fdt
|
||||
@ -112,7 +149,7 @@ static int fdt_splice_string_(void *fdt, int newlen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
|
||||
static int fdt_find_add_string_(void *fdt, const char *s)
|
||||
{
|
||||
char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
|
||||
const char *p;
|
||||
@ -120,8 +157,6 @@ static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
|
||||
int len = strlen(s) + 1;
|
||||
int err;
|
||||
|
||||
*allocated = 0;
|
||||
|
||||
p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s);
|
||||
if (p)
|
||||
/* found it */
|
||||
@ -132,8 +167,6 @@ static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
*allocated = 1;
|
||||
|
||||
memcpy(new, s, len);
|
||||
return (new - strtab);
|
||||
}
|
||||
@ -143,7 +176,7 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
|
||||
struct fdt_reserve_entry *re;
|
||||
int err;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
re = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt));
|
||||
err = fdt_splice_mem_rsv_(fdt, re, 0, 1);
|
||||
@ -159,7 +192,7 @@ int fdt_del_mem_rsv(void *fdt, int n)
|
||||
{
|
||||
struct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n);
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
if (n >= fdt_num_mem_rsv(fdt))
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
@ -192,12 +225,11 @@ static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
|
||||
int nextoffset;
|
||||
int namestroff;
|
||||
int err;
|
||||
int allocated;
|
||||
|
||||
if ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)
|
||||
return nextoffset;
|
||||
|
||||
namestroff = fdt_find_add_string_(fdt, name, &allocated);
|
||||
namestroff = fdt_find_add_string_(fdt, name);
|
||||
if (namestroff < 0)
|
||||
return namestroff;
|
||||
|
||||
@ -205,11 +237,8 @@ static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
|
||||
proplen = sizeof(**prop) + FDT_TAGALIGN(len);
|
||||
|
||||
err = fdt_splice_struct_(fdt, *prop, 0, proplen);
|
||||
if (err) {
|
||||
if (allocated)
|
||||
fdt_del_last_string_(fdt, name);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
(*prop)->tag = cpu_to_fdt32(FDT_PROP);
|
||||
(*prop)->nameoff = cpu_to_fdt32(namestroff);
|
||||
@ -223,7 +252,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
|
||||
int oldlen, newlen;
|
||||
int err;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
|
||||
if (!namep)
|
||||
@ -246,7 +275,7 @@ int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
|
||||
struct fdt_property *prop;
|
||||
int err;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop);
|
||||
if (err == -FDT_ERR_NOTFOUND)
|
||||
@ -279,7 +308,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
|
||||
struct fdt_property *prop;
|
||||
int err, oldlen, newlen;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
|
||||
if (prop) {
|
||||
@ -305,7 +334,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name)
|
||||
struct fdt_property *prop;
|
||||
int len, proplen;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
|
||||
if (!prop)
|
||||
@ -325,7 +354,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
|
||||
uint32_t tag;
|
||||
fdt32_t *endtag;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);
|
||||
if (offset >= 0)
|
||||
@ -365,7 +394,7 @@ int fdt_del_node(void *fdt, int nodeoffset)
|
||||
{
|
||||
int endoffset;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
endoffset = fdt_node_end_offset_(fdt, nodeoffset);
|
||||
if (endoffset < 0)
|
||||
@ -406,7 +435,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
|
||||
const char *fdtend = fdtstart + fdt_totalsize(fdt);
|
||||
char *tmp;
|
||||
|
||||
FDT_RO_PROBE(fdt);
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
||||
* sizeof(struct fdt_reserve_entry);
|
||||
@ -465,7 +494,7 @@ int fdt_pack(void *fdt)
|
||||
{
|
||||
int mem_rsv_size;
|
||||
|
||||
FDT_RW_PROBE(fdt);
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
||||
* sizeof(struct fdt_reserve_entry);
|
||||
|
@ -1,7 +1,51 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
@ -38,7 +82,6 @@ static struct fdt_errtabent fdt_errtable[] = {
|
||||
FDT_ERRTABENT(FDT_ERR_BADVALUE),
|
||||
FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
|
||||
FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
|
||||
FDT_ERRTABENT(FDT_ERR_BADFLAGS),
|
||||
};
|
||||
#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
|
||||
|
||||
|
@ -1,7 +1,52 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
@ -10,83 +55,21 @@
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
static int fdt_sw_probe_(void *fdt)
|
||||
static int fdt_sw_check_header_(void *fdt)
|
||||
{
|
||||
if (fdt_magic(fdt) == FDT_MAGIC)
|
||||
return -FDT_ERR_BADSTATE;
|
||||
else if (fdt_magic(fdt) != FDT_SW_MAGIC)
|
||||
if (fdt_magic(fdt) != FDT_SW_MAGIC)
|
||||
return -FDT_ERR_BADMAGIC;
|
||||
/* FIXME: should check more details about the header state */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_SW_PROBE(fdt) \
|
||||
#define FDT_SW_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = fdt_sw_probe_(fdt)) != 0) \
|
||||
if ((err = fdt_sw_check_header_(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
/* 'memrsv' state: Initial state after fdt_create()
|
||||
*
|
||||
* Allowed functions:
|
||||
* fdt_add_reservmap_entry()
|
||||
* fdt_finish_reservemap() [moves to 'struct' state]
|
||||
*/
|
||||
static int fdt_sw_probe_memrsv_(void *fdt)
|
||||
{
|
||||
int err = fdt_sw_probe_(fdt);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (fdt_off_dt_strings(fdt) != 0)
|
||||
return -FDT_ERR_BADSTATE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_SW_PROBE_MEMRSV(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = fdt_sw_probe_memrsv_(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
/* 'struct' state: Enter this state after fdt_finish_reservemap()
|
||||
*
|
||||
* Allowed functions:
|
||||
* fdt_begin_node()
|
||||
* fdt_end_node()
|
||||
* fdt_property*()
|
||||
* fdt_finish() [moves to 'complete' state]
|
||||
*/
|
||||
static int fdt_sw_probe_struct_(void *fdt)
|
||||
{
|
||||
int err = fdt_sw_probe_(fdt);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (fdt_off_dt_strings(fdt) != fdt_totalsize(fdt))
|
||||
return -FDT_ERR_BADSTATE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_SW_PROBE_STRUCT(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = fdt_sw_probe_struct_(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
static inline uint32_t sw_flags(void *fdt)
|
||||
{
|
||||
/* assert: (fdt_magic(fdt) == FDT_SW_MAGIC) */
|
||||
return fdt_last_comp_version(fdt);
|
||||
}
|
||||
|
||||
/* 'complete' state: Enter this state after fdt_finish()
|
||||
*
|
||||
* Allowed functions: none
|
||||
*/
|
||||
|
||||
static void *fdt_grab_space_(void *fdt, size_t len)
|
||||
{
|
||||
int offset = fdt_size_dt_struct(fdt);
|
||||
@ -102,58 +85,38 @@ static void *fdt_grab_space_(void *fdt, size_t len)
|
||||
return fdt_offset_ptr_w_(fdt, offset);
|
||||
}
|
||||
|
||||
int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags)
|
||||
int fdt_create(void *buf, int bufsize)
|
||||
{
|
||||
const size_t hdrsize = FDT_ALIGN(sizeof(struct fdt_header),
|
||||
sizeof(struct fdt_reserve_entry));
|
||||
void *fdt = buf;
|
||||
|
||||
if (bufsize < hdrsize)
|
||||
if (bufsize < sizeof(struct fdt_header))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
if (flags & ~FDT_CREATE_FLAGS_ALL)
|
||||
return -FDT_ERR_BADFLAGS;
|
||||
|
||||
memset(buf, 0, bufsize);
|
||||
|
||||
/*
|
||||
* magic and last_comp_version keep intermediate state during the fdt
|
||||
* creation process, which is replaced with the proper FDT format by
|
||||
* fdt_finish().
|
||||
*
|
||||
* flags should be accessed with sw_flags().
|
||||
*/
|
||||
fdt_set_magic(fdt, FDT_SW_MAGIC);
|
||||
fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);
|
||||
fdt_set_last_comp_version(fdt, flags);
|
||||
|
||||
fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
|
||||
fdt_set_totalsize(fdt, bufsize);
|
||||
|
||||
fdt_set_off_mem_rsvmap(fdt, hdrsize);
|
||||
fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header),
|
||||
sizeof(struct fdt_reserve_entry)));
|
||||
fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));
|
||||
fdt_set_off_dt_strings(fdt, 0);
|
||||
fdt_set_off_dt_strings(fdt, bufsize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_create(void *buf, int bufsize)
|
||||
{
|
||||
return fdt_create_with_flags(buf, bufsize, 0);
|
||||
}
|
||||
|
||||
int fdt_resize(void *fdt, void *buf, int bufsize)
|
||||
{
|
||||
size_t headsize, tailsize;
|
||||
char *oldtail, *newtail;
|
||||
|
||||
FDT_SW_PROBE(fdt);
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
headsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
|
||||
headsize = fdt_off_dt_struct(fdt);
|
||||
tailsize = fdt_size_dt_strings(fdt);
|
||||
|
||||
if ((headsize + tailsize) > fdt_totalsize(fdt))
|
||||
return -FDT_ERR_INTERNAL;
|
||||
|
||||
if ((headsize + tailsize) > bufsize)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
@ -170,9 +133,8 @@ int fdt_resize(void *fdt, void *buf, int bufsize)
|
||||
memmove(buf, fdt, headsize);
|
||||
}
|
||||
|
||||
fdt_set_off_dt_strings(buf, bufsize);
|
||||
fdt_set_totalsize(buf, bufsize);
|
||||
if (fdt_off_dt_strings(buf))
|
||||
fdt_set_off_dt_strings(buf, bufsize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -182,7 +144,10 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
|
||||
struct fdt_reserve_entry *re;
|
||||
int offset;
|
||||
|
||||
FDT_SW_PROBE_MEMRSV(fdt);
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_size_dt_struct(fdt))
|
||||
return -FDT_ERR_BADSTATE;
|
||||
|
||||
offset = fdt_off_dt_struct(fdt);
|
||||
if ((offset + sizeof(*re)) > fdt_totalsize(fdt))
|
||||
@ -199,23 +164,16 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
|
||||
|
||||
int fdt_finish_reservemap(void *fdt)
|
||||
{
|
||||
int err = fdt_add_reservemap_entry(fdt, 0, 0);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fdt_set_off_dt_strings(fdt, fdt_totalsize(fdt));
|
||||
return 0;
|
||||
return fdt_add_reservemap_entry(fdt, 0, 0);
|
||||
}
|
||||
|
||||
int fdt_begin_node(void *fdt, const char *name)
|
||||
{
|
||||
struct fdt_node_header *nh;
|
||||
int namelen;
|
||||
int namelen = strlen(name) + 1;
|
||||
|
||||
FDT_SW_PROBE_STRUCT(fdt);
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
namelen = strlen(name) + 1;
|
||||
nh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
|
||||
if (! nh)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
@ -229,7 +187,7 @@ int fdt_end_node(void *fdt)
|
||||
{
|
||||
fdt32_t *en;
|
||||
|
||||
FDT_SW_PROBE_STRUCT(fdt);
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
en = fdt_grab_space_(fdt, FDT_TAGSIZE);
|
||||
if (! en)
|
||||
@ -239,13 +197,19 @@ int fdt_end_node(void *fdt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fdt_add_string_(void *fdt, const char *s)
|
||||
static int fdt_find_add_string_(void *fdt, const char *s)
|
||||
{
|
||||
char *strtab = (char *)fdt + fdt_totalsize(fdt);
|
||||
const char *p;
|
||||
int strtabsize = fdt_size_dt_strings(fdt);
|
||||
int len = strlen(s) + 1;
|
||||
int struct_top, offset;
|
||||
|
||||
p = fdt_find_string_(strtab - strtabsize, strtabsize, s);
|
||||
if (p)
|
||||
return p - strtab;
|
||||
|
||||
/* Add it */
|
||||
offset = -strtabsize - len;
|
||||
struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
|
||||
if (fdt_totalsize(fdt) + offset < struct_top)
|
||||
@ -256,56 +220,20 @@ static int fdt_add_string_(void *fdt, const char *s)
|
||||
return offset;
|
||||
}
|
||||
|
||||
/* Must only be used to roll back in case of error */
|
||||
static void fdt_del_last_string_(void *fdt, const char *s)
|
||||
{
|
||||
int strtabsize = fdt_size_dt_strings(fdt);
|
||||
int len = strlen(s) + 1;
|
||||
|
||||
fdt_set_size_dt_strings(fdt, strtabsize - len);
|
||||
}
|
||||
|
||||
static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
|
||||
{
|
||||
char *strtab = (char *)fdt + fdt_totalsize(fdt);
|
||||
int strtabsize = fdt_size_dt_strings(fdt);
|
||||
const char *p;
|
||||
|
||||
*allocated = 0;
|
||||
|
||||
p = fdt_find_string_(strtab - strtabsize, strtabsize, s);
|
||||
if (p)
|
||||
return p - strtab;
|
||||
|
||||
*allocated = 1;
|
||||
|
||||
return fdt_add_string_(fdt, s);
|
||||
}
|
||||
|
||||
int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int nameoff;
|
||||
int allocated;
|
||||
|
||||
FDT_SW_PROBE_STRUCT(fdt);
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
/* String de-duplication can be slow, _NO_NAME_DEDUP skips it */
|
||||
if (sw_flags(fdt) & FDT_CREATE_FLAG_NO_NAME_DEDUP) {
|
||||
allocated = 1;
|
||||
nameoff = fdt_add_string_(fdt, name);
|
||||
} else {
|
||||
nameoff = fdt_find_add_string_(fdt, name, &allocated);
|
||||
}
|
||||
nameoff = fdt_find_add_string_(fdt, name);
|
||||
if (nameoff == 0)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
prop = fdt_grab_space_(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
|
||||
if (! prop) {
|
||||
if (allocated)
|
||||
fdt_del_last_string_(fdt, name);
|
||||
if (! prop)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
}
|
||||
|
||||
prop->tag = cpu_to_fdt32(FDT_PROP);
|
||||
prop->nameoff = cpu_to_fdt32(nameoff);
|
||||
@ -334,7 +262,7 @@ int fdt_finish(void *fdt)
|
||||
uint32_t tag;
|
||||
int offset, nextoffset;
|
||||
|
||||
FDT_SW_PROBE_STRUCT(fdt);
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
/* Add terminator */
|
||||
end = fdt_grab_space_(fdt, sizeof(*end));
|
||||
@ -367,10 +295,6 @@ int fdt_finish(void *fdt)
|
||||
|
||||
/* Finally, adjust the header */
|
||||
fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));
|
||||
|
||||
/* And fix up fields that were keeping intermediate state. */
|
||||
fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
|
||||
fdt_set_magic(fdt, FDT_MAGIC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,52 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
|
@ -1,9 +1,54 @@
|
||||
/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
|
||||
#ifndef LIBFDT_H
|
||||
#define LIBFDT_H
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "libfdt_env.h"
|
||||
@ -45,9 +90,8 @@
|
||||
|
||||
/* Error codes: codes for bad device tree blobs */
|
||||
#define FDT_ERR_TRUNCATED 8
|
||||
/* FDT_ERR_TRUNCATED: FDT or a sub-block is improperly
|
||||
* terminated (overflows, goes outside allowed bounds, or
|
||||
* isn't properly terminated). */
|
||||
/* FDT_ERR_TRUNCATED: Structure block of the given device tree
|
||||
* ends without an FDT_END tag. */
|
||||
#define FDT_ERR_BADMAGIC 9
|
||||
/* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a
|
||||
* device tree at all - it is missing the flattened device
|
||||
@ -93,15 +137,7 @@
|
||||
/* FDT_ERR_NOPHANDLES: The device tree doesn't have any
|
||||
* phandle available anymore without causing an overflow */
|
||||
|
||||
#define FDT_ERR_BADFLAGS 18
|
||||
/* FDT_ERR_BADFLAGS: The function was passed a flags field that
|
||||
* contains invalid flags or an invalid combination of flags. */
|
||||
|
||||
#define FDT_ERR_MAX 18
|
||||
|
||||
/* constants */
|
||||
#define FDT_MAX_PHANDLE 0xfffffffe
|
||||
/* Valid values for phandles range from 1 to 2^32-2. */
|
||||
#define FDT_ERR_MAX 17
|
||||
|
||||
/**********************************************************************/
|
||||
/* Low-level functions (you probably don't need these) */
|
||||
@ -117,61 +153,6 @@ static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
|
||||
|
||||
uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
|
||||
|
||||
/*
|
||||
* Alignment helpers:
|
||||
* These helpers access words from a device tree blob. They're
|
||||
* built to work even with unaligned pointers on platforms (ike
|
||||
* ARM) that don't like unaligned loads and stores
|
||||
*/
|
||||
|
||||
static inline uint32_t fdt32_ld(const fdt32_t *p)
|
||||
{
|
||||
const uint8_t *bp = (const uint8_t *)p;
|
||||
|
||||
return ((uint32_t)bp[0] << 24)
|
||||
| ((uint32_t)bp[1] << 16)
|
||||
| ((uint32_t)bp[2] << 8)
|
||||
| bp[3];
|
||||
}
|
||||
|
||||
static inline void fdt32_st(void *property, uint32_t value)
|
||||
{
|
||||
uint8_t *bp = property;
|
||||
|
||||
bp[0] = value >> 24;
|
||||
bp[1] = (value >> 16) & 0xff;
|
||||
bp[2] = (value >> 8) & 0xff;
|
||||
bp[3] = value & 0xff;
|
||||
}
|
||||
|
||||
static inline uint64_t fdt64_ld(const fdt64_t *p)
|
||||
{
|
||||
const uint8_t *bp = (const uint8_t *)p;
|
||||
|
||||
return ((uint64_t)bp[0] << 56)
|
||||
| ((uint64_t)bp[1] << 48)
|
||||
| ((uint64_t)bp[2] << 40)
|
||||
| ((uint64_t)bp[3] << 32)
|
||||
| ((uint64_t)bp[4] << 24)
|
||||
| ((uint64_t)bp[5] << 16)
|
||||
| ((uint64_t)bp[6] << 8)
|
||||
| bp[7];
|
||||
}
|
||||
|
||||
static inline void fdt64_st(void *property, uint64_t value)
|
||||
{
|
||||
uint8_t *bp = property;
|
||||
|
||||
bp[0] = value >> 56;
|
||||
bp[1] = (value >> 48) & 0xff;
|
||||
bp[2] = (value >> 40) & 0xff;
|
||||
bp[3] = (value >> 32) & 0xff;
|
||||
bp[4] = (value >> 24) & 0xff;
|
||||
bp[5] = (value >> 16) & 0xff;
|
||||
bp[6] = (value >> 8) & 0xff;
|
||||
bp[7] = value & 0xff;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Traversal functions */
|
||||
/**********************************************************************/
|
||||
@ -214,7 +195,7 @@ int fdt_next_subnode(const void *fdt, int offset);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* if ((node < 0) && (node != -FDT_ERR_NOTFOUND)) {
|
||||
* if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
|
||||
* Error handling
|
||||
* }
|
||||
*
|
||||
@ -232,7 +213,7 @@ int fdt_next_subnode(const void *fdt, int offset);
|
||||
/* General functions */
|
||||
/**********************************************************************/
|
||||
#define fdt_get_header(fdt, field) \
|
||||
(fdt32_ld(&((const struct fdt_header *)(fdt))->field))
|
||||
(fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
|
||||
#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
|
||||
#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
|
||||
#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
|
||||
@ -263,31 +244,18 @@ fdt_set_hdr_(size_dt_struct);
|
||||
#undef fdt_set_hdr_
|
||||
|
||||
/**
|
||||
* fdt_header_size - return the size of the tree's header
|
||||
* @fdt: pointer to a flattened device tree
|
||||
*/
|
||||
size_t fdt_header_size_(uint32_t version);
|
||||
static inline size_t fdt_header_size(const void *fdt)
|
||||
{
|
||||
return fdt_header_size_(fdt_version(fdt));
|
||||
}
|
||||
|
||||
/**
|
||||
* fdt_check_header - sanity check a device tree header
|
||||
|
||||
* fdt_check_header - sanity check a device tree or possible device tree
|
||||
* @fdt: pointer to data which might be a flattened device tree
|
||||
*
|
||||
* fdt_check_header() checks that the given buffer contains what
|
||||
* appears to be a flattened device tree, and that the header contains
|
||||
* valid information (to the extent that can be determined from the
|
||||
* header alone).
|
||||
* appears to be a flattened device tree with sane information in its
|
||||
* header.
|
||||
*
|
||||
* returns:
|
||||
* 0, if the buffer appears to contain a valid device tree
|
||||
* -FDT_ERR_BADMAGIC,
|
||||
* -FDT_ERR_BADVERSION,
|
||||
* -FDT_ERR_BADSTATE,
|
||||
* -FDT_ERR_TRUNCATED, standard meanings, as above
|
||||
* -FDT_ERR_BADSTATE, standard meanings, as above
|
||||
*/
|
||||
int fdt_check_header(const void *fdt);
|
||||
|
||||
@ -316,24 +284,6 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
|
||||
/* Read-only functions */
|
||||
/**********************************************************************/
|
||||
|
||||
int fdt_check_full(const void *fdt, size_t bufsize);
|
||||
|
||||
/**
|
||||
* fdt_get_string - retrieve a string from the strings block of a device tree
|
||||
* @fdt: pointer to the device tree blob
|
||||
* @stroffset: offset of the string within the strings block (native endian)
|
||||
* @lenp: optional pointer to return the string's length
|
||||
*
|
||||
* fdt_get_string() retrieves a pointer to a single string from the
|
||||
* strings block of the device tree blob at fdt, and optionally also
|
||||
* returns the string's length in *lenp.
|
||||
*
|
||||
* returns:
|
||||
* a pointer to the string, on success
|
||||
* NULL, if stroffset is out of bounds, or doesn't point to a valid string
|
||||
*/
|
||||
const char *fdt_get_string(const void *fdt, int stroffset, int *lenp);
|
||||
|
||||
/**
|
||||
* fdt_string - retrieve a string from the strings block of a device tree
|
||||
* @fdt: pointer to the device tree blob
|
||||
@ -344,24 +294,10 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp);
|
||||
*
|
||||
* returns:
|
||||
* a pointer to the string, on success
|
||||
* NULL, if stroffset is out of bounds, or doesn't point to a valid string
|
||||
* NULL, if stroffset is out of bounds
|
||||
*/
|
||||
const char *fdt_string(const void *fdt, int stroffset);
|
||||
|
||||
/**
|
||||
* fdt_find_max_phandle - find and return the highest phandle in a tree
|
||||
* @fdt: pointer to the device tree blob
|
||||
* @phandle: return location for the highest phandle value found in the tree
|
||||
*
|
||||
* fdt_find_max_phandle() finds the highest phandle value in the given device
|
||||
* tree. The value returned in @phandle is only valid if the function returns
|
||||
* success.
|
||||
*
|
||||
* returns:
|
||||
* 0 on success or a negative error code on failure
|
||||
*/
|
||||
int fdt_find_max_phandle(const void *fdt, uint32_t *phandle);
|
||||
|
||||
/**
|
||||
* fdt_get_max_phandle - retrieves the highest phandle in a tree
|
||||
* @fdt: pointer to the device tree blob
|
||||
@ -370,39 +306,12 @@ int fdt_find_max_phandle(const void *fdt, uint32_t *phandle);
|
||||
* device tree. This will ignore badly formatted phandles, or phandles
|
||||
* with a value of 0 or -1.
|
||||
*
|
||||
* This function is deprecated in favour of fdt_find_max_phandle().
|
||||
*
|
||||
* returns:
|
||||
* the highest phandle on success
|
||||
* 0, if no phandle was found in the device tree
|
||||
* -1, if an error occurred
|
||||
*/
|
||||
static inline uint32_t fdt_get_max_phandle(const void *fdt)
|
||||
{
|
||||
uint32_t phandle;
|
||||
int err;
|
||||
|
||||
err = fdt_find_max_phandle(fdt, &phandle);
|
||||
if (err < 0)
|
||||
return (uint32_t)-1;
|
||||
|
||||
return phandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* fdt_generate_phandle - return a new, unused phandle for a device tree blob
|
||||
* @fdt: pointer to the device tree blob
|
||||
* @phandle: return location for the new phandle
|
||||
*
|
||||
* Walks the device tree blob and looks for the highest phandle value. On
|
||||
* success, the new, unused phandle value (one higher than the previously
|
||||
* highest phandle value in the device tree blob) will be returned in the
|
||||
* @phandle parameter.
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success or a negative error-code on failure
|
||||
*/
|
||||
int fdt_generate_phandle(const void *fdt, uint32_t *phandle);
|
||||
uint32_t fdt_get_max_phandle(const void *fdt);
|
||||
|
||||
/**
|
||||
* fdt_num_mem_rsv - retrieve the number of memory reserve map entries
|
||||
@ -594,7 +503,7 @@ int fdt_next_property_offset(const void *fdt, int offset);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* if ((property < 0) && (property != -FDT_ERR_NOTFOUND)) {
|
||||
* if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {
|
||||
* Error handling
|
||||
* }
|
||||
*
|
||||
@ -697,7 +606,7 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
|
||||
/**
|
||||
* fdt_getprop_by_offset - retrieve the value of a property at a given offset
|
||||
* @fdt: pointer to the device tree blob
|
||||
* @offset: offset of the property to read
|
||||
* @ffset: offset of the property to read
|
||||
* @namep: pointer to a string variable (will be overwritten) or NULL
|
||||
* @lenp: pointer to an integer variable (will be overwritten) or NULL
|
||||
*
|
||||
@ -1181,7 +1090,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset);
|
||||
*
|
||||
* returns:
|
||||
* 0 <= n < FDT_MAX_NCELLS, on success
|
||||
* 1, if the node has no #size-cells property
|
||||
* 2, if the node has no #address-cells property
|
||||
* -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
|
||||
* #size-cells property
|
||||
* -FDT_ERR_BADMAGIC,
|
||||
@ -1388,45 +1297,7 @@ int fdt_nop_node(void *fdt, int nodeoffset);
|
||||
/* Sequential write functions */
|
||||
/**********************************************************************/
|
||||
|
||||
/* fdt_create_with_flags flags */
|
||||
#define FDT_CREATE_FLAG_NO_NAME_DEDUP 0x1
|
||||
/* FDT_CREATE_FLAG_NO_NAME_DEDUP: Do not try to de-duplicate property
|
||||
* names in the fdt. This can result in faster creation times, but
|
||||
* a larger fdt. */
|
||||
|
||||
#define FDT_CREATE_FLAGS_ALL (FDT_CREATE_FLAG_NO_NAME_DEDUP)
|
||||
|
||||
/**
|
||||
* fdt_create_with_flags - begin creation of a new fdt
|
||||
* @fdt: pointer to memory allocated where fdt will be created
|
||||
* @bufsize: size of the memory space at fdt
|
||||
* @flags: a valid combination of FDT_CREATE_FLAG_ flags, or 0.
|
||||
*
|
||||
* fdt_create_with_flags() begins the process of creating a new fdt with
|
||||
* the sequential write interface.
|
||||
*
|
||||
* fdt creation process must end with fdt_finished() to produce a valid fdt.
|
||||
*
|
||||
* returns:
|
||||
* 0, on success
|
||||
* -FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt
|
||||
* -FDT_ERR_BADFLAGS, flags is not valid
|
||||
*/
|
||||
int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags);
|
||||
|
||||
/**
|
||||
* fdt_create - begin creation of a new fdt
|
||||
* @fdt: pointer to memory allocated where fdt will be created
|
||||
* @bufsize: size of the memory space at fdt
|
||||
*
|
||||
* fdt_create() is equivalent to fdt_create_with_flags() with flags=0.
|
||||
*
|
||||
* returns:
|
||||
* 0, on success
|
||||
* -FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt
|
||||
*/
|
||||
int fdt_create(void *buf, int bufsize);
|
||||
|
||||
int fdt_resize(void *fdt, void *buf, int bufsize);
|
||||
int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
|
||||
int fdt_finish_reservemap(void *fdt);
|
||||
@ -1442,13 +1313,10 @@ static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
|
||||
fdt64_t tmp = cpu_to_fdt64(val);
|
||||
return fdt_property(fdt, name, &tmp, sizeof(tmp));
|
||||
}
|
||||
|
||||
#ifndef SWIG /* Not available in Python */
|
||||
static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
|
||||
{
|
||||
return fdt_property_u32(fdt, name, val);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* fdt_property_placeholder - add a new property and return a ptr to its value
|
||||
@ -1897,43 +1765,6 @@ static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
|
||||
#define fdt_appendprop_string(fdt, nodeoffset, name, str) \
|
||||
fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
|
||||
|
||||
/**
|
||||
* fdt_appendprop_addrrange - append a address range property
|
||||
* @fdt: pointer to the device tree blob
|
||||
* @parent: offset of the parent node
|
||||
* @nodeoffset: offset of the node to add a property at
|
||||
* @name: name of property
|
||||
* @addr: start address of a given range
|
||||
* @size: size of a given range
|
||||
*
|
||||
* fdt_appendprop_addrrange() appends an address range value (start
|
||||
* address and size) to the value of the named property in the given
|
||||
* node, or creates a new property with that value if it does not
|
||||
* already exist.
|
||||
* If "name" is not specified, a default "reg" is used.
|
||||
* Cell sizes are determined by parent's #address-cells and #size-cells.
|
||||
*
|
||||
* This function may insert data into the blob, and will therefore
|
||||
* change the offsets of some existing nodes.
|
||||
*
|
||||
* returns:
|
||||
* 0, on success
|
||||
* -FDT_ERR_BADLAYOUT,
|
||||
* -FDT_ERR_BADMAGIC,
|
||||
* -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
|
||||
* #address-cells property
|
||||
* -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
|
||||
* -FDT_ERR_BADSTATE,
|
||||
* -FDT_ERR_BADSTRUCTURE,
|
||||
* -FDT_ERR_BADVERSION,
|
||||
* -FDT_ERR_BADVALUE, addr or size doesn't fit to respective cells size
|
||||
* -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
|
||||
* contain a new property
|
||||
* -FDT_ERR_TRUNCATED, standard meanings
|
||||
*/
|
||||
int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,
|
||||
const char *name, uint64_t addr, uint64_t size);
|
||||
|
||||
/**
|
||||
* fdt_delprop - delete a property
|
||||
* @fdt: pointer to the device tree blob
|
||||
|
@ -1,18 +1,61 @@
|
||||
/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
|
||||
#ifndef LIBFDT_ENV_H
|
||||
#define LIBFDT_ENV_H
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
* Copyright 2012 Kim Phillips, Freescale Semiconductor.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __CHECKER__
|
||||
#define FDT_FORCE __attribute__((force))
|
||||
|
@ -1,20 +1,64 @@
|
||||
/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
|
||||
#ifndef LIBFDT_INTERNAL_H
|
||||
#define LIBFDT_INTERNAL_H
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <fdt.h>
|
||||
|
||||
#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
||||
#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
|
||||
|
||||
int fdt_ro_probe_(const void *fdt);
|
||||
#define FDT_RO_PROBE(fdt) \
|
||||
#define FDT_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err_; \
|
||||
if ((err_ = fdt_ro_probe_(fdt)) != 0) \
|
||||
if ((err_ = fdt_check_header(fdt)) != 0) \
|
||||
return err_; \
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,24 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include "dtc.h"
|
||||
#include "srcpos.h"
|
||||
|
||||
/*
|
||||
* Tree building functions
|
||||
@ -36,8 +50,7 @@ void delete_labels(struct label **labels)
|
||||
label->deleted = 1;
|
||||
}
|
||||
|
||||
struct property *build_property(char *name, struct data val,
|
||||
struct srcpos *srcpos)
|
||||
struct property *build_property(char *name, struct data val)
|
||||
{
|
||||
struct property *new = xmalloc(sizeof(*new));
|
||||
|
||||
@ -45,7 +58,6 @@ struct property *build_property(char *name, struct data val,
|
||||
|
||||
new->name = name;
|
||||
new->val = val;
|
||||
new->srcpos = srcpos_copy(srcpos);
|
||||
|
||||
return new;
|
||||
}
|
||||
@ -85,8 +97,7 @@ struct property *reverse_properties(struct property *first)
|
||||
return head;
|
||||
}
|
||||
|
||||
struct node *build_node(struct property *proplist, struct node *children,
|
||||
struct srcpos *srcpos)
|
||||
struct node *build_node(struct property *proplist, struct node *children)
|
||||
{
|
||||
struct node *new = xmalloc(sizeof(*new));
|
||||
struct node *child;
|
||||
@ -95,7 +106,6 @@ struct node *build_node(struct property *proplist, struct node *children,
|
||||
|
||||
new->proplist = reverse_properties(proplist);
|
||||
new->children = children;
|
||||
new->srcpos = srcpos_copy(srcpos);
|
||||
|
||||
for_each_child(new, child) {
|
||||
child->parent = new;
|
||||
@ -104,14 +114,13 @@ struct node *build_node(struct property *proplist, struct node *children,
|
||||
return new;
|
||||
}
|
||||
|
||||
struct node *build_node_delete(struct srcpos *srcpos)
|
||||
struct node *build_node_delete(void)
|
||||
{
|
||||
struct node *new = xmalloc(sizeof(*new));
|
||||
|
||||
memset(new, 0, sizeof(*new));
|
||||
|
||||
new->deleted = 1;
|
||||
new->srcpos = srcpos_copy(srcpos);
|
||||
|
||||
return new;
|
||||
}
|
||||
@ -174,8 +183,6 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
|
||||
|
||||
old_prop->val = new_prop->val;
|
||||
old_prop->deleted = 0;
|
||||
free(old_prop->srcpos);
|
||||
old_prop->srcpos = new_prop->srcpos;
|
||||
free(new_prop);
|
||||
new_prop = NULL;
|
||||
break;
|
||||
@ -216,8 +223,6 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
|
||||
add_child(old_node, new_child);
|
||||
}
|
||||
|
||||
old_node->srcpos = srcpos_extend(old_node->srcpos, new_node->srcpos);
|
||||
|
||||
/* The new node contents are now merged into the old node. Free
|
||||
* the new node. */
|
||||
free(new_node);
|
||||
@ -234,21 +239,20 @@ struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
|
||||
char *name;
|
||||
|
||||
if (ref[0] == '/') {
|
||||
d = data_add_marker(d, TYPE_STRING, ref);
|
||||
d = data_append_data(d, ref, strlen(ref) + 1);
|
||||
|
||||
p = build_property("target-path", d, NULL);
|
||||
p = build_property("target-path", d);
|
||||
} else {
|
||||
d = data_add_marker(d, REF_PHANDLE, ref);
|
||||
d = data_append_integer(d, 0xffffffff, 32);
|
||||
|
||||
p = build_property("target", d, NULL);
|
||||
p = build_property("target", d);
|
||||
}
|
||||
|
||||
xasprintf(&name, "fragment@%u",
|
||||
next_orphan_fragment++);
|
||||
name_node(new_node, "__overlay__");
|
||||
node = build_node(p, new_node, NULL);
|
||||
node = build_node(p, new_node);
|
||||
name_node(node, name);
|
||||
|
||||
add_child(dt, node);
|
||||
@ -336,21 +340,18 @@ void delete_node(struct node *node)
|
||||
}
|
||||
|
||||
void append_to_property(struct node *node,
|
||||
char *name, const void *data, int len,
|
||||
enum markertype type)
|
||||
char *name, const void *data, int len)
|
||||
{
|
||||
struct data d;
|
||||
struct property *p;
|
||||
|
||||
p = get_property(node, name);
|
||||
if (p) {
|
||||
d = data_add_marker(p->val, type, name);
|
||||
d = data_append_data(d, data, len);
|
||||
d = data_append_data(p->val, data, len);
|
||||
p->val = d;
|
||||
} else {
|
||||
d = data_add_marker(empty_data, type, name);
|
||||
d = data_append_data(d, data, len);
|
||||
p = build_property(name, d, NULL);
|
||||
d = data_append_data(empty_data, data, len);
|
||||
p = build_property(name, d);
|
||||
add_property(node, p);
|
||||
}
|
||||
}
|
||||
@ -593,7 +594,6 @@ struct node *get_node_by_ref(struct node *tree, const char *ref)
|
||||
cell_t get_node_phandle(struct node *root, struct node *node)
|
||||
{
|
||||
static cell_t phandle = 1; /* FIXME: ick, static local */
|
||||
struct data d = empty_data;
|
||||
|
||||
if ((node->phandle != 0) && (node->phandle != -1))
|
||||
return node->phandle;
|
||||
@ -603,16 +603,17 @@ cell_t get_node_phandle(struct node *root, struct node *node)
|
||||
|
||||
node->phandle = phandle;
|
||||
|
||||
d = data_add_marker(d, TYPE_UINT32, NULL);
|
||||
d = data_append_cell(d, phandle);
|
||||
|
||||
if (!get_property(node, "linux,phandle")
|
||||
&& (phandle_format & PHANDLE_LEGACY))
|
||||
add_property(node, build_property("linux,phandle", d, NULL));
|
||||
add_property(node,
|
||||
build_property("linux,phandle",
|
||||
data_append_cell(empty_data, phandle)));
|
||||
|
||||
if (!get_property(node, "phandle")
|
||||
&& (phandle_format & PHANDLE_EPAPR))
|
||||
add_property(node, build_property("phandle", d, NULL));
|
||||
add_property(node,
|
||||
build_property("phandle",
|
||||
data_append_cell(empty_data, phandle)));
|
||||
|
||||
/* If the node *does* have a phandle property, we must
|
||||
* be dealing with a self-referencing phandle, which will be
|
||||
@ -786,7 +787,7 @@ static struct node *build_and_name_child_node(struct node *parent, char *name)
|
||||
{
|
||||
struct node *node;
|
||||
|
||||
node = build_node(NULL, NULL, NULL);
|
||||
node = build_node(NULL, NULL);
|
||||
name_node(node, xstrdup(name));
|
||||
add_child(parent, node);
|
||||
|
||||
@ -847,9 +848,8 @@ static void generate_label_tree_internal(struct dt_info *dti,
|
||||
|
||||
/* insert it */
|
||||
p = build_property(l->label,
|
||||
data_copy_escape_string(node->fullpath,
|
||||
strlen(node->fullpath)),
|
||||
NULL);
|
||||
data_copy_mem(node->fullpath,
|
||||
strlen(node->fullpath) + 1));
|
||||
add_property(an, p);
|
||||
}
|
||||
|
||||
@ -899,7 +899,7 @@ static void add_fixup_entry(struct dt_info *dti, struct node *fn,
|
||||
|
||||
xasprintf(&entry, "%s:%s:%u",
|
||||
node->fullpath, prop->name, m->offset);
|
||||
append_to_property(fn, m->ref, entry, strlen(entry) + 1, TYPE_STRING);
|
||||
append_to_property(fn, m->ref, entry, strlen(entry) + 1);
|
||||
|
||||
free(entry);
|
||||
}
|
||||
@ -959,7 +959,7 @@ static void add_local_fixup_entry(struct dt_info *dti,
|
||||
char **compp;
|
||||
int i, depth;
|
||||
|
||||
/* walk back retrieving depth */
|
||||
/* walk back retreiving depth */
|
||||
depth = 0;
|
||||
for (wn = node; wn; wn = wn->parent)
|
||||
depth++;
|
||||
@ -982,7 +982,7 @@ static void add_local_fixup_entry(struct dt_info *dti,
|
||||
free(compp);
|
||||
|
||||
value_32 = cpu_to_fdt32(m->offset);
|
||||
append_to_property(wn, prop->name, &value_32, sizeof(value_32), TYPE_UINT32);
|
||||
append_to_property(wn, prop->name, &value_32, sizeof(value_32));
|
||||
}
|
||||
|
||||
static void generate_local_fixups_tree_internal(struct dt_info *dti,
|
||||
|
@ -1,6 +1,20 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright 2007 Jon Loeliger, Freescale Semiconductor, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
@ -19,9 +33,6 @@ struct search_path {
|
||||
/* This is the list of directories that we search for source files */
|
||||
static struct search_path *search_path_head, **search_path_tail;
|
||||
|
||||
/* Detect infinite include recursion. */
|
||||
#define MAX_SRCFILE_DEPTH (100)
|
||||
static int srcfile_depth; /* = 0 */
|
||||
|
||||
static char *get_dirname(const char *path)
|
||||
{
|
||||
@ -40,51 +51,11 @@ static char *get_dirname(const char *path)
|
||||
|
||||
FILE *depfile; /* = NULL */
|
||||
struct srcfile_state *current_srcfile; /* = NULL */
|
||||
static char *initial_path; /* = NULL */
|
||||
static int initial_pathlen; /* = 0 */
|
||||
static bool initial_cpp = true;
|
||||
|
||||
static void set_initial_path(char *fname)
|
||||
{
|
||||
int i, len = strlen(fname);
|
||||
/* Detect infinite include recursion. */
|
||||
#define MAX_SRCFILE_DEPTH (100)
|
||||
static int srcfile_depth; /* = 0 */
|
||||
|
||||
xasprintf(&initial_path, "%s", fname);
|
||||
initial_pathlen = 0;
|
||||
for (i = 0; i != len; i++)
|
||||
if (initial_path[i] == '/')
|
||||
initial_pathlen++;
|
||||
}
|
||||
|
||||
static char *shorten_to_initial_path(char *fname)
|
||||
{
|
||||
char *p1, *p2, *prevslash1 = NULL;
|
||||
int slashes = 0;
|
||||
|
||||
for (p1 = fname, p2 = initial_path; *p1 && *p2; p1++, p2++) {
|
||||
if (*p1 != *p2)
|
||||
break;
|
||||
if (*p1 == '/') {
|
||||
prevslash1 = p1;
|
||||
slashes++;
|
||||
}
|
||||
}
|
||||
p1 = prevslash1 + 1;
|
||||
if (prevslash1) {
|
||||
int diff = initial_pathlen - slashes, i, j;
|
||||
int restlen = strlen(fname) - (p1 - fname);
|
||||
char *res;
|
||||
|
||||
res = xmalloc((3 * diff) + restlen + 1);
|
||||
for (i = 0, j = 0; i != diff; i++) {
|
||||
res[j++] = '.';
|
||||
res[j++] = '.';
|
||||
res[j++] = '/';
|
||||
}
|
||||
strcpy(res + j, p1);
|
||||
return res;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to open a file in a given directory.
|
||||
@ -186,9 +157,6 @@ void srcfile_push(const char *fname)
|
||||
srcfile->colno = 1;
|
||||
|
||||
current_srcfile = srcfile;
|
||||
|
||||
if (srcfile_depth == 1)
|
||||
set_initial_path(srcfile->name);
|
||||
}
|
||||
|
||||
bool srcfile_pop(void)
|
||||
@ -229,6 +197,18 @@ void srcfile_add_search_path(const char *dirname)
|
||||
search_path_tail = &node->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* The empty source position.
|
||||
*/
|
||||
|
||||
struct srcpos srcpos_empty = {
|
||||
.first_line = 0,
|
||||
.first_column = 0,
|
||||
.last_line = 0,
|
||||
.last_column = 0,
|
||||
.file = NULL,
|
||||
};
|
||||
|
||||
void srcpos_update(struct srcpos *pos, const char *text, int len)
|
||||
{
|
||||
int i;
|
||||
@ -254,35 +234,13 @@ struct srcpos *
|
||||
srcpos_copy(struct srcpos *pos)
|
||||
{
|
||||
struct srcpos *pos_new;
|
||||
struct srcfile_state *srcfile_state;
|
||||
|
||||
if (!pos)
|
||||
return NULL;
|
||||
|
||||
pos_new = xmalloc(sizeof(struct srcpos));
|
||||
assert(pos->next == NULL);
|
||||
memcpy(pos_new, pos, sizeof(struct srcpos));
|
||||
|
||||
/* allocate without free */
|
||||
srcfile_state = xmalloc(sizeof(struct srcfile_state));
|
||||
memcpy(srcfile_state, pos->file, sizeof(struct srcfile_state));
|
||||
pos_new->file = srcfile_state;
|
||||
|
||||
return pos_new;
|
||||
}
|
||||
|
||||
struct srcpos *srcpos_extend(struct srcpos *pos, struct srcpos *newtail)
|
||||
{
|
||||
struct srcpos *p;
|
||||
|
||||
if (!pos)
|
||||
return newtail;
|
||||
|
||||
for (p = pos; p->next != NULL; p = p->next);
|
||||
p->next = newtail;
|
||||
return pos;
|
||||
}
|
||||
|
||||
char *
|
||||
srcpos_string(struct srcpos *pos)
|
||||
{
|
||||
@ -308,68 +266,6 @@ srcpos_string(struct srcpos *pos)
|
||||
return pos_str;
|
||||
}
|
||||
|
||||
static char *
|
||||
srcpos_string_comment(struct srcpos *pos, bool first_line, int level)
|
||||
{
|
||||
char *pos_str, *fname, *first, *rest;
|
||||
bool fresh_fname = false;
|
||||
|
||||
if (!pos) {
|
||||
if (level > 1) {
|
||||
xasprintf(&pos_str, "<no-file>:<no-line>");
|
||||
return pos_str;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pos->file)
|
||||
fname = "<no-file>";
|
||||
else if (!pos->file->name)
|
||||
fname = "<no-filename>";
|
||||
else if (level > 1)
|
||||
fname = pos->file->name;
|
||||
else {
|
||||
fname = shorten_to_initial_path(pos->file->name);
|
||||
if (fname)
|
||||
fresh_fname = true;
|
||||
else
|
||||
fname = pos->file->name;
|
||||
}
|
||||
|
||||
if (level > 1)
|
||||
xasprintf(&first, "%s:%d:%d-%d:%d", fname,
|
||||
pos->first_line, pos->first_column,
|
||||
pos->last_line, pos->last_column);
|
||||
else
|
||||
xasprintf(&first, "%s:%d", fname,
|
||||
first_line ? pos->first_line : pos->last_line);
|
||||
|
||||
if (fresh_fname)
|
||||
free(fname);
|
||||
|
||||
if (pos->next != NULL) {
|
||||
rest = srcpos_string_comment(pos->next, first_line, level);
|
||||
xasprintf(&pos_str, "%s, %s", first, rest);
|
||||
free(first);
|
||||
free(rest);
|
||||
} else {
|
||||
pos_str = first;
|
||||
}
|
||||
|
||||
return pos_str;
|
||||
}
|
||||
|
||||
char *srcpos_string_first(struct srcpos *pos, int level)
|
||||
{
|
||||
return srcpos_string_comment(pos, true, level);
|
||||
}
|
||||
|
||||
char *srcpos_string_last(struct srcpos *pos, int level)
|
||||
{
|
||||
return srcpos_string_comment(pos, false, level);
|
||||
}
|
||||
|
||||
void srcpos_verror(struct srcpos *pos, const char *prefix,
|
||||
const char *fmt, va_list va)
|
||||
{
|
||||
@ -398,9 +294,4 @@ void srcpos_set_line(char *f, int l)
|
||||
{
|
||||
current_srcfile->name = f;
|
||||
current_srcfile->lineno = l;
|
||||
|
||||
if (initial_cpp) {
|
||||
initial_cpp = false;
|
||||
set_initial_path(f);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,20 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* Copyright 2007 Jon Loeliger, Freescale Semiconductor, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#ifndef SRCPOS_H
|
||||
@ -60,7 +74,6 @@ struct srcpos {
|
||||
int last_line;
|
||||
int last_column;
|
||||
struct srcfile_state *file;
|
||||
struct srcpos *next;
|
||||
};
|
||||
|
||||
#define YYLTYPE struct srcpos
|
||||
@ -80,18 +93,19 @@ struct srcpos {
|
||||
YYRHSLOC(Rhs, 0).last_column; \
|
||||
(Current).file = YYRHSLOC (Rhs, 0).file; \
|
||||
} \
|
||||
(Current).next = NULL; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Fictional source position used for IR nodes that are
|
||||
* created without otherwise knowing a true source position.
|
||||
* For example,constant definitions from the command line.
|
||||
*/
|
||||
extern struct srcpos srcpos_empty;
|
||||
|
||||
extern void srcpos_update(struct srcpos *pos, const char *text, int len);
|
||||
extern struct srcpos *srcpos_copy(struct srcpos *pos);
|
||||
extern struct srcpos *srcpos_extend(struct srcpos *new_srcpos,
|
||||
struct srcpos *old_srcpos);
|
||||
extern char *srcpos_string(struct srcpos *pos);
|
||||
extern char *srcpos_string_first(struct srcpos *pos, int level);
|
||||
extern char *srcpos_string_last(struct srcpos *pos, int level);
|
||||
|
||||
|
||||
extern void PRINTF(3, 0) srcpos_verror(struct srcpos *pos, const char *prefix,
|
||||
const char *fmt, va_list va);
|
||||
|
@ -1,6 +1,21 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include "dtc.h"
|
||||
@ -46,18 +61,24 @@ static bool isstring(char c)
|
||||
|| strchr("\a\b\t\n\v\f\r", c));
|
||||
}
|
||||
|
||||
static void write_propval_string(FILE *f, const char *s, size_t len)
|
||||
static void write_propval_string(FILE *f, struct data val)
|
||||
{
|
||||
const char *end = s + len - 1;
|
||||
const char *str = val.val;
|
||||
int i;
|
||||
struct marker *m = val.markers;
|
||||
|
||||
if (!len)
|
||||
return;
|
||||
|
||||
assert(*end == '\0');
|
||||
assert(str[val.len-1] == '\0');
|
||||
|
||||
while (m && (m->offset == 0)) {
|
||||
if (m->type == LABEL)
|
||||
fprintf(f, "%s: ", m->ref);
|
||||
m = m->next;
|
||||
}
|
||||
fprintf(f, "\"");
|
||||
while (s < end) {
|
||||
char c = *s++;
|
||||
|
||||
for (i = 0; i < (val.len-1); i++) {
|
||||
char c = str[i];
|
||||
|
||||
switch (c) {
|
||||
case '\a':
|
||||
fprintf(f, "\\a");
|
||||
@ -87,80 +108,91 @@ static void write_propval_string(FILE *f, const char *s, size_t len)
|
||||
fprintf(f, "\\\"");
|
||||
break;
|
||||
case '\0':
|
||||
fprintf(f, "\\0");
|
||||
fprintf(f, "\", ");
|
||||
while (m && (m->offset <= (i + 1))) {
|
||||
if (m->type == LABEL) {
|
||||
assert(m->offset == (i+1));
|
||||
fprintf(f, "%s: ", m->ref);
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
fprintf(f, "\"");
|
||||
break;
|
||||
default:
|
||||
if (isprint((unsigned char)c))
|
||||
fprintf(f, "%c", c);
|
||||
else
|
||||
fprintf(f, "\\x%02"PRIx8, c);
|
||||
fprintf(f, "\\x%02hhx", c);
|
||||
}
|
||||
}
|
||||
fprintf(f, "\"");
|
||||
}
|
||||
|
||||
static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
|
||||
{
|
||||
const char *end = p + len;
|
||||
assert(len % width == 0);
|
||||
|
||||
for (; p < end; p += width) {
|
||||
switch (width) {
|
||||
case 1:
|
||||
fprintf(f, "%02"PRIx8, *(const uint8_t*)p);
|
||||
break;
|
||||
case 2:
|
||||
fprintf(f, "0x%02"PRIx16, fdt16_to_cpu(*(const fdt16_t*)p));
|
||||
break;
|
||||
case 4:
|
||||
fprintf(f, "0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p));
|
||||
break;
|
||||
case 8:
|
||||
fprintf(f, "0x%02"PRIx64, fdt64_to_cpu(*(const fdt64_t*)p));
|
||||
break;
|
||||
}
|
||||
if (p + width < end)
|
||||
fputc(' ', f);
|
||||
/* Wrap up any labels at the end of the value */
|
||||
for_each_marker_of_type(m, LABEL) {
|
||||
assert (m->offset == val.len);
|
||||
fprintf(f, " %s:", m->ref);
|
||||
}
|
||||
}
|
||||
|
||||
static bool has_data_type_information(struct marker *m)
|
||||
static void write_propval_cells(FILE *f, struct data val)
|
||||
{
|
||||
return m->type >= TYPE_UINT8;
|
||||
void *propend = val.val + val.len;
|
||||
fdt32_t *cp = (fdt32_t *)val.val;
|
||||
struct marker *m = val.markers;
|
||||
|
||||
fprintf(f, "<");
|
||||
for (;;) {
|
||||
while (m && (m->offset <= ((char *)cp - val.val))) {
|
||||
if (m->type == LABEL) {
|
||||
assert(m->offset == ((char *)cp - val.val));
|
||||
fprintf(f, "%s: ", m->ref);
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
|
||||
fprintf(f, "0x%x", fdt32_to_cpu(*cp++));
|
||||
if ((void *)cp >= propend)
|
||||
break;
|
||||
fprintf(f, " ");
|
||||
}
|
||||
|
||||
/* Wrap up any labels at the end of the value */
|
||||
for_each_marker_of_type(m, LABEL) {
|
||||
assert (m->offset == val.len);
|
||||
fprintf(f, " %s:", m->ref);
|
||||
}
|
||||
fprintf(f, ">");
|
||||
}
|
||||
|
||||
static struct marker *next_type_marker(struct marker *m)
|
||||
static void write_propval_bytes(FILE *f, struct data val)
|
||||
{
|
||||
while (m && !has_data_type_information(m))
|
||||
m = m->next;
|
||||
return m;
|
||||
void *propend = val.val + val.len;
|
||||
const char *bp = val.val;
|
||||
struct marker *m = val.markers;
|
||||
|
||||
fprintf(f, "[");
|
||||
for (;;) {
|
||||
while (m && (m->offset == (bp-val.val))) {
|
||||
if (m->type == LABEL)
|
||||
fprintf(f, "%s: ", m->ref);
|
||||
m = m->next;
|
||||
}
|
||||
|
||||
fprintf(f, "%02hhx", (unsigned char)(*bp++));
|
||||
if ((const void *)bp >= propend)
|
||||
break;
|
||||
fprintf(f, " ");
|
||||
}
|
||||
|
||||
/* Wrap up any labels at the end of the value */
|
||||
for_each_marker_of_type(m, LABEL) {
|
||||
assert (m->offset == val.len);
|
||||
fprintf(f, " %s:", m->ref);
|
||||
}
|
||||
fprintf(f, "]");
|
||||
}
|
||||
|
||||
size_t type_marker_length(struct marker *m)
|
||||
{
|
||||
struct marker *next = next_type_marker(m->next);
|
||||
|
||||
if (next)
|
||||
return next->offset - m->offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *delim_start[] = {
|
||||
[TYPE_UINT8] = "[",
|
||||
[TYPE_UINT16] = "/bits/ 16 <",
|
||||
[TYPE_UINT32] = "<",
|
||||
[TYPE_UINT64] = "/bits/ 64 <",
|
||||
[TYPE_STRING] = "",
|
||||
};
|
||||
static const char *delim_end[] = {
|
||||
[TYPE_UINT8] = "]",
|
||||
[TYPE_UINT16] = ">",
|
||||
[TYPE_UINT32] = ">",
|
||||
[TYPE_UINT64] = ">",
|
||||
[TYPE_STRING] = "",
|
||||
};
|
||||
|
||||
static enum markertype guess_value_type(struct property *prop)
|
||||
static void write_propval(FILE *f, struct property *prop)
|
||||
{
|
||||
int len = prop->val.len;
|
||||
const char *p = prop->val.val;
|
||||
@ -169,6 +201,11 @@ static enum markertype guess_value_type(struct property *prop)
|
||||
int nnotstringlbl = 0, nnotcelllbl = 0;
|
||||
int i;
|
||||
|
||||
if (len == 0) {
|
||||
fprintf(f, ";\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (! isstring(p[i]))
|
||||
nnotstring++;
|
||||
@ -183,99 +220,17 @@ static enum markertype guess_value_type(struct property *prop)
|
||||
nnotcelllbl++;
|
||||
}
|
||||
|
||||
fprintf(f, " = ");
|
||||
if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul < (len-nnul))
|
||||
&& (nnotstringlbl == 0)) {
|
||||
return TYPE_STRING;
|
||||
write_propval_string(f, prop->val);
|
||||
} else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) {
|
||||
return TYPE_UINT32;
|
||||
write_propval_cells(f, prop->val);
|
||||
} else {
|
||||
write_propval_bytes(f, prop->val);
|
||||
}
|
||||
|
||||
return TYPE_UINT8;
|
||||
}
|
||||
|
||||
static void write_propval(FILE *f, struct property *prop)
|
||||
{
|
||||
size_t len = prop->val.len;
|
||||
struct marker *m = prop->val.markers;
|
||||
struct marker dummy_marker;
|
||||
enum markertype emit_type = TYPE_NONE;
|
||||
char *srcstr;
|
||||
|
||||
if (len == 0) {
|
||||
fprintf(f, ";");
|
||||
if (annotate) {
|
||||
srcstr = srcpos_string_first(prop->srcpos, annotate);
|
||||
if (srcstr) {
|
||||
fprintf(f, " /* %s */", srcstr);
|
||||
free(srcstr);
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(f, " =");
|
||||
|
||||
if (!next_type_marker(m)) {
|
||||
/* data type information missing, need to guess */
|
||||
dummy_marker.type = guess_value_type(prop);
|
||||
dummy_marker.next = prop->val.markers;
|
||||
dummy_marker.offset = 0;
|
||||
dummy_marker.ref = NULL;
|
||||
m = &dummy_marker;
|
||||
}
|
||||
|
||||
for_each_marker(m) {
|
||||
size_t chunk_len = (m->next ? m->next->offset : len) - m->offset;
|
||||
size_t data_len = type_marker_length(m) ? : len - m->offset;
|
||||
const char *p = &prop->val.val[m->offset];
|
||||
|
||||
if (has_data_type_information(m)) {
|
||||
emit_type = m->type;
|
||||
fprintf(f, " %s", delim_start[emit_type]);
|
||||
} else if (m->type == LABEL)
|
||||
fprintf(f, " %s:", m->ref);
|
||||
else if (m->offset)
|
||||
fputc(' ', f);
|
||||
|
||||
if (emit_type == TYPE_NONE) {
|
||||
assert(chunk_len == 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(emit_type) {
|
||||
case TYPE_UINT16:
|
||||
write_propval_int(f, p, chunk_len, 2);
|
||||
break;
|
||||
case TYPE_UINT32:
|
||||
write_propval_int(f, p, chunk_len, 4);
|
||||
break;
|
||||
case TYPE_UINT64:
|
||||
write_propval_int(f, p, chunk_len, 8);
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
write_propval_string(f, p, chunk_len);
|
||||
break;
|
||||
default:
|
||||
write_propval_int(f, p, chunk_len, 1);
|
||||
}
|
||||
|
||||
if (chunk_len == data_len) {
|
||||
size_t pos = m->offset + chunk_len;
|
||||
fprintf(f, pos == len ? "%s" : "%s,",
|
||||
delim_end[emit_type] ? : "");
|
||||
emit_type = TYPE_NONE;
|
||||
}
|
||||
}
|
||||
fprintf(f, ";");
|
||||
if (annotate) {
|
||||
srcstr = srcpos_string_first(prop->srcpos, annotate);
|
||||
if (srcstr) {
|
||||
fprintf(f, " /* %s */", srcstr);
|
||||
free(srcstr);
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, ";\n");
|
||||
}
|
||||
|
||||
static void write_tree_source_node(FILE *f, struct node *tree, int level)
|
||||
@ -283,24 +238,14 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
|
||||
struct property *prop;
|
||||
struct node *child;
|
||||
struct label *l;
|
||||
char *srcstr;
|
||||
|
||||
write_prefix(f, level);
|
||||
for_each_label(tree->labels, l)
|
||||
fprintf(f, "%s: ", l->label);
|
||||
if (tree->name && (*tree->name))
|
||||
fprintf(f, "%s {", tree->name);
|
||||
fprintf(f, "%s {\n", tree->name);
|
||||
else
|
||||
fprintf(f, "/ {");
|
||||
|
||||
if (annotate) {
|
||||
srcstr = srcpos_string_first(tree->srcpos, annotate);
|
||||
if (srcstr) {
|
||||
fprintf(f, " /* %s */", srcstr);
|
||||
free(srcstr);
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, "/ {\n");
|
||||
|
||||
for_each_property(tree, prop) {
|
||||
write_prefix(f, level+1);
|
||||
@ -314,17 +259,10 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
|
||||
write_tree_source_node(f, child, level+1);
|
||||
}
|
||||
write_prefix(f, level);
|
||||
fprintf(f, "};");
|
||||
if (annotate) {
|
||||
srcstr = srcpos_string_last(tree->srcpos, annotate);
|
||||
if (srcstr) {
|
||||
fprintf(f, " /* %s */", srcstr);
|
||||
free(srcstr);
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, "};\n");
|
||||
}
|
||||
|
||||
|
||||
void dt_to_source(FILE *f, struct dt_info *dti)
|
||||
{
|
||||
struct reserve_info *re;
|
||||
@ -343,3 +281,4 @@ void dt_to_source(FILE *f, struct dt_info *dti)
|
||||
|
||||
write_tree_source_node(f, dti->dt, 0);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ DTC_UPSTREAM_PATH=`pwd`/../dtc
|
||||
DTC_LINUX_PATH=`pwd`/scripts/dtc
|
||||
|
||||
DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \
|
||||
srcpos.h treesource.c util.c util.h version_gen.h yamltree.c Makefile.dtc \
|
||||
srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \
|
||||
dtc-lexer.l dtc-parser.y"
|
||||
LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \
|
||||
fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \
|
||||
|
@ -1,10 +1,24 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright 2011 The Chromium Authors, All Rights Reserved.
|
||||
* Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
|
||||
*
|
||||
* util_is_printable_string contributed by
|
||||
* Pantelis Antoniou <pantelis.antoniou AT gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
@ -32,52 +46,34 @@ char *xstrdup(const char *s)
|
||||
return d;
|
||||
}
|
||||
|
||||
int xavsprintf_append(char **strp, const char *fmt, va_list ap)
|
||||
{
|
||||
int n, size = 0; /* start with 128 bytes */
|
||||
char *p;
|
||||
va_list ap_copy;
|
||||
|
||||
p = *strp;
|
||||
if (p)
|
||||
size = strlen(p);
|
||||
|
||||
va_copy(ap_copy, ap);
|
||||
n = vsnprintf(NULL, 0, fmt, ap_copy) + 1;
|
||||
va_end(ap_copy);
|
||||
|
||||
p = xrealloc(p, size + n);
|
||||
|
||||
n = vsnprintf(p + size, n, fmt, ap);
|
||||
|
||||
*strp = p;
|
||||
return strlen(p);
|
||||
}
|
||||
|
||||
int xasprintf_append(char **strp, const char *fmt, ...)
|
||||
{
|
||||
int n;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
n = xavsprintf_append(strp, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* based in part from (3) vsnprintf */
|
||||
int xasprintf(char **strp, const char *fmt, ...)
|
||||
{
|
||||
int n;
|
||||
int n, size = 128; /* start with 128 bytes */
|
||||
char *p;
|
||||
va_list ap;
|
||||
|
||||
*strp = NULL;
|
||||
/* initial pointer is NULL making the fist realloc to be malloc */
|
||||
p = NULL;
|
||||
while (1) {
|
||||
p = xrealloc(p, size);
|
||||
|
||||
va_start(ap, fmt);
|
||||
n = xavsprintf_append(strp, fmt, ap);
|
||||
va_end(ap);
|
||||
/* Try to print in the allocated space. */
|
||||
va_start(ap, fmt);
|
||||
n = vsnprintf(p, size, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return n;
|
||||
/* If that worked, return the string. */
|
||||
if (n > -1 && n < size)
|
||||
break;
|
||||
/* Else try again with more space. */
|
||||
if (n > -1) /* glibc 2.1 */
|
||||
size = n + 1; /* precisely what is needed */
|
||||
else /* glibc 2.0 */
|
||||
size *= 2; /* twice the old size */
|
||||
}
|
||||
*strp = p;
|
||||
return strlen(p);
|
||||
}
|
||||
|
||||
char *join_path(const char *path, const char *name)
|
||||
@ -231,11 +227,11 @@ char get_escape_char(const char *s, int *i)
|
||||
return val;
|
||||
}
|
||||
|
||||
int utilfdt_read_err(const char *filename, char **buffp, size_t *len)
|
||||
int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len)
|
||||
{
|
||||
int fd = 0; /* assume stdin */
|
||||
char *buf = NULL;
|
||||
size_t bufsize = 1024, offset = 0;
|
||||
off_t bufsize = 1024, offset = 0;
|
||||
int ret = 0;
|
||||
|
||||
*buffp = NULL;
|
||||
@ -268,15 +264,20 @@ int utilfdt_read_err(const char *filename, char **buffp, size_t *len)
|
||||
free(buf);
|
||||
else
|
||||
*buffp = buf;
|
||||
if (len)
|
||||
*len = bufsize;
|
||||
*len = bufsize;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *utilfdt_read(const char *filename, size_t *len)
|
||||
int utilfdt_read_err(const char *filename, char **buffp)
|
||||
{
|
||||
off_t len;
|
||||
return utilfdt_read_err_len(filename, buffp, &len);
|
||||
}
|
||||
|
||||
char *utilfdt_read_len(const char *filename, off_t *len)
|
||||
{
|
||||
char *buff;
|
||||
int ret = utilfdt_read_err(filename, &buff, len);
|
||||
int ret = utilfdt_read_err_len(filename, &buff, len);
|
||||
|
||||
if (ret) {
|
||||
fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename,
|
||||
@ -287,6 +288,12 @@ char *utilfdt_read(const char *filename, size_t *len)
|
||||
return buff;
|
||||
}
|
||||
|
||||
char *utilfdt_read(const char *filename)
|
||||
{
|
||||
off_t len;
|
||||
return utilfdt_read_len(filename, &len);
|
||||
}
|
||||
|
||||
int utilfdt_write_err(const char *filename, const void *blob)
|
||||
{
|
||||
int fd = 1; /* assume stdout */
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
@ -9,6 +8,21 @@
|
||||
/*
|
||||
* Copyright 2011 The Chromium Authors, All Rights Reserved.
|
||||
* Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -58,8 +72,6 @@ static inline void *xrealloc(void *p, size_t len)
|
||||
extern char *xstrdup(const char *s);
|
||||
|
||||
extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...);
|
||||
extern int PRINTF(2, 3) xasprintf_append(char **strp, const char *fmt, ...);
|
||||
extern int xavsprintf_append(char **strp, const char *fmt, va_list ap);
|
||||
extern char *join_path(const char *path, const char *name);
|
||||
|
||||
/**
|
||||
@ -86,10 +98,16 @@ char get_escape_char(const char *s, int *i);
|
||||
* stderr.
|
||||
*
|
||||
* @param filename The filename to read, or - for stdin
|
||||
* @param len If non-NULL, the amount of data we managed to read
|
||||
* @return Pointer to allocated buffer containing fdt, or NULL on error
|
||||
*/
|
||||
char *utilfdt_read(const char *filename, size_t *len);
|
||||
char *utilfdt_read(const char *filename);
|
||||
|
||||
/**
|
||||
* Like utilfdt_read(), but also passes back the size of the file read.
|
||||
*
|
||||
* @param len If non-NULL, the amount of data we managed to read
|
||||
*/
|
||||
char *utilfdt_read_len(const char *filename, off_t *len);
|
||||
|
||||
/**
|
||||
* Read a device tree file into a buffer. Does not report errors, but only
|
||||
@ -98,17 +116,23 @@ char *utilfdt_read(const char *filename, size_t *len);
|
||||
*
|
||||
* @param filename The filename to read, or - for stdin
|
||||
* @param buffp Returns pointer to buffer containing fdt
|
||||
* @param len If non-NULL, the amount of data we managed to read
|
||||
* @return 0 if ok, else an errno value representing the error
|
||||
*/
|
||||
int utilfdt_read_err(const char *filename, char **buffp, size_t *len);
|
||||
int utilfdt_read_err(const char *filename, char **buffp);
|
||||
|
||||
/**
|
||||
* Like utilfdt_read_err(), but also passes back the size of the file read.
|
||||
*
|
||||
* @param len If non-NULL, the amount of data we managed to read
|
||||
*/
|
||||
int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len);
|
||||
|
||||
/**
|
||||
* Write a device tree buffer to a file. This will report any errors on
|
||||
* stderr.
|
||||
*
|
||||
* @param filename The filename to write, or - for stdout
|
||||
* @param blob Pointer to buffer containing fdt
|
||||
* @param blob Poiner to buffer containing fdt
|
||||
* @return 0 if ok, -1 on error
|
||||
*/
|
||||
int utilfdt_write(const char *filename, const void *blob);
|
||||
@ -119,7 +143,7 @@ int utilfdt_write(const char *filename, const void *blob);
|
||||
* an error message for the user.
|
||||
*
|
||||
* @param filename The filename to write, or - for stdout
|
||||
* @param blob Pointer to buffer containing fdt
|
||||
* @param blob Poiner to buffer containing fdt
|
||||
* @return 0 if ok, else an errno value representing the error
|
||||
*/
|
||||
int utilfdt_write_err(const char *filename, const void *blob);
|
||||
|
@ -1 +1 @@
|
||||
#define DTC_VERSION "DTC 1.5.0-g702c1b6c"
|
||||
#define DTC_VERSION "DTC 1.4.6-g84e414b0"
|
||||
|
@ -1,233 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* (C) Copyright Linaro, Ltd. 2018
|
||||
* (C) Copyright Arm Holdings. 2017
|
||||
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <yaml.h>
|
||||
#include "dtc.h"
|
||||
#include "srcpos.h"
|
||||
|
||||
char *yaml_error_name[] = {
|
||||
[YAML_NO_ERROR] = "no error",
|
||||
[YAML_MEMORY_ERROR] = "memory error",
|
||||
[YAML_READER_ERROR] = "reader error",
|
||||
[YAML_SCANNER_ERROR] = "scanner error",
|
||||
[YAML_PARSER_ERROR] = "parser error",
|
||||
[YAML_COMPOSER_ERROR] = "composer error",
|
||||
[YAML_WRITER_ERROR] = "writer error",
|
||||
[YAML_EMITTER_ERROR] = "emitter error",
|
||||
};
|
||||
|
||||
#define yaml_emitter_emit_or_die(emitter, event) ( \
|
||||
{ \
|
||||
if (!yaml_emitter_emit(emitter, event)) \
|
||||
die("yaml '%s': %s in %s, line %i\n", \
|
||||
yaml_error_name[(emitter)->error], \
|
||||
(emitter)->problem, __func__, __LINE__); \
|
||||
})
|
||||
|
||||
static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, char *data, int len, int width)
|
||||
{
|
||||
yaml_event_t event;
|
||||
void *tag;
|
||||
int off, start_offset = markers->offset;
|
||||
|
||||
switch(width) {
|
||||
case 1: tag = "!u8"; break;
|
||||
case 2: tag = "!u16"; break;
|
||||
case 4: tag = "!u32"; break;
|
||||
case 8: tag = "!u64"; break;
|
||||
default:
|
||||
die("Invalid width %i", width);
|
||||
}
|
||||
assert(len % width == 0);
|
||||
|
||||
yaml_sequence_start_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)tag, width == 4, YAML_FLOW_SEQUENCE_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
|
||||
for (off = 0; off < len; off += width) {
|
||||
char buf[32];
|
||||
struct marker *m;
|
||||
bool is_phandle = false;
|
||||
|
||||
switch(width) {
|
||||
case 1:
|
||||
sprintf(buf, "0x%"PRIx8, *(uint8_t*)(data + off));
|
||||
break;
|
||||
case 2:
|
||||
sprintf(buf, "0x%"PRIx16, fdt16_to_cpu(*(fdt16_t*)(data + off)));
|
||||
break;
|
||||
case 4:
|
||||
sprintf(buf, "0x%"PRIx32, fdt32_to_cpu(*(fdt32_t*)(data + off)));
|
||||
m = markers;
|
||||
is_phandle = false;
|
||||
for_each_marker_of_type(m, REF_PHANDLE) {
|
||||
if (m->offset == (start_offset + off)) {
|
||||
is_phandle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
sprintf(buf, "0x%"PRIx64, fdt64_to_cpu(*(fdt64_t*)(data + off)));
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_phandle)
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t*)"!phandle", (yaml_char_t *)buf,
|
||||
strlen(buf), 0, 0, YAML_PLAIN_SCALAR_STYLE);
|
||||
else
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t*)YAML_INT_TAG, (yaml_char_t *)buf,
|
||||
strlen(buf), 1, 1, YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
}
|
||||
|
||||
yaml_sequence_end_event_initialize(&event);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
}
|
||||
|
||||
static void yaml_propval_string(yaml_emitter_t *emitter, char *str, int len)
|
||||
{
|
||||
yaml_event_t event;
|
||||
int i;
|
||||
|
||||
assert(str[len-1] == '\0');
|
||||
|
||||
/* Make sure the entire string is in the lower 7-bit ascii range */
|
||||
for (i = 0; i < len; i++)
|
||||
assert(isascii(str[i]));
|
||||
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)str,
|
||||
len-1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
}
|
||||
|
||||
static void yaml_propval(yaml_emitter_t *emitter, struct property *prop)
|
||||
{
|
||||
yaml_event_t event;
|
||||
int len = prop->val.len;
|
||||
struct marker *m = prop->val.markers;
|
||||
|
||||
/* Emit the property name */
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)prop->name,
|
||||
strlen(prop->name), 1, 1, YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
|
||||
/* Boolean properties are easiest to deal with. Length is zero, so just emit 'true' */
|
||||
if (len == 0) {
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_BOOL_TAG,
|
||||
(yaml_char_t*)"true",
|
||||
strlen("true"), 1, 0, YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m)
|
||||
die("No markers present in property '%s' value\n", prop->name);
|
||||
|
||||
yaml_sequence_start_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_SEQ_TAG, 1, YAML_FLOW_SEQUENCE_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
|
||||
for_each_marker(m) {
|
||||
int chunk_len;
|
||||
char *data = &prop->val.val[m->offset];
|
||||
|
||||
if (m->type < TYPE_UINT8)
|
||||
continue;
|
||||
|
||||
chunk_len = type_marker_length(m) ? : len;
|
||||
assert(chunk_len > 0);
|
||||
len -= chunk_len;
|
||||
|
||||
switch(m->type) {
|
||||
case TYPE_UINT16:
|
||||
yaml_propval_int(emitter, m, data, chunk_len, 2);
|
||||
break;
|
||||
case TYPE_UINT32:
|
||||
yaml_propval_int(emitter, m, data, chunk_len, 4);
|
||||
break;
|
||||
case TYPE_UINT64:
|
||||
yaml_propval_int(emitter, m, data, chunk_len, 8);
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
yaml_propval_string(emitter, data, chunk_len);
|
||||
break;
|
||||
default:
|
||||
yaml_propval_int(emitter, m, data, chunk_len, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
yaml_sequence_end_event_initialize(&event);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
}
|
||||
|
||||
|
||||
static void yaml_tree(struct node *tree, yaml_emitter_t *emitter)
|
||||
{
|
||||
struct property *prop;
|
||||
struct node *child;
|
||||
yaml_event_t event;
|
||||
|
||||
if (tree->deleted)
|
||||
return;
|
||||
|
||||
yaml_mapping_start_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_MAP_TAG, 1, YAML_ANY_MAPPING_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
|
||||
for_each_property(tree, prop)
|
||||
yaml_propval(emitter, prop);
|
||||
|
||||
/* Loop over all the children, emitting them into the map */
|
||||
for_each_child(tree, child) {
|
||||
yaml_scalar_event_initialize(&event, NULL,
|
||||
(yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)child->name,
|
||||
strlen(child->name), 1, 0, YAML_PLAIN_SCALAR_STYLE);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
yaml_tree(child, emitter);
|
||||
}
|
||||
|
||||
yaml_mapping_end_event_initialize(&event);
|
||||
yaml_emitter_emit_or_die(emitter, &event);
|
||||
}
|
||||
|
||||
void dt_to_yaml(FILE *f, struct dt_info *dti)
|
||||
{
|
||||
yaml_emitter_t emitter;
|
||||
yaml_event_t event;
|
||||
|
||||
yaml_emitter_initialize(&emitter);
|
||||
yaml_emitter_set_output_file(&emitter, f);
|
||||
yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING);
|
||||
yaml_emitter_emit_or_die(&emitter, &event);
|
||||
|
||||
yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0);
|
||||
yaml_emitter_emit_or_die(&emitter, &event);
|
||||
|
||||
yaml_sequence_start_event_initialize(&event, NULL, (yaml_char_t *)YAML_SEQ_TAG, 1, YAML_ANY_SEQUENCE_STYLE);
|
||||
yaml_emitter_emit_or_die(&emitter, &event);
|
||||
|
||||
yaml_tree(dti->dt, &emitter);
|
||||
|
||||
yaml_sequence_end_event_initialize(&event);
|
||||
yaml_emitter_emit_or_die(&emitter, &event);
|
||||
|
||||
yaml_document_end_event_initialize(&event, 0);
|
||||
yaml_emitter_emit_or_die(&emitter, &event);
|
||||
|
||||
yaml_stream_end_event_initialize(&event);
|
||||
yaml_emitter_emit_or_die(&emitter, &event);
|
||||
|
||||
yaml_emitter_delete(&emitter);
|
||||
}
|
75
scripts/gcc-wrapper.py
Executable file
75
scripts/gcc-wrapper.py
Executable file
@ -0,0 +1,75 @@
|
||||
#! /usr/bin/env python2
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Copyright (c) 2011-2017, 2018 The Linux Foundation. All rights reserved.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Invoke gcc, looking for warnings, and causing a failure if there are
|
||||
# non-whitelisted warnings.
|
||||
|
||||
import errno
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
# Note that gcc uses unicode, which may depend on the locale. TODO:
|
||||
# force LANG to be set to en_US.UTF-8 to get consistent warnings.
|
||||
|
||||
allowed_warnings = set([
|
||||
"umid.c:138",
|
||||
"umid.c:213",
|
||||
"umid.c:388",
|
||||
])
|
||||
|
||||
# Capture the name of the object file, can find it.
|
||||
ofile = None
|
||||
|
||||
warning_re = re.compile(r'''(.*/|)([^/]+\.[a-z]+:\d+):(\d+:)? warning:''')
|
||||
def interpret_warning(line):
|
||||
"""Decode the message from gcc. The messages we care about have a filename, and a warning"""
|
||||
line = line.rstrip('\n')
|
||||
m = warning_re.match(line)
|
||||
if m and m.group(2) not in allowed_warnings:
|
||||
print "error, forbidden warning:", m.group(2)
|
||||
|
||||
# If there is a warning, remove any object if it exists.
|
||||
if ofile:
|
||||
try:
|
||||
os.remove(ofile)
|
||||
except OSError:
|
||||
pass
|
||||
sys.exit(1)
|
||||
|
||||
def run_gcc():
|
||||
args = sys.argv[1:]
|
||||
# Look for -o
|
||||
try:
|
||||
i = args.index('-o')
|
||||
global ofile
|
||||
ofile = args[i+1]
|
||||
except (ValueError, IndexError):
|
||||
pass
|
||||
|
||||
compiler = sys.argv[0]
|
||||
|
||||
try:
|
||||
proc = subprocess.Popen(args, stderr=subprocess.PIPE)
|
||||
for line in proc.stderr:
|
||||
print line,
|
||||
interpret_warning(line)
|
||||
|
||||
result = proc.wait()
|
||||
except OSError as e:
|
||||
result = e.errno
|
||||
if result == errno.ENOENT:
|
||||
print args[0] + ':',e.strerror
|
||||
print 'Is your PATH set correctly?'
|
||||
else:
|
||||
print ' '.join(args), str(e)
|
||||
|
||||
return result
|
||||
|
||||
if __name__ == '__main__':
|
||||
status = run_gcc()
|
||||
sys.exit(status)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user