6 typedef unsigned long ULONG;
42 #define MMU_ADDR_RESERVED ((vaddr_t)-2) 72 void SerialSetUp(
int deviceType,
void *deviceAddr,
int baud);
76 void copy(
void *
t,
void *
s,
int b);
126 trap_frame->
srr1 |= 0x8000;
165 copy(trap_frame, (
void *)0xf040,
sizeof(*trap_frame));
166 __asm__(
"mr 1,%0\n\tb trap_finish_start" : :
"r" 167 (((
int)trap_frame) - 16));
194 __asm__(
"mfmsr %0" :
"=r" (tmp));
196 __asm__(
"mtmsr %0" : :
"r" (tmp));
198 for(
i = 0;
i < 4;
i++) {
213 int framecopy = 0xf040;
214 copy((
void *)framecopy, trap_frame,
sizeof(*trap_frame));
216 trap_frame->
srr1 &= 0x7fff;
218 trap_frame->
gpr[4] = framecopy;
219 __asm__(
"mr 1,%0\n\tsubi 1,1,16\n\tb trap_finish_start" : :
"r" (trap_frame));
240 if(dig < 10)
outchar(dig +
'0');
247 for(
i = 0;
i < 8;
i++ )
266 else if(
str[1] ==
's')
312 paddr_t targetArea = trap * 0x100;
333 for(
i = 0;
i < 30;
i++)
364 fmtout(
"Problem! FreeList: page 0 is free\n");
429 for(
i = 0;
i < 256;
i++)
442 map->pte.pteh =
map->pte.ptel = 0;
453 for(
i = 0;
i < 16;
i++)
476 for(
i = 0;
i < 256;
i++)
487 for(
i = 0;
i < 16;
i++)
496 int i, iva = 0,
vsid, phys, virt;
498 int ptelo, vsid_table_hi, vsid_table_lo;
512 if(!VsidInfo)
return -1;
514 ptehi = (1 << 31) | (
vsid << 7) | ((virt >> 22) & 0x3f);
532 fmtout(
"Allocated physical: %x, logical %x\n", phys, virt);
533 fmtout(
"PagePtr %x (page %d)\n", PagePtr,
i);
542 PagePtr->
addr = virt;
544 vsid_table_hi = virt >> 20 & 255;
545 vsid_table_lo = virt >> 12 & 255;
547 if(!VsidInfo->
tree[vsid_table_hi])
549 VsidTree = VsidInfo->
tree[vsid_table_hi];
550 if(!VsidTree)
return 0;
551 VsidTree->
leaves[vsid_table_lo] = PagePtr;
553 __asm__(
"tlbie %0\n\tsync\n\tisync" : :
"r" (iva));
561 if (!PagePtr)
return 0;
567 if(!
map->proc && !
map->addr)
return 0;
573 int vsid_pte = (pte.
pteh >> 7) & 15, api_pte = pte.
pteh & 63;
575 (((
addr >> 28) & 15) == vsid_pte) &&
576 (((
addr >> 22) & 63) == api_pte);
581 int seg = (
addr >> 28) & 15;
584 if(!seginfo)
return 0;
585 segtree = seginfo->
tree[(
addr >> 20) & 255];
586 if(!segtree)
return 0;
612 for(
j = 0;
j < 2;
j++)
615 for(
k = 0;
k < 8;
k++)
621 PageEntry->
block[
k] = ZeroPte;
661 return !PagePtr->
addr;
669 s_vsid = (
vsid << 4) | (
i & 15);
683 map->pte.pteh = (
map->pte.pteh & ~64) | (hfun << 6);
686 fmtout(
"Reloading addr %x (phys %x) at %x[%x] (%x:%x)\r\n",
692 __asm__(
"tlbie %0\n\tsync\n\tisync" : :
"r" (
addr));
698 fmtout(
"%x: proc %x addr %x\n",
707 for (
j = 0;
j < 256;
j++)
721 for (
i = 0;
i < 256;
i++)
735 fmtout(
"Address spaces:\n");
748 for (
i = 0;
i < 16;
i++)
755 void (*fun)(
void *) = fun_ptr;
static unsigned int block
void mmuallocvsid(int vsid, int mask)
void mmudelpage(ppc_map_info_t *info, int count)
int fpenable(int trapCode, ppc_trap_frame_t *trap)
void freepage(ppc_map_t *PagePtr)
void printmap(vaddr_t vaddr, ppc_map_t *map)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
struct _MmuFreePage MmuFreePage
void freevsidtree(MmuVsidTree *tree)
void callkernel(void *fun_ptr, void *arg)
struct _MmuFreeTree MmuFreeTree
int mmuisfreepage(paddr_t pageno)
int mmuaddpage(ppc_map_info_t *info, int count)
int ignore(int trapCode, ppc_trap_frame_t *trap)
GLuint GLuint GLsizei count
MmuVsidInfo * findvsid(int vsid)
ppc_map_t * mmuvirtmap(vaddr_t addr)
int(* MmuTrapHandler)(int trapid, ppc_trap_frame_t *trap)
void TakeException(int n, ppc_trap_frame_t *tf)
int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf)
#define MMU_ADDR_RESERVED
#define PPC_PAGE_NUMBER(x)
void SetBat(int bat, int inst, int batHi, int batLo)
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
void trapcallback(int action, ppc_trap_frame_t *trap_frame)
static unsigned char bytes[4]
__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
int ptegreload(ppc_trap_frame_t *frame, vaddr_t addr)
void fmtout(const char *fmt,...)
void dumpvsid(MmuVsidInfo *vsid)
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 GLint GLint j
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
MmuTrapHandler callback[0x30]
GLboolean GLboolean GLboolean b
void copy(void *t, void *s, int b)
void SerialSetUp(int deviceType, void *deviceAddr, int baud)
struct _MmuVsidTree MmuVsidTree
ULONG GetPhys(ULONG Addr)
int PageMatch(vaddr_t addr, ppc_pte_t pte)
void SetSR(int n, int val)
ppc_pteg_t * PtegFromPage(ppc_map_t *map, int hfun)
GLenum const GLvoid * addr
struct _MmuFreeTree * next
void mmusetvsid(int start, int end, int vsid)
void mmufreevsid(int vsid, int mask)
void mmugetpage(ppc_map_info_t *info, int count)
void dumptree(vaddr_t vaddr, MmuVsidTree *tree)
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
void copy_trap_handler(int trap)
MmuVsidTree * allocvsidtree()
int PtegNumber(vaddr_t virt, int hfun)
void mmusetramsize(paddr_t ramsize)
struct _MmuFreePage * next
MmuVsidTree * NextTreePage
void int int ULONGLONG int va_list * ap
void outnum(unsigned long num)
int SerialInterrupt(int n, ppc_trap_frame_t *tf)
struct _MmuVsidInfo MmuVsidInfo
void * allocvsid(int vsid)
void SetPhys(ULONG Addr, ULONG Data)
void SetPhysByte(ULONG Addr, ULONG Data)
void outstr(const char *str)
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum map
struct _MmuVsidInfo * next
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *