diff --git a/src/system/boot/platform/atari_m68k/atari_memory_map.h b/src/system/boot/platform/atari_m68k/atari_memory_map.h new file mode 100644 index 0000000000..766485292e --- /dev/null +++ b/src/system/boot/platform/atari_m68k/atari_memory_map.h @@ -0,0 +1,23 @@ +/* + * Copyright 2008, François Revol, revol@free.fr. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#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 + +#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_IO_TOP 0x01000000 +#define ATARI_FASTRAM_TOP ATARI_IO_TOP + +#define ATARI_SHADOW_BASE 0xff000000 + +#endif /* ATARI_MEMORY_MAP_H */ diff --git a/src/system/boot/platform/atari_m68k/cpu.cpp b/src/system/boot/platform/atari_m68k/cpu.cpp index 6c211e71fe..a017b73050 100644 --- a/src/system/boot/platform/atari_m68k/cpu.cpp +++ b/src/system/boot/platform/atari_m68k/cpu.cpp @@ -29,12 +29,15 @@ # define TRACE(x) ; #endif +#warning M68K: add set_vbr() + static status_t check_cpu_features() { #warning M68K: TODO: probe ourselves, we shouldn't trust the TOS! - const tos_cookie *c = tos_find_cookie('_CPU'); + const tos_cookie *c; + c = tos_find_cookie('_CPU'); if (!c) { panic("can't get a cookie (_CPU)! Mum, I'm hungry!"); return EINVAL; @@ -47,6 +50,18 @@ check_cpu_features() gKernelArgs.arch_args.has_lpstop = (c->ivalue >= 60)?true:false; #warning M68K: add cpu type to kern args + c = tos_find_cookie('_FPU'); + if (!c) { + panic("can't get a cookie (_FPU)! Mum, I'm hungry!"); + return EINVAL; + } + +#warning M68K: check for fpu in detail + if (c->ivalue < 2 || c->ivalue > 7) { + panic("bad fpu"); + return EINVAL; + } + return B_OK; } diff --git a/src/system/boot/platform/atari_m68k/mmu.cpp b/src/system/boot/platform/atari_m68k/mmu.cpp index 0d2b0cc897..f7adffc195 100644 --- a/src/system/boot/platform/atari_m68k/mmu.cpp +++ b/src/system/boot/platform/atari_m68k/mmu.cpp @@ -48,36 +48,6 @@ # define TRACE(x) ; #endif -struct gdt_idt_descr { - uint16 limit; - uint32 *base; -} _PACKED; - -// memory structure returned by int 0x15, ax 0xe820 -struct extended_memory { - uint64 base_addr; - uint64 length; - uint32 type; -}; - -#ifdef _PXE_ENV - -static const uint32 kDefaultPageTableFlags = 0x07; // present, user, R/W -static const size_t kMaxKernelSize = 0x100000; // 1 MB for the kernel - -// working page directory and page table -static uint32 *sPageDirectory = 0; - -static addr_t sNextPhysicalAddress = 0x112000; -static addr_t sNextVirtualAddress = KERNEL_BASE + kMaxKernelSize; -static addr_t sMaxVirtualAddress = KERNEL_BASE + 0x400000; - -static addr_t sNextPageTableAddress = 0x7d000; -static const uint32 kPageTableRegionEnd = 0x8b000; - // we need to reserve 2 pages for the SMP trampoline code - -#else - static const uint32 kDefaultPageTableFlags = 0x07; // present, user, R/W static const size_t kMaxKernelSize = 0x100000; // 1 MB for the kernel @@ -92,9 +62,6 @@ static addr_t sNextPageTableAddress = 0x90000; static const uint32 kPageTableRegionEnd = 0x9e000; // we need to reserve 2 pages for the SMP trampoline code -#endif - - static addr_t get_next_virtual_address(size_t size) { diff --git a/src/system/boot/platform/atari_m68k/mmu.h b/src/system/boot/platform/atari_m68k/mmu.h index 7cd38633f9..b429b3fa0e 100644 --- a/src/system/boot/platform/atari_m68k/mmu.h +++ b/src/system/boot/platform/atari_m68k/mmu.h @@ -22,6 +22,12 @@ extern addr_t mmu_map_physical_memory(addr_t physicalAddress, size_t size, uint3 extern void *mmu_allocate(void *virtualAddress, size_t size); extern void mmu_free(void *virtualAddress, size_t size); +struct boot_mmu_ops { + // len=0 to disable + status_t (*set_tt)(int which, addr_t pa, size_t len, uint32 perms); + +}; + #ifdef __cplusplus } #endif diff --git a/src/system/boot/platform/atari_m68k/stage1.S b/src/system/boot/platform/atari_m68k/stage1.S index 70b2aec6f5..6a09c896ee 100644 --- a/src/system/boot/platform/atari_m68k/stage1.S +++ b/src/system/boot/platform/atari_m68k/stage1.S @@ -73,6 +73,12 @@ #define S_IFDIR 00000040000o +// NOTE: normal programs (.prg) run as user mode, +// while boot sector is chained in supervisor mode. +// this means using Super(SUP_INQUIRE) we can know +// from the same entry point if we were run from boot code or prg. + + //Pterm0 //move.w #1,%d0 //trap #1 diff --git a/src/system/boot/platform/atari_m68k/toscalls.h b/src/system/boot/platform/atari_m68k/toscalls.h index 180f7d8c16..84c82b661e 100644 --- a/src/system/boot/platform/atari_m68k/toscalls.h +++ b/src/system/boot/platform/atari_m68k/toscalls.h @@ -129,6 +129,12 @@ extern int32 xbios(uint16 nr, ...); extern int32 gemdos(uint16 nr, ...); +#define SUP_USER 0 +#define SUP_SUPER 1 + +#define SUP_SET (void *)0 +#define SUP_INQUIRE (void *)1 + // official names #define Pterm0() gemdos(0) #define Cconin() gemdos(1) @@ -167,6 +173,33 @@ static inline const tos_cookie *tos_find_cookie(uint32 what) return NULL; } +/* + * OSHEADER access + */ + +typedef struct tos_osheader { + uint16 os_entry; + uint16 os_version; + void *reseth; + struct tos_osheader *os_beg; + void *os_end; + void *os_rsv1; + void *os_magic; + uint32 os_date; + uint32 os_conf; + //uint32/16? os_dosdate; + // ... more stuff we don't care about +} tos_osheader; + +#define tos_sysbase ((const struct tos_osheader **)0x4F2) + +static inline const struct tos_osheader *tos_get_osheader() +{ + if (!(*tos_sysbase)) + return NULL; + return (*tos_sysbase)->os_beg; +} + #endif /* __ASSEMBLER__ */ #ifdef __cplusplus