new exceptions.c also brings set_ipl() instead of asm_set_ipl()

This commit is contained in:
Markus Fröschle
2013-11-20 06:55:46 +00:00
parent 523f73a9ae
commit 24377aee92
2 changed files with 45 additions and 28 deletions

View File

@@ -24,6 +24,9 @@
#include <stdint.h> #include <stdint.h>
#include "bas_printf.h" #include "bas_printf.h"
#include "bas_string.h" #include "bas_string.h"
#include "startcf.h"
#include "interrupts.h"
#include "MCF5475.h"
#if MACHINE_FIREBEE #if MACHINE_FIREBEE
#include "firebee.h" #include "firebee.h"
@@ -39,7 +42,9 @@
#define debug_printf(format, arg...) do { ; } while (0) #define debug_printf(format, arg...) do { ; } while (0)
#endif /* DEBUG_EXC */ #endif /* DEBUG_EXC */
inline uint32_t set_vbr(uint32_t value) typedef void (*exception_handler)(void);
static inline uint32_t set_vbr(uint32_t value)
{ {
extern uint32_t rt_vbr; extern uint32_t rt_vbr;
uint32_t ret = rt_vbr; uint32_t ret = rt_vbr;
@@ -55,50 +60,62 @@ inline uint32_t set_vbr(uint32_t value)
return ret; return ret;
} }
void __attribute__((interrupt)) std_exception_handler() static void __attribute__((interrupt)) std_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) reset_exception_handler() static void __attribute__((interrupt)) reset_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) access_exception_handler() static void __attribute__((interrupt)) access_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) irq1_exception_handler() static void __attribute__((interrupt)) irq1_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) irq2_exception_handler() static void __attribute__((interrupt)) irq2_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) irq3_exception_handler() static void __attribute__((interrupt)) irq3_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) irq4_exception_handler() static void __attribute__((interrupt)) irq4_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) irq5_exception_handler() static void __attribute__((interrupt)) irq5_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) irq6_exception_handler() static void __attribute__((interrupt)) irq6_exception_handler(void)
{ {
} }
void __attribute__((interrupt)) irq7_exception_handler() static void __attribute__((interrupt)) irq7_exception_handler(void)
{ {
} }
static void __attribute__((interrupt)) psc3_interrupt_handler(void)
{
}
static void __attribute__((interrupt)) gpt0_interrupt_handler(void)
{
}
extern void __attribute__((interrupt)) xhdi_sd_install(void);
void vec_init(void) void vec_init(void)
{ {
extern uint32_t _RAMBAR0[]; /* defined in linker script */ exception_handler *VBR = (exception_handler *) &_RAMBAR0[0];
uint32_t *VBR = &_RAMBAR0[0]; extern uint32_t _SUP_SP[]; /* supervisor stack pointer from linker script */
exception_handler *SUP_SP = (exception_handler *) &_SUP_SP[0];
extern uint32_t rt_mod; extern uint32_t rt_mod;
extern uint32_t rt_ssp; extern uint32_t rt_ssp;
extern uint32_t rt_usp; extern uint32_t rt_usp;
@@ -120,7 +137,7 @@ void vec_init(void)
VBR[i] = std_exception_handler; VBR[i] = std_exception_handler;
} }
VBR[0] = __SUP_SP; VBR[0] = SUP_SP;
VBR[1] = reset_exception_handler; VBR[1] = reset_exception_handler;
VBR[2] = access_exception_handler; VBR[2] = access_exception_handler;
@@ -133,20 +150,20 @@ void vec_init(void)
} }
#endif /* MACHINE_FIREBEE */ #endif /* MACHINE_FIREBEE */
VBR[0X80] = xhdi_install; /* trap #0 exception handler for BaS driver vectors */ VBR[0X80] = xhdi_sd_install; /* trap #0 exception handler for BaS driver vectors */
#if MACHINE_FIREBEE #if MACHINE_FIREBEE
/* /*
* ACP interrupts 1-7 (generated by the FPGA on the FireBee) * ACP interrupts 1-7 (generated by the FPGA on the FireBee)
*/ */
VBR[0X104] = (uint32_t) irq1_exception_handler; VBR[0X104] = irq1_exception_handler;
VBR[0x108] = (uint32_t) irq2_exception_handler; VBR[0x108] = irq2_exception_handler;
VBR[0x10c] = (uint32_t) irq3_exception_handler; VBR[0x10c] = irq3_exception_handler;
VBR[0x110] = (uint32_t) irq4_exception_handler; VBR[0x110] = irq4_exception_handler;
VBR[0x114] = (uint32_t) irq5_exception_handler; VBR[0x114] = irq5_exception_handler;
VBR[0x118] = (uint32_t) irq6_exception_handler; VBR[0x118] = irq6_exception_handler;
VBR[0x11c] = (uint32_t) irq7_exception_handler; VBR[0x11c] = irq7_exception_handler;
/* /*
* install PSC vectors (used for PIC communication on the FireBee * install PSC vectors (used for PIC communication on the FireBee

View File

@@ -15,6 +15,7 @@
#include "bas_string.h" #include "bas_string.h"
#include "bas_printf.h" #include "bas_printf.h"
#include "usb.h" #include "usb.h"
#include "exceptions.h" /* set_ipl() */
#if MACHINE_FIREBEE #if MACHINE_FIREBEE
#include "firebee.h" #include "firebee.h"
@@ -37,7 +38,6 @@
#define USB_MEM_PRINTF(fmt, args...) #define USB_MEM_PRINTF(fmt, args...)
#endif #endif
extern int asm_set_ipl(int level);
extern void *info_fvdi; extern void *info_fvdi;
extern long offscren_reserved(void); extern long offscren_reserved(void);
@@ -204,7 +204,7 @@ int usb_free(void *addr)
MD *p, **q; MD *p, **q;
MPB *mpb; MPB *mpb;
mpb = &pmd; mpb = &pmd;
level = asm_set_ipl(7); level = set_ipl(7);
for(p = *(q = &mpb->mp_mal); p; p = *(q = &p->m_link)) for(p = *(q = &mpb->mp_mal); p; p = *(q = &p->m_link))
{ {
if ((long)addr == p->m_start) if ((long)addr == p->m_start)
@@ -212,12 +212,12 @@ int usb_free(void *addr)
} }
if (!p) if (!p)
{ {
asm_set_ipl(level); set_ipl(level);
return(-1); return(-1);
} }
*q = p->m_link; *q = p->m_link;
freeit(p, mpb); freeit(p, mpb);
asm_set_ipl(level); set_ipl(level);
USB_MEM_PRINTF("usb_free(0x%08X)\r\n", addr); USB_MEM_PRINTF("usb_free(0x%08X)\r\n", addr);
return(0); return(0);
} }
@@ -233,11 +233,11 @@ void *usb_malloc(long amount)
return(0); return(0);
if ((amount & 1)) if ((amount & 1))
amount++; amount++;
level = asm_set_ipl(7); level = set_ipl(7);
m = ffit(amount, &pmd); m = ffit(amount, &pmd);
if (m != NULL) if (m != NULL)
ret = (void *)m->m_start; ret = (void *)m->m_start;
asm_set_ipl(level); set_ipl(level);
USB_MEM_PRINTF("usb_malloc(%d) = 0x%08X\r\n", amount, ret); USB_MEM_PRINTF("usb_malloc(%d) = 0x%08X\r\n", amount, ret);
return(ret); return(ret);
} }