From: Brett Gordon Date: Thu, 2 Jun 2016 17:53:21 +0000 (-0400) Subject: coco3: autodetect and use up to 2M of RAM X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=2699cd1ca4a83d6ded2c7b4ac4766c6af761d4ca;p=FUZIX.git coco3: autodetect and use up to 2M of RAM --- diff --git a/Kernel/platform-coco3/coco3.s b/Kernel/platform-coco3/coco3.s index a44e45d1..405c05b2 100644 --- a/Kernel/platform-coco3/coco3.s +++ b/Kernel/platform-coco3/coco3.s @@ -37,6 +37,7 @@ .globl nmi_handler .globl null_handler .globl video_init + .globl _scanmem include "kernel.def" include "../kernel09.def" @@ -142,9 +143,16 @@ init_hardware: ;; High speed poke sta 0xffd9 ; high speed poke ;; set system RAM size - ldd #512 + jsr _scanmem ; X = number of pages + tfr x,d + lslb + rola + lslb + rola + lslb + rola std _ramsize - ldd #512-64 + subd #64+16 std _procmem ;; set initial user mmu ldd #8 diff --git a/Kernel/platform-coco3/config.h b/Kernel/platform-coco3/config.h index 35649783..d9108dce 100644 --- a/Kernel/platform-coco3/config.h +++ b/Kernel/platform-coco3/config.h @@ -17,7 +17,7 @@ /* We use flexible 16K banks so use the helper */ #define CONFIG_BANK16 #define CONFIG_BANKS 4 -#define MAX_MAPS 32-3 +#define MAX_MAPS 128-3 #define MAPBASE 0x0000 /* And swapping */ /* #define SWAPDEV 2051 */ diff --git a/Kernel/platform-coco3/main.c b/Kernel/platform-coco3/main.c index 39fcb749..34d95574 100644 --- a/Kernel/platform-coco3/main.c +++ b/Kernel/platform-coco3/main.c @@ -33,6 +33,27 @@ void do_beep(void) { } +/* Scan memory return number of 8k pages found */ +__attribute__((section(".discard"))) +int scanmem(void) +{ + volatile uint8_t *mmu=(uint8_t *)0xffa8; + volatile uint8_t *ptr=(uint8_t *)0x0100; + int i; + for( i = 0; i<256; i++ ){ + *mmu=i; + *ptr=0; + } + *mmu=0; + *ptr=0xff; + *mmu=1; + for( i = 1; i<256 && !*ptr ; ) + *mmu=++i; + *mmu=0; + return i; +} + + /* Map handling: We have flexible paging. Each map table consists of a set of pages with the last page repeated to fill any holes. @@ -41,15 +62,18 @@ void do_beep(void) void pagemap_init(void) { int i; + int max = scanmem(); + /* We have 64 8k pages for a CoCo3 so insert every other one * into the kernel allocator map. */ - for (i = 10; i < 64; i+=2) + for (i = 10; i < max ; i+=2) pagemap_add(i); /* add common page last so init gets it */ pagemap_add(6); } + void map_init(void) { }