/SPARTAN/trunk/tools/mips/gencontext.c |
---|
0,0 → 1,43 |
#include <stdio.h> |
typedef unsigned int __u32; |
typedef __u32 pri_t; |
#define __mips_TYPES_H_ |
#include "../../arch/mips/include/context.h" |
#define FILENAME "../../arch/mips/src/context_offset.h" |
int main(void) |
{ |
FILE *f; |
struct context ctx; |
struct context *pctx = &ctx; |
f = fopen(FILENAME,"w"); |
if (!f) { |
perror(FILENAME); |
return 1; |
} |
fprintf(f, "/* This file is automatically generated by %s. */\n", __FILE__); |
fprintf(f,"#define OFFSET_SP 0x%x\n",((int)&pctx->sp) - (int )pctx); |
fprintf(f,"#define OFFSET_PC 0x%x\n",((int)&pctx->pc) - (int )pctx); |
fprintf(f,"#define OFFSET_S0 0x%x\n",((int)&pctx->s0) - (int )pctx); |
fprintf(f,"#define OFFSET_S1 0x%x\n",((int)&pctx->s1) - (int )pctx); |
fprintf(f,"#define OFFSET_S2 0x%x\n",((int)&pctx->s2) - (int )pctx); |
fprintf(f,"#define OFFSET_S3 0x%x\n",((int)&pctx->s3) - (int )pctx); |
fprintf(f,"#define OFFSET_S4 0x%x\n",((int)&pctx->s4) - (int )pctx); |
fprintf(f,"#define OFFSET_S5 0x%x\n",((int)&pctx->s5) - (int )pctx); |
fprintf(f,"#define OFFSET_S6 0x%x\n",((int)&pctx->s6) - (int )pctx); |
fprintf(f,"#define OFFSET_S7 0x%x\n",((int)&pctx->s7) - (int )pctx); |
fprintf(f,"#define OFFSET_S8 0x%x\n",((int)&pctx->s8) - (int )pctx); |
fprintf(f,"#define OFFSET_GP 0x%x\n",((int)&pctx->gp) - (int )pctx); |
fclose(f); |
return 0; |
} |
/SPARTAN/trunk/src/Makefile.config |
---|
20,7 → 20,7 |
#USERSPACE=__USERSPACE__ |
# Uncomment if you want to run in the test mode |
#TEST=__TEST__ |
TEST=__TEST__ |
TEST_FILE=test.c |
28,7 → 28,7 |
#TEST_DIR=synch/rwlock1/ |
#TEST_DIR=synch/rwlock2/ |
#TEST_DIR=synch/rwlock3/ |
#TEST_DIR=synch/rwlock4/ |
TEST_DIR=synch/rwlock4/ |
#TEST_DIR=synch/rwlock5/ |
#TEST_DIR=synch/semaphore1/ |
#TEST_DIR=synch/semaphore2/ |
/SPARTAN/trunk/src/clean.mips |
---|
1,3 → 1,5 |
#! /bin/sh |
make dist-clean ARCH=mips |
rm ../tools/mips/gencontext |
/SPARTAN/trunk/src/build.mips |
---|
1,3 → 1,8 |
#! /bin/sh |
set -e |
# Generate context_offset.h |
(cd ../tools/mips/;make gencontext;./gencontext) |
make all ARCH=mips |
/SPARTAN/trunk/src/build.amd64 |
---|
15,7 → 15,7 |
fi |
done |
for a in atomic.h ega.h fpu_context.h i8042.h i8259.h i8254.h interrupt.h bios mm/memory_init.h boot/memmap.h boot/memmapasm.h smp acpi; do |
for a in atomic.h ega.h fpu_context.h i8042.h i8259.h i8254.h interrupt.h bios mm/memory_init.h boot/memmap.h boot/memmapasm.h smp acpi barrier.h; do |
if [ \! -e amd64/include/$a ]; then |
echo ln -sf `pwd`/ia32/include/$a amd64/include/$a |
ln -sf `pwd`/ia32/include/$a amd64/include/$a |
/SPARTAN/trunk/arch/mips/boot/boot.s |
---|
File deleted |
/SPARTAN/trunk/arch/mips/boot/boot.S |
---|
0,0 → 1,43 |
# |
# Copyright (C) 2001-2004 Jakub Jermar |
# 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. |
# |
.text |
.set noat |
.set noreorder |
.set nomacro |
#include <arch/asm/boot.h> |
.global start |
start: |
lui $ra, KERNEL_STARTUP_ADDRESS >> 16 |
ori $ra, KERNEL_STARTUP_ADDRESS & 0xffff |
j $ra |
nop |
/SPARTAN/trunk/arch/mips/boot/Makefile |
---|
9,16 → 9,18 |
cp boot.bin ../../../src/load.bin |
AS=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-as |
CC=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-gcc |
LD=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-ld |
ASFLAGS=-mips2 |
ASFLAGS=-mips2 -I../../../include |
LFLAGS=--oformat=binary -mips2 -e start |
.S.o: |
$(CC) $(ASFLAGS) -c -o $@ $< |
boot.bin: boot.o |
$(LD) $(LFLAGS) boot.o -o $@ |
$(LD) $(LFLAGS) $< -o $@ |
boot.o: |
$(AS) boot.s -o $@ |
clean: |
-rm *.o *.bin |
/SPARTAN/trunk/arch/mips/include/asm/macro.h |
---|
File deleted |
/SPARTAN/trunk/arch/mips/include/asm/regname.h |
---|
0,0 → 1,61 |
#ifndef __mips_REGNAME_H_ |
#define __mips_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 index 0 |
#define random 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 config 16 |
#define lladdr 17 |
#define watchlo 18 |
#define watchhi 19 |
#define xcontext 20 |
#define debug 23 |
#define depc 24 |
#define eepc 30 |
#endif /* _REGNAME_H_ */ |
/SPARTAN/trunk/arch/mips/include/mm/page.h |
---|
29,15 → 29,15 |
#ifndef __mips_PAGE_H__ |
#define __mips_PAGE_H__ |
#include <arch/mm/tlb.h> |
#include <mm/page.h> |
#include <arch/mm/frame.h> |
#include <arch/types.h> |
#define PAGE_SIZE FRAME_SIZE |
#define KA2PA(x) (((__address) (x)) - 0x80000000) |
#define PA2KA(x) (((__address) (x)) + 0x80000000) |
#ifndef __ASM__ |
# define KA2PA(x) (((__address) (x)) - 0x80000000) |
# define PA2KA(x) (((__address) (x)) + 0x80000000) |
#else |
# define KA2PA(x) ((x) - 0x80000000) |
# define PA2KA(x) ((x) + 0x80000000) |
#endif |
/* |
* Implementation of generic 4-level page table interface. |
81,6 → 81,13 |
#define SET_PTL3_FLAGS_ARCH(ptl2, i, x) |
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x)) |
#ifndef __ASM__ |
#include <arch/mm/tlb.h> |
#include <mm/page.h> |
#include <arch/mm/frame.h> |
#include <arch/types.h> |
static inline int get_pt_flags(pte_t *pt, index_t i) |
{ |
pte_t *p = &pt[i]; |
109,4 → 116,6 |
extern pte_t *PTL0; |
#endif /* __ASM__ */ |
#endif |
/SPARTAN/trunk/arch/mips/include/context.h |
---|
29,10 → 29,44 |
#ifndef __mips_CONTEXT_H__ |
#define __mips_CONTEXT_H__ |
#include <arch/types.h> |
#define STACK_ITEM_SIZE 4 |
/* These are offsets into the register dump saved |
* on exception entry |
*/ |
#define EOFFSET_AT 0 |
#define EOFFSET_V0 4 |
#define EOFFSET_V1 8 |
#define EOFFSET_A0 12 |
#define EOFFSET_A1 16 |
#define EOFFSET_A2 20 |
#define EOFFSET_A3 24 |
#define EOFFSET_A4 28 |
#define EOFFSET_T1 32 |
#define EOFFSET_T2 36 |
#define EOFFSET_T3 40 |
#define EOFFSET_T4 44 |
#define EOFFSET_T5 48 |
#define EOFFSET_T6 52 |
#define EOFFSET_T7 56 |
#define EOFFSET_T8 60 |
#define EOFFSET_T9 64 |
#define EOFFSET_S0 68 |
#define EOFFSET_S1 72 |
#define EOFFSET_S2 76 |
#define EOFFSET_S3 80 |
#define EOFFSET_S4 84 |
#define EOFFSET_S5 88 |
#define EOFFSET_S6 92 |
#define EOFFSET_S7 96 |
#define EOFFSET_S8 100 |
#define EOFFSET_GP 104 |
#define EOFFSET_RA 108 |
#define EOFFSET_LO 112 |
#define EOFFSET_HI 116 |
#define REGISTER_SPACE 120 |
/* |
* Put one item onto the stack to support get_stack_base(). |
*/ |
39,40 → 73,34 |
#define SP_DELTA (0+STACK_ITEM_SIZE) |
#ifndef __ASM__ |
#ifndef __mips_TYPES_H_ |
# include <arch/types.h> |
#endif |
/* |
* Only save registers that must be preserved across |
* function calls. |
*/ |
struct context { |
__u32 r0; |
__u32 r1; |
__u32 r2; |
__u32 r3; |
__u32 r4; |
__u32 r5; |
__u32 r6; |
__u32 r7; |
__u32 r8; |
__u32 r9; |
__u32 r10; |
__u32 r11; |
__u32 r12; |
__u32 r13; |
__u32 r14; |
__u32 r15; |
__u32 r16; |
__u32 r17; |
__u32 r18; |
__u32 r19; |
__u32 r20; |
__u32 r21; |
__u32 r22; |
__u32 r23; |
__u32 r24; |
__u32 r25; |
__u32 r26; |
__u32 r27; |
__u32 r28; |
__u32 sp; |
__u32 r30; |
__u32 pc; |
__u32 s0; |
__u32 s1; |
__u32 s2; |
__u32 s3; |
__u32 s4; |
__u32 s5; |
__u32 s6; |
__u32 s7; |
__u32 s8; |
__u32 gp; |
__u32 pri; |
}; |
#endif /* __ASM__ */ |
#endif |
/SPARTAN/trunk/arch/mips/src/context.S |
---|
26,8 → 26,10 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
#include <arch/asm/macro.h> |
#define __ASM__ |
#include <arch/asm/regname.h> |
#include "context_offset.h" |
.text |
.set noat |
37,8 → 39,41 |
.global context_save |
.global context_restore |
.macro CONTEXT_STORE r |
sw $s0,OFFSET_S0(\r) |
sw $s1,OFFSET_S1(\r) |
sw $s2,OFFSET_S2(\r) |
sw $s3,OFFSET_S3(\r) |
sw $s4,OFFSET_S4(\r) |
sw $s5,OFFSET_S5(\r) |
sw $s6,OFFSET_S6(\r) |
sw $s7,OFFSET_S7(\r) |
sw $s8,OFFSET_S7(\r) |
sw $gp,OFFSET_GP(\r) |
sw $ra,OFFSET_PC(\r) |
sw $sp,OFFSET_SP(\r) |
.endm |
.macro CONTEXT_LOAD r |
lw $s0,OFFSET_S0(\r) |
lw $s1,OFFSET_S1(\r) |
lw $s2,OFFSET_S2(\r) |
lw $s3,OFFSET_S3(\r) |
lw $s4,OFFSET_S4(\r) |
lw $s5,OFFSET_S5(\r) |
lw $s6,OFFSET_S6(\r) |
lw $s7,OFFSET_S7(\r) |
lw $s8,OFFSET_S7(\r) |
lw $gp,OFFSET_GP(\r) |
lw $ra,OFFSET_PC(\r) |
lw $sp,OFFSET_SP(\r) |
.endm |
context_save: |
REGISTERS_STORE $4 |
CONTEXT_STORE $a0 |
# context_save returns 1 |
j $31 |
45,7 → 80,7 |
li $2, 1 |
context_restore: |
REGISTERS_LOAD $4 |
CONTEXT_LOAD $a0 |
# context_restore returns 0 |
j $31 |
/SPARTAN/trunk/arch/mips/src/mm/tlb.c |
---|
35,17 → 35,8 |
#include <symtab.h> |
void main_bsp(void); |
int bootstrap = 1; |
void tlb_refill(void) |
{ |
if (bootstrap) { |
bootstrap = 0; |
main_bsp(); |
} |
panic("tlb_refill exception\n"); |
} |
/SPARTAN/trunk/arch/mips/src/start.S |
---|
1,4 → 1,4 |
# |
# Copyright (C) 2001-2004 Jakub Jermar |
# All rights reserved. |
# |
26,10 → 26,13 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
#include <arch/asm/macro.h> |
#define STACK_SPACE 128 |
#define __ASM__ |
#include <arch/asm/regname.h> |
#include <arch/mm/page.h> |
#include <arch/asm/boot.h> |
#include <arch/context.h> |
.text |
.set noat |
41,8 → 44,79 |
.global cache_error_entry |
.global exception_entry |
.macro REGISTERS_STORE r |
sw $at,EOFFSET_AT(\r) |
sw $v0,EOFFSET_V0(\r) |
sw $v1,EOFFSET_V1(\r) |
sw $a0,EOFFSET_A0(\r) |
sw $a1,EOFFSET_A1(\r) |
sw $a2,EOFFSET_A2(\r) |
sw $a3,EOFFSET_A3(\r) |
sw $t0,EOFFSET_A4(\r) |
sw $t1,EOFFSET_T1(\r) |
sw $t2,EOFFSET_T2(\r) |
sw $t3,EOFFSET_T3(\r) |
sw $t4,EOFFSET_T4(\r) |
sw $t5,EOFFSET_T5(\r) |
sw $t6,EOFFSET_T6(\r) |
sw $t7,EOFFSET_T7(\r) |
sw $t8,EOFFSET_T8(\r) |
sw $t9,EOFFSET_T9(\r) |
sw $s0,EOFFSET_S0(\r) |
sw $s1,EOFFSET_S1(\r) |
sw $s2,EOFFSET_S2(\r) |
sw $s3,EOFFSET_S3(\r) |
sw $s4,EOFFSET_S4(\r) |
sw $s5,EOFFSET_S5(\r) |
sw $s6,EOFFSET_S6(\r) |
sw $s7,EOFFSET_S7(\r) |
sw $s8,EOFFSET_S8(\r) |
sw $gp,EOFFSET_GP(\r) |
sw $ra,EOFFSET_RA(\r) |
mflo $k0 |
mfhi $k1 |
sw $k0,EOFFSET_LO(\r) |
sw $k1,EOFFSET_HI(\r) |
.endm |
.macro REGISTERS_LOAD r |
lw $at,EOFFSET_AT(\r) |
lw $v0,EOFFSET_V0(\r) |
lw $v1,EOFFSET_V1(\r) |
lw $a0,EOFFSET_A0(\r) |
lw $a1,EOFFSET_A1(\r) |
lw $a2,EOFFSET_A2(\r) |
lw $a3,EOFFSET_A3(\r) |
lw $t0,EOFFSET_A4(\r) |
lw $t1,EOFFSET_T1(\r) |
lw $t2,EOFFSET_T2(\r) |
lw $t3,EOFFSET_T3(\r) |
lw $t4,EOFFSET_T4(\r) |
lw $t5,EOFFSET_T5(\r) |
lw $t6,EOFFSET_T6(\r) |
lw $t7,EOFFSET_T7(\r) |
lw $t8,EOFFSET_T8(\r) |
lw $t9,EOFFSET_T9(\r) |
lw $s0,EOFFSET_S0(\r) |
lw $s1,EOFFSET_S1(\r) |
lw $s2,EOFFSET_S2(\r) |
lw $s3,EOFFSET_S3(\r) |
lw $s4,EOFFSET_S4(\r) |
lw $s5,EOFFSET_S5(\r) |
lw $s6,EOFFSET_S6(\r) |
lw $s7,EOFFSET_S7(\r) |
lw $s8,EOFFSET_S8(\r) |
lw $gp,EOFFSET_GP(\r) |
lw $ra,EOFFSET_RA(\r) |
lw $k0,EOFFSET_LO(\r) |
lw $k1,EOFFSET_HI(\r) |
mtlo $k0 |
mthi $k1 |
.endm |
.org 0x0 |
kernel_image_start: |
tlb_refill_entry: |
j tlb_refill_handler |
nop |
55,37 → 129,55 |
.org 0x180 |
exception_entry: |
exception_handler: |
sub $29, STACK_SPACE |
REGISTERS_STORE $29 |
sub $sp, REGISTER_SPACE |
REGISTERS_STORE $sp |
jal exception |
nop |
REGISTERS_LOAD $29 |
add $29, STACK_SPACE |
REGISTERS_LOAD $sp |
add $sp, REGISTER_SPACE |
eret |
nop |
.org KA2PA(0x80000300) |
kernel_image_start: |
/* Load temporary stack */ |
lui $sp, (TEMP_STACK_START + TEMP_STACK_SIZE) >> 16 |
ori $sp, (TEMP_STACK_START + TEMP_STACK_SIZE) & 0xffff |
/* Not sure about this, but might be needed for PIC code???? */ |
lui $gp, 0x8000 |
jal main_bsp |
nop |
.org KA2PA(TEMP_STACK_START) |
.space TEMP_STACK_SIZE |
tlb_refill_handler: |
sub $29, STACK_SPACE |
REGISTERS_STORE $29 |
sub $sp, REGISTER_SPACE |
REGISTERS_STORE $sp |
jal tlb_refill |
nop |
REGISTERS_LOAD $29 |
add $29, STACK_SPACE |
REGISTERS_LOAD $sp |
add $sp, REGISTER_SPACE |
eret |
nop |
cache_error_handler: |
sub $29, STACK_SPACE |
REGISTERS_STORE $29 |
sub $sp, REGISTER_SPACE |
REGISTERS_STORE $sp |
jal cache_error |
nop |
REGISTERS_LOAD $29 |
add $29, STACK_SPACE |
REGISTERS_LOAD $sp |
add $sp, REGISTER_SPACE |
eret |
nop |
/SPARTAN/trunk/arch/amd64/include/barrier.h |
---|
File deleted |
/SPARTAN/trunk/arch/amd64/include/arch.h |
---|
1,5 → 1,5 |
/* |
* Copyright (C) 2005 Martin Decky |
* Copyright (C) 2005 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
/SPARTAN/trunk/arch/amd64/include/faddr.h |
---|
1,5 → 1,5 |
/* |
* Copyright (C) 2005 Martin Decky |
* Copyright (C) 2005 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
/SPARTAN/trunk/arch/amd64/include/context.h |
---|
1,5 → 1,5 |
/* |
* Copyright (C) 2005 Martin Decky |
* Copyright (C) 2005 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
40,6 → 40,9 |
*/ |
#define SP_DELTA 16 |
/* We include only registers that must be preserved |
* during function call |
*/ |
struct context { |
__u64 sp; |
__u64 pc; |
/SPARTAN/trunk/arch/amd64/include/thread.h |
---|
1,5 → 1,5 |
/* |
* Copyright (C) 2005 Martin Decky |
* Copyright (C) 2005 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |