From 0243b256d6187ea610174531607366945e489605 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 12 Feb 2008 14:35:39 +0000 Subject: Add stubdomain support. See stubdom/README for usage details. - Move PAGE_SIZE and STACK_SIZE into __PAGE_SIZE and __STACK_SIZE in arch_limits.h so as to permit getting them from there without pulling all the internal Mini-OS defines. - Setup a xen-elf cross-compilation environment in stubdom/cross-root - Add a POSIX layer on top of Mini-OS by linking against the newlib C library and lwIP, and implementing the Unixish part in mini-os/lib/sys.c - Cross-compile zlib and libpci too. - Add an xs.h-compatible layer on top of Mini-OS' xenbus. - Cross-compile libxc with an additional xc_minios.c and a few things disabled. - Cross-compile ioemu with an additional block-vbd, but without sound, tpm and other details. A few hacks are needed: - Align ide and scsi buffers at least on sector size to permit direct transmission to the block backend. While we are at it, just page-align it to possibly save a segment. Also, limit the scsi buffer size because of limitations of the block paravirtualization protocol. - Allocate big tables dynamically rather that letting them go to bss: when Mini-OS gets installed in memory, bss is not lazily allocated, and doing so during Mini-OS is unnecessarily trick while we can simply use malloc. - Had to change the Mini-OS compilation somehow, so as to export Mini-OS compilation flags to the Makefiles of libxc and ioemu. Signed-off-by: Samuel Thibault --- extras/mini-os/arch/ia64/Makefile | 4 +++- extras/mini-os/arch/ia64/minios-ia64.lds | 12 ++++++++++++ extras/mini-os/arch/ia64/mm.c | 8 ++++++++ extras/mini-os/arch/x86/Makefile | 3 ++- extras/mini-os/arch/x86/arch.mk | 8 ++++---- extras/mini-os/arch/x86/minios-x86_32.lds | 12 ++++++++++++ extras/mini-os/arch/x86/minios-x86_64.lds | 12 ++++++++++++ extras/mini-os/arch/x86/mm.c | 17 +++++++++++++++++ extras/mini-os/arch/x86/x86_32.S | 6 +++--- extras/mini-os/arch/x86/x86_64.S | 6 +++--- 10 files changed, 76 insertions(+), 12 deletions(-) (limited to 'extras/mini-os/arch') diff --git a/extras/mini-os/arch/ia64/Makefile b/extras/mini-os/arch/ia64/Makefile index fb5ca9fb72..6e46aa67ef 100644 --- a/extras/mini-os/arch/ia64/Makefile +++ b/extras/mini-os/arch/ia64/Makefile @@ -5,6 +5,8 @@ XEN_ROOT = ../../../.. include $(XEN_ROOT)/Config.mk +include ../../Config.mk + include arch.mk include ../../minios.mk @@ -41,7 +43,7 @@ ARCH_OBJS += __divdi3.o GEN_OFF_SRC := gen_off.c GEN_OFF_ASM := gen_off.s -GEN_OFF_H := $(ARCH_INC)/offsets.h +GEN_OFF_H := $(MINI-OS_ROOT)/include/$(ARCH_INC)/offsets.h all: $(ARCH_LIB) diff --git a/extras/mini-os/arch/ia64/minios-ia64.lds b/extras/mini-os/arch/ia64/minios-ia64.lds index 70435de11e..96911aa3fd 100644 --- a/extras/mini-os/arch/ia64/minios-ia64.lds +++ b/extras/mini-os/arch/ia64/minios-ia64.lds @@ -40,6 +40,18 @@ SECTIONS .rodata.str1.8 : AT(ADDR(.rodata.str1.8) - (((5<<(61))+0x100000000) - (1 << 20))) { *(.rodata.str1.8) } + /* newlib initialization functions */ + . = ALIGN(64 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { *(.preinit_array) } + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { *(.init_array) } + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { *(.fini_array) } + PROVIDE (__fini_array_end = .); + .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - (((5<<(61))+0x100000000) - (1 << 20))) { *(.IA_64.unwind_info) } diff --git a/extras/mini-os/arch/ia64/mm.c b/extras/mini-os/arch/ia64/mm.c index f557730257..f2291f918c 100644 --- a/extras/mini-os/arch/ia64/mm.c +++ b/extras/mini-os/arch/ia64/mm.c @@ -43,6 +43,14 @@ extern uint64_t _text[], _etext[], _end[], kstack[], phys_start[]; uint64_t kernstart, kernend, kernsize, kernpstart, kernpend; +#ifdef HAVE_LIBC +uint8_t _heap[512 * 1024]; +unsigned long heap = (unsigned long)_heap, + brk = (unsigned long)_heap, + heap_mapped = (unsigned long)_heap + sizeof(_heap), + heap_end = (unsigned long)_heap + sizeof(_heap); +#endif + /* Print the available memory chunks. */ static void print_phys_avail(void) diff --git a/extras/mini-os/arch/x86/Makefile b/extras/mini-os/arch/x86/Makefile index 22cfe82811..21f0958f6a 100644 --- a/extras/mini-os/arch/x86/Makefile +++ b/extras/mini-os/arch/x86/Makefile @@ -5,13 +5,14 @@ XEN_ROOT = ../../../.. include $(XEN_ROOT)/Config.mk +include ../../Config.mk # include arch.mk has to be before mini-os.mk! include arch.mk include ../../minios.mk -# Sources here are all *.c *.S without $(TARGET_ARCH).S +# Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S # This is handled in $(HEAD_ARCH_OBJ) ARCH_SRCS := $(wildcard *.c) diff --git a/extras/mini-os/arch/x86/arch.mk b/extras/mini-os/arch/x86/arch.mk index dd6bfe0b8d..1680362789 100644 --- a/extras/mini-os/arch/x86/arch.mk +++ b/extras/mini-os/arch/x86/arch.mk @@ -3,11 +3,11 @@ # (including x86_32, x86_32y and x86_64). # -ifeq ($(TARGET_ARCH),x86_32) +ifeq ($(XEN_TARGET_ARCH),x86_32) ARCH_CFLAGS := -m32 -march=i686 ARCH_LDFLAGS := -m elf_i386 ARCH_ASFLAGS := -m32 -EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH) +EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH) EXTRA_SRC += arch/$(EXTRA_INC) ifeq ($(XEN_TARGET_X86_PAE),y) @@ -16,12 +16,12 @@ ARCH_ASFLAGS += -DCONFIG_X86_PAE=1 endif endif -ifeq ($(TARGET_ARCH),x86_64) +ifeq ($(XEN_TARGET_ARCH),x86_64) ARCH_CFLAGS := -m64 -mno-red-zone -fno-reorder-blocks ARCH_CFLAGS += -fno-asynchronous-unwind-tables ARCH_ASFLAGS := -m64 ARCH_LDFLAGS := -m elf_x86_64 -EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH) +EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH) EXTRA_SRC += arch/$(EXTRA_INC) endif diff --git a/extras/mini-os/arch/x86/minios-x86_32.lds b/extras/mini-os/arch/x86/minios-x86_32.lds index 08ebe14328..df5301944f 100644 --- a/extras/mini-os/arch/x86/minios-x86_32.lds +++ b/extras/mini-os/arch/x86/minios-x86_32.lds @@ -16,6 +16,18 @@ SECTIONS . = ALIGN(4096); _erodata = .; + /* newlib initialization functions */ + . = ALIGN(32 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { *(.preinit_array) } + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { *(.init_array) } + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { *(.fini_array) } + PROVIDE (__fini_array_end = .); + .data : { /* Data */ *(.data) CONSTRUCTORS diff --git a/extras/mini-os/arch/x86/minios-x86_64.lds b/extras/mini-os/arch/x86/minios-x86_64.lds index 345c38640c..f93800236b 100644 --- a/extras/mini-os/arch/x86/minios-x86_64.lds +++ b/extras/mini-os/arch/x86/minios-x86_64.lds @@ -16,6 +16,18 @@ SECTIONS . = ALIGN(4096); _erodata = .; + /* newlib initialization functions */ + . = ALIGN(64 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { *(.preinit_array) } + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { *(.init_array) } + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { *(.fini_array) } + PROVIDE (__fini_array_end = .); + .data : { /* Data */ *(.data) CONSTRUCTORS diff --git a/extras/mini-os/arch/x86/mm.c b/extras/mini-os/arch/x86/mm.c index 082527d098..dd556e4741 100644 --- a/extras/mini-os/arch/x86/mm.c +++ b/extras/mini-os/arch/x86/mm.c @@ -448,6 +448,15 @@ static unsigned long demand_map_area_start; #define DEMAND_MAP_PAGES ((2ULL << 30) / PAGE_SIZE) #endif +#ifdef HAVE_LIBC +unsigned long heap, brk, heap_mapped, heap_end; +#ifdef __x86_64__ +#define HEAP_PAGES ((128ULL << 30) / PAGE_SIZE) +#else +#define HEAP_PAGES ((1ULL << 30) / PAGE_SIZE) +#endif +#endif + void arch_init_demand_mapping_area(unsigned long cur_pfn) { cur_pfn++; @@ -455,6 +464,14 @@ void arch_init_demand_mapping_area(unsigned long cur_pfn) demand_map_area_start = (unsigned long) pfn_to_virt(cur_pfn); cur_pfn += DEMAND_MAP_PAGES; printk("Demand map pfns at %lx-%lx.\n", demand_map_area_start, pfn_to_virt(cur_pfn)); + +#ifdef HAVE_LIBC + cur_pfn++; + heap_mapped = brk = heap = (unsigned long) pfn_to_virt(cur_pfn); + cur_pfn += HEAP_PAGES; + heap_end = (unsigned long) pfn_to_virt(cur_pfn); + printk("Heap resides at %lx-%lx.\n", brk, heap_end); +#endif } #define MAP_BATCH ((STACK_SIZE / 2) / sizeof(mmu_update_t)) diff --git a/extras/mini-os/arch/x86/x86_32.S b/extras/mini-os/arch/x86/x86_32.S index 4b9a337c08..7f01851f0c 100644 --- a/extras/mini-os/arch/x86/x86_32.S +++ b/extras/mini-os/arch/x86/x86_32.S @@ -1,5 +1,5 @@ #include -#include +#include #include .section __xen_guest @@ -22,12 +22,12 @@ _start: cld lss stack_start,%esp - andl $(~(STACK_SIZE-1)), %esp + andl $(~(__STACK_SIZE-1)), %esp push %esi call start_kernel stack_start: - .long stack+(2*STACK_SIZE), __KERNEL_SS + .long stack+(2*__STACK_SIZE), __KERNEL_SS /* Unpleasant -- the PTE that maps this page is actually overwritten */ /* to map the real shared-info page! :-) */ diff --git a/extras/mini-os/arch/x86/x86_64.S b/extras/mini-os/arch/x86/x86_64.S index fae2ae4cf5..c7a797db90 100644 --- a/extras/mini-os/arch/x86/x86_64.S +++ b/extras/mini-os/arch/x86/x86_64.S @@ -1,5 +1,5 @@ #include -#include +#include #include .section __xen_guest @@ -19,12 +19,12 @@ _start: cld movq stack_start(%rip),%rsp - andq $(~(STACK_SIZE-1)), %rsp + andq $(~(__STACK_SIZE-1)), %rsp movq %rsi,%rdi call start_kernel stack_start: - .quad stack+(2*STACK_SIZE) + .quad stack+(2*__STACK_SIZE) /* Unpleasant -- the PTE that maps this page is actually overwritten */ /* to map the real shared-info page! :-) */ -- cgit v1.2.3