From cd9253c9b8047edbe49792664e4759453848f318 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 20 Oct 2017 23:15:22 +0200 Subject: [PATCH] Start SCSI Command (Adaptec and BusLogic) and Start BIOS SCSI Command (Adaptec) controller commands now set the event the thread is waiting for to signal that it's time to stop waiting. --- src/scsi/scsi_aha154x.c | 5 +---- src/scsi/scsi_x54x.c | 18 +++++++++++++++++- src/scsi/scsi_x54x.h | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index e3c2ca3d5..e234da639 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -268,10 +268,7 @@ aha_fast_cmds(void *p, uint8_t cmd) if (cmd == CMD_BIOS_SCSI) { x54x_busy(1); dev->BIOSMailboxReq++; - -#if 0 - x54x_thread_start(dev); -#endif + x54x_set_wait_event(); x54x_busy(0); return 1; } diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index 926945ad1..417633e04 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -57,6 +57,8 @@ int busy; static volatile event_t *evt; +static volatile +event_t *wait_evt; static volatile event_t *wake_poll_thread; @@ -1318,7 +1320,7 @@ x54x_cmd_thread(void *priv) if ((dev->Status & STAT_INIT) || (!dev->MailboxInit && !dev->BIOSMailboxInit) || (!dev->MailboxReq && !dev->BIOSMailboxReq)) { /* If we did not get anything, wait a while. */ - thread_wait_event((event_t *) evt, 10); + thread_wait_event((event_t *) wait_evt, 10); scsi_mutex_wait(0); continue; @@ -1368,6 +1370,13 @@ x54x_is_busy(void) } +void +x54x_set_wait_event(void) +{ + thread_set_event((event_t *) wait_evt); +} + + static uint8_t x54x_in(uint16_t port, void *priv) { @@ -1537,6 +1546,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) if ((val == CMD_START_SCSI) && (dev->Command == 0xff)) { x54x_busy(1); dev->MailboxReq++; + x54x_set_wait_event(); x54x_log("Start SCSI command: "); x54x_busy(0); return; @@ -1969,6 +1979,7 @@ x54x_init(device_t *info) /* Create a waitable event. */ evt = thread_create_event(); + wait_evt = thread_create_event(); x54x_thread_start(dev); thread_wait_event((event_t *) thread_started, -1); @@ -2005,6 +2016,11 @@ x54x_close(void *priv) if (dev->ven_data) free(dev->ven_data); + if (wait_evt) { + thread_destroy_event((event_t *) evt); + evt = NULL; + } + if (evt) { thread_destroy_event((event_t *) evt); evt = NULL; diff --git a/src/scsi/scsi_x54x.h b/src/scsi/scsi_x54x.h index 86b1ffde0..9f850f162 100644 --- a/src/scsi/scsi_x54x.h +++ b/src/scsi/scsi_x54x.h @@ -494,6 +494,7 @@ typedef struct extern void x54x_reset_ctrl(x54x_t *dev, uint8_t Reset); extern void x54x_busy(uint8_t set); extern void x54x_thread_start(x54x_t *dev); +extern void x54x_set_wait_event(void); extern uint8_t x54x_is_busy(void); extern void x54x_buf_alloc(uint8_t id, uint8_t lun, int length); extern void x54x_buf_free(uint8_t id, uint8_t lun);