Disable interrupts before jumping to scratch ROM

This commit is contained in:
Jeremy Soller 2020-02-04 09:44:50 -07:00
parent c50632c1bf
commit 81084066df
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
3 changed files with 86 additions and 103 deletions

View File

@ -46,16 +46,10 @@ void scratch_trampoline(void) {
// Uses SCAR0, 1, 2, 3, and 4 which are mapped at 0x0000 in data space and are
// 4096 bytes in size.
//TODO: ensure pdata is not used!
// Disable interrupts
EA = 0;
if ((SCAR0H == 0x00) || (SCAR1H == 0x00) || (SCAR2H == 0x00) || (SCAR3H == 0x00) || (SCAR4H == 0x00)) {
// Disable scratch RAM mapping
SCAR0H = 0b11;
SCAR1H = 0b11;
SCAR2H = 0b11;
SCAR3H = 0b11;
SCAR4H = 0b11;
} else {
// Ensure pdata is not used!
int __data i;
// Copy scratch ROM
for (i = 0; i < ARRAY_SIZE(scratch_rom) && i < ARRAY_SIZE(scratch_ram); i++) {
@ -87,7 +81,6 @@ void scratch_trampoline(void) {
SCAR4L = 0x00;
SCAR4M = 0x0F;
SCAR4H = 0x00;
}
// Jump to reset function
__asm__("ljmp 0");

View File

@ -46,16 +46,10 @@ void scratch_trampoline(void) {
// Uses SCAR0, 1, 2, 3, and 4 which are mapped at 0x0000 in data space and are
// 4096 bytes in size.
//TODO: ensure pdata is not used!
// Disable interrupts
EA = 0;
if ((SCAR0H == 0x00) || (SCAR1H == 0x00) || (SCAR2H == 0x00) || (SCAR3H == 0x00) || (SCAR4H == 0x00)) {
// Disable scratch RAM mapping
SCAR0H = 0b11;
SCAR1H = 0b11;
SCAR2H = 0b11;
SCAR3H = 0b11;
SCAR4H = 0b11;
} else {
// Ensure pdata is not used!
int __data i;
// Copy scratch ROM
for (i = 0; i < ARRAY_SIZE(scratch_rom) && i < ARRAY_SIZE(scratch_ram); i++) {
@ -87,7 +81,6 @@ void scratch_trampoline(void) {
SCAR4L = 0x00;
SCAR4M = 0x0F;
SCAR4H = 0x00;
}
// Jump to reset function
__asm__("ljmp 0");

View File

@ -30,12 +30,10 @@ void scratch_trampoline(void) {
// Uses SCAR0 which is mapped at 0x0000 in data space and are
// 4096 bytes in size.
//TODO: ensure pdata is not used!
// Disable interrupts
EA = 0;
if (SCAR0H == 0x00) {
// Disable scratch RAM mapping
SCAR0H = 0b11;
} else {
// Ensure pdata is not used!
int __data i;
// Copy scratch ROM
for (i = 0; i < ARRAY_SIZE(scratch_rom) && i < ARRAY_SIZE(scratch_ram); i++) {
@ -51,7 +49,6 @@ void scratch_trampoline(void) {
SCAR0L = 0x00;
SCAR0M = 0x00;
SCAR0H = 0x00;
}
// Jump to reset function
__asm__("ljmp 0");