Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2328 → Rev 2329

/branches/arm/kernel/arch/arm32/src/exception.c
33,6 → 33,7
@brief Exception handlers and exception initialization routines.
*/
 
 
#include <arch/exception.h>
#include <arch/debug/print.h>
#include <arch/memstr.h>
43,6 → 44,7
#include <print.h>
#include <syscall/syscall.h>
 
 
#define PREFETCH_OFFSET 0x8
#define BRANCH_OPCODE 0xea000000
#define LDR_OPCODE 0xe59ff000
50,9 → 52,11
#define EXC_VECTORS_SIZE 0x20
#define EXC_VECTORS 0x8
 
 
extern uintptr_t supervisor_sp;
extern uintptr_t exc_stack;
 
 
inline static void setup_stack_and_save_regs()
{
asm volatile( "ldr r13, =exc_stack \n\
164,8 → 168,9
/** General exception handler.
* Stores registers, dispatches the exception,
* and finally restores registers and returns from exception processing.
*
* @param exception Exception number.
*/
 
#define PROCESS_EXCEPTION(exception) \
setup_stack_and_save_regs(); \
CALL_EXC_DISPATCH(exception) \
176,8 → 181,9
CALL_EXC_DISPATCH(exception) \
LOAD_REGS_FROM_STACK*/
 
 
/** Updates specified exception vector to jump to given handler.
* Addresses of handlers are stored in memory following exception vectors.
* Addresses of handlers are stored in memory following exception vectors.
*/
static void install_handler (unsigned handler_addr, unsigned* vector)
{
195,30 → 201,35
}
 
 
/** Low-level Reset Exception handler. */
static void reset_exception_entry()
{
PROCESS_EXCEPTION(EXC_RESET);
}
 
/** Low-level Software Interrupt Exception handler */
 
/** Low-level Software Interrupt Exception handler. */
static void swi_exception_entry()
{
PROCESS_EXCEPTION(EXC_SWI);
}
 
/** Low-level Undefined Instruction Exception handler */
 
/** Low-level Undefined Instruction Exception handler. */
static void undef_instr_exception_entry()
{
PROCESS_EXCEPTION(EXC_UNDEF_INSTR);
}
 
/** Low-level Fast Interrupt Exception handler */
 
/** Low-level Fast Interrupt Exception handler. */
static void fiq_exception_entry()
{
PROCESS_EXCEPTION(EXC_FIQ);
}
 
/** Low-level Prefetch Abort Exception handler */
 
/** Low-level Prefetch Abort Exception handler. */
static void prefetch_abort_exception_entry()
{
asm("sub lr, lr, #4");
225,7 → 236,8
PROCESS_EXCEPTION(EXC_PREFETCH_ABORT);
}
 
/** Low-level Data Abort Exception handler */
 
/** Low-level Data Abort Exception handler. */
static void data_abort_exception_entry()
{
asm("sub lr, lr, #8");
233,7 → 245,7
}
 
 
/** Low-level Interrupt Exception handler */
/** Low-level Interrupt Exception handler. */
static void irq_exception_entry()
{
asm("sub lr, lr, #4");
240,6 → 252,7
PROCESS_EXCEPTION(EXC_IRQ);
}
 
 
/** Software Interrupt handler.
*
* Dispatches the syscall.
257,6 → 270,7
istate->r4);
}
 
 
/** Interrupt Exception handler.
*
* Determines the sources of interrupt, and calls their handlers.
266,8 → 280,8
machine_irq_exception(exc_no, istate);
}
 
/** Fills exception vectors with appropriate exception handlers.
*/
 
/** Fills exception vectors with appropriate exception handlers. */
void install_exception_handlers(void)
{
install_handler((unsigned)reset_exception_entry,
292,9 → 306,10
(unsigned*)EXC_FIQ_VEC);
}
 
 
#ifdef HIGH_EXCEPTION_VECTORS
/** Activates using high exception vectors addresses. */
static void high_vectors()
/** Activates use of high exception vectors addresses. */
static void high_vectors()
{
uint32_t control_reg;
328,8 → 343,7
}
 
 
/** Sets stack pointers in all supported exception modes.
*/
/** Sets stack pointers in all supported exception modes. */
void setup_exception_stacks()
{
/* switch to particular mode and set "r13" there */