Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/kernel/arch/x86_64/core/paging.d b/kernel/arch/x86_64/core/paging.d
- index a44df60..9e427da 100644
- --- a/kernel/arch/x86_64/core/paging.d
- +++ b/kernel/arch/x86_64/core/paging.d
- @@ -413,56 +413,23 @@ static:
- return ErrorVal.Success;
- }
- - bool createGib(ubyte* location, ulong size, AccessMode flags) {
- + bool createSegment2(ubyte* location, ulong size, AccessMode flags) {
- uint pagelevel = sizeToPageLevel(size);
- - bool global = (flags & AccessMode.Global) != 0;
- -
- - ulong vAddr = cast(ulong)location;
- bool success;
- - PhysicalAddress phys = PageAllocator.allocPage();
- switch(pagelevel){
- case 1:
- - // create the segment in the AddressSpace
- - PageLevel!(1)* segmentParent;
- - walk!(mapSegmentHelper)(root, vAddr, flags, success, segmentParent, phys);
- + success = createGib!(1)(location, flags);
- break;
- case 2:
- - PageLevel!(2)* segmentParent;
- - walk!(mapSegmentHelper)(root, vAddr, flags, success, segmentParent, phys);
- -
- - // 'map' the segment into the Global Space
- - if(success && global){
- - PageLevel!(1)* globalSegmentParent;
- - success = false;
- -
- - walk!(mapSegmentHelper)(root, getGlobalAddress(vAddr), flags, success, globalSegmentParent, phys);
- - }
- + success = createGib!(2)(location, flags);
- break;
- case 3:
- - PageLevel!(3)* segmentParent;
- - walk!(mapSegmentHelper)(root, vAddr, flags, success, segmentParent, phys);
- -
- - // 'map' the segment into the Global Space
- - if(success && global){
- - PageLevel!(2)* globalSegmentParent;
- - success = false;
- -
- - walk!(mapSegmentHelper)(root, getGlobalAddress(vAddr), flags, success, globalSegmentParent, phys);
- - }
- + success = createGib!(3)(location, flags);
- break;
- case 4:
- - PageLevel!(4)* segmentParent;
- - walk!(mapSegmentHelper)(root, vAddr, flags, success, segmentParent, phys);
- -
- - // 'map' the segment into the Global Space
- - if(success && global){
- - PageLevel!(3)* globalSegmentParent;
- - success = false;
- -
- - walk!(mapSegmentHelper)(root, getGlobalAddress(vAddr), flags, success, globalSegmentParent, phys);
- - }
- + success = createGib!(4)(location, flags);
- break;
- }
- @@ -471,6 +438,34 @@ static:
- return success;
- }
- + template createGib(ushort PL){
- + bool createGib(ubyte *location, AccessMode flags){
- + bool global = (flags & AccessMode.Global) != 0;
- +
- + ulong vAddr = cast(ulong)location;
- + bool success;
- + PhysicalAddress phys = PageAllocator.allocPage();
- +
- + if(phys is null)
- + return false;
- +
- + PageLevel!(PL)* segmentParent;
- + walk!(mapSegmentHelper)(root, vAddr, flags, success, segmentParent, phys);
- +
- + static if(PL != 1){
- + // 'map' the segment into the Global Space
- + if(success && global){
- + PageLevel!(PL-1)* globalSegmentParent;
- + success = false;
- +
- + walk!(mapSegmentHelper)(root, getGlobalAddress(vAddr), flags, success, globalSegmentParent, phys);
- + }
- + }
- +
- + return success;
- + }
- + }
- +
- template mapSegmentHelper(U, T){
- bool mapSegmentHelper(T table, uint idx, ref AccessMode flags, ref bool success, ref U segmentParent, ref PhysicalAddress phys){
- static if(is(T == U)){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement