Commit 936d7d6f92e2b6f646ce9bb17dea4350653894b0
- Diff rendering mode:
- inline
- side by side
kernel/arch/x86/paging.cc
(3 / 2)
|   | |||
| 204 | 204 | // Set the current directory to dir | |
| 205 | 205 | current_directory = dir; | |
| 206 | 206 | ||
| 207 | // Set CR3 to the physical address of the page tables | ||
| 207 | 208 | asm volatile("mov %0, %%cr3":: "r"(dir->physicalAddress)); | |
| 208 | 209 | ||
| 209 | 210 | // Get the contents of the CR0 register | |
| … | … | ||
| 254 | 254 | ||
| 255 | 255 | page_directory_t * clone_directory(page_directory_t * src) | |
| 256 | 256 | { | |
| 257 | u32int phys; | ||
| 257 | uintptr phys; | ||
| 258 | 258 | ||
| 259 | 259 | // Make a new directory, and get it's address | |
| 260 | 260 | page_directory_t * dir = (page_directory_t *)kmalloc(sizeof(page_directory_t), &phys, true); | |
| … | … | ||
| 285 | 285 | else | |
| 286 | 286 | { | |
| 287 | 287 | // Copy the table | |
| 288 | u32int addr; | ||
| 288 | uintptr addr; | ||
| 289 | 289 | dir->tables[i] = clone_table(src->tables[i], &addr); | |
| 290 | 290 | dir->tablesPhysical[i] = addr | 0x07; | |
| 291 | 291 | } |
kernel/arch/x86/paging.h
(2 / 2)
|   | |||
| 30 | 30 | typedef struct page_directory | |
| 31 | 31 | { | |
| 32 | 32 | page_table_t * tables[1024]; // An array of pointers to our page tables | |
| 33 | u32int tablesPhysical[1024]; // Physical addresses of the above tables | ||
| 34 | u32int physicalAddress; // The location of the above location | ||
| 33 | uintptr tablesPhysical[1024]; // Physical addresses of the above tables | ||
| 34 | uintptr physicalAddress; // The location of the above location | ||
| 35 | 35 | ||
| 36 | 36 | } page_directory_t; | |
| 37 | 37 |
kernel/mm/kheap.cc
(3 / 3)
|   | |||
| 271 | 271 | ||
| 272 | 272 | if(phys != NULL) | |
| 273 | 273 | { | |
| 274 | paging::page_t * page = paging::get_page((uintptr) address, 0, kernel_directory); | ||
| 275 | *phys = page->frame * PAGE_SIZE + ((uintptr) address & 0xFFFFF000); | ||
| 274 | paging::page_t * page = paging::get_page((uintptr)address, false, kernel_directory); | ||
| 275 | *phys = (page->frame * PAGE_SIZE) + ((uintptr)address & 0xFFF); | ||
| 276 | 276 | } | |
| 277 | 277 | ||
| 278 | 278 | return (u32int)address; | |
| … | … | ||
| 402 | 402 | ||
| 403 | 403 | // Check if we want to page align the data, and page align it if it is not coincidentally | |
| 404 | 404 | // already aligned. Also, make a hole in front of the block to not waste space | |
| 405 | if(page_align && (original_hole_pos & 0xFFFFF000)) | ||
| 405 | if(page_align && (original_hole_pos & 0xFFFFF000) == 1) | ||
| 406 | 406 | { | |
| 407 | 407 | uintptr new_location = original_hole_pos + PAGE_SIZE - (original_hole_pos & 0xFFF) - sizeof(header); | |
| 408 | 408 |

