mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-03 18:12:14 +02:00
Add virtmemFindAliasMemory to virtmem APIs
This commit is contained in:
parent
091f88915d
commit
e0b8852257
@ -59,6 +59,15 @@ void* virtmemFindStack(size_t size, size_t guard_size);
|
|||||||
*/
|
*/
|
||||||
void* virtmemFindCodeMemory(size_t size, size_t guard_size);
|
void* virtmemFindCodeMemory(size_t size, size_t guard_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finds a random slice of free alias address space.
|
||||||
|
* @param size Desired size of the slice (rounded up to page alignment).
|
||||||
|
* @param guard_size Desired size of the unmapped guard areas surrounding the slice (rounded up to page alignment).
|
||||||
|
* @return Pointer to the slice of address space, or NULL on failure.
|
||||||
|
* @note The virtual memory manager mutex must be held during the find-and-map process (see \ref virtmemLock and \ref virtmemUnlock).
|
||||||
|
*/
|
||||||
|
void* virtmemFindAlias(size_t size, size_t guard_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reserves a range of memory address space.
|
* @brief Reserves a range of memory address space.
|
||||||
* @param mem Pointer to the address space slice.
|
* @param mem Pointer to the address space slice.
|
||||||
|
@ -273,6 +273,11 @@ void* virtmemFindCodeMemory(size_t size, size_t guard_size) {
|
|||||||
return _memregionFindRandom(g_IsLegacyKernel ? &g_StackRegion : &g_AslrRegion, size, guard_size);
|
return _memregionFindRandom(g_IsLegacyKernel ? &g_StackRegion : &g_AslrRegion, size, guard_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* virtmemFindAlias(size_t size, size_t guard_size) {
|
||||||
|
if (!mutexIsLockedByCurrentThread(&g_VirtmemMutex)) return NULL;
|
||||||
|
return _memregionFindRandom(&g_AliasRegion, size, guard_size);
|
||||||
|
}
|
||||||
|
|
||||||
VirtmemReservation* virtmemAddReservation(void* mem, size_t size) {
|
VirtmemReservation* virtmemAddReservation(void* mem, size_t size) {
|
||||||
if (!mutexIsLockedByCurrentThread(&g_VirtmemMutex)) return NULL;
|
if (!mutexIsLockedByCurrentThread(&g_VirtmemMutex)) return NULL;
|
||||||
VirtmemReservation* rv = (VirtmemReservation*)malloc(sizeof(VirtmemReservation));
|
VirtmemReservation* rv = (VirtmemReservation*)malloc(sizeof(VirtmemReservation));
|
||||||
|
Loading…
Reference in New Issue
Block a user