Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1685 → Rev 1684

/boot/trunk/arch/mips32/Makefile.inc
29,7 → 29,7
build: image.boot
 
image.boot: kernel uspace
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNEL=../../../$(KERNELDIR)/kernel.bin
cp arch/$(ARCH)/loader/image.boot image.boot
 
clean: clean_kernel clean_uspace
/boot/trunk/arch/mips32/loader/pack
File deleted
Property changes:
Deleted: svn:executable
-*
\ No newline at end of property
/boot/trunk/arch/mips32/loader/asm.S
35,76 → 35,12
.text
 
.global halt
.global memcpy
.global jump_to_kernel
 
halt:
b halt
nop
memcpy:
addiu $v0,$a1,3
li $v1,-4 # 0xfffffffffffffffc
and $v0,$v0,$v1
beq $a1,$v0,3f
move $t0,$a0
 
0:
beq $a2,$zero,2f
move $a3,$zero
 
1:
addu $v0,$a1,$a3
lbu $a0,0($v0)
addu $v1,$t0,$a3
addiu $a3,$a3,1
bne $a3,$a2,1b
sb $a0,0($v1)
 
2:
jr $ra
move $v0,$a1
 
3:
addiu $v0,$a0,3
and $v0,$v0,$v1
bne $a0,$v0,0b
srl $t1,$a2,2
 
beq $t1,$zero,5f
move $a3,$zero
 
move $a3,$zero
move $a0,$zero
4:
addu $v0,$a1,$a0
lw $v1,0($v0)
addiu $a3,$a3,1
addu $v0,$t0,$a0
sw $v1,0($v0)
bne $a3,$t1,4b
addiu $a0,$a0,4
 
5:
andi $a2,$a2,0x3
beq $a2,$zero,2b
nop
 
sll $v0,$a3,2
addu $t1,$v0,$t0
move $a3,$zero
addu $t0,$v0,$a1
6:
addu $v0,$t0,$a3
lbu $a0,0($v0)
addu $v1,$t1,$a3
addiu $a3,$a3,1
bne $a3,$a2,6b
sb $a0,0($v1)
 
jr $ra
move $v0,$a1
 
jump_to_kernel:
# .word 0x39
j $a0
/boot/trunk/arch/mips32/loader/boot.S
28,7 → 28,7
 
#include "regname.h"
 
#define INITIAL_STACK 0x40000
#define INITIAL_STACK 0x10000
 
.set noat
.set noreorder
39,7 → 39,7
.global start
start:
lui $sp, INITIAL_STACK >> 16
ori $sp, $sp, INITIAL_STACK & 0xffff
ori $sp, $sp, INITIAL_STACK & 0xffff
 
j bootstrap
nop
/boot/trunk/arch/mips32/loader/main.c
30,42 → 30,27
#include "printf.h"
#include "msim.h"
#include "asm.h"
#include "_components.h"
 
#define KERNEL_VIRTUAL_ADDRESS 0x80100000
#define KERNEL_START &_binary_____________kernel_kernel_bin_start
#define KERNEL_END &_binary_____________kernel_kernel_bin_end
#define KERNEL_SIZE ((unsigned int) KERNEL_END - (unsigned int) KERNEL_START)
 
void bootstrap(void)
{
printf("HelenOS MIPS Bootloader\n");
printf("loaded at %L\n", &start);
printf("kernel memory at %L (size %d bytes)\n", KERNEL_VIRTUAL_ADDRESS, KERNEL_SIZE);
component_t components[COMPONENTS];
bootinfo_t bootinfo;
init_components(components);
printf("\nMemory statistics\n");
printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS);
printf(" %L: boot info structure\n", &bootinfo);
unsigned int i;
for (i = 0; i < COMPONENTS; i++)
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++) {
printf(" %s...", components[i].name);
top = ALIGN_UP(top, PAGE_SIZE);
memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size);
if (i > 0) {
bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top;
bootinfo.tasks[bootinfo.cnt].size = components[i].size;
bootinfo.cnt++;
}
top += components[i].size;
printf("done.\n");
// TODO: implement memcpy
int i;
for (i = 0; i < KERNEL_SIZE; i++) {
if (i % 4096 == 0)
printf(".");
((char *) KERNEL_VIRTUAL_ADDRESS)[i] = ((char *) KERNEL_START)[i];
}
printf("\nBooting the kernel...\n");
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS);
}
/boot/trunk/arch/mips32/loader/asm.h
29,11 → 29,6
#ifndef __ASM_H__
#define __ASM_H__
 
#define PAGE_SIZE 16384
#define PAGE_WIDTH 14
void jump_to_kernel(void *code) __attribute__((noreturn));
 
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))
 
void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
 
#endif
/boot/trunk/arch/mips32/loader/printf.h
38,8 → 38,8
 
typedef unsigned char __u8;
typedef unsigned short __u16;
typedef unsigned int __u32;
typedef unsigned long long __u64;
typedef unsigned long __u32;
typedef long long __u64;
 
typedef __u32 __address;
typedef __u32 __native;
/boot/trunk/arch/mips32/loader/_link.ld
0,0 → 1,24
/*
* MIPS linker script
*
*/
 
OUTPUT_FORMAT(binary)
ENTRY(start)
 
SECTIONS {
.image 0xbfc00000: AT (0) {
*(BOOTSTRAP)
*(.text);
*(.rodata);
*(.rodata.*);
*(.data); /* initialized data */
*(.sdata);
*(.sdata2);
*(.sbss);
*(.bss); /* uninitialized static variables */
*(COMMON); /* global variables */
*(.reginfo);
}
}
/boot/trunk/arch/mips32/loader/main.h
29,25 → 29,8
#ifndef __MAIN_H__
#define __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 TASKMAP_MAX_RECORDS 32
 
typedef struct {
void *addr;
unsigned int size;
} task_t;
 
typedef struct {
unsigned int cnt;
task_t tasks[TASKMAP_MAX_RECORDS];
} bootinfo_t;
 
extern int _binary_____________kernel_kernel_bin_start;
extern int _binary_____________kernel_kernel_bin_end;
extern void start(void);
extern void bootstrap(void);
 
/boot/trunk/arch/mips32/loader/Makefile
51,24 → 51,12
 
SOURCES = \
main.c \
printf.c \
msim.c \
printf.c \
asm.S \
boot.S
 
COMPONENTS = \
$(KERNELDIR)/kernel.bin \
$(USPACEDIR)/ns/ns \
$(USPACEDIR)/init/init \
$(USPACEDIR)/fb/fb \
$(USPACEDIR)/kbd/kbd \
$(USPACEDIR)/console/console \
$(USPACEDIR)/tetris/tetris \
$(USPACEDIR)/ipcc/ipcc \
$(USPACEDIR)/klog/klog
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
 
.PHONY: all clean depend
 
76,17 → 64,17
 
-include Makefile.depend
 
image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) kernel.o
$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
image.boot: depend $(OBJECTS) kernel.o
$(LD) -no-check-sections -N -T _link.ld $(OBJECTS) kernel.o -o $@
 
depend:
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
 
clean:
-rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
-rm -f $(OBJECTS) image.boot kernel.o Makefile.depend
 
_components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
./pack $(OBJCOPY) $(COMPONENTS)
kernel.o: $(KERNEL)
$(OBJCOPY) -I binary -O elf32-tradlittlemips -B mips $(KERNEL) $@
 
%.o: %.S
$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@