Got rid of a lot of windows ifdefs

This commit is contained in:
Tyler Wilding 2020-09-07 20:00:02 -04:00
parent 84e0bee6f4
commit aea7b692e4
8 changed files with 8 additions and 81 deletions

View file

@ -5,6 +5,9 @@
*/
#include <cstring>
#include <chrono>
#include <thread>
#include "common/common_types.h"
#include "game/sce/libscf.h"
#include "kboot.h"
@ -134,21 +137,14 @@ void KernelCheckAndDispatch() {
// dispatch the kernel
//(**kernel_dispatcher)();
call_goal(Ptr<Function>(kernel_dispatcher->value), 0, 0, 0, s7.offset, g_ee_main_mem);
// TODO-WINDOWS
#ifdef __linux__
ClearPending();
#endif
// if the listener function changed, it means the kernel ran it, so we should notify compiler.
if (MasterDebug && ListenerFunction->value != old_listener) {
SendAck();
}
#ifdef _WIN32
Sleep(1000); // todo - remove this
#elif __linux__
usleep(1000);
#endif
std::this_thread::sleep_for(std::chrono::microseconds(1000));
}
}

View file

@ -27,8 +27,6 @@ void kdsnetm_init_globals() {
protoBlock.reset();
}
// TODO-WINDOWS
#ifdef __linux__
/*!
* Register GOAL DECI2 Protocol Driver with DECI2 service
* DONE, EXACT
@ -222,4 +220,3 @@ void GoalProtoStatus() {
Msg(6, "gproto: got %d %d\n", protoBlock.most_recent_event, protoBlock.most_recent_param);
Msg(6, "gproto: %d %d\n", protoBlock.last_receive_size, protoBlock.send_remaining);
}
#endif

View file

@ -51,8 +51,6 @@ extern GoalProtoBlock protoBlock;
*/
void kdsnetm_init_globals();
// TODO-WINDOWS
#ifdef __linux__
/*!
* Register GOAL DECI2 Protocol Driver with DECI2 service
* DONE, EXACT
@ -65,8 +63,6 @@ void InitGoalProto();
*/
void ShutdownGoalProto();
#endif
/*!
* Handle a DECI2 Protocol Event for the GOAL Proto.
* Called by the DECI2 Protocol driver
@ -74,8 +70,6 @@ void ShutdownGoalProto();
*/
void GoalProtoHandler(int event, int param, void* data);
// TODO-WINDOWS
#ifdef __linux__
/*!
* Low level DECI2 send
* Will block until send is complete.
@ -83,7 +77,6 @@ void GoalProtoHandler(int event, int param, void* data);
* removed
*/
s32 SendFromBufferD(s32 p1, u64 p2, char* data, s32 size);
#endif
/*!
* Print GOAL Protocol status

View file

@ -71,10 +71,7 @@ void ClearPending() {
Ptr<char> msg = OutputBufArea.cast<char>() + sizeof(GoalMessageHeader);
auto size = strlen(msg.c());
// note - if size is ever greater than 2^16 this will cause an issue.
// TODO-WINDOWS
#ifdef __linux__
SendFromBuffer(msg.c(), size);
#endif
clear_output();
}
@ -87,10 +84,7 @@ void ClearPending() {
if (send_size > 64000) {
send_size = 64000;
}
// TODO-WINDOWS
#ifdef __linux__
SendFromBufferD(2, 0, msg, send_size);
#endif
size -= send_size;
msg += send_size;
}
@ -109,11 +103,9 @@ void ClearPending() {
*/
void SendAck() {
if (MasterDebug) {
#ifdef __linux__
SendFromBufferD(u16(ListenerMessageKind::MSG_ACK), protoBlock.msg_id,
AckBufArea + sizeof(GoalMessageHeader),
strlen(AckBufArea + sizeof(GoalMessageHeader)));
#endif
}
}
@ -161,4 +153,4 @@ void ProcessListenerMessage(Ptr<char> msg) {
break;
}
SendAck();
}
}

View file

