ReactOS  0.4.14-dev-323-g6fe6a88
mmu.h File Reference
#include <string.h>
#include "mmuutil.h"
Include dependency graph for mmu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ppc_pte_t
 
struct  _ppc_pteg_t
 
struct  _ppc_map_t
 
struct  _ppc_map_info_t
 
struct  _ppc_trap_frame_t
 

Macros

#define MMUCODE   0x10000
 
#define HTABORG   0x20000
 
#define HTABSIZ   0x10000
 
#define PAGETAB   0x30000
 
#define PpcHashedPTE   ((ppc_pteg_t*)(HTABORG))
 
#define PpcPageTable   ((ppc_map_t*)(PAGETAB))
 
#define PPC_PAGE_ADDR(x)   ((x) << 12)
 
#define PPC_PAGE_NUMBER(x)   ((x) >> 12)
 
#define PPC_VSID_MASK   0xffffff
 
#define PPC_PAGE_MASK   0xfff
 
#define MMU_NONE   0
 
#define MMU_KR   8
 
#define MMU_KW   4
 
#define MMU_UR   2
 
#define MMU_UW   1
 
#define MMU_ALL_R   10
 
#define MMU_KRW   12
 
#define MMU_KRW_UR   14
 
#define MMU_ALL_RW   15
 
#define MMU_PAGE_ACCESS   0x40000000
 
#define MMU_PAGE_DIRTY   0x80000000
 
#define MMU_KMASK   12
 
#define MMU_UMASK   3
 
#define MmuInit()   _MmuInit(&_binary_mmucode_start, &_binary_mmucode_end)
 

Typedefs

typedef unsigned long paddr_t
 
typedef unsigned long vaddr_t
 
typedef struct _ppc_pte_t ppc_pte_t
 
typedef struct _ppc_pteg_t ppc_pteg_t
 
typedef struct _ppc_map_t ppc_map_t
 
typedef struct _ppc_map_info_t ppc_map_info_t
 
typedef struct _ppc_trap_frame_t ppc_trap_frame_t
 
typedef int(* MmuTrapHandler) (int trapid, ppc_trap_frame_t *trap)
 

Functions

static int PPCMMU (int action, void *arg1, void *arg2, void *arg3)
 
static void _MmuInit (void *_start, void *_end)
 
static int MmuMapPage (ppc_map_info_t *info, int count)
 
static void MmuUnmapPage (ppc_map_info_t *info, int count)
 
static void MmuSetVsid (int start, int end, int vsid)
 
static MmuTrapHandler MmuSetTrapHandler (int trap, MmuTrapHandler cb)
 
static void MmuInqPage (ppc_map_info_t *info, int count)
 
static int MmuUnitTest ()
 
static int MmuTurnOn (void *fun, void *arg)
 
static void MmuSetMemorySize (paddr_t size)
 
static paddr_t MmuGetFirstPage ()
 
static voidMmuAllocVsid (int vsid, int mask)
 
static void MmuRevokeVsid (int vsid, int mask)
 
static paddr_t MmuGetPage ()
 
static void MmuCallbackRet ()
 
static void MmuDumpMap ()
 
static void MmuDbgInit (int deviceType, int devicePort)
 
static void MmuDbgEnter (int signal)
 

Variables

char _binary_mmucode_start []
 
char _binary_mmucode_end []
 

Macro Definition Documentation

◆ HTABORG

#define HTABORG   0x20000

Definition at line 58 of file mmu.h.

◆ HTABSIZ

#define HTABSIZ   0x10000

Definition at line 59 of file mmu.h.

◆ MMU_ALL_R

#define MMU_ALL_R   10

Definition at line 75 of file mmu.h.

◆ MMU_ALL_RW

#define MMU_ALL_RW   15

Definition at line 78 of file mmu.h.

◆ MMU_KMASK

#define MMU_KMASK   12

Definition at line 83 of file mmu.h.

◆ MMU_KR

#define MMU_KR   8

Definition at line 71 of file mmu.h.

◆ MMU_KRW

#define MMU_KRW   12

