Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2261 → Rev 2262

/branches/arm/kernel/arch/arm32/include/exception.h
39,14 → 39,22
 
#include <arch/types.h>
 
#define HIGH_EXCEPTION_VECTORS
 
#ifdef HIGH_EXCEPTION_VECTORS
#define EXC_BASE_ADDRESS 0xffff0000
#else
#define EXC_BASE_ADDRESS 0x0
#endif
 
/* Exception Vectors */
#define EXC_RESET_VEC 0x0
#define EXC_UNDEF_INSTR_VEC 0x4
#define EXC_SWI_VEC 0x8
#define EXC_PREFETCH_ABORT_VEC 0xc
#define EXC_DATA_ABORT_VEC 0x10
#define EXC_IRQ_VEC 0x18
#define EXC_FIQ_VEC 0x1c
#define EXC_RESET_VEC EXC_BASE_ADDRESS + 0x0
#define EXC_UNDEF_INSTR_VEC EXC_BASE_ADDRESS + 0x4
#define EXC_SWI_VEC EXC_BASE_ADDRESS + 0x8
#define EXC_PREFETCH_ABORT_VEC EXC_BASE_ADDRESS + 0xc
#define EXC_DATA_ABORT_VEC EXC_BASE_ADDRESS + 0x10
#define EXC_IRQ_VEC EXC_BASE_ADDRESS + 0x18
#define EXC_FIQ_VEC EXC_BASE_ADDRESS + 0x1c
 
/* Exception numbers */
#define EXC_RESET 0
/branches/arm/kernel/arch/arm32/include/regutils.h
31,16 → 31,18
*/
/**
* @file
* @brief Utilities for convenient manipulation with ARM registries.
* @brief Utilities for convenient manipulation with ARM registers.
*/
 
#ifndef KERN_arm32_REGUTILS_H_
#define KERN_arm32_REGUTILS_H_
 
 
#define STATUS_REG_IE_ENABLED_BIT (1 << 7)
#define STATUS_REG_MODE_MASK 0x1F
 
#define CP15_R1_HIGH_VECTORS_BIT (1 << 13)
 
 
/* ARM Processor Operation Modes */
#define USER_MODE 0x10
#define FIQ_MODE 0x11
/branches/arm/kernel/arch/arm32/src/exception.c
137,7 → 137,12
PROCESS_EXCEPTION(EXC_IRQ);
}
 
static void prefetch_abort_exception(int exc_no, istate_t* istate)
{
//aux_puts("(PREFETCH|DATA) ABORT exception caught, not processed.\n");
}
 
 
/** Interrupt Exception handler.
* Determines the sources of interrupt, and calls their handlers.
*/
208,6 → 213,20
(unsigned*)EXC_FIQ_VEC);
}
 
/** Activates using high exception vectors addresses. */
static void high_vectors()
{
uint32_t control_reg;
asm volatile( "mrc p15, 0, %0, c1, c1": "=r" (control_reg));
//switch on the high vectors bit
control_reg |= CP15_R1_HIGH_VECTORS_BIT;
asm volatile( "mcr p15, 0, %0, c1, c1" : : "r" (control_reg));
}
 
 
/** Initializes exception handling.
*
* Installs low-level exception handlers and then registers
215,9 → 234,15
*/
void exception_init(void)
{
#ifdef HIGH_EXCEPTION_VECTORS
high_vectors();
#endif
 
install_exception_handlers();
exc_register(EXC_IRQ, "interrupt", (iroutine) irq_exception);
exc_register(EXC_PREFETCH_ABORT, "prefetch abort", (iroutine) prefetch_abort_exception);
exc_register(EXC_DATA_ABORT, "data abort", (iroutine) prefetch_abort_exception);
/* TODO add next */
}
 
225,16 → 250,27
void setup_exception_stacks()
{
/* switch to particular mode and set "sp" there */
 
uint32_t cspr = current_status_reg_read();
 
/* IRQ stack */
current_status_reg_control_write(
(cspr & ~STATUS_REG_MODE_MASK) | IRQ_MODE
);
asm("ldr sp, =irq_stack");
current_status_reg_control_write( cspr);
 
/* abort stack */
current_status_reg_control_write(
(cspr & ~STATUS_REG_MODE_MASK) | ABORT_MODE
);
asm("ldr sp, =abort_stack");
 
/* TODO if you want to test other exceptions than IRQ,
make stack analogous to irq_stack (in start.S),
and then set stack pointer here */
 
current_status_reg_control_write( cspr);
 
}
 
/** @}
/branches/arm/kernel/arch/arm32/src/start.S
32,6 → 32,7
 
.global kernel_image_start
.global irq_stack
.global abort_stack
 
kernel_image_start:
 
65,6 → 66,8
end_stack:
.space 1024
irq_stack:
.space 1024
abort_stack:
 
halt:
ldr r0,=0x10000010