diff --git a/src/system/boot/platform/atari_m68k/Jamfile b/src/system/boot/platform/atari_m68k/Jamfile index a1e33aa7a9..39c9eb28d4 100644 --- a/src/system/boot/platform/atari_m68k/Jamfile +++ b/src/system/boot/platform/atari_m68k/Jamfile @@ -23,6 +23,25 @@ KernelMergeObject boot_platform_atari_m68k_shell.o : : -Wa,--pcrel ; +# cpu-specific stuff +# should be moved to boot/arch/m68k/... +# XXX: add 020+68851 support +KernelMergeObject boot_arch_m68k_030.o : + mmu_030.cpp + : -fno-pic -Wno-unused -m68030 +; + +KernelMergeObject boot_arch_m68k_040.o : + mmu_040.cpp + : -fno-pic -Wno-unused -m68040 +; + +KernelMergeObject boot_arch_m68k_060.o : + mmu_060.cpp + : -fno-pic -Wno-unused -m68060 +; + + KernelMergeObject boot_platform_atari_m68k_other.o : # shell.S start.c @@ -57,6 +76,7 @@ KernelMergeObject boot_platform_atari_m68k.o : : : boot_platform_atari_m68k_shell.o boot_platform_atari_m68k_other.o + boot_arch_m68k_030.o ; # AUTO folder PRG target diff --git a/src/system/boot/platform/atari_m68k/cpu.cpp b/src/system/boot/platform/atari_m68k/cpu.cpp index b0307bde92..fef2a43156 100644 --- a/src/system/boot/platform/atari_m68k/cpu.cpp +++ b/src/system/boot/platform/atari_m68k/cpu.cpp @@ -36,7 +36,7 @@ static status_t check_cpu_features() { -#warning M68K: TODO: probe ourselves, we shouldn't trust the TOS! +#warning M68K: TODO: probe ourselves, we shouldnt trust the TOS! const tos_cookie *c; uint16 cpu_type, fpu_type, fpu_emul; diff --git a/src/system/boot/platform/atari_m68k/mmu.cpp b/src/system/boot/platform/atari_m68k/mmu.cpp index b100178c98..aa40cd39fe 100644 --- a/src/system/boot/platform/atari_m68k/mmu.cpp +++ b/src/system/boot/platform/atari_m68k/mmu.cpp @@ -92,9 +92,6 @@ static addr_t sNextPageTableAddress = 0x90000; static const uint32 kPageTableRegionEnd = 0x9e000; // we need to reserve 2 pages for the SMP trampoline code XXX:no -extern struct boot_mmu_ops k030MMUOps; -extern struct boot_mmu_ops k040MMUOps; -//extern struct boot_mmu_ops k060MMUOps; static struct boot_mmu_ops *gMMUOps; static addr_t @@ -295,7 +292,7 @@ init_page_directory(void) { TRACE(("init_page_directory\n")); - gMMUOps->load_rp(); + gMMUOps->load_rp(NULL); gMMUOps->enable_paging(); #if 0 // allocate a new pgdir diff --git a/src/system/boot/platform/atari_m68k/mmu.h b/src/system/boot/platform/atari_m68k/mmu.h index 80e1412632..db6bec1113 100644 --- a/src/system/boot/platform/atari_m68k/mmu.h +++ b/src/system/boot/platform/atari_m68k/mmu.h @@ -23,14 +23,20 @@ extern void *mmu_allocate(void *virtualAddress, size_t size); extern void mmu_free(void *virtualAddress, size_t size); struct boot_mmu_ops { + void (*initialize)(void); /* len=0 to disable */ status_t (*set_tt)(int which, addr_t pa, size_t len, uint32 perms); /* load root pointers */ - status_t (*load_rp)(void/*XXX*/); + status_t (*load_rp)(addr_t pa); status_t (*enable_paging)(void); }; +extern const struct boot_mmu_ops k030MMUOps; +extern const struct boot_mmu_ops k040MMUOps; +extern const struct boot_mmu_ops k060MMUOps; + + #ifdef __cplusplus } #endif diff --git a/src/system/boot/platform/atari_m68k/mmu_030.cpp b/src/system/boot/platform/atari_m68k/mmu_030.cpp new file mode 100644 index 0000000000..6daeb4982c --- /dev/null +++ b/src/system/boot/platform/atari_m68k/mmu_030.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. + * Based on code written by Travis Geiselbrecht for NewOS. + * + * Distributed under the terms of the MIT License. + */ + + +#include "mmu.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "arch_030_mmu.h" + + +#define TRACE_MMU +#ifdef TRACE_MMU +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +static uint32 *sPageDirectory = 0; + + + +static void +initialize(void) +{ + TRACE(("mmu_030:initialize\n")); +} + + +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)); + + return B_ERROR; +} + + +static status_t +load_rp(addr_t pa) +{ + TRACE(("mmu_030:load_rp(0x%lx)\n", pa)); + long_page_directory_entry entry; + *(uint64 *)&entry = DFL_PAGEENT_VAL; + entry.type = DT_ROOT; + entry.addr = TA_TO_PREA(((addr_t)pa)); + + asm volatile( \ + "pmove (%0),%%srp\n" \ + "pmove (%0),%%crp\n" \ + : : "a"((uint64 *)&entry)); + return B_OK; +} + + +static status_t +enable_paging(void) +{ + TRACE(("mmu_030:enable_paging\n")); + return B_NO_INIT; +} + + +const struct boot_mmu_ops k030MMUOps = { + &initialize, + &set_tt, + &load_rp, + &enable_paging +}; diff --git a/src/system/boot/platform/atari_m68k/mmu_040.cpp b/src/system/boot/platform/atari_m68k/mmu_040.cpp new file mode 100644 index 0000000000..8db9e615ff --- /dev/null +++ b/src/system/boot/platform/atari_m68k/mmu_040.cpp @@ -0,0 +1,88 @@ +/* + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. + * Based on code written by Travis Geiselbrecht for NewOS. + * + * Distributed under the terms of the MIT License. + */ + + +#include "mmu.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "arch_040_mmu.h" + + +#define TRACE_MMU +#ifdef TRACE_MMU +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +static uint32 *sPageDirectory = 0; + + + +static void +initialize(void) +{ + TRACE(("mmu_040:initialize\n")); +} + + +static status_t +set_tt(int which, addr_t pa, size_t len, uint32 perms) +{ + TRACE(("mmu_040:set_tt(%d, 0x%lx, %ld, 0x%08lx)\n", which, pa, len, perms)); + + return B_OK; +} + + +static status_t +load_rp(addr_t pa) +{ + TRACE(("mmu_040:load_rp(0x%lx)\n", pa)); + long_page_directory_entry entry; + *(uint64 *)&entry = DFL_PAGEENT_VAL; + entry.type = DT_ROOT; + entry.addr = TA_TO_PREA(((addr_t)pa)); + + asm volatile( \ + "pmove (%0),%%srp\n" \ + "pmove (%0),%%crp\n" \ + : : "a"((uint64 *)&entry)); + return B_OK; +} + + +static status_t +enable_paging(void) +{ + TRACE(("mmu_040:enable_paging\n")); + asm volatile( \ + "pmove (%0),%%srp\n" \ + "pmove (%0),%%crp\n" \ + : : "a"((uint64 *)&entry)); + return B_OK; +} + + +const struct boot_mmu_ops k040MMUOps = { + &initialize, + &set_tt, + &load_rp, + &enable_paging +}; diff --git a/src/system/boot/platform/atari_m68k/start.c b/src/system/boot/platform/atari_m68k/start.c index 0885daff6b..f03b1ba13c 100644 --- a/src/system/boot/platform/atari_m68k/start.c +++ b/src/system/boot/platform/atari_m68k/start.c @@ -79,17 +79,14 @@ platform_start_kernel(void) dprintf("kernel entry at %lx\n", gKernelArgs.kernel_image.elf_header.e_entry); -#if 0 - asm("movl %0, %%eax; " // move stack out of way - "movl %%eax, %%esp; " + asm("move.l %0, %%sp; " // move stack out of way : : "m" (stackTop)); - asm("pushl $0x0; " // we're the BSP cpu (0) - "pushl %0; " // kernel args - "pushl $0x0;" // dummy retval for call to main - "pushl %1; " // this is the start address - "ret; " // jump. + asm("move.l #0x0,-(%%sp); " // we're the BSP cpu (0) + "move.l %0,-(%%sp); " // kernel args + "move.l #0x0,-(%%sp);" // dummy retval for call to main + "move.l %1,-(%%sp); " // this is the start address + "rts; " // jump. : : "g" (args), "g" (gKernelArgs.kernel_image.elf_header.e_entry)); -#endif panic("kernel returned!\n"); }