mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Update kernel
This commit is contained in:
@ -36,6 +36,9 @@ namespace Memory
|
||||
uintptr_t Break = 0x0;
|
||||
|
||||
public:
|
||||
/* fork() */
|
||||
void SetTable(PageTable *Table) { this->Table = Table; }
|
||||
|
||||
/* Directly to syscall */
|
||||
void *brk(void *Address);
|
||||
|
||||
|
@ -148,7 +148,7 @@ namespace Memory
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
};
|
||||
uintptr_t raw;
|
||||
uintptr_t raw = 0;
|
||||
|
||||
/** @brief Set Address */
|
||||
void SetAddress(uintptr_t _Address)
|
||||
@ -273,7 +273,7 @@ namespace Memory
|
||||
} FourMiB;
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
uintptr_t raw;
|
||||
uintptr_t raw = 0;
|
||||
|
||||
/** @brief Set PageTableEntryPtr address */
|
||||
void SetAddress(uintptr_t _Address)
|
||||
@ -359,7 +359,7 @@ namespace Memory
|
||||
} OneGiB;
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
uintptr_t raw;
|
||||
uintptr_t raw = 0;
|
||||
|
||||
/** @brief Set PageDirectoryEntryPtr address */
|
||||
void SetAddress(uintptr_t _Address)
|
||||
@ -413,7 +413,7 @@ namespace Memory
|
||||
};
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
uintptr_t raw;
|
||||
uintptr_t raw = 0;
|
||||
|
||||
/** @brief Set PageDirectoryPointerTableEntryPtr address */
|
||||
void SetAddress(uintptr_t _Address)
|
||||
@ -467,7 +467,7 @@ namespace Memory
|
||||
};
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
uintptr_t raw;
|
||||
uintptr_t raw = 0;
|
||||
|
||||
/** @brief Set PageMapLevel4Ptr address */
|
||||
void SetAddress(uintptr_t _Address)
|
||||
@ -516,10 +516,34 @@ namespace Memory
|
||||
*
|
||||
* @return A new PageTable with the same content
|
||||
*/
|
||||
PageTable Fork();
|
||||
PageTable *Fork();
|
||||
|
||||
void *__getPhysical(void *Address);
|
||||
|
||||
/**
|
||||
* @brief Get the Physical Address of a virtual address
|
||||
*
|
||||
* This function will return the physical address
|
||||
* of a virtual address and not the virtual address
|
||||
* of the current page table. This is intentional because
|
||||
* the kernel page table has 1:1 mapping for the free
|
||||
* memory.
|
||||
*
|
||||
* @tparam T
|
||||
* @param Address The virtual address
|
||||
* @return The physical address
|
||||
*/
|
||||
template <typename T>
|
||||
T Get(T Address);
|
||||
T Get(T Address)
|
||||
{
|
||||
void *PhysAddr = __getPhysical((void *)Address);
|
||||
if (PhysAddr == nullptr)
|
||||
return {};
|
||||
uintptr_t Diff = uintptr_t(Address);
|
||||
Diff &= 0xFFF;
|
||||
Diff = uintptr_t(PhysAddr) + Diff;
|
||||
return (T)Diff;
|
||||
}
|
||||
} __aligned(0x1000);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Memory
|
||||
{
|
||||
private:
|
||||
NewLock(MemoryLock);
|
||||
PageTable *Table = nullptr;
|
||||
PageTable *pTable = nullptr;
|
||||
|
||||
public:
|
||||
enum MapType
|
||||
@ -60,8 +60,7 @@ namespace Memory
|
||||
* @param VirtualAddress Virtual address of the page
|
||||
* @param Flag Flag to check
|
||||
* @param Type Type of the page. Check MapType enum.
|
||||
* @return true if page has the specified flag.
|
||||
* @return false if page is has the specified flag.
|
||||
* @return true if page has the specified flag, false otherwise.
|
||||
*/
|
||||
bool Check(void *VirtualAddress,
|
||||
PTFlag Flag = PTFlag::P,
|
||||
|
@ -56,6 +56,7 @@ namespace Memory
|
||||
|
||||
public:
|
||||
PageTable *GetTable() { return Table; }
|
||||
void SetTable(PageTable *Table) { this->Table = Table; }
|
||||
|
||||
std::vector<AllocatedPages> GetAllocatedPagesList()
|
||||
{
|
||||
@ -94,6 +95,10 @@ namespace Memory
|
||||
|
||||
bool HandleCoW(uintptr_t PFA);
|
||||
|
||||
void FreeAllPages();
|
||||
|
||||
void Fork(VirtualMemoryArea *Parent);
|
||||
|
||||
VirtualMemoryArea(PageTable *Table = nullptr);
|
||||
~VirtualMemoryArea();
|
||||
};
|
||||
|
Reference in New Issue
Block a user