fusee_cpp: implement emummc/system partition mounting
This commit is contained in:
@@ -20,13 +20,15 @@ namespace ams::nxboot {
|
||||
|
||||
void *AllocateMemory(size_t size);
|
||||
|
||||
template<typename T>
|
||||
inline T *AllocateObject() {
|
||||
void * const mem = AllocateMemory(sizeof(T) + alignof(T));
|
||||
ALWAYS_INLINE void *AllocateAligned(size_t size, size_t align) {
|
||||
return reinterpret_cast<void *>(util::AlignUp(reinterpret_cast<uintptr_t>(AllocateMemory(size + align)), align));
|
||||
}
|
||||
|
||||
T * const obj = reinterpret_cast<T *>(util::AlignUp(reinterpret_cast<uintptr_t>(mem), alignof(T)));
|
||||
template<typename T, typename... Args> requires std::constructible_from<T, Args...>
|
||||
inline T *AllocateObject(Args &&... args) {
|
||||
T * const obj = static_cast<T *>(AllocateAligned(sizeof(T), alignof(T)));
|
||||
|
||||
std::construct_at(obj);
|
||||
std::construct_at(obj, std::forward<Args>(args)...);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user