Definition at line 76 of file mmu.h.

◆ MMU_KRW_UR

#define MMU_KRW_UR   14

Definition at line 77 of file mmu.h.

◆ MMU_KW

#define MMU_KW   4

Definition at line 72 of file mmu.h.

◆ MMU_NONE

#define MMU_NONE   0

Definition at line 70 of file mmu.h.

◆ MMU_PAGE_ACCESS

#define MMU_PAGE_ACCESS   0x40000000

Definition at line 80 of file mmu.h.

◆ MMU_PAGE_DIRTY

#define MMU_PAGE_DIRTY   0x80000000

Definition at line 81 of file mmu.h.

◆ MMU_UMASK

#define MMU_UMASK   3

Definition at line 84 of file mmu.h.

◆ MMU_UR

#define MMU_UR   2

Definition at line 73 of file mmu.h.

◆ MMU_UW

#define MMU_UW   1

Definition at line 74 of file mmu.h.

◆ MMUCODE

#define MMUCODE   0x10000

Definition at line 57 of file mmu.h.

◆ MmuInit

Definition at line 177 of file mmu.h.

◆ PAGETAB

#define PAGETAB   0x30000

Definition at line 60 of file mmu.h.

◆ PPC_PAGE_ADDR

#define PPC_PAGE_ADDR (   x)    ((x) << 12)

Definition at line 65 of file mmu.h.

◆ PPC_PAGE_MASK

#define PPC_PAGE_MASK   0xfff

Definition at line 68 of file mmu.h.

◆ PPC_PAGE_NUMBER

#define PPC_PAGE_NUMBER (   x)    ((x) >> 12)

Definition at line 66 of file mmu.h.

◆ PPC_VSID_MASK

#define PPC_VSID_MASK   0xffffff

Definition at line 67 of file mmu.h.

◆ PpcHashedPTE

#define PpcHashedPTE   ((ppc_pteg_t*)(HTABORG))

Definition at line 62 of file mmu.h.

◆ PpcPageTable

#define PpcPageTable   ((ppc_map_t*)(PAGETAB))

Definition at line 63 of file mmu.h.

Typedef Documentation

◆ MmuTrapHandler

typedef int(* MmuTrapHandler) (int trapid, ppc_trap_frame_t *trap)

Definition at line 118 of file mmu.h.

◆ paddr_t

typedef unsigned long paddr_t

Definition at line 89 of file mmu.h.

◆ ppc_map_info_t

◆ ppc_map_t

◆ ppc_pte_t

◆ ppc_pteg_t

◆ ppc_trap_frame_t

◆ vaddr_t

typedef unsigned long vaddr_t

Definition at line 90 of file mmu.h.

Function Documentation

◆ _MmuInit()

static void _MmuInit ( void _start,
void _end 
)
inlinestatic

Definition at line 184 of file mmu.h.

185 {
186  int target = MMUCODE, copy;
187  int *start = (int *)_start;
188  while(start < (int *)_end)
189  {
190  memcpy(&copy, start++, sizeof(int));
191  SetPhys(target, copy);
192  target += sizeof(int);
193  }
194  PPCMMU(0x100, 0, 0, 0);
195 }
int _start[]
int _end[]
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint start
Definition: gl.h:1545
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define MMUCODE
Definition: mmu.h:57
GLenum target
Definition: glext.h:7315
void SetPhys(ULONG Addr, ULONG Data)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ MmuAllocVsid()

static void* MmuAllocVsid ( int  vsid,
int  mask 
)
inlinestatic

Definition at line 242 of file mmu.h.

243 {
244  return (void *)PPCMMU(0x10a, (void *)vsid, (void *)mask, 0);
245 }
GLenum GLint GLuint mask
Definition: glext.h:6028
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by FrLdrStartup(), KiInitializeContextThread(), and KiSystemStartupReal().

◆ MmuCallbackRet()

static void MmuCallbackRet ( )
inlinestatic

Definition at line 257 of file mmu.h.

258 {
259  PPCMMU(0x10d, 0,0,0);
260 }
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by KiPageFaultHandler().

