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,560 of 4,255    |
|    James Harris to All    |
|    Re: paging makes OS to reboot infinitely    |
|    07 Dec 22 14:17:19    |
   
   From: james.harris.1@gmail.com   
      
   On 06/12/2022 19:41, אורי ויסבלום wrote:   
      
   > 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;   
      
   I might be wrong but when you add an integer to a pointer in C doesn't   
   it automatically scale the integer by the size of the type of element   
   pointed at so   
      
    kernelPTAddr + 3   
      
   would form the address kernelPTAddr + 12 (because kernelPTAddr points to   
   elements of PTEntry which has size 4)?   
      
   Do you have any kind of Protected Mode printing working? It would help   
   debugging if you could print out things such as the non-zero elements of   
   the PD and PT.   
      
   ...   
      
   > typedef uint32_t PDEntry;   
   > typedef uint32_t PTEntry;   
      
      
   --   
   James Harris   
      
   --- 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