• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revisão4db90db17f3af41722981ee097579ceecb56088d (tree)
Hora2020-02-18 01:13:31
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Mensagem de Log

[VM][FMTOWNS][CDC][WIP] Improve CPU<->DMAC<->CDC<->CDC_SCSI<->TOWNS_CDROM routing, but still not works.

Mudança Sumário

Diff

--- a/source/src/vm/fmtowns/cdc.cpp
+++ b/source/src/vm/fmtowns/cdc.cpp
@@ -19,14 +19,15 @@ namespace FMTOWNS {
1919 #define CDDA_PLAYING 1
2020 #define CDDA_PAUSED 2
2121
22-#define EVENT_CDROM_SEL_ON 1
23-#define EVENT_CDROM_SEL_OFF 2
24-#define EVENT_CDROM_SEL_OFF2 3
25-#define EVENT_POLL_CMD 4
26-#define EVENT_ENQUEUE_CMD 5
27-#define EVENT_WAIT_REQ 6
28-#define EVENT_POLL_BUS_FREE 7
29-#define EVENT_CDC_RESET 8
22+#define EVENT_CDROM_SEL_ON 1
23+#define EVENT_CDROM_SEL_OFF 2
24+#define EVENT_CDROM_SEL_OFF2 3
25+#define EVENT_POLL_CMD 4
26+#define EVENT_ENQUEUE_CMD 5
27+#define EVENT_WAIT_REQ 6
28+#define EVENT_POLL_BUS_FREE 7
29+#define EVENT_CDC_RESET 8
30+#define EVENT_WAIT_CMD_REQ_OFF 9
3031
3132 void CDC::set_context_scsi_host(SCSI_HOST* dev)
3233 {
@@ -134,7 +135,7 @@ void CDC::initialize()
134135 event_poll_cmd = -1;
135136 event_enqueue_cmd = -1;
136137 event_wait_req = -1;
137-
138+ event_wait_cmd_req_off = -1;
138139 }
139140
140141 void CDC::release()
@@ -159,18 +160,20 @@ void CDC::enqueue_cmdqueue(int size, uint8_t data[])
159160 cmdqueue[n].cmd_write_ptr = 0;
160161 next_cmdqueue++;
161162 left_cmdqueue--;
162- start_poll_bus_free();
163+ start_poll_bus_free(0); // CDROM's pseudo SCSI ID is 0.
163164 }
164165 next_cmdqueue = next_cmdqueue & (CDC_COMMAND_QUEUE_LENGTH - 1);
165166 }
166167 return NULL;
167168 }
168169
169-void CDC::start_poll_bus_free()
170+void CDC::start_poll_bus_free(int unit)
170171 {
172+ unit = unit & 7;
171173 out_debug_log("POLLING BUS FREE");
172- d_scsi_host->write_dma_io8(0, 0x81);
173-// d_scsi_host->write_signal(SIG_SCSI_SEL, 1, 1);
174+ // SET SCSI ID to DATA BUS before RISING UP SEL.
175+ d_scsi_host->write_dma_io8(0, (0x80 | (1 << unit)));
176+ // d_scsi_host->write_signal(SIG_SCSI_SEL, 1, 1);
174177 register_event(this, EVENT_CDROM_SEL_ON, 15.0, true, &event_cdrom_sel);
175178 }
176179
@@ -190,7 +193,71 @@ void CDC::start_enqueue_command()
190193 register_event(this, EVENT_ENQUEUE_CMD, 3.0, true, &event_enqueue_cmd);
191194 }
192195 }
193-
196+
197+bool CDC::check_bus_free()
198+{
199+ if(!(busy_status) && !(scsi_req_status)) {
200+ return (!(cd_status) && !(msg_status) && !(io_status));
201+ }
202+ return false;
203+}
204+
205+bool CDC::check_command_phase()
206+{
207+ return ((cd_status) && !(msg_status) && !(io_status));
208+}
209+
210+bool CDC::check_data_in()
211+{
212+ return (!(cd_status) && !(msg_status) && (io_status));
213+}
214+
215+void CDC::select_unit_on()
216+{
217+ out_debug_log("BUS FREE->SEL ON");
218+ d_scsi_host->write_signal(SIG_SCSI_SEL, 1, 1);
219+ //d_scsi_host->write_dma_io8(0, 0x81); // Write SCSI ADDRESS 0
220+ if(event_cdrom_sel > -1) {
221+ cancel_event(this, event_cdrom_sel);
222+ event_cdrom_sel = -1;
223+ }
224+ register_event(this, EVENT_CDROM_SEL_OFF, 800.0, false, &event_cdrom_sel);
225+}
226+
227+void CDC::select_unit_off()
228+{
229+// d_scsi_host->write_dma_io8(0, 0x00); // Write SCSI ADDRESS 0
230+ register_event(this, EVENT_CDROM_SEL_OFF2, 100.0, false, &event_cdrom_sel);
231+}
232+
233+void CDC::select_unit_off2()
234+{
235+ out_debug_log("SEL ON ->SEL OFF");
236+ event_cdrom_sel = -1;
237+ d_scsi_host->write_signal(SIG_SCSI_SEL, 0, 1);
238+ event_cdrom_sel = -1;
239+ start_poll_cmd_phase();
240+}
241+
242+
243+void CDC::prologue_command_phase()
244+{
245+ if(check_command_phase()) {
246+ out_debug_log("COMMAND PHASE");
247+ accept_command = true;
248+ cancel_event(this, event_poll_cmd);
249+ event_poll_cmd = -1;
250+ if(event_enqueue_cmd > -1) {
251+ cancel_event(this, event_enqueue_cmd);
252+ }
253+ if(left_cmdqueue < CDC_COMMAND_QUEUE_LENGTH) {
254+// d_scsi_host->write_signal(SIG_SCSI_SEL, 1, 1);
255+ start_enqueue_command();
256+ }
257+
258+ }
259+}
260+
194261 void CDC::event_callback(int id, int error)
195262 {
196263 switch(id) {
@@ -198,40 +265,19 @@ void CDC::event_callback(int id, int error)
198265 d_scsi_host->write_signal(SIG_SCSI_RST, 0, 1);
199266 break;
200267 case EVENT_CDROM_SEL_ON:
201- if(!(busy_status) && !(scsi_req_status) &&
202- !(cd_status) && !(msg_status) && !(io_status)) { // BUS FREE
203- out_debug_log("BUS FREE->SEL ON");
204- d_scsi_host->write_signal(SIG_SCSI_SEL, 1, 1);
205- //d_scsi_host->write_dma_io8(0, 0x81); // Write SCSI ADDRESS 0
206- cancel_event(this, event_cdrom_sel);
207- event_cdrom_sel = -1;
208- register_event(this, EVENT_CDROM_SEL_OFF, 800.0, false, &event_cdrom_sel);
268+ if(check_bus_free()) {
269+ select_unit_on();
209270 }
210271 break;
211272 case EVENT_CDROM_SEL_OFF:
212- d_scsi_host->write_dma_io8(0, 0x00); // Write SCSI ADDRESS 0
213- register_event(this, EVENT_CDROM_SEL_OFF2, 100.0, false, &event_cdrom_sel);
273+ select_unit_off();
214274 break;
215275 case EVENT_CDROM_SEL_OFF2:
216- out_debug_log("SEL ON ->SEL OFF");
217- event_cdrom_sel = -1;
218- d_scsi_host->write_signal(SIG_SCSI_SEL, 0, 1);
219- event_cdrom_sel = -1;
220- start_poll_cmd_phase();
276+ select_unit_off2();
221277 break;
222278 case EVENT_POLL_CMD:
223- if((scsi_req_status) && (cd_status) && !(msg_status) && !(io_status)) {
224- out_debug_log("COMMAND PHASE");
225- accept_command = true;
226- cancel_event(this, event_poll_cmd);
227- event_poll_cmd = -1;
228- if(event_enqueue_cmd > -1) {
229- cancel_event(this, event_enqueue_cmd);
230- }
231- if(left_cmdqueue < CDC_COMMAND_QUEUE_LENGTH) {
232-// d_scsi_host->write_signal(SIG_SCSI_SEL, 1, 1);
233- start_enqueue_command();
234- }
279+ if((scsi_req_status)) {
280+ prologue_command_phase();
235281 }
236282 break;
237283 case EVENT_ENQUEUE_CMD:
@@ -240,8 +286,24 @@ void CDC::event_callback(int id, int error)
240286 data_in_status = false;
241287 uint8_t val = cmdqueue[current_cmdqueue].command[cmdqueue[current_cmdqueue].cmd_write_ptr];
242288 d_scsi_host->write_dma_io8(0, val);
289+ d_scsi_host->write_signal(SIG_SCSI_ACK, 0, 1);
243290 cmdqueue[current_cmdqueue].cmd_write_ptr++;
244- if(cmdqueue[current_cmdqueue].cmd_write_ptr >= cmdqueue[current_cmdqueue].cmd_table_size) {
291+ if(event_wait_cmd_req_off > -1) {
292+ cancel_event(this, event_wait_cmd_req_off);
293+ event_wait_cmd_req_off = -1;
294+ }
295+ register_event(this, EVENT_WAIT_CMD_REQ_OFF, 6.0, true, &event_wait_cmd_req_off);
296+ }
297+ }
298+ break;
299+ case EVENT_WAIT_CMD_REQ_OFF:
300+ if(!(scsi_req_status)) {
301+ if(event_wait_cmd_req_off > -1) {
302+ cancel_event(this, event_wait_cmd_req_off);
303+ event_wait_cmd_req_off = -1;
304+ }
305+// d_scsi_host->write_signal(SIG_SCSI_ACK, 0, 1);
306+ if(cmdqueue[current_cmdqueue].cmd_write_ptr >= cmdqueue[current_cmdqueue].cmd_table_size) { // Write all data.
245307 accept_command = false;
246308 cancel_event(this, event_enqueue_cmd);
247309 event_enqueue_cmd = -1;
@@ -262,23 +324,24 @@ void CDC::event_callback(int id, int error)
262324 }
263325 current_cmdqueue++;
264326 current_cmdqueue = current_cmdqueue & (CDC_COMMAND_QUEUE_LENGTH - 1);
265-// d_scsi_host->write_signal(SIG_SCSI_SEL, 0, 1);
266- register_event(this, EVENT_WAIT_REQ, 6.0, true, &event_wait_req);
327+ d_scsi_host->write_signal(SIG_SCSI_ACK, 0, 1);
328+ register_event(this, EVENT_WAIT_REQ, 1.0, true, &event_wait_req);
329+ } else {
330+ // Continue
331+ if(event_enqueue_cmd > -1) {
332+ cancel_event(this, event_enqueue_cmd);
333+ event_enqueue_cmd = -1;
334+ }
335+ start_enqueue_command();
267336 }
268337 }
269- }
270- break;
271338 case EVENT_WAIT_REQ:
272- if(1/*(scsi_req_status)*/) {
339+ if((scsi_req_status)) {
340+#if 0
273341 if(!(cd_status) && !(msg_status) && (io_status)) { // DATA IN
274342 out_debug_log("DATA IN");
275343 data_in_status = true;
276344 if(!(pio_transfer) && (dma_transfer)) {
277- uint8_t val = d_scsi_host->read_dma_io8(0);
278- out_debug_log(_T("DATA IN/DMA DATA=%02X"), val);
279- d_dmac->write_signal(SIG_UPD71071_CH3, val, 0xff);
280-// data_in_status = false;
281- data_reg = val;
282345 // WAIT FOR DRQ, NOT EVENT.
283346 cancel_event(this, event_wait_req);
284347 event_wait_req = -1;
@@ -289,19 +352,23 @@ void CDC::event_callback(int id, int error)
289352 // cancel_event(this, event_wait_req);
290353 // event_wait_req = -1;
291354 }
292- } else if(((cd_status) && !(msg_status) && (io_status)) ||// STATUS
355+ } else
356+#endif
357+ if(((cd_status) && !(msg_status) && (io_status)) ||// STATUS
293358 ((cd_status) && (msg_status) && (io_status))) { // MSG IN
294359 data_in_status = true;
295360 if(!(pio_transfer) && (dma_transfer)) {
296- uint8_t val = d_scsi_host->read_dma_io8(0);
297- out_debug_log(_T("STATUS DATA=%02X"), val);
298- d_dmac->write_signal(SIG_UPD71071_CH3, val, 0xff);
299- data_reg = val;
361+ //uint8_t val = d_scsi_host->read_dma_io8(0);
362+ //out_debug_log(_T("STATUS DATA=%02X"), val);
363+ d_dmac->write_signal(SIG_UPD71071_CH3, 0xff, 0xff);
364+ //data_reg = val;
300365 // WAIT FOR DRQ, NOT EVENT.
301366 cancel_event(this, event_wait_req);
302367 event_wait_req = -1;
303368 } else if((pio_transfer) && !(dma_transfer)) {
304369 data_reg = d_scsi_host->read_dma_io8(0);
370+ out_debug_log(_T("STATUS DATA=%02X"), data_reg);
371+ d_scsi_host->write_signal(SIG_SCSI_ACK, 1, 1);
305372 // WAIT FOR DRQ, NOT EVENT.
306373 // cancel_event(this, event_wait_req);
307374 // event_wait_req = -1;
@@ -311,8 +378,8 @@ void CDC::event_callback(int id, int error)
311378 } else {
312379 // BUS FREE
313380 // d_scsi_host->write_signal(SIG_SCSI_SEL, 0, 1);
314- cancel_event(this, event_wait_req);
315- event_wait_req = -1;
381+// cancel_event(this, event_wait_req);
382+// event_wait_req = -1;
316383 // EOL
317384 }
318385 break;
@@ -326,7 +393,7 @@ void CDC::write_io8(uint32_t address, uint32_t data)
326393 * 04C4h : Parameter register
327394 * 04C6h : Transfer control register.
328395 */
329- out_debug_log(_T("WRITE I/O: ADDR=%04X DATA=%02X"), address, data);
396+// out_debug_log(_T("WRITE I/O: ADDR=%04X DATA=%02X"), address, data);
330397 switch(address & 0x0f) {
331398 case 0x00: // Master control register
332399 {
@@ -520,7 +587,7 @@ uint32_t CDC::read_io8(uint32_t address)
520587 val = data_reg;
521588 if((pio_transfer)) {
522589 data_reg = d_scsi_host->read_dma_io8(0);
523- out_debug_log(_T("PIO READ DATA=%02X"), val);
590+// out_debug_log(_T("PIO READ DATA=%02X"), val);
524591 }
525592 break;
526593 case 0xc: // Sub code status register
@@ -577,7 +644,7 @@ void CDC::read_cdrom(bool req_reply)
577644 __remain = lba2 - lba1;
578645 //seek_time = get_seek_time(lba1);
579646 uint8_t command[16] = {0};
580- command[0] = SCSI_CMD_READ10;
647+ command[0] = SCSI_CMD_READ12;
581648 command[1] = 0;
582649 command[2] = 0;
583650 command[3] = m1;
@@ -589,7 +656,7 @@ void CDC::read_cdrom(bool req_reply)
589656 command[8] = (uint8_t)((__remain / 0x100) & 0xff);
590657 command[9] = (uint8_t) (__remain % 0x100);
591658
592- enqueue_cmdqueue(10, command);
659+ enqueue_cmdqueue(12, command);
593660
594661 if(req_reply) {
595662 extra_status = 2;
@@ -902,15 +969,15 @@ void CDC::write_signal(int ch, uint32_t data, uint32_t mask)
902969 {
903970 switch(ch) {
904971 case SIG_TOWNS_CDC_DRQ:
905- out_debug_log(_T("SIG_TOWND_CDC_DRQ"));
972+// out_debug_log(_T("SIG_TOWNS_CDC_DRQ"));
906973 if((data & mask) != 0) {
907974 if((dma_transfer) ) {
908975 software_transfer_phase = false;
909- uint8_t val = d_scsi_host->read_dma_io8(0);
910- out_debug_log(_T("DRQ/DMA PTR=%d DATA=%02X"), val);
911- d_dmac->write_signal(SIG_UPD71071_CH3, val, 0xff);
912- data_reg = val;
913-// write_signals(&output_dma_line, val); // Indirect call do_dma().
976+ out_debug_log(_T("DRQ/DMA"));
977+ if((scsi_req_status) && (check_data_in())) {
978+ out_debug_log(_T("SEND DMAREQ to DMA3"));
979+ d_dmac->write_signal(SIG_UPD71071_CH3, 0xff, 0xff);
980+ }
914981 } else if((pio_transfer) ) {
915982 software_transfer_phase = true;
916983 } else {
@@ -958,11 +1025,11 @@ void CDC::write_signal(int ch, uint32_t data, uint32_t mask)
9581025 msg_status = ((data & mask) != 0);
9591026 break;
9601027 case SIG_TOWNS_CDC_REQ:
961- out_debug_log(_T("REQ %s"), ((data & mask) != 0) ? _T("ON") : _T("OFF"));
1028+// out_debug_log(_T("REQ %s"), ((data & mask) != 0) ? _T("ON") : _T("OFF"));
9621029 scsi_req_status = ((data & mask) != 0);
9631030 break;
9641031 case SIG_TOWNS_CDC_ACK:
965- out_debug_log(_T("ACK %s"), ((data & mask) != 0) ? _T("ON") : _T("OFF"));
1032+// out_debug_log(_T("ACK %s"), ((data & mask) != 0) ? _T("ON") : _T("OFF"));
9661033 ack_status = ((data & mask) != 0);
9671034 break;
9681035
@@ -1053,6 +1120,7 @@ bool CDC::process_state(FILEIO* state_fio, bool loading)
10531120 state_fio->StateValue(event_poll_cmd);
10541121 state_fio->StateValue(event_enqueue_cmd);
10551122 state_fio->StateValue(event_wait_req);
1123+ state_fio->StateValue(event_wait_cmd_req_off);
10561124
10571125 return true;
10581126
--- a/source/src/vm/fmtowns/cdc.h
+++ b/source/src/vm/fmtowns/cdc.h
@@ -86,6 +86,7 @@ protected:
8686 int event_poll_cmd;
8787 int event_enqueue_cmd;
8888 int event_wait_req;
89+ int event_wait_cmd_req_off;
8990
9091 virtual void read_cdrom(bool req_reply);
9192 virtual void stop_cdda(bool req_reply);
@@ -95,8 +96,18 @@ protected:
9596 virtual void write_status(uint8_t a, uint8_t b, uint8_t c, uint8_t d);
9697 virtual void enqueue_command_play(uint8_t cmd);
9798 virtual void enqueue_command_status(uint8_t cmd);
99+
100+ bool check_bus_free();
101+ bool check_command_phase();
102+ bool check_data_in();
103+ void select_unit_on();
104+ void select_unit_off();
105+ void select_unit_off2();
106+
107+ void prologue_command_phase();
108+
98109 void enqueue_cmdqueue(int size, uint8_t data[]);
99- void start_poll_bus_free();
110+ void start_poll_bus_free(int unit);
100111 void start_poll_cmd_phase();
101112 void start_enqueue_command();
102113
--- a/source/src/vm/fmtowns/fmtowns.cpp
+++ b/source/src/vm/fmtowns/fmtowns.cpp
@@ -308,8 +308,8 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
308308 dma->set_context_ch0(fdc);
309309 dma->set_context_ch1(scsi_host);
310310 //dma->set_context_ch2(printer);
311- dma->set_context_ch3(cdc);
312- //dma->set_context_ch3(cdc_scsi);
311+ //dma->set_context_ch3(cdc);
312+ dma->set_context_ch3(cdc_scsi);
313313 dma->set_context_child_dma(extra_dma);
314314
315315 floppy->set_context_fdc(fdc);
--- a/source/src/vm/fmtowns/towns_dmac.cpp
+++ b/source/src/vm/fmtowns/towns_dmac.cpp
@@ -20,7 +20,8 @@ void TOWNS_DMAC::reset()
2020
2121 void TOWNS_DMAC::write_io8(uint32_t addr, uint32_t data)
2222 {
23- if((addr & 0x0f) == 0x0c) out_debug_log("WRITE REG: %08X %08X", addr, data);
23+// if((addr & 0x0f) == 0x0c) out_debug_log("WRITE REG: %08X %08X", addr, data);
24+ out_debug_log("WRITE REG: %04X %02X", addr, data);
2425 switch(addr & 0x0f) {
2526 case 0x07:
2627 dma_high_address = (data & 0xff) << 24;
--- a/source/src/vm/fmtowns/towns_scsi_host.cpp
+++ b/source/src/vm/fmtowns/towns_scsi_host.cpp
@@ -102,7 +102,9 @@ uint32_t TOWNS_SCSI_HOST::read_dma_io16(uint32_t addr)
102102 return d.d;
103103 #else
104104 // out_debug_log(_T("READ DMA16"));
105- return SCSI_HOST::read_dma_io8(addr);
105+ uint8_t val = SCSI_HOST::read_dma_io8(addr);
106+ out_debug_log(_T("DMA READ8 DATA: %02X"), val);
107+ return val;
106108 #endif
107109 }
108110
--- a/source/src/vm/scsi_dev.cpp
+++ b/source/src/vm/scsi_dev.cpp
@@ -64,6 +64,7 @@ void SCSI_DEV::write_signal(int id, uint32_t data, uint32_t mask)
6464 switch(id) {
6565 case SIG_SCSI_DAT:
6666 data_bus = data & mask;
67+// out_debug_log(_T("DATA=%04X"), data_bus);
6768 break;
6869
6970 case SIG_SCSI_SEL:
@@ -161,7 +162,7 @@ void SCSI_DEV::write_signal(int id, uint32_t data, uint32_t mask)
161162 */
162163 bool prev_status = ack_status;
163164 ack_status = ((data & mask) != 0);
164-
165+// out_debug_log(_T("ACK=%s"), (ack_status) ? _T("ON") : _T("OFF"));
165166 if(phase == SCSI_PHASE_BUS_FREE) {
166167 // this device is not selected
167168 } else if(!prev_status & ack_status) {
Show on old repository browser