diff --git a/headers/private/kernel/arch/m68k/arch_kernel_args.h b/headers/private/kernel/arch/m68k/arch_kernel_args.h index 1e8699b261..15d42349c8 100644 --- a/headers/private/kernel/arch/m68k/arch_kernel_args.h +++ b/headers/private/kernel/arch/m68k/arch_kernel_args.h @@ -46,9 +46,10 @@ typedef struct { struct { //XXX: are those meant to be used by physical // or virtual address ? - int32 (*nf_get_id)(const char *); - int32 (*nf_call)(int32, ...); - int32 nf_dprintf_id; + uint32 (*nf_get_id)(const char *); + int32 (*nf_call)(uint32, ...); + addr_t nf_page; + uint32 nf_dprintf_id; } nat_feat; } atari; } plat_args; diff --git a/src/system/boot/platform/atari_m68k/mmu.cpp b/src/system/boot/platform/atari_m68k/mmu.cpp index e2493dd981..b1849ecc1f 100644 --- a/src/system/boot/platform/atari_m68k/mmu.cpp +++ b/src/system/boot/platform/atari_m68k/mmu.cpp @@ -628,6 +628,8 @@ mmu_init(void) gKernelArgs.num_physical_allocated_ranges++; + gKernelArgs.arch_args.plat_args.atari.nat_feat.nf_page = + get_next_physical_page() /*| 0xff000000*/; } diff --git a/src/system/boot/platform/atari_m68k/toscalls.c b/src/system/boot/platform/atari_m68k/toscalls.c index 25ff67ba95..2a65385792 100644 --- a/src/system/boot/platform/atari_m68k/toscalls.c +++ b/src/system/boot/platform/atari_m68k/toscalls.c @@ -17,7 +17,7 @@ void *gXHDIEntryPoint = NULL; uint32 gXHDIVersion = 0; NatFeatCookie *gNatFeatCookie = NULL; -int32 gDebugPrintfNatFeatID = 0; +uint32 gDebugPrintfNatFeatID = 0; /*! Maps TOS error codes to native errors */ diff --git a/src/system/boot/platform/atari_m68k/toscalls.h b/src/system/boot/platform/atari_m68k/toscalls.h index 0bc54136bc..a41ba97fa8 100644 --- a/src/system/boot/platform/atari_m68k/toscalls.h +++ b/src/system/boot/platform/atari_m68k/toscalls.h @@ -310,6 +310,7 @@ static inline int Bconputs(int16 handle, const char *string) #define NVM_R_YEAR 9 #define NVM_R_VIDEO 29 +#define VM_INQUIRE -1 #ifndef __ASSEMBLER__ @@ -724,12 +725,12 @@ static inline const struct tos_osheader *tos_get_osheader() typedef struct { uint32 magic; - int32 (*nfGetID) (const char *); - int32 (*nfCall) (int32 ID, ...); + uint32 (*nfGetID) (const char *); + int32 (*nfCall) (uint32 ID, ...); } NatFeatCookie; extern NatFeatCookie *gNatFeatCookie; -extern int32 gDebugPrintfNatFeatID; +extern uint32 gDebugPrintfNatFeatID; static inline NatFeatCookie *nat_features(void) { diff --git a/src/system/boot/platform/atari_m68k/video.cpp b/src/system/boot/platform/atari_m68k/video.cpp index 3e18ed905f..fd7c7045a7 100644 --- a/src/system/boot/platform/atari_m68k/video.cpp +++ b/src/system/boot/platform/atari_m68k/video.cpp @@ -4,6 +4,7 @@ */ +#include "toscalls.h" #include "video.h" //#include "mmu.h" //#include "images.h" @@ -130,6 +131,8 @@ extern "C" status_t platform_init_video(void) { // ToDo: implement me + dprintf("current video mode: \n"); + dprintf("Vsetmode(-1): 0x%08x\n", VsetMode(VM_INQUIRE)); return B_OK; } diff --git a/src/system/kernel/arch/m68k/arch_cpu.cpp b/src/system/kernel/arch/m68k/arch_cpu.cpp index eaf0e996ea..34b6eefc46 100644 --- a/src/system/kernel/arch/m68k/arch_cpu.cpp +++ b/src/system/kernel/arch/m68k/arch_cpu.cpp @@ -60,13 +60,6 @@ arch_cpu_init(kernel_args *args) arch_mmu_type = args->arch_args.mmu_type; arch_platform = args->arch_args.platform; arch_platform = args->arch_args.machine; - void (*flush_insn_pipeline)(void); - void (*flush_atc_all)(void); - void (*flush_atc_user)(void); - void (*flush_atc_addr)(void *addr); - void (*flush_dcache)(void *address, size_t len); - void (*flush_icache)(void *address, size_t len); - void (*idle)(void); switch (arch_cpu_type) { case 68020: diff --git a/src/system/kernel/arch/m68k/arch_debug.cpp b/src/system/kernel/arch/m68k/arch_debug.cpp index 0d37a8a8b1..efb843c418 100644 --- a/src/system/kernel/arch/m68k/arch_debug.cpp +++ b/src/system/kernel/arch/m68k/arch_debug.cpp @@ -212,7 +212,7 @@ return 0; frame->a[0], frame->a[1], frame->a[2], frame->a[3]); kprintf(" a4 0x%08lx a5 0x%08lx a6 0x%08lx a7 0x%08lx (sp)\n", #warning M68K: a7 in iframe ?? - frame->a[4], frame->a[5], frame->a[6], -1/*frame->a[7]*/); + frame->a[4], frame->a[5], frame->a[6], -1L/*frame->a[7]*/); /*kprintf(" pc 0x%08lx ccr 0x%02x\n", frame->pc, frame->ccr);*/ diff --git a/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp b/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp index e2e3e239f3..7afad224e8 100644 --- a/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp +++ b/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp @@ -85,7 +85,7 @@ typedef struct vm_translation_map_arch_info { addr_t pages_to_invalidate[PAGE_INVALIDATE_CACHE_SIZE]; } vm_translation_map_arch_info; -#if 1//XXX ? +#if 1//XXX:HOLE static page_table_entry *page_hole = NULL; static page_directory_entry *page_hole_pgdir = NULL; #endif @@ -110,11 +110,6 @@ static addr_t sIOSpaceBase; #define ADDR_REVERSE_SHIFT(x) ((x)<<12) #endif -/* 7/7/6 split */ -#define VADDR_TO_PRENT(va) (((va) / B_PAGE_SIZE) / (64*128)) -#define VADDR_TO_PDENT(va) ((((va) / B_PAGE_SIZE) / 64) % 128) -#define VADDR_TO_PTENT(va) (((va) / B_PAGE_SIZE) % 64) - #define FIRST_USER_PGROOT_ENT (VADDR_TO_PRENT(USER_BASE)) #define FIRST_USER_PGDIR_ENT (VADDR_TO_PDENT(USER_BASE)) #define NUM_USER_PGROOT_ENTS (VADDR_TO_PRENT(ROUNDUP(USER_SIZE, B_PAGE_SIZE * 64 * 128))) @@ -220,26 +215,51 @@ _update_all_pgdirs(int index, page_root_entry e) } -// XXX currently assumes this translation map is active - +// this is used before the vm is fully up, it uses the +// transparent translation of the first 32MB +// a set up by the bootloader. +// (XXX: why just 32MB ? TT0 should just map 2G) static status_t early_query(addr_t va, addr_t *_physicalAddress) { - page_table_entry *pentry; + page_root_entry *pr = sKernelVirtualPageRoot; + page_directory_entry *pd; + page_indirect_entry *pi; + page_table_entry *pt; + addr_t pa; + int32 index; + status_t err = B_ERROR; // no pagetable here - if (page_hole_pgdir[VADDR_TO_PDENT(va)].type != DT_DIR) { - // no pagetable here - return B_ERROR; - } -#warning M68K: va or VADDR_TO_PTENT(va) ?? - pentry = page_hole + va / B_PAGE_SIZE; - if (pentry->type != DT_PAGE) { - // page mapping not valid - return B_ERROR; - } + index = VADDR_TO_PRENT(va); + if (pr && pr[index].type == DT_ROOT) { + pa = PRE_TO_TA(pr[index]); + // pa == va when in TT + // and no need to fiddle with cache + pd = (page_directory_entry *)pa; - *_physicalAddress = PTE_TO_PA(*pentry); - return B_OK; + index = VADDR_TO_PDENT(va); + if (pd && pd[index].type == DT_DIR) { + pa = PDE_TO_TA(pd[index]); + pt = (page_table_entry *)pa; + + index = VADDR_TO_PTENT(va); + if (pt && pt[index].type == DT_INDIRECT) { + pi = (page_indirect_entry *)pt; + pa = PIE_TO_TA(pi[index]); + pt = (page_table_entry *)pa; + index = 0; // single descriptor + } + + if (pt /*&& pt[index].type == DT_PAGE*/) { + *_physicalAddress = PTE_TO_PA(pt[index]); + // we should only be passed page va, but just in case. + *_physicalAddress += va % B_PAGE_SIZE; + err = B_OK; + } + } + } + + return err; } @@ -705,14 +725,14 @@ query_tmap_interrupt(vm_translation_map *map, addr_t va, addr_t *_physical, put_page_table_entry_in_pgtable(&sQueryDesc, PRE_TO_TA(pr[index]), B_KERNEL_READ_AREA, false); arch_cpu_invalidate_TLB_range((addr_t)pt, (addr_t)pt); pd = (page_directory_entry *)sQueryPage; + index = VADDR_TO_PDENT(va); - if (pd && pd[index].type == DT_DIR) { put_page_table_entry_in_pgtable(&sQueryDesc, PDE_TO_TA(pd[index]), B_KERNEL_READ_AREA, false); arch_cpu_invalidate_TLB_range((addr_t)pt, (addr_t)pt); pt = (page_table_entry *)sQueryPage; + index = VADDR_TO_PTENT(va); - if (pt && pt[index].type == DT_INDIRECT) { pi = (page_indirect_entry *)pt; put_page_table_entry_in_pgtable(&sQueryDesc, PIE_TO_TA(pi[index]), B_KERNEL_READ_AREA, false); @@ -1178,7 +1198,7 @@ m68k_vm_translation_map_init(kernel_args *args) status_t error; TRACE(("vm_translation_map_init: entry\n")); -#if 0 +#if 0//XXX:HOLE // page hole set up in stage2 page_hole = (page_table_entry *)args->arch_args.page_hole; // calculate where the pgdir would be @@ -1215,6 +1235,7 @@ m68k_vm_translation_map_init(kernel_args *args) TRACE(("mapping iospace_pgtables\n")); +#if 0 // put the array of pgtables directly into the kernel pagedir // these will be wired and kept mapped into virtual space to be easy to get to { @@ -1231,6 +1252,7 @@ m68k_vm_translation_map_init(kernel_args *args) put_pgtable_in_pgdir(e, phys_pgtable, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); } } +#endif TRACE(("vm_translation_map_init: done\n")); @@ -1260,8 +1282,10 @@ m68k_vm_translation_map_init_post_area(kernel_args *args) // unmap the page hole hack we were using before #warning M68K: FIXME //sKernelVirtualPageRoot[1023].present = 0; +#if 0 page_hole_pgdir = NULL; page_hole = NULL; +#endif temp = (void *)sKernelVirtualPageRoot; area = create_area("kernel_pgdir", &temp, B_EXACT_ADDRESS, B_PAGE_SIZE,