diff options
Diffstat (limited to 'clients')
-rw-r--r-- | clients/net-snk/Makefile | 19 | ||||
-rw-r--r-- | clients/net-snk/include/macros.h | 72 | ||||
-rw-r--r-- | clients/net-snk/kernel/entry.S | 63 | ||||
-rw-r--r-- | clients/net-snk/kernel/lowmem.S | 21 | ||||
-rw-r--r-- | clients/net-snk/kernel/modules.c | 49 | ||||
-rw-r--r-- | clients/net-snk/libc/socket/Makefile | 4 | ||||
-rw-r--r-- | clients/net-snk/libc/time/Makefile | 5 | ||||
-rw-r--r-- | clients/net-snk/make.depend | 4 | ||||
-rw-r--r-- | clients/net-snk/make.rules | 9 | ||||
-rw-r--r-- | clients/net-snk/oflib/entry.S | 25 | ||||
-rw-r--r-- | clients/takeover/Makefile | 7 |
11 files changed, 97 insertions, 181 deletions
diff --git a/clients/net-snk/Makefile b/clients/net-snk/Makefile index f89ef28..e5305f7 100644 --- a/clients/net-snk/Makefile +++ b/clients/net-snk/Makefile @@ -17,29 +17,24 @@ include $(TOP)/make.rules OBJS = kernel/kernel.o oflib/oflib.o libc/libc-glue.o app/app.o .PHONY : subdirs clean depend mrproper -client : .depend subdirs $(OBJS) $(LIBCMNDIR)/libc.a - $(LD) $(LDFLAGS) -o $@ -Tclient.lds $(OBJS) $(LIBCMNDIR)/libc.a +CLIENTLIBS = $(LIBCMNDIR)/libelf.a $(LIBCMNDIR)/libc.a + +client : .depend subdirs $(OBJS) $(CLIENTLIBS) + $(LD) $(LDFLAGS) -o $@ -Tclient.lds $(OBJS) $(CLIENTLIBS) $(OBJDUMP) -DSsx $@ > $@.dis cp $@ $@.unstripped - $(STRIP) $@ + $(STRIP) --strip-unneeded $@ sec-client : subdirs $(OBJS) $(LIBCMNDIR)/libc.a $(LD) $(LDFLAGS) -o $@ -Tsec-client.lds $(OBJS) $(LIBCMNDIR)/libc.a -fpga-client : - $(MAKE) -C . fpga-client-int SNK_LJTAG_PROCESS=1 - -fpga-client-int : subdirs $(OBJS) $(LIBCMNDIR)/libc.a - $(LD) $(LDFLAGS) -o fpga-client -Tsec-client.lds $(OBJS) $(LIBCMNDIR)/libc.a - $(STRIP) fpga-client - subdirs : @for dir in $(dir $(OBJS)); do \ $(MAKE) -C $$dir || exit 1; \ done -$(LIBCMNDIR)/libc.a: - $(MAKE) -C $(LIBCMNDIR) libc +$(LIBCMNDIR)/%.a: + $(MAKE) -C $(LIBCMNDIR) $(@:$(LIBCMNDIR)/%.a=%) clean: @for dir in $(dir $(OBJS)); do \ diff --git a/clients/net-snk/include/macros.h b/clients/net-snk/include/macros.h deleted file mode 100644 index e8ad919..0000000 --- a/clients/net-snk/include/macros.h +++ /dev/null @@ -1,72 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#define LOAD64(rn,name) \ - lis rn,name##@highest; \ - ori rn,rn,name##@higher; \ - rldicr rn,rn,32,31; \ - oris rn,rn,name##@h; \ - ori rn,rn,name##@l - -#define LOAD32(rn, name) \ - lis rn,name##@h; \ - ori rn,rn,name##@l - -// load 32 bit constant in little endian order -#define LOAD32le(rn,name) \ - lis rn,(((name>>8)&0x00FF)|((name<<8)&0xFF00)); \ - ori rn,rn,(((name>>24)&0x00FF)|((name>>8)&0xFF00)) - -// load 16 bit constant in little endian order -#define LOAD16le(rn,name) \ - li rn,(((name>>8)&0x00FF)|(name<<8)) - -#define SET_CI(rn) \ - sync; \ - mfspr rn,LPCR; \ - ori rn,rn,2; \ - mtspr LPCR,rn; \ - sync - -#define CLR_CI(rn) \ - sync; \ - mfspr rn,LPCR; \ - ori rn,rn,2; \ - xori rn,rn,2; \ - mtspr LPCR,rn; \ - sync - -#define SAVE_AND_SET_CI(rn,rx) \ - sync; \ - mfspr rx,LPCR; \ - ori rn,rx,2; \ - mtspr LPCR,rn; \ - sync - -#define RESTORE_CI(rx) \ - sync; \ - mtspr LPCR,rx; \ - sync - -#define ENTRY(func_name) \ - .text; \ - .align 2; \ - .globl .func_name; \ - .func_name: \ - .globl func_name; \ - func_name: - -#define ASM_ENTRY(fn) \ - .globl fn; \ -fn: - diff --git a/clients/net-snk/kernel/entry.S b/clients/net-snk/kernel/entry.S index c0c7a12..c0c7e0a 100644 --- a/clients/net-snk/kernel/entry.S +++ b/clients/net-snk/kernel/entry.S @@ -13,6 +13,18 @@ #define STACKSIZE 0x100000 #include <macros.h> + + .section ".toc","aw" # TOC entries are needed for relocation +.exception_stack_frame_toc: + .tc exception_stack_frame[TC],exception_stack_frame +.exit_sp_toc: + .tc _exit_sp[TC],_exit_sp +.prom_entry_toc: + .tc _prom_entry[TC],_prom_entry + + .previous + + /* Function: Input: @@ -24,15 +36,7 @@ Function: Decription: Main entry point, called from OF */ - .globl _entry - .section ".opd","aw" - .align 3 -_entry: - .quad ._entry,.TOC.@tocbase,0 - .previous - .size main,24 - .globl ._entry -._entry: +C_ENTRY(_entry) mr r3, r6 # parm 0 passed in r6 mr r4, r7 # parm 1 passed in r7 mr r6, r1 # save stack pointer @@ -48,14 +52,14 @@ over: add r1, r1, r8 # add base std r2, 64(r1) # save got std r7, 56(r1) # save link register -# ld r2, .LCgot-base(r8) # load got pointer -# add r2, r2, r8 # add base + ld r2, .LCgot-base(r8) # load got pointer + add r2, r2, r8 # add base std r6, 0(r1) # save stack pointer - ld r6, _prom_entry@got(r2) + ld r6, .prom_entry_toc@toc(r2) std r5, 0(r6) # Save prom handle - ld r10, _exit_sp@got(r2) # save stack pointer for exit call + ld r10, .exit_sp_toc@toc(r2) # save stack pointer for exit call std r1, 0(r10) bl ._start_kernel # call kernel init code @@ -79,16 +83,7 @@ the_end: * function moves R6 to R3 and R7 to R4 and then calls callback_entry(). * */ - .globl _callback_entry - .section ".opd", "aw" - .align 3 -_callback_entry: - .quad ._callback_entry,.TOC.@tocbase,0 - .previous - .size callback,24 - .type ._callback_entry, @function - .globl ._callback_entry -._callback_entry: +C_ENTRY(_callback_entry) # Save the LR mflr r0 std r0, 16(r1) @@ -114,27 +109,27 @@ _callback_entry: # Return to caller blr + .section ".bss" - .globl _exit_sp _exit_sp: .quad 0 - .globl _prom_entry + +.global _prom_entry _prom_entry: .quad 0 -ENTRY(_exit) - ld r1, _exit_sp@got(r2) + .section ".text" + +C_ENTRY(_exit) + ld r1, .exit_sp_toc@toc(r2) ld r1, 0(r1) b the_end - .globl .undo_exception -.undo_exception: - .globl undo_exception -undo_exception: +C_ENTRY(undo_exception) /* unwind stack */ - ld r3,exception_stack_frame@got(r2) - ld r1,0(r3) + ld r3,.exception_stack_frame_toc@toc(r2) + ld r1,0(r3) ld r14,0x130(r1) mtctr r14 @@ -146,7 +141,7 @@ undo_exception: 27, 28, 29, 30, 31 ld r\i, 0x30+\i*8 (r1) .endr - addi r1, r1, 0x130 + addi r1, r1, 0x130 // restore regs as in default handler diff --git a/clients/net-snk/kernel/lowmem.S b/clients/net-snk/kernel/lowmem.S index 8d6cfc6..31e643b 100644 --- a/clients/net-snk/kernel/lowmem.S +++ b/clients/net-snk/kernel/lowmem.S @@ -12,7 +12,15 @@ #include <macros.h> -.section .lowmem,"aw",@progbits + + .section ".toc","aw" # TOC entries are needed for relocation +.exception_stack_frame_toc: + .tc exception_stack_frame[TC],exception_stack_frame +.system_call_toc: + .tc _system_call[TC],_system_call + + + .section .lowmem,"aw",@progbits .irp i, 0x0200,0x0300,0x0380,0x0400,0x0480,0x0500,0x0600,0x0700, \ 0x0800,0x0900,0x0a00,0x0b00 @@ -63,10 +71,10 @@ mflr r11 std r11, 0x30(r1) mfsrr0 r11 - std r11, 0x40(r1) + std r11, 0x40(r1) mfsrr1 r11 - std r11, 0x48(r1) - ld r11, _system_call@got(r2) + std r11, 0x48(r1) + ld r11, .system_call_toc@toc(r2) ld r11, 0(r11) mtctr r11 mr r10, r0 @@ -143,9 +151,8 @@ _exception_handler: LOAD64(r3,_entry) ld r2,8(r3) - ld r3,exception_stack_frame@got(r2) - std r1,0(r3) - + ld r3,.exception_stack_frame_toc@toc(r2) + std r1,0(r3) mflr r14 bctrl diff --git a/clients/net-snk/kernel/modules.c b/clients/net-snk/kernel/modules.c index 1ebf0b9..3592a28 100644 --- a/clients/net-snk/kernel/modules.c +++ b/clients/net-snk/kernel/modules.c @@ -14,9 +14,11 @@ #include <kernel.h> #include <of.h> #include <rtas.h> +#include <libelf.h> #include <cpu.h> /* flush_cache */ -//#include <stdlib.h> /* malloc */ #include <unistd.h> /* open, close, read, write */ +#include <stdio.h> + unsigned int read_io(void *, size_t); int write_io(void *, unsigned int, size_t); @@ -24,22 +26,21 @@ int write_io(void *, unsigned int, size_t); extern void get_mac(char *mac); extern snk_module_t of_module; +extern char __client_start[]; + + typedef snk_module_t *(*module_init_t) (snk_kernel_t *, pci_config_t *); typedef struct { const char *name; - void *link_addr; int type; } mod_descriptor_t; static const mod_descriptor_t modules[] = { - { "net_e1000" , (void*) 0xF800000, MOD_TYPE_NETWORK }, - { "net_bcm" , (void*) 0xF800000, MOD_TYPE_NETWORK }, - { "net_nx203x", (void*) 0xF800000, MOD_TYPE_NETWORK }, - { "net_mcmal" , (void*) 0xF800000, MOD_TYPE_NETWORK }, - { "net_spider", (void*) 0xF800000, MOD_TYPE_NETWORK }, - { "net_veth", (void*) 0xF800000, MOD_TYPE_NETWORK }, - { 0 , (void*) 0 } + { "net_e1000", MOD_TYPE_NETWORK }, + { "net_bcm", MOD_TYPE_NETWORK }, + { "net_veth", MOD_TYPE_NETWORK }, + { NULL, 0 } }; snk_module_t *snk_modules[MODULES_MAX]; @@ -59,6 +60,12 @@ load_module(const char *name) void *link_addr; module_init_t module_init; + // Load modules right after the SNK... + // FIXME: hard-coded offset! + link_addr = (void*)__client_start + 0x800000; + + // snk_kernel_interface.print("Loading Module '%s'\n", name); + /* find module in module list and lookup link address */ for(i=0; modules[i].name; ++i) { if(strcmp(modules[i].name, name) == 0) @@ -68,12 +75,11 @@ load_module(const char *name) /* module not in list */ return -1; } - link_addr = modules[i].link_addr; /* check if link address is used already */ - for(i=0; i<MODULES_MAX; ++i) { - if(snk_modules[i] && snk_modules[i]->link_addr == link_addr) { - /* busy, can't load modules */ + for(i=1; i<MODULES_MAX; ++i) { + if(snk_modules[i] /* && snk_modules[i]->link_addr == link_addr*/) { + // busy, can't load modules return -2; } } @@ -95,18 +101,13 @@ load_module(const char *name) /* file not found */ return -4; } - /* Copy image from flash to RAM - * FIXME fix address 8MB - */ - - memcpy(link_addr, addr, len); - - flush_cache(link_addr, len); - /* Module starts with opd structure of the module_init - * function. - */ - module_init = (module_init_t) link_addr; + /* Copy image from flash to RAM */ + if (elf_load_file_to_addr(addr, link_addr, (void*)&module_init, + NULL, flush_cache) != 2) { + snk_kernel_interface.print("ELF loading failed!\n"); + return -5; + } snk_modules[i] = module_init(&snk_kernel_interface, &snk_kernel_interface.pci_conf); if(snk_modules[i] == 0) { diff --git a/clients/net-snk/libc/socket/Makefile b/clients/net-snk/libc/socket/Makefile index cffa6b3..99bd760 100644 --- a/clients/net-snk/libc/socket/Makefile +++ b/clients/net-snk/libc/socket/Makefile @@ -27,10 +27,6 @@ all: socket.o socket.o: $(OBJS) $(LD) $(LDFLAGS) -r $< -o $@ -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - - clean: $(RM) -f *.o *.i *.s diff --git a/clients/net-snk/libc/time/Makefile b/clients/net-snk/libc/time/Makefile index 072df55..5db7794 100644 --- a/clients/net-snk/libc/time/Makefile +++ b/clients/net-snk/libc/time/Makefile @@ -22,15 +22,10 @@ OBJS = timer.o ftime.o all: time.o - time.o: $(OBJS) $(LD) $(LDFLAGS) -r $< -o $@ -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - - clean: $(RM) -f *.o *.i *.s diff --git a/clients/net-snk/make.depend b/clients/net-snk/make.depend index e995741..af83059 100644 --- a/clients/net-snk/make.depend +++ b/clients/net-snk/make.depend @@ -16,12 +16,12 @@ depend : @rm -rf .depend ifdef OBJS @touch .depend && \ - $(CC) -M $(CFLAGS) $(OBJS:.o=.c) >> .depend + $(CC) -M $(CPPFLAGS) $(CFLAGS) $(OBJS:.o=.c) >> .depend #else # @echo "OBJ is NOT defined" endif ifdef OBJS2 - @$(CC) -M $(CFLAGS) $(OBJS2:.o=.S) >> .depend + @$(CC) -M $(CPPFLAGS) $(CFLAGS) $(OBJS2:.o=.S) >> .depend #else # @echo "OBJ2 is NOT definde" endif diff --git a/clients/net-snk/make.rules b/clients/net-snk/make.rules index ea89e08..0216093 100644 --- a/clients/net-snk/make.rules +++ b/clients/net-snk/make.rules @@ -16,11 +16,10 @@ include $(ROOTDIR)/make.rules INCLCMNDIR ?= $(ROOTDIR)/include LIBCMNDIR ?= $(ROOTDIR)/lib -CFLAGS = -g -I. -I$(TOP)/include -I$(LIBCMNDIR)/libc/include \ - -I$(LIBCMNDIR)/libbootmsg -I$(INCLCMNDIR)/$(CPUARCH) \ - -O2 -fno-builtin -ffreestanding -msoft-float -mno-altivec \ - -Wall $(FLAG) -nostdinc -fno-stack-protector +CPPFLAGS = -I$(TOP)/include -I$(LIBCMNDIR)/libc/include -I$(INCLCMNDIR) \ + -I$(LIBCMNDIR)/libbootmsg -I$(INCLCMNDIR)/$(CPUARCH) -I. +CFLAGS += $(FLAG) -LDFLAGS = -nostdlib +LDFLAGS = -nostdlib -q -n ASFLAGS = -I. -I$(TOP)/include -Wa,-mregnames -I$(INCLCMNDIR)/$(CPUARCH) DD = dd diff --git a/clients/net-snk/oflib/entry.S b/clients/net-snk/oflib/entry.S index 5deeb04..f778920 100644 --- a/clients/net-snk/oflib/entry.S +++ b/clients/net-snk/oflib/entry.S @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation + * Copyright (c) 2004, 2011 IBM Corporation * All rights reserved. * This program and the accompanying materials * are made available under the terms of the BSD License @@ -10,12 +10,15 @@ * IBM Corporation - initial implementation *****************************************************************************/ +#include <macros.h> - .globl call_client_interface -call_client_interface: - .globl .call_client_interface -.call_client_interface: - ld r4, _prom_entry@got(r2) # Load prom entry point + .section ".toc","aw" # TOC entries are needed for relocation +.prom_entry_toc: + .tc _prom_entry[TC],_prom_entry + + +C_ENTRY(call_client_interface) + ld r4, .prom_entry_toc@toc(r2) # Load prom entry point mflr r0 ld r4, 0(r4) stdu r1, -16(r1) @@ -27,11 +30,7 @@ call_client_interface: addi r1, r1, 16 blr - .globl rtas_call_entry -rtas_call_entry: - .globl .rtas_call_entry -.rtas_call_entry: - mtctr r5 - bctr - +C_ENTRY(rtas_call_entry) + mtctr r5 + bctr diff --git a/clients/takeover/Makefile b/clients/takeover/Makefile index f492234..ed73ef1 100644 --- a/clients/takeover/Makefile +++ b/clients/takeover/Makefile @@ -1,5 +1,5 @@ # ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation +# * Copyright (c) 2004, 2011 IBM Corporation # * All rights reserved. # * This program and the accompanying materials # * are made available under the terms of the BSD License @@ -16,13 +16,14 @@ SNKDIR = $(TOPCMNDIR)/clients/net-snk CFLAGS += -fno-builtin -I$(LIBCMNDIR)/libc/include CFLAGS += -I$(SNKDIR)/include -I. $(CPUARCHDEF) -CFLAGS += -I$(INCLBRDDIR) -I.. -I$(INCLCMNDIR)/$(CPUARCH) +CFLAGS += -I$(INCLBRDDIR) -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) CFLAGS += -O2 -msoft-float -Wa,-mregnames $(RELEASE) OBJS = $(SNKDIR)/kernel/kernel.o OBJS += $(SNKDIR)/oflib/oflib.o OBJS += $(SNKDIR)/libc/time/timer.o -OBJS += $(LIBCMNDIR)/libc.a entry.o main.o of.elf takeover.o +OBJS += entry.o main.o of.elf takeover.o +OBJS += $(LIBCMNDIR)/libelf.a $(LIBCMNDIR)/libc.a %.o: %.S $(CC) $(CFLAGS) -c $^ |