Guest User

Untitled

a guest
Jul 7th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. static void* vmm_alloc_in_range(uint32_t low, uint32_t high, uint32_t* retpaddr, uint32_t cont) {
  2.   void* vaddr = 0;
  3.   uint32_t i = 0;
  4.   uint32_t c = 0;
  5.  
  6.   for(i = (low & 0xFFFFF000); i < high; i += 0x1000) {
  7.     if((active_pagetables[i >> 12] & (PT_ALLOCATABLE | PT_PRESENT)) == PT_ALLOCATABLE) {
  8.       if(c == 0) vaddr = (void*) i;
  9.       c++;
  10.       if(c >= cont)
  11.         break;
  12.     }
  13.     else
  14.     {
  15.       c = 0;
  16.     }
  17.   }
  18.  
  19.   uint32_t off = 0;
  20.  
  21.   while(c--) {
  22.     vmm_alloc_addr(vaddr + off * 0x1000, off == 0 ? retpaddr : 0);
  23.     off++;
  24.   }
  25.  
  26.   return vaddr;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment