rpcsx/rpcs3/Emu/SysCalls/lv2/SC_Timer.cpp
Peter Tissen c37905e465 initial start to eliminate static func init, not compilable atm
move module initialization into a module manager, still has some issues like stopping not working and debug crashing

add #idef 0 to modules that aren't in the windows project

don't double initialize and don't de-initialize for now, since many modules don't expect it and it leads to many errors

remove duplicate module lists for empty modules and implemented ones, make Module non-copyable but movable

add secondary project, no real use for it now

add some memleak config to the emucore and add asmjit path to rpcs3

small rebase error fixed to get it to compile again

add filters for emucore

re-add the module manager and static file

WIP commit, linker errors abound

some more abstraction layer stuff

fix the remaining linker errors, re-enable platform specific mouse, pad and keyboard handlers

rebasing

fix memset undefined and re() usage of se_t before declaration

Add wxGUI define by default for cmake builds

fix copy constructors of Datetime header

fix copy constructors of other wx interface classes

remove static declarations of global variables

make wxGLCanvas constructor non-ambiguous even with wx2.8. compat mode, fix wrong std::exception constructor calls

remove duplicate definition for FromUTF8 and ToUTF8

temp changes
2014-06-08 23:16:06 +02:00

113 lines
3.1 KiB
C++

#include "stdafx.h"
#include "Emu/ConLog.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "SC_Timer.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/event.h"
SysCallBase sys_timer("sys_timer");
int sys_timer_create(mem32_t timer_id)
{
sys_timer.Warning("sys_timer_create(timer_id_addr=0x%x)", timer_id.GetAddr());
if(!Memory.IsGoodAddr(timer_id.GetAddr())) return CELL_EFAULT;
timer_id = sys_timer.GetNewId(new timer);
return CELL_OK;
}
int sys_timer_destroy(u32 timer_id)
{
sys_timer.Warning("TODO: sys_timer_destroy(timer_id=%d)", timer_id);
if(!sys_timer.CheckId(timer_id)) return CELL_ESRCH;
Emu.GetIdManager().RemoveID(timer_id);
return CELL_OK;
}
int sys_timer_get_information(u32 timer_id, mem_ptr_t<sys_timer_information_t> info)
{
sys_timer.Warning("sys_timer_get_information(timer_id=%d, info_addr=0x%x)", timer_id, info.GetAddr());
timer* timer_data = nullptr;
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
*info = timer_data->timer_information_t;
return CELL_OK;
}
int sys_timer_start(u32 timer_id, s64 base_time, u64 period)
{
sys_timer.Warning("sys_timer_start_periodic_absolute(timer_id=%d, basetime=%lld, period=%llu)", timer_id, base_time, period);
timer* timer_data = nullptr;
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
if(timer_data->timer_information_t.timer_state != SYS_TIMER_STATE_STOP) return CELL_EBUSY;
if(period < 100) return CELL_EINVAL;
//TODO: if (timer is not connected to an event queue) return CELL_ENOTCONN;
timer_data->timer_information_t.next_expiration_time = base_time;
timer_data->timer_information_t.period = period;
timer_data->timer_information_t.timer_state = SYS_TIMER_STATE_RUN;
//TODO: ?
timer_data->tmr.Start();
return CELL_OK;
}
int sys_timer_stop(u32 timer_id)
{
sys_timer.Warning("TODO: sys_timer_stop()");
timer* timer_data = nullptr;
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
timer_data->timer_information_t.timer_state = SYS_TIMER_STATE_STOP;
timer_data->tmr.Stop();
return CELL_OK;
}
int sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data1, u64 data2)
{
sys_timer.Warning("sys_timer_connect_event_queue(timer_id=%d, queue_id=%d, name=%llu, data1=%llu, data2=%llu)",
timer_id, queue_id, name, data1, data2);
timer* timer_data = nullptr;
EventQueue* equeue = nullptr;
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
if(!sys_timer.CheckId(queue_id, equeue)) return CELL_ESRCH;
//TODO: ?
return CELL_OK;
}
int sys_timer_disconnect_event_queue(u32 timer_id)
{
sys_timer.Warning("TODO: sys_timer_disconnect_event_queue(timer_id=%d)", timer_id);
timer* timer_data = nullptr;
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
//TODO: ?
return CELL_OK;
}
int sys_timer_sleep(u32 sleep_time)
{
sys_timer.Warning("sys_timer_sleep(sleep_time=%d)", sleep_time);
rSleep(sleep_time);
return CELL_OK;
}
int sys_timer_usleep(u64 sleep_time)
{
sys_timer.Log("sys_timer_usleep(sleep_time=%lld)", sleep_time);
if (sleep_time > 0xFFFFFFFFFFFF) sleep_time = 0xFFFFFFFFFFFF; //2^48-1
rMicroSleep(sleep_time); //TODO: If (sleep_time >= 2^32) shit may happen
return CELL_OK;
}