mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Extend NvServices and implement IDirectory (#107)
* Fix alignment handling in NvHostAsGpu::AllocSpace * Implement Ioctl{2,3} ioctls These were added in HOS 3.0.0 in order to ease handling ioctl buffers. * Introduce support for GPU address space remapping * Fix nvdrv and am service bugs Syncpoints are supposed to be allocated from ID 1, they were allocated at 0 before. The ioctl functions were also missing from the service map * Fix friend:u service name * Stub NVGPU_IOCTL_CHANNEL_SET_TIMESLICE * Stub IManagerForApplication::CheckAvailability * Add OsFileSystem Directory support and add a size field to directory entries The size field will be needed by the incoming HOS IDirectory support. * Implement support for IDirectory This is used by applications to list the contents of a directory. * Address feedback
This commit is contained in:
@ -14,9 +14,9 @@ namespace skyline::gpu::vmm {
|
||||
chunks.push_back(baseChunk);
|
||||
}
|
||||
|
||||
std::optional<ChunkDescriptor> MemoryManager::FindChunk(u64 size, ChunkState state) {
|
||||
auto chunk{std::find_if(chunks.begin(), chunks.end(), [size, state](const ChunkDescriptor &chunk) -> bool {
|
||||
return chunk.size > size && chunk.state == state;
|
||||
std::optional<ChunkDescriptor> MemoryManager::FindChunk(ChunkState state, u64 size, u64 alignment) {
|
||||
auto chunk{std::find_if(chunks.begin(), chunks.end(), [state, size, alignment](const ChunkDescriptor &chunk) -> bool {
|
||||
return (alignment ? util::IsAligned(chunk.address, alignment) : true) && chunk.size > size && chunk.state == state;
|
||||
})};
|
||||
|
||||
if (chunk != chunks.end())
|
||||
@ -83,9 +83,9 @@ namespace skyline::gpu::vmm {
|
||||
throw exception("Failed to insert chunk into GPU address space!");
|
||||
}
|
||||
|
||||
u64 MemoryManager::ReserveSpace(u64 size) {
|
||||
u64 MemoryManager::ReserveSpace(u64 size, u64 alignment) {
|
||||
size = util::AlignUp(size, constant::GpuPageSize);
|
||||
auto newChunk{FindChunk(size, ChunkState::Unmapped)};
|
||||
auto newChunk{FindChunk(ChunkState::Unmapped, size, alignment)};
|
||||
if (!newChunk)
|
||||
return 0;
|
||||
|
||||
@ -98,7 +98,7 @@ namespace skyline::gpu::vmm {
|
||||
|
||||
u64 MemoryManager::ReserveFixed(u64 address, u64 size) {
|
||||
if (!util::IsAligned(address, constant::GpuPageSize))
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
size = util::AlignUp(size, constant::GpuPageSize);
|
||||
|
||||
@ -107,7 +107,7 @@ namespace skyline::gpu::vmm {
|
||||
|
||||
u64 MemoryManager::MapAllocate(u64 address, u64 size) {
|
||||
size = util::AlignUp(size, constant::GpuPageSize);
|
||||
auto mappedChunk{FindChunk(size, ChunkState::Unmapped)};
|
||||
auto mappedChunk{FindChunk(ChunkState::Unmapped, size)};
|
||||
if (!mappedChunk)
|
||||
return 0;
|
||||
|
||||
@ -121,26 +121,22 @@ namespace skyline::gpu::vmm {
|
||||
|
||||
u64 MemoryManager::MapFixed(u64 address, u64 cpuAddress, u64 size) {
|
||||
if (!util::IsAligned(address, constant::GpuPageSize))
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
size = util::AlignUp(size, constant::GpuPageSize);
|
||||
|
||||
return InsertChunk(ChunkDescriptor(address, size, cpuAddress, ChunkState::Mapped));
|
||||
}
|
||||
|
||||
bool MemoryManager::Unmap(u64 address) {
|
||||
bool MemoryManager::Unmap(u64 address, u64 size) {
|
||||
if (!util::IsAligned(address, constant::GpuPageSize))
|
||||
return false;
|
||||
|
||||
auto chunk{std::find_if(chunks.begin(), chunks.end(), [address](const ChunkDescriptor &chunk) -> bool {
|
||||
return chunk.address == address;
|
||||
})};
|
||||
|
||||
if (chunk == chunks.end())
|
||||
try {
|
||||
InsertChunk(ChunkDescriptor(address, size, 0, ChunkState::Unmapped));
|
||||
} catch (const std::exception &e) {
|
||||
return false;
|
||||
|
||||
chunk->state = ChunkState::Reserved;
|
||||
chunk->cpuAddress = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -43,11 +43,12 @@ namespace skyline {
|
||||
|
||||
/**
|
||||
* @brief Finds a chunk of the specified type in the GPU address space that is larger than the given size
|
||||
* @param state The state of the chunk to find
|
||||
* @param size The minimum size of the chunk to find
|
||||
* @param state The state desired state of the chunk to find
|
||||
* @return The first unmapped chunk in the GPU address space that fits the requested size
|
||||
* @param alignment The alignment of the chunk to find
|
||||
* @return The first unmapped chunk in the GPU address space that fulfils the requested conditions
|
||||
*/
|
||||
std::optional<ChunkDescriptor> FindChunk(u64 size, ChunkState state);
|
||||
std::optional<ChunkDescriptor> FindChunk(ChunkState state, u64 size, u64 alignment = 0);
|
||||
|
||||
/**
|
||||
* @brief Inserts a chunk into the chunk list, resizing and splitting as necessary
|
||||
@ -62,9 +63,10 @@ namespace skyline {
|
||||
/**
|
||||
* @brief Reserves a region of the GPU address space so it will not be chosen automatically when mapping
|
||||
* @param size The size of the region to reserve
|
||||
* @param alignment The alignment of the region to reserve
|
||||
* @return The virtual GPU base address of the region base
|
||||
*/
|
||||
u64 ReserveSpace(u64 size);
|
||||
u64 ReserveSpace(u64 size, u64 alignment);
|
||||
|
||||
/**
|
||||
* @brief Reserves a fixed region of the GPU address space so it will not be chosen automatically when mapping
|
||||
@ -92,10 +94,10 @@ namespace skyline {
|
||||
u64 MapFixed(u64 address, u64 cpuAddress, u64 size);
|
||||
|
||||
/**
|
||||
* @brief Unmaps the chunk that starts at 'offset' from the GPU address space
|
||||
* @brief Unmaps all chunks in the given region from the GPU address space
|
||||
* @return Whether the operation succeeded
|
||||
*/
|
||||
bool Unmap(u64 address);
|
||||
bool Unmap(u64 address, u64 size);
|
||||
|
||||
void Read(u8 *destination, u64 address, u64 size) const;
|
||||
|
||||
|
Reference in New Issue
Block a user