On 07.08.20 05:06, peng....@nxp.com wrote:
> From: Peng Fan <peng....@nxp.com>
> 
> Add libbaremetal for sharing code between inmates and jailhouse
> baremetal loader.
> 
> The Makefile code is copied from inmates, currently only string.c
> is moved from inmates to libbaremetal. In future, we might
> need to share uart/mmu and etc.

Might quickly become confusing to have two libs. What prevents renaming
inmates/lib completely into libbaremetal? Sure, there are some jailhouse
specifics in inmates/lib, but those could likely be put in some corner.

Jan

> 
> Signed-off-by: Peng Fan <peng....@nxp.com>
> ---
>  Kbuild                                 |  4 +-
>  inmates/Makefile                       |  4 ++
>  inmates/lib/arm-common/Makefile.lib    |  2 +-
>  inmates/lib/arm/Makefile.lib           |  2 +-
>  inmates/lib/arm64/Makefile.lib         |  2 +-
>  inmates/lib/x86/Makefile               |  2 +-
>  inmates/lib/x86/Makefile.lib           |  3 +-
>  libbaremetal/Makefile                  | 46 +++++++++++++++++++++++
>  libbaremetal/arm-common/Makefile.lib   | 41 ++++++++++++++++++++
>  libbaremetal/arm/Makefile              | 44 ++++++++++++++++++++++
>  libbaremetal/arm/Makefile.lib          | 63 +++++++++++++++++++++++++++++++
>  libbaremetal/arm64/Makefile            | 44 ++++++++++++++++++++++
>  libbaremetal/arm64/Makefile.lib        | 63 +++++++++++++++++++++++++++++++
>  {inmates/lib => libbaremetal}/string.c |  0
>  libbaremetal/x86/Makefile              | 66 ++++++++++++++++++++++++++++++++
>  libbaremetal/x86/Makefile.lib          | 69 
> ++++++++++++++++++++++++++++++++++
>  16 files changed, 449 insertions(+), 6 deletions(-)
>  create mode 100644 libbaremetal/Makefile
>  create mode 100644 libbaremetal/arm-common/Makefile.lib
>  create mode 100644 libbaremetal/arm/Makefile
>  create mode 100644 libbaremetal/arm/Makefile.lib
>  create mode 100644 libbaremetal/arm64/Makefile
>  create mode 100644 libbaremetal/arm64/Makefile.lib
>  rename {inmates/lib => libbaremetal}/string.c (100%)
>  create mode 100644 libbaremetal/x86/Makefile
>  create mode 100644 libbaremetal/x86/Makefile.lib
> 
> diff --git a/Kbuild b/Kbuild
> index 0b25e26e..dc6423ad 100644
> --- a/Kbuild
> +++ b/Kbuild
> @@ -51,7 +51,7 @@ GEN_PCI_DEFS_PY := $(obj)/pyjailhouse/pci_defs.py
>  $(GEN_PCI_DEFS_PY): $(src)/scripts/gen_pci_defs.sh
>       $(call if_changed,gen_pci_defs)
>  
> -subdir-y := hypervisor configs inmates tools
> +subdir-y := hypervisor configs inmates tools libbaremetal
>  
>  subdir-ccflags-y := -Werror
>  
> @@ -62,6 +62,8 @@ ifeq ($(filter %/Makefile.clean,$(MAKEFILE_LIST)),)
>  
>  $(obj)/driver $(addprefix $(obj)/,$(subdir-y)): $(GEN_CONFIG_MK)
>  
> +$(addprefix $(obj)/,inmates): $(addprefix $(obj)/,libbaremetal)
> +
>  $(obj)/driver $(obj)/hypervisor: $(GEN_VERSION_H)
>  
>  $(obj)/tools: $(GEN_PCI_DEFS_PY)
> diff --git a/inmates/Makefile b/inmates/Makefile
> index 095055c8..44354c87 100644
> --- a/inmates/Makefile
> +++ b/inmates/Makefile
> @@ -15,7 +15,11 @@
>  INMATES_LIB = $(src)/lib/$(SRCARCH)
>  export INMATES_LIB
>  
> +BAREMETAL_LIB = $(src)/../libbaremetal/$(SRCARCH)
> +export BAREMETAL_LIB
> +
>  INCLUDES := -I$(INMATES_LIB) \
> +         -I$(BAREMETAL_LIB)/include \
>           -I$(src)/../include/arch/$(SRCARCH) \
>           -I$(src)/lib/include \
>           -I$(src)/../include \
> diff --git a/inmates/lib/arm-common/Makefile.lib 
> b/inmates/lib/arm-common/Makefile.lib
> index 3d7b335d..d99102a9 100644
> --- a/inmates/lib/arm-common/Makefile.lib
> +++ b/inmates/lib/arm-common/Makefile.lib
> @@ -36,7 +36,7 @@
>  # THE POSSIBILITY OF SUCH DAMAGE.
>  #
>  
> -objs-y := ../string.o ../cmdline.o ../setup.o ../alloc.o ../uart-8250.o
> +objs-y := ../cmdline.o ../setup.o ../alloc.o ../uart-8250.o
>  objs-y += ../printk.o ../pci.o
>  objs-y += printk.o gic.o mem.o pci.o timing.o setup.o uart.o
>  objs-y += uart-xuartps.o uart-mvebu.o uart-hscif.o uart-scifa.o uart-imx.o
> diff --git a/inmates/lib/arm/Makefile.lib b/inmates/lib/arm/Makefile.lib
> index 0976f894..4b4165bb 100644
> --- a/inmates/lib/arm/Makefile.lib
> +++ b/inmates/lib/arm/Makefile.lib
> @@ -56,7 +56,7 @@ endef
>  
>  .SECONDEXPANSION:
>  $(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix 
> $$(obj)/,$$($$*-y)) \
> -                $(INMATES_LIB)/lib.a
> +                $(INMATES_LIB)/lib.a $(BAREMETAL_LIB)/lib.a
>       $(call if_changed,ld)
>  
>  $(obj)/%.bin: $(obj)/%-linked.o
> diff --git a/inmates/lib/arm64/Makefile.lib b/inmates/lib/arm64/Makefile.lib
> index 0976f894..6d5df339 100644
> --- a/inmates/lib/arm64/Makefile.lib
> +++ b/inmates/lib/arm64/Makefile.lib
> @@ -56,7 +56,7 @@ endef
>  
>  .SECONDEXPANSION:
>  $(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix 
> $$(obj)/,$$($$*-y)) \
> -                $(INMATES_LIB)/lib.a
> +                   $(INMATES_LIB)/lib.a $(BAREMETAL_LIB)/lib.a
>       $(call if_changed,ld)
>  
>  $(obj)/%.bin: $(obj)/%-linked.o
> diff --git a/inmates/lib/x86/Makefile b/inmates/lib/x86/Makefile
> index 40d3eba2..74e38b5a 100644
> --- a/inmates/lib/x86/Makefile
> +++ b/inmates/lib/x86/Makefile
> @@ -42,7 +42,7 @@ always := lib.a lib32.a
>  
>  TARGETS := cpu-features.o excp.o header-common.o irq.o ioapic.o printk.o
>  TARGETS += setup.o uart.o
> -TARGETS += ../alloc.o ../pci.o ../string.o ../cmdline.o ../setup.o ../test.o
> +TARGETS += ../alloc.o ../pci.o ../cmdline.o ../setup.o ../test.o
>  TARGETS += ../uart-8250.o ../printk.o
>  TARGETS_32_ONLY := header-32.o
>  TARGETS_64_ONLY := mem.o pci.o smp.o timing.o header-64.o
> diff --git a/inmates/lib/x86/Makefile.lib b/inmates/lib/x86/Makefile.lib
> index 6190315b..754dc426 100644
> --- a/inmates/lib/x86/Makefile.lib
> +++ b/inmates/lib/x86/Makefile.lib
> @@ -55,7 +55,8 @@ endef
>  # obj/NAME-linked.o: ... obj/$(NAME-y) lib/lib[32].a
>  .SECONDEXPANSION:
>  $(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix 
> $$(obj)/,$$($$*-y)) \
> -                $(INMATES_LIB)/$$(if $$($$*_32),lib32.a,lib.a)
> +                $(INMATES_LIB)/$$(if $$($$*_32),lib32.a,lib.a) \
> +                $(BAREMETAL_LIB)/$$(if $$($$*_32),lib32.a,lib.a)
>       $(call if_changed,ld)
>  
>  $(obj)/%.bin: $(obj)/%-linked.o
> diff --git a/libbaremetal/Makefile b/libbaremetal/Makefile
> new file mode 100644
> index 00000000..f36a2d09
> --- /dev/null
> +++ b/libbaremetal/Makefile
> @@ -0,0 +1,46 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) Siemens AG, 2013
> +#
> +# Authors:
> +#  Jan Kiszka <jan.kis...@siemens.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +
> +-include $(GEN_CONFIG_MK)
> +
> +BAREMETAL_LIB := $(src)/$(SRCARCH)
> +export BAREMETAL_LIB
> +
> +INCLUDES := -I$(BAREMETAL_LIB) \
> +         -I$(src)/../include/arch/$(SRCARCH) \
> +         -I$(src)/include \
> +         -I$(src)/../include
> +
> +ifeq ($(subst arm64,arm,$(SRCARCH)),arm)
> +INCLUDES += -I$(src)/../hypervisor/arch/arm-common/include
> +INCLUDES += -I$(src)/arm-common/include
> +endif
> +
> +LINUXINCLUDE  := $(INCLUDES)
> +KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
> +KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
> +              -Wmissing-declarations -Wmissing-prototypes \
> +              -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
> +              -fno-common -fno-stack-protector -ffreestanding \
> +              -ffunction-sections \
> +              -D__LINUX_COMPILER_TYPES_H
> +ifneq ($(wildcard $(INC_CONFIG_H)),)
> +KBUILD_CFLAGS += -include $(INC_CONFIG_H)
> +endif
> +
> +OBJCOPYFLAGS := -O binary
> +# prior to 4.19
> +LDFLAGS += --gc-sections -T
> +# since 4.19
> +KBUILD_LDFLAGS += --gc-sections -T
> +
> +subdir-y := $(SRCARCH)
> diff --git a/libbaremetal/arm-common/Makefile.lib 
> b/libbaremetal/arm-common/Makefile.lib
> new file mode 100644
> index 00000000..7b650a44
> --- /dev/null
> +++ b/libbaremetal/arm-common/Makefile.lib
> @@ -0,0 +1,41 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) OTH Regensburg, 2016
> +#
> +# Authors:
> +#  Ralf Ramsauer <ralf.ramsa...@oth-regensburg.de>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +# Alternatively, you can use or redistribute this file under the following
> +# BSD license:
> +#
> +# 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 HOLDER 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.
> +#
> +
> +objs-y := ../string.o
> +
> +common-objs-y = $(addprefix ../arm-common/,$(objs-y))
> diff --git a/libbaremetal/arm/Makefile b/libbaremetal/arm/Makefile
> new file mode 100644
> index 00000000..952b1475
> --- /dev/null
> +++ b/libbaremetal/arm/Makefile
> @@ -0,0 +1,44 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) Siemens AG, 2015, 2016
> +#
> +# Authors:
> +#  Jan Kiszka <jan.kis...@siemens.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +# Alternatively, you can use or redistribute this file under the following
> +# BSD license:
> +#
> +# 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 HOLDER 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 $(INMATES_LIB)/Makefile.lib
> +include $(INMATES_LIB)/../arm-common/Makefile.lib
> +
> +always := lib.a
> +
> +lib-y := $(common-objs-y)
> diff --git a/libbaremetal/arm/Makefile.lib b/libbaremetal/arm/Makefile.lib
> new file mode 100644
> index 00000000..0976f894
> --- /dev/null
> +++ b/libbaremetal/arm/Makefile.lib
> @@ -0,0 +1,63 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) ARM Limited, 2014
> +# Copyright (c) Siemens AG, 2014
> +#
> +# Authors:
> +#  Jean-Philippe Brucker <jean-philippe.bruc...@arm.com>
> +#  Jan Kiszka <jan.kis...@siemens.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +# Alternatively, you can use or redistribute this file under the following
> +# BSD license:
> +#
> +# 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 HOLDER 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 $(GEN_CONFIG_MK)
> +
> +LINUXINCLUDE += -I$(INMATES_LIB)/include
> +LINUXINCLUDE += -I$(INMATES_LIB)/../arm-common/include
> +
> +define DECLARE_TARGETS =
> + _TARGETS = $(1)
> + always := $$(_TARGETS)
> + # $(NAME-y) NAME-linked.o NAME.bin
> + targets += $$(foreach t,$$(_TARGETS:.bin=-y),$$($$t)) \
> +            $$(_TARGETS:.bin=-linked.o) $$(_TARGETS)
> +endef
> +
> +# prevent deleting intermediate files which would cause rebuilds
> +.SECONDARY: $(addprefix $(obj)/,$(targets))
> +
> +.SECONDEXPANSION:
> +$(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix 
> $$(obj)/,$$($$*-y)) \
> +                $(INMATES_LIB)/lib.a
> +     $(call if_changed,ld)
> +
> +$(obj)/%.bin: $(obj)/%-linked.o
> +     $(call if_changed,objcopy)
> diff --git a/libbaremetal/arm64/Makefile b/libbaremetal/arm64/Makefile
> new file mode 100644
> index 00000000..6d3cf399
> --- /dev/null
> +++ b/libbaremetal/arm64/Makefile
> @@ -0,0 +1,44 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) Siemens AG, 2015
> +#
> +# Authors:
> +#  Jan Kiszka <jan.kis...@siemens.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +# Alternatively, you can use or redistribute this file under the following
> +# BSD license:
> +#
> +# 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 HOLDER 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 $(BAREMETAL_LIB)/Makefile.lib
> +include $(BAREMETAL_LIB)/../arm-common/Makefile.lib
> +
> +always := lib.a
> +
> +lib-y := $(common-objs-y)
> diff --git a/libbaremetal/arm64/Makefile.lib b/libbaremetal/arm64/Makefile.lib
> new file mode 100644
> index 00000000..c4560721
> --- /dev/null
> +++ b/libbaremetal/arm64/Makefile.lib
> @@ -0,0 +1,63 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) ARM Limited, 2014
> +# Copyright (c) Siemens AG, 2014
> +#
> +# Authors:
> +#  Jean-Philippe Brucker <jean-philippe.bruc...@arm.com>
> +#  Jan Kiszka <jan.kis...@siemens.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +# Alternatively, you can use or redistribute this file under the following
> +# BSD license:
> +#
> +# 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 HOLDER 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 $(GEN_CONFIG_MK)
> +
> +LINUXINCLUDE += -I$(INMATES_LIB)/include
> +LINUXINCLUDE += -I$(INMATES_LIB)/../arm-common/include
> +
> +define DECLARE_TARGETS =
> + _TARGETS = $(1)
> + always := $$(_TARGETS)
> + # $(NAME-y) NAME-linked.o NAME.bin
> + targets += $$(foreach t,$$(_TARGETS:.bin=-y),$$($$t)) \
> +            $$(_TARGETS:.bin=-linked.o) $$(_TARGETS)
> +endef
> +
> +# prevent deleting intermediate files which would cause rebuilds
> +.SECONDARY: $(addprefix $(obj)/,$(targets))
> +
> +.SECONDEXPANSION:
> +$(obj)/%-linked.o: $$(addprefix $$(obj)/,$$($$*-y)) \
> +                $(INMATES_LIB)/lib.a
> +     $(call if_changed,ld)
> +
> +$(obj)/%.bin: $(obj)/%-linked.o
> +     $(call if_changed,objcopy)
> diff --git a/inmates/lib/string.c b/libbaremetal/string.c
> similarity index 100%
> rename from inmates/lib/string.c
> rename to libbaremetal/string.c
> diff --git a/libbaremetal/x86/Makefile b/libbaremetal/x86/Makefile
> new file mode 100644
> index 00000000..e4e72b5b
> --- /dev/null
> +++ b/libbaremetal/x86/Makefile
> @@ -0,0 +1,66 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) Siemens AG, 2015, 2016
> +#
> +# Authors:
> +#  Jan Kiszka <jan.kis...@siemens.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +# Alternatively, you can use or redistribute this file under the following
> +# BSD license:
> +#
> +# 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 HOLDER 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 $(INMATES_LIB)/Makefile.lib
> +
> +always := lib.a lib32.a
> +
> +TARGETS := += ../string.o
> +
> +lib-y := $(TARGETS) $(TARGETS_64_ONLY)
> +lib32-y := $(TARGETS:.o=-32.o) $(TARGETS_32_ONLY)
> +
> +quiet_cmd_link_archive32 = AR      $@
> +cmd_link_archive32 = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $^
> +
> +$(obj)/lib32.a: $(addprefix $(obj)/,$(lib32-y))
> +     $(call if_changed,link_archive32)
> +
> +targets += $(lib32-y)
> +
> +# Code of this object is called before SSE/AVX extensions are available. 
> Ensure
> +# that the compiler won't generate unsupported instructions for this file.
> +CFLAGS_cpu-features.o += -mno-sse
> +
> +$(obj)/%-32.o: c_flags += -m32
> +$(obj)/%-32.o: $(src)/%.c FORCE
> +     $(call if_changed_rule,cc_o_c)
> +
> +$(obj)/%-32.o: a_flags += -m32
> +$(obj)/%-32.o: $(src)/%.S FORCE
> +     $(call if_changed_rule,as_o_S)
> diff --git a/libbaremetal/x86/Makefile.lib b/libbaremetal/x86/Makefile.lib
> new file mode 100644
> index 00000000..6190315b
> --- /dev/null
> +++ b/libbaremetal/x86/Makefile.lib
> @@ -0,0 +1,69 @@
> +#
> +# Jailhouse, a Linux-based partitioning hypervisor
> +#
> +# Copyright (c) Siemens AG, 2013, 2014
> +#
> +# Authors:
> +#  Jan Kiszka <jan.kis...@siemens.com>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.  See
> +# the COPYING file in the top-level directory.
> +#
> +# Alternatively, you can use or redistribute this file under the following
> +# BSD license:
> +#
> +# 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 HOLDER 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 $(GEN_CONFIG_MK)
> +
> +KBUILD_CFLAGS += -m64 -mno-red-zone
> +LINUXINCLUDE += -I$(INMATES_LIB)/include
> +
> +define DECLARE_TARGETS =
> + _TARGETS = $(1)
> + always := $$(_TARGETS)
> + # $(NAME-y) NAME-linked.o NAME.bin
> + targets += $$(foreach t,$$(_TARGETS:.bin=-y),$$($$t)) \
> +            $$(_TARGETS:.bin=-linked.o) $$(_TARGETS)
> +endef
> +
> +# prevent deleting intermediate files which would cause rebuilds
> +.SECONDARY: $(addprefix $(obj)/,$(targets))
> +
> +# obj/NAME-linked.o: ... obj/$(NAME-y) lib/lib[32].a
> +.SECONDEXPANSION:
> +$(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix 
> $$(obj)/,$$($$*-y)) \
> +                $(INMATES_LIB)/$$(if $$($$*_32),lib32.a,lib.a)
> +     $(call if_changed,ld)
> +
> +$(obj)/%.bin: $(obj)/%-linked.o
> +     $(call if_changed,objcopy)
> +
> +# 32-bit (i386) support
> +define DECLARE_32_BIT =
> + CFLAGS_$(1).o := -m32 -msse
> + LDFLAGS_$(1)-linked.o := /dev/null -m elf_i386 -T
> + $(1)_32 := y
> +endef
> 

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/4bfbd74f-843e-c3b9-47c7-31100d085052%40siemens.com.

Reply via email to