Support use of all available scratch RAM
This commit is contained in:
parent
3e8cc817b7
commit
8950a783f4
@ -16,7 +16,7 @@ SCRATCH_CC=\
|
|||||||
sdcc \
|
sdcc \
|
||||||
-mmcs51 \
|
-mmcs51 \
|
||||||
--model-small \
|
--model-small \
|
||||||
--code-size 1024 \
|
--code-size 2048 \
|
||||||
--Werror
|
--Werror
|
||||||
|
|
||||||
# Convert from binary file to C header
|
# Convert from binary file to C header
|
||||||
|
@ -8,13 +8,25 @@ uint8_t __code scratch_rom[] = {
|
|||||||
#include <scratch.h>
|
#include <scratch.h>
|
||||||
};
|
};
|
||||||
|
|
||||||
// Scratch RAM 1 is 1024 bytes, located at 2048 bytes
|
// Scratch RAM 1, 2, 3, and 4 are 2048 bytes total, located at 0x0800 bytes
|
||||||
volatile uint8_t __xdata __at(0x0800) scratch_ram_1[1024];
|
volatile uint8_t __xdata __at(0x0800) scratch_ram[2048];
|
||||||
|
|
||||||
volatile uint8_t __xdata __at(0x1043) SCAR1L;
|
volatile uint8_t __xdata __at(0x1043) SCAR1L;
|
||||||
volatile uint8_t __xdata __at(0x1044) SCAR1M;
|
volatile uint8_t __xdata __at(0x1044) SCAR1M;
|
||||||
volatile uint8_t __xdata __at(0x1045) SCAR1H;
|
volatile uint8_t __xdata __at(0x1045) SCAR1H;
|
||||||
|
|
||||||
|
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 {
|
||||||
__asm
|
__asm
|
||||||
@ -27,24 +39,36 @@ static void scratch_start(void) __naked {
|
|||||||
|
|
||||||
// Enter scratch ROM
|
// Enter scratch ROM
|
||||||
int scratch_trampoline(void) {
|
int scratch_trampoline(void) {
|
||||||
// Uses SCAR1 which is mapped at 0x0800 in data space and is 1024 bytes in
|
// Uses SCAR1, 2, 3, and 4 which are mapped at 0x0800 in data space and are
|
||||||
// size. SCAR0 cannot be used due to __pdata overwriting it.
|
// 2048 bytes in size. SCAR0 cannot be used due to __pdata overwriting it.
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
// Copy scratch ROM
|
// Copy scratch ROM
|
||||||
for (i = 0; i < ARRAY_SIZE(scratch_rom) && i < ARRAY_SIZE(scratch_ram_1); i++) {
|
for (i = 0; i < ARRAY_SIZE(scratch_rom) && i < ARRAY_SIZE(scratch_ram); i++) {
|
||||||
scratch_ram_1[i] = scratch_rom[i];
|
scratch_ram[i] = scratch_rom[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill the rest with nop
|
// Fill the rest with nop
|
||||||
for (; i < ARRAY_SIZE(scratch_ram_1); i++) {
|
for (; i < ARRAY_SIZE(scratch_ram); i++) {
|
||||||
scratch_ram_1[i] = 0x00;
|
scratch_ram[i] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set mapping at 0x0000 and enable
|
// Set scratch RAM 1 mapping at 0x0000 and enable
|
||||||
SCAR1L = 0x00;
|
SCAR1L = 0x00;
|
||||||
SCAR1M = 0x00;
|
SCAR1M = 0x00;
|
||||||
SCAR1H = 0x00;
|
SCAR1H = 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 0x0800 and enable
|
||||||
|
SCAR4L = 0x00;
|
||||||
|
SCAR4M = 0x08;
|
||||||
|
SCAR4H = 0x00;
|
||||||
|
|
||||||
// Jump to scratch reset function
|
// Jump to scratch reset function
|
||||||
__asm__("ljmp 0");
|
__asm__("ljmp 0");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user