TempleOSCDV4.06.ISO
This commit is contained in:
1 parent
6fe38d2d9d
commit
b632ab9a4f
261 files changed
+6282
-5801
No files matched your search
@@ -6,9 +6,9 @@ F64 VGAPattern(I64 p)
|
||||
F64 start=tS;
|
||||
I64 plane;
|
||||
for (plane=1;plane<0x10;plane<<=1) {
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,plane);
|
||||
MemSetI64(0xA0000,p,640*480/64);
|
||||
MemSetI64(text.vga_alias,p,640*480/64);
|
||||
}
|
||||
return tS-start;
|
||||
}
|
||||
|
||||
@@ -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"$.
|
||||
@@ -2,7 +2,7 @@
|
||||
U8 reverse[256], //The VGA bits are bwd
|
||||
|
||||
image[640*480/8]; //We need read-modify write.
|
||||
//0xA0000 memory can't be read.
|
||||
//0xA0000 alias memory can't be read.
|
||||
|
||||
U0 MGInit()
|
||||
{
|
||||
@@ -18,10 +18,10 @@ U0 MGInit()
|
||||
U0 MGUpdate()
|
||||
{//Copy image to VGA memory
|
||||
//For better performance we could only write what's changed.
|
||||
//0xA0000 is slower than normal RAM.
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
//0xA0000 alias is slower than normal RAM.
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,0xF);//All color planes at once -- Black and White
|
||||
MemCpy(0xA0000,image,sizeof(image));
|
||||
MemCpy(text.vga_alias,image,sizeof(image)); //Alias of 0xA0000
|
||||
}
|
||||
|
||||
U0 MGPlot(I64 x,I64 y)
|
||||
|
||||
@@ -78,31 +78,31 @@ CPURep;
|
||||
"Bad Code\n";
|
||||
t0=tS;
|
||||
i=Loop1;
|
||||
"Result:%d Time:%9.6f\n",i,tS-t0;
|
||||
"Res:%d Time:%9.6f\n",i,tS-t0;
|
||||
|
||||
"Good Code #1\n";
|
||||
t0=tS;
|
||||
i=Loop2;
|
||||
"Result:%d Time:%9.6f\n",i,tS-t0;
|
||||
"Res:%d Time:%9.6f\n",i,tS-t0;
|
||||
|
||||
"Good Code #2\n";
|
||||
t0=tS;
|
||||
i=Loop3;
|
||||
"Result:%d Time:%9.6f\n",i,tS-t0;
|
||||
"Res:%d Time:%9.6f\n",i,tS-t0;
|
||||
|
||||
"Good Code #3\n";
|
||||
t0=tS;
|
||||
i=Loop4;
|
||||
"Result:%d Time:%9.6f\n",i,tS-t0;
|
||||
"Res:%d Time:%9.6f\n",i,tS-t0;
|
||||
|
||||
/* Program Output$HL,0$$WW+H,1$$FD,1$
|
||||
8 Cores 2.660GHz
|
||||
Bad Code
|
||||
Result:3200000040000000 Time: 0.069966
|
||||
Res:3200000040000000 Time: 0.069966
|
||||
Good Code #1
|
||||
Result:3200000040000000 Time: 0.062567
|
||||
Res:3200000040000000 Time: 0.062567
|
||||
Good Code #2
|
||||
Result:3200000040000000 Time: 0.062907
|
||||
Res:3200000040000000 Time: 0.062907
|
||||
Good Code #3
|
||||
Result:3200000040000000 Time: 0.156359
|
||||
Res:3200000040000000 Time: 0.156359
|
||||
$HL,1$*/
|
||||
@@ -4,28 +4,28 @@
|
||||
U0 PlotXY(I64 x,I64 y)
|
||||
{
|
||||
//Screen bits are reversed
|
||||
LBts(VGAM_GRAPHICS,y*GR_WIDTH+x^7);
|
||||
LBts(text.vga_alias,y*GR_WIDTH+x^7);
|
||||
}
|
||||
|
||||
U0 Main()
|
||||
{
|
||||
I64 i;
|
||||
//This makes all 4 color planes active.
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,WHITE);
|
||||
MemSet(VGAM_GRAPHICS,0,GR_WIDTH*GR_HEIGHT/8);
|
||||
MemSet(text.vga_alias,0,GR_WIDTH*GR_HEIGHT/8);
|
||||
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,RED);
|
||||
for (i=0;i<200;i++)
|
||||
PlotXY(i,i);
|
||||
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,GREEN);
|
||||
for (i=0;i<200;i++)
|
||||
PlotXY(100,i);
|
||||
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,BLUE);
|
||||
for (i=0;i<200;i++)
|
||||
PlotXY(200-i,i);
|
||||
|
||||
Reference in new issue
Block a user