87 lines
1.8 KiB
C++
87 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "sh7091/sh7091.hpp"
|
|
#include "sh7091/sh7091_bits.hpp"
|
|
#include "sh7091/serial.hpp"
|
|
#include "sh7091/vbr.hpp"
|
|
|
|
#include "systembus.hpp"
|
|
#include "systembus_bits.hpp"
|
|
|
|
extern int render_done;
|
|
|
|
void interrupt_init();
|
|
|
|
static inline __attribute__((always_inline)) void interrupt_exception()
|
|
{
|
|
serial::string("expevt ");
|
|
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
|
serial::string("intevt ");
|
|
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
|
serial::string("tra ");
|
|
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
|
|
|
serial::string("istnrm: ");
|
|
serial::integer<uint32_t>(system.ISTNRM);
|
|
serial::string("isterr: ");
|
|
serial::integer<uint32_t>(system.ISTERR);
|
|
|
|
uint32_t spc;
|
|
uint32_t ssr;
|
|
asm volatile ("stc spc,%0" : "=r" (spc));
|
|
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
|
serial::string("spc ");
|
|
serial::integer(spc);
|
|
serial::string("ssr ");
|
|
serial::integer(ssr);
|
|
|
|
while (1);
|
|
}
|
|
|
|
void interrupt_init()
|
|
{
|
|
system.IML2NRM = 0;
|
|
system.IML2ERR = 0;
|
|
system.IML2EXT = 0;
|
|
|
|
system.IML4NRM = 0;
|
|
system.IML4ERR = 0;
|
|
system.IML4EXT = 0;
|
|
|
|
system.IML6NRM = 0;
|
|
system.IML6ERR = 0;
|
|
system.IML6EXT = 0;
|
|
|
|
system.ISTERR = 0xffffffff;
|
|
system.ISTNRM = 0xffffffff;
|
|
|
|
sh7091.CCN.INTEVT = 0;
|
|
sh7091.CCN.EXPEVT = 0;
|
|
|
|
uint32_t vbr = reinterpret_cast<uint32_t>(&__vbr_link_start) - 0x100;
|
|
serial::string("vbr ");
|
|
serial::integer<uint32_t>(vbr);
|
|
serial::string("vbr100 ");
|
|
serial::integer<uint32_t>(reinterpret_cast<uint32_t>(&vbr100));
|
|
|
|
asm volatile ("ldc %0,vbr"
|
|
:
|
|
: "r" (vbr));
|
|
|
|
uint32_t sr;
|
|
asm volatile ("stc sr,%0"
|
|
: "=r" (sr));
|
|
serial::string("sr ");
|
|
serial::integer<uint32_t>(sr);
|
|
|
|
sr &= ~sh::sr::bl; // BL
|
|
sr &= ~sh::sr::imask(15); // imask
|
|
|
|
serial::string("sr ");
|
|
serial::integer<uint32_t>(sr);
|
|
|
|
asm volatile ("ldc %0,sr"
|
|
:
|
|
: "r" (sr));
|
|
}
|