mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-27 23:47:03 +02:00
implement stubs for i2c + gpio
Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
b515dbd5ce
commit
6337aff0c4
9 changed files with 157 additions and 5 deletions
|
|
@ -1121,6 +1121,10 @@ add_library(core STATIC
|
||||||
hle/service/vi/vi_types.h
|
hle/service/vi/vi_types.h
|
||||||
hle/service/vi/vsync_manager.cpp
|
hle/service/vi/vsync_manager.cpp
|
||||||
hle/service/vi/vsync_manager.h
|
hle/service/vi/vsync_manager.h
|
||||||
|
hle/service/gpio/gpio.cpp
|
||||||
|
hle/service/gpio/gpio.h
|
||||||
|
hle/service/i2c/i2c.cpp
|
||||||
|
hle/service/i2c/i2c.h
|
||||||
internal_network/emu_net_state.cpp
|
internal_network/emu_net_state.cpp
|
||||||
internal_network/emu_net_state.h
|
internal_network/emu_net_state.h
|
||||||
internal_network/network.cpp
|
internal_network/network.cpp
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
@ -21,6 +24,7 @@ void LoopProcess(Core::System& system) {
|
||||||
"apm:am", std::make_shared<APM>(system, module, system.GetAPMController(), "apm:am"));
|
"apm:am", std::make_shared<APM>(system, module, system.GetAPMController(), "apm:am"));
|
||||||
server_manager->RegisterNamedService(
|
server_manager->RegisterNamedService(
|
||||||
"apm:sys", std::make_shared<APM_Sys>(system, system.GetAPMController()));
|
"apm:sys", std::make_shared<APM_Sys>(system, system.GetAPMController()));
|
||||||
|
|
||||||
ServerManager::RunServer(std::move(server_manager));
|
ServerManager::RunServer(std::move(server_manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
33
src/core/hle/service/gpio/gpio.cpp
Normal file
33
src/core/hle/service/gpio/gpio.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "core/core.h"
|
||||||
|
#include "core/hle/service/i2c/i2c.h"
|
||||||
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Service::GPIO {
|
||||||
|
|
||||||
|
class GPIO final : public ServiceFramework<GPIO> {
|
||||||
|
public:
|
||||||
|
explicit GPIO(Core::System& system_)
|
||||||
|
: ServiceFramework{system_, "gpio"}
|
||||||
|
{
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, nullptr, "Cmd0"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
~GPIO() override = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
void LoopProcess(Core::System& system) {
|
||||||
|
auto server_manager = std::make_unique<ServerManager>(system);
|
||||||
|
server_manager->RegisterNamedService("gpio", std::make_shared<GPIO>(system));
|
||||||
|
ServerManager::RunServer(std::move(server_manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Service::GPIO
|
||||||
15
src/core/hle/service/gpio/gpio.h
Normal file
15
src/core/hle/service/gpio/gpio.h
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Service::GPIO {
|
||||||
|
void LoopProcess(Core::System& system);
|
||||||
|
} // namespace Service::GPIO
|
||||||
33
src/core/hle/service/i2c/i2c.cpp
Normal file
33
src/core/hle/service/i2c/i2c.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "core/core.h"
|
||||||
|
#include "core/hle/service/i2c/i2c.h"
|
||||||
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Service::I2C {
|
||||||
|
|
||||||
|
class I2C final : public ServiceFramework<I2C> {
|
||||||
|
public:
|
||||||
|
explicit I2C(Core::System& system_)
|
||||||
|
: ServiceFramework{system_, "i2c"}
|
||||||
|
{
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, nullptr, "Cmd0"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
~I2C() override = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
void LoopProcess(Core::System& system) {
|
||||||
|
auto server_manager = std::make_unique<ServerManager>(system);
|
||||||
|
server_manager->RegisterNamedService("i2c", std::make_shared<I2C>(system));
|
||||||
|
ServerManager::RunServer(std::move(server_manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Service::I2C
|
||||||
15
src/core/hle/service/i2c/i2c.h
Normal file
15
src/core/hle/service/i2c/i2c.h
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Service::I2C {
|
||||||
|
void LoopProcess(Core::System& system);
|
||||||
|
} // namespace Service::I2C
|
||||||
|
|
@ -6,10 +6,12 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "common/common_funcs.h"
|
||||||
#include "common/device_power_state.h"
|
#include "common/device_power_state.h"
|
||||||
#include "common/logging.h"
|
#include "common/logging.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
#include "core/hle/service/kernel_helpers.h"
|
#include "core/hle/service/kernel_helpers.h"
|
||||||
#include "core/hle/service/ptm/psm.h"
|
#include "core/hle/service/ptm/psm.h"
|
||||||
|
|
@ -139,7 +141,7 @@ PSM::PSM(Core::System& system_) : ServiceFramework{system_, "psm"} {
|
||||||
{14, nullptr, "IsEnoughPowerSupplied"},
|
{14, nullptr, "IsEnoughPowerSupplied"},
|
||||||
{15, nullptr, "GetBatteryAgePercentage"},
|
{15, nullptr, "GetBatteryAgePercentage"},
|
||||||
{16, nullptr, "GetBatteryChargeInfoEvent"},
|
{16, nullptr, "GetBatteryChargeInfoEvent"},
|
||||||
{17, nullptr, "GetBatteryChargeInfoFields"},
|
{17, &PSM::GetBatteryChargeInfoFields, "GetBatteryChargeInfoFields"},
|
||||||
{18, nullptr, "GetBatteryChargeCalibratedEvent"},
|
{18, nullptr, "GetBatteryChargeCalibratedEvent"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
@ -187,4 +189,46 @@ void PSM::OpenSession(HLERequestContext& ctx) {
|
||||||
rb.PushIpcInterface<IPsmSession>(system);
|
rb.PushIpcInterface<IPsmSession>(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct BatteryChargeInfoFields {
|
||||||
|
u32 input_current_limit; //mA
|
||||||
|
u32 boost_mode_current_limit;
|
||||||
|
u32 fast_charge_current_limit;
|
||||||
|
u32 charge_voltage_limit;
|
||||||
|
u32 charger_type;
|
||||||
|
u8 hi2_mode;
|
||||||
|
u8 battery_charging;
|
||||||
|
INSERT_PADDING_BYTES_NOINIT(2);
|
||||||
|
u32 vdd50_state;
|
||||||
|
u32 temperature_celcius;
|
||||||
|
u32 battery_charge_percentage;
|
||||||
|
u32 battery_charge_milli_voltage;
|
||||||
|
u32 battery_age_percentage;
|
||||||
|
u32 usb_power_role;
|
||||||
|
u32 usb_charger_type;
|
||||||
|
u32 charger_input_voltage_limit;
|
||||||
|
u32 charger_input_current_limit;
|
||||||
|
u8 fast_battery_charging;
|
||||||
|
u8 controller_power_supply;
|
||||||
|
u8 otg_request;
|
||||||
|
INSERT_PADDING_BYTES_NOINIT(1);
|
||||||
|
INSERT_PADDING_BYTES_NOINIT(0x14); //[+17.0.0]
|
||||||
|
};
|
||||||
|
static_assert(sizeof(struct BatteryChargeInfoFields) == 0x54);
|
||||||
|
|
||||||
|
void PSM::GetBatteryChargeInfoFields(HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_PTM, "called");
|
||||||
|
Common::PowerStatus power_status = Common::GetPowerStatus();
|
||||||
|
|
||||||
|
BatteryChargeInfoFields r{};
|
||||||
|
r.battery_charge_percentage = power_status.percentage; //100%
|
||||||
|
r.battery_age_percentage = power_status.percentage; //100%
|
||||||
|
r.battery_charging = power_status.charging ? 1 : 0;
|
||||||
|
r.charger_type = u32(power_status.has_battery && power_status.charging
|
||||||
|
? ChargerType::RegularCharger : ChargerType::Unplugged);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.PushRaw<BatteryChargeInfoFields>(r);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Service::PTM
|
} // namespace Service::PTM
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
|
@ -22,10 +22,10 @@ private:
|
||||||
LowPowerCharger = 2,
|
LowPowerCharger = 2,
|
||||||
Unknown = 3,
|
Unknown = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
void GetBatteryChargePercentage(HLERequestContext& ctx);
|
void GetBatteryChargePercentage(HLERequestContext& ctx);
|
||||||
void GetChargerType(HLERequestContext& ctx);
|
void GetChargerType(HLERequestContext& ctx);
|
||||||
void OpenSession(HLERequestContext& ctx);
|
void OpenSession(HLERequestContext& ctx);
|
||||||
|
void GetBatteryChargeInfoFields(HLERequestContext& ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::PTM
|
} // namespace Service::PTM
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
|
|
@ -25,8 +25,10 @@
|
||||||
#include "core/hle/service/friend/friend.h"
|
#include "core/hle/service/friend/friend.h"
|
||||||
#include "core/hle/service/glue/glue.h"
|
#include "core/hle/service/glue/glue.h"
|
||||||
#include "core/hle/service/grc/grc.h"
|
#include "core/hle/service/grc/grc.h"
|
||||||
|
#include "core/hle/service/gpio/gpio.h"
|
||||||
#include "core/hle/service/hid/hid.h"
|
#include "core/hle/service/hid/hid.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
#include "core/hle/service/i2c/i2c.h"
|
||||||
#include "core/hle/service/jit/jit.h"
|
#include "core/hle/service/jit/jit.h"
|
||||||
#include "core/hle/service/lbl/lbl.h"
|
#include "core/hle/service/lbl/lbl.h"
|
||||||
#include "core/hle/service/ldn/ldn.h"
|
#include "core/hle/service/ldn/ldn.h"
|
||||||
|
|
@ -144,7 +146,9 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
|
||||||
{"ro", &RO::LoopProcess},
|
{"ro", &RO::LoopProcess},
|
||||||
{"spl", &SPL::LoopProcess},
|
{"spl", &SPL::LoopProcess},
|
||||||
{"ssl", &SSL::LoopProcess},
|
{"ssl", &SSL::LoopProcess},
|
||||||
{"usb", &USB::LoopProcess}
|
{"usb", &USB::LoopProcess},
|
||||||
|
{"i2c", &I2C::LoopProcess},
|
||||||
|
{"gpio", &GPIO::LoopProcess},
|
||||||
})
|
})
|
||||||
kernel.RunOnGuestCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); });
|
kernel.RunOnGuestCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue