[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 37/88] esp.c: introduce esp_get_phase() function
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 37/88] esp.c: introduce esp_get_phase() function |
Date: |
Fri, 12 Jan 2024 12:53:29 +0000 |
Make use of this new function in all places where the SCSI phase bits are
manually masked from the ESP_RSTAT register.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 16cb6c72fd..de8d98082a 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -196,6 +196,11 @@ static void esp_set_phase(ESPState *s, uint8_t phase)
trace_esp_set_phase(esp_phase_names[phase]);
}
+static uint8_t esp_get_phase(ESPState *s)
+{
+ return s->rregs[ESP_RSTAT] & 7;
+}
+
static uint8_t esp_pdma_read(ESPState *s)
{
uint8_t val;
@@ -537,7 +542,7 @@ static void esp_dma_ti_check(ESPState *s)
static void do_dma_pdma_cb(ESPState *s)
{
- int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO);
+ int to_device = (esp_get_phase(s) == STAT_DO);
uint8_t buf[ESP_CMDFIFO_SZ];
int len;
uint32_t n;
@@ -554,7 +559,7 @@ static void do_dma_pdma_cb(ESPState *s)
}
s->ti_size = 0;
- if ((s->rregs[ESP_RSTAT] & 7) == STAT_CD) {
+ if (esp_get_phase(s) == STAT_CD) {
/* No command received */
if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) {
return;
@@ -621,7 +626,7 @@ static void do_dma_pdma_cb(ESPState *s)
static void esp_do_dma(ESPState *s)
{
uint32_t len, cmdlen;
- int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO);
+ int to_device = (esp_get_phase(s) == STAT_DO);
uint8_t buf[ESP_CMDFIFO_SZ];
int n;
@@ -654,7 +659,7 @@ static void esp_do_dma(ESPState *s)
}
trace_esp_handle_ti_cmd(cmdlen);
s->ti_size = 0;
- if ((s->rregs[ESP_RSTAT] & 7) == STAT_CD) {
+ if (esp_get_phase(s) == STAT_CD) {
/* No command received */
if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) {
return;
@@ -762,7 +767,7 @@ static void esp_do_dma(ESPState *s)
static void esp_do_nodma(ESPState *s)
{
- int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO);
+ int to_device = (esp_get_phase(s) == STAT_DO);
uint8_t buf[ESP_FIFO_SZ];
uint32_t cmdlen;
int len, n;
@@ -776,7 +781,7 @@ static void esp_do_nodma(ESPState *s)
cmdlen = fifo8_num_used(&s->cmdfifo);
trace_esp_handle_ti_cmd(cmdlen);
s->ti_size = 0;
- if ((s->rregs[ESP_RSTAT] & 7) == STAT_CD) {
+ if (esp_get_phase(s) == STAT_CD) {
/* No command received */
if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) {
return;
@@ -856,7 +861,7 @@ static void esp_pdma_cb(ESPState *s)
void esp_command_complete(SCSIRequest *req, size_t resid)
{
ESPState *s = req->hba_private;
- int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO);
+ int to_device = (esp_get_phase(s) == STAT_DO);
trace_esp_command_complete();
@@ -909,7 +914,7 @@ void esp_command_complete(SCSIRequest *req, size_t resid)
void esp_transfer_data(SCSIRequest *req, uint32_t len)
{
ESPState *s = req->hba_private;
- int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO);
+ int to_device = (esp_get_phase(s) == STAT_DO);
uint32_t dmalen = esp_get_tc(s);
assert(!s->do_cmd);
@@ -1103,7 +1108,7 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr)
qemu_log_mask(LOG_UNIMP, "esp: PIO data read not implemented\n");
s->rregs[ESP_FIFO] = 0;
} else {
- if ((s->rregs[ESP_RSTAT] & 0x7) == STAT_DI) {
+ if (esp_get_phase(s) == STAT_DI) {
if (s->ti_size) {
esp_do_nodma(s);
} else {
--
2.39.2
- [PATCH 27/88] esp.c: update end of transfer logic at the end of esp_transfer_data(), (continued)
- [PATCH 27/88] esp.c: update end of transfer logic at the end of esp_transfer_data(), Mark Cave-Ayland, 2024/01/12
- [PATCH 28/88] esp.c: consolidate async_len and TC == 0 checks in do_dma_pdma_cb() and esp_do_dma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 30/88] esp.c: move TC and FIFO check logic into esp_dma_done(), Mark Cave-Ayland, 2024/01/12
- [PATCH 29/88] esp.c: fix premature end of phase logic esp_command_complete, Mark Cave-Ayland, 2024/01/12
- [PATCH 34/88] esp.c: update esp_do_dma() bypass if async_len is zero to include non-zero transfer check, Mark Cave-Ayland, 2024/01/12
- [PATCH 35/88] esp.c: move end of SCSI transfer check after TC adjustment in do_dma_pdma_cb(), Mark Cave-Ayland, 2024/01/12
- [PATCH 33/88] esp.c: copy logic for do_cmd transfers from do_dma_pdma_cb() to esp_do_dma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 31/88] esp.c: rename esp_dma_done() to esp_dma_ti_check(), Mark Cave-Ayland, 2024/01/12
- [PATCH 32/88] esp.c: copy PDMA logic for transfers to device from do_dma_pdma_cb() to esp_do_dma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 36/88] esp.c: remove s_without_satn_pdma_cb() PDMA callback, Mark Cave-Ayland, 2024/01/12
- [PATCH 37/88] esp.c: introduce esp_get_phase() function,
Mark Cave-Ayland <=
- [PATCH 38/88] esp.c: convert esp_do_dma() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/01/12
- [PATCH 39/88] esp.c: convert do_dma_pdma_db() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/01/12
- [PATCH 42/88] esp.c: convert do_dma_pdma_cb() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/01/12
- [PATCH 43/88] esp.c: convert esp_do_nodma() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/01/12
- [PATCH 40/88] esp.c: convert esp_do_nodma() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/01/12
- [PATCH 41/88] esp.c: convert esp_do_dma() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/01/12
- [PATCH 45/88] esp.c: remove do_cmd from ESPState, Mark Cave-Ayland, 2024/01/12
- [PATCH 47/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in do_dma_pdma_cb(), Mark Cave-Ayland, 2024/01/12
- [PATCH 44/88] esp.c: convert esp_reg_write() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/01/12
- [PATCH 49/88] esp.c: move CMD_SELATN end of message phase detection to esp_do_dma() and do_dma_pdma_cb(), Mark Cave-Ayland, 2024/01/12