esp.c (2c1017bf) esp.c (743d8736)
1/*
2 * QEMU ESP/NCR53C9x emulation
3 *
4 * Copyright (c) 2005-2006 Fabrice Bellard
5 * Copyright (c) 2012 Herve Poussineau
6 * Copyright (c) 2023 Mark Cave-Ayland
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy

--- 110 unchanged lines hidden (view full) ---

119 if (req == s->current_req) {
120 scsi_req_unref(s->current_req);
121 s->current_req = NULL;
122 s->current_dev = NULL;
123 s->async_len = 0;
124 }
125}
126
1/*
2 * QEMU ESP/NCR53C9x emulation
3 *
4 * Copyright (c) 2005-2006 Fabrice Bellard
5 * Copyright (c) 2012 Herve Poussineau
6 * Copyright (c) 2023 Mark Cave-Ayland
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy

--- 110 unchanged lines hidden (view full) ---

119 if (req == s->current_req) {
120 scsi_req_unref(s->current_req);
121 s->current_req = NULL;
122 s->current_dev = NULL;
123 s->async_len = 0;
124 }
125}
126
127static void esp_update_drq(ESPState *s)
128{
129 bool to_device;
130
131 switch (esp_get_phase(s)) {
132 case STAT_MO:
133 case STAT_CD:
134 case STAT_DO:
135 to_device = true;
136 break;
137
138 case STAT_DI:
139 case STAT_ST:
140 case STAT_MI:
141 to_device = false;
142 break;
143
144 default:
145 return;
146 }
147
148 if (s->dma) {
149 /* DMA request so update DRQ according to transfer direction */
150 if (to_device) {
151 if (fifo8_num_free(&s->fifo) < 2) {
152 esp_lower_drq(s);
153 } else {
154 esp_raise_drq(s);
155 }
156 } else {
157 if (fifo8_num_used(&s->fifo) < 2) {
158 esp_lower_drq(s);
159 } else {
160 esp_raise_drq(s);
161 }
162 }
163 } else {
164 /* Not a DMA request */
165 esp_lower_drq(s);
166 }
167}
168
127static void esp_fifo_push(ESPState *s, uint8_t val)
128{
129 if (fifo8_num_used(&s->fifo) == s->fifo.capacity) {
130 trace_esp_error_fifo_overrun();
131 return;
132 }
133
134 fifo8_push(&s->fifo, val);
135}
136
137static void esp_fifo_push_buf(ESPState *s, uint8_t *buf, int len)
138{
139 fifo8_push_all(&s->fifo, buf, len);
169static void esp_fifo_push(ESPState *s, uint8_t val)
170{
171 if (fifo8_num_used(&s->fifo) == s->fifo.capacity) {
172 trace_esp_error_fifo_overrun();
173 return;
174 }
175
176 fifo8_push(&s->fifo, val);
177}
178
179static void esp_fifo_push_buf(ESPState *s, uint8_t *buf, int len)
180{
181 fifo8_push_all(&s->fifo, buf, len);
182 esp_update_drq(s);
140}
141
142static uint8_t esp_fifo_pop(ESPState *s)
143{
144 if (fifo8_is_empty(&s->fifo)) {
145 return 0;
146 }
147

--- 27 unchanged lines hidden (view full) ---

175 n += n2;
176 }
177
178 return n;
179}
180
181static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen)
182{
183}
184
185static uint8_t esp_fifo_pop(ESPState *s)
186{
187 if (fifo8_is_empty(&s->fifo)) {
188 return 0;
189 }
190

--- 27 unchanged lines hidden (view full) ---

218 n += n2;
219 }
220
221 return n;
222}
223
224static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen)
225{
183 return esp_fifo8_pop_buf(&s->fifo, dest, maxlen);
226 uint32_t len = esp_fifo8_pop_buf(&s->fifo, dest, maxlen);
227
228 esp_update_drq(s);
229 return len;
184}
185
186static uint32_t esp_get_tc(ESPState *s)
187{
188 uint32_t dmalen;
189
190 dmalen = s->rregs[ESP_TCLO];
191 dmalen |= s->rregs[ESP_TCMID] << 8;

--- 1425 unchanged lines hidden ---
230}
231
232static uint32_t esp_get_tc(ESPState *s)
233{
234 uint32_t dmalen;
235
236 dmalen = s->rregs[ESP_TCLO];
237 dmalen |= s->rregs[ESP_TCMID] << 8;

--- 1425 unchanged lines hidden ---