mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-23 22:29:53 +00:00
f8bc883d48
* Use sleepthread in RPC loop * Keep a pointer to current IOP thread * Implement IOP thread scheduling based on priority And implement DelayThread as an actual delay. * Run IOP flat out * Use information from scheduler in wait_run_iop * Lock sif mutex in set_rpc_queue * always use kernel dispatch with wait_run * Loop in dispatch until no thread is ready * Use timestamp for next wakeup instead of duration * Wrap IOP thread entrypoints for safety Libco threads are not supposed to return from their entrypoint * Use a queue for IOP thread wakeups from EE thread
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#ifndef JAK1_IOP_THREAD_H
|
|
#define JAK1_IOP_THREAD_H
|
|
|
|
#include "IOP_Kernel.h"
|
|
|
|
#include "common/common_types.h"
|
|
|
|
enum IOP_Status { IOP_WAIT_FOR_LOAD, IOP_OVERLORD_INIT, IOP_OVERLORD_RUN, IOP_OVERLORD_STOP };
|
|
|
|
class IOP {
|
|
public:
|
|
IOP();
|
|
~IOP();
|
|
void* iop_alloc(int size);
|
|
void reset_allocator();
|
|
void send_status(IOP_Status new_status);
|
|
void wait_for_overlord_start_cmd();
|
|
void wait_for_overlord_init_finish();
|
|
void signal_overlord_init_finish();
|
|
void signal_run_iop();
|
|
|
|
void wait_run_iop(
|
|
std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds> duration);
|
|
void kill_from_ee();
|
|
|
|
void set_ee_main_mem(u8* mem) { ee_main_mem = mem; }
|
|
|
|
IOP_Status status = IOP_WAIT_FOR_LOAD;
|
|
|
|
char overlord_arg_data[512];
|
|
char* overlord_argv[8];
|
|
s32 overlord_argc;
|
|
|
|
IOP_Kernel kernel;
|
|
u8* ee_main_mem = nullptr;
|
|
bool want_exit = false;
|
|
|
|
private:
|
|
std::vector<void*> allocations;
|
|
std::condition_variable cv;
|
|
std::mutex iop_mutex, run_cv_mutex;
|
|
bool overlord_init_done = false;
|
|
std::condition_variable iop_run_cv;
|
|
};
|
|
|
|
#endif // JAK1_IOP_THREAD_H
|