mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
more APIs
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
|
||||
#include "Kyty/Core/Common.h"
|
||||
#include "Kyty/Core/DbgAssert.h"
|
||||
#include "Kyty/Core/MagicEnum.h"
|
||||
#include "Kyty/Core/String.h"
|
||||
#include "Kyty/Core/Threads.h"
|
||||
|
||||
#include "Emulator/Kernel/Pthread.h"
|
||||
#include "Emulator/Libs/Errno.h"
|
||||
#include "Emulator/Libs/Libs.h"
|
||||
|
||||
@@ -15,13 +17,75 @@ namespace Kyty::Libs::Audio {
|
||||
class Audio
|
||||
{
|
||||
public:
|
||||
enum class Format
|
||||
{
|
||||
Unknown,
|
||||
Signed16bitMono,
|
||||
Signed16bitStereo,
|
||||
Signed16bit8Ch,
|
||||
FloatMono,
|
||||
FloatStereo,
|
||||
Float8Ch,
|
||||
Signed16bit8ChStd,
|
||||
Float8ChStd,
|
||||
};
|
||||
|
||||
class Id
|
||||
{
|
||||
public:
|
||||
explicit Id(int id): m_id(id - 1) {}
|
||||
[[nodiscard]] int ToInt() const { return m_id + 1; }
|
||||
[[nodiscard]] bool IsValid() const { return m_id >= 0; }
|
||||
|
||||
friend class Audio;
|
||||
|
||||
private:
|
||||
Id() = default;
|
||||
static Id Invalid() { return Id(); }
|
||||
static Id Create(int audio_id)
|
||||
{
|
||||
Id r;
|
||||
r.m_id = audio_id;
|
||||
return r;
|
||||
}
|
||||
[[nodiscard]] int GetId() const { return m_id; }
|
||||
|
||||
int m_id = -1;
|
||||
};
|
||||
|
||||
struct OutputParam
|
||||
{
|
||||
Id handle;
|
||||
const void* data = nullptr;
|
||||
};
|
||||
|
||||
Audio() = default;
|
||||
virtual ~Audio() = default;
|
||||
|
||||
KYTY_CLASS_NO_COPY(Audio);
|
||||
|
||||
Id AudioOutOpen(int type, uint32_t samples_num, uint32_t freq, Format format);
|
||||
bool AudioOutValid(Id handle);
|
||||
bool AudioOutSetVolume(Id handle, uint32_t bitflag, const int* volume);
|
||||
uint32_t AudioOutOutputs(OutputParam* params, uint32_t num);
|
||||
|
||||
static constexpr int PORTS_MAX = 32;
|
||||
|
||||
private:
|
||||
struct Port
|
||||
{
|
||||
bool used = false;
|
||||
int type = 0;
|
||||
uint32_t samples_num = 0;
|
||||
uint32_t freq = 0;
|
||||
Format format = Format::Unknown;
|
||||
uint64_t last_output_time = 0;
|
||||
int channels_num = 0;
|
||||
int volume[8] = {};
|
||||
};
|
||||
|
||||
Core::Mutex m_mutex;
|
||||
Port m_ports[PORTS_MAX];
|
||||
};
|
||||
|
||||
static Audio* g_audio = nullptr;
|
||||
@@ -37,6 +101,230 @@ KYTY_SUBSYSTEM_UNEXPECTED_SHUTDOWN(Audio) {}
|
||||
|
||||
KYTY_SUBSYSTEM_DESTROY(Audio) {}
|
||||
|
||||
Audio::Id Audio::AudioOutOpen(int type, uint32_t samples_num, uint32_t freq, Format format)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
for (int id = 0; id < PORTS_MAX; id++)
|
||||
{
|
||||
if (!m_ports[id].used)
|
||||
{
|
||||
auto& port = m_ports[id];
|
||||
|
||||
port.used = true;
|
||||
port.type = type;
|
||||
port.samples_num = samples_num;
|
||||
port.freq = freq;
|
||||
port.format = format;
|
||||
port.last_output_time = 0;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case Format::Signed16bitMono:
|
||||
case Format::FloatMono: port.channels_num = 1; break;
|
||||
case Format::Signed16bitStereo:
|
||||
case Format::FloatStereo: port.channels_num = 2; break;
|
||||
case Format::Signed16bit8Ch:
|
||||
case Format::Float8Ch:
|
||||
case Format::Signed16bit8ChStd:
|
||||
case Format::Float8ChStd: port.channels_num = 8; break;
|
||||
default: EXIT("unknown format");
|
||||
}
|
||||
|
||||
for (int i = 0; i < port.channels_num; i++)
|
||||
{
|
||||
port.volume[i] = 32768;
|
||||
}
|
||||
|
||||
return Id::Create(id);
|
||||
}
|
||||
}
|
||||
|
||||
return Id::Invalid();
|
||||
}
|
||||
|
||||
bool Audio::AudioOutValid(Id handle)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
return (handle.GetId() >= 0 && handle.GetId() < PORTS_MAX && m_ports[handle.GetId()].used);
|
||||
}
|
||||
|
||||
bool Audio::AudioOutSetVolume(Id handle, uint32_t bitflag, const int* volume)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
if (AudioOutValid(handle))
|
||||
{
|
||||
auto& port = m_ports[handle.GetId()];
|
||||
|
||||
for (int i = 0; i < port.channels_num; i++, bitflag >>= 1u)
|
||||
{
|
||||
auto bit = bitflag & 0x1u;
|
||||
|
||||
if (bit == 1)
|
||||
{
|
||||
int src_index = i;
|
||||
if (port.format == Format::Float8ChStd || port.format == Format::Signed16bit8ChStd)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 4: src_index = 6; break;
|
||||
case 5: src_index = 7; break;
|
||||
case 6: src_index = 4; break;
|
||||
case 7: src_index = 5; break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
port.volume[i] = volume[src_index];
|
||||
|
||||
printf("\t port.volume[%d] = volume[%d] (%d)\n", i, src_index, volume[src_index]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t Audio::AudioOutOutputs(OutputParam* params, uint32_t num)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(num == 0);
|
||||
EXIT_NOT_IMPLEMENTED(!AudioOutValid(params[0].handle));
|
||||
|
||||
const auto& first_port = m_ports[params[0].handle.GetId()];
|
||||
|
||||
uint64_t block_time = (1000000 * first_port.samples_num) / first_port.freq;
|
||||
uint64_t current_time = LibKernel::KernelGetProcessTime();
|
||||
|
||||
uint64_t max_wait_time = 0;
|
||||
|
||||
for (uint32_t i = 0; i < num; i++)
|
||||
{
|
||||
uint64_t next_time = m_ports[params[i].handle.GetId()].last_output_time + block_time;
|
||||
uint64_t wait_time = (next_time > current_time ? next_time - current_time : 0);
|
||||
max_wait_time = (wait_time > max_wait_time ? wait_time : max_wait_time);
|
||||
}
|
||||
|
||||
// Audio output is not yet implemented, so simulate audio delay
|
||||
Core::Thread::SleepMicro(max_wait_time);
|
||||
|
||||
for (uint32_t i = 0; i < num; i++)
|
||||
{
|
||||
m_ports[params[i].handle.GetId()].last_output_time = LibKernel::KernelGetProcessTime();
|
||||
}
|
||||
|
||||
return first_port.samples_num;
|
||||
}
|
||||
|
||||
namespace AudioOut {
|
||||
|
||||
LIB_NAME("AudioOut", "AudioOut");
|
||||
|
||||
struct AudioOutOutputParam
|
||||
{
|
||||
int handle;
|
||||
const void* ptr;
|
||||
};
|
||||
|
||||
int KYTY_SYSV_ABI AudioOutInit()
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI AudioOutOpen(int user_id, int type, int index, uint32_t len, uint32_t freq, uint32_t param)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\t user_id = %d\n", user_id);
|
||||
printf("\t type = %d\n", type);
|
||||
printf("\t index = %d\n", index);
|
||||
printf("\t len = %u\n", len);
|
||||
printf("\t freq = %u\n", freq);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(user_id != 255);
|
||||
EXIT_NOT_IMPLEMENTED(type != 0);
|
||||
EXIT_NOT_IMPLEMENTED(index != 0);
|
||||
|
||||
Audio::Format format = Audio::Format::Unknown;
|
||||
|
||||
switch (param)
|
||||
{
|
||||
case 0: format = Audio::Format::Signed16bitMono; break;
|
||||
case 1: format = Audio::Format::Signed16bitStereo; break;
|
||||
case 2: format = Audio::Format::Signed16bit8Ch; break;
|
||||
case 3: format = Audio::Format::FloatMono; break;
|
||||
case 4: format = Audio::Format::FloatStereo; break;
|
||||
case 5: format = Audio::Format::Float8Ch; break;
|
||||
case 6: format = Audio::Format::Signed16bit8ChStd; break;
|
||||
case 7: format = Audio::Format::Float8ChStd; break;
|
||||
default:;
|
||||
}
|
||||
|
||||
printf("\t param = %u (%s)\n", param, Core::EnumName(format).C_Str());
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(format == Audio::Format::Unknown);
|
||||
|
||||
EXIT_IF(g_audio == nullptr);
|
||||
|
||||
auto id = g_audio->AudioOutOpen(type, len, freq, format);
|
||||
|
||||
if (!id.IsValid())
|
||||
{
|
||||
return AUDIO_OUT_ERROR_PORT_FULL;
|
||||
}
|
||||
|
||||
return id.ToInt();
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI AudioOutSetVolume(int handle, uint32_t flag, int* vol)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\t handle = %d\n", handle);
|
||||
printf("\t flag = %u\n", flag);
|
||||
|
||||
EXIT_IF(g_audio == nullptr);
|
||||
EXIT_NOT_IMPLEMENTED(vol == nullptr);
|
||||
|
||||
if (!g_audio->AudioOutSetVolume(Audio::Id(handle), flag, vol))
|
||||
{
|
||||
return AUDIO_OUT_ERROR_INVALID_PORT;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI AudioOutOutputs(AudioOutOutputParam* param, uint32_t num)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(param == nullptr);
|
||||
EXIT_NOT_IMPLEMENTED(num != 1);
|
||||
|
||||
Audio::OutputParam params[Audio::PORTS_MAX];
|
||||
|
||||
EXIT_IF(g_audio == nullptr);
|
||||
|
||||
for (uint32_t i = 0; i < num; i++)
|
||||
{
|
||||
params[i].handle = Audio::Id(param[i].handle);
|
||||
params[i].data = param[i].ptr;
|
||||
|
||||
if (!g_audio->AudioOutValid(params[i].handle))
|
||||
{
|
||||
return AUDIO_OUT_ERROR_INVALID_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
return static_cast<int>(g_audio->AudioOutOutputs(params, num));
|
||||
}
|
||||
|
||||
} // namespace AudioOut
|
||||
|
||||
namespace VoiceQoS {
|
||||
|
||||
LIB_NAME("VoiceQoS", "VoiceQoS");
|
||||
|
||||
@@ -476,22 +476,32 @@ void TileGetDepthSize(uint32_t width, uint32_t height, uint32_t z_format, uint32
|
||||
};
|
||||
|
||||
static const DepthInfo infos_base[] = {
|
||||
{3840, 2160, 3, 0, true, false, 3840, {0, 0}, {655360, 2048}, {33423360, 32768}},
|
||||
{3840, 2160, 3, 0, false, false, 3840, {0, 0}, {0, 0}, {33423360, 32768}},
|
||||
{1920, 1080, 3, 0, true, false, 2048, {0, 0}, {196608, 2048}, {9437184, 32768}},
|
||||
{1920, 1080, 3, 0, false, false, 2048, {0, 0}, {0, 0}, {9437184, 32768}},
|
||||
{1280, 720, 3, 0, true, false, 1280, {0, 0}, {98304, 2048}, {3932160, 32768}},
|
||||
{1280, 720, 3, 0, false, false, 1280, {0, 0}, {0, 0}, {3932160, 32768}},
|
||||
{3840, 2160, 1, 0, true, false, 3840, {0, 0}, {655360, 2048}, {16711680, 32768}},
|
||||
{3840, 2160, 1, 0, false, false, 3840, {0, 0}, {0, 0}, {16711680, 32768}},
|
||||
{1920, 1080, 1, 0, true, false, 2048, {0, 0}, {196608, 2048}, {4718592, 32768}},
|
||||
{1920, 1080, 1, 0, false, false, 2048, {0, 0}, {0, 0}, {4718592, 32768}},
|
||||
{1280, 720, 1, 0, true, false, 1280, {0, 0}, {98304, 2048}, {1966080, 32768}},
|
||||
{1280, 720, 1, 0, false, false, 1280, {0, 0}, {0, 0}, {1966080, 32768}},
|
||||
{3840, 2160, 0, 1, true, false, 3840, {8355840, 32768}, {655360, 2048}, {0, 0}},
|
||||
{3840, 2160, 0, 1, false, false, 3840, {8355840, 32768}, {0, 0}, {0, 0}},
|
||||
{1920, 1080, 0, 1, true, false, 2048, {2359296, 32768}, {196608, 2048}, {0, 0}},
|
||||
{1920, 1080, 0, 1, false, false, 2048, {2359296, 32768}, {0, 0}, {0, 0}},
|
||||
{1280, 720, 0, 1, true, false, 1280, {983040, 32768}, {98304, 2048}, {0, 0}},
|
||||
{1280, 720, 0, 1, false, false, 1280, {983040, 32768}, {0, 0}, {0, 0}},
|
||||
{3840, 2160, 3, 1, true, false, 3840, {8355840, 32768}, {655360, 2048}, {33423360, 32768}},
|
||||
{3840, 2160, 3, 1, false, false, 3840, {8355840, 32768}, {0, 0}, {33423360, 32768}},
|
||||
{1920, 1080, 3, 1, true, false, 2048, {2359296, 32768}, {196608, 2048}, {9437184, 32768}},
|
||||
{1920, 1080, 3, 1, false, false, 2048, {2359296, 32768}, {0, 0}, {9437184, 32768}},
|
||||
{1280, 720, 3, 1, true, false, 1280, {983040, 32768}, {98304, 2048}, {3932160, 32768}},
|
||||
{1280, 720, 3, 1, false, false, 1280, {983040, 32768}, {0, 0}, {3932160, 32768}},
|
||||
{3840, 2160, 1, 1, true, false, 3840, {8355840, 32768}, {655360, 2048}, {16711680, 32768}},
|
||||
{3840, 2160, 1, 1, false, false, 3840, {8355840, 32768}, {0, 0}, {16711680, 32768}},
|
||||
{1920, 1080, 1, 1, true, false, 2048, {2359296, 32768}, {196608, 2048}, {4718592, 32768}},
|
||||
{1920, 1080, 1, 1, false, false, 2048, {2359296, 32768}, {0, 0}, {4718592, 32768}},
|
||||
{1280, 720, 1, 1, true, false, 1280, {983040, 32768}, {98304, 2048}, {1966080, 32768}},
|
||||
@@ -499,22 +509,32 @@ void TileGetDepthSize(uint32_t width, uint32_t height, uint32_t z_format, uint32
|
||||
};
|
||||
|
||||
static const DepthInfo infos_neo[] = {
|
||||
{3840, 2160, 3, 0, true, true, 3840, {0, 0}, {655360, 4096}, {33423360, 65536}},
|
||||
{3840, 2160, 3, 0, false, true, 3840, {0, 0}, {0, 0}, {33423360, 65536}},
|
||||
{1920, 1080, 3, 0, true, true, 1920, {0, 0}, {196608, 4096}, {8847360, 65536}},
|
||||
{1920, 1080, 3, 0, false, true, 1920, {0, 0}, {0, 0}, {8847360, 65536}},
|
||||
{1280, 720, 3, 0, true, true, 1280, {0, 0}, {131072, 4096}, {3932160, 65536}},
|
||||
{1280, 720, 3, 0, false, true, 1280, {0, 0}, {0, 0}, {3932160, 65536}},
|
||||
{3840, 2160, 1, 0, true, true, 3840, {0, 0}, {655360, 4096}, {16711680, 65536}},
|
||||
{3840, 2160, 1, 0, false, true, 3840, {0, 0}, {0, 0}, {16711680, 65536}},
|
||||
{1920, 1080, 1, 0, true, true, 2048, {0, 0}, {196608, 4096}, {4718592, 65536}},
|
||||
{1920, 1080, 1, 0, false, true, 2048, {0, 0}, {0, 0}, {4718592, 65536}},
|
||||
{1280, 720, 1, 0, true, true, 1280, {0, 0}, {131072, 4096}, {1966080, 65536}},
|
||||
{1280, 720, 1, 0, false, true, 1280, {0, 0}, {0, 0}, {1966080, 65536}},
|
||||
{3840, 2160, 0, 1, true, true, 3840, {8355840, 32768}, {655360, 4096}, {0, 0}},
|
||||
{3840, 2160, 0, 1, false, true, 3840, {8355840, 32768}, {0, 0}, {0, 0}},
|
||||
{1920, 1080, 0, 1, true, true, 2048, {2359296, 32768}, {196608, 4096}, {0, 0}},
|
||||
{1920, 1080, 0, 1, false, true, 2048, {2359296, 32768}, {0, 0}, {0, 0}},
|
||||
{1280, 720, 0, 1, true, true, 1280, {983040, 32768}, {131072, 4096}, {0, 0}},
|
||||
{1280, 720, 0, 1, false, true, 1280, {983040, 32768}, {0, 0}, {0, 0}},
|
||||
{3840, 2160, 3, 1, true, true, 3840, {8355840, 32768}, {655360, 4096}, {33423360, 65536}},
|
||||
{3840, 2160, 3, 1, false, true, 3840, {8355840, 32768}, {0, 0}, {33423360, 65536}},
|
||||
{1920, 1080, 3, 1, true, true, 2048, {2359296, 32768}, {196608, 4096}, {9437184, 65536}},
|
||||
{1920, 1080, 3, 1, false, true, 2048, {2359296, 32768}, {0, 0}, {9437184, 65536}},
|
||||
{1280, 720, 3, 1, true, true, 1280, {983040, 32768}, {131072, 4096}, {3932160, 65536}},
|
||||
{1280, 720, 3, 1, false, true, 1280, {983040, 32768}, {0, 0}, {3932160, 65536}},
|
||||
{3840, 2160, 1, 1, true, true, 3840, {8355840, 32768}, {655360, 4096}, {16711680, 65536}},
|
||||
{3840, 2160, 1, 1, false, true, 3840, {8355840, 32768}, {0, 0}, {16711680, 65536}},
|
||||
{1920, 1080, 1, 1, true, true, 2048, {2359296, 32768}, {196608, 4096}, {4718592, 65536}},
|
||||
{1920, 1080, 1, 1, false, true, 2048, {2359296, 32768}, {0, 0}, {4718592, 65536}},
|
||||
{1280, 720, 1, 1, true, true, 1280, {983040, 32768}, {131072, 4096}, {1966080, 65536}},
|
||||
@@ -566,6 +586,27 @@ void TileGetVideoOutSize(uint32_t width, uint32_t height, bool tile, bool neo, u
|
||||
uint32_t ret_size = 0;
|
||||
uint32_t ret_pitch = 0;
|
||||
|
||||
if (width == 3840 && height == 2160 && tile && !neo)
|
||||
{
|
||||
ret_size = 33423360;
|
||||
ret_pitch = 3840;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && tile && neo)
|
||||
{
|
||||
ret_size = 33423360;
|
||||
ret_pitch = 3840;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && !tile && !neo)
|
||||
{
|
||||
ret_size = 33177600;
|
||||
ret_pitch = 3840;
|
||||
}
|
||||
if (width == 3840 && height == 2160 && !tile && neo)
|
||||
{
|
||||
ret_size = 33177600;
|
||||
ret_pitch = 3840;
|
||||
}
|
||||
|
||||
if (width == 1920 && height == 1080 && tile && !neo)
|
||||
{
|
||||
ret_size = 8355840;
|
||||
@@ -586,6 +627,7 @@ void TileGetVideoOutSize(uint32_t width, uint32_t height, bool tile, bool neo, u
|
||||
ret_size = 8294400;
|
||||
ret_pitch = 1920;
|
||||
}
|
||||
|
||||
if (width == 1280 && height == 720 && tile && !neo)
|
||||
{
|
||||
ret_size = 3932160;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "Emulator/Graphics/Utils.h"
|
||||
#include "Emulator/Graphics/VideoOut.h"
|
||||
#include "Emulator/Profiler.h"
|
||||
#include "Emulator/VirtualMemory.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_error.h"
|
||||
@@ -230,6 +231,7 @@ struct WindowContext
|
||||
GameApi* game = nullptr;
|
||||
|
||||
char device_name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE] = {0};
|
||||
char processor_name[64] = {0};
|
||||
|
||||
Core::Mutex mutex;
|
||||
bool graphic_initialized = false;
|
||||
@@ -2016,6 +2018,7 @@ static void VulkanCreate(WindowContext* ctx)
|
||||
printf("Select device: %s\n", device_properties.deviceName);
|
||||
|
||||
memcpy(ctx->device_name, device_properties.deviceName, sizeof(ctx->device_name));
|
||||
memcpy(ctx->processor_name, Loader::GetSystemInfo().ProcessorName.C_Str(), sizeof(ctx->processor_name));
|
||||
|
||||
ctx->graphic_ctx.device =
|
||||
VulkanCreateDevice(ctx->graphic_ctx.physical_device, ctx->surface, &r, VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT,
|
||||
@@ -2109,8 +2112,8 @@ void WindowShowFps()
|
||||
EXIT_IF(g_window_ctx == nullptr);
|
||||
EXIT_IF(g_window_ctx->game == nullptr);
|
||||
|
||||
auto fps = String::FromPrintf("[%s], frame: %d, fps: %f", g_window_ctx->device_name, g_window_ctx->game->m_frame_num,
|
||||
g_window_ctx->game->m_current_fps);
|
||||
auto fps = String::FromPrintf("[%s] [%s], frame: %d, fps: %f", g_window_ctx->device_name, g_window_ctx->processor_name,
|
||||
g_window_ctx->game->m_frame_num, g_window_ctx->game->m_current_fps);
|
||||
|
||||
SDL_SetWindowTitle(g_window_ctx->window, fps.C_Str());
|
||||
}
|
||||
|
||||
@@ -90,6 +90,8 @@ KYTY_SUBSYSTEM_INIT(Memory)
|
||||
{
|
||||
g_physical_memory = new PhysicalMemory;
|
||||
g_flexible_memory = new FlexibleMemory;
|
||||
|
||||
VirtualMemory::Init();
|
||||
}
|
||||
|
||||
KYTY_SUBSYSTEM_UNEXPECTED_SHUTDOWN(Memory) {}
|
||||
|
||||
@@ -2310,6 +2310,7 @@ int KYTY_SYSV_ABI KernelClockGettime(KernelClockid clock_id, KernelTimespec* tp)
|
||||
switch (clock_id)
|
||||
{
|
||||
case 0: pclock_id = CLOCK_REALTIME; break;
|
||||
case 13:
|
||||
case 4: pclock_id = CLOCK_MONOTONIC; break;
|
||||
default: EXIT("unknown clock_id: %d", clock_id);
|
||||
}
|
||||
@@ -2419,7 +2420,7 @@ int KYTY_SYSV_ABI KernelNanosleep(const KernelTimespec* rqtp, KernelTimespec* rm
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
if (rqtp == nullptr || rmtp == nullptr)
|
||||
if (rqtp == nullptr)
|
||||
{
|
||||
return KERNEL_ERROR_EFAULT;
|
||||
}
|
||||
@@ -2438,7 +2439,11 @@ int KYTY_SYSV_ABI KernelNanosleep(const KernelTimespec* rqtp, KernelTimespec* rm
|
||||
Core::Thread::SleepNano(nanos);
|
||||
double ts = t.GetTimeS();
|
||||
printf("\tactual: %g nanoseconds\n", ts * 1000000000.0);
|
||||
sec_to_timespec(rmtp, ts);
|
||||
|
||||
if (rmtp != nullptr)
|
||||
{
|
||||
sec_to_timespec(rmtp, ts);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -2546,14 +2551,14 @@ int KYTY_SYSV_ABI pthread_cond_wait(LibKernel::PthreadCond* cond, LibKernel::Pth
|
||||
|
||||
int KYTY_SYSV_ABI pthread_mutex_lock(LibKernel::PthreadMutex* mutex)
|
||||
{
|
||||
PRINT_NAME();
|
||||
// PRINT_NAME();
|
||||
|
||||
return POSIX_PTHREAD_CALL(LibKernel::PthreadMutexLock(mutex));
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI pthread_mutex_unlock(LibKernel::PthreadMutex* mutex)
|
||||
{
|
||||
PRINT_NAME();
|
||||
// PRINT_NAME();
|
||||
|
||||
return POSIX_PTHREAD_CALL(LibKernel::PthreadMutexUnlock(mutex));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "Kyty/Core/Common.h"
|
||||
#include "Kyty/Core/Core.h"
|
||||
#include "Kyty/Core/DbgAssert.h"
|
||||
#include "Kyty/Core/MagicEnum.h"
|
||||
@@ -8,6 +7,7 @@
|
||||
#include "Kyty/Core/Threads.h"
|
||||
#include "Kyty/Core/Vector.h"
|
||||
#include "Kyty/Scripts/Scripts.h"
|
||||
#include "Kyty/UnitTest.h"
|
||||
|
||||
#include "Emulator/Audio.h"
|
||||
#include "Emulator/Common.h"
|
||||
@@ -58,6 +58,7 @@ static void print_system_info()
|
||||
printf("AllocationGranularity = %" PRIu32 "\n", info.AllocationGranularity);
|
||||
printf("ProcessorLevel = %" PRIu16 "\n", info.ProcessorLevel);
|
||||
printf("ProcessorRevision = 0x%04" PRIx16 "\n", info.ProcessorRevision);
|
||||
printf("ProcessorName = %s\n", info.ProcessorName.C_Str());
|
||||
}
|
||||
|
||||
static void kyty_close()
|
||||
@@ -144,7 +145,7 @@ KYTY_SCRIPT_FUNC(kyty_init_func)
|
||||
|
||||
KYTY_SCRIPT_FUNC(kyty_load_elf_func)
|
||||
{
|
||||
if (Scripts::ArgGetVarCount() != 1 && Scripts::ArgGetVarCount() != 2)
|
||||
if (Scripts::ArgGetVarCount() != 1 && Scripts::ArgGetVarCount() != 2 && Scripts::ArgGetVarCount() != 3)
|
||||
{
|
||||
EXIT("invalid args\n");
|
||||
}
|
||||
@@ -155,7 +156,7 @@ KYTY_SCRIPT_FUNC(kyty_load_elf_func)
|
||||
|
||||
auto* program = rt->LoadProgram(Libs::LibKernel::FileSystem::GetRealFilename(elf.ToString()));
|
||||
|
||||
if (Scripts::ArgGetVarCount() == 2)
|
||||
if (Scripts::ArgGetVarCount() >= 2)
|
||||
{
|
||||
if (Scripts::ArgGetVar(1).ToInteger() == 1)
|
||||
{
|
||||
@@ -163,6 +164,13 @@ KYTY_SCRIPT_FUNC(kyty_load_elf_func)
|
||||
}
|
||||
}
|
||||
|
||||
if (Scripts::ArgGetVarCount() >= 3)
|
||||
{
|
||||
auto save_name = Scripts::ArgGetVar(2).ToString();
|
||||
|
||||
rt->SaveProgram(program, Libs::LibKernel::FileSystem::GetRealFilename(save_name));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -355,6 +363,16 @@ KYTY_SCRIPT_FUNC(kyty_shader_printf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
KYTY_SCRIPT_FUNC(kyty_run_tests)
|
||||
{
|
||||
if (!UnitTest::unit_test_all())
|
||||
{
|
||||
EXIT("test failed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kyty_help() {}
|
||||
|
||||
} // namespace LuaFunc
|
||||
@@ -371,6 +389,7 @@ void kyty_reg()
|
||||
Scripts::RegisterFunc("kyty_mount", LuaFunc::kyty_mount_func, LuaFunc::kyty_help);
|
||||
Scripts::RegisterFunc("kyty_shader_disable", LuaFunc::kyty_shader_disable, LuaFunc::kyty_help);
|
||||
Scripts::RegisterFunc("kyty_shader_printf", LuaFunc::kyty_shader_printf, LuaFunc::kyty_help);
|
||||
Scripts::RegisterFunc("kyty_run_tests", LuaFunc::kyty_run_tests, LuaFunc::kyty_help);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -7,6 +7,22 @@
|
||||
|
||||
namespace Kyty::Libs {
|
||||
|
||||
namespace LibAudioOut {
|
||||
|
||||
LIB_VERSION("AudioOut", 1, "AudioOut", 1, 1);
|
||||
|
||||
namespace AudioOut = Audio::AudioOut;
|
||||
|
||||
LIB_DEFINE(InitAudio_1_AudioOut)
|
||||
{
|
||||
LIB_FUNC("JfEPXVxhFqA", AudioOut::AudioOutInit);
|
||||
LIB_FUNC("ekNvsT22rsY", AudioOut::AudioOutOpen);
|
||||
LIB_FUNC("b+uAV89IlxE", AudioOut::AudioOutSetVolume);
|
||||
LIB_FUNC("w3PdaSTSwGE", AudioOut::AudioOutOutputs);
|
||||
}
|
||||
|
||||
} // namespace LibAudioOut
|
||||
|
||||
namespace LibVoiceQoS {
|
||||
|
||||
LIB_VERSION("VoiceQoS", 1, "VoiceQoS", 0, 0);
|
||||
@@ -22,6 +38,7 @@ LIB_DEFINE(InitAudio_1_VoiceQoS)
|
||||
|
||||
LIB_DEFINE(InitAudio_1)
|
||||
{
|
||||
LibAudioOut::InitAudio_1_AudioOut(s);
|
||||
LibVoiceQoS::InitAudio_1_VoiceQoS(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Kyty/Core/Common.h"
|
||||
#include "Kyty/Core/DbgAssert.h"
|
||||
#include "Kyty/Core/LinkList.h"
|
||||
#include "Kyty/Core/MSpace.h"
|
||||
#include "Kyty/Core/Singleton.h"
|
||||
#include "Kyty/Core/String.h"
|
||||
|
||||
@@ -59,21 +60,20 @@ static KYTY_SYSV_ABI int atexit(void (*func)())
|
||||
return 0;
|
||||
}
|
||||
|
||||
static KYTY_SYSV_ABI int printf(VA_ARGS)
|
||||
static KYTY_SYSV_ABI int libc_printf(VA_ARGS)
|
||||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
|
||||
VA_CONTEXT(ctx);
|
||||
VA_CONTEXT(ctx); // NOLINT(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
|
||||
|
||||
PRINT_NAME();
|
||||
|
||||
return GetPrintFuncV()(&ctx);
|
||||
return GetPrintfCtxFunc()(&ctx);
|
||||
}
|
||||
|
||||
static KYTY_SYSV_ABI int puts(const char* s)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
return GetPrintFunc()("%s\n", s);
|
||||
return GetPrintfStdFunc()("%s\n", s);
|
||||
}
|
||||
|
||||
static KYTY_SYSV_ABI void catchReturnFromMain(int status)
|
||||
@@ -161,7 +161,16 @@ int KYTY_SYSV_ABI vprintf(const char* str, VaList* c)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
return GetVPrintFunc()(str, c);
|
||||
return GetVprintfFunc()(str, c);
|
||||
}
|
||||
|
||||
static KYTY_SYSV_ABI int snprintf(VA_ARGS)
|
||||
{
|
||||
VA_CONTEXT(ctx); // NOLINT(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
|
||||
|
||||
PRINT_NAME();
|
||||
|
||||
return GetSnrintfCtxFunc()(&ctx);
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI fflush(FILE* stream)
|
||||
@@ -180,6 +189,49 @@ void* KYTY_SYSV_ABI memset(void* s, int c, size_t n)
|
||||
return ::memset(s, c, n);
|
||||
}
|
||||
|
||||
void* KYTY_SYSV_ABI LibcMspaceCreate(const char* name, void* base, size_t capacity, uint32_t flag)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\t name = %s\n", name);
|
||||
printf("\t base = %016" PRIx64 "\n", reinterpret_cast<uint64_t>(base));
|
||||
printf("\t capacity = %016" PRIx64 "\n", capacity);
|
||||
printf("\t flag = %u\n", flag);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(flag != 0 && flag != 1);
|
||||
EXIT_NOT_IMPLEMENTED(name == nullptr);
|
||||
EXIT_NOT_IMPLEMENTED(base == nullptr);
|
||||
EXIT_NOT_IMPLEMENTED(capacity == 0);
|
||||
|
||||
bool thread_safe = true;
|
||||
|
||||
if (flag == 1)
|
||||
{
|
||||
thread_safe = false;
|
||||
}
|
||||
|
||||
auto* msp = Core::MSpaceCreate(name, base, capacity, thread_safe, nullptr);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(msp == nullptr);
|
||||
|
||||
return msp;
|
||||
}
|
||||
|
||||
void* KYTY_SYSV_ABI LibcMspaceMalloc(void* msp, size_t size)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\t size = %016" PRIx64 "\n", size);
|
||||
|
||||
auto* buf = Core::MSpaceMalloc(msp, size);
|
||||
|
||||
printf("\t buf = %016" PRIx64 "\n", reinterpret_cast<uint64_t>(buf));
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(buf == nullptr);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
LIB_DEFINE(InitLibcInternal_1)
|
||||
{
|
||||
LibcInternalExt::InitLibcInternalExt_1(s);
|
||||
@@ -190,8 +242,13 @@ LIB_DEFINE(InitLibcInternal_1)
|
||||
LIB_FUNC("GMpvxPFW924", LibcInternal::vprintf);
|
||||
LIB_FUNC("MUjC4lbHrK4", LibcInternal::fflush);
|
||||
LIB_FUNC("8zTFvBIAIN8", LibcInternal::memset);
|
||||
LIB_FUNC("eLdDw6l0-bU", LibcInternal::snprintf);
|
||||
|
||||
LIB_FUNC("tsvEmnenz48", LibC::cxa_atexit);
|
||||
LIB_FUNC("H2e8t5ScQGc", LibC::cxa_finalize);
|
||||
|
||||
LIB_FUNC("-hn1tcVHq5Q", LibcInternal::LibcMspaceCreate);
|
||||
LIB_FUNC("OJjm-QOIHlI", LibcInternal::LibcMspaceMalloc);
|
||||
}
|
||||
|
||||
} // namespace LibcInternal
|
||||
@@ -200,6 +257,8 @@ LIB_USING(LibC);
|
||||
|
||||
LIB_DEFINE(InitLibC_1)
|
||||
{
|
||||
EXIT("deprecated\n");
|
||||
|
||||
LibcInternal::InitLibcInternal_1(s);
|
||||
|
||||
LIB_OBJECT("P330P3dFF68", &LibC::g_need_flag);
|
||||
@@ -207,7 +266,7 @@ LIB_DEFINE(InitLibC_1)
|
||||
LIB_FUNC("uMei1W9uyNo", LibC::exit);
|
||||
LIB_FUNC("bzQExy189ZI", LibC::init_env);
|
||||
LIB_FUNC("8G2LB+A3rzg", LibC::atexit);
|
||||
LIB_FUNC("hcuQgD53UxM", LibC::printf);
|
||||
LIB_FUNC("hcuQgD53UxM", LibC::libc_printf);
|
||||
LIB_FUNC("YQ0navp+YIc", LibC::puts);
|
||||
LIB_FUNC("XKRegsFpEpk", LibC::catchReturnFromMain);
|
||||
LIB_FUNC("tsvEmnenz48", LibC::cxa_atexit);
|
||||
|
||||
@@ -410,6 +410,13 @@ int KYTY_SYSV_ABI KernelIsNeoMode()
|
||||
return (Config::IsNeo() ? 1 : 0);
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI clock_gettime(int clock_id, LibKernel::KernelTimespec* time)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
return POSIX_CALL(LibKernel::KernelClockGettime(clock_id, time));
|
||||
}
|
||||
|
||||
} // namespace LibKernel
|
||||
|
||||
namespace Posix {
|
||||
@@ -423,9 +430,17 @@ int KYTY_SYSV_ABI clock_gettime(int clock_id, LibKernel::KernelTimespec* time)
|
||||
return POSIX_CALL(LibKernel::KernelClockGettime(clock_id, time));
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI nanosleep(const LibKernel::KernelTimespec* rqtp, LibKernel::KernelTimespec* rmtp)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
return POSIX_CALL(LibKernel::KernelNanosleep(rqtp, rmtp));
|
||||
}
|
||||
|
||||
LIB_DEFINE(InitLibKernel_1_Posix)
|
||||
{
|
||||
LIB_FUNC("lLMT9vJAck0", clock_gettime);
|
||||
LIB_FUNC("yS8U2TGCe1A", nanosleep);
|
||||
|
||||
LIB_FUNC("7H0iTOciTLo", Posix::pthread_mutex_lock);
|
||||
LIB_FUNC("2Z+PpY6CaJg", Posix::pthread_mutex_unlock);
|
||||
@@ -543,6 +558,7 @@ LIB_DEFINE(InitLibKernel_1_Pthread)
|
||||
LIB_FUNC("WKAXJ4XBPQ4", LibKernel::PthreadCondWait);
|
||||
LIB_FUNC("JGgj7Uvrl+A", LibKernel::PthreadCondBroadcast);
|
||||
LIB_FUNC("BmMjYxmew1w", LibKernel::PthreadCondTimedwait);
|
||||
LIB_FUNC("m5-2bsNfv7s", LibKernel::PthreadCondattrInit);
|
||||
|
||||
LIB_FUNC("QBi7HCK03hw", LibKernel::KernelClockGettime);
|
||||
LIB_FUNC("ejekcaNQNq0", LibKernel::KernelGettimeofday);
|
||||
@@ -588,6 +604,7 @@ LIB_DEFINE(InitLibKernel_1)
|
||||
LIB_FUNC("WslcK1FQcGI", LibKernel::KernelIsNeoMode);
|
||||
LIB_FUNC("9BcDykPmo1I", LibKernel::get_error_addr);
|
||||
LIB_FUNC("6xVpy0Fdq+I", LibKernel::sigprocmask);
|
||||
LIB_FUNC("lLMT9vJAck0", LibKernel::clock_gettime);
|
||||
|
||||
LIB_FUNC("1jfXLRVzisc", LibKernel::KernelUsleep);
|
||||
LIB_FUNC("rNhWz+lvOMU", LibKernel::KernelSetThreadDtors);
|
||||
|
||||
@@ -137,6 +137,19 @@ LIB_DEFINE(InitNet_1_NpManager)
|
||||
|
||||
} // namespace LibNpManager
|
||||
|
||||
namespace LibNpManagerForToolkit {
|
||||
|
||||
LIB_VERSION("NpManagerForToolkit", 1, "NpManager", 1, 1);
|
||||
|
||||
namespace NpManagerForToolkit = Network::NpManagerForToolkit;
|
||||
|
||||
LIB_DEFINE(InitNet_1_NpManagerForToolkit)
|
||||
{
|
||||
LIB_FUNC("0c7HbXRKUt4", NpManagerForToolkit::NpRegisterStateCallbackForToolkit);
|
||||
}
|
||||
|
||||
} // namespace LibNpManagerForToolkit
|
||||
|
||||
namespace LibNpTrophy {
|
||||
|
||||
LIB_VERSION("NpTrophy", 1, "NpTrophy", 1, 1);
|
||||
@@ -170,6 +183,7 @@ LIB_DEFINE(InitNet_1)
|
||||
LibHttp::InitNet_1_Http(s);
|
||||
LibNetCtl::InitNet_1_NetCtl(s);
|
||||
LibNpManager::InitNet_1_NpManager(s);
|
||||
LibNpManagerForToolkit::InitNet_1_NpManagerForToolkit(s);
|
||||
LibNpTrophy::InitNet_1_NpTrophy(s);
|
||||
LibNpWebApi::InitNet_1_NpWebApi(s);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "Kyty/Core/Common.h"
|
||||
#include "Kyty/Core/DbgAssert.h"
|
||||
#include "Kyty/Core/String.h"
|
||||
|
||||
#include "Emulator/Common.h"
|
||||
@@ -13,6 +15,37 @@ LIB_VERSION("SaveData", 1, "SaveData", 1, 1);
|
||||
|
||||
namespace SaveData {
|
||||
|
||||
struct SceSaveDataDirName
|
||||
{
|
||||
char data[32];
|
||||
};
|
||||
|
||||
struct SaveDataMountPoint
|
||||
{
|
||||
char data[16];
|
||||
};
|
||||
|
||||
struct SaveDataMount2
|
||||
{
|
||||
int user_id;
|
||||
int pad;
|
||||
const SceSaveDataDirName* dir_name;
|
||||
uint64_t blocks;
|
||||
uint32_t mount_mode;
|
||||
uint8_t reserved[32];
|
||||
int pad2;
|
||||
};
|
||||
|
||||
struct SaveDataMountResult
|
||||
{
|
||||
SaveDataMountPoint mount_point;
|
||||
uint64_t required_blocks;
|
||||
uint32_t unused;
|
||||
uint32_t mount_status;
|
||||
uint8_t reserved[28];
|
||||
int pad;
|
||||
};
|
||||
|
||||
int KYTY_SYSV_ABI SaveDataInitialize(const void* /*init*/)
|
||||
{
|
||||
PRINT_NAME();
|
||||
@@ -40,6 +73,34 @@ int KYTY_SYSV_ABI SaveDataInitialize3(const void* /*init*/)
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI SaveDataMount2(const SaveDataMount2* mount, SaveDataMountResult* mount_result)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(mount == nullptr);
|
||||
EXIT_NOT_IMPLEMENTED(mount_result == nullptr);
|
||||
|
||||
printf("\t user_id = %d\n", mount->user_id);
|
||||
printf("\t dir_name = %s\n", mount->dir_name->data);
|
||||
printf("\t blocks = %" PRIu64 "\n", mount->blocks);
|
||||
printf("\t mount_mode = %" PRIu32 "\n", mount->mount_mode);
|
||||
|
||||
if (mount->mount_mode == 1)
|
||||
{
|
||||
return SAVE_DATA_ERROR_NOT_FOUND;
|
||||
} else // NOLINT
|
||||
{
|
||||
EXIT("unknown mount mode: %u", mount->mount_mode);
|
||||
}
|
||||
|
||||
strcpy(mount_result->mount_point.data, "/savedata0");
|
||||
|
||||
mount_result->required_blocks = 0;
|
||||
mount_result->mount_status = 1;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
} // namespace SaveData
|
||||
|
||||
LIB_DEFINE(InitSaveData_1)
|
||||
@@ -47,6 +108,7 @@ LIB_DEFINE(InitSaveData_1)
|
||||
LIB_FUNC("ZkZhskCPXFw", SaveData::SaveDataInitialize);
|
||||
LIB_FUNC("l1NmDeDpNGU", SaveData::SaveDataInitialize2);
|
||||
LIB_FUNC("TywrFKCoLGY", SaveData::SaveDataInitialize3);
|
||||
LIB_FUNC("0z45PIH+SNI", SaveData::SaveDataMount2);
|
||||
}
|
||||
|
||||
} // namespace Kyty::Libs
|
||||
|
||||
@@ -18,7 +18,7 @@ static KYTY_SYSV_ABI int SysmoduleLoadModule(uint16_t id)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\tid = %d\n", static_cast<int>(id));
|
||||
printf("\t id = %d\n", static_cast<int>(id));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ static KYTY_SYSV_ABI int SysmoduleUnloadModule(uint16_t id)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\tid = %d\n", static_cast<int>(id));
|
||||
printf("\t id = %d\n", static_cast<int>(id));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ static KYTY_SYSV_ABI int SysmoduleLoadModuleInternalWithArg(uint16_t id, int arg
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\tid = %d\n", static_cast<int>(id));
|
||||
printf("\t id = %d\n", static_cast<int>(id));
|
||||
|
||||
EXIT_IF(arg1 != 0);
|
||||
EXIT_IF(arg2 != 0);
|
||||
@@ -48,6 +48,15 @@ static KYTY_SYSV_ABI int SysmoduleLoadModuleInternalWithArg(uint16_t id, int arg
|
||||
return 0;
|
||||
}
|
||||
|
||||
static KYTY_SYSV_ABI int SysmoduleIsLoaded(uint16_t id)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
printf("\t id = %d\n", static_cast<int>(id));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Sysmodule
|
||||
|
||||
LIB_DEFINE(InitSysmodule_1)
|
||||
@@ -55,6 +64,7 @@ LIB_DEFINE(InitSysmodule_1)
|
||||
LIB_FUNC("eR2bZFAAU0Q", Sysmodule::SysmoduleUnloadModule);
|
||||
LIB_FUNC("hHrGoGoNf+s", Sysmodule::SysmoduleLoadModuleInternalWithArg);
|
||||
LIB_FUNC("g8cM39EUZ6o", Sysmodule::SysmoduleLoadModule);
|
||||
LIB_FUNC("fMP5NHUOaMk", Sysmodule::SysmoduleIsLoaded);
|
||||
}
|
||||
|
||||
} // namespace Kyty::Libs
|
||||
|
||||
@@ -14,6 +14,11 @@ LIB_VERSION("UserService", 1, "UserService", 1, 1);
|
||||
|
||||
namespace UserService {
|
||||
|
||||
struct UserServiceLoginUserIdList
|
||||
{
|
||||
int user_id[4];
|
||||
};
|
||||
|
||||
static KYTY_SYSV_ABI int UserServiceInitialize(const void* /*params*/)
|
||||
{
|
||||
PRINT_NAME();
|
||||
@@ -41,6 +46,20 @@ static KYTY_SYSV_ABI int UserServiceGetEvent(void* event)
|
||||
return USER_SERVICE_ERROR_NO_EVENT;
|
||||
}
|
||||
|
||||
static KYTY_SYSV_ABI int UserServiceGetLoginUserIdList(UserServiceLoginUserIdList* user_id_list)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(user_id_list == nullptr);
|
||||
|
||||
user_id_list->user_id[0] = 1;
|
||||
user_id_list->user_id[1] = -1;
|
||||
user_id_list->user_id[2] = -1;
|
||||
user_id_list->user_id[3] = -1;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
} // namespace UserService
|
||||
|
||||
LIB_DEFINE(InitUserService_1)
|
||||
@@ -48,6 +67,7 @@ LIB_DEFINE(InitUserService_1)
|
||||
LIB_FUNC("j3YMu1MVNNo", UserService::UserServiceInitialize);
|
||||
LIB_FUNC("CdWp0oHWGr0", UserService::UserServiceGetInitialUser);
|
||||
LIB_FUNC("yH17Q6NWtVg", UserService::UserServiceGetEvent);
|
||||
LIB_FUNC("fPhymKNvK-A", UserService::UserServiceGetLoginUserIdList);
|
||||
}
|
||||
|
||||
} // namespace Kyty::Libs
|
||||
|
||||
@@ -13,7 +13,7 @@ LIB_DEFINE(InitDebug_1);
|
||||
LIB_DEFINE(InitDialog_1);
|
||||
LIB_DEFINE(InitDiscMap_1);
|
||||
LIB_DEFINE(InitGraphicsDriver_1);
|
||||
LIB_DEFINE(InitLibC_1);
|
||||
// LIB_DEFINE(InitLibC_1);
|
||||
LIB_DEFINE(InitLibKernel_1);
|
||||
LIB_DEFINE(InitNet_1);
|
||||
LIB_DEFINE(InitPad_1);
|
||||
@@ -27,7 +27,7 @@ LIB_DEFINE(InitVideoOut_1);
|
||||
bool Init(const String& id, Loader::SymbolDatabase* s)
|
||||
{
|
||||
LIB_CHECK(U"libAudio_1", InitAudio_1);
|
||||
LIB_CHECK(U"libc_1", InitLibC_1);
|
||||
// LIB_CHECK(U"libc_1", InitLibC_1);
|
||||
LIB_CHECK(U"libc_internal_1", LibcInternal::InitLibcInternal_1);
|
||||
LIB_CHECK(U"libDebug_1", InitDebug_1);
|
||||
LIB_CHECK(U"libDialog_1", InitDialog_1);
|
||||
|
||||
@@ -506,7 +506,7 @@ static inline unsigned int _strnlen_s(const char* str, size_t maxsize)
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
int my_vprint(const char* format, VaList* va_list)
|
||||
static int kyty_printf_internal(bool sn, char* sn_s, size_t sn_n, const char* format, VaList* va_list)
|
||||
{
|
||||
Vector<char> buffer;
|
||||
|
||||
@@ -854,40 +854,64 @@ int my_vprint(const char* format, VaList* va_list)
|
||||
// termination
|
||||
out(static_cast<char>(0), &buffer, idx < maxlen ? idx : maxlen - 1U, maxlen);
|
||||
|
||||
printf(FG_BRIGHT_MAGENTA "%s" DEFAULT, buffer.GetDataConst());
|
||||
if (sn)
|
||||
{
|
||||
snprintf(sn_s, sn_n, "%s", buffer.GetDataConst());
|
||||
} else
|
||||
{
|
||||
printf(FG_BRIGHT_MAGENTA "%s" DEFAULT, buffer.GetDataConst());
|
||||
}
|
||||
|
||||
// return written chars without terminating \0
|
||||
return static_cast<int>(idx);
|
||||
}
|
||||
|
||||
int my_print_v(VaContext* ctx)
|
||||
static int kyty_vprintf(const char* format, VaList* va_list)
|
||||
{
|
||||
return kyty_printf_internal(false, nullptr, 0, format, va_list);
|
||||
}
|
||||
|
||||
static int kyty_printf_ctx(VaContext* ctx)
|
||||
{
|
||||
const char* format = VaArg_ptr<const char>(&ctx->va_list);
|
||||
|
||||
return my_vprint(format, &ctx->va_list);
|
||||
return kyty_printf_internal(false, nullptr, 0, format, &ctx->va_list);
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI my_print2(VA_ARGS)
|
||||
static int kyty_snprintf_ctx(VaContext* ctx)
|
||||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
|
||||
VA_CONTEXT(ctx);
|
||||
char* s = VaArg_ptr<char>(&ctx->va_list);
|
||||
size_t n = VaArg_size_t(&ctx->va_list);
|
||||
const char* format = VaArg_ptr<const char>(&ctx->va_list);
|
||||
|
||||
return my_print_v(&ctx);
|
||||
return kyty_printf_internal(true, s, n, format, &ctx->va_list);
|
||||
}
|
||||
|
||||
libc_print_func_t GetPrintFunc()
|
||||
static int KYTY_SYSV_ABI kyty_printf_std(VA_ARGS)
|
||||
{
|
||||
return reinterpret_cast<libc_print_func_t>(my_print2);
|
||||
VA_CONTEXT(ctx); // NOLINT(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
|
||||
|
||||
return kyty_printf_ctx(&ctx);
|
||||
}
|
||||
|
||||
libc_print_v_func_t GetPrintFuncV()
|
||||
libc_printf_std_func_t GetPrintfStdFunc()
|
||||
{
|
||||
return my_print_v;
|
||||
return reinterpret_cast<libc_printf_std_func_t>(kyty_printf_std);
|
||||
}
|
||||
|
||||
libc_vprint_func_t GetVPrintFunc()
|
||||
libc_printf_ctx_func_t GetPrintfCtxFunc()
|
||||
{
|
||||
return my_vprint;
|
||||
return kyty_printf_ctx;
|
||||
}
|
||||
|
||||
libc_snprintf_ctx_func_t GetSnrintfCtxFunc()
|
||||
{
|
||||
return kyty_snprintf_ctx;
|
||||
}
|
||||
|
||||
libc_vprintf_func_t GetVprintfFunc()
|
||||
{
|
||||
return kyty_vprintf;
|
||||
}
|
||||
|
||||
} // namespace Kyty::Libs
|
||||
|
||||
@@ -17,6 +17,29 @@ namespace Kyty::Libs::Network {
|
||||
class Network
|
||||
{
|
||||
public:
|
||||
class Id
|
||||
{
|
||||
public:
|
||||
explicit Id(int id): m_id(id - 1) {}
|
||||
[[nodiscard]] int ToInt() const { return m_id + 1; }
|
||||
[[nodiscard]] bool IsValid() const { return m_id >= 0; }
|
||||
|
||||
friend class Network;
|
||||
|
||||
private:
|
||||
Id() = default;
|
||||
static Id Invalid() { return Id(); }
|
||||
static Id Create(int net_id)
|
||||
{
|
||||
Id r;
|
||||
r.m_id = net_id;
|
||||
return r;
|
||||
}
|
||||
[[nodiscard]] int GetId() const { return m_id; }
|
||||
|
||||
int m_id = -1;
|
||||
};
|
||||
|
||||
Network() = default;
|
||||
virtual ~Network() = default;
|
||||
|
||||
@@ -25,14 +48,14 @@ public:
|
||||
int PoolCreate(const char* name, int size);
|
||||
bool PoolDestroy(int memid);
|
||||
|
||||
int SslInit(uint64_t pool_size);
|
||||
bool SslTerm(int ssl_ctx_id);
|
||||
Id SslInit(uint64_t pool_size);
|
||||
bool SslTerm(Id ssl_ctx_id);
|
||||
|
||||
int HttpInit(int memid, int ssl_ctx_id, uint64_t pool_size);
|
||||
bool HttpTerm(int http_ctx_id);
|
||||
int HttpCreateTemplate(int http_ctx_id, const char* user_agent, int http_ver, bool is_auto_proxy_conf);
|
||||
bool HttpDeleteTemplate(int tmpl_id);
|
||||
bool HttpValid(int http_ctx_id);
|
||||
Id HttpInit(int memid, Id ssl_ctx_id, uint64_t pool_size);
|
||||
bool HttpTerm(Id http_ctx_id);
|
||||
Id HttpCreateTemplate(Id http_ctx_id, const char* user_agent, int http_ver, bool is_auto_proxy_conf);
|
||||
bool HttpDeleteTemplate(Id tmpl_id);
|
||||
bool HttpValid(Id http_ctx_id);
|
||||
|
||||
private:
|
||||
struct Pool
|
||||
@@ -122,7 +145,7 @@ bool Network::PoolDestroy(int memid)
|
||||
return false;
|
||||
}
|
||||
|
||||
int Network::SslInit(uint64_t pool_size)
|
||||
Network::Id Network::SslInit(uint64_t pool_size)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
@@ -133,20 +156,20 @@ int Network::SslInit(uint64_t pool_size)
|
||||
m_ssl[id].used = true;
|
||||
m_ssl[id].size = pool_size;
|
||||
|
||||
return id;
|
||||
return Id::Create(id);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return Id::Invalid();
|
||||
}
|
||||
|
||||
bool Network::SslTerm(int ssl_ctx_id)
|
||||
bool Network::SslTerm(Id ssl_ctx_id)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
if (ssl_ctx_id >= 0 && ssl_ctx_id < SSL_MAX && m_ssl[ssl_ctx_id].used)
|
||||
if (ssl_ctx_id.GetId() >= 0 && ssl_ctx_id.GetId() < SSL_MAX && m_ssl[ssl_ctx_id.GetId()].used)
|
||||
{
|
||||
m_ssl[ssl_ctx_id].used = false;
|
||||
m_ssl[ssl_ctx_id.GetId()].used = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -154,11 +177,12 @@ bool Network::SslTerm(int ssl_ctx_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
int Network::HttpInit(int memid, int ssl_ctx_id, uint64_t pool_size)
|
||||
Network::Id Network::HttpInit(int memid, Id ssl_ctx_id, uint64_t pool_size)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
if (ssl_ctx_id >= 0 && ssl_ctx_id < SSL_MAX && m_ssl[ssl_ctx_id].used && memid >= 0 && memid < POOLS_MAX && m_pools[memid].used)
|
||||
if (ssl_ctx_id.GetId() >= 0 && ssl_ctx_id.GetId() < SSL_MAX && m_ssl[ssl_ctx_id.GetId()].used && memid >= 0 && memid < POOLS_MAX &&
|
||||
m_pools[memid].used)
|
||||
{
|
||||
for (int id = 0; id < HTTP_MAX; id++)
|
||||
{
|
||||
@@ -166,31 +190,31 @@ int Network::HttpInit(int memid, int ssl_ctx_id, uint64_t pool_size)
|
||||
{
|
||||
m_http[id].used = true;
|
||||
m_http[id].size = pool_size;
|
||||
m_http[id].ssl_ctx_id = ssl_ctx_id;
|
||||
m_http[id].ssl_ctx_id = ssl_ctx_id.GetId();
|
||||
m_http[id].memid = memid;
|
||||
|
||||
return id;
|
||||
return Id::Create(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return Id::Invalid();
|
||||
}
|
||||
|
||||
bool Network::HttpValid(int http_ctx_id)
|
||||
bool Network::HttpValid(Id http_ctx_id)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
return (http_ctx_id >= 0 && http_ctx_id < HTTP_MAX && m_http[http_ctx_id].used);
|
||||
return (http_ctx_id.GetId() >= 0 && http_ctx_id.GetId() < HTTP_MAX && m_http[http_ctx_id.GetId()].used);
|
||||
}
|
||||
|
||||
bool Network::HttpTerm(int http_ctx_id)
|
||||
bool Network::HttpTerm(Id http_ctx_id)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
if (HttpValid(http_ctx_id))
|
||||
{
|
||||
m_http[http_ctx_id].used = false;
|
||||
m_http[http_ctx_id.GetId()].used = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -198,18 +222,18 @@ bool Network::HttpTerm(int http_ctx_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
int Network::HttpCreateTemplate(int http_ctx_id, const char* user_agent, int http_ver, bool is_auto_proxy_conf)
|
||||
Network::Id Network::HttpCreateTemplate(Id http_ctx_id, const char* user_agent, int http_ver, bool is_auto_proxy_conf)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
if (http_ctx_id >= 0 && http_ctx_id < HTTP_MAX && m_http[http_ctx_id].used)
|
||||
if (http_ctx_id.GetId() >= 0 && http_ctx_id.GetId() < HTTP_MAX && m_http[http_ctx_id.GetId()].used)
|
||||
{
|
||||
HttpTemplate tn {};
|
||||
tn.used = true;
|
||||
tn.http_ver = http_ver;
|
||||
tn.user_agent = String::FromUtf8(user_agent);
|
||||
tn.is_auto_proxy_conf = is_auto_proxy_conf;
|
||||
tn.http_ctx_id = http_ctx_id;
|
||||
tn.http_ctx_id = http_ctx_id.GetId();
|
||||
|
||||
int index = 0;
|
||||
for (auto& t: m_templates)
|
||||
@@ -217,26 +241,26 @@ int Network::HttpCreateTemplate(int http_ctx_id, const char* user_agent, int htt
|
||||
if (!t.used)
|
||||
{
|
||||
t = tn;
|
||||
return index;
|
||||
return Id::Create(index);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
m_templates.Add(tn);
|
||||
|
||||
return index;
|
||||
return Id::Create(index);
|
||||
}
|
||||
|
||||
return -1;
|
||||
return Id::Invalid();
|
||||
}
|
||||
|
||||
bool Network::HttpDeleteTemplate(int tmpl_id)
|
||||
bool Network::HttpDeleteTemplate(Id tmpl_id)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
if (m_templates.IndexValid(tmpl_id) && m_templates.At(tmpl_id).used)
|
||||
if (m_templates.IndexValid(tmpl_id.GetId()) && m_templates.At(tmpl_id.GetId()).used)
|
||||
{
|
||||
m_templates[tmpl_id].used = false;
|
||||
m_templates[tmpl_id.GetId()].used = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -364,14 +388,14 @@ int KYTY_SYSV_ABI SslInit(uint64_t pool_size)
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(pool_size == 0);
|
||||
|
||||
int id = g_net->SslInit(pool_size);
|
||||
auto id = g_net->SslInit(pool_size);
|
||||
|
||||
if (id < 0)
|
||||
if (!id.IsValid())
|
||||
{
|
||||
return SSL_ERROR_OUT_OF_SIZE;
|
||||
}
|
||||
|
||||
return id + 1;
|
||||
return id.ToInt();
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI SslTerm(int ssl_ctx_id)
|
||||
@@ -380,7 +404,7 @@ int KYTY_SYSV_ABI SslTerm(int ssl_ctx_id)
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (!g_net->SslTerm(ssl_ctx_id - 1))
|
||||
if (!g_net->SslTerm(Network::Id(ssl_ctx_id)))
|
||||
{
|
||||
return SSL_ERROR_INVALID_ID;
|
||||
}
|
||||
@@ -406,14 +430,14 @@ int KYTY_SYSV_ABI HttpInit(int memid, int ssl_ctx_id, uint64_t pool_size)
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(pool_size == 0);
|
||||
|
||||
int id = g_net->HttpInit(memid, ssl_ctx_id - 1, pool_size);
|
||||
auto id = g_net->HttpInit(memid, Network::Id(ssl_ctx_id), pool_size);
|
||||
|
||||
if (id < 0)
|
||||
if (!id.IsValid())
|
||||
{
|
||||
return HTTP_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return id + 1;
|
||||
return id.ToInt();
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpTerm(int http_ctx_id)
|
||||
@@ -422,7 +446,7 @@ int KYTY_SYSV_ABI HttpTerm(int http_ctx_id)
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (!g_net->HttpTerm(http_ctx_id - 1))
|
||||
if (!g_net->HttpTerm(Network::Id(http_ctx_id)))
|
||||
{
|
||||
return HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
@@ -441,14 +465,14 @@ int KYTY_SYSV_ABI HttpCreateTemplate(int http_ctx_id, const char* user_agent, in
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
int id = g_net->HttpCreateTemplate(http_ctx_id, user_agent, http_ver, is_auto_proxy_conf != 0);
|
||||
auto id = g_net->HttpCreateTemplate(Network::Id(http_ctx_id), user_agent, http_ver, is_auto_proxy_conf != 0);
|
||||
|
||||
if (id < 0)
|
||||
if (!id.IsValid())
|
||||
{
|
||||
return HTTP_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return id + 1;
|
||||
return id.ToInt();
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpDeleteTemplate(int tmpl_id)
|
||||
@@ -457,7 +481,7 @@ int KYTY_SYSV_ABI HttpDeleteTemplate(int tmpl_id)
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (!g_net->HttpDeleteTemplate(tmpl_id - 1))
|
||||
if (!g_net->HttpDeleteTemplate(Network::Id(tmpl_id)))
|
||||
{
|
||||
return HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
@@ -689,6 +713,19 @@ int KYTY_SYSV_ABI NpRegisterPlusEventCallback(void* /*callback*/, void* /*userda
|
||||
|
||||
} // namespace NpManager
|
||||
|
||||
namespace NpManagerForToolkit {
|
||||
|
||||
LIB_NAME("NpManagerForToolkit", "NpManager");
|
||||
|
||||
int KYTY_SYSV_ABI NpRegisterStateCallbackForToolkit(void* /*callback*/, void* /*userdata*/)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
} // namespace NpManagerForToolkit
|
||||
|
||||
namespace NpTrophy {
|
||||
|
||||
LIB_NAME("NpTrophy", "NpTrophy");
|
||||
@@ -719,7 +756,7 @@ int KYTY_SYSV_ABI NpWebApiInitialize(int http_ctx_id, size_t pool_size)
|
||||
printf("\t http_ctx_id = %d\n", http_ctx_id);
|
||||
printf("\t pool_size = %" PRIu64 "\n", pool_size);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(!g_net->HttpValid(http_ctx_id - 1));
|
||||
EXIT_NOT_IMPLEMENTED(!g_net->HttpValid(Network::Id(http_ctx_id)));
|
||||
|
||||
static int id = 0;
|
||||
|
||||
|
||||
@@ -675,7 +675,8 @@ Program* RuntimeLinker::LoadProgram(const String& elf_name)
|
||||
}
|
||||
|
||||
if (elf_name.FilenameWithoutExtension().EndsWith(U"libc") || elf_name.FilenameWithoutExtension().EndsWith(U"Fios2") ||
|
||||
elf_name.FilenameWithoutExtension().EndsWith(U"Fios2_debug"))
|
||||
elf_name.FilenameWithoutExtension().EndsWith(U"Fios2_debug") || elf_name.FilenameWithoutExtension().EndsWith(U"NpToolkit") ||
|
||||
elf_name.FilenameWithoutExtension().EndsWith(U"NpToolkit2"))
|
||||
{
|
||||
program->fail_if_global_not_resolved = false;
|
||||
}
|
||||
@@ -701,6 +702,23 @@ void RuntimeLinker::SaveMainProgram(const String& elf_name)
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeLinker::SaveProgram(Program* program, const String& elf_name)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(!Core::Thread::IsMainThread());
|
||||
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
if (auto index = m_programs.Find(program); m_programs.IndexValid(index))
|
||||
{
|
||||
EXIT_IF(m_programs.At(index)->elf == nullptr);
|
||||
|
||||
m_programs.At(index)->elf->Save(elf_name);
|
||||
} else
|
||||
{
|
||||
EXIT("program not found");
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeLinker::Clear()
|
||||
{
|
||||
// EXIT_NOT_IMPLEMENTED(!Core::Thread::IsMainThread());
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
#include "Emulator/Jit.h"
|
||||
#include "Emulator/Profiler.h"
|
||||
|
||||
#include <new>
|
||||
#include "cpuinfo.h"
|
||||
|
||||
//#include <atomic>
|
||||
//#include <new>
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
//#define NTDDI_VERSION 0x0A000005
|
||||
@@ -52,6 +55,12 @@ SystemInfo GetSystemInfo()
|
||||
ret.ProcessorLevel = system_info.wProcessorLevel;
|
||||
ret.ProcessorRevision = system_info.wProcessorRevision;
|
||||
|
||||
const auto* p = cpuinfo_get_package(0);
|
||||
|
||||
EXIT_IF(p == nullptr);
|
||||
|
||||
ret.ProcessorName = String::FromUtf8(p->name);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -280,6 +289,11 @@ static VirtualMemory::Mode get_protection_flag(DWORD mode)
|
||||
}
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
cpuinfo_initialize();
|
||||
}
|
||||
|
||||
uint64_t Alloc(uint64_t address, uint64_t size, Mode mode)
|
||||
{
|
||||
auto ptr = reinterpret_cast<uintptr_t>(VirtualAlloc(reinterpret_cast<LPVOID>(static_cast<uintptr_t>(address)), size,
|
||||
|
||||
Reference in New Issue
Block a user