Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.os.development    |    Operating system development chatter    |    4,255 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,546 of 4,255    |
|    =?UTF-8?B?15DXldeo15kg15XXmdeh15HXn to All    |
|    Re: paging makes OS to reboot infinitely    |
|    06 Dec 22 11:41:22    |
   
   From: turhuhxckuo@gmail.com   
      
   Now, here is the new code I've made (with a basic kmalloc, without free   
   because I don't need it for now). The same bug happens. Any other ideas?   
   BTW, I've checked all of the or expressions and all of the allocPage()   
   outputs, they're as intended.   
      
      
   #define PDT_SIZE 1024   
   #define KERNEL_START 0x1000 // a constant in my linker code   
   #define PAGE_SIZE 0x1000   
   #define KERNEL_SIZE 3 // the size of the kernel code is 10KB for now (I've   
   checked it), so I gave it 3 pages * 4KB = 12KB   
   #define KERNEL_END (KERNEL_START + PAGE_SIZE*KERNEL_SIZE)   
      
   PTEntry* kernelPTAddr = 0;   
   uint32_t firstFree = 0;   
      
   uint32_t allocPage() {   
    if (firstFree == 0)   
    firstFree = KERNEL_END;   
    firstFree += PAGE_SIZE;   
    return firstFree - PAGE_SIZE;   
   }   
      
   void initPDT() {   
    PDEntry* table = allocPage();   
    kernelPTAddr = allocPage();   
    // Here it was with the struct of PD earlier, but I've realized it doesn't   
   work correctly, it doesn't take into account the size of P*Entry, so I'm using   
   pointers now.   
    *table = READWRITE | PRESENT | (uint32_t)kernelPTAddr;   
      
    for (int i = 1; i <= KERNEL_SIZE; i++) {   
    *(kernelPTAddr+i*sizeof(PTEntry)) = PRESENT | READWRITE | DIRTY |   
   KERNEL_START + (i-1)*PAGE_SIZE;   
    }   
      
    // last entry points to the PDT itself   
    *(table+(PDT_SIZE-1)*sizeof(PDEntry)) = READWRITE | PRESENT |   
   (uint32_t)table;   
      
    irqInstallHandler(14, pagefault);   
      
    startVirtualMode((uint32_t)table);   
   }   
   void startVirtualMode(uint32_t address); // the same as before.   
      
   // typedefs (it's in the .h file, the order of the definitions in this mail is   
   for comfort purposes)   
   typedef enum {   
    PRESENT = 1,   
    READWRITE = 2,   
    USER = 4,   
    WRITETHROUGH = 8,   
    CACHE = 16,   
    DIRTY = 64 // this is specifically in PTEntry and not in PDEntry   
    // you may have noticed i don't mention some other flags, such as   
   PageSize, Global, PageAttributeTable   
    // I didn't because we don't need them   
   } PageFlags;   
      
   typedef uint32_t PDEntry;   
   typedef uint32_t PTEntry;   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca