Subversion Repositories HelenOS-historic

Compare Revisions

No changes between revisions

Ignore whitespace Rev 331 → Rev 332

/SPARTAN/trunk/contrib/toolchain/toolchain.mips.sh
File deleted
Property changes:
Deleted: svn:executable
-*
\ No newline at end of property
/SPARTAN/trunk/contrib/toolchain/toolchain.mipsel.sh
0,0 → 1,84
#!/bin/bash
 
# Cross-Compiler Toolchain for ${PLATFORM}
# by Martin Decky <martin@decky.cz>
#
# GPL'ed, copyleft
#
 
 
check_error() {
if [ "$1" -ne "0" ]; then
echo
echo "Script failed: $2"
exit
fi
}
 
BINUTILS_VERSION="2.16"
GCC_VERSION="4.0.1"
 
BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
GCC="gcc-core-${GCC_VERSION}.tar.bz2"
 
BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
 
PLATFORM="mipsel"
WORKDIR=`pwd`
TARGET="${PLATFORM}-linux-gnu"
HOST="i686-pc-linux-gnu"
PREFIX="/usr/local/${PLATFORM}"
BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
OBJDIR="${WORKDIR}/gcc-obj"
 
echo ">>> Downloading tarballs"
 
if [ ! -f "${BINUTILS}" ]; then
wget -c "${BINUTILS_SOURCE}${BINUTILS}"
check_error $? "Error downloading binutils."
fi
if [ ! -f "${GCC}" ]; then
wget -c "${GCC_SOURCE}${GCC}"
check_error $? "Error downloading GCC."
fi
 
echo ">>> Creating destionation directory"
if [ ! -d "${PREFIX}" ]; then
mkdir -p "${PREFIX}"
test -d "${PREFIX}"
check_error $? "Unable to create ${PREFIX}."
fi
 
echo ">>> Creating GCC work directory"
if [ ! -d "${OBJDIR}" ]; then
mkdir -p "${OBJDIR}"
test -d "${OBJDIR}"
check_error $? "Unable to create ${OBJDIR}."
fi
 
echo ">>> Unpacking tarballs"
tar -xvzf "${BINUTILS}"
check_error $? "Error unpacking binutils."
tar -xvjf "${GCC}"
check_error $? "Error unpacking GCC."
 
echo ">>> Compiling and installing binutils"
cd "${BINUTILSDIR}"
check_error $? "Change directory failed."
./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
check_error $? "Error configuring binutils."
make all install
check_error $? "Error compiling/installing binutils."
 
echo ">>> Compiling and installing GCC"
cd "${OBJDIR}"
check_error $? "Change directory failed."
"${GCCDIR}/configure" "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c --disable-multilib --disable-libgcj --without-headers --disable-shared
check_error $? "Error configuring GCC."
PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
check_error $? "Error compiling/installing GCC."
 
echo
echo ">>> Cross-compiler for ${TARGET} installed."
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/SPARTAN/trunk/contrib/toolchain/toolchain.mipseb.sh
0,0 → 1,84
#!/bin/bash
 
# Cross-Compiler Toolchain for ${PLATFORM}
# by Martin Decky <martin@decky.cz>
#
# GPL'ed, copyleft
#
 
 
check_error() {
if [ "$1" -ne "0" ]; then
echo
echo "Script failed: $2"
exit
fi
}
 
BINUTILS_VERSION="2.16"
GCC_VERSION="4.0.1"
 
BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
GCC="gcc-core-${GCC_VERSION}.tar.bz2"
 
BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
 
PLATFORM="mips"
WORKDIR=`pwd`
TARGET="${PLATFORM}-sgi-irix5"
HOST="i686-pc-linux-gnu"
PREFIX="/usr/local/${PLATFORM}"
BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
OBJDIR="${WORKDIR}/gcc-obj"
 
echo ">>> Downloading tarballs"
 
if [ ! -f "${BINUTILS}" ]; then
wget -c "${BINUTILS_SOURCE}${BINUTILS}"
check_error $? "Error downloading binutils."
fi
if [ ! -f "${GCC}" ]; then
wget -c "${GCC_SOURCE}${GCC}"
check_error $? "Error downloading GCC."
fi
 
