From 2113fce2fbac96d863e96eb2bc4b4029b38935d0 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 4 Aug 2015 17:47:37 +0300 Subject: [PATCH] cellFont, cellRudp cleanup --- rpcs3/Emu/SysCalls/Modules/cellFont.cpp | 48 ------------------------- rpcs3/Emu/SysCalls/Modules/cellRudp.cpp | 44 +++++++++-------------- 2 files changed, 17 insertions(+), 75 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 8da8291a84..0c3e62aedc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -8,21 +8,10 @@ extern Module cellFont; -struct font_instance_t -{ - std::atomic init{ false }; -} -g_font; - // Functions s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr config) { cellFont.Warning("cellFontInitializeWithRevision(revisionFlags=0x%llx, config=*0x%x)", revisionFlags, config); - - if (g_font.init.load()) - { - return CELL_FONT_ERROR_ALREADY_INITIALIZED; - } if (config->fc_size < 24) { @@ -34,11 +23,6 @@ s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr co cellFont.Error("cellFontInitializeWithRevision: Unknown flags (0x%x)", config->flags); } - if (g_font.init.exchange(true)) - { - throw EXCEPTION("Unexpected"); - } - return CELL_OK; } @@ -52,16 +36,6 @@ s32 cellFontEnd() { cellFont.Warning("cellFontEnd()"); - if (!g_font.init.load()) - { - return CELL_FONT_ERROR_UNINITIALIZED; - } - - if (!g_font.init.exchange(false)) - { - throw EXCEPTION("Unexpected"); - } - return CELL_OK; } @@ -75,11 +49,6 @@ s32 cellFontOpenFontMemory(vm::ptr library, u32 fontAddr, u32 f { cellFont.Warning("cellFontOpenFontMemory(library=*0x%x, fontAddr=0x%x, fontSize=%d, subNum=%d, uniqueId=%d, font=*0x%x)", library, fontAddr, fontSize, subNum, uniqueId, font); - if (!g_font.init.load()) - { - return CELL_FONT_ERROR_UNINITIALIZED; - } - font->stbfont = (stbtt_fontinfo*)((u8*)&(font->stbfont) + sizeof(void*)); // hack: use next bytes of the struct if (!stbtt_InitFont(font->stbfont, vm::get_ptr(fontAddr), 0)) @@ -115,11 +84,6 @@ s32 cellFontOpenFontset(PPUThread& ppu, vm::ptr library, vm::pt { cellFont.Warning("cellFontOpenFontset(library=*0x%x, fontType=*0x%x, font=*0x%x)", library, fontType, font); - if (!g_font.init.load()) - { - return CELL_FONT_ERROR_UNINITIALIZED; - } - if (fontType->map != CELL_FONT_MAP_UNICODE) { cellFont.Warning("cellFontOpenFontset: Only Unicode is supported"); @@ -222,11 +186,6 @@ s32 cellFontSetFontOpenMode(u32 openMode) s32 cellFontCreateRenderer(vm::ptr library, vm::ptr config, vm::ptr Renderer) { cellFont.Todo("cellFontCreateRenderer(library=*0x%x, config=*0x%x, Renderer=*0x%x)", library, config, Renderer); - - if (!g_font.init.load()) - { - return CELL_FONT_ERROR_UNINITIALIZED; - } //Write data in Renderer @@ -468,11 +427,6 @@ s32 cellFontOpenFontsetOnMemory(PPUThread& ppu, vm::ptr library { cellFont.Todo("cellFontOpenFontsetOnMemory(library=*0x%x, fontType=*0x%x, font=*0x%x)", library, fontType, font); - if (!g_font.init.load()) - { - return CELL_FONT_ERROR_UNINITIALIZED; - } - if (fontType->map != CELL_FONT_MAP_UNICODE) { cellFont.Warning("cellFontOpenFontsetOnMemory: Only Unicode is supported"); @@ -789,8 +743,6 @@ s32 cellFontGraphicsGetLineRGBA() Module cellFont("cellFont", []() { - g_font.init = false; - REG_FUNC(cellFont, cellFontSetFontsetOpenMode); REG_FUNC(cellFont, cellFontSetFontOpenMode); REG_FUNC(cellFont, cellFontCreateRenderer); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp b/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp index 9bd3f84131..b23408e3a6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Emu/Memory/Memory.h" +#include "Emu/IdManager.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" @@ -8,42 +9,41 @@ extern Module cellRudp; -struct RudpInternal +struct rudp_t { - std::atomic init; - // allocator functions std::function(PPUThread& ppu, u32 size)> malloc; std::function ptr)> free; // event handler function - vm::ptr handler; + vm::ptr handler = vm::null; vm::ptr handler_arg; -} -g_rudp; +}; s32 cellRudpInit(vm::ptr allocator) { cellRudp.Warning("cellRudpInit(allocator=*0x%x)", allocator); - if (g_rudp.init.load()) + const auto rudp = Emu.GetIdManager().make_fixed(); + + if (!rudp) { return CELL_RUDP_ERROR_ALREADY_INITIALIZED; } if (allocator) { - g_rudp.malloc = allocator->app_malloc; - g_rudp.free = allocator->app_free; + rudp->malloc = allocator->app_malloc; + rudp->free = allocator->app_free; } else { - g_rudp.malloc = [](PPUThread& ppu, u32 size) + rudp->malloc = [](PPUThread& ppu, u32 size) { return vm::ptr::make(vm::alloc(size, vm::main)); }; - g_rudp.free = [](PPUThread& ppu, vm::ptr ptr) + rudp->free = [](PPUThread& ppu, vm::ptr ptr) { if (!vm::dealloc(ptr.addr(), vm::main)) { @@ -52,11 +52,6 @@ s32 cellRudpInit(vm::ptr allocator) }; } - if (g_rudp.init.exchange(true)) - { - throw EXCEPTION("Unexpected"); - } - return CELL_OK; } @@ -64,16 +59,11 @@ s32 cellRudpEnd() { cellRudp.Warning("cellRudpEnd()"); - if (!g_rudp.init.load()) + if (!Emu.GetIdManager().remove()) { return CELL_RUDP_ERROR_NOT_INITIALIZED; } - if (!g_rudp.init.exchange(false)) - { - throw EXCEPTION("Unexpected"); - } - return CELL_OK; } @@ -87,13 +77,15 @@ s32 cellRudpSetEventHandler(vm::ptr handler, vm::ptr { cellRudp.Todo("cellRudpSetEventHandler(handler=*0x%x, arg=*0x%x)", handler, arg); - if (!g_rudp.init.load()) + const auto rudp = Emu.GetIdManager().get(); + + if (!rudp) { return CELL_RUDP_ERROR_NOT_INITIALIZED; } - g_rudp.handler = handler; - g_rudp.handler_arg = arg; + rudp->handler = handler; + rudp->handler_arg = arg; return CELL_OK; } @@ -250,8 +242,6 @@ s32 cellRudpProcessEvents() Module cellRudp("cellRudp", []() { - g_rudp.init = false; - REG_FUNC(cellRudp, cellRudpInit); REG_FUNC(cellRudp, cellRudpEnd); REG_FUNC(cellRudp, cellRudpEnableInternalIOThread);