◆ MmuDbgEnter()

static void MmuDbgEnter ( int  signal)
inlinestatic

Definition at line 272 of file mmu.h.

273 {
274  PPCMMU(0x201, (void *)signal, 0, 0);
275 }
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122
int signal
Definition: xcptfil.c:12

◆ MmuDbgInit()

static void MmuDbgInit ( int  deviceType,
int  devicePort 
)
inlinestatic

Definition at line 267 of file mmu.h.

268 {
269  PPCMMU(0x200, (void *)deviceType, (void *)devicePort, 0);
270 }
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by PpcInitializeMmu().

◆ MmuDumpMap()

static void MmuDumpMap ( )
inlinestatic

Definition at line 262 of file mmu.h.

263 {
264  PPCMMU(0x10e, 0,0,0);
265 }
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by KiDispatchException().

◆ MmuGetFirstPage()

static paddr_t MmuGetFirstPage ( )
inlinestatic

Definition at line 237 of file mmu.h.

238 {
239  return (paddr_t)PPCMMU(0x109, 0, 0, 0);
240 }
unsigned long paddr_t
Definition: mmu.h:89
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

◆ MmuGetPage()

static paddr_t MmuGetPage ( )
inlinestatic

Definition at line 252 of file mmu.h.

253 {
254  return PPCMMU(0x10c, 0,0,0);
255 }
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by MmPPCPrimitiveAllocPage().

◆ MmuInqPage()

static void MmuInqPage ( ppc_map_info_t info,
int  count 
)
inlinestatic

Definition at line 217 of file mmu.h.

