diff --git a/src/system/boot/platform/atari_m68k/atari_memory_map.h b/src/system/boot/platform/atari_m68k/atari_memory_map.h index b8b9000ac9..881450a898 100644 --- a/src/system/boot/platform/atari_m68k/atari_memory_map.h +++ b/src/system/boot/platform/atari_m68k/atari_memory_map.h @@ -5,25 +5,70 @@ #ifndef ATARI_MEMORY_MAP_H #define ATARI_MEMORY_MAP_H -#define ATARI_CHIPRAM_TOP_TT 0x00a00000 -/* -> e00000 is VME for MegaST*/ -#define ATARI_CHIPRAM_TOP_FALCON 0x00e00000 +/* the DMA-accessible RAM */ +#define ATARI_CHIPRAM_BASE 0x00000000 +#define ATARI_CHIPRAM_MAX 0x00e00000 +#define ATARI_CHIPRAM_LAST \ + (ATARI_CHIPRAM_BASE + (ATARI_CHIPRAM_MAX - 1)) -#define ATARI_ROM_BASE ATARI_CHIPRAM_TOP_FALCON -#define ATARI_ROM_TOP 0x00f00000 -#define ATARI_IO_BASE ATARI_ROM_TOP -#define ATARI_CARTRIDGE_BASE 0x00fa0000 -#define ATARI_OLD_ROM_BASE 0x00fc0000 +#define ATARI_TOSROM_BASE 0x00e00000 +#define ATARI_TOSROM_MAX 0x00100000 +#define ATARI_TOSROM_LAST \ + (ATARI_TOSROM_BASE + (ATARI_TOSROM_MAX - 1)) -#define ATARI_IO_TOP 0x01000000 -#define ATARI_FASTRAM_TOP ATARI_IO_TOP +/* some reserved ST I/O there... */ +/* cartridge ROM */ +#define ATARI_CARTROM_BASE 0x00fa0000 +#define ATARI_CARTROM_MAX 0x00020000 +#define ATARI_CARTROM_LAST \ + (ATARI_CARTROM_BASE + (ATARI_CARTROM_MAX - 1)) + +#define ATARI_SYSROM_BASE 0x00fc0000 +#define ATARI_SYSROM_MAX 0x00030000 +#define ATARI_SYSROM_LAST \ + (ATARI_SYSROM_BASE + (ATARI_SYSROM_MAX - 1)) + +/* more ST I/O there... */ + +/* the fast, non-DMA-accessible RAM */ +#define ATARI_FASTRAM_BASE 0x01000000 +// max on TT, +// but there is nothing beyond until SHADOW_BASE +//#define ATARI_FASTRAM_MAX 0x00400000 +#define ATARI_FASTRAM_MAX 0xfe000000 +#define ATARI_FASTRAM_LAST \ + (ATARI_FASTRAM_BASE + (ATARI_FASTRAM_MAX - 1)) + + + +/* due to ST legacy (24 bit addressing), IO is actually there */ #define ATARI_SHADOW_BASE 0xff000000 -/* how we will use it */ +#define ATARI_IO_BASE (ATARI_SHADOW_BASE + 0x00f00000) +#define ATARI_IO_MAX 0x00100000 +#define ATARI_IO_LAST \ + (ATARI_IO_BASE + (ATARI_IO_MAX - 1)) + + + + + +/* physical memory layout as used by the bootloader */ + //#define ATARI_ZBEOS_STACK_BASE 0x00040000 #define ATARI_ZBEOS_STACK_BASE 0x00060000 #define ATARI_ZBEOS_STACK_END 0x00080000 -#define ATARI_ZBEOS_BASE 0x00080000 /* from .prg shell.S will copy itself there */ + +/* from .prg shell.S will copy itself there + * must stay in sync with src/system/ldscripts/m68k/boot_prg_atari_m68k.ld + */ +#define ATARI_ZBEOS_BASE 0x00080000 +#define ATARI_ZBEOS_MAX 0x00080000 +#define ATARI_ZBEOS_LAST \ + (ATARI_ZBEOS_BASE + (ATARI_ZBEOS_MAX - 1)) + + +#define ATARI_STRAM_VIRT_BASE #endif /* ATARI_MEMORY_MAP_H */ diff --git a/src/system/boot/platform/atari_m68k/mmu.cpp b/src/system/boot/platform/atari_m68k/mmu.cpp index bf25150a3c..c62c38f1a9 100644 --- a/src/system/boot/platform/atari_m68k/mmu.cpp +++ b/src/system/boot/platform/atari_m68k/mmu.cpp @@ -6,6 +6,7 @@ */ +#include "atari_memory_map.h" #include "mmu.h" #include @@ -46,20 +47,14 @@ /** The (physical) memory layout of the boot loader is currently as follows: * 0x0800 - 0x10000 supervisor mode stack (1) XXX: more ? x86 starts at 500 * 0x10000 - ? code (up to ~500 kB) - * unused (TT0 instead): - * 0x90000 1st temporary page table (identity maps 0-4 MB) - * 0x91000 2nd (4-8 MB) - * - * 0x92000 - 0x92000 further page tables - * 0x100000 page directory + * 0x100000 or FAST_RAM_BASE if any: + * ... page directory * ... boot loader heap (32 kB) * ... free physical memory - * [0xa00000] end of chip RAM for TT (falcon has more till ROM) - * [0xe00000 - 0xf00000 TOS ROM] - * [0xf00000 - 0x1000000 I/O] - XXX: where is the video buffer ? + * 0xdNNNNN video buffer usually there, as per v_bas_ad + * (=Logbase() but Physbase() is better) * - * The first 16 MB (2) are identity mapped (0x0 - 0x1000000); paging + * The first 32 MB (2) are identity mapped (0x0 - 0x1000000); paging * is turned on. The kernel is mapped at 0x80000000, all other stuff * mapped by the loader (kernel args, modules, driver settings, ...) * comes after 0x81000000 which means that there is currently only @@ -67,9 +62,10 @@ * * (1) no need for user stack, we are already in supervisor mode in the * loader. - * (2) maps the whole regular ST space; transparent translation registers - * have larger granularity anyway; + * (2) maps the whole regular ST space; transparent translation registers + * have larger granularity anyway. */ +#warning M68K: check for Physbase() < ST_RAM_TOP #define TRACE_MMU #ifdef TRACE_MMU @@ -444,7 +440,8 @@ mmu_init_for_kernel(void) // remove identity mapping of ST space - gMMUOps->set_tt(0, NULL, 0, 0); + // actually done by the kernel when it's done using query_early + //gMMUOps->set_tt(0, NULL, 0, 0); #if 0 // set up a new idt @@ -594,6 +591,11 @@ mmu_init(void) gKernelArgs.num_physical_allocated_ranges = 1; // remember the start of the allocated physical pages + // enable transparent translation of the first 32 MB + gMMUOps->set_tt(0, ATARI_CHIPRAM_BASE, 0x02000000, 0); + // enable transparent translation of the 16MB ST shadow range for I/O + gMMUOps->set_tt(0, ATARI_SHADOW_BASE, 0x01000000, 0); + init_page_directory(); #if 0 diff --git a/src/system/boot/platform/atari_m68k/mmu_030.cpp b/src/system/boot/platform/atari_m68k/mmu_030.cpp index b282fb5b6b..8ac4e4e6fd 100644 --- a/src/system/boot/platform/atari_m68k/mmu_030.cpp +++ b/src/system/boot/platform/atari_m68k/mmu_030.cpp @@ -45,20 +45,20 @@ initialize(void) static status_t set_tt(int which, addr_t pa, size_t len, uint32 perms) { - TRACE(("mmu_030:set_tt(%d, 0x%lx, %ld, 0x%08lx)\n", which, pa, len, perms)); + TRACE(("mmu_030:set_tt(%d, 0x%lx, 0x%lx, 0x%08lx)\n", which, pa, len, perms)); uint32 mask; uint32 ttr = 0; - mask = 1; + mask = 0x0000ffff; if (len) { + len = (len >> 24) & 0x00ff; while (len >>= 1) mask <<= 1; - mask = (mask - 1); // enable, cachable(?), r/w // super only // mc68030 user's manual, page 9-57 ttr = 0x08043; ttr |= (pa & 0xff000000); - ttr |= ((mask & 0xff000000) >> 8); + ttr |= (mask & 0x00ff0000); } TRACE(("mmu_030:set_tt: 0x%08lx\n", ttr)); diff --git a/src/system/boot/platform/atari_m68k/mmu_040.cpp b/src/system/boot/platform/atari_m68k/mmu_040.cpp index 98b2cf7c2d..ae307d91db 100644 --- a/src/system/boot/platform/atari_m68k/mmu_040.cpp +++ b/src/system/boot/platform/atari_m68k/mmu_040.cpp @@ -43,21 +43,21 @@ initialize(void) static status_t -set_tt(int which, addr_t pa, size_t len, uint32 perms) +set_tt(int which, addr_t pa, size_t len, uint32 perms /* NOTUSED */) { - TRACE(("mmu_040:set_tt(%d, 0x%lx, %ld, 0x%08lx)\n", which, pa, len, perms)); + TRACE(("mmu_040:set_tt(%d, 0x%lx, 0x%lx, 0x%08lx)\n", which, pa, len, perms)); uint32 mask; uint32 ttr = 0; - mask = 1; + mask = 0x0000ffff; if (len) { + len = (len >> 24) & 0x00ff; while (len >>= 1) mask <<= 1; - mask = (mask - 1); // enable, super only, upa=0, // cachable write-through, rw ttr = 0x0a000; ttr |= (pa & 0xff000000); - ttr |= ((mask & 0xff000000) >> 8); + ttr |= (mask & 0x00ff0000); } TRACE(("mmu_040:set_tt: 0x%08lx\n", ttr)); diff --git a/src/system/boot/platform/atari_m68k/start.c b/src/system/boot/platform/atari_m68k/start.c index f03b1ba13c..a05109dc04 100644 --- a/src/system/boot/platform/atari_m68k/start.c +++ b/src/system/boot/platform/atari_m68k/start.c @@ -123,11 +123,16 @@ _start(void) init_nat_features(); //serial_init(); - console_init(); Bconout(DEV_CON, 'K'); - cpu_init(); + console_init(); Bconout(DEV_CON, 'U'); - //mmu_init(); + dprintf("membot = %p\n", *TOSVAR_membot); + dprintf("memtop = %p\n", *TOSVAR_memtop); + dprintf("v_bas_ad= %p\n", *TOSVAR_v_bas_ad); + dprintf("phystop = %p\n", *TOSVARphystop); + dprintf("ramtop = %p\n", *TOSVARramtop); + cpu_init(); + mmu_init(); // wait a bit to give the user the opportunity to press a key spin(750000);