TempleOSCDV4.06.ISO
This commit is contained in:
1 parent
6fe38d2d9d
commit
b632ab9a4f
261 files changed
+6282
-5801
No files matched your search
@@ -9,7 +9,7 @@ so a ptr to a page count is passed.
|
||||
Return: NULL if out of memory.
|
||||
*/
|
||||
I64 i,j,*pte,num=*_pages2Meg;
|
||||
CMemBlk *result=NULL,*m,*m1;
|
||||
CMemBlk *res=NULL,*m,*m1;
|
||||
|
||||
if (!bp) bp=sys_code_bp;
|
||||
PUSHFD
|
||||
@@ -20,18 +20,18 @@ Return: NULL if out of memory.
|
||||
|
||||
m=&bp->mem_free_2meg_lst;
|
||||
while (TRUE) {
|
||||
if (!(result=m->next))
|
||||
if (!(res=m->next))
|
||||
break;
|
||||
if (result->pages<num)
|
||||
m=result;
|
||||
if (res->pages<num)
|
||||
m=res;
|
||||
else {
|
||||
if (result->pages==num) {
|
||||
m->next=result->next;
|
||||
if (res->pages==num) {
|
||||
m->next=res->next;
|
||||
goto am_done;
|
||||
} else {
|
||||
result->pages-=num;
|
||||
result(U8 *)+=result->pages<<MEM_PAGE_BITS;
|
||||
result->pages=num;
|
||||
res->pages-=num;
|
||||
res(U8 *)+=res->pages<<MEM_PAGE_BITS;
|
||||
res->pages=num;
|
||||
goto am_done;
|
||||
}
|
||||
}
|
||||
@@ -39,36 +39,36 @@ Return: NULL if out of memory.
|
||||
|
||||
m=&bp->mem_free_lst;
|
||||
while (TRUE) {
|
||||
if (!(result=m->next)) {
|
||||
if (!(res=m->next)) {
|
||||
num=0;
|
||||
result=NULL; //Out of memory
|
||||
res=NULL; //Out of memory
|
||||
goto am_done;
|
||||
}
|
||||
if (result->pages<num)
|
||||
m=result;
|
||||
if (res->pages<num)
|
||||
m=res;
|
||||
else {
|
||||
if (result->pages==num) {
|
||||
if (result(U8 *)&0x1FFFFF)
|
||||
m=result;
|
||||
if (res->pages==num) {
|
||||
if (res(U8 *)&0x1FFFFF)
|
||||
m=res;
|
||||
else {
|
||||
m->next=result->next;
|
||||
m->next=res->next;
|
||||
goto am_done;
|
||||
}
|
||||
} else {
|
||||
if (i=(result(U8 *)&0x1FFFFF)>>MEM_PAGE_BITS) {
|
||||
if (i=(res(U8 *)&0x1FFFFF)>>MEM_PAGE_BITS) {
|
||||
j=1<<(21-MEM_PAGE_BITS)-i;
|
||||
if (result->pages<num+j)
|
||||
m=result;
|
||||
else if (result->pages==num+j) {
|
||||
result->pages-=num;
|
||||
result(U8 *)+=result->pages<<MEM_PAGE_BITS;
|
||||
result->pages=num;
|
||||
if (res->pages<num+j)
|
||||
m=res;
|
||||
else if (res->pages==num+j) {
|
||||
res->pages-=num;
|
||||
res(U8 *)+=res->pages<<MEM_PAGE_BITS;
|
||||
res->pages=num;
|
||||
goto am_done;
|
||||
} else {
|
||||
m1=result;
|
||||
result(U8 *)+=j<<MEM_PAGE_BITS;
|
||||
result->pages=num;
|
||||
m=result(U8 *)+num<<MEM_PAGE_BITS;
|
||||
m1=res;
|
||||
res(U8 *)+=j<<MEM_PAGE_BITS;
|
||||
res->pages=num;
|
||||
m=res(U8 *)+num<<MEM_PAGE_BITS;
|
||||
m->pages=m1->pages-num-j;
|
||||
m1->pages=j;
|
||||
m->next=m1->next;
|
||||
@@ -77,11 +77,11 @@ Return: NULL if out of memory.
|
||||
goto am_done;
|
||||
}
|
||||
} else {
|
||||
m=m->next=result(U8 *)+num<<MEM_PAGE_BITS;
|
||||
m->next=result->next;
|
||||
m->pages=result->pages-num;
|
||||
m=m->next=res(U8 *)+num<<MEM_PAGE_BITS;
|
||||
m->next=res->next;
|
||||
m->pages=res->pages-num;
|
||||
m->mb_signature=MBS_UNUSED_SIGNATURE_VAL;
|
||||
result->pages=num;
|
||||
res->pages=num;
|
||||
goto am_done;
|
||||
}
|
||||
}
|
||||
@@ -92,17 +92,17 @@ am_done:
|
||||
bp->used_u8s+=i;
|
||||
num>>=21-MEM_PAGE_BITS;
|
||||
*_pages2Meg=num;
|
||||
m=result;
|
||||
m=res;
|
||||
m1=m(U8 *)+i;
|
||||
while (m<m1) {
|
||||
pte=MemPageTable(m);
|
||||
*pte &= ~0x18;
|
||||
InvlPg(m);
|
||||
m(U8 *)+=MemPageSize(m);
|
||||
m(U8 *)+=0x200000;
|
||||
}
|
||||
LBtr(&bp->locked_flags,BPlf_LOCKED);
|
||||
POPFD
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
U8 *Mem2MegUncachedAlloc(I64 *_pages2Meg,CBlkPool *bp=NULL)
|
||||
@@ -113,20 +113,20 @@ so a ptr to a page count is passed.
|
||||
|
||||
Return: NULL if out of memory.
|
||||
*/
|
||||
CMemBlk *result,*m,*m1;
|
||||
CMemBlk *res,*m,*m1;
|
||||
I64 num=*_pages2Meg,*pte;
|
||||
if (result=Mem2MegAlloc(_pages2Meg,bp)) {
|
||||
if (res=Mem2MegAlloc(_pages2Meg,bp)) {
|
||||
num=*_pages2Meg;
|
||||
m=result;
|
||||
m=res;
|
||||
m1=m(U8 *)+num<<21;
|
||||
while (m<m1) {
|
||||
pte=MemPageTable(m);
|
||||
*pte= *pte& ~0x18 |0x10;
|
||||
InvlPg(m);
|
||||
m(U8 *)+=MemPageSize(m);
|
||||
m(U8 *)+=0x200000;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
U8 *Mem2MegWriteThruAlloc(I64 *_pages2Meg,CBlkPool *bp=NULL)
|
||||
@@ -137,20 +137,20 @@ so a ptr to a page count is passed.
|
||||
|
||||
Return: NULL if out of memory.
|
||||
*/
|
||||
CMemBlk *result,*m,*m1;
|
||||
CMemBlk *res,*m,*m1;
|
||||
I64 num=*_pages2Meg,*pte;
|
||||
if (result=Mem2MegAlloc(_pages2Meg,bp)) {
|
||||
if (res=Mem2MegAlloc(_pages2Meg,bp)) {
|
||||
num=*_pages2Meg;
|
||||
m=result;
|
||||
m=res;
|
||||
m1=m(U8 *)+num<<21;
|
||||
while (m<m1) {
|
||||
pte=MemPageTable(m);
|
||||
*pte= *pte& ~0x18 |8;
|
||||
InvlPg(m);
|
||||
m(U8 *)+=MemPageSize(m);
|
||||
m(U8 *)+=0x200000;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 Mem2MegFree(CMemBlk *m,I64 pages2Meg,CBlkPool *bp=NULL)
|
||||
@@ -165,7 +165,7 @@ U0 Mem2MegFree(CMemBlk *m,I64 pages2Meg,CBlkPool *bp=NULL)
|
||||
pte=MemPageTable(m2);
|
||||
*pte=*pte & ~0x18;
|
||||
InvlPg(m2);
|
||||
m2(U8 *)+=MemPageSize(m2);
|
||||
m2(U8 *)+=0x200000;
|
||||
}
|
||||
PUSHFD
|
||||
CLI
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
I64 *addr=VGAM_GRAPHICS,
|
||||
I64 *addr=text.vga_alias,
|
||||
*pte_addr=MemPageTable(addr),
|
||||
err_code=0,
|
||||
*reported_fault_addr;
|
||||
@@ -22,7 +22,7 @@ interrupt haserrcode U0 IntPageFault()
|
||||
reported_fault_addr=GetRAX;
|
||||
}
|
||||
|
||||
U0 PageTableDemo2()
|
||||
U0 PageTableDemo()
|
||||
{
|
||||
U8 *old_idte=IntEntrySet(I_PAGE_FAULT,&IntPageFault,IDTET_IRQ);
|
||||
err_code=0;
|
||||
@@ -34,4 +34,4 @@ U0 PageTableDemo2()
|
||||
"Err Code:%X Addr:%X\n",err_code,reported_fault_addr;
|
||||
}
|
||||
|
||||
PageTableDemo2;
|
||||
PageTableDemo;
|
||||
@@ -1,47 +0,0 @@
|
||||
/*What's funner than page tables for programmers to play with!!
|
||||
|
||||
This changes a page table entry for VGA graphics memory.
|
||||
TempleOS keeps a cached copy of VGA memory in
|
||||
$LK,"gr.screen_image",A="MN:CGrGlbls"$. See $LK,"GrUpdateVGAGraphics",A="MN:GrUpdateVGAGraphics"$.
|
||||
|
||||
TempleOS used 4096 size pages for memory below addr 2 Meg
|
||||
and 2 Meg pages above two Meg. See $LK,"MemPageSize",A="MN:MemPageSize"$() and $LK,"INIT_MEMORY",A="FF:::/Kernel/Mem/PageTables.CPP,SYS_INIT_MEM"$.
|
||||
*/
|
||||
|
||||
U0 PageTableDemo1()
|
||||
{
|
||||
I64 *pte=MemPageTable(VGAM_GRAPHICS),p0,p1;
|
||||
"Page table entries for VGA screen memory\n";
|
||||
DocD(pte);
|
||||
PressAKey;
|
||||
|
||||
p0=pte[0];
|
||||
p1=pte[1];
|
||||
pte[0]=p1;
|
||||
pte[1]=p0;
|
||||
InvlPg(VGAM_GRAPHICS); //Invalidate translation look aside buffer (TLB).
|
||||
InvlPg(VGAM_GRAPHICS+0x1000);
|
||||
|
||||
//Use this if you wish to change
|
||||
//the page table reg.
|
||||
|
||||
// SetRAX(0x100000+0x1000*(MEM_NUM_PML1+MEM_NUM_PML2+MEM_NUM_PML3));
|
||||
// MOV_CR3_EAX
|
||||
|
||||
//<CTRL-ALT-v> will flush screen VGA cache.
|
||||
VGAFlush;
|
||||
PressAKey;
|
||||
|
||||
pte[0]=p0;
|
||||
pte[1]=p1;
|
||||
InvlPg(VGAM_GRAPHICS);
|
||||
InvlPg(VGAM_GRAPHICS+0x1000);
|
||||
|
||||
//<CTRL-ALT-v> will flush screen VGA cache.
|
||||
VGAFlush;
|
||||
}
|
||||
|
||||
PageTableDemo1;
|
||||
|
||||
//See $LK,"CBlkPool",A="MN:CBlkPool"$, $LK,"CHeapCtrl",A="MN:CHeapCtrl"$, $LK,"sys_code_bp",A="MN:sys_code_bp"$ and $LK,"sys_data_bp",A="MN:sys_data_bp"$.
|
||||
//See $LK,"Memory Overview",A="FI:::/Doc/MemOverview.TXT"$ and $LK,"Memory Routines",A="HI:Memory"$.
|
||||
Reference in new issue
Block a user