ia64/xen-unstable

changeset 14069:dda691c7f25f

[IA64][MINIOS] Make mini-os ia64 cross compile-able

Signed-off-by: Tristan Gingold <tgingold@free.fr>
author awilliam@xenbuild2.aw
date Wed Feb 28 09:40:36 2007 -0700 (2007-02-28)
parents 707a696e840d
children ac28d6c41e6f
files extras/mini-os/arch/ia64/Makefile extras/mini-os/arch/ia64/gen_off.c
line diff
     1.1 --- a/extras/mini-os/arch/ia64/Makefile	Fri Feb 23 14:06:08 2007 -0700
     1.2 +++ b/extras/mini-os/arch/ia64/Makefile	Wed Feb 28 09:40:36 2007 -0700
     1.3 @@ -2,6 +2,9 @@
     1.4  # Special makefile for ia64.
     1.5  #
     1.6  
     1.7 +XEN_ROOT = ../../../..
     1.8 +include $(XEN_ROOT)/Config.mk
     1.9 +
    1.10  include arch.mk
    1.11  include ../../minios.mk
    1.12  
    1.13 @@ -36,21 +39,21 @@ ARCH_OBJS += __udivdi3.o
    1.14  ARCH_OBJS += __divdi3.o
    1.15  
    1.16  GEN_OFF_SRC := gen_off.c
    1.17 -GEN_OFF_BIN := gen_off
    1.18 +GEN_OFF_ASM := gen_off.s
    1.19  GEN_OFF_H   := $(ARCH_INC)/offsets.h
    1.20  
    1.21  all: $(ARCH_LIB)
    1.22  
    1.23 -$(GEN_OFF_BIN): $(GEN_OFF_SRC)
    1.24 -	$(CC) -o $@ $(CPPFLAGS) $<
    1.25 +$(GEN_OFF_ASM): $(GEN_OFF_SRC)
    1.26 +	$(CC) -S -o $@ $(CPPFLAGS) $<
    1.27  
    1.28 -$(GEN_OFF_H): $(GEN_OFF_BIN)
    1.29 -	./$(GEN_OFF_BIN) > $(GEN_OFF_H)
    1.30 +$(GEN_OFF_H): $(GEN_OFF_ASM)
    1.31 +	sed -ne "/^->/ {s/->/#define /; p}" < $< > $@
    1.32  
    1.33  $(ARCH_LIB): $(GEN_OFF_H) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
    1.34  	$(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
    1.35  
    1.36  clean:
    1.37  	rm -f $(ARCH_LIB) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
    1.38 -	rm -f $(GEN_OFF_BIN)
    1.39 +	rm -f $(GEN_OFF_ASM)
    1.40  	rm -f $(GEN_OFF_H)
     2.1 --- a/extras/mini-os/arch/ia64/gen_off.c	Fri Feb 23 14:06:08 2007 -0700
     2.2 +++ b/extras/mini-os/arch/ia64/gen_off.c	Wed Feb 28 09:40:36 2007 -0700
     2.3 @@ -25,19 +25,25 @@
     2.4   * SUCH DAMAGE.
     2.5   *
     2.6   */
     2.7 -
     2.8 -#include <stdio.h>
     2.9 -#include <stddef.h>
    2.10 -#include <string.h>
    2.11  #include "types.h"
    2.12  #include "sched.h"
    2.13  #include "xen/xen.h"
    2.14  #include "xen/arch-ia64.h"
    2.15  
    2.16 +#define DEFINE(sym, val)					\
    2.17 +  asm volatile("\n->" sym " %0 /* " #val " */": : "i" (val))
    2.18 +#define DEFINE_STR2(sym, pfx, val)				\
    2.19 +  asm volatile("\n->" sym " " pfx "%0" : : "i"(val));
    2.20 +
    2.21  #define SZ(st,e) sizeof(((st *)0)->e)
    2.22 -#define OFF(st,e,d,o) print_define(fp, #d, offsetof(st, e) + o, SZ(st, e))
    2.23 +#define OFF(st,e,d,o)				\
    2.24 +  DEFINE(#d, offsetof(st, e) + o);		\
    2.25 +  DEFINE(#d "_sz", SZ(st,e ));			\
    2.26 +  DEFINE_STR2(#d "_ld", "ld", SZ(st, e));	\
    2.27 +  DEFINE_STR2(#d "_st", "st", SZ(st, e));			
    2.28 +
    2.29  #define TFOFF(e,d) OFF(trap_frame_t, e, d, 0)
    2.30 -#define SIZE(st,d) fprintf(fp, "#define %-30s\t0x%016lx\n", #d, sizeof(st))
    2.31 +#define SIZE(st,d) DEFINE(#d, sizeof(st))
    2.32  
    2.33  #define SWOFF(e,d) OFF(struct thread, e, d, 0)
    2.34  
    2.35 @@ -46,51 +52,9 @@
    2.36  /* mapped_regs_t from xen/arch-ia64.h */
    2.37  #define MR_OFF(e, d) OFF(mapped_regs_t, e, d, XMAPPEDREGS_OFS)
    2.38  
    2.39 -void
    2.40 -print_define(FILE *fp, char *name, uint64_t val, int size)
    2.41 -{
    2.42 -	char	ld_name[64];
    2.43 -	char	st_name[64];
    2.44 -	char	sz_name[64];
    2.45 -
    2.46 -	strcpy(ld_name, name);
    2.47 -	strcat(ld_name, "_ld");
    2.48 -	strcpy(st_name, name);
    2.49 -	strcat(st_name, "_st");
    2.50 -	strcpy(sz_name, name);
    2.51 -	strcat(sz_name, "_sz");
    2.52 -	fprintf(fp, "#define %-30s\t0x%016lx\n", name, val);
    2.53 -	fprintf(fp, "#define %-30s\t%u\n", sz_name, size);
    2.54 -	switch (size) {
    2.55 -		case 1:
    2.56 -			fprintf(fp, "#define %-30s\tld1\n", ld_name);
    2.57 -			fprintf(fp, "#define %-30s\tst1\n", st_name);
    2.58 -			break;
    2.59 -		case 2:
    2.60 -			fprintf(fp, "#define %-30s\tld2\n", ld_name);
    2.61 -			fprintf(fp, "#define %-30s\tst2\n", st_name);
    2.62 -			break;
    2.63 -		case 4:
    2.64 -			fprintf(fp, "#define %-30s\tld4\n", ld_name);
    2.65 -			fprintf(fp, "#define %-30s\tst4\n", st_name);
    2.66 -			break;
    2.67 -		case 8:
    2.68 -			fprintf(fp, "#define %-30s\tld8\n", ld_name);
    2.69 -			fprintf(fp, "#define %-30s\tst8\n", st_name);
    2.70 -			break;
    2.71 -		default: ;
    2.72 -	}
    2.73 -	return;
    2.74 -}
    2.75 -
    2.76 -
    2.77  int
    2.78  main(int argc, char ** argv)
    2.79  {
    2.80 -	FILE		*fp;
    2.81 -
    2.82 -	fp = stdout;
    2.83 -
    2.84  	TFOFF(cfm, TF_CFM);
    2.85  	TFOFF(pfs, TF_PFS);
    2.86  	TFOFF(bsp, TF_BSP);
    2.87 @@ -173,5 +137,5 @@ main(int argc, char ** argv)
    2.88  	MR_OFF(bank1_regs[0], XSI_BANK1_R16_OFS);
    2.89  	MR_OFF(precover_ifs, XSI_PRECOVER_IFS_OFS);
    2.90  
    2.91 -	return(0);
    2.92 +	return 0;
    2.93  }