kern
diff src/vm.c @ 49:50730d42d2d3
fuck yeah, now do priviledge levels and TSS
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 30 Jul 2011 07:21:54 +0300 |
parents | 4c9c16754b59 |
children | b1e8c8251884 |
line diff
1.1 --- a/src/vm.c Thu Jul 28 17:56:05 2011 +0300 1.2 +++ b/src/vm.c Sat Jul 30 07:21:54 2011 +0300 1.3 @@ -328,8 +328,35 @@ 1.4 node = pglist[area]; 1.5 while(node) { 1.6 if(start >= node->start && start + num <= node->end) { 1.7 - ret = node->start; 1.8 - node->start += num; 1.9 + ret = start; /* can do .. */ 1.10 + 1.11 + if(start == node->start) { 1.12 + /* adjacent to the start of the range */ 1.13 + node->start += num; 1.14 + } else if(start + num == node->end) { 1.15 + /* adjacent to the end of the range */ 1.16 + node->end = start; 1.17 + } else { 1.18 + /* somewhere in the middle, which means we need 1.19 + * to allocate a new page_range 1.20 + */ 1.21 + struct page_range *newnode; 1.22 + 1.23 + if(!(newnode = alloc_node())) { 1.24 + panic("pgalloc_vrange failed to allocate new page_range while splitting a range in half... bummer\n"); 1.25 + } 1.26 + newnode->start = start + num; 1.27 + newnode->end = node->end; 1.28 + newnode->next = node->next; 1.29 + 1.30 + node->end = start; 1.31 + node->next = newnode; 1.32 + /* no need to check for null nodes at this point, there's 1.33 + * certainly stuff at the begining and the end, otherwise we 1.34 + * wouldn't be here. so break out of it. 1.35 + */ 1.36 + break; 1.37 + } 1.38 1.39 if(node->start == node->end) { 1.40 prev->next = node->next; 1.41 @@ -526,7 +553,7 @@ 1.42 /* we will allocate physical pages and map them to this virtual page 1.43 * as needed in the loop below. 1.44 */ 1.45 - free_phys_page(virt_to_phys(tblpg)); 1.46 + free_phys_page(virt_to_phys((uint32_t)ntbl)); 1.47 1.48 kstart_dirent = ADDR_TO_PAGE(KMEM_START) / 1024; 1.49 1.50 @@ -548,10 +575,10 @@ 1.51 1.52 /* kernel space */ 1.53 for(i=kstart_dirent; i<1024; i++) { 1.54 - ndir[i] = *PGTBL(i); 1.55 + ndir[i] = pgdir[i]; 1.56 } 1.57 1.58 - paddr = virt_to_phys(dirpg); 1.59 + paddr = virt_to_phys((uint32_t)ndir); 1.60 1.61 /* unmap before freeing to avoid deallocating the physical pages */ 1.62 unmap_page(dirpg);