POK(kernelpart)
traps.c File Reference

Traps management. More...

#include <types.h>
#include <errno.h>
#include <libc.h>
#include <core/debug.h>
#include "thread.h"
#include "traps.h"

Go to the source code of this file.

Functions

pok_ret_t traps_init (void)
void trap_handler (unsigned int pc, unsigned int npc, unsigned int psr, unsigned int trap_nb, unsigned int restore_counter, unsigned int stack_pointer)

Variables

sparc_traps_handler pok_sparc_isr [256]

Detailed Description

Traps management.

Author:
Fabien Chouteau

Definition in file traps.c.


Function Documentation

void trap_handler ( unsigned int  pc,
unsigned int  npc,
unsigned int  psr,
unsigned int  trap_nb,
unsigned int  restore_counter,
unsigned int  stack_pointer 
)

Function called by interrupt pre-handler. Call the correct handler for the given trap number.

Parameters:
trap_nbThe number of the current trap. (cf SPARC V8 Manual, page 76)
stack_pointerAdress of the interrupted stack.
See also:
pok_arch_sp

Definition at line 53 of file traps.c.

{
(void)restore_counter;
pok_arch_sp = stack_pointer;
if (pok_sparc_isr[trap_nb] != NULL)
{
pok_sparc_isr[trap_nb]();
}
else
{
#ifdef POK_NEEDS_DEBUG
printf ("[KERNEL] [ERROR] Unhandled trap: 0x%x %%PSR=%x %%PC=%x %%nPC=%x %%sp=0x%x\n", trap_nb, psr, pc, npc, stack_pointer);
printf("%%psr : impl:0x%x ver:%x nzvc:%u%u%u%u EC:%u EF:%u PIL:0x%x S:%u PS:%u ET:%u CWP:%u\n\r",
(psr >> 28) & 0xF, (psr >> 24) & 0xF,
(psr >> 23) & 0x1, (psr >> 22) & 0x1c, (psr >> 21) & 0x1, (psr >> 20) & 0x1,
(psr >> 23) & 0x1, (psr >> 12) & 0x1, (psr >> 8) & 0xF, (psr >> 7) & 0x1, (psr >> 6) & 0x1,
(psr >> 5) & 0x1, psr & 0xF);
#else
(void)psr;
(void)npc;
(void)pc;
#endif
POK_FATAL ("Unhandled trap");
}
return;
}
pok_ret_t traps_init ( void  )

Initialize ISR table.

See also:
pok_sparc_isr

Definition at line 40 of file traps.c.

{
memset((unsigned char *)pok_sparc_isr, 0x0, sizeof (pok_sparc_isr));
return POK_ERRNO_OK;
}

Variable Documentation

sparc_traps_handler pok_sparc_isr[256]

Interrupt subroutine table.

Definition at line 34 of file traps.c.