diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-10-17 22:42:00 +0200 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-10-17 22:42:00 +0200 |
| commit | 2f100c78c0f12b56bcd73c203e6216d415d9f772 (patch) | |
| tree | 932b600b32b53a47727dc9a898417ec12793fac7 | |
| parent | 8770122c970eeedb145ee903e2243b7d4a18605b (diff) | |
| download | psn00bsdk-2f100c78c0f12b56bcd73c203e6216d415d9f772.tar.gz | |
Remove interrupt disabling calls in psxcd callback APIs
| -rw-r--r-- | examples/cdrom/cdxa/main.c | 2 | ||||
| -rw-r--r-- | libpsn00b/include/psxcd.h | 4 | ||||
| -rw-r--r-- | libpsn00b/psxcd/isofs.c | 19 | ||||
| -rw-r--r-- | libpsn00b/psxcd/psxcd.c | 11 | ||||
| -rw-r--r-- | libpsn00b/psxcd/psxcd_asm.s | 30 |
5 files changed, 32 insertions, 34 deletions
diff --git a/examples/cdrom/cdxa/main.c b/examples/cdrom/cdxa/main.c index 4921658..93cf01a 100644 --- a/examples/cdrom/cdxa/main.c +++ b/examples/cdrom/cdxa/main.c @@ -349,7 +349,9 @@ int main(int argc, const char* argv[]) xa_loc = file.pos; /* Hook XA callback function to CdReadyCallback (for auto stop/loop */ + EnterCriticalSection(); CdReadyCallback(xa_callback); + ExitCriticalSection(); /* Set CD mode for XA streaming (2x speed, send XA to SPU, enable filter */ i = CdlModeSpeed|CdlModeRT|CdlModeSF; diff --git a/libpsn00b/include/psxcd.h b/libpsn00b/include/psxcd.h index 429a439..0460f20 100644 --- a/libpsn00b/include/psxcd.h +++ b/libpsn00b/include/psxcd.h @@ -145,7 +145,7 @@ int CdControlF(uint8_t com, const void *param); int CdSync(int mode, uint8_t *result); uint32_t CdSyncCallback(CdlCB func); -long CdReadyCallback(CdlCB func); +int CdReadyCallback(CdlCB func); int CdGetSector(void *madr, int size); int CdGetSector2(void *madr, int size); int CdDataSync(int mode); @@ -168,7 +168,7 @@ void CdCloseDir(CdlDIR* dir); int CdGetVolumeLabel(char* label); -long* CdAutoPauseCallback(void(*func)()); +int* CdAutoPauseCallback(void(*func)()); int CdIsoError(); int CdLoadSession(int session); diff --git a/libpsn00b/psxcd/isofs.c b/libpsn00b/psxcd/isofs.c index 16e64ef..4ec701c 100644 --- a/libpsn00b/psxcd/isofs.c +++ b/libpsn00b/psxcd/isofs.c @@ -3,7 +3,7 @@ #include <stdlib.h> #include <string.h> #include <psxgpu.h> -#include <psxsio.h> +#include <psxapi.h> #include "psxcd.h" #include "isofs.h" @@ -795,8 +795,10 @@ int CdLoadSession(int session) } // Set search routine callback + EnterCriticalSection(); ready_oldcb = CdReadyCallback(_scan_callback); - + ExitCriticalSection(); + _ses_scanfound = 0; _ses_scancount = 0; _ses_scancomplete = 0; @@ -811,21 +813,28 @@ int CdLoadSession(int session) // Wait until scan complete while(!_ses_scancomplete); - + + EnterCriticalSection(); CdReadyCallback((void*)_ready_oldcb); - + ExitCriticalSection(); + if( !_ses_scanfound ) { _LOG("psxcd: CdLoadSession(): Did not find volume descriptor.\n"); _cd_iso_error = CdlIsoInvalidFs; + EnterCriticalSection(); CdReadyCallback((CdlCB)ready_oldcb); + ExitCriticalSection(); + return -1; } // Restore old callback if any + EnterCriticalSection(); CdReadyCallback((CdlCB)ready_oldcb); - + ExitCriticalSection(); + // Wait until CD-ROM has completely stopped reading, to get a consistent // fix of the CD-ROM pickup's current location do diff --git a/libpsn00b/psxcd/psxcd.c b/libpsn00b/psxcd/psxcd.c index f48542d..6730531 100644 --- a/libpsn00b/psxcd/psxcd.c +++ b/libpsn00b/psxcd/psxcd.c @@ -1,6 +1,7 @@ #include <stdint.h> #include <stdio.h> #include <psxgpu.h> +#include <psxapi.h> #include "psxcd.h" #define READ_TIMEOUT 600 // 10 seconds for NTSC @@ -293,8 +294,10 @@ int CdRead(int sectors, uint32_t *buf, int mode) _cd_read_counter = VSync(-1); // Set read callback + EnterCriticalSection(); _cd_read_oldcb = CdReadyCallback(_CdReadReadyCallback); - + ExitCriticalSection(); + // Set specified mode CdControl(CdlSetmode, (uint8_t*)&mode, 0); @@ -320,9 +323,11 @@ static void CdDoRetry() // Reset timeout _cd_read_counter = VSync(-1); - + + EnterCriticalSection(); CdReadyCallback(_CdReadReadyCallback); - + ExitCriticalSection(); + // Retry read CdControl(CdlSetloc, (void*)&_cd_last_setloc, 0); CdControl(CdlReadN, 0, (uint8_t*)_cd_read_result); diff --git a/libpsn00b/psxcd/psxcd_asm.s b/libpsn00b/psxcd/psxcd_asm.s index 16e17d8..c0a5312 100644 --- a/libpsn00b/psxcd/psxcd_asm.s +++ b/libpsn00b/psxcd/psxcd_asm.s @@ -413,17 +413,11 @@ CdAutoPauseCallback: lw $v0, 0($v1) la $v1, _cd_callback_int4 - - jal EnterCriticalSection - nop - + lw $a0, 4($sp) nop sw $a0, 0($v1) - - jal ExitCriticalSection - nop - + lw $ra, 0($sp) addiu $sp, 8 jr $ra @@ -443,17 +437,11 @@ CdReadyCallback: la $v1, _cd_callback_int1_data sw $v0, 8($sp) - - jal EnterCriticalSection - nop - + lw $a0, 4($sp) nop sw $a0, 0($v1) - - jal ExitCriticalSection - nop - + lw $ra, 0($sp) lw $v0, 8($sp) jr $ra @@ -472,17 +460,11 @@ CdSyncCallback: la $v1, _cd_sync_cb sw $v0, 8($sp) - - jal EnterCriticalSection - nop - + lw $a0, 4($sp) nop sw $a0, 0($v1) - - jal ExitCriticalSection - nop - + lw $ra, 0($sp) lw $v0, 8($sp) jr $ra |
