Changeset 25f089b in mainline
- Timestamp:
- 2006-06-10T11:04:11Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e5cd717
- Parents:
- 2d1a1d4
- Location:
- arch/mips32
- Files:
-
- 1 added
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/mips32/Makefile.inc
r2d1a1d4 r25f089b 30 30 31 31 image.boot: kernel uspace 32 make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNEL =../../../$(KERNELDIR)/kernel.bin32 make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) 33 33 cp arch/$(ARCH)/loader/image.boot image.boot 34 34 -
arch/mips32/loader/Makefile
r2d1a1d4 r25f089b 52 52 SOURCES = \ 53 53 main.c \ 54 msim.c \ 54 55 printf.c \ 55 msim.c \56 56 asm.S \ 57 57 boot.S 58 58 59 COMPONENTS = \ 60 $(KERNELDIR)/kernel.bin \ 61 $(USPACEDIR)/ns/ns \ 62 $(USPACEDIR)/init/init \ 63 $(USPACEDIR)/fb/fb \ 64 $(USPACEDIR)/kbd/kbd \ 65 $(USPACEDIR)/console/console \ 66 $(USPACEDIR)/tetris/tetris \ 67 $(USPACEDIR)/ipcc/ipcc \ 68 $(USPACEDIR)/klog/klog 69 59 70 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 71 COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS)))) 60 72 61 73 .PHONY: all clean depend … … 65 77 -include Makefile.depend 66 78 67 image.boot: depend $(OBJECTS) kernel.o68 $(LD) -no-check-sections -N -T _link.ld $( OBJECTS) kernel.o-o $@79 image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) kernel.o 80 $(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@ 69 81 70 82 depend: … … 72 84 73 85 clean: 74 -rm -f $(OBJECTS) image.boot kernel.oMakefile.depend86 -rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend 75 87 76 kernel.o: $(KERNEL)77 $(OBJCOPY) -I binary -O elf32-tradlittlemips -B mips $(KERNEL) $@88 _components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) 89 ./pack $(OBJCOPY) $(COMPONENTS) 78 90 79 91 %.o: %.S -
arch/mips32/loader/asm.S
r2d1a1d4 r25f089b 36 36 37 37 .global halt 38 .global memcpy 38 39 .global jump_to_kernel 39 40 … … 41 42 b halt 42 43 nop 44 45 memcpy: 46 addiu $v0,$a1,3 47 li $v1,-4 # 0xfffffffffffffffc 48 and $v0,$v0,$v1 49 beq $a1,$v0,3f 50 move $t0,$a0 51 52 0: 53 beq $a2,$zero,2f 54 move $a3,$zero 55 56 1: 57 addu $v0,$a1,$a3 58 lbu $a0,0($v0) 59 addu $v1,$t0,$a3 60 addiu $a3,$a3,1 61 bne $a3,$a2,1b 62 sb $a0,0($v1) 63 64 2: 65 jr $ra 66 move $v0,$a1 67 68 3: 69 addiu $v0,$a0,3 70 and $v0,$v0,$v1 71 bne $a0,$v0,0b 72 srl $t1,$a2,2 73 74 beq $t1,$zero,5f 75 move $a3,$zero 76 77 move $a3,$zero 78 move $a0,$zero 79 4: 80 addu $v0,$a1,$a0 81 lw $v1,0($v0) 82 addiu $a3,$a3,1 83 addu $v0,$t0,$a0 84 sw $v1,0($v0) 85 bne $a3,$t1,4b 86 addiu $a0,$a0,4 87 88 5: 89 andi $a2,$a2,0x3 90 beq $a2,$zero,2b 91 nop 92 93 sll $v0,$a3,2 94 addu $t1,$v0,$t0 95 move $a3,$zero 96 addu $t0,$v0,$a1 97 6: 98 addu $v0,$t0,$a3 99 lbu $a0,0($v0) 100 addu $v1,$t1,$a3 101 addiu $a3,$a3,1 102 bne $a3,$a2,6b 103 sb $a0,0($v1) 104 105 jr $ra 106 move $v0,$a1 43 107 44 108 jump_to_kernel: -
arch/mips32/loader/asm.h
r2d1a1d4 r25f089b 30 30 #define __ASM_H__ 31 31 32 void jump_to_kernel(void *code) __attribute__((noreturn)); 32 #define PAGE_SIZE 16384 33 #define PAGE_WIDTH 14 34 35 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 36 37 void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn)); 33 38 34 39 #endif -
arch/mips32/loader/boot.S
r2d1a1d4 r25f089b 29 29 #include "regname.h" 30 30 31 #define INITIAL_STACK 0x 1000031 #define INITIAL_STACK 0x40000 32 32 33 33 .set noat … … 40 40 start: 41 41 lui $sp, INITIAL_STACK >> 16 42 ori $sp, $sp, INITIAL_STACK & 0xffff 43 42 ori $sp, $sp, INITIAL_STACK & 0xffff 43 44 44 j bootstrap 45 45 nop -
arch/mips32/loader/main.c
r2d1a1d4 r25f089b 31 31 #include "msim.h" 32 32 #include "asm.h" 33 #include "_components.h" 33 34 34 35 #define KERNEL_VIRTUAL_ADDRESS 0x80100000 35 #define KERNEL_START &_binary_____________kernel_kernel_bin_start36 #define KERNEL_END &_binary_____________kernel_kernel_bin_end37 #define KERNEL_SIZE ((unsigned int) KERNEL_END - (unsigned int) KERNEL_START)38 36 39 37 void bootstrap(void) 40 38 { 41 39 printf("HelenOS MIPS Bootloader\n"); 42 printf("loaded at %L\n", &start);43 printf("kernel memory at %L (size %d bytes)\n", KERNEL_VIRTUAL_ADDRESS, KERNEL_SIZE);44 40 45 // TODO: implement memcpy 46 int i; 47 for (i = 0; i < KERNEL_SIZE; i++) { 48 if (i % 4096 == 0) 49 printf("."); 50 ((char *) KERNEL_VIRTUAL_ADDRESS)[i] = ((char *) KERNEL_START)[i]; 41 component_t components[COMPONENTS]; 42 bootinfo_t bootinfo; 43 init_components(components); 44 45 printf("\nMemory statistics\n"); 46 printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS); 47 printf(" %L: boot info structure\n", &bootinfo); 48 49 unsigned int i; 50 for (i = 0; i < COMPONENTS; i++) 51 printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size); 52 53 printf("\nCopying components\n"); 54 unsigned int top = 0; 55 bootinfo.cnt = 0; 56 for (i = 0; i < COMPONENTS; i++) { 57 printf(" %s...", components[i].name); 58 top = ALIGN_UP(top, PAGE_SIZE); 59 memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size); 60 if (i > 0) { 61 bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top; 62 bootinfo.tasks[bootinfo.cnt].size = components[i].size; 63 bootinfo.cnt++; 64 } 65 top += components[i].size; 66 printf("done.\n"); 51 67 } 52 68 53 69 printf("\nBooting the kernel...\n"); 54 55 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS); 70 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo)); 56 71 } -
arch/mips32/loader/main.h
r2d1a1d4 r25f089b 30 30 #define __MAIN_H__ 31 31 32 extern int _binary_____________kernel_kernel_bin_start; 33 extern int _binary_____________kernel_kernel_bin_end; 32 /** Align to the nearest higher address. 33 * 34 * @param addr Address or size to be aligned. 35 * @param align Size of alignment, must be power of 2. 36 */ 37 #define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1)) 38 39 #define TASKMAP_MAX_RECORDS 32 40 41 typedef struct { 42 void *addr; 43 unsigned int size; 44 } task_t; 45 46 typedef struct { 47 unsigned int cnt; 48 task_t tasks[TASKMAP_MAX_RECORDS]; 49 } bootinfo_t; 50 34 51 extern void start(void); 35 52 extern void bootstrap(void); -
arch/mips32/loader/printf.h
r2d1a1d4 r25f089b 39 39 typedef unsigned char __u8; 40 40 typedef unsigned short __u16; 41 typedef unsigned long__u32;42 typedef long long __u64;41 typedef unsigned int __u32; 42 typedef unsigned long long __u64; 43 43 44 44 typedef __u32 __address;
Note:
See TracChangeset
for help on using the changeset viewer.