Search
lxdream.org :: lxdream/src/sh4/mmu.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/mmu.h
changeset 945:787729653236
prev939:6f2302afeb89
next946:d41ee7994db7
author nkeynes
date Mon Jan 05 04:19:46 2009 +0000 (12 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Move address space decls to mmu.h
Finally remove sh4_read_long and friends
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * MMU/TLB definitions.
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    20 #ifndef lxdream_sh4_mmu_H
    21 #define lxdream_sh4_mmu_H 1
    23 #include "lxdream.h"
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    29 #define VMA_TO_EXT_ADDR(vma) ((vma)&0x1FFFFFFF)
    31 /************************** UTLB/ITLB Definitions ***************************/
    32 /* mmucr register bits */
    33 #define MMUCR_AT   0x00000001 /* Address Translation enabled */
    34 #define MMUCR_TI   0x00000004 /* TLB invalidate (always read as 0) */
    35 #define MMUCR_SV   0x00000100 /* Single Virtual mode=1 / multiple virtual=0 */
    36 #define MMUCR_SQMD 0x00000200 /* Store queue mode bit (0=user, 1=priv only) */
    37 #define MMUCR_URC  0x0000FC00 /* UTLB access counter */
    38 #define MMUCR_URB  0x00FC0000 /* UTLB entry boundary */
    39 #define MMUCR_LRUI 0xFC000000 /* Least recently used ITLB */
    40 #define MMUCR_MASK 0xFCFCFF05
    41 #define MMUCR_RMASK 0xFCFCFF01 /* Read mask */
    43 #define IS_TLB_ENABLED() (MMIO_READ(MMU, MMUCR)&MMUCR_AT)
    44 #define IS_SV_ENABLED() (MMIO_READ(MMU,MMUCR)&MMUCR_SV)
    46 #define ITLB_ENTRY_COUNT 4
    47 #define UTLB_ENTRY_COUNT 64
    49 /* Entry address */
    50 #define TLB_VALID     0x00000100
    51 #define TLB_USERMODE  0x00000040
    52 #define TLB_WRITABLE  0x00000020
    53 #define TLB_USERWRITABLE (TLB_WRITABLE|TLB_USERMODE)
    54 #define TLB_SIZE_MASK 0x00000090
    55 #define TLB_SIZE_1K   0x00000000
    56 #define TLB_SIZE_4K   0x00000010
    57 #define TLB_SIZE_64K  0x00000080
    58 #define TLB_SIZE_1M   0x00000090
    59 #define TLB_CACHEABLE 0x00000008
    60 #define TLB_DIRTY     0x00000004
    61 #define TLB_SHARE     0x00000002
    62 #define TLB_WRITETHRU 0x00000001
    64 #define MASK_1K  0xFFFFFC00
    65 #define MASK_4K  0xFFFFF000
    66 #define MASK_64K 0xFFFF0000
    67 #define MASK_1M  0xFFF00000
    69 struct itlb_entry {
    70     sh4addr_t vpn; // Virtual Page Number
    71     uint32_t asid; // Process ID
    72     uint32_t mask;
    73     sh4addr_t ppn; // Physical Page Number
    74     uint32_t flags;
    75 };
    77 struct utlb_entry {
    78     sh4addr_t vpn; // Virtual Page Number
    79     uint32_t mask; // Page size mask
    80     uint32_t asid; // Process ID
    81     sh4addr_t ppn; // Physical Page Number
    82     uint32_t flags;
    83     uint32_t pcmcia; // extra pcmcia data - not used in this implementation
    84 };
    86 #define TLB_FUNC_SIZE 48
    88 struct utlb_page_entry {
    89     struct mem_region_fn fn;
    90     mem_region_fn_t user_fn;
    91     mem_region_fn_t target;
    92     unsigned char code[TLB_FUNC_SIZE*8];
    93 };
    95 struct utlb_1k_entry {
    96     struct mem_region_fn fn;
    97     struct mem_region_fn user_fn;
    98     struct mem_region_fn *subpages[4];
    99     struct mem_region_fn *user_subpages[4];
   100     unsigned char code[TLB_FUNC_SIZE*16];
   101 };
   103 void mmu_utlb_init_vtable( struct utlb_entry *ent, struct utlb_page_entry *page, gboolean writable ); 
   104 void mmu_utlb_1k_init_vtable( struct utlb_1k_entry *ent ); 
   106 extern uint32_t mmu_urc;
   107 extern uint32_t mmu_urb;
   109 /** Primary SH4 address space (privileged and user access)
   110  * Page map (4KB) of the entire 32-bit address space
   111  * Note: only callable from the SH4 cores as it depends on the caller setting
   112  * up an appropriate exception environment. 
   113  **/
   114 extern struct mem_region_fn **sh4_address_space;
   115 extern struct mem_region_fn **sh4_user_address_space;
   117 /** Store-queue (prefetch) address space (privileged and user access)
   118  * Page map (4KB) of the 0xE0000000..0xE4000000 region
   119  * Same caveats apply as for the primary address space above.
   120  */
   121 extern struct mem_region_fn **storequeue_address_space;
   122 extern struct mem_region_fn **storequeue_user_address_space;
   124 #ifdef __cplusplus
   125 }
   126 #endif
   127 #endif /* !lxdream_sh4_mmu_H */
.