218 {
219  PPCMMU(0x105, info, (void *)count, 0);
220 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by KiInitializeContextThread(), MmDeletePageFileMapping(), MmDeleteVirtualMapping(), MmGetPageProtect(), MmGetPhysicalAddressProcess(), MmIsDirtyPage(), and MmIsPagePresent().

◆ MmuMapPage()

static int MmuMapPage ( ppc_map_info_t info,
int  count 
)
inlinestatic

Definition at line 197 of file mmu.h.

198 {
199  return PPCMMU(0x101, info, (void *)count, 0);
200 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by FrLdrStartup(), KiInitializeContextThread(), KiSystemStartupReal(), MmCreateVirtualMappingUnsafe(), and MmPPCCreatePrimitiveMapping().

◆ MmuRevokeVsid()

static void MmuRevokeVsid ( int  vsid,
int  mask 
)
inlinestatic

Definition at line 247 of file mmu.h.

248 {
249  PPCMMU(0x10b, (void *)vsid, (void *)mask, 0);
250 }
GLenum GLint GLuint mask
Definition: glext.h:6028
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by MmDeletePageTable().

◆ MmuSetMemorySize()

static void MmuSetMemorySize ( paddr_t  size)
inlinestatic

Definition at line 232 of file mmu.h.

233 {
234  PPCMMU(0x108, (void *)size, 0, 0);
235 }
GLsizeiptr size
Definition: glext.h:5919
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by PpcInitializeMmu().

◆ MmuSetTrapHandler()

static MmuTrapHandler MmuSetTrapHandler ( int  trap,
MmuTrapHandler  cb 
)
inlinestatic

Definition at line 212 of file mmu.h.

213 {
214  return (MmuTrapHandler)PPCMMU(0x104, (void *)trap, (void *)cb, 0);
215 }
int(* MmuTrapHandler)(int trapid, ppc_trap_frame_t *trap)
Definition: mmu.h:118
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

Referenced by KiSystemStartupReal().

◆ MmuSetVsid()

static void MmuSetVsid ( int  start,
int  end,
int  vsid 
)
inlinestatic

Definition at line 207 of file mmu.h.

208 {
209  PPCMMU(0x103, (void *)start, (void *)end, (void *)vsid);
210 }
GLuint GLuint end
Definition: gl.h:1545
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122
GLuint start
Definition: gl.h:1545

Referenced by FrLdrStartup(), KiSwapProcess(), and KiSystemStartupReal().

◆ MmuTurnOn()

static int MmuTurnOn ( void fun,
void arg 
)
inlinestatic

Definition at line 227 of file mmu.h.

228 {
229  return PPCMMU(0x107, fun, arg, 0);
230 }
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

Referenced by FrLdrStartup().

◆ MmuUnitTest()

static int MmuUnitTest ( )
inlinestatic

Definition at line 222 of file mmu.h.

223 {
224  return PPCMMU(0x106, 0, 0, 0);
225 }
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

◆ MmuUnmapPage()

static void MmuUnmapPage ( ppc_map_info_t info,
int  count 
)
inlinestatic

Definition at line 202 of file mmu.h.

203 {
204  PPCMMU(0x102, info, (void *)count, 0);
205 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static int PPCMMU(int action, void *arg1, void *arg2, void *arg3)
Definition: mmu.h:122

◆ PPCMMU()

static int PPCMMU ( int  action,
void arg1,
void arg2,
void arg3 
)
inlinestatic

Definition at line 122 of file mmu.h.

123 {
124  /* Set Bat0 to mmu object address */
125  int i, batu, batl, usebat[2] = { 0, 1 }, gotbat = 0, pc, mask;
126  volatile int ret;
127  int (*mmumain)(int action, void *arg1, void *arg2, void *arg3) = (void *)MMUCODE;
128  __asm__("bl 1f\n\t"
129  "\n1:\n\t"
130  "mflr %0\n\t" : "=r" (pc));
131 
132  for(i = 0, gotbat = 0; i < 4; i++)
133  {
134  /* Use the space above the trap handlers to store the old bats */
135  GetBat(i, 0, &batu, &batl);
136 
137  SetPhys(0xf000 + i * 16, batu);
138  SetPhys(0xf004 + i * 16, batl);
139 
140  GetBat(i, 1, &batu, &batl);
141 
142  SetPhys(0xf008 + i * 16, batu);
143  SetPhys(0xf00c + i * 16, batl);
144 
145  if (gotbat < 2)
146  {
147  if(batu & 0xffc)
148  {
149  mask = ~(0x1ffff | ((batu & 0xffc)>>2)<<17);
150  if(!(batu & 2) || ((batu & mask) != (pc & mask)))
151  usebat[gotbat++] = i;
152  } else {
153  mask = ~(0x1ffff | (batl << 17));
154  if(!(batl & 0x40) || ((batu & mask) != (pc & mask)))
155  usebat[gotbat++] = i;
156  }
157  }
158  }
159 
160  batu = 0xff;
161  batl = 0x7f;
162  SetBat(usebat[0], 0, batu, batl);
163  SetBat(usebat[0], 1, batu, batl);
164  batu += 8192 * 1024;
165  batl += 8192 * 1024;
166  SetBat(usebat[1], 0, batu, batl);
167  SetBat(usebat[1], 1, batu, batl);
168 
169  ret = mmumain(action, arg1, arg2, arg3);
170 
171  return ret;
172 }
void SetBat(int bat, int inst, int batHi, int batLo)
Definition: mmu.c:236
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLenum GLint GLuint mask
Definition: glext.h:6028
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:9513
void GetBat(int bat, int inst, int *batHi, int *batLo)
Definition: mmu.c:191
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
Definition: glext.h:9515
int ret
const WCHAR * action
Definition: action.c:7783
#define MMUCODE
Definition: mmu.h:57
void SetPhys(ULONG Addr, ULONG Data)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by _MmuInit(), MmuAllocVsid(), MmuCallbackRet(), MmuDbgEnter(), MmuDbgInit(), MmuDumpMap(), MmuGetFirstPage(), MmuGetPage(), MmuInqPage(), MmuMapPage(), MmuRevokeVsid(), MmuSetMemorySize(), MmuSetTrapHandler(), MmuSetVsid(), MmuTurnOn(), MmuUnitTest(), and MmuUnmapPage().

Variable Documentation

◆ _binary_mmucode_end

char _binary_mmucode_end[]

◆ _binary_mmucode_start

char _binary_mmucode_start[]