Merge pull request #4 from Mr-Wiseguy/usb-fix

Fixed usb library
This commit is contained in:
CrashOveride95
2021-04-16 17:48:34 -04:00
committed by GitHub
5 changed files with 29 additions and 42 deletions

View File

@@ -170,9 +170,6 @@ $(eval $(call validate-option,UNF,0 1))
ifeq ($(UNF),1) ifeq ($(UNF),1)
DEFINES += UNF=1 DEFINES += UNF=1
SRC_DIRS += src/usb SRC_DIRS += src/usb
ULTRALIB := ultra_d
else
ULTRALIB := ultra_rom
endif endif

View File

@@ -132,7 +132,7 @@ SECTIONS
BUILD_DIR/src/usb*.o(.text); BUILD_DIR/src/usb*.o(.text);
#endif #endif
BUILD_DIR/src/audio*.o(.text); BUILD_DIR/src/audio*.o(.text);
#if defined(ISVPRINT) || defined(UNF) #if defined(ISVPRINT)
*/libultra_d.a:*.o(.text); */libultra_d.a:*.o(.text);
#else #else
*/libultra_rom.a:*.o(.text); */libultra_rom.a:*.o(.text);
@@ -158,7 +158,7 @@ SECTIONS
#ifdef GZIP #ifdef GZIP
*/libz.a:*.o(.*data*); */libz.a:*.o(.*data*);
#endif #endif
#if defined(ISVPRINT) || defined(UNF) #if defined(ISVPRINT)
*/libultra_d.a:*.o(.*data*); */libultra_d.a:*.o(.*data*);
#else #else
*/libultra_rom.a:*.o(.*data*); */libultra_rom.a:*.o(.*data*);
@@ -178,7 +178,7 @@ SECTIONS
BUILD_DIR/src/usb*.o(.rodata*); BUILD_DIR/src/usb*.o(.rodata*);
#endif #endif
BUILD_DIR/src/audio*.o(.rodata*); BUILD_DIR/src/audio*.o(.rodata*);
#if defined(ISVPRINT) || defined(UNF) #if defined(ISVPRINT)
*/libultra_d.a:*.o(.*rodata*); */libultra_d.a:*.o(.*rodata*);
#else #else
*/libultra_rom.a:*.o(.*rodata*); */libultra_rom.a:*.o(.*rodata*);
@@ -208,7 +208,7 @@ SECTIONS
BUILD_DIR/src/gzip*.o(.bss*); BUILD_DIR/src/gzip*.o(.bss*);
#endif #endif
BUILD_DIR/src/audio*.o(.*bss*); BUILD_DIR/src/audio*.o(.*bss*);
#if defined(ISVPRINT) || defined(UNF) #if defined(ISVPRINT)
*/libultra_d.a:*.o(COMMON); */libultra_d.a:*.o(COMMON);
*/libultra_d.a:*.o(.scommon); */libultra_d.a:*.o(.scommon);
*/libultra_d.a:*.o(.*bss*); */libultra_d.a:*.o(.*bss*);

View File

@@ -17,6 +17,10 @@
#if defined(RNC1) || defined(RNC2) #if defined(RNC1) || defined(RNC2)
#include <rnc.h> #include <rnc.h>
#endif #endif
#ifdef UNF
#include "usb/usb.h"
#include "usb/debug.h"
#endif
// round up to the next multiple // round up to the next multiple

View File

@@ -9,8 +9,10 @@
#define DEBUG_MODE 1 // Enable/Disable debug mode #define DEBUG_MODE 1 // Enable/Disable debug mode
#define DEBUG_INIT_MSG 1 // Print a message when debug mode has initialized #define DEBUG_INIT_MSG 1 // Print a message when debug mode has initialized
#define USE_FAULTTHREAD 1 // Create a fault detection thread (libultra only) #define USE_FAULTTHREAD 1 // Create a fault detection thread (libultra only)
#define OVERWRITE_OSPRINT 1 // Replaces osSyncPrintf calls with debug_printf (libultra only) #define OVERWRITE_OSPRINT 0 // Replaces osSyncPrintf calls with debug_printf (libultra only)
#define MAX_COMMANDS 25 // The max amount of user defined commands possible #define MAX_COMMANDS 25 // The max amount of user defined commands possible
#define osSyncPrintf debug_printf // Temporary until libultra_d is linked instead
// Fault thread definitions (libultra only) // Fault thread definitions (libultra only)
#define FAULT_THREAD_ID 13 #define FAULT_THREAD_ID 13

View File

@@ -973,6 +973,15 @@ static void usb_everdrive_readdata(void* buff, u32 pi_address, u32 len)
#ifdef LIBDRAGON #ifdef LIBDRAGON
data_cache_hit_writeback_invalidate(buff, len); data_cache_hit_writeback_invalidate(buff, len);
disable_interrupts(); disable_interrupts();
// Write the data to the PI
usb_everdrive_wait_pidma();
IO_WRITE(PI_STATUS_REG, 3);
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_RAMADDRESS) = (u32)buff;
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_PIADDRESS) = pi_address;
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_WRITELENGTH) = len-1;
usb_everdrive_wait_pidma();
// Enable system interrupts
enable_interrupts();
#else #else
osInvalDCache(buff, len); osInvalDCache(buff, len);
#if USE_OSRAW #if USE_OSRAW
@@ -986,23 +995,6 @@ static void usb_everdrive_readdata(void* buff, u32 pi_address, u32 len)
(void)osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK); (void)osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);
#endif #endif
#endif #endif
// Write the data to the PI
usb_everdrive_wait_pidma();
IO_WRITE(PI_STATUS_REG, 3);
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_RAMADDRESS) = (u32)buff;
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_PIADDRESS) = pi_address;
#ifdef LIBDRAGON
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_WRITELENGTH) = len-1;
#else
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_READLENGTH) = len-1;
#endif
usb_everdrive_wait_pidma();
// Enable system interrupts
#ifdef LIBDRAGON
enable_interrupts();
#endif
} }
@@ -1036,6 +1028,15 @@ static void usb_everdrive_writedata(void* buff, u32 pi_address, u32 len)
#ifdef LIBDRAGON #ifdef LIBDRAGON
data_cache_hit_writeback(buff, len); data_cache_hit_writeback(buff, len);
disable_interrupts(); disable_interrupts();
// Write the data to the PI
usb_everdrive_wait_pidma();
IO_WRITE(PI_STATUS_REG, 3);
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_RAMADDRESS) = (u32)buff;
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_PIADDRESS) = pi_address;
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_READLENGTH) = len-1;
usb_everdrive_wait_pidma();
// Enable system interrupts
enable_interrupts();
#else #else
osWritebackDCache(buff, len); osWritebackDCache(buff, len);
#if USE_OSRAW #if USE_OSRAW
@@ -1049,23 +1050,6 @@ static void usb_everdrive_writedata(void* buff, u32 pi_address, u32 len)
(void)osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK); (void)osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);
#endif #endif
#endif #endif
// Write the data to the PI
usb_everdrive_wait_pidma();
IO_WRITE(PI_STATUS_REG, 3);
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_RAMADDRESS) = (u32)buff;
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_PIADDRESS) = pi_address;
#ifdef LIBDRAGON
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_READLENGTH) = len-1;
#else
*(volatile unsigned long *)(N64_PI_ADDRESS + N64_PI_WRITELENGTH) = len-1;
#endif
usb_everdrive_wait_pidma();
// Enable system interrupts
#ifdef LIBDRAGON
enable_interrupts();
#endif
} }