/trunk/boot/arch/mips32/loader/boot.S |
---|
27,10 → 27,8 |
# |
#include "regname.h" |
#include "main.h" |
#define INITIAL_STACK 0x80040000 |
#define MSIM_DORDER_ADDRESS 0x90000004 |
.set noat |
.set noreorder |
.set nomacro |
40,16 → 38,69 |
.global start |
start: |
/* 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 $k0, ($k0) |
lw $k1, ($k0) |
/* If we are not running on BSP |
end in an infinite loop */ |
beq $k0, $zero, 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 |
57,9 → 108,11 |
#endif |
bsp: |
/* Record CPU presence */ |
sw $a1, ($a0) |
/* Setup initial stack */ |
lui $sp, INITIAL_STACK >> 16 |
ori $sp, $sp, INITIAL_STACK & 0xffff |
la $sp, INITIAL_STACK |
j bootstrap |
nop |
/trunk/boot/arch/mips32/loader/main.c |
---|
28,6 → 28,7 |
#include "main.h" |
#include <printf.h> |
#include <align.h> |
#include <macros.h> |
#include "msim.h" |
#include "asm.h" |
73,9 → 74,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); |
88,6 → 90,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); |
} |
/trunk/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 |
/trunk/boot/arch/mips32/loader/main.h |
---|
29,15 → 29,15 |
#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__ |
typedef struct { |
void *addr; |
unsigned int size; |
44,6 → 44,7 |
} task_t; |
typedef struct { |
unsigned int cpumap; |
unsigned int cnt; |
task_t tasks[TASKMAP_MAX_RECORDS]; |
} bootinfo_t; |
52,3 → 53,5 |
extern void bootstrap(void); |
#endif |
#endif |