From f3ae74891e6a7c762e097b21845aba2c0340a082 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Thu, 10 Aug 2006 10:43:20 +0100 Subject: [PATCH] [MINIOS] A first step to re-architecture mini-os for a port to ia64. Create architecture specific directories below mini-os for sources and below mini-os/include for headers. Signed-off-by: Dietmar Hahn --- Makefile | 53 ++++++++++++++++++++- traps.c => arch/x86/traps.c | 0 include/hypervisor.h | 3 ++ include/types.h | 4 +- include/{ => x86}/os.h | 0 include/{ => x86}/spinlock.h | 0 include/{ => x86}/traps.h | 0 include/{ => x86/x86_32}/hypercall-x86_32.h | 0 include/{ => x86/x86_64}/hypercall-x86_64.h | 0 9 files changed, 56 insertions(+), 4 deletions(-) rename traps.c => arch/x86/traps.c (100%) rename include/{ => x86}/os.h (100%) rename include/{ => x86}/spinlock.h (100%) rename include/{ => x86}/traps.h (100%) rename include/{ => x86/x86_32}/hypercall-x86_32.h (100%) rename include/{ => x86/x86_64}/hypercall-x86_64.h (100%) diff --git a/Makefile b/Makefile index e53c281..281ae07 100644 --- a/Makefile +++ b/Makefile @@ -11,26 +11,54 @@ override TARGET_ARCH := $(XEN_TARGET_ARCH) CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline -override CPPFLAGS := -Iinclude $(CPPFLAGS) ASFLAGS = -D__ASSEMBLY__ LDLIBS = -L. -lminios LDFLAGS := -N -T minios-$(TARGET_ARCH).lds +# For possible special source directories. +EXTRA_SRC = +# For possible special header directories. +EXTRA_INC = + +# Standard name for architecture specific subdirectories. +TARGET_ARCH_DIR = $(TARGET_ARCH) +# This is used for architecture specific links. +ARCH_LINKS = + ifeq ($(TARGET_ARCH),x86_32) CFLAGS += -m32 -march=i686 LDFLAGS += -m elf_i386 +TARGET_ARCH_DIR = x86 +EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH) +EXTRA_SRC += arch/$(EXTRA_INC) endif ifeq ($(TARGET_ARCH)$(pae),x86_32y) CFLAGS += -DCONFIG_X86_PAE=1 ASFLAGS += -DCONFIG_X86_PAE=1 +TARGET_ARCH_DIR = x86 +EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH) +EXTRA_SRC += arch/$(EXTRA_INC) endif ifeq ($(TARGET_ARCH),x86_64) CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks CFLAGS += -fno-asynchronous-unwind-tables LDFLAGS += -m elf_x86_64 +TARGET_ARCH_DIR = x86 +EXTRA_INC += $(TARGET_ARCH_DIR)/$(TARGET_ARCH) +EXTRA_SRC += arch/$(EXTRA_INC) +endif + +ifeq ($(TARGET_ARCH),ia64) +CFLAGS += -mfixed-range=f12-f15,f32-f127 +ASFLAGS += -x assembler-with-cpp -ansi -Wall +ASFLAGS += -mfixed-range=f12-f15,f32-f127 +ARCH_LINKS = IA64_LINKS # Special link on ia64 needed +define arch_links +[ -e include/ia64/asm-xsi-offsets.h ] || ln -sf ../../../../xen/include/asm-ia64/asm-xsi-offsets.h include/ia64/asm-xsi-offsets.h +endef endif ifeq ($(debug),y) @@ -39,6 +67,10 @@ else CFLAGS += -O3 endif +# Add the special header directories to the include paths. +extra_incl := $(foreach dir,$(EXTRA_INC),-Iinclude/$(dir)) +override CPPFLAGS := -Iinclude $(CPPFLAGS) -Iinclude/$(TARGET_ARCH_DIR) $(extra_incl) + TARGET := mini-os HEAD := $(TARGET_ARCH).o @@ -46,15 +78,32 @@ OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c)) OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c)) OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c)) +OBJS += $(patsubst %.S,%.o,$(wildcard arch/$(TARGET_ARCH_DIR)/*.S)) +OBJS += $(patsubst %.c,%.o,$(wildcard arch/$(TARGET_ARCH_DIR)/*.c)) +# For special wanted source directories. +extra_objs := $(foreach dir,$(EXTRA_SRC),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c))) +OBJS += $(extra_objs) +extra_objs := $(foreach dir,$(EXTRA_SRC),$(patsubst %.S,%.o,$(wildcard $(dir)/*.S))) +OBJS += $(extra_objs) HDRS := $(wildcard include/*.h) HDRS += $(wildcard include/xen/*.h) +HDRS += $(wildcard include/$(TARGET_ARCH_DIR)/*.h) +# For special wanted header directories. +extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h)) +HDRS += $(extra_heads) .PHONY: default default: $(TARGET) +# Create special architecture specific links. +ifneq ($(ARCH_LINKS),) +$(ARCH_LINKS): + $(arch_links) +endif + .PHONY: links -links: +links: $(ARCH_LINKS) [ -e include/xen ] || ln -sf ../../../xen/include/public include/xen libminios.a: links $(OBJS) $(HEAD) diff --git a/traps.c b/arch/x86/traps.c similarity index 100% rename from traps.c rename to arch/x86/traps.c diff --git a/include/hypervisor.h b/include/hypervisor.h index f5daa2c..e3f149e 100644 --- a/include/hypervisor.h +++ b/include/hypervisor.h @@ -7,6 +7,7 @@ * Copyright (c) 2002, K A Fraser * Copyright (c) 2005, Grzegorz Milos * Updates: Aravindh Puthiyaparambil + * Updates: Dietmar Hahn for ia64 */ #ifndef _HYPERVISOR_H_ @@ -19,6 +20,8 @@ #include #elif defined(__x86_64__) #include +#elif defined(__ia64__) +#include #else #error "Unsupported architecture" #endif diff --git a/include/types.h b/include/types.h index f6f3f94..f0b6760 100644 --- a/include/types.h +++ b/include/types.h @@ -29,7 +29,7 @@ typedef unsigned int u32; #ifdef __i386__ typedef signed long long s64; typedef unsigned long long u64; -#elif defined(__x86_64__) +#elif defined(__x86_64__) || defined(__ia64__) typedef signed long s64; typedef unsigned long u64; #endif @@ -49,7 +49,7 @@ typedef struct { unsigned long pte_low; } pte_t; typedef struct { unsigned long pte_low, pte_high; } pte_t; #endif /* CONFIG_X86_PAE */ -#elif defined(__x86_64__) +#elif defined(__x86_64__) || defined(__ia64__) typedef long quad_t; typedef unsigned long u_quad_t; typedef unsigned long uintptr_t; diff --git a/include/os.h b/include/x86/os.h similarity index 100% rename from include/os.h rename to include/x86/os.h diff --git a/include/spinlock.h b/include/x86/spinlock.h similarity index 100% rename from include/spinlock.h rename to include/x86/spinlock.h diff --git a/include/traps.h b/include/x86/traps.h similarity index 100% rename from include/traps.h rename to include/x86/traps.h diff --git a/include/hypercall-x86_32.h b/include/x86/x86_32/hypercall-x86_32.h similarity index 100% rename from include/hypercall-x86_32.h rename to include/x86/x86_32/hypercall-x86_32.h diff --git a/include/hypercall-x86_64.h b/include/x86/x86_64/hypercall-x86_64.h similarity index 100% rename from include/hypercall-x86_64.h rename to include/x86/x86_64/hypercall-x86_64.h -- 2.39.5