Add mmu-specific code, WIP.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26115 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2008-06-23 22:25:43 +00:00
parent 57ba13c507
commit ac00c6372d
7 changed files with 207 additions and 15 deletions
@@ -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
+1 -1
View File
@@ -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;
+1 -4
View File
@@ -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
+7 -1
View File
@@ -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
@@ -0,0 +1,84 @@
/*
* Copyright 2004-2007, Axel Dörfler, [email protected].
* Based on code written by Travis Geiselbrecht for NewOS.
*
* Distributed under the terms of the MIT License.
*/
#include "mmu.h"
#include <boot/platform.h>
#include <boot/stdio.h>
#include <boot/kernel_args.h>
#include <boot/stage2.h>
#include <arch/cpu.h>
#include <arch_kernel.h>
#include <kernel.h>
#include <OS.h>
#include <string.h>
#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
};
@@ -0,0 +1,88 @@
/*
* Copyright 2004-2007, Axel Dörfler, [email protected].
* Based on code written by Travis Geiselbrecht for NewOS.
*
* Distributed under the terms of the MIT License.
*/
#include "mmu.h"
#include <boot/platform.h>
#include <boot/stdio.h>
#include <boot/kernel_args.h>
#include <boot/stage2.h>
#include <arch/cpu.h>
#include <arch_kernel.h>
#include <kernel.h>
#include <OS.h>
#include <string.h>
#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
};
+6 -9
View File
@@ -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");
}