* Comments on how mmu will be set up in the bootloader

* Add aranym native feature helper funcs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23526 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-01-14 23:14:26 +00:00
parent 005ff05292
commit aa84dea3fd
3 changed files with 142 additions and 19 deletions

View File

@ -21,6 +21,7 @@
#include <string.h>
//XXX: x86
/** The (physical) memory layout of the boot loader is currently as follows:
* 0x0500 - 0x10000 protected mode stack
* 0x0500 - 0x09000 real mode stack
@ -41,7 +42,36 @@
* the kernel itself (see kMaxKernelSize).
*/
//#define TRACE_MMU
// notes m68k:
/** 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
* ... 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 ?
*
* The first 16 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
* 1 MB reserved for the kernel itself (see kMaxKernelSize).
*
* (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;
*/
#define TRACE_MMU
#ifdef TRACE_MMU
# define TRACE(x) dprintf x
#else
@ -60,7 +90,12 @@ static addr_t sMaxVirtualAddress = KERNEL_BASE + 0x400000;
static addr_t sNextPageTableAddress = 0x90000;
static const uint32 kPageTableRegionEnd = 0x9e000;
// we need to reserve 2 pages for the SMP trampoline code
// 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
get_next_virtual_address(size_t size)
@ -260,6 +295,8 @@ init_page_directory(void)
{
TRACE(("init_page_directory\n"));
gMMUOps->load_rp();
gMMUOps->enable_paging();
#if 0
// allocate a new pgdir
sPageDirectory = (uint32 *)get_next_physical_page();
@ -405,6 +442,13 @@ extern "C" void
mmu_init_for_kernel(void)
{
TRACE(("mmu_init_for_kernel\n"));
// remove identity mapping of ST space
gMMUOps->set_tt(0, NULL, 0, 0);
#if 0
// set up a new idt
{

View File

@ -23,8 +23,11 @@ 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
/* 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)(XXX);
status_t (*enable_paging)(void);
};

View File

@ -13,6 +13,14 @@
extern "C" {
#endif
#ifndef __ASSEMBLER__
#include <OS.h>
#endif
/*
* Atari BIOS calls
*/
/* those are used by asm code too */
#define DEV_PRINTER 0
@ -37,19 +45,8 @@ extern "C" {
#define RW_NORETRY 0x04
#define RW_NOTRANSLATE 0x08
#define SUP_USER 0
#define SUP_SUPER 1
#define SUP_SET 0
#define SUP_INQUIRE 1
#ifndef __ASSEMBLER__
#include <OS.h>
/*
* Atari BIOS calls
*/
extern int32 bios(uint16 nr, ...);
// cf. http://www.fortunecity.com/skyscraper/apple/308/html/bios.htm
@ -92,12 +89,12 @@ static inline int Bconputs(int16 handle, const char *string)
return i;
}
#endif /* __ASSEMBLER__ */
/*
* Atari XBIOS calls
*/
extern int32 xbios(uint16 nr, ...);
#define IM_DISABLE 0
#define IM_RELATIVE 1
#define IM_ABSOLUTE 2
@ -106,6 +103,20 @@ extern int32 xbios(uint16 nr, ...);
#define NVM_READ 0
#define NVM_WRITE 1
#define NVM_RESET 2
// unofficial
#define NVM_R_SEC 0
#define NVM_R_MIN 2
#define NVM_R_HOUR 4
#define NVM_R_MDAY 7
#define NVM_R_MON 8 /*+- 1*/
#define NVM_R_YEAR 9
#define NVM_R_VIDEO 29
#ifndef __ASSEMBLER__
extern int32 xbios(uint16 nr, ...);
#define Initmous(mode, param, vec) xbios(0, (int16)mode, (void *)param, (void *)vec)
#define Physbase() (void *)xbios(2)
@ -130,23 +141,36 @@ extern int32 xbios(uint16 nr, ...);
#define Locksnd() xbios(128)
#define Unlocksnd() xbios(129)
#endif /* __ASSEMBLER__ */
/*
* Atari GEMDOS calls
*/
#define SUP_USER 0
#define SUP_SUPER 1
#ifdef __ASSEMBLER__
#define SUP_SET 0
#define SUP_INQUIRE 1
#else
extern int32 gemdos(uint16 nr, ...);
#undef SUP_SET
#undef SUP_INQUIRE
#define SUP_SET (void *)0
#define SUP_INQUIRE (void *)1
// official names
#define Pterm0() gemdos(0)
#define Cconin() gemdos(1)
#define Super(a) gemdos(0x20, (uint32)a)
#define Super(s) gemdos(0x20, (uint32)s)
#define Pterm(retcode) gemdos(76, (int16)retcode)
#endif /* __ASSEMBLER__ */
#ifdef __ASSEMBLER__
/*
* error mapping
* in debug.c
@ -208,6 +232,58 @@ static inline const struct tos_osheader *tos_get_osheader()
#endif /* __ASSEMBLER__ */
/*
* XHDI
*/
/*
* ARAnyM Native Features
*/
#define NF_COOKIE 0x5f5f4e46L //'__NF'
#define NF_MAGIC 0x20021021L
typedef struct {
long magic;
long (*nfGetID) (const char *);
long (*nfCall) (long ID, ...);
} NatFeatCookie;
extern NatFeatCookie *gNatFeatCookie;
static inline NatFeatCookie *nat_features(void)
{
if (gNatFeatCookie == (void *)-1 || !gNatFeatCookie)
return NULL;
gNatFeatCookie = tos_find_cookie(NF_COOKIE);
if (!gNatFeatCookie || gNatFeatCookie->magic != NF_MAGIC) {
gNatFeatCookie = (void *)-1;
return NULL;
}
return c;
}
/* XHDI NatFeat */
#define NF_XHDI "XHDI"
#define nfxhdi(code, a...) \
{ \
gNatFeatCookie->nfCall((uint32)
if (gNatFeatCookie == NULL) {
c = tos_find_cookie(NF_COOKIE);
if (!c || c->magic != NF_MAGIC)
return NULL;
return c;
}
#define NFXHversion() nfxhdi(0)
#endif /* __ASSEMBLER__ */
#ifdef __cplusplus
}
#endif