diff --git a/kernel/Makefile b/kernel/Makefile index 613ec315..34d96f36 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -22,6 +22,7 @@ else ZIP = zip endif + CFLAGS := -mbig-endian -O3 -std=gnu89 -g -I. -Wall \ -mcpu=arm926ej-s -msoft-float -mfloat-abi=soft \ -fdata-sections -ffunction-sections -fno-builtin-toupper -fno-builtin-memcpy \ @@ -34,7 +35,7 @@ LDFLAGS := -nostartfiles -nodefaultlibs -mbig-endian -Wl,--gc-sections,-T,kernel TARGET := kernel.elf OBJECTS := start.o common.o alloc.o GCAM.o JVSIO.o JVSIOMessage.o FST.o DI.o RealDI.o \ SlippiMemory.o SlippiFileWriter.o SlippiNetwork.o SlippiNetworkBroadcast.o \ - SlippiDebug.o Patch.o PatchTimers.o TRI.o \ + Patch.o PatchTimers.o TRI.o \ PatchWidescreen.o ISO.o Stream.o adp.o EXI.o SRAM.o GCNCard.o SI.o HID.o diskio.o \ Config.o utils_asm.o ES.o NAND.o main.o syscalls.o ReadSpeed.o vsprintf.o string.o \ prs.o SDI.o usb.o usbstorage.o wdvd.o net.o @@ -44,6 +45,15 @@ ZIPFILE := ../loader/data/kernel.zip # Bluetooth stack OBJECTS += lwbt/bte.o lwbt/btmemb.o lwbt/btmemr.o lwbt/btpbuf.o lwbt/hci.o lwbt/l2cap.o lwbt/physbusif.o BT.o + +# When make is invoked with `make SLIPPI_DEBUG=1`: compile SlippiDebug.o and +# let GCC define SLIPPI_PROFILE as a macro. Use this for some profiling code. + +ifeq ($(SLIPPI_DEBUG), 1) + OBJECTS += SlippiDebug.o + CFLAGS += -DSLIPPI_DEBUG +endif + #--------------------------------------------------------------------------------- # For pulling in built-in Gecko codes ifeq ($(OS),Windows_NT) diff --git a/kernel/SlippiFileWriter.c b/kernel/SlippiFileWriter.c index 63305aa0..229f58ae 100644 --- a/kernel/SlippiFileWriter.c +++ b/kernel/SlippiFileWriter.c @@ -5,8 +5,6 @@ #include "string.h" #include "ff_utf8.h" -#include "SlippiDebug.h" - #include "Config.h" // Game can transfer at most 784 bytes / frame diff --git a/kernel/SlippiMemory.c b/kernel/SlippiMemory.c index 8f6ef2f9..c5e1785a 100644 --- a/kernel/SlippiMemory.c +++ b/kernel/SlippiMemory.c @@ -1,5 +1,4 @@ #include "SlippiMemory.h" -#include "SlippiDebug.h" #include "common.h" #include "debug.h" #include "string.h" @@ -71,7 +70,6 @@ SlpMemError SlippiMemoryRead(SlpGameReader *reader, u8 *buf, u32 bufLen, u64 rea if (bytesRead > 0 && command == SLP_CMD_RECEIVE_COMMANDS) { dbgprintf("WARN: Unnexpected new game message\r\n"); - ppc_msg("SLP UNEXP MSG\x00", 14); errCode = SLP_MEM_UNNEX_NG; break; } @@ -82,7 +80,6 @@ SlpMemError SlippiMemoryRead(SlpGameReader *reader, u8 *buf, u32 bufLen, u64 rea reader->lastReadResult.isNewGame = true; resetMetadata(reader); setPayloadSizes(reader, normalizedReadPos); - ppc_msg("SLP NEWGAME\x00", 12); } u16 payloadSize = getPayloadSize(reader, command); @@ -129,7 +126,6 @@ SlpMemError SlippiMemoryRead(SlpGameReader *reader, u8 *buf, u32 bufLen, u64 rea // Special case handling: game end message processed if (command == SLP_CMD_RECEIVE_GAME_END) { - ppc_msg("SLP GAME END\x00", 13); reader->lastReadResult.isGameEnd = true; break; } @@ -156,11 +152,10 @@ void resetMetadata(SlpGameReader *reader) void updateMetadata(SlpGameReader *reader, u8 *message, u32 messageLength) { u8 command = message[0]; + + // Only need to update if this is a post frame update if (messageLength <= 0 || command != SLP_CMD_RECEIVE_POST_FRAME_UPDATE) - { - // Only need to update if this is a post frame update return; - } // Keep track of last frame reader->metadata.lastFrame = message[1] << 24 | message[2] << 16 | message[3] << 8 | message[4]; @@ -205,9 +200,7 @@ u16 getPayloadSize(SlpGameReader *reader, u8 command) { int payloadSizesIndex = command - SLP_CMD_RECEIVE_COMMANDS; if (payloadSizesIndex >= PAYLOAD_SIZES_BUFFER_SIZE || payloadSizesIndex < 0) - { return 0; - } return reader->payloadSizes[payloadSizesIndex]; } diff --git a/kernel/SlippiNetwork.c b/kernel/SlippiNetwork.c index 4a37a6c6..9e99169d 100644 --- a/kernel/SlippiNetwork.c +++ b/kernel/SlippiNetwork.c @@ -66,7 +66,6 @@ s32 SlippiNetworkInit() 0x78); thread_continue(SlippiNetwork_Thread); SlippiServerStarted = 1; - ppc_msg("SERVER INIT OK\x00", 15); return 0; } @@ -121,7 +120,6 @@ void listenForClient() dbgprintf("[TCP_NODELAY] Client setsockopt result: %d\r\n", optRes); dbgprintf("Client connection detected\r\n"); - ppc_msg("CLIENT OK\x00", 10); client_alive_ts = read32(HW_TIMER); } else { // dbgprintf("Client sock accept failure: %d\r\n", client_sock); @@ -146,7 +144,6 @@ void hangUpConnection() { close(top_fd, client_sock); client_sock = -1; reset_broadcast_timer(); - ppc_msg("CLIENT HUP\x00", 11); } /* handleFileTransfer() @@ -163,10 +160,10 @@ static SlpGameReader reader; s32 handleFileTransfer() { int status = getConnectionStatus(); - if (status != CONN_STATUS_CONNECTED) { - // Do nothing if we aren't connected to a client + + // Do nothing if we aren't connected to a client + if (status != CONN_STATUS_CONNECTED) return 0; - } SlpMemError err = SlippiMemoryRead(&reader, readBuf, READ_BUF_SIZE, memReadPos); if (err) @@ -231,17 +228,14 @@ static char alive_msg[] __attribute__((aligned(32))) = "HELO"; s32 checkAlive(void) { int status = getConnectionStatus(); - if (status != CONN_STATUS_CONNECTED) { - // Do nothing if we aren't connected to a client - // the handleFileTransfer could sometimes cause a disconnect + + // Do nothing if we aren't connected to a client + if (status != CONN_STATUS_CONNECTED) return 0; - } + // Only check alive if we haven't detected any communication if (TimerDiffSeconds(client_alive_ts) < 3) - { - // Only check alive if we haven't detected any communication return 0; - } s32 res; res = sendto(top_fd, client_sock, alive_msg, sizeof(alive_msg), 0); diff --git a/kernel/main.c b/kernel/main.c index 5cecbddd..a716fefd 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -41,7 +41,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "SlippiFileWriter.h" #include "SlippiNetwork.h" #include "SlippiNetworkBroadcast.h" -#include "SlippiDebug.h" #include "net.h" #include "diskio.h" @@ -477,7 +476,6 @@ int _main( int argc, char *argv[] ) // Initialize 8040a5a8 with a string to print w/ UnclePunch Gecko code if ( (TimerDiffSeconds(NCDTimer) > 3) && (SlippiDbgStringInit == 0) ) { - ppc_msg("SLIPPI BUP\x00", 11); SlippiDbgStringInit = 1; } diff --git a/kernel/net.c b/kernel/net.c index 5a9b3885..dd532e08 100644 --- a/kernel/net.c +++ b/kernel/net.c @@ -10,8 +10,6 @@ #include "debug.h" #include "net.h" -#include "SlippiDebug.h" - // File descriptor for the IOS socket driver, shared by all Slippi threads s32 top_fd __attribute__((aligned(32))); @@ -93,7 +91,6 @@ int NCDInit(void) dbgprintf("IOCTL_SO_GETHOSTID: 0x%x\n", current_ip_address); NetworkStarted = 1; - ppc_msg("NCDINIT OK\x00", 11); return 0; } @@ -231,9 +228,8 @@ s32 sendto(s32 fd, s32 socket, void *data, s32 len, u32 flags) */ u8 *message_buf = (u8*)heap_alloc_aligned(0, len, 32); - if (message_buf == NULL) { + if (message_buf == NULL) return -1; - } // I don't see how this won't totally kill performance memset(params, 0, sizeof(struct sendto_params));