1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2025-04-21 12:27:27 +03:00

Created xbboot.

This commit is contained in:
Wolfgang Spraul
2009-08-21 14:04:09 +08:00
parent 23e322b2dd
commit a1c4ecab6b
25 changed files with 6674 additions and 0 deletions

11
xbboot/target-echokernel/.gitignore vendored Normal file
View File

@@ -0,0 +1,11 @@
echo-kernel.bin
echo-kernel.dump
echo-kernel.lst
echo-kernel.o
echo-kernel.sym
echo-kernel.map
echo-kernel.elf
head.lst
head.o
serial.lst
serial.o

View File

@@ -0,0 +1,53 @@
#
# Authors: Wolfgang Spraul <wolfgang@qi-hardware.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version
# 3 of the License, or (at your option) any later version.
#
ifeq ($(CROSS_COMPILE),)
$(error CROSS_COMPILE variable not set, should point to .../mipsel-openwrt-linux-)
endif
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar rcsv
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
NM = $(CROSS_COMPILE)nm
OBJDUMP = $(CROSS_COMPILE)objdump
DEBUG_CFLAGS = -g -Wa,-a=$(basename $@).lst
# Wolfgang saw data corruptions in stage2 when dealing with ECC data on random writes
# to NAND. Disabling the unit-at-a-time optimization reproducibly fixed the bug.
# The compiler may be optimizing in a way that conflicts with how the hardware ECC
# registers work. Since other register accesses might be affected too it seems the best
# is to disable this optimization right now.
CFLAGS = -mips32 -O2 -fno-exceptions -fno-unit-at-a-time -fno-zero-initialized-in-bss \
-ffunction-sections -fomit-frame-pointer -msoft-float -G 0 $(DEBUG_CFLAGS)
LDFLAGS = -nostdlib -T target.ld $(CFLAGS)
LIBS = -lstdc++ -lc -lm -lgcc
VPATH = ../target-common
OBJS = echo-kernel.o serial.o
all: echo-kernel.elf
$(OBJCOPY) -O binary echo-kernel.elf echo-kernel.bin
$(OBJDUMP) -D echo-kernel.elf > echo-kernel.dump
$(NM) echo-kernel.elf | sort > echo-kernel.sym
$(OBJDUMP) -h echo-kernel.elf > echo-kernel.map
echo-kernel.elf: head.o $(OBJS)
$(CC) $(LDFLAGS) $^ -o $@
.c.o:
$(CC) $(CFLAGS) -o $@ -c $<
.cpp.o:
$(CC) $(CFLAGS) -fno-rtti -fvtable-gc -o $@ -c $<
.S.o:
$(CC) $(CFLAGS) -o $@ -c $<
clean:
rm -f $(addprefix echo-kernel., bin dump elf map sym)
rm -f head.o head.lst $(OBJS) $(OBJS:.o=.lst)

View File

@@ -0,0 +1,67 @@
//
// Authors: Wolfgang Spraul <wolfgang@qi-hardware.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version.
//
#include <inttypes.h>
#include "../target-common/jz4740.h"
#include "../target-common/serial.h"
void c_main();
void pre_main(void)
{
volatile unsigned int start_addr, got_start, got_end, addr, offset;
/* get absolute start address */
__asm__ __volatile__(
"move %0, $20\n\t"
: "=r"(start_addr)
:
);
/* get related GOT address */
__asm__ __volatile__(
"la $4, _GLOBAL_OFFSET_TABLE_\n\t"
"move %0, $4\n\t"
"la $5, _got_end\n\t"
"move %1, $5\n\t"
: "=r"(got_start),"=r"(got_end)
:
);
/* calculate offset and correct GOT*/
offset = start_addr - 0x80000000;
got_start += offset;
got_end += offset;
for ( addr = got_start + 8; addr < got_end; addr += 4 )
*((volatile unsigned int *)(addr)) += offset; // add offset to correct all GOT
// fw_args = (struct fw_args *)(start_addr + 0x8); //get the fw args from memory
UART_BASE = 0xB0030000;
serial_puts("Start address is:");
serial_put_hex(start_addr);
serial_puts("Address offset is:");
serial_put_hex(start_addr - 0x80000000);
serial_puts("GOT corrected to:");
serial_put_hex(got_start);
c_main();
}
void c_main()
{
// start infinite 'echo' kernel
while (1) {
if (serial_tstc()) {
int c = serial_getc();
serial_putc(c);
if (c == '\r')
serial_putc('\n');
}
}
}

View File

@@ -0,0 +1,34 @@
//
// Authors: Wolfgang Spraul <wolfgang@qi-hardware.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version.
//
.text
.extern pre_main
.globl _start
.set noreorder
_start:
b real_start
nop
.word 0x0 // its address == start address + 8
.word 0x0
.word 0x0
.word 0x0
.word 0x0
.word 0x0
.word 0x0
.word 0x0
real_start:
/* setup stack, jump to C code */
add $29, $20, 0x3ffff0 // sp locate at start address offset 0x2ffff0
add $25, $20, 0x40 // t9 = pre_main()
j $25
nop
.set reorder

View File

@@ -0,0 +1,31 @@
OUTPUT_ARCH(mips)
ENTRY(_start)
MEMORY
{
ram : ORIGIN = 0x80000000 , LENGTH = 3M
}
SECTIONS
{
. = ALIGN(4);
.text : { *(.text*) } > ram
. = ALIGN(4);
.rodata : { *(.rodata*) } > ram
. = ALIGN(4);
.sdata : { *(.sdata*) } > ram
. = ALIGN(4);
.data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram
_gp = ALIGN(16);
.got : { *(.got*) } > ram
_got_end = ABSOLUTE(.);
. = ALIGN(4);
.sbss : { *(.sbss*) } > ram
.bss : { *(.bss*) } > ram
. = ALIGN (4);
}