echo ">>> Creating destionation directory"
if [ ! -d "${PREFIX}" ]; then
mkdir -p "${PREFIX}"
test -d "${PREFIX}"
check_error $? "Unable to create ${PREFIX}."
fi
 
echo ">>> Creating GCC work directory"
if [ ! -d "${OBJDIR}" ]; then
mkdir -p "${OBJDIR}"
test -d "${OBJDIR}"
check_error $? "Unable to create ${OBJDIR}."
fi
 
echo ">>> Unpacking tarballs"
tar -xvzf "${BINUTILS}"
check_error $? "Error unpacking binutils."
tar -xvjf "${GCC}"
check_error $? "Error unpacking GCC."
 
echo ">>> Compiling and installing binutils"
cd "${BINUTILSDIR}"
check_error $? "Change directory failed."
./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
check_error $? "Error configuring binutils."
make all install
check_error $? "Error compiling/installing binutils."
 
echo ">>> Compiling and installing GCC"
cd "${OBJDIR}"
check_error $? "Change directory failed."
"${GCCDIR}/configure" "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c --disable-multilib --disable-libgcj --without-headers --disable-shared
check_error $? "Error configuring GCC."
PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
check_error $? "Error compiling/installing GCC."
 
echo
echo ">>> Cross-compiler for ${TARGET} installed."
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/SPARTAN/trunk/tools/genmap.py
8,7 → 8,7
symtabfmt = "<Q%ds" % (MAXSTRING+1)
 
 
funcline = re.compile(r'([0-9a-f]+)\s+[lg]\s+F\s+\.text\s+([0-9a-f]+)\s+(.*)$')
funcline = re.compile(r'([0-9a-f]+)\s+[lg]\s+.\s+\.text\s+([0-9a-f]+)\s+(.*)$')
bssline = re.compile(r'([0-9a-f]+)\s+[lg]\s+[a-zA-Z]\s+\.bss\s+([0-9a-f]+)\s+(.*)$')
dataline = re.compile(r'([0-9a-f]+)\s+[lg]\s+[a-zA-Z]\s+\.data\s+([0-9a-f]+)\s+(.*)$')
fileexp = re.compile(r'([^\s]+):\s+file format')
/SPARTAN/trunk/src/debug/symtab.c
39,10 → 39,10
count_t i;
 
for (i=1;symbol_table[i].address_le;++i) {
if (addr < native_le2host(symbol_table[i].address_le))
if (addr < u64_le2host(symbol_table[i].address_le))
break;
}
if (addr >= native_le2host(symbol_table[i-1].address_le))
if (addr >= u64_le2host(symbol_table[i-1].address_le))
return symbol_table[i-1].symbol_name;
return NULL;
}
/SPARTAN/trunk/arch/ppc/include/byteorder.h
40,6 → 40,17
* @return Result in host endianess.
*
*/
static inline __u64 u64_le2host(__u64 n)
{
return ((n & 0xff) << 56) |
((n & 0xff00) << 40) |
((n & 0xff0000) << 24) |
((n & 0xff000000LL) << 8) |
((n & 0xff00000000LL) >>8) |
((n & 0xff0000000000LL) >> 24) |
((n & 0xff000000000000LL) >> 40) |
((n & 0xff00000000000000LL) >> 56);
}
static inline __native native_le2host(__native n)
{
__address v;
/SPARTAN/trunk/arch/ia64/include/byteorder.h
30,6 → 30,7
#define __ia64_BYTEORDER_H__
 
/* IA-64 is little-endian */
#define native_le2host(n) n
#define native_le2host(n) (n)
#define u64_le2host(n) (n)
 
#endif
/SPARTAN/trunk/arch/mips/_link.ld.in
33,6 → 33,11
*(.rodata*);
*(.sdata);
*(.reginfo);
/* Unfortunately IRIX does not allow us
* to include this as a last section :-(
* BSS/SBSS addresses will be wrong */
symbol_table = .;
*(symtab.*);
}
_gp = . + 0x8000;
.lit8 : { *(.lit8) }
46,10 → 51,6
*(COMMON); /* global variables */
}
 
