paging problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Fukuda

paging problem

Post by Fukuda »

Im new to this paging stuff. ı enable paging and change the address of the screen coordinates and want print a message to a different position of screen from expected position. (as I see in Alexie's pmode tutorial)

Code: Select all

   outtextxy(10, 10, "Old message");
   initpaging();
   outtextxy(10, 10, "New message");
but next printing code prints new message onto old one. Where did I wrong?

Code: Select all

void InitPaging(void)
{
    unsigned long *PageDirectory = (unsigned long *) 0x9C000;
    unsigned long *PageTable = (unsigned long *) 0x9D000;
                                    
    unsigned long Address=0;        
    unsigned int i;

    for(i=0; i<1024; i++) {
        PageTable[i] = Address | 3;
        Address = Address + 4096; 
    };

    PageDirectory[0] = PageTable;
    PageDirectory[0] = PageDirectory[0] | 3;

    // fill the rest of the page directory
    for(i=1; i<1024; i++)  {
        PageDirectory[i] = 0 | 2;
    };

    //chage the screen position addresses...
    Address = 0xBA000;
    for (i=0xB8;i<0xBA;i++) {
        Address -= 4096;
        PageTable[i] = Address | 3;
    }

    WriteCR3((unsigned int)PageDirectory); 
    WriteCR0(ReadCR0() | 0x80000000); 
}
Tim

Re:paging problem

Post by Tim »

Code: Select all

outtextxy(10, 10, "Old message");
initpaging();
outtextxy(10, 10, "New message");
So what you're saying is, you're printing two strings at position (10,10), and you're wondering why they appear in the same place?
Fukuda

Re:paging problem

Post by Fukuda »

But I change the address of the screen positions.Arent I?

Code: Select all

    Address = 0xBA000;
    for (i=0xB8;i<0xBA;i++) {
        Address -= 4096;
        PageTable[i] = Address | 3;
    }
Tim

Re:paging problem

Post by Tim »

I had to get out a calculator to check the addresses (you could make your code a lot clearer), but it looks OK. This seems a very strange thing to be doing.
Therx

Re:paging problem

Post by Therx »

Tim : I think its just meant to be an easy check that paging is working.

Fukuda : Trouble is that the text video memory is all inside one page so you can't move the text. To check you paging code try mapping some other address to 0xB8000 then write to that memory address and see if anything comes up.

Pete
Post Reply