fusee_cpp: implement emummc/system partition mounting

This commit is contained in:
Michael Scire 2021-08-31 22:51:51 -07:00 committed by SciresM
parent 8560713a60
commit 2f7012cbc6
15 changed files with 1009 additions and 18 deletions

View file

@ -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;
}