Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1771 → Rev 1764

/boot/trunk/arch/mips32/loader/ofw.c
File deleted
/boot/trunk/arch/mips32/loader/main.c
28,14 → 28,15
 
#include "main.h"
#include <printf.h>
#include "msim.h"
#include "asm.h"
#include "_components.h"
 
#define KERNEL_VIRTUAL_ADDRESS 0x400000
#define KERNEL_VIRTUAL_ADDRESS 0x80100000
 
void bootstrap(void)
{
printf("HelenOS SPARC64 Bootloader\n");
printf("HelenOS MIPS Bootloader\n");
component_t components[COMPONENTS];
bootinfo_t bootinfo;
/boot/trunk/arch/mips32/loader/msim.c
0,0 → 1,40
/*
* Copyright (C) 2006 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "msim.h"
#include <printf.h>
 
#define MSIM_VIDEORAM 0xB0000000
 
void write(const char *str, const int len)
{
int i;
for (i = 0; i < len; i++)
*((char *) MSIM_VIDEORAM) = str[i];
}
/boot/trunk/arch/mips32/loader/types.h
36,9 → 36,9
typedef unsigned char __u8;
typedef unsigned short __u16;
typedef unsigned int __u32;
typedef unsigned long __u64;
typedef unsigned long long __u64;
 
typedef __u64 __address;
typedef __u64 __native;
typedef __u32 __address;
typedef __u32 __native;
 
#endif
/boot/trunk/arch/mips32/loader/Makefile
29,8 → 29,8
## Toolchain configuration
#
 
TARGET = sparc64-linux-gnu
TOOLCHAIN_DIR = /usr/local/sparc64/bin
TARGET = mipsel-linux-gnu
TOOLCHAIN_DIR = /usr/local/mipsel/bin
 
ifeq ($(COMPILER),native)
CC = gcc
46,18 → 46,25
OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
endif
 
CFLAGS = -I. -I../../../generic -I../../../genarch -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=ultrasparc -m64
CFLAGS = -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
 
SOURCES = \
main.c \
msim.c \
../../../generic/printf.c \
../../../genarch/ofw.c \
ofw.c \
asm.S \
boot.S
 
COMPONENTS = \
$(KERNELDIR)/kernel.bin
$(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))))
/boot/trunk/arch/mips32/loader/msim.h
0,0 → 1,37
/*
* Copyright (C) 2006 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __MSIM_H__
#define __MSIM_H__
 
extern void init(void);
extern void halt(void);
 
extern void *translate(void *addr);
 
#endif
/boot/trunk/arch/mips32/loader/pack
30,27 → 30,43
 
[ "$#" -lt 1 ] && exit 1
 
OBJCOPY="$1"
case "$1" in
"binary")
BFD="binary"
;;
"ecoff")
BFD="ecoff-littlemips"
;;
*)
echo "Undefined image format" >&1
exit 1
;;
esac
 
OBJCOPY="$2"
LINK="_link.ld"
HEADER="_components.h"
 
shift
shift 2
 
echo 'OUTPUT_FORMAT("elf64-sparc")
echo "OUTPUT_FORMAT(\"${BFD}\")
ENTRY(start)
 
SECTIONS {
.boot 0x4000: AT (0) {
.boot 0xbfc00000: AT (0) {
*(BOOTSTRAP);
*(.text);
*(.rodata);
*(.rodata.*);
*(.data); /* initialized data */
*(.data); /* initialized data */
*(.sdata);
*(.sdata2);
*(.sbss);
*(.bss); /* uninitialized static variables */
*(COMMON);' > "$LINK"
*(.scommon);
*(.bss); /* uninitialized static variables */
*(COMMON); /* global variables */
*(.reginfo);" > "$LINK"
 
echo '#ifndef ___COMPONENTS_H__
#define ___COMPONENTS_H__
74,7 → 90,7
echo "$TASK -> $OBJECT"
echo "
. = ALIGN(8192);
. = ALIGN(4096);
*(.${BASENAME}_image);" >> "$LINK"
echo "
85,7 → 101,7
#define ${MACRO}_END ((void *) &${SYMBOL}_end)
#define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER"
"$OBJCOPY" -I binary -O elf64-sparc -B sparc --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT"
"$OBJCOPY" -I binary -O elf32-tradlittlemips -B mips --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT"
DATA="${DATA}
components[$COUNT].name = \"${BASENAME}\";
/boot/trunk/arch/mips32/loader/boot.S
26,13 → 26,20
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
#define INITIAL_STACK 0x0
#include "regname.h"
 
.section BOOTSTRAP, "ax"
#define INITIAL_STACK 0x80040000
 
.set noat
.set noreorder
.set nomacro
 
.section BOOTSTRAP
 
.global start
start:
# TODO: set initial stack
lui $sp, INITIAL_STACK >> 16
ori $sp, $sp, INITIAL_STACK & 0xffff
b bootstrap
j bootstrap
nop
/boot/trunk/arch/mips32/loader/asm.S
26,6 → 26,12
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
#include "regname.h"
 
.set noat
.set noreorder
.set nomacro
 
.text
 
.global halt
37,9 → 43,69
nop
memcpy:
b 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:
b jump_to_kernel
# .word 0x39
j $a0
nop
/boot/trunk/arch/mips32/loader/asm.h
29,12 → 29,11
#ifndef __ASM_H__
#define __ASM_H__
 
#define PAGE_SIZE 8192
#define PAGE_WIDTH 13
#define PAGE_SIZE 16384
#define PAGE_WIDTH 14
 
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))
 
extern void halt(void);
extern void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
 
#endif
/boot/trunk/arch/mips32/loader/regname.h
0,0 → 1,89
/*
* Copyright (C) 2005 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __mips32_REGNAME_H_
#define __mips32_REGNAME_H_
 
#define zero 0
#define at 1
#define v0 2
#define v1 3
#define a0 4
#define a1 5
#define a2 6
#define a3 7
#define t0 8
#define t1 9
#define t2 10
#define t3 11
#define t4 12
#define t5 13
#define t6 14
#define t7 15
#define s0 16
#define s1 17
#define s2 18
#define s3 19
#define s4 20
#define s5 21
#define s6 22
#define s7 23
#define t8 24
#define t9 25
#define k0 26
#define k1 27
#define gp 28
#define sp 29
#define s8 30
#define ra 31
 
#define rindex 0
#define rrandom 1
#define entrylo0 2
#define entrylo1 3
#define context 4
#define pagemask 5
#define wired 6
#define badvaddr 8
#define count 9
#define entryhi 10
#define compare 11
#define status 12
#define cause 13
#define epc 14
#define rconfig 16
#define lladdr 17
#define watchlo 18
#define watchhi 19
#define xcontext 20
#define rdebug 23
#define depc 24
#define eepc 30
 
 
#endif /* _REGNAME_H_ */