/branches/tracing/boot/arch/mips32/loader/_link.ld.in.ecoff |
---|
File deleted |
/branches/tracing/boot/arch/mips32/loader/_link.ld.in.binary |
---|
File deleted |
/branches/tracing/boot/arch/mips32/loader/_link.ld.in |
---|
0,0 → 1,20 |
ENTRY(start) |
SECTIONS { |
.boot 0xbfc00000: AT (0) { |
*(BOOTSTRAP); |
*(.text); |
*(.rodata); |
*(.rodata.*); |
*(.data); /* initialized data */ |
*(.sdata); |
*(.sdata2); |
*(.sbss); |
*(.scommon); |
*(.bss); /* uninitialized static variables */ |
*(COMMON); /* global variables */ |
*(.reginfo); |
[[COMPONENTS]] |
} |
} |
/branches/tracing/boot/arch/mips32/loader/boot.S |
---|
27,9 → 27,8 |
# |
#include "regname.h" |
#include "main.h" |
#define INITIAL_STACK 0x80040000 |
.set noat |
.set noreorder |
.set nomacro |
38,8 → 37,82 |
.global start |
start: |
lui $sp, INITIAL_STACK >> 16 |
ori $sp, $sp, INITIAL_STACK & 0xffff |
j bootstrap |
/* Setup CPU map (on msim this code |
is executed in parallel on all CPUs, |
but it not an issue) */ |
la $a0, CPUMAP |
sw $zero, 0($a0) |
sw $zero, 4($a0) |
sw $zero, 8($a0) |
sw $zero, 12($a0) |
sw $zero, 16($a0) |
sw $zero, 20($a0) |
sw $zero, 24($a0) |
sw $zero, 28($a0) |
sw $zero, 32($a0) |
sw $zero, 36($a0) |
sw $zero, 40($a0) |
sw $zero, 44($a0) |
sw $zero, 48($a0) |
sw $zero, 52($a0) |
sw $zero, 56($a0) |
sw $zero, 60($a0) |
sw $zero, 64($a0) |
sw $zero, 68($a0) |
sw $zero, 72($a0) |
sw $zero, 76($a0) |
sw $zero, 80($a0) |
sw $zero, 84($a0) |
sw $zero, 88($a0) |
sw $zero, 92($a0) |
sw $zero, 96($a0) |
sw $zero, 100($a0) |
sw $zero, 104($a0) |
sw $zero, 108($a0) |
sw $zero, 112($a0) |
sw $zero, 116($a0) |
sw $zero, 120($a0) |
sw $zero, 124($a0) |
lui $a1, 1 |
#ifdef MACHINE_msim |
/* Read dorder value */ |
la $k0, MSIM_DORDER_ADDRESS |
lw $k1, ($k0) |
/* If we are not running on BSP |
then end in an infinite loop */ |
beq $k1, $zero, bsp |
nop |
/* Record CPU presence */ |
sll $a2, $k1, 2 |
addu $a2, $a2, $a0 |
sw $a1, ($a2) |
loop: |
j loop |
nop |
#endif |
bsp: |
/* Record CPU presence */ |
sw $a1, ($a0) |
/* Setup initial stack */ |
la $sp, INITIAL_STACK |
j bootstrap |
nop |
/branches/tracing/boot/arch/mips32/loader/main.c |
---|
28,6 → 28,9 |
#include "main.h" |
#include <printf.h> |
#include <align.h> |
#include <macros.h> |
#include <string.h> |
#include "msim.h" |
#include "asm.h" |
#include "_components.h" |
34,16 → 37,16 |
#define KERNEL_VIRTUAL_ADDRESS 0x80100000 |
char *release = RELEASE; |
char *release = STRING(RELEASE); |
#ifdef REVISION |
char *revision = ", revision " REVISION; |
char *revision = ", revision " STRING(REVISION); |
#else |
char *revision = ""; |
#endif |
#ifdef TIMESTAMP |
char *timestamp = "\nBuilt on " TIMESTAMP; |
char *timestamp = "\nBuilt on " STRING(TIMESTAMP); |
#else |
char *timestamp = ""; |
#endif |
72,9 → 75,10 |
printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size); |
printf("\nCopying components\n"); |
unsigned int top = 0; |
bootinfo.cnt = 0; |
for (i = 0; i < COMPONENTS; i++) { |
for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) { |
printf(" %s...", components[i].name); |
top = ALIGN_UP(top, PAGE_SIZE); |
memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size); |
81,6 → 85,8 |
if (i > 0) { |
bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top; |
bootinfo.tasks[bootinfo.cnt].size = components[i].size; |
strncpy(bootinfo.tasks[bootinfo.cnt].name, |
components[i].name, BOOTINFO_TASK_NAME_BUFLEN); |
bootinfo.cnt++; |
} |
top += components[i].size; |
87,6 → 93,13 |
printf("done.\n"); |
} |
unsigned int *cpumap = (unsigned int *) CPUMAP; |
bootinfo.cpumap = 0; |
for (i = 0; i < CPUMAP_MAX_RECORDS; i++) { |
if (cpumap[i] != 0) |
bootinfo.cpumap |= (1 << i); |
} |
printf("\nBooting the kernel...\n"); |
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo)); |
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo); |
} |
/branches/tracing/boot/arch/mips32/loader/asm.h |
---|
29,11 → 29,11 |
#ifndef BOOT_mips32_ASM_H_ |
#define BOOT_mips32_ASM_H_ |
#define PAGE_SIZE 16384 |
#define PAGE_WIDTH 14 |
#define PAGE_SIZE 16384 |
#define PAGE_WIDTH 14 |
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) |
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) |
void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn)); |
void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn)); |
#endif |
/branches/tracing/boot/arch/mips32/loader/main.h |
---|
29,21 → 29,30 |
#ifndef BOOT_mips32_MAIN_H_ |
#define BOOT_mips32_MAIN_H_ |
/** Align to the nearest higher address. |
* |
* @param addr Address or size to be aligned. |
* @param align Size of alignment, must be power of 2. |
*/ |
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1)) |
#define CPUMAP 0x80001000 |
#define INITIAL_STACK 0x80002000 |
#define MSIM_DORDER_ADDRESS 0xb0000004 |
#define TASKMAP_MAX_RECORDS 32 |
#define TASKMAP_MAX_RECORDS 32 |
#define CPUMAP_MAX_RECORDS 32 |
#ifndef __ASM__ |
/** Size of buffer for storing task name in task_t. */ |
#define BOOTINFO_TASK_NAME_BUFLEN 32 |
/** Struct holding information about single loaded task. */ |
typedef struct { |
/** Address where the task was placed. */ |
void *addr; |
/** Size of the task's binary. */ |
unsigned int size; |
/** Task name. */ |
char name[BOOTINFO_TASK_NAME_BUFLEN]; |
} task_t; |
typedef struct { |
unsigned int cpumap; |
unsigned int cnt; |
task_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
52,3 → 61,5 |
extern void bootstrap(void); |
#endif |
#endif |
/branches/tracing/boot/arch/mips32/loader/Makefile |
---|
27,7 → 27,7 |
# |
include ../../../../version |
include ../../../Makefile.config |
-include ../../../../Makefile.config |
## Toolchain configuration |
# |
36,17 → 36,25 |
CROSS_PREFIX = /usr/local |
endif |
ifeq ($(IMAGE),binary) |
LD_IN = binary |
endif |
ifeq ($(IMAGE),ecoff) |
LD_IN = ecoff |
endif |
BFD_NAME = elf32-tradlittlemips |
BFD_ARCH = mips |
TARGET = mipsel-linux-gnu |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/mipsel/bin |
ifeq ($(MACHINE),lgxemul) |
BFD_NAME = elf32-tradlittlemips |
BFD = ecoff-littlemips |
endif |
ifeq ($(MACHINE),bgxemul) |
BFD_NAME = elf32-tradbigmips |
BFD = ecoff-bigmips |
TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips/bin |
TARGET = mips-linux-gnu |
endif |
ifeq ($(MACHINE),msim) |
BFD_NAME = elf32-tradlittlemips |
BFD = binary |
endif |
ifeq ($(COMPILER),gcc_native) |
CC = gcc |
AS = as |
63,21 → 71,14 |
OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump |
endif |
CFLAGS = -DRELEASE=\"$(RELEASE)\" -I. -I../../../generic -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mhard-float -mips3 -pipe |
CFLAGS = -DRELEASE=$(RELEASE) -I. -I../../../generic -imacros ../../../../config.h -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mhard-float -mips3 -pipe |
ifdef REVISION |
CFLAGS += "-DREVISION=\"$(REVISION)\"" |
endif |
ifdef TIMESTAMP |
CFLAGS += "-DTIMESTAMP=\"$(TIMESTAMP)\"" |
endif |
SOURCES = \ |
main.c \ |
msim.c \ |
_components.c \ |
../../../generic/printf.c \ |
../../../generic/string.c \ |
asm.S \ |
boot.S |
88,7 → 89,7 |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |
endif |
120,9 → 121,12 |
-include Makefile.depend |
image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) |
$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) -o $@ |
image.boot: image.raw |
$(OBJCOPY) -O $(BFD) $< $@ |
image.raw: depend _components.h _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) |
$(LD) -no-check-sections -N -T _link.ld -o $@ $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) |
depend: |
-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null |
133,7 → 137,7 |
-for file in $(RD_APPS) ; do \ |
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \ |
done |
-rm -f _components.h _components.c _link.ld _link.ld.in $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.boot Makefile.depend |
-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.raw image.boot Makefile.depend |
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in |
for file in $(RD_SRVS) ; do \ |
152,9 → 156,6 |
rm initrd.fs |
../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 16384 "unsigned int" $(COMPONENTS) ./initrd.img |
_link.ld.in: _link.ld.in.$(LD_IN) |
cp $< $@ |
%.o: %.S |
$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@ |