forked from Imagelibrary/rtems
2006-06-02 Jay Monkman
* at91rm9200/irq/bsp_irq_init.c, mc9328mxl/clock/clockdrv.c, mc9328mxl/irq/bsp_irq_asm.S, mc9328mxl/irq/bsp_irq_init.c, mc9328mxl/irq/irq.c, mc9328mxl/irq/irq.h, s3c2400/irq/bsp_irq_init.c: Changed interrupt handling to use shared rtems_irq_connect_data struct.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2006-06-02 Jay Monkman
|
||||
|
||||
* shared/arm920/mmu.c: Fixed bug in mmu_get_ctrl(),
|
||||
added mmu_set_cpu_async() function.
|
||||
|
||||
2006-06-02 Jay Monkman
|
||||
|
||||
* at91rm9200/irq/bsp_irq_init.c, mc9328mxl/clock/clockdrv.c,
|
||||
|
||||
@@ -23,6 +23,16 @@ extern void default_int_handler();
|
||||
*/
|
||||
void BSP_rtems_irq_mngt_init()
|
||||
{
|
||||
long *vectorTable;
|
||||
int i;
|
||||
|
||||
vectorTable = (long *) VECTOR_TABLE;
|
||||
|
||||
/* Initialize the vector table contents with default handler */
|
||||
for (i=0; i<BSP_MAX_INT; i++) {
|
||||
*(vectorTable + i) = (long)(default_int_handler);
|
||||
}
|
||||
|
||||
/* disable all interrupts */
|
||||
AIC_CTL_REG(AIC_IDCR) = 0xffffffff;
|
||||
}
|
||||
|
||||
@@ -28,13 +28,14 @@ static void clock_isr_off(const rtems_irq_connect_data *unused);
|
||||
static int clock_isr_is_on(const rtems_irq_connect_data *irq);
|
||||
|
||||
/* Replace the first value with the clock's interrupt name. */
|
||||
rtems_irq_connect_data clock_isr_data = {BSP_INT_TIMER1,
|
||||
(rtems_irq_hdl)Clock_isr,
|
||||
clock_isr_on,
|
||||
clock_isr_off,
|
||||
clock_isr_is_on,
|
||||
3, /* unused for ARM cpus */
|
||||
0 }; /* unused for ARM cpus */
|
||||
rtems_irq_connect_data clock_isr_data = {
|
||||
.name = BSP_INT_TIMER1,
|
||||
.hdl = (rtems_irq_hdl)Clock_isr,
|
||||
.handle = (void *)BSP_INT_TIMER1,
|
||||
.on = clock_isr_on,
|
||||
.off = clock_isr_off,
|
||||
.isOn = clock_isr_is_on,
|
||||
};
|
||||
|
||||
/* If you follow the code, this is never used, so any value
|
||||
* should work
|
||||
@@ -82,7 +83,7 @@ rtems_irq_connect_data clock_isr_data = {BSP_INT_TIMER1,
|
||||
int cnt; \
|
||||
freq = get_perclk1_freq(); \
|
||||
printk("perclk1 freq is %d\n", freq); \
|
||||
cnt = ((freq / 1000) * BSP_Configuration.microseconds_per_tick) / 1000;\
|
||||
cnt = ((long long)freq * BSP_Configuration.microseconds_per_tick + 500000) / 1000000;\
|
||||
printk("cnt freq is %d\n", cnt); \
|
||||
MC9328MXL_TMR1_TCMP = cnt; \
|
||||
/* use PERCLK1 as input, enable timer */ \
|
||||
|
||||
@@ -31,13 +31,15 @@ ExecuteITHandler :
|
||||
|
||||
/* find the ISR's address based on the vector */
|
||||
ldr r0, =bsp_vector_table
|
||||
ldr r0, [r0, r1, LSL #2] /* Read the address */
|
||||
|
||||
mov r1, r1, LSL #3 /* Shift vector to get offset into table */
|
||||
add r1, r0, r1 /* r1 has address of vector entry */
|
||||
ldr r0, [r1, #4] /* Get the data pointer */
|
||||
ldr r1, [r1] /* Get the vector */
|
||||
|
||||
stmdb sp!,{lr}
|
||||
ldr lr, =IRQ_return /* prepare the return from handler */
|
||||
|
||||
mov pc, r0 /* EXECUTE INT HANDLER */
|
||||
mov pc, r1 /* EXECUTE INT HANDLER */
|
||||
|
||||
IRQ_return:
|
||||
ldmia sp!,{lr}
|
||||
|
||||
@@ -23,10 +23,11 @@ extern void default_int_handler();
|
||||
*/
|
||||
void BSP_rtems_irq_mngt_init()
|
||||
{
|
||||
#if 0
|
||||
/* disable all interrupts */
|
||||
AIC_CTL_REG(AIC_IDCR) = 0xffffffff;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BSP_MAX_INT; i++) {
|
||||
bsp_vector_table[i].vector = default_int_handler;
|
||||
bsp_vector_table[i].data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <rtems/score/apiext.h>
|
||||
#include <mc9328mxl.h>
|
||||
|
||||
mc9328mxl_irq_info_t bsp_vector_table[BSP_MAX_INT];
|
||||
|
||||
/*
|
||||
* This function check that the value given for the irq line
|
||||
* is valid.
|
||||
@@ -36,9 +38,6 @@ static int isValidInterrupt(int irq)
|
||||
int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq)
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
rtems_irq_hdl *bsp_tbl;
|
||||
|
||||
bsp_tbl = (rtems_irq_hdl *)&bsp_vector_table;
|
||||
|
||||
if (!isValidInterrupt(irq->name)) {
|
||||
return 0;
|
||||
@@ -47,7 +46,7 @@ int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq)
|
||||
/*
|
||||
* Check if default handler is actually connected. If not issue an error.
|
||||
*/
|
||||
if (bsp_tbl[irq->name] != default_int_handler) {
|
||||
if (bsp_vector_table[irq->name].vector != default_int_handler) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -56,7 +55,8 @@ int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq)
|
||||
/*
|
||||
* store the new handler
|
||||
*/
|
||||
bsp_tbl[irq->name] = irq->hdl;
|
||||
bsp_vector_table[irq->name].vector = irq->hdl;
|
||||
bsp_vector_table[irq->name].data = irq->handle;
|
||||
|
||||
/*
|
||||
* Enable interrupt on device
|
||||
@@ -80,9 +80,6 @@ int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq)
|
||||
int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq)
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
rtems_irq_hdl *bsp_tbl;
|
||||
|
||||
bsp_tbl = (rtems_irq_hdl *)&bsp_vector_table;
|
||||
|
||||
if (!isValidInterrupt(irq->name)) {
|
||||
return 0;
|
||||
@@ -90,7 +87,7 @@ int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq)
|
||||
/*
|
||||
* Check if the handler is actually connected. If not issue an error.
|
||||
*/
|
||||
if (bsp_tbl[irq->name] != irq->hdl) {
|
||||
if (bsp_vector_table[irq->name].vector != irq->hdl) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -106,8 +103,8 @@ int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq)
|
||||
/*
|
||||
* restore the default irq value
|
||||
*/
|
||||
bsp_tbl[irq->name] = default_int_handler;
|
||||
|
||||
bsp_vector_table[irq->name].vector = default_int_handler;
|
||||
bsp_vector_table[irq->name].data = NULL;
|
||||
|
||||
_CPU_ISR_Enable(level);
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#ifndef __IRQ_H__
|
||||
#define __IRQ_H__
|
||||
|
||||
#include <rtems/irq.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -34,7 +36,7 @@ extern void default_int_handler();
|
||||
* Constants
|
||||
**********************************************************************/
|
||||
|
||||
/* possible interrupt sources on the AT91RM9200 */
|
||||
/* possible interrupt sources on the MC9328MXL */
|
||||
#define BSP_INT_UART3_PFERR 0
|
||||
#define BSP_INT_UART3_RTS 1
|
||||
#define BSP_INT_UART3_DTR 2
|
||||
@@ -101,42 +103,14 @@ extern void default_int_handler();
|
||||
#define BSP_INT_WDT 63
|
||||
#define BSP_MAX_INT 64
|
||||
|
||||
typedef unsigned char rtems_irq_level;
|
||||
typedef unsigned char rtems_irq_trigger;
|
||||
typedef struct {
|
||||
rtems_irq_hdl vector;
|
||||
rtems_irq_hdl_param data;
|
||||
} mc9328mxl_irq_info_t;
|
||||
|
||||
typedef unsigned int rtems_irq_number;
|
||||
struct __rtems_irq_connect_data__; /* forward declaratiuon */
|
||||
|
||||
typedef void (*rtems_irq_hdl) (void);
|
||||
typedef void (*rtems_irq_enable) (const struct __rtems_irq_connect_data__*);
|
||||
typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*);
|
||||
typedef int (*rtems_irq_is_enabled)(const struct __rtems_irq_connect_data__*);
|
||||
|
||||
extern rtems_irq_hdl bsp_vector_table[BSP_MAX_INT];
|
||||
#define VECTOR_TABLE bsp_vector_table
|
||||
|
||||
typedef struct __rtems_irq_connect_data__ {
|
||||
/* IRQ line */
|
||||
rtems_irq_number name;
|
||||
|
||||
/* Handler */
|
||||
rtems_irq_hdl hdl;
|
||||
|
||||
/* function for enabling interrupts at device level. */
|
||||
rtems_irq_enable on;
|
||||
|
||||
/* function for disabling interrupts at device level. */
|
||||
rtems_irq_disable off;
|
||||
|
||||
/* Function to test if interrupt is enabled */
|
||||
rtems_irq_is_enabled isOn;
|
||||
|
||||
/* priority level of interrupt */
|
||||
rtems_irq_level irqLevel;
|
||||
|
||||
/* Trigger method (rising/falling edge or high/low level) */
|
||||
rtems_irq_trigger irqTrigger;
|
||||
} rtems_irq_connect_data;
|
||||
extern mc9328mxl_irq_info_t bsp_vector_table[BSP_MAX_INT];
|
||||
|
||||
/*
|
||||
* function to initialize the interrupt for a specific BSP
|
||||
@@ -144,21 +118,6 @@ typedef struct __rtems_irq_connect_data__ {
|
||||
void BSP_rtems_irq_mngt_init();
|
||||
|
||||
|
||||
/*
|
||||
* function to connect a particular irq handler.
|
||||
*/
|
||||
int BSP_install_rtems_irq_handler (const rtems_irq_connect_data*);
|
||||
|
||||
/*
|
||||
* function to get the current RTEMS irq handler for ptr->name.
|
||||
*/
|
||||
int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* ptr);
|
||||
|
||||
/*
|
||||
* function to disconnect the RTEMS irq handler for ptr->name.
|
||||
*/
|
||||
int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data*);
|
||||
|
||||
#endif /* __asm__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -20,6 +20,16 @@ extern void default_int_handler();
|
||||
|
||||
void BSP_rtems_irq_mngt_init()
|
||||
{
|
||||
long *vectorTable;
|
||||
int i;
|
||||
|
||||
vectorTable = (long *) VECTOR_TABLE;
|
||||
|
||||
/* Initialize the vector table contents with default handler */
|
||||
for (i=0; i<BSP_MAX_INT; i++) {
|
||||
*(vectorTable + i) = (long)(default_int_handler);
|
||||
}
|
||||
|
||||
/*
|
||||
* Here is the code to initialize the INT for
|
||||
* the specified BSP
|
||||
|
||||
@@ -151,7 +151,7 @@ static inline uint32_t mmu_get_id(void)
|
||||
static inline uint32_t mmu_get_ctrl(void)
|
||||
{
|
||||
uint32_t val;
|
||||
asm volatile ("msr 15, 0, %0, cr1, cr0\n" : "=r" (val));
|
||||
asm volatile ("mrc 15, 0, %0, cr1, cr0\n" : "=r" (val));
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -240,3 +240,13 @@ static void mmu_set_map_inval(mmu_lvl1_t *base)
|
||||
base[i] = MMU_SET_LVL1_INVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void mmu_set_cpu_async_mode(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
reg = mmu_get_ctrl();
|
||||
reg |= 0xc0000000;
|
||||
mmu_set_ctrl(reg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user