1 /* 2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "paging/pae/X86PagingStructuresPAE.h" 8 9 #include <stdlib.h> 10 #include <string.h> 11 12 #include <KernelExport.h> 13 14 #include <int.h> 15 16 #include "paging/pae/X86PagingMethodPAE.h" 17 18 19 #if B_HAIKU_PHYSICAL_BITS == 64 20 21 22 X86PagingStructuresPAE::X86PagingStructuresPAE() 23 : 24 fPageDirPointerTable(NULL) 25 { 26 memset(fVirtualPageDirs, 0, sizeof(fVirtualPageDirs)); 27 } 28 29 30 X86PagingStructuresPAE::~X86PagingStructuresPAE() 31 { 32 // free the user page dirs 33 free(fVirtualPageDirs[0]); 34 // There's one contiguous allocation for 0 and 1. 35 36 // free the PDPT page 37 if (fPageDirPointerTable != NULL) { 38 X86PagingMethodPAE::Method()->Free32BitPage(fPageDirPointerTable, 39 pgdir_phys, fPageDirPointerTableHandle); 40 } 41 } 42 43 44 void 45 X86PagingStructuresPAE::Init( 46 pae_page_directory_pointer_table_entry* virtualPDPT, 47 phys_addr_t physicalPDPT, void* pdptHandle, 48 pae_page_directory_entry* const* virtualPageDirs, 49 const phys_addr_t* physicalPageDirs) 50 { 51 fPageDirPointerTable = virtualPDPT; 52 pgdir_phys = physicalPDPT; 53 fPageDirPointerTableHandle = pdptHandle; 54 memcpy(fVirtualPageDirs, virtualPageDirs, sizeof(fVirtualPageDirs)); 55 memcpy(fPhysicalPageDirs, physicalPageDirs, sizeof(fPhysicalPageDirs)); 56 } 57 58 59 void 60 X86PagingStructuresPAE::Delete() 61 { 62 if (are_interrupts_enabled()) 63 delete this; 64 else 65 deferred_delete(this); 66 } 67 68 69 #endif // B_HAIKU_PHYSICAL_BITS == 64 70