Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 330 → Rev 332

/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);
}