aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Huth <thuth@linux.vnet.ibm.com>2011-07-11 17:32:32 +0200
committerThomas Huth <thuth@linux.vnet.ibm.com>2011-10-12 08:58:04 +0200
commit399e16b3f77cda49e6a92af401415f6e8f4faa0d (patch)
treec4d5cf7d3b6c8926249a2027bbecb193c3e6e18e
parentf06450c2e5909ff97e58007e7c602ed69a956dd9 (diff)
downloadSLOF-399e16b3f77cda49e6a92af401415f6e8f4faa0d.zip
SLOF-399e16b3f77cda49e6a92af401415f6e8f4faa0d.tar.gz
SLOF-399e16b3f77cda49e6a92af401415f6e8f4faa0d.tar.bz2
Make net-snk and modules relocatable, too.
Cleaned up the toc-relative assembly of net-snk, fixed the Makefiles, save the modules as ELF files instead of raw binaries, adjust the net-snk base address and the load-base variable... a lot of changes were required to make the net-snk and the snk modules relocatable, too. But now it should be possible to relocate all files so that the firmware also runs with less than 256 MiB RAM. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
-rw-r--r--board-js2x/romfs/boot_rom.ffs4
-rw-r--r--board-qemu/llfw/stage2.c4
-rw-r--r--board-qemu/romfs/boot_rom.ffs2
-rw-r--r--board-qemu/slof/OF.fs3
-rw-r--r--board-qemu/veth/Makefile13
-rw-r--r--board-qemu/veth/module_entry.c20
-rw-r--r--board-qemu/veth/veth.lds13
-rw-r--r--clients/net-snk/Makefile19
-rw-r--r--clients/net-snk/include/macros.h72
-rw-r--r--clients/net-snk/kernel/entry.S63
-rw-r--r--clients/net-snk/kernel/lowmem.S21
-rw-r--r--clients/net-snk/kernel/modules.c49
-rw-r--r--clients/net-snk/libc/socket/Makefile4
-rw-r--r--clients/net-snk/libc/time/Makefile5
-rw-r--r--clients/net-snk/make.depend4
-rw-r--r--clients/net-snk/make.rules9
-rw-r--r--clients/net-snk/oflib/entry.S25
-rw-r--r--clients/takeover/Makefile7
-rw-r--r--lib/libelf/elf64.c2
-rw-r--r--other-licence/bcm/Makefile16
-rw-r--r--other-licence/common/module.lds15
-rw-r--r--other-licence/common/module_entry.c21
-rw-r--r--slof/fs/claim.fs7
-rw-r--r--slof/fs/loaders.fs9
24 files changed, 166 insertions, 241 deletions
diff --git a/board-js2x/romfs/boot_rom.ffs b/board-js2x/romfs/boot_rom.ffs
index fc86bbf..a27cec9 100644
--- a/board-js2x/romfs/boot_rom.ffs
+++ b/board-js2x/romfs/boot_rom.ffs
@@ -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
@@ -20,4 +20,4 @@ stageS board-js2x/llfw/stageS.bin 0 0
bootinfo board-js2x/llfw/Cboot.bin 0 0
rtas board-js2x/rtas/rtas.bin 0 0
snk clients/net-snk.client 0 0
-net_bcm other-licence/bcm/net_bcm57xx.bin 0 0
+net_bcm other-licence/bcm/net_bcm57xx.elf 0 0
diff --git a/board-qemu/llfw/stage2.c b/board-qemu/llfw/stage2.c
index 4b1c15b..3d2e410 100644
--- a/board-qemu/llfw/stage2.c
+++ b/board-qemu/llfw/stage2.c
@@ -168,9 +168,9 @@ void early_c_entry(uint64_t start_addr, uint64_t fdt_addr)
((uint64_t *)fileInfo.addr_header)[2],
((uint64_t *)fileInfo.addr_header)[3]);
- /* Assume that paflof need ca. 16 MiB RAM right now..
+ /* Assume that paflof and SNK need ca. 31 MiB RAM right now.
* TODO: Use value from ELF file instead */
- paflof_base = romfs_base - 0x1000000 + 0x100;
+ paflof_base = romfs_base - 0x1F00000 + 0x100;
if ((int64_t)paflof_base <= 0LL) {
puts("ERROR: Not enough memory for Open Firmware");
}
diff --git a/board-qemu/romfs/boot_rom.ffs b/board-qemu/romfs/boot_rom.ffs
index 385a08d..75a9fc5 100644
--- a/board-qemu/romfs/boot_rom.ffs
+++ b/board-qemu/romfs/boot_rom.ffs
@@ -18,4 +18,4 @@ xvect slof/xvect.bin 0 0
ofw_main board-qemu/slof/paflof 0 0
bootinfo board-qemu/llfw/Cboot.bin 0 0
snk clients/net-snk.client 0 0
-net_veth board-qemu/veth/net_veth.bin 0 0
+net_veth board-qemu/veth/net_veth.elf 0 0
diff --git a/board-qemu/slof/OF.fs b/board-qemu/slof/OF.fs
index bd2c7b3..e2712c9 100644
--- a/board-qemu/slof/OF.fs
+++ b/board-qemu/slof/OF.fs
@@ -22,6 +22,9 @@ hex
#include "base.fs"
+\ Adjust load-base to point to paflof-start / 2:
+paflof-start 1 rshift fff not and to load-base
+
\ Little-endian accesses. Also known as `wrong-endian'.
#include <little-endian.fs>
diff --git a/board-qemu/veth/Makefile b/board-qemu/veth/Makefile
index 0032b8e..ac3b947 100644
--- a/board-qemu/veth/Makefile
+++ b/board-qemu/veth/Makefile
@@ -24,15 +24,14 @@ SRCS = module_entry.c veth.c
OBJS = $(SRCS:.c=.o) $(TOP)/lib/libhvcall/hvcall.o
-all: Makefile.dep net_veth.bin
+all: Makefile.dep net_veth.elf
-net_veth.o: $(OBJS)
- $(LD) $(LDFLAGS) $^ -o $@ -T veth.lds -N
+net_veth.elf: $(OBJS)
+ $(LD) $(LDFLAGS) $^ -o $@ -T veth.lds -N -q
+ $(STRIP) --strip-unneeded $@
-net_veth.bin: net_veth.o
- $(OBJCOPY) -O binary $^ $@
-clean:
- $(RM) -f *.o *.a *.i *.bin
+clean:
+ $(RM) -f *.o *.a *.i *.elf
distclean : clean
rm -f Makefile.dep
diff --git a/board-qemu/veth/module_entry.c b/board-qemu/veth/module_entry.c
index 30a3508..385baba 100644
--- a/board-qemu/veth/module_entry.c
+++ b/board-qemu/veth/module_entry.c
@@ -20,25 +20,27 @@ static void* memset( void *dest, int c, size_t n )
return dest;
}
-extern char __bss_start;
-extern char __bss_size;
+extern char __module_start[];
+extern char __module_end[];
+extern char __bss_start[];
+extern char __bss_end[];
extern snk_module_t* veth_module_init(snk_kernel_t *snk_kernel_int,
vio_config_t *conf);
snk_module_t* module_init(snk_kernel_t *snk_kernel_int, pci_config_t *pciconf)
{
- char *bss = &__bss_start;
- unsigned long long bss_size = (unsigned long long) &__bss_size;
+ long module_size;
vio_config_t *vioconf = (vio_config_t *)pciconf;
- if (((unsigned long long) bss) + bss_size >= 0xFF00000
- || bss_size >= 0x2000000) {
- snk_kernel_int->print("BSS size (%llu bytes) is too big!\n",
- bss_size);
+ module_size = __module_end - __module_start;
+ if (module_size >= 0x800000) {
+ snk_kernel_int->print("Module size (%llu bytes) is too big!\n",
+ module_size);
return 0;
}
- memset(bss, 0, bss_size);
+
+ memset(__bss_start, 0, __bss_end - __bss_start);
return veth_module_init(snk_kernel_int, vioconf);
}
diff --git a/board-qemu/veth/veth.lds b/board-qemu/veth/veth.lds
index a0c75d5..5132bcf 100644
--- a/board-qemu/veth/veth.lds
+++ b/board-qemu/veth/veth.lds
@@ -17,23 +17,24 @@ ENTRY(module_init)
SECTIONS {
.code 0xF800000:
{
+ __module_start = .;
module_entry.o(.opd)
*(.text .stub .text.* .gnu.linkonce.t.*)
*(.sfpr .glink)
- *(.rodata .rodata.* .gnu.linkonce.r.*)
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
*(.data .data.* .gnu.linkonce.d.*)
*(.opd)
}
.got :
{
_got = .;
- *(.got .toc)
+ *(.got .toc)
}
- .bss : {
+ .bss :
+ {
__bss_start = .;
- *(*COM* .bss .gnu.linkonce.b.*)
+ *(*COM* .bss .gnu.linkonce.b.*)
__bss_end = .;
}
- __bss_size = (__bss_end - __bss_start);
- __end = .;
+ __module_end = .;
}
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 $^
diff --git a/lib/libelf/elf64.c b/lib/libelf/elf64.c
index dbf6b47..78b7697 100644
--- a/lib/libelf/elf64.c
+++ b/lib/libelf/elf64.c
@@ -360,6 +360,8 @@ elf_apply_rela64(void *file_addr, signed long offset, struct rela *relaentry,
case R_PPC64_REL14:
case R_PPC64_REL24: /* (S + A - P) >> 2 */
case R_PPC64_REL64: /* S + A - P */
+ case R_PPC64_GOT16_DS:
+ case R_PPC64_GOT16_LO_DS:
// printf("\t\tignoring relocation type %i\n",
// ELF_R_TYPE(relaentry->r_info));
break;
diff --git a/other-licence/bcm/Makefile b/other-licence/bcm/Makefile
index b7b386d..87bb3bf 100644
--- a/other-licence/bcm/Makefile
+++ b/other-licence/bcm/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
@@ -25,21 +25,19 @@ COMMONOBJS = ../common/module_entry.o
OBJS += $(COMMONOBJS) $(SRCS:.c=.o)
-all: Makefile.dep net_bcm57xx.bin
+all: Makefile.dep net_bcm57xx.elf
-bcm57xx_net.o: $(OBJS)
- $(LD) $(LDFLAGS) $^ -o $@ -T ../common/module.lds -N
-
-net_bcm57xx.bin: bcm57xx_net.o
- $(OBJCOPY) -O binary $^ $@
+net_bcm57xx.elf: $(OBJS)
+ $(LD) $(LDFLAGS) $^ -o $@ -T ../common/module.lds -N -q
+ $(STRIP) --strip-unneeded $@
# A rule for making the object files in the common directory:
../common/%.o: ../common/%.c
$(MAKE) -C ../common all
-clean:
- $(RM) -f *.o *.a *.i *.bin
+clean:
+ $(RM) *.o *.a *.i *.elf
distclean : clean
rm -f Makefile.dep
diff --git a/other-licence/common/module.lds b/other-licence/common/module.lds
index c17a055..df42f53 100644
--- a/other-licence/common/module.lds
+++ b/other-licence/common/module.lds
@@ -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
@@ -17,23 +17,24 @@ ENTRY(module_init)
SECTIONS {
.code 0xF800000:
{
+ __module_start = .;
../common/module_entry.o(.opd)
*(.text .stub .text.* .gnu.linkonce.t.*)
*(.sfpr .glink)
- *(.rodata .rodata.* .gnu.linkonce.r.*)
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
*(.data .data.* .gnu.linkonce.d.*)
*(.opd)
}
.got :
{
_got = .;
- *(.got .toc)
+ *(.got .toc)
}
- .bss : {
+ .bss :
+ {
__bss_start = .;
- *(*COM* .bss .gnu.linkonce.b.*)
+ *(*COM* .bss .gnu.linkonce.b.*)
__bss_end = .;
}
- __bss_size = (__bss_end - __bss_start);
- __end = .;
+ __module_end = .;
}
diff --git a/other-licence/common/module_entry.c b/other-licence/common/module_entry.c
index 423d908..be1a110 100644
--- a/other-licence/common/module_entry.c
+++ b/other-licence/common/module_entry.c
@@ -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
@@ -30,23 +30,24 @@ memset( void *dest, int c, size_t n )
}
-extern char __bss_start;
-extern char __bss_size;
+extern char __module_start[];
+extern char __module_end[];
+extern char __bss_start[];
+extern char __bss_end[];
snk_module_t*
module_init(snk_kernel_t *snk_kernel_int, pci_config_t *pciconf)
{
- /* Need to clear bss, heavy linker script dependency, expert change only */
- char *bss = &__bss_start;
- unsigned long long bss_size = (unsigned long long) &__bss_size;
+ long module_size;
- if (((unsigned long long) bss) + bss_size >= 0xFF00000
- || bss_size >= 0x2000000) {
- snk_kernel_int->print("BSS size (%llu bytes) is too big!\n", bss_size);
+ module_size = __module_end - __module_start;
+ if (module_size >= 0x800000) {
+ snk_kernel_int->print("Module size (%llu bytes) is too big!\n",
+ module_size);
return 0;
}
- memset(bss, 0, bss_size);
+ memset(__bss_start, 0, __bss_end - __bss_start);
if (snk_kernel_int->version != snk_module_interface.version) {
return 0;
diff --git a/slof/fs/claim.fs b/slof/fs/claim.fs
index ea75c2d..a530fe6 100644
--- a/slof/fs/claim.fs
+++ b/slof/fs/claim.fs
@@ -408,10 +408,7 @@ defer release
\ claim first pages used for PPC exception vectors
0 MIN-RAM-RESERVE 0 ' claim CATCH IF ." claim failed!" cr 2drop THEN drop
-\ claim region used by firmware (assume 15 MiB size right now)
-paflof-start ffff not and f00000 0 ' claim CATCH IF
+\ claim region used by firmware (assume 31 MiB size right now)
+paflof-start ffff not and 1f00000 0 ' claim CATCH IF
." claim failed!" cr 2drop
THEN drop
-
-\ FIXME: Hard claim memory region of net-snk
-F000000 1000000 0 ' claim CATCH IF ." claim failed!" cr 2drop THEN drop
diff --git a/slof/fs/loaders.fs b/slof/fs/loaders.fs
index 4b97cb1..6631c7a 100644
--- a/slof/fs/loaders.fs
+++ b/slof/fs/loaders.fs
@@ -44,8 +44,13 @@ CREATE load-list 2 cells allot load-list 2 cells erase
;
: .(client-exec) ( arg len -- rc )
- s" snk" romfs-lookup 0<> IF elf-load-file drop start-elf64 client-data
- ELSE 2drop false THEN
+ s" snk" romfs-lookup 0<> IF
+ \ Load SNK client 15 MiB after Paflof... FIXME: Hard-coded offset is ugly!
+ paflof-start f00000 +
+ elf-load-file-to-addr drop start-elf64 client-data
+ ELSE
+ 2drop false
+ THEN
;
' .(client-exec) to (client-exec)