provide an early exception vector table to catch exceptions during startup, before the final table has been set up (in exceptions.S)
This commit is contained in:
@@ -61,6 +61,7 @@ BASFLASH_EXEC=basflash.$(EXE)
|
||||
CSRCS= \
|
||||
$(SRCDIR)/sysinit.c \
|
||||
$(SRCDIR)/init_fpga.c \
|
||||
$(SRCDIR)/fault_vectors.c \
|
||||
$(SRCDIR)/bas_printf.c \
|
||||
$(SRCDIR)/bas_string.c \
|
||||
$(SRCDIR)/BaS.c \
|
||||
|
||||
@@ -11,6 +11,7 @@ SECTIONS
|
||||
{
|
||||
objs/startcf.o(.text) /* this one is the entry point so it must be the first */
|
||||
objs/sysinit.o(.text)
|
||||
objs/fault_vectors.o(.text)
|
||||
objs/init_fpga.o(.text)
|
||||
objs/wait.o(.text)
|
||||
|
||||
@@ -70,6 +71,7 @@ SECTIONS
|
||||
/* SDRAM Initialization @ 0000_0000 - 1FFF_FFFF 512Mbytes */
|
||||
___SDRAM = 0x00000000;
|
||||
___SDRAM_SIZE = 0x20000000;
|
||||
_SDRAM_VECTOR_TABLE = ___SDRAM;
|
||||
|
||||
/* ST-RAM */
|
||||
__STRAM = ___SDRAM;
|
||||
|
||||
@@ -16,6 +16,14 @@
|
||||
#define COPYBACK_MMUDR (MCF_MMU_MMUDR_SZ(00) | MCF_MMU_MMUDR_CM(01) | MCF_MMU_MMUDR_R | MCF_MMU_MMUDR_W | MCF_MMU_MMUDR_X)
|
||||
#define NOCACHE_PRECISE_MMUDR (MCF_MMU_MMUDR_SZ(00) | MCF_MMU_MMUDR_CM(10) | MCF_MMU_MMUDR_R | MCF_MMU_MMUDR_W | MCF_MMU_MMUDR_X)
|
||||
|
||||
#define SCA_PAGE_ID 6
|
||||
|
||||
/*
|
||||
* global variables from linker script
|
||||
*/
|
||||
extern long video_tlb;
|
||||
extern long video_sbt;
|
||||
|
||||
extern void mmu_init(void);
|
||||
extern void mmutr_miss(void) __attribute__((interrupt));
|
||||
|
||||
|
||||
49
BaS_gcc/sources/fault_vectors.c
Normal file
49
BaS_gcc/sources/fault_vectors.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "MCF5475.h"
|
||||
#include "bas_types.h"
|
||||
#include "bas_printf.h"
|
||||
|
||||
/*
|
||||
* provide an early exception vector branch table to catch exceptions _before_ VBR has been setup eventually
|
||||
* (to RAMBAR0, in exceptions.S)
|
||||
*/
|
||||
|
||||
typedef void (*exception_handler)(void);
|
||||
extern exception_handler SDRAM_VECTOR_TABLE[];
|
||||
|
||||
void fault_handler(uint32_t format_status, uint32_t pc)
|
||||
{
|
||||
xprintf("\007\007exception!\r\n");
|
||||
xprintf("format_status: %lx\r\n", format_status);
|
||||
xprintf("pc: %lx\r\n", pc);
|
||||
xprintf("processor halted.\r\n");
|
||||
}
|
||||
|
||||
void handler(void)
|
||||
{
|
||||
/*
|
||||
* for standard routines, we'd have to save registers here.
|
||||
* Since we do not intend to return anyway, we just ignore that
|
||||
*/
|
||||
__asm__ __volatile__("move.l (sp),-(sp)\n\t" /* format, fault status and status register values */
|
||||
"move.l 8(sp),-(sp)\n\t" /* the program counter where the fault originated */
|
||||
"bra _fault_handler\n\t"
|
||||
"halt\n\t"
|
||||
: : :);
|
||||
}
|
||||
|
||||
void setup_vectors(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
SDRAM_VECTOR_TABLE[i] = handler;
|
||||
}
|
||||
|
||||
/*
|
||||
* make sure VBR points to our table
|
||||
*/
|
||||
__asm__ __volatile__("clr.l d0\n\t"
|
||||
"movec d0,VBR\n\t"
|
||||
"move.l d0,_rt_vbr");
|
||||
}
|
||||
@@ -68,10 +68,10 @@ void mmu_init(void)
|
||||
* 0x00d00000 locked ID=6
|
||||
* video RAM: read write execute normal write true
|
||||
*/
|
||||
MCF_MMU_MMUTR = 0x00d00000 | MCF_MMU_MMUTR_ID(sca_page_ID) | STD_MMUTR;
|
||||
MCF_MMU_MMUTR = 0x00d00000 | MCF_MMU_MMUTR_ID(SCA_PAGE_ID) | STD_MMUTR;
|
||||
MCF_MMU_MMUDR = 0x60d00000 | WRITETHROUGH_MMUDR | MCF_MMU_MMUDR_LK;
|
||||
MCF_MMU_MMUOR = MMUORD_D;
|
||||
MCF_MMU_MMUOR = 0x00d00000 | std_mmutr;
|
||||
MCF_MMU_MMUOR = 0x00d00000 | STD_MMUTR;
|
||||
|
||||
video_tlb = 0x2000;
|
||||
video_sbt = 0;
|
||||
|
||||
Reference in New Issue
Block a user