mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-21 02:07:49 +00:00
[hle] constexpr handler dispatch maps, introduce version gating (#4480)
This PR primarily focuses on upbringing constexpr maps for handlers. Each time an HLE object of a service is construed, it registers it's own handlers, over and over. Regardless of whetever it needs them at the moment or not. Additionally we don't require to keep track of different function pointers amongst each object. This can be done by overriding the given function instead, as opposed to having a separate hash map for every given object. In other words: Remove handlers (and handlers_tipc) map for every instance then read from a static defined per-class. - [x] Migrate all HLE functions to new `frozen::map` constexpr time finder - [ ] Measure if this approach actually makes better codegen Optional: - [x] Properly gate all functions (that have versions commented next to them) - [x] Maybe store `HandlerFnP<>` and `const char*` separately, version gating can go in a different map as well Information such as name can be used on debug builds, but doesn't particularly help on release as one can consult an external reference (or have an annotated IPC map) Signed-off-by: lizzie <lizzie@eden-emu.dev> - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- Co-authored-by: Maufeat <sahyno1996@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4480 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
@@ -15,64 +15,62 @@ namespace Service::PCIe {
|
||||
|
||||
class ISession final : public ServiceFramework<ISession> {
|
||||
public:
|
||||
explicit ISession(Core::System& system_) : ServiceFramework{system_, "ISession"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "QueryFunctions"},
|
||||
{1, nullptr, "AcquireFunction"},
|
||||
{2, nullptr, "ReleaseFunction"},
|
||||
{3, nullptr, "GetFunctionState"},
|
||||
{4, nullptr, "GetBarProfile"},
|
||||
{5, nullptr, "ReadConfig"},
|
||||
{6, nullptr, "WriteConfig"},
|
||||
{7, nullptr, "ReadBarRegion"},
|
||||
{8, nullptr, "WriteBarRegion"},
|
||||
{9, nullptr, "FindCapability"},
|
||||
{10, nullptr, "FindExtendedCapability"},
|
||||
{11, nullptr, "MapDma"},
|
||||
{12, nullptr, "UnmapDma"},
|
||||
{13, nullptr, "UnmapDmaBusAddress"},
|
||||
{14, nullptr, "GetDmaBusAddress"},
|
||||
{15, nullptr, "GetDmaBusAddressRange"},
|
||||
{16, nullptr, "SetDmaEnable"},
|
||||
{17, nullptr, "AcquireIrq"},
|
||||
{18, nullptr, "ReleaseIrq"},
|
||||
{19, nullptr, "SetIrqEnable"},
|
||||
{20, nullptr, "GetIrqEvent"},
|
||||
{21, nullptr, "SetAspmEnable"},
|
||||
{22, nullptr, "SetResetUponResumeEnable"},
|
||||
{23, nullptr, "ResetFunction"},
|
||||
};
|
||||
// clang-format on
|
||||
explicit ISession(Core::System& system_) : ServiceFramework{system_, "ISession"} {}
|
||||
|
||||
RegisterHandlers(functions);
|
||||
static constexpr auto functions = CreateStaticMap(
|
||||
FunctionInfo{0, nullptr, "QueryFunctions"},
|
||||
FunctionInfo{1, nullptr, "AcquireFunction"},
|
||||
FunctionInfo{2, nullptr, "ReleaseFunction"},
|
||||
FunctionInfo{3, nullptr, "GetFunctionState"},
|
||||
FunctionInfo{4, nullptr, "GetBarProfile"},
|
||||
FunctionInfo{5, nullptr, "ReadConfig"},
|
||||
FunctionInfo{6, nullptr, "WriteConfig"},
|
||||
FunctionInfo{7, nullptr, "ReadBarRegion"},
|
||||
FunctionInfo{8, nullptr, "WriteBarRegion"},
|
||||
FunctionInfo{9, nullptr, "FindCapability"},
|
||||
FunctionInfo{10, nullptr, "FindExtendedCapability"},
|
||||
FunctionInfo{11, nullptr, "MapDma"},
|
||||
FunctionInfo{12, nullptr, "UnmapDma"},
|
||||
FunctionInfo{13, nullptr, "UnmapDmaBusAddress"},
|
||||
FunctionInfo{14, nullptr, "GetDmaBusAddress"},
|
||||
FunctionInfo{15, nullptr, "GetDmaBusAddressRange"},
|
||||
FunctionInfo{16, nullptr, "SetDmaEnable"},
|
||||
FunctionInfo{17, nullptr, "AcquireIrq"},
|
||||
FunctionInfo{18, nullptr, "ReleaseIrq"},
|
||||
FunctionInfo{19, nullptr, "SetIrqEnable"},
|
||||
FunctionInfo{20, nullptr, "GetIrqEvent"},
|
||||
FunctionInfo{21, nullptr, "SetAspmEnable"},
|
||||
FunctionInfo{22, nullptr, "SetResetUponResumeEnable"},
|
||||
FunctionInfo{23, nullptr, "ResetFunction"}
|
||||
);
|
||||
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
|
||||
return HandlerTableGenerateWithFind(key, functions);
|
||||
}
|
||||
};
|
||||
|
||||
class PCIE final : public ServiceFramework<PCIE> {
|
||||
public:
|
||||
explicit PCIE(Core::System& system_) : ServiceFramework{system_, "pcie"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "RegisterClassDriver"},
|
||||
{1, nullptr, "QueryFunctionsUnregistered"},
|
||||
};
|
||||
// clang-format on
|
||||
explicit PCIE(Core::System& system_) : ServiceFramework{system_, "pcie"} {}
|
||||
|
||||
RegisterHandlers(functions);
|
||||
static constexpr auto functions = CreateStaticMap(
|
||||
FunctionInfo{0, nullptr, "RegisterClassDriver"},
|
||||
FunctionInfo{1, nullptr, "QueryFunctionsUnregistered"}
|
||||
);
|
||||
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
|
||||
return HandlerTableGenerateWithFind(key, functions);
|
||||
}
|
||||
};
|
||||
|
||||
class PCIE_LOG final : public ServiceFramework<PCIE_LOG> {
|
||||
public:
|
||||
explicit PCIE_LOG(Core::System& system_) : ServiceFramework{system_, "pcie:log"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetLoggedState"},
|
||||
{1, nullptr, "GetLoggedStateEvent"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
explicit PCIE_LOG(Core::System& system_) : ServiceFramework{system_, "pcie:log"} {}
|
||||
|
||||
static constexpr auto functions = CreateStaticMap(
|
||||
FunctionInfo{0, nullptr, "GetLoggedState"},
|
||||
FunctionInfo{1, nullptr, "GetLoggedStateEvent"}
|
||||
);
|
||||
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
|
||||
return HandlerTableGenerateWithFind(key, functions);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user