Changeset 25f089b in mainline


Ignore:
Timestamp:
2006-06-10T11:04:11Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e5cd717
Parents:
2d1a1d4
Message:

mips piggybacker

Location:
arch/mips32
Files:
1 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • arch/mips32/Makefile.inc

    r2d1a1d4 r25f089b  
    3030
    3131image.boot: kernel uspace
    32         make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNEL=../../../$(KERNELDIR)/kernel.bin
     32        make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
    3333        cp arch/$(ARCH)/loader/image.boot image.boot
    3434
  • arch/mips32/loader/Makefile

    r2d1a1d4 r25f089b  
    5252SOURCES = \
    5353        main.c \
     54        msim.c \
    5455        printf.c \
    55         msim.c \
    5656        asm.S \
    5757        boot.S
    5858
     59COMPONENTS = \
     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
    5970OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     71COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
    6072
    6173.PHONY: all clean depend
     
    6577-include Makefile.depend
    6678
    67 image.boot: depend $(OBJECTS) kernel.o
    68         $(LD) -no-check-sections -N -T _link.ld $(OBJECTS) kernel.o -o $@
     79image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) kernel.o
     80        $(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
    6981
    7082depend:
     
    7284
    7385clean:
    74         -rm -f $(OBJECTS) image.boot kernel.o Makefile.depend
     86        -rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
    7587
    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)
    7890
    7991%.o: %.S
  • arch/mips32/loader/asm.S

    r2d1a1d4 r25f089b  
    3636
    3737.global halt
     38.global memcpy
    3839.global jump_to_kernel
    3940
     
    4142        b halt
    4243        nop
     44       
     45memcpy:
     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
     520:
     53        beq     $a2,$zero,2f
     54        move    $a3,$zero
     55
     561:
     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
     642:
     65        jr      $ra
     66        move    $v0,$a1
     67
     683:
     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
     794:
     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
     885:
     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
     976:
     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
    43107
    44108jump_to_kernel:
  • arch/mips32/loader/asm.h

    r2d1a1d4 r25f089b  
    3030#define __ASM_H__
    3131
    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
     37void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
    3338
    3439#endif
  • arch/mips32/loader/boot.S

    r2d1a1d4 r25f089b  
    2929#include "regname.h"
    3030
    31 #define INITIAL_STACK 0x10000
     31#define INITIAL_STACK 0x40000
    3232
    3333.set noat
     
    4040start:
    4141        lui $sp, INITIAL_STACK >> 16
    42     ori $sp, $sp, INITIAL_STACK & 0xffff       
    43 
     42        ori $sp, $sp, INITIAL_STACK & 0xffff
     43       
    4444        j bootstrap
    4545        nop
  • arch/mips32/loader/main.c

    r2d1a1d4 r25f089b  
    3131#include "msim.h"
    3232#include "asm.h"
     33#include "_components.h"
    3334
    3435#define KERNEL_VIRTUAL_ADDRESS 0x80100000
    35 #define KERNEL_START &_binary_____________kernel_kernel_bin_start
    36 #define KERNEL_END &_binary_____________kernel_kernel_bin_end
    37 #define KERNEL_SIZE ((unsigned int) KERNEL_END - (unsigned int) KERNEL_START)
    3836
    3937void bootstrap(void)
    4038{
    4139        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);
    4440       
    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");
    5167        }
    5268       
    5369        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));
    5671}
  • arch/mips32/loader/main.h

    r2d1a1d4 r25f089b  
    3030#define __MAIN_H__
    3131
    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
     41typedef struct {
     42        void *addr;
     43        unsigned int size;
     44} task_t;
     45
     46typedef struct {
     47        unsigned int cnt;
     48        task_t tasks[TASKMAP_MAX_RECORDS];
     49} bootinfo_t;
     50
    3451extern void start(void);
    3552extern void bootstrap(void);
  • arch/mips32/loader/printf.h

    r2d1a1d4 r25f089b  
    3939typedef unsigned char __u8;
    4040typedef unsigned short __u16;
    41 typedef unsigned long __u32;
    42 typedef long long __u64;
     41typedef unsigned int __u32;
     42typedef unsigned long long __u64;
    4343
    4444typedef __u32 __address;
Note: See TracChangeset for help on using the changeset viewer.