home bbs files messages ]

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,553 of 4,255   
   Alexei A. Frounze to All   
   Re: paging makes OS to reboot infinitely   
   06 Dec 22 20:24:13   
   
   From: alexfrunews@gmail.com   
      
   On Tuesday, December 6, 2022 at 11:41:23 AM UTC-8, אורי ויסבלום   
   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;    
      
   So, when you add a number to a pointer to type T, how many bytes does the   
   pointer advance?   
      
   Also, why do you use i and (i-1) in this statement? Shouldn't they be the same?   
      
   > }    
   >    
   > // last entry points to the PDT itself    
   > *(table+(PDT_SIZE-1)*sizeof(PDEntry)) = READWRITE | PRESENT |    
   uint32_t)table;    
      
   Same question w.r.t. pointer arithmetic.   
      
   ...   
   > typedef uint32_t PDEntry;    
   > typedef uint32_t PTEntry;   
      
   Alex   
      
   --- 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