mysymtab : {
symbol_table = .;
*(symtab.*); /* Symbol table, must be LAST symbol!*/
}
kdata_end = .;
 
/DISCARD/ : {
/SPARTAN/trunk/arch/mips/include/interrupt.h
29,8 → 29,10
#ifndef __INTERRUPT_H__
#define __INTERRUPT_H__
 
#include <arch/exception.h>
 
#define TIMER_INTERRUPT 7
 
extern void interrupt(void);
extern void interrupt(struct exception_regdump *pstate);
 
#endif
/SPARTAN/trunk/arch/mips/include/byteorder.h
31,6 → 31,18
 
/* MIPS is little-endian */
#ifdef BIG_ENDIAN
static inline __u64 u64_le2host(__u64 n)
{
return ((n & 0xff) << 56) |
((n & 0xff00) << 40) |
((n & 0xff0000) << 24) |
((n & 0xff000000LL) << 8) |
((n & 0xff00000000LL) >>8) |
((n & 0xff0000000000LL) >> 24) |
((n & 0xff000000000000LL) >> 40) |
((n & 0xff00000000000000LL) >> 56);
}
 
static inline __native native_le2host(__native n)
{
return ((n & 0xff) << 24) |
39,7 → 51,8
((n & 0xff000000) >> 24);
}
#else
# define native_le2host(n) n
# define native_le2host(n) (n)
# define u64_le2host(n) (n)
#endif
 
#endif
/SPARTAN/trunk/arch/mips/include/console.h
38,7 → 38,4
 
void console_init(void);
 
extern int bios_write(int fd, const char *buf, int size, int *cnt);
 
 
#endif
/SPARTAN/trunk/arch/mips/include/types.h
32,12 → 32,17
#define NULL 0
 
typedef signed char __s8;
typedef unsigned char __u8;
 
typedef unsigned char __u8;
typedef signed short __s16;
typedef unsigned short __u16;
 
typedef unsigned long __u32;
typedef long long __u64;
typedef signed long __s32;
 
typedef unsigned long long __u64;
typedef signed long long __s64;
 
typedef __u32 __address;
 
typedef __u32 pri_t;
/SPARTAN/trunk/arch/mips/include/drivers/arc.h
0,0 → 1,139
/*
* 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 __mips_ARC_H_
#define __mips_ARC_H_
 
#include <arch/types.h>
 
#define ARC_BASE_ADDR 0x1000;
#define ARC_MAGIC 0x53435241
 
typedef struct {
} arc_component;
 
typedef struct {
__u16 year;
__u16 month;
__u16 day;
__u16 hour;
__u16 minutes;
__u16 seconds;
__u16 mseconds;
} arc_timeinfo ;
 
/* This is the SGI block structure, WinNT has it different */
typedef enum {
ExceptionBlock,
SystemParameterBlock,
FreeContiguous,
FreeMemory,
BadMemory,
LoadedProgram,
FirmwareTemporary,
FirmwarePermanent
}arc_memorytype_t;
 
typedef struct {
arc_memorytype_t type;
__u32 basepage; /* *4096 = baseaddr */
__u32 basecount;
}arc_memdescriptor_t;
 
typedef struct {
char vendorid[8];
char prodid[8];
}arc_sysid_t;
 
typedef struct {
long (*load)(void); /* ... */
long (*invoke)(__u32 eaddr,__u32 saddr,__u32 argc,char **argv,
char **envp);
long (*execute)(char *path,__u32 argc,char **argv,char **envp);
void (*halt)(void);
void (*powerdown)(void);
void (*restart)(void);
void (*reboot)(void);
void (*enterinteractivemode)(void);
long (*reserved)(void);
/* 10 */
arc_component * (*getpeer)(arc_component *c);
arc_component * (*getchild)(arc_component *c);
arc_component * (*getparent)(arc_component *c);
long (*getconfigurationdata)(void *configdata, arc_component *c);
long (*addchild)(arc_component *c, arc_component *template,
void *configdata);
long (*deletecomponet)(arc_component *current);
long (*getcomponent)(char *path);
long (*saveconfiguration)(void);
arc_sysid_t (*getsystemid)(void);
arc_memdescriptor_t * (*getmemorydescriptor)(arc_memdescriptor_t *cur);
/* 20 */
long (*reserved2)(void);
arc_timeinfo * (*gettime)(void);
__u32 (*getrelativetime)(void);
long (*getdirectoryentry)();
long (*open)(void); /* ... */
long (*close)(__u32 fileid);
long (*read)(__u32 fileid,void *buf,__u32 n,__u32 *cnt);
long (*getreadstatus)();
long (*write)(__u32 fileid, void *buf,__u32 n,__u32 *cnt);
long (*seek)(void); /* ... */
/* 30 */
long (*mount)(void); /* ... */
char * (*getenvironmentvariable)(char *name);
char * (*setenvironmentvariable)(char *name, char *value);
long (*getfileinformation)(void); /* ... */
long (*setfileinformation)(__u32 fileid,__u32 attflags,__u32 attmask);
void (*flushallcaches)(void);
long (*testunicodecharacter)(void); /* ... */
long (*getdisplaystatus)(void); /* ... */
} arc_func_vector_t;
 
typedef struct {
__u32 signature;
__u32 length;
__u16 version;
__u16 revision;
void *restartblock;
void *debugblock;
void *gevector;
void *utlbmissvector;
__u32 firmwarevectorlen;
arc_func_vector_t *firmwarevector;
__u32 privvectorlen;
void *privvector;
__u32 adaptercount;
}__attribute__ ((packed)) arc_sbp;
 
extern int init_arc(void);
extern void arc_print_memory_map(void);
extern int arc_enabled(void);
extern void arc_putchar(char ch);
 
#endif
/SPARTAN/trunk/arch/mips/Makefile.inc
1,5 → 1,4
MIPS_TARGET=mipsel-linux-gnu
 
MIPS_CC_DIR=/usr/local/mipsel/bin
MIPS_BINUTILS_DIR=/usr/local/mipsel/bin
 
8,21 → 7,25
LD=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-ld
OBJDUMP=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-objdump
OBJCOPY=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-objcopy
BFD_NAME=elf32-tradlittlemips
BFD_ARCH=mips
 
DEFS=-DARCH=$(ARCH) -DMACHINE=${MACHINE} -DKERNEL_LOAD_ADDRESS=${KERNEL_LOAD_ADDRESS}
CFLAGS=$(DEFS) -mno-abicalls -G 0 -nostdlib -fno-builtin -O2 -fno-zero-initialized-in-bss
LFLAGS=-M -N
BFD_ARCH=mips
 
# It seems that on big endian either GCC or the simulators
# have the swl/swr/lwl/lwr instructions wrong. Just for sure,
# disable it with -mmemcpy (force calling memcpy instead of inlining)
# GCC 4.0.1 compiled for mipsEL has problems compiling in
# BigEndian mode with the swl/swr/lwl/lwr instructions.
# We have to compile it with mips-sgi-irix5 to get it right.
ifeq (${MACHINE},indy)
MIPS_TARGET=mips-sgi-irix5
MIPS_CC_DIR=/usr/local/mips/bin
MIPS_BINUTILS_DIR=/usr/local/mips/bin
 
ifeq (${MACHINE},indy)
CFLAGS += -EB -mmemcpy -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -march=r4600
CFLAGS += -EB -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -march=r4600
BFD = ecoff-bigmips
KERNEL_LOAD_ADDRESS = 0x88002000
BFD_NAME=elf32-big
endif
 
ifeq (${MACHINE},lgxemul)
29,12 → 32,18
CFLAGS += -DHAVE_FPU -DFPU_LAZY -mips3
BFD = ecoff-littlemips
KERNEL_LOAD_ADDRESS = 0x80100000
BFD_NAME=elf32-little
endif
 
ifeq (${MACHINE},bgxemul)
CFLAGS += -EB -mmemcpy -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -mips3
MIPS_TARGET=mips-sgi-irix5
MIPS_CC_DIR=/usr/local/mips/bin
MIPS_BINUTILS_DIR=/usr/local/mips/bin
 
CFLAGS += -EB -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -mips3
BFD = ecoff-bigmips
KERNEL_LOAD_ADDRESS = 0x80100000
BFD_NAME=elf32-big
endif
 
# MSIM needs lwl/swl patch & 4kc instruction patch to work
43,6 → 52,7
BFD = binary
CFLAGS += -msoft-float -march=4kc
KERNEL_LOAD_ADDRESS = 0x80100000
BFD_NAME=elf32-little
endif
 
# SIMICS 4kc emulation is broken, although for instructions
51,6 → 61,7
BFD = elf32-little
CFLAGS += -msoft-float -mips3
KERNEL_LOAD_ADDRESS = 0x80100000
BFD_NAME=elf32-little
endif
 
../arch/$(ARCH)/_link.ld: ../arch/$(ARCH)/_link.ld.in
72,4 → 83,5
arch/mm/page.c \
arch/mm/tlb.c \
arch/fpu_context.c \
arch/fmath.c
arch/fmath.c \
arch/drivers/arc.c
/SPARTAN/trunk/arch/mips/src/exception.c
65,7 → 65,7
/* decode exception number and process the exception */
switch (excno) {
case EXC_Int:
interrupt();
interrupt(pstate);
break;
case EXC_TLBL:
case EXC_TLBS:
/SPARTAN/trunk/arch/mips/src/asm.S
117,13 → 117,6
cp0_prid_read: cp0_read $15
 
 
.global bios_write
bios_write:
lw $2, 0x80001020
lw $2, 0x6c($2)
j $2
nop
.global cpu_halt
cpu_halt:
j cpu_halt
/SPARTAN/trunk/arch/mips/src/console.c
31,25 → 31,16
#include <arch/cp0.h>
#include <arch/console.h>
#include <arch.h>
#include <arch/drivers/arc.h>
#include <arch/arch.h>
 
static void arc_putchar(const char ch)
{
int cnt;
pri_t pri;
 
/* TODO: Should be spinlock? */
pri = cpu_priority_high();
bios_write(1, &ch, 1, &cnt);
cpu_priority_restore(pri);
}
 
/** Putchar that works with MSIM & gxemul */
static void cons_putchar(const char ch)
{
*((char *) VIDEORAM) = ch;
}
 
 
/** Putchar that works with simics */
static void serial_putchar(const char ch)
{
int i;
67,8 → 58,10
 
void console_init(void)
{
if (arc_enabled())
putchar_func = arc_putchar;
/* The LSR on the start usually contains this value */
if (*SERIAL_LSR == 0x60)
else if (*SERIAL_LSR == 0x60)
putchar_func = serial_putchar;
else
putchar_func = cons_putchar;
/SPARTAN/trunk/arch/mips/src/mips.c
36,6 → 36,7
#include <arch/console.h>
#include <memstr.h>
#include <arch/interrupt.h>
#include <arch/drivers/arc.h>
 
#include <print.h>
 
53,6 → 54,8
/* It is not assumed by default */
cpu_priority_high();
 
init_arc();
 
/* Copy the exception vectors to the right places */
memcpy(TLB_EXC, (char *)tlb_refill_entry, EXCEPTION_JUMP_SIZE);
memcpy(NORM_EXC, (char *)exception_entry, EXCEPTION_JUMP_SIZE);
79,6 → 82,7
cp0_compare_write(cp0_compare_value + cp0_count_read());
 
console_init();
arc_print_memory_map();
}
 
void arch_post_mm_init(void)
110,5 → 114,3
{
supervisor_sp = (__address) &THREAD->kstack[THREAD_STACK_SIZE-SP_DELTA];
}
 
 
/SPARTAN/trunk/arch/mips/src/mm/tlb.c
40,14 → 40,12
char *symbol = "";
char *sym2 = "";
 
if (THREAD) {
char *s = get_symtab_entry(pstate->epc);
if (s)
symbol = s;
s = get_symtab_entry(pstate->ra);
if (s)
sym2 = s;
}
char *s = get_symtab_entry(pstate->epc);
if (s)
symbol = s;
s = get_symtab_entry(pstate->ra);
if (s)
sym2 = s;
panic("%X: tlb_refill exception at %X(%s<-%s)\n", cp0_badvaddr_read(),
pstate->epc, symbol,sym2);
}
56,11 → 54,9
{
char *symbol = "";
 
if (THREAD) {
char *s = get_symtab_entry(pstate->epc);
if (s)
symbol = s;
}
char *s = get_symtab_entry(pstate->epc);
if (s)
symbol = s;
panic("%X: TLB exception at %X(%s)\n", cp0_badvaddr_read(),
pstate->epc, symbol);
}
/SPARTAN/trunk/arch/mips/src/interrupt.c
32,7 → 32,26
#include <arch/cp0.h>
#include <time/clock.h>
#include <panic.h>
#include <print.h>
#include <symtab.h>
#include <arch/drivers/arc.h>
 
static void print_regdump(struct exception_regdump *pstate)
{
char *pcsymbol = "";
char *rasymbol = "";
 
char *s = get_symtab_entry(pstate->epc);
if (s)
pcsymbol = s;
s = get_symtab_entry(pstate->ra);
if (s)
rasymbol = s;
printf("PC: %X(%s) RA: %X(%s)\n",pstate->epc,pcsymbol,
pstate->ra,rasymbol);
}
 
pri_t cpu_priority_high(void)
{
pri_t pri = (pri_t) cp0_status_read();
57,7 → 76,7
return cp0_status_read();
}
 
void interrupt(void)
void interrupt(struct exception_regdump *pstate)
{
__u32 cause;
int i;
69,10 → 88,10
if (cause & (1 << i)) {
switch (i) {
case 0: /* SW0 - Software interrupt 0 */
cp0_cause_write(cause & ~(1 << 8)); /* clear SW0 interrupt */
cp0_cause_write(cp0_cause_read() & ~(1 << 8)); /* clear SW0 interrupt */
break;
case 1: /* SW1 - Software interrupt 1 */
cp0_cause_write(cause & ~(1 << 9)); /* clear SW1 interrupt */
cp0_cause_write(cp0_cause_read() & ~(1 << 9)); /* clear SW1 interrupt */
break;
case 2: /* IRQ0 */
case 3: /* IRQ1 */
79,6 → 98,7
case 4: /* IRQ2 */
case 5: /* IRQ3 */
case 6: /* IRQ4 */
print_regdump(pstate);
panic("unhandled interrupt %d\n", i);
break;
case TIMER_INTERRUPT:
/SPARTAN/trunk/arch/mips/src/drivers/arc.c
0,0 → 1,108
/*
* 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.
*/
 
#include <arch/drivers/arc.h>
#include <arch/mm/page.h>
#include <print.h>
#include <arch.h>
#include <arch/byteorder.h>
 
/* This is a good joke, SGI HAS different types than NT bioses... */
/* Here is the SGI type */
static char *basetypes[] = {
"ExceptionBlock",
"SystemParameterBlock",
"FreeContiguous",
"FreeMemory",
"BadMemory",
"LoadedProgram",
"FirmwareTemporary",
"FirmwarePermanent"
};
 
static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000);
static arc_func_vector_t *arc_entry;
 
static void _arc_putchar(char ch);
 
/** Initialize ARC structure
*
* @return 0 - ARC OK, -1 - ARC does not exist
*/
int init_arc(void)
{
if (sbp->signature != ARC_MAGIC) {
sbp = NULL;
return -1;
}
arc_entry = sbp->firmwarevector;
 
arc_putchar('A');
arc_putchar('R');
arc_putchar('C');
arc_putchar('\n');
}
 
/** Return true if ARC is available */
int arc_enabled(void)
{
return sbp != NULL;
}
 
void arc_print_memory_map(void)
{
arc_memdescriptor_t *desc;
 
if (!sbp) {
printf("ARC not enabled.\n");
return;
}
 
printf("Memory map:\n");
 
desc = arc_entry->getmemorydescriptor(NULL);
while (desc) {
printf("%s: %d (size: %dKB)\n",basetypes[desc->type],
desc->basepage * 4096,
desc->basecount*4);
desc = arc_entry->getmemorydescriptor(desc);
}
}
 
/** Print charactor to console */
void arc_putchar(char ch)
{
__u32 cnt;
pri_t pri;
 
/* TODO: Should be spinlock? */
pri = cpu_priority_high();
arc_entry->write(1, &ch, 1, &cnt);
cpu_priority_restore(pri);
}
/SPARTAN/trunk/arch/amd64/_link.ld.in
62,7 → 62,15
 
_hardcoded_kernel_size = (ktext_end - ktext_start) + (unmapped_ktext_end - unmapped_ktext_start) + (kdata_end - kdata_start) + (unmapped_kdata_end - unmapped_kdata_start);
 
/* Symbols that need to be accessed both from real mode & long mode */
/* e820*_boot is real mode (pre-above-1MB-move), e820* is */
/* kernel mapped above-1MB-physical copied symbol */
e820table_boot = KA2PA(e820table) - BOOT_OFFSET;
e820counter_boot = KA2PA(e820counter) - BOOT_OFFSET;
 
/* real_bootstrap_gdtr is mapped real_bootstrap_gdtr_boot */
/* It is physically outside of kernel area, we have to access */
/* it after modification from long mode for booting */
/* SMP slave processors */
real_bootstrap_gdtr = PA2KA(real_bootstrap_gdtr_boot);
}
/SPARTAN/trunk/arch/amd64/include/byteorder.h
30,6 → 30,7
#define __amd64_BYTEORDER_H__
 
/* AMD64 is little-endian */
#define native_le2host(n) n
#define native_le2host(n) (n)
#define u64_le2host(n) (n)
 
#endif
/SPARTAN/trunk/arch/amd64/src/fpu_context.c
31,6 → 31,7
#include <arch.h>
#include <cpu.h>
 
/** Save FPU (mmx, sse) context using fxsave instruction */
void fpu_context_save(fpu_context_t *fctx)
{
/* Align on 16-byte boundary */
43,6 → 44,7
);
}
 
/** Restore FPU (mmx,sse) context using fxrstor instruction */
void fpu_context_restore(fpu_context_t *fctx)
{
/* Align on 16-byte boundary */
/SPARTAN/trunk/arch/amd64/src/asm_utils.S
58,11 → 58,6
# THIS IS USERSPACE CODE
.global utext
utext:
xor %ax,%ax;
mov %ax,%ds;
mov %ax,%es;
mov %ax,%fs;
mov %ax,%gs;
0:
int $48
jmp 0b
177,11 → 172,10
push_all_gpr
 
# trap_dispatcher(i, stack)
movq $(\i),%rdi # %rdi - first parameter
movq %rbp, %rsi
addq $8, %rsi # %rsi - second parameter - original stack
call trap_dispatcher
call trap_dispatcher # trap_dispatcher(i, stack)
 
# Test if this is interrupt with error word or not
mov $\i,%cl;
216,9 → 210,6
interrupt_handlers:
h_start:
handler 0 IDT_ITEMS
# handler 64 128
# handler 128 192
# handler 192 256
h_end:
/SPARTAN/trunk/arch/amd64/src/pm.c
91,7 → 91,7
.special = 1,
.granularity = 1,
.base_24_31 = 0 },
/* KTEXT 32-bit protected */
/* KTEXT 32-bit protected, for protected mode before long mode */
{ .limit_0_15 = 0xffff,
.base_0_15 = 0,
.base_16_23 = 0,
/SPARTAN/trunk/arch/ia32/include/byteorder.h
30,6 → 30,7
#define __ia32_BYTEORDER_H__
 
/* IA-32 is little-endian */
#define native_le2host(n) n
#define native_le2host(n) (n)
#define u64_le2host(n) (n)
 
#endif