Adjust scratch ROM for IT5570

This commit is contained in:
Jeremy Soller 2020-01-14 15:43:26 -07:00
parent b68303f32c
commit bd450ce9c3
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 17 additions and 42 deletions

View File

@ -3,29 +3,17 @@
#include <common/macro.h> #include <common/macro.h>
// Include scratch ROM, must be less than 2048 bytes, controlled by makefile // Include scratch ROM, must be less than 4096 bytes, controlled by makefile
uint8_t __code scratch_rom[] = { uint8_t __code scratch_rom[] = {
#include <scratch.h> #include <scratch.h>
}; };
// Scratch RAM 1, 2, 3, and 4 are 2048 bytes total, located at 0x0800 bytes // Scratch RAM 0 is 4096 bytes, located at 0x0000 bytes
volatile uint8_t __xdata __at(0x0800) scratch_ram[2048]; volatile uint8_t __xdata __at(0x0000) scratch_ram[4096];
volatile uint8_t __xdata __at(0x1043) SCAR1L; volatile uint8_t __xdata __at(0x1040) SCAR0L;
volatile uint8_t __xdata __at(0x1044) SCAR1M; volatile uint8_t __xdata __at(0x1041) SCAR0M;
volatile uint8_t __xdata __at(0x1045) SCAR1H; volatile uint8_t __xdata __at(0x1042) SCAR0H;
volatile uint8_t __xdata __at(0x1046) SCAR2L;
volatile uint8_t __xdata __at(0x1047) SCAR2M;
volatile uint8_t __xdata __at(0x1048) SCAR2H;
volatile uint8_t __xdata __at(0x1049) SCAR3L;
volatile uint8_t __xdata __at(0x104A) SCAR3M;
volatile uint8_t __xdata __at(0x104B) SCAR3H;
volatile uint8_t __xdata __at(0x104C) SCAR4L;
volatile uint8_t __xdata __at(0x104D) SCAR4M;
volatile uint8_t __xdata __at(0x104E) SCAR4H;
// Create new segment located at 0x1000, after scratch ROM mapping // Create new segment located at 0x1000, after scratch ROM mapping
static void scratch_start(void) __naked { static void scratch_start(void) __naked {
@ -39,15 +27,14 @@ static void scratch_start(void) __naked {
// Enter or exit scratch ROM // Enter or exit scratch ROM
void scratch_trampoline(void) { void scratch_trampoline(void) {
// Uses SCAR1, 2, 3, and 4 which are mapped at 0x0800 in data space and are // Uses SCAR0 which is mapped at 0x0000 in data space and are
// 2048 bytes in size. SCAR0 cannot be used due to __pdata overwriting it. // 4096 bytes in size.
//TODO: ensure pdata is not used!
if ((SCAR1H == 0x00) || (SCAR2H == 0x00) || (SCAR3H == 0x00) || (SCAR4H == 0x00)) { if (SCAR0H == 0x00) {
// Disable scratch RAM mapping // Disable scratch RAM mapping
SCAR1H = 0b11; SCAR0H = 0b11;
SCAR2H = 0b11;
SCAR3H = 0b11;
SCAR4H = 0b11;
} else { } else {
int i; int i;
// Copy scratch ROM // Copy scratch ROM
@ -60,22 +47,10 @@ void scratch_trampoline(void) {
scratch_ram[i] = 0x00; scratch_ram[i] = 0x00;
} }
// Set scratch RAM 1 mapping at 0x0000 and enable // Set scratch RAM 0 mapping at 0x0000 and enable
SCAR1L = 0x00; SCAR0L = 0x00;
SCAR1M = 0x00; SCAR0M = 0x00;
SCAR1H = 0x00; SCAR0H = 0x00;
// Set scratch RAM 2 mapping at 0x0400 and enable
SCAR2L = 0x00;
SCAR2M = 0x04;
SCAR2H = 0x00;
// Set scratch RAM 3 mapping at 0x0600 and enable
SCAR3L = 0x00;
SCAR3M = 0x06;
SCAR3H = 0x00;
// Set scratch RAM 4 mapping at 0x0700 and enable
SCAR4L = 0x00;
SCAR4M = 0x07;
SCAR4H = 0x00;
} }
// Jump to reset function // Jump to reset function

View File

@ -16,7 +16,7 @@ SCRATCH_CC=\
sdcc \ sdcc \
-mmcs51 \ -mmcs51 \
--model-small \ --model-small \
--code-size 2048 \ --code-size 4096 \
--Werror --Werror
# Convert from binary file to C header # Convert from binary file to C header