On 12/05/2018 11:33 PM, Michael S. Tsirkin wrote:
On Wed, Dec 05, 2018 at 06:28:11PM +0800, Li Zhijian wrote:Hi Michael I cooked a draft with cp_portable to import bootparam.h, could you have a look. diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh index 0a964fe..1beeceb 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -44,6 +44,12 @@ cp_portable() { -e 'linux/kernel' \ -e 'linux/sysinfo' \ -e 'asm-generic/kvm_para' \ + -e 'linux/screen_info.h' \ + -e 'linux/apm_bios.h' \ + -e 'linux/edd.h' \ + -e 'video/edid.h' \ + -e 'asm/ist.h' \ + -e 'linux/ioctl.h' \ > /dev/null then echo "Unexpected #include in input file $f". @@ -59,6 +65,8 @@ cp_portable() { -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \ -e 's/"\(input-event-codes\.h\)"/"standard-headers\/linux\/\1"/' \ -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \ + -e "s/<asm\/\([^>]*\)>/\"standard-headers\/asm-$arch\/\1\"/" \ + -e 's/<video\/\([^>]*\)>/"standard-headers\/video\/\1"/' \ -e 's/__bitwise//' \ -e 's/__attribute__((packed))/QEMU_PACKED/' \ -e 's/__inline__/inline/' \ @@ -74,6 +82,23 @@ cp_portable() { "$f" > "$to/$header"; } +rm -rf "$output/include/standard-headers/linux" +mkdir -p "$output/include/standard-headers/linux" + +cp_bootparam() +{ + mkdir -p $output/include/standard-headers/video + cp "$tmpdir"/include/linux/ioctl.h "$output/include/standard-headers/linux" + cp_portable "$tmpdir"/include/linux/screen_info.h "$output/include/standard-headers/linux" + cp_portable "$tmpdir/include/linux/apm_bios.h" "$output/include/standard-headers/linux" + cp_portable "$tmpdir/include/linux/edd.h" "$output/include/standard-headers/linux" + cp_portable "$tmpdir/include/asm/ist.h" $output/include/standard-headers/asm-$arch + cp_portable "$tmpdir/include/video/edid.h" $output/include/standard-headers/video + + # bootparam.h includes above headers + cp_portable "$tmpdir/include/asm/bootparam.h" "$output/include/standard-headers/asm-$arch" +} + # This will pick up non-directories too (eg "Kconfig") but we will # ignore them in the next loop. ARCHLIST=$(cd "$linux/arch" && echo *) @@ -120,6 +145,7 @@ for arch in $ARCHLIST; do cp "$tmpdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/" cp "$tmpdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/" cp_portable "$tmpdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch" + cp_bootparam fi done @@ -163,8 +189,6 @@ cat <<EOF >$output/linux-headers/linux/virtio_ring.h #include "standard-headers/linux/virtio_ring.h" EOF -rm -rf "$output/include/standard-headers/linux" -mkdir -p "$output/include/standard-headers/linux" for i in "$tmpdir"/include/linux/*virtio*.h \ "$tmpdir/include/linux/qemu_fw_cfg.h" \ "$tmpdir/include/linux/input.h" \ Thanks ZhijianSo arch specific asm including asm doesn't work well right now :( You can either fix the path to ist to pull it from asm-x86,
+ -e "s/<asm\/\([^>]*\)>/\"standard-headers\/asm-$arch\/\1\"/" \ + -e 's/<video\/\([^>]*\)>/"standard-headers\/video\/\1"/' \
Actually above changes fix the path with asm as well. But I'd like below solution which is simpler and clearer
or if you don't actually need anything in that header the macros, you can just cut out everything around __ASSEMBLY__ with a bit of e.g. sed magic. E.g. pvrdma does this. Something like: # Remove everything except the macros from bootparam.h avoiding the unnecessary # import of several video/ist/etc headers sed -e '/__ASSEMBLY__/,/__ASSEMBLY__/d' arch/x86/include/uapi/asm/bootparam.h should do the job.
Thanks Zhijian
