Add a bunch of #ifdefs to keep things working as expected on linux

This commit is contained in:
Tyler Wilding
2020-09-03 22:24:50 -04:00
parent f68f220e5b
commit ef09eb12c8
26 changed files with 336 additions and 419 deletions
+15 -2
View File
@@ -4,7 +4,6 @@
* DONE!
*/
#include <io.h>
#include <cstring>
#include "common/common_types.h"
#include "game/sce/libscf.h"
@@ -13,7 +12,14 @@
#include "kscheme.h"
#include "ksocket.h"
#include "klisten.h"
#ifdef _WIN32
#include "Windows.h"
#include <io.h>
#elif __linux__
#include <unistd.h>
#endif
using namespace ee;
// Level to load on boot
@@ -128,14 +134,21 @@ void KernelCheckAndDispatch() {
// dispatch the kernel
//(**kernel_dispatcher)();
call_goal(Ptr<Function>(kernel_dispatcher->value), 0, 0, 0, s7.offset, g_ee_main_mem);
//ClearPending();
// 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
}
}
+8 -13
View File
@@ -1,6 +1,3 @@
/*
/*!
* @file kdsnetm.cpp
* Low-level DECI2 wrapper for ksocket
@@ -30,10 +27,12 @@ void kdsnetm_init_globals() {
protoBlock.reset();
}
// TODO-WINDOWS
#ifdef __linux__
/*!
* Register GOAL DECI2 Protocol Driver with DECI2 service
* DONE, EXACT
*/
void InitGoalProto() {
protoBlock.socket = sceDeci2Open(DECI2_PROTOCOL, &protoBlock, GoalProtoHandler);
if (protoBlock.socket < 0) {
@@ -49,12 +48,10 @@ void InitGoalProto() {
}
}
*/
/*!
* Close the DECI2 Protocol Driver
* DONE, EXACT
*/
void ShutdownGoalProto() {
if (protoBlock.socket > 0) {
sceDeci2Close(protoBlock.socket);
@@ -65,7 +62,7 @@ void ShutdownGoalProto() {
* Handle a DECI2 Protocol Event for the GOAL Proto.
* Called by the DECI2 Protocol driver
* DONE, added print statements on errors for debugging, EI and SYNC at the end were removed
*/
void GoalProtoHandler(int event, int param, void* opt) {
// verify we got the correct opt pointer. It's not clear why the opt pointer is used
// like this?
@@ -165,7 +162,7 @@ void GoalProtoHandler(int event, int param, void* opt) {
* Will block until send is complete.
* DONE, original version used an uncached address and had a FlushCache call, which were both
* removed
*/
s32 SendFromBufferD(s32 msg_kind, u64 p2, char* data, s32 size) {
// wait for send to finish or error first...
while (protoBlock.send_status > 0) {
@@ -220,11 +217,9 @@ s32 SendFromBufferD(s32 msg_kind, u64 p2, char* data, s32 size) {
/*!
* Print GOAL Protocol status
*/
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
+6 -2
View File
@@ -51,17 +51,21 @@ extern GoalProtoBlock protoBlock;
*/
void kdsnetm_init_globals();
// TODO-WINDOWS
#ifdef __linux__
/*!
* Register GOAL DECI2 Protocol Driver with DECI2 service
* DONE, EXACT
*/
//void InitGoalProto();
void InitGoalProto();
/*!
* Close the DECI2 Protocol Driver
* DONE, EXACT
*/
//void ShutdownGoalProto();
void ShutdownGoalProto();
#endif
/*!
* Handle a DECI2 Protocol Event for the GOAL Proto.
+11 -5
View File
@@ -71,7 +71,10 @@ 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.
// SendFromBuffer(msg.c(), size);
// TODO-WINDOWS
#ifdef __linux__
SendFromBuffer(msg.c(), size);
#endif
clear_output();
}
@@ -84,7 +87,10 @@ void ClearPending() {
if (send_size > 64000) {
send_size = 64000;
}
// SendFromBufferD(2, 0, msg, send_size);
// TODO-WINDOWS
#ifdef __linux__
SendFromBufferD(2, 0, msg, send_size);
#endif
size -= send_size;
msg += send_size;
}
@@ -103,9 +109,9 @@ void ClearPending() {
*/
void SendAck() {
if (MasterDebug) {
// SendFromBufferD(u16(ListenerMessageKind::MSG_ACK), protoBlock.msg_id,
// AckBufArea + sizeof(GoalMessageHeader),
// strlen(AckBufArea + sizeof(GoalMessageHeader)));
#ifdef __linux__
SendFromBufferD(u16(ListenerMessageKind::MSG_ACK), protoBlock.msg_id, AckBufArea + sizeof(GoalMessageHeader), strlen(AckBufArea + sizeof(GoalMessageHeader)));
#endif
}
}
+9 -3
View File
@@ -153,7 +153,7 @@ void InitCD() {
/*!
* Initialize the I/O Processor
* Removed calls to exit(0) if loading modules fails.
* Removed calls to exit(0) if loading modules fails.
*/
void InitIOP() {
// before doing anything with the I/O Processor, we need to set up SIF RPC
@@ -329,7 +329,10 @@ int InitMachine() {
// }
if (MasterDebug) { // connect to GOAL compiler
// InitGoalProto();
// TODO-WINDOWS
#ifdef __linux__
InitGoalProto();
#endif
}
printf("InitSound\n");
@@ -359,7 +362,10 @@ int ShutdownMachine() {
StopIOP();
CloseListener();
ShutdownSound();
// ShutdownGoalProto();
// TODO-WINDOWS
#ifdef __linux__
ShutdownGoalProto();
#endif
Msg(6, "kernel: machine shutdown");
return 0;
}
+1 -1
View File
@@ -1,6 +1,6 @@
/*!
* @file kmemcard.cpp
* Memory card interfaces. Very messy code.
* Memory card interface. Very messy code.
*/
//#include "ps2/SCE_MC.h"
+1 -1
View File
@@ -1,6 +1,6 @@
/*!
* @file kmemcard.h
* Memory card interfaces. Very messy code.
* Memory card interface. Very messy code.
*/
#ifndef JAK_KMEMCARD_H
+4 -6
View File
@@ -13,8 +13,6 @@ constexpr u32 DEBUG_OUTPUT_BUFFER_SIZE = 0x80000;
constexpr u32 DEBUG_PRINT_BUFFER_SIZE = 0x200000;
constexpr u32 PRINT_BUFFER_SIZE = 0x2000;
#define __attribute__(A) /* do nothing */
///////////
// SDATA
///////////
@@ -67,25 +65,25 @@ void output_segment_load(const char* name, Ptr<u8> link_block, u32 flags);
/*!
* Print to the GOAL print buffer from C
*/
void cprintf(const char* format, ...) __attribute__((format(printf, 1, 2)));
void cprintf(const char* format, ...);
/*!
* Print directly to the C stdout
* The "k" parameter is ignored, so this is just like printf
*/
void Msg(s32 k, const char* format, ...) __attribute__((format(printf, 2, 3)));
void Msg(s32 k, const char* format, ...);
/*!
* Print directly to the C stdout
* This is identical to Msg.
*/
void MsgWarn(const char* format, ...) __attribute__((format(printf, 1, 2)));
void MsgWarn(const char* format, ...);
/*!
* Print directly to the C stdout
* This is identical to Msg.
*/
void MsgErr(const char* format, ...) __attribute__((format(printf, 1, 2)));
void MsgErr(const char* format, ...);
/*!
* Reverse string in place.
+1 -3
View File
@@ -318,8 +318,6 @@ u64 make_string_from_c(const char* c_str) {
* creates a function object on the global heap.
*
* The implementation is to create a simple trampoline function which jumps to the C function.
*
*
*/
Ptr<Function> make_function_from_c(void* func) {
// allocate a function object on the global heap
@@ -1804,7 +1802,7 @@ s32 InitHeapAndSymbol() {
// setup deci2count for message counter.
protoBlock.deci2count = intern_from_c("*deci-count*").cast<s32>();
// load stuff for the listener interfaces
// load stuff for the listener interface
InitListener();
// Do final initialization, including loading and initializing the engine.
+6 -3
View File
@@ -52,14 +52,17 @@ 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
* DONE, EXACT
*/
//s32 SendFromBuffer(char* buff, s32 size) {
// return SendFromBufferD(u16(ListenerMessageKind::MSG_OUTPUT), 0, buff, size);
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.