@@ -60,10 +60,6 @@ mutex_t _g1_ata_mutex = MUTEX_INITIALIZER;
6060
6161/* Command handling */
6262static gdc_cmd_hnd_t cmd_hnd = 0 ;
63- static semaphore_t cmd_done = SEM_INITIALIZER (0 );
64- static bool cmd_in_progress = false;
65- static uint64_t cmd_begin_time = 0 ;
66- static uint32_t cmd_timeout = 0 ;
6763static int cmd_response = NO_ACTIVE ;
6864static int32_t cmd_status [4 ] = {
6965 0 , /* Error code 1 */
@@ -247,7 +243,6 @@ int cdrom_abort_cmd(uint32_t timeout, bool abort_dma) {
247243 irq_restore (old );
248244 return ERR_NO_ACTIVE ;
249245 }
250- cmd_in_progress = false;
251246
252247 if (abort_dma && dma_in_progress ) {
253248 dma_in_progress = false;
@@ -413,11 +408,6 @@ static int cdrom_read_sectors_dma_irq(void *params) {
413408 cdrom_poll (& cmd_hnd , 0 , cdrom_check_ready );
414409
415410 if (cmd_response == PROCESSING ) {
416- cmd_timeout = 0 ;
417- /* Poll syscalls in vblank IRQ in case an unexpected error occurs
418- while we wait DMA IRQ. */
419- cmd_in_progress = true;
420-
421411 /* Wait DMA is finished or command failed. */
422412 sem_wait (& dma_done );
423413
@@ -761,32 +751,19 @@ static void cdrom_vblank(uint32 evt, void *data) {
761751 (void )evt ;
762752 (void )data ;
763753
764- if (!cmd_in_progress ) {
765- return ;
766- }
767-
768- syscall_gdrom_exec_server ();
769- cmd_response = syscall_gdrom_check_command (cmd_hnd , cmd_status );
770-
771- if (cmd_response != PROCESSING && cmd_response != BUSY ) {
772- cmd_in_progress = false;
754+ if (dma_in_progress ) {
755+ syscall_gdrom_exec_server ();
756+ cmd_response = syscall_gdrom_check_command (cmd_hnd , cmd_status );
773757
774- if (dma_in_progress ) {
758+ if (cmd_response != PROCESSING && cmd_response != BUSY && cmd_response != STREAMING ) {
775759 dma_in_progress = false;
776760
777761 if (dma_blocking ) {
778762 dma_blocking = false;
779763 sem_signal (& dma_done );
764+ thd_schedule (1 , 0 );
780765 }
781766 }
782- else {
783- sem_signal (& cmd_done );
784- }
785- thd_schedule (1 , 0 );
786- }
787- else if (cmd_timeout && (timer_ms_gettime64 () - cmd_begin_time ) >= cmd_timeout ) {
788- sem_signal (& cmd_done );
789- thd_schedule (1 , 0 );
790767 }
791768}
792769
@@ -796,11 +773,9 @@ static void g1_dma_irq_hnd(uint32_t code, void *data) {
796773 if (dma_in_progress ) {
797774 dma_in_progress = false;
798775
799- if (cmd_in_progress ) {
800- cmd_in_progress = false;
801- syscall_gdrom_exec_server ();
802- cmd_response = syscall_gdrom_check_command (cmd_hnd , cmd_status );
803- }
776+ syscall_gdrom_exec_server ();
777+ cmd_response = syscall_gdrom_check_command (cmd_hnd , cmd_status );
778+
804779 if (dma_blocking ) {
805780 dma_blocking = false;
806781 sem_signal (& dma_done );
0 commit comments