From ac12a91f5607d8839b9bcd82c60a9e15b932b778 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 15 Jan 2020 16:26:10 -0700 Subject: [PATCH] Increase scratch ROM size for galp3-c --- src/board/system76/galp3-c/scratch.c | 37 ++++++++++++------- src/board/system76/galp3-c/scratch/scratch.mk | 2 +- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/board/system76/galp3-c/scratch.c b/src/board/system76/galp3-c/scratch.c index ef1b074..0e59ba3 100644 --- a/src/board/system76/galp3-c/scratch.c +++ b/src/board/system76/galp3-c/scratch.c @@ -3,13 +3,17 @@ #include -// 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[] = { #include }; -// Scratch RAM 1, 2, 3, and 4 are 2048 bytes total, located at 0x0800 bytes -volatile uint8_t __xdata __at(0x0800) scratch_ram[2048]; +// Scratch RAM 0, 1, 2, 3, and 4 are 4096 bytes total, located at 0x0000 bytes +volatile uint8_t __xdata __at(0x0000) scratch_ram[4096]; + +volatile uint8_t __xdata __at(0x1040) SCAR0L; +volatile uint8_t __xdata __at(0x1041) SCAR0M; +volatile uint8_t __xdata __at(0x1042) SCAR0H; volatile uint8_t __xdata __at(0x1043) SCAR1L; volatile uint8_t __xdata __at(0x1044) SCAR1M; @@ -39,11 +43,12 @@ static void scratch_start(void) __naked { // Enter or exit scratch ROM void scratch_trampoline(void) { - // Uses SCAR1, 2, 3, and 4 which are mapped at 0x0800 in data space and are - // 2048 bytes in size. SCAR0 cannot be used due to __pdata overwriting it. + // Uses SCAR0, 1, 2, 3, and 4 which are mapped at 0x0000 in data space and are + // 4096 bytes in size. - if ((SCAR1H == 0x00) || (SCAR2H == 0x00) || (SCAR3H == 0x00) || (SCAR4H == 0x00)) { + if ((SCAR0H == 0x00) || (SCAR1H == 0x00) || (SCAR2H == 0x00) || (SCAR3H == 0x00) || (SCAR4H == 0x00)) { // Disable scratch RAM mapping + SCAR0H = 0b11; SCAR1H = 0b11; SCAR2H = 0b11; SCAR3H = 0b11; @@ -60,21 +65,25 @@ void scratch_trampoline(void) { scratch_ram[i] = 0x00; } - // Set scratch RAM 1 mapping at 0x0000 and enable + // Set scratch RAM 0 mapping at 0x0000 and enable + SCAR0L = 0x00; + SCAR0M = 0x00; + SCAR0H = 0x00; + // Set scratch RAM 1 mapping at 0x0800 and enable SCAR1L = 0x00; - SCAR1M = 0x00; + SCAR1M = 0x08; SCAR1H = 0x00; - // Set scratch RAM 2 mapping at 0x0400 and enable + // Set scratch RAM 2 mapping at 0x0C00 and enable SCAR2L = 0x00; - SCAR2M = 0x04; + SCAR2M = 0x0C; SCAR2H = 0x00; - // Set scratch RAM 3 mapping at 0x0600 and enable + // Set scratch RAM 3 mapping at 0x0E00 and enable SCAR3L = 0x00; - SCAR3M = 0x06; + SCAR3M = 0x0E; SCAR3H = 0x00; - // Set scratch RAM 4 mapping at 0x0700 and enable + // Set scratch RAM 4 mapping at 0x0F00 and enable SCAR4L = 0x00; - SCAR4M = 0x07; + SCAR4M = 0x0F; SCAR4H = 0x00; } diff --git a/src/board/system76/galp3-c/scratch/scratch.mk b/src/board/system76/galp3-c/scratch/scratch.mk index ba018b5..981eb02 100644 --- a/src/board/system76/galp3-c/scratch/scratch.mk +++ b/src/board/system76/galp3-c/scratch/scratch.mk @@ -16,7 +16,7 @@ SCRATCH_CC=\ sdcc \ -mmcs51 \ --model-small \ - --code-size 2048 \ + --code-size 4096 \ --Werror # Convert from binary file to C header