mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-09-25 12:53:19 +02:00
haze: use svc defs from vapours
This commit is contained in:
parent
dce6173137
commit
5298712061
@ -15,11 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define HAZE_ASSERT(expr) \
|
#define HAZE_ASSERT(expr) \
|
||||||
{ \
|
{ \
|
||||||
if (const bool __tmp_haze_assert_val = static_cast<bool>(expr); (!__tmp_haze_assert_val)) { \
|
const bool __tmp_haze_assert_val = static_cast<bool>(expr); \
|
||||||
svcBreak(BreakReason_Assert, 0, 0); \
|
if (AMS_UNLIKELY(!__tmp_haze_assert_val)) { \
|
||||||
} \
|
svcBreak(BreakReason_Assert, 0, 0); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HAZE_R_ABORT_UNLESS(res_expr) \
|
#define HAZE_R_ABORT_UNLESS(res_expr) \
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define ATMOSPHERE_OS_HORIZON
|
||||||
|
#define ATMOSPHERE_ARCH_ARM64
|
||||||
|
#define ATMOSPHERE_ARCH_ARM_V8A
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
@ -28,6 +32,8 @@
|
|||||||
#include <haze/assert.hpp>
|
#include <haze/assert.hpp>
|
||||||
|
|
||||||
#include <vapours/literals.hpp>
|
#include <vapours/literals.hpp>
|
||||||
|
#include <vapours/svc/svc_common.hpp>
|
||||||
|
#include <vapours/svc/svc_types_common.hpp>
|
||||||
|
|
||||||
namespace haze {
|
namespace haze {
|
||||||
|
|
||||||
|
@ -60,12 +60,15 @@ namespace haze {
|
|||||||
explicit ConsoleMainLoop() : m_reactor(), m_pad(), m_thread(), m_event(), m_cancel_event(), m_last_heap_used(), m_last_heap_total(), m_is_applet_mode() { /* ... */ }
|
explicit ConsoleMainLoop() : m_reactor(), m_pad(), m_thread(), m_event(), m_cancel_event(), m_last_heap_used(), m_last_heap_total(), m_is_applet_mode() { /* ... */ }
|
||||||
|
|
||||||
Result Initialize(EventReactor *reactor, PtpObjectHeap *object_heap) {
|
Result Initialize(EventReactor *reactor, PtpObjectHeap *object_heap) {
|
||||||
|
/* Register event reactor and heap. */
|
||||||
m_reactor = reactor;
|
m_reactor = reactor;
|
||||||
m_object_heap = object_heap;
|
m_object_heap = object_heap;
|
||||||
|
|
||||||
|
/* Get whether we are launched in applet mode. */
|
||||||
AppletType applet_type = appletGetAppletType();
|
AppletType applet_type = appletGetAppletType();
|
||||||
m_is_applet_mode = applet_type != AppletType_Application && applet_type != AppletType_SystemApplication;
|
m_is_applet_mode = applet_type != AppletType_Application && applet_type != AppletType_SystemApplication;
|
||||||
|
|
||||||
|
/* Initialize events. */
|
||||||
ueventCreate(std::addressof(m_event), true);
|
ueventCreate(std::addressof(m_event), true);
|
||||||
ueventCreate(std::addressof(m_cancel_event), true);
|
ueventCreate(std::addressof(m_cancel_event), true);
|
||||||
|
|
||||||
@ -73,8 +76,8 @@ namespace haze {
|
|||||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||||
padInitializeAny(std::addressof(m_pad));
|
padInitializeAny(std::addressof(m_pad));
|
||||||
|
|
||||||
/* Create the delay thread with higher priority than the main thread. */
|
/* Create the delay thread with higher priority than the main thread (which runs at priority 0x2c). */
|
||||||
R_TRY(threadCreate(std::addressof(m_thread), ConsoleMainLoop::Run, this, nullptr, 4_KB, 0x2b, -2));
|
R_TRY(threadCreate(std::addressof(m_thread), ConsoleMainLoop::Run, this, nullptr, 4_KB, 0x2b, svc::IdealCoreUseProcessValue));
|
||||||
|
|
||||||
/* Ensure we close the thread on failure. */
|
/* Ensure we close the thread on failure. */
|
||||||
ON_RESULT_FAILURE { threadClose(std::addressof(m_thread)); };
|
ON_RESULT_FAILURE { threadClose(std::addressof(m_thread)); };
|
||||||
|
@ -27,8 +27,8 @@ namespace haze {
|
|||||||
|
|
||||||
class EventReactor {
|
class EventReactor {
|
||||||
private:
|
private:
|
||||||
EventConsumer *m_consumers[MAX_WAIT_OBJECTS];
|
EventConsumer *m_consumers[svc::ArgumentHandleCountMax];
|
||||||
Waiter m_waiters[MAX_WAIT_OBJECTS];
|
Waiter m_waiters[svc::ArgumentHandleCountMax];
|
||||||
s32 m_num_wait_objects;
|
s32 m_num_wait_objects;
|
||||||
bool m_stop_requested;
|
bool m_stop_requested;
|
||||||
public:
|
public:
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
namespace haze {
|
namespace haze {
|
||||||
|
|
||||||
bool EventReactor::AddConsumer(EventConsumer *consumer, Waiter waiter) {
|
bool EventReactor::AddConsumer(EventConsumer *consumer, Waiter waiter) {
|
||||||
HAZE_ASSERT(m_num_wait_objects + 1 <= MAX_WAIT_OBJECTS);
|
HAZE_ASSERT(m_num_wait_objects + 1 <= svc::ArgumentHandleCountMax);
|
||||||
|
|
||||||
/* Add to the end of the list. */
|
/* Add to the end of the list. */
|
||||||
m_consumers[m_num_wait_objects] = consumer;
|
m_consumers[m_num_wait_objects] = consumer;
|
||||||
@ -49,7 +49,7 @@ namespace haze {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result EventReactor::WaitForImpl(s32 *out_arg_waiter, const Waiter *arg_waiters, s32 num_arg_waiters) {
|
Result EventReactor::WaitForImpl(s32 *out_arg_waiter, const Waiter *arg_waiters, s32 num_arg_waiters) {
|
||||||
HAZE_ASSERT(m_num_wait_objects + num_arg_waiters <= MAX_WAIT_OBJECTS);
|
HAZE_ASSERT(m_num_wait_objects + num_arg_waiters <= svc::ArgumentHandleCountMax);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
R_UNLESS(!m_stop_requested, haze::ResultStopRequested());
|
R_UNLESS(!m_stop_requested, haze::ResultStopRequested());
|
||||||
@ -60,7 +60,7 @@ namespace haze {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 idx;
|
s32 idx;
|
||||||
HAZE_R_ABORT_UNLESS(waitObjects(std::addressof(idx), m_waiters, m_num_wait_objects + num_arg_waiters, -1));
|
HAZE_R_ABORT_UNLESS(waitObjects(std::addressof(idx), m_waiters, m_num_wait_objects + num_arg_waiters, svc::WaitInfinite));
|
||||||
|
|
||||||
/* If a waiter in the argument list was signaled, return it. */
|
/* If a waiter in the argument list was signaled, return it. */
|
||||||
if (idx >= m_num_wait_objects) {
|
if (idx >= m_num_wait_objects) {
|
||||||
|
@ -33,7 +33,7 @@ namespace haze {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Estimate how much memory we can reserve. */
|
/* Estimate how much memory we can reserve. */
|
||||||
HAZE_R_ABORT_UNLESS(svcGetInfo(std::addressof(mem_used), InfoType_UsedMemorySize, CUR_PROCESS_HANDLE, 0));
|
HAZE_R_ABORT_UNLESS(svcGetInfo(std::addressof(mem_used), InfoType_UsedMemorySize, svc::CurrentProcess, 0));
|
||||||
HAZE_ASSERT(mem_used > LibnxReservedMemorySize);
|
HAZE_ASSERT(mem_used > LibnxReservedMemorySize);
|
||||||
mem_used -= LibnxReservedMemorySize;
|
mem_used -= LibnxReservedMemorySize;
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ namespace haze {
|
|||||||
PtpOperationCode_DeleteObject,
|
PtpOperationCode_DeleteObject,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr PtpEventCode SupportedEventCodes[] = { /* ... */};
|
constexpr const PtpEventCode SupportedEventCodes[] = { /* ... */};
|
||||||
constexpr PtpDevicePropertyCode SupportedPropertyCodes[] = { /* ...*/ };
|
constexpr const PtpDevicePropertyCode SupportedPropertyCodes[] = { /* ...*/ };
|
||||||
constexpr PtpObjectFormatCode SupportedCaptureFormats[] = { /* ...*/ };
|
constexpr const PtpObjectFormatCode SupportedCaptureFormats[] = { /* ...*/ };
|
||||||
constexpr PtpObjectFormatCode SupportedPlaybackFormats[] = { /* ...*/ };
|
constexpr const PtpObjectFormatCode SupportedPlaybackFormats[] = { /* ...*/ };
|
||||||
|
|
||||||
constexpr StorageId SupportedStorageIds[] = {
|
constexpr const StorageId SupportedStorageIds[] = {
|
||||||
StorageId_SdmcFs,
|
StorageId_SdmcFs,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ namespace haze {
|
|||||||
R_TRY(db.AddDataHeader(m_request_header, sizeof(u32) + (entry_count * sizeof(u32))));
|
R_TRY(db.AddDataHeader(m_request_header, sizeof(u32) + (entry_count * sizeof(u32))));
|
||||||
R_TRY(db.Add(static_cast<u32>(entry_count)));
|
R_TRY(db.Add(static_cast<u32>(entry_count)));
|
||||||
|
|
||||||
/* Enumerate the directory, writing results to the data builder as we progres. */
|
/* Enumerate the directory, writing results to the data builder as we progress. */
|
||||||
/* TODO: How should we handle the directory contents changing during enumeration? */
|
/* TODO: How should we handle the directory contents changing during enumeration? */
|
||||||
/* Is this even feasible to handle? */
|
/* Is this even feasible to handle? */
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -442,7 +442,7 @@ namespace haze {
|
|||||||
FsDirEntryType entry_type;
|
FsDirEntryType entry_type;
|
||||||
R_TRY(m_fs.GetEntryType(fileobj->GetName(), std::addressof(entry_type)));
|
R_TRY(m_fs.GetEntryType(fileobj->GetName(), std::addressof(entry_type)));
|
||||||
|
|
||||||
/* Get the size of the file. */
|
/* Get the size, if we are requesting info about a file. */
|
||||||
s64 size = 0;
|
s64 size = 0;
|
||||||
if (entry_type == FsDirEntryType_File) {
|
if (entry_type == FsDirEntryType_File) {
|
||||||
FsFile file;
|
FsFile file;
|
||||||
|
Loading…
Reference in New Issue
Block a user