@ -329,10 +329,7 @@ int InitMachine() {
// }
if (MasterDebug) { // connect to GOAL compiler
// TODO-WINDOWS
#ifdef __linux__
InitGoalProto();
#endif
}
printf("InitSound\n");
@ -362,10 +359,7 @@ int ShutdownMachine() {
StopIOP();
CloseListener();
ShutdownSound();
// TODO-WINDOWS
#ifdef __linux__
ShutdownGoalProto();
#endif
Msg(6, "kernel: machine shutdown");
return 0;
}

View file

@ -52,8 +52,6 @@ u32 ReceiveToBuffer(char* buff) {
return msg_size;
}
// TODO-WINDOWS
#ifdef __linux__
/*!
* Do a DECI2 send and block until it is complete.
* The message type is OUTPUT
@ -62,7 +60,6 @@ u32 ReceiveToBuffer(char* buff) {
s32 SendFromBuffer(char* buff, s32 size) {
return SendFromBufferD(u16(ListenerMessageKind::MSG_OUTPUT), 0, buff, size);
}
#endif
/*!
* Just prepare the Ack buffer, doesn't actually connect.

View file

@ -12,7 +12,9 @@
#include <Windows.h>
#endif
#include <chrono>
#include <cstring>
#include <thread>
#include "runtime.h"
#include "system/SystemThread.h"
@ -45,11 +47,6 @@
u8* g_ee_main_mem = nullptr;
/*!
* TODO-WINDOWS
* runtime.cpp - Deci2Listener has been disabled for now, pending rewriting for Windows.
*/
namespace {
/*!
@ -57,8 +54,6 @@ namespace {
*/
void deci2_runner(SystemThreadInterface& iface) {
// TODO-WINDOWS
#ifdef __linux__
// callback function so the server knows when to give up and shutdown
std::function<bool()> shutdown_callback = [&]() { return iface.get_want_exit(); };
@ -89,10 +84,9 @@ void deci2_runner(SystemThreadInterface& iface) {
server.run();
} else {
// no connection yet. Do a sleep so we don't spam checking the listener.
usleep(50000);
std::this_thread::sleep_for(std::chrono::microseconds(50000));
}
}
#endif
}
// EE System
@ -236,10 +230,7 @@ void exec_runtime(int argc, char** argv) {
// step 1: sce library prep
iop::LIBRARY_INIT();
ee::LIBRARY_INIT_sceCd();
// TODO-WINDOWS
#ifdef __linux__
ee::LIBRARY_INIT_sceDeci2();
#endif
ee::LIBRARY_INIT_sceSif();
// step 2: system prep

View file

@ -12,14 +12,11 @@
namespace ee {
namespace {
// TODO-WINDOWS
#ifdef __linux__
constexpr int MAX_DECI2_PROTOCOLS = 4;
Deci2Driver protocols[MAX_DECI2_PROTOCOLS]; // info for each deci2 protocol registered
int protocol_count; // number of registered protocols
Deci2Driver* sending_driver; // currently sending protocol driver
::Deci2Server* server; // the server to send data to
#endif
} // namespace
@ -27,8 +24,6 @@ Deci2Driver* sending_driver; // currently sending protocol drive
* Initialize the library.
*/
void LIBRARY_INIT_sceDeci2() {
// TODO-WINDOWS
#ifdef __linux__
// reset protocols
for (auto& p : protocols) {
p = Deci2Driver();
@ -36,15 +31,12 @@ void LIBRARY_INIT_sceDeci2() {
protocol_count = 0;
server = nullptr;
sending_driver = nullptr;
#endif
}
/*!
* Run any pending requested sends.
*/
void LIBRARY_sceDeci2_run_sends() {
// TODO-WINDOWS
#ifdef __linux__
for (auto& prot : protocols) {
if (prot.active && prot.pending_send == 'H') {
sending_driver = &prot;
@ -54,17 +46,13 @@ void LIBRARY_sceDeci2_run_sends() {
(prot.handler)(DECI2_WRITEDONE, 0, prot.opt);
}
}
#endif
}
/*!
* Register a Deci2Server with this library.
*/
void LIBRARY_sceDeci2_register(::Deci2Server* s) {
// TODO-WINDOWS
#ifdef __linux__
server = s;
#endif
}
/*!
@ -73,8 +61,6 @@ void LIBRARY_sceDeci2_register(::Deci2Server* s) {
* I don't know why it's like this.
*/
s32 sceDeci2Open(u16 protocol, void* opt, void (*handler)(s32 event, s32 param, void* opt)) {
// TODO-WINDOWS
#ifdef __linux__
server->lock();
Deci2Driver drv;
drv.protocol = protocol;
@ -93,20 +79,14 @@ s32 sceDeci2Open(u16 protocol, void* opt, void (*handler)(s32 event, s32 param,
}
return drv.id;
#elif _WIN32
return 0;
#endif
}
/*!
* Deactivate a DECI2 protocol by socket descriptor.
*/
s32 sceDeci2Close(s32 s) {
// TODO-WINDOWS
#ifdef __linux__
assert(s - 1 < protocol_count);
protocols[s - 1].active = false;
#endif
return 1;
}
@ -114,12 +94,9 @@ s32 sceDeci2Close(s32 s) {
* Start a send.
*/
s32 sceDeci2ReqSend(s32 s, char dest) {
// TODO-WINDOWS
#ifdef __linux__
assert(s - 1 < protocol_count);
auto& proto = protocols[s - 1];
proto.pending_send = dest;
#endif
return 0;
}
@ -128,8 +105,6 @@ s32 sceDeci2ReqSend(s32 s, char dest) {
* Returns after data is copied.
*/
s32 sceDeci2ExRecv(s32 s, void* buf, u16 len) {
// TODO-WINDOWS
#ifdef __linux__
assert(s - 1 < protocol_count);
protocols[s - 1].recv_size = len;
auto avail = protocols[s - 1].available_to_receive;
@ -140,17 +115,12 @@ s32 sceDeci2ExRecv(s32 s, void* buf, u16 len) {
printf("[DECI2] Error: ExRecv %d, only %d available!\n", len, avail);
return -1;
}
#elif _WIN32
return 0;
#endif
}
/*!
* Do a send.
*/
s32 sceDeci2ExSend(s32 s, void* buf, u16 len) {
// TODO-WINDOWS
#ifdef __linux__
assert(s - 1 < protocol_count);
if (!sending_driver) {
printf("sceDeci2ExSend called at illegal time!\n");
@ -162,8 +132,5 @@ s32 sceDeci2ExSend(s32 s, void* buf, u16 len) {
server->send_data(buf, len);
return len;
#elif _WIN32
return 0;
#endif
}
} // namespace ee