try another approach for uapi headers
Subsystems (3)
cover try another approach for uapi headers
Rather than import uapi headers, just include them. I've put an RFC on this series because it will now require kernel headers to be installed on the build machine. I'm guessing that's not a big problem, but before we commit to it, it'd be good to hear opinions from others.
This change wouldn't be worth it just for psci.h, but we're looking at PCI support now, and thus we'll also want pci.h (and pci_regs.h). Although after pci.h I'm not sure what else we'll eventually want. If nothing, then maybe importing pci.h is also the right thing to do?
Thanks,
drew
Andrew Jones (2):
lib: link in linux kernel headers (uapi) Revert "arm/arm64: import include/uapi/linux/psci.h"
.gitignore | 1 + Makefile | 4 +-- configure | 9 ++++++ lib/arm/asm/page.h | 2 +- lib/arm/asm/psci.h | 2 +- lib/arm/asm/uapi-psci.h | 73 ----------------------------------------------- lib/arm64/asm/page.h | 2 +- lib/arm64/asm/psci.h | 2 +- lib/arm64/asm/uapi-psci.h | 1 - lib/asm-generic/page.h | 2 +- lib/const.h | 11 ------- 11 files changed, 17 insertions(+), 92 deletions(-) delete mode 100644 lib/arm/asm/uapi-psci.h delete mode 100644 lib/arm64/asm/uapi-psci.h delete mode 100644 lib/const.h
Signature · 1 line
2.4.3
RFC PATCH 1/2 lib: link in linux kernel headers (uapi)
Rather than import uapi headers, e.g. lib/arm/asm/uapi-psci.h, just include them. For cross compilation we'll need the headers explicitly added to the include path, but doing -I /usr/include won't work, as some of our local header names will collide with /usr/include names. Even just doing -I /usr/include/linux would leave too many potential name collisions. So we create a lib/linux link, and do *not* add -I lib/linux. Doing it this way requires code to include the uapi headers with <linux/header.h>, putting them in their own "linux" namespace.
--- .gitignore | 1 + Makefile | 4 ++-- configure | 9 +++++++++ lib/arm/asm/page.h | 2 +- lib/arm/asm/psci.h | 2 +- lib/arm64/asm/page.h | 2 +- lib/arm64/asm/psci.h | 2 +- lib/asm-generic/page.h | 2 +- lib/const.h | 11 ----------- 9 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 lib/const.h
.gitignore +1 -0
@@ -10,6 +10,7 @@ patches cscope.* *.swp /lib/asm +/lib/linux /config.mak /*-run /test.log
Makefile +2 -2
@@ -80,10 +80,10 @@ libfdt_clean: $(LIBFDT_objdir)/.*.d distclean: clean libfdt_clean - $(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.* + $(RM) lib/linux lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.* $(RM) -r tests -cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic +cscope: common_dirs = lib lib/libfdt lib/linux lib/asm lib/asm-generic cscope: $(RM) ./cscope.* find -L $(TEST_DIR) lib/$(TEST_DIR) lib/$(ARCH) $(common_dirs) -maxdepth 1 \
configure +9 -0
@@ -90,6 +90,15 @@ if [ -f $testdir/run ]; then ln -fs $testdir/run $testdir-run fi +# link uapi/linux +rm -f lib/linux +if [ ! -d /usr/include/linux ]; then + echo kernel-headers not installed, aborting... + exit 1 +else + ln -s /usr/include/linux lib/linux +fi + # check for dependent 32 bit libraries if [ "$arch" != "arm" ]; then cat << EOF > lib_test.c
lib/arm/asm/page.h +1 -1
@@ -6,7 +6,7 @@* This work is licensed under the terms of the GNU LGPL, version 2. */ -#include <const.h> +#include <linux/const.h> #define PAGE_SHIFT 12#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
lib/arm/asm/psci.h +1 -1
@@ -1,7 +1,7 @@#ifndef _ASMARM_PSCI_H_#define _ASMARM_PSCI_H_#include <libcflat.h> -#include <asm/uapi-psci.h> +#include <linux/psci.h> #define PSCI_INVOKE_ARG_TYPE u32#define PSCI_FN_CPU_ON PSCI_0_2_FN_CPU_ON
lib/arm64/asm/page.h +1 -1
@@ -11,7 +11,7 @@* This work is licensed under the terms of the GNU LGPL, version 2. */ -#include <const.h> +#include <linux/const.h> #define PGTABLE_LEVELS 2#define VA_BITS 42
lib/arm64/asm/psci.h +1 -1
@@ -1,7 +1,7 @@#ifndef _ASMARM64_PSCI_H_#define _ASMARM64_PSCI_H_#include <libcflat.h> -#include <asm/uapi-psci.h> +#include <linux/psci.h> #define PSCI_INVOKE_ARG_TYPE u64#define PSCI_FN_CPU_ON PSCI_0_2_FN64_CPU_ON
lib/asm-generic/page.h +1 -1
@@ -9,7 +9,7 @@* This work is licensed under the terms of the GNU LGPL, version 2. */ -#include "const.h" +#include <linux/const.h> #define PAGE_SHIFT 12#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
lib/const.h deleted +0 -11
@@ -1,11 +0,0 @@ -#ifndef _CONST_H_ -#define _CONST_H_ -#ifdef __ASSEMBLY__ -#define _AC (X ,Y ) X -#define _AT (T ,X ) X -#else -#define __AC (X ,Y ) (X##Y) -#define _AC (X ,Y ) __AC(X,Y) -#define _AT (T ,X ) ((T)(X)) -#endif -#endif
Signature · 1 line
2.4.3
RFC PATCH 2/2 Revert "arm/arm64: import include/uapi/linux/psci.h"
In reply to Andrew JonesThe previous patch allows us to "unimport" this header now.
This reverts commit 7bc9f5e757bfa5c5a5202816404444fcf47a14b3.
--- lib/arm/asm/uapi-psci.h | 73 ----------------------------------------------- lib/arm64/asm/uapi-psci.h | 1 - 2 files changed, 74 deletions(-) delete mode 100644 lib/arm/asm/uapi-psci.h delete mode 100644 lib/arm64/asm/uapi-psci.h
lib/arm/asm/uapi-psci.h deleted +0 -73
@@ -1,73 +0,0 @@ -#ifndef _ASMARM_UAPI_PSCI_H_ -#define _ASMARM_UAPI_PSCI_H_ -/* -* From include/uapi/linux/psci.h -*/ - -/* PSCI v0.2 interface */ -#define PSCI_0_2_FN_BASE 0x84000000 -#define PSCI_0_2_FN (n) (PSCI_0_2_FN_BASE + (n)) -#define PSCI_0_2_64BIT 0x40000000 -#define PSCI_0_2_FN64_BASE \ - (PSCI_0_2_FN_BASE + PSCI_0_2_64BIT) -#define PSCI_0_2_FN64 (n) (PSCI_0_2_FN64_BASE + (n)) - -#define PSCI_0_2_FN_PSCI_VERSION PSCI_0_2_FN(0) -#define PSCI_0_2_FN_CPU_SUSPEND PSCI_0_2_FN(1) -#define PSCI_0_2_FN_CPU_OFF PSCI_0_2_FN(2) -#define PSCI_0_2_FN_CPU_ON PSCI_0_2_FN(3) -#define PSCI_0_2_FN_AFFINITY_INFO PSCI_0_2_FN(4) -#define PSCI_0_2_FN_MIGRATE PSCI_0_2_FN(5) -#define PSCI_0_2_FN_MIGRATE_INFO_TYPE PSCI_0_2_FN(6) -#define PSCI_0_2_FN_MIGRATE_INFO_UP_CPU PSCI_0_2_FN(7) -#define PSCI_0_2_FN_SYSTEM_OFF PSCI_0_2_FN(8) -#define PSCI_0_2_FN_SYSTEM_RESET PSCI_0_2_FN(9) - -#define PSCI_0_2_FN64_CPU_SUSPEND PSCI_0_2_FN64(1) -#define PSCI_0_2_FN64_CPU_ON PSCI_0_2_FN64(3) -#define PSCI_0_2_FN64_AFFINITY_INFO PSCI_0_2_FN64(4) -#define PSCI_0_2_FN64_MIGRATE PSCI_0_2_FN64(5) -#define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7) - -/* PSCI v0.2 power state encoding for CPU_SUSPEND function */ -#define PSCI_0_2_POWER_STATE_ID_MASK 0xffff -#define PSCI_0_2_POWER_STATE_ID_SHIFT 0 -#define PSCI_0_2_POWER_STATE_TYPE_SHIFT 16 -#define PSCI_0_2_POWER_STATE_TYPE_MASK \ - (0x1 << PSCI_0_2_POWER_STATE_TYPE_SHIFT) -#define PSCI_0_2_POWER_STATE_AFFL_SHIFT 24 -#define PSCI_0_2_POWER_STATE_AFFL_MASK \ - (0x3 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) - -/* PSCI v0.2 affinity level state returned by AFFINITY_INFO */ -#define PSCI_0_2_AFFINITY_LEVEL_ON 0 -#define PSCI_0_2_AFFINITY_LEVEL_OFF 1 -#define PSCI_0_2_AFFINITY_LEVEL_ON_PENDING 2 - -/* PSCI v0.2 multicore support in Trusted OS returned by MIGRATE_INFO_TYPE */ -#define PSCI_0_2_TOS_UP_MIGRATE 0 -#define PSCI_0_2_TOS_UP_NO_MIGRATE 1 -#define PSCI_0_2_TOS_MP 2 - -/* PSCI version decoding (independent of PSCI version) */ -#define PSCI_VERSION_MAJOR_SHIFT 16 -#define PSCI_VERSION_MINOR_MASK \ - ((1U << PSCI_VERSION_MAJOR_SHIFT) - 1) -#define PSCI_VERSION_MAJOR_MASK ~PSCI_VERSION_MINOR_MASK -#define PSCI_VERSION_MAJOR (ver) \ - (((ver) & PSCI_VERSION_MAJOR_MASK) >> PSCI_VERSION_MAJOR_SHIFT) -#define PSCI_VERSION_MINOR (ver) \ - ((ver) & PSCI_VERSION_MINOR_MASK) - -/* PSCI return values (inclusive of all PSCI versions) */ -#define PSCI_RET_SUCCESS 0 -#define PSCI_RET_NOT_SUPPORTED -1 -#define PSCI_RET_INVALID_PARAMS -2 -#define PSCI_RET_DENIED -3 -#define PSCI_RET_ALREADY_ON -4 -#define PSCI_RET_ON_PENDING -5 -#define PSCI_RET_INTERNAL_FAILURE -6 -#define PSCI_RET_NOT_PRESENT -7 -#define PSCI_RET_DISABLED -8 - -#endif /* _ASMARM_UAPI_PSCI_H_ */
lib/arm64/asm/uapi-psci.h deleted +0 -1
@@ -1 +0,0 @@ -#include "../../arm/asm/uapi-psci.h"
Signature · 1 line
2.4.3
Paolo Bonzini
maintainerQuoted 9 lines · Andrew Jones
Rather than import uapi headers, just include them. I've put an RFC on this series because it will now require kernel headers to be installed on the build machine. I'm guessing that's not a big problem, but before we commit to it, it'd be good to hear opinions from others.
This change wouldn't be worth it just for
psci.h, but we're looking at PCI support now, and thus we'll also wantpci.h(andpci_regs.h). Although afterpci.hI'm not sure what else we'll eventually want. If nothing, then maybe importingpci.his also the right thing to do?
Sounds good, and it's a tiny bit easier to go include->import than import->include.
Paolo