File tree 6 files changed +383
-186
lines changed
6 files changed +383
-186
lines changed Original file line number Diff line number Diff line change @@ -817,15 +817,18 @@ int main(int argc, char *argv[])
817
817
if (cpu6_halted ())
818
818
halt_system ();
819
819
/* Service DMA */
820
- if (hawk_dma == 1 ) {
821
- if (dma_read_cycle (hawk_read_next ()))
822
- hawk_dma_done ();
823
- }
824
- if (hawk_dma == 2 ) {
825
- if (dma_write_active ())
826
- hawk_write_next (dma_write_cycle ());
827
- else
828
- hawk_dma_done ();
820
+ if (hawk_dma ) {
821
+ while (dma_write_active ()) {
822
+ // Advance time to next scheduler event
823
+ int64_t next = scheduler_next ();
824
+ if (next == -1 ) {
825
+ fprintf (stderr , "DMA stalled\n" );
826
+ exit (-1 );
827
+ }
828
+ cpu_timestamp_ns = next ;
829
+ run_scheduler (cpu_timestamp_ns , trace & TRACE_SCHEDULER );
830
+ }
831
+ hawk_dma_done ();
829
832
}
830
833
/* Floppy controller command host to controller */
831
834
if (fd_dma == 1 ) {
Original file line number Diff line number Diff line change @@ -102,6 +102,17 @@ uint16_t cpu6_dma_count(void) {
102
102
return ~dma_count ;
103
103
}
104
104
105
+ void cpu6_dma_write (uint8_t byte ) {
106
+ /* DMA is done when it incs to 0 */
107
+ if (dma_enable == 0 || ++ dma_count == 0 ) {
108
+ dma_enable = 0 ;
109
+ return ;
110
+ }
111
+ if (dma_enable ) {
112
+ mem_write8 (dma_addr ++ , byte );
113
+ }
114
+ }
115
+
105
116
/*
106
117
* When packed into C, the flags live in the upper 4 bits of the low byte
107
118
*/
Original file line number Diff line number Diff line change @@ -50,3 +50,5 @@ extern void cpu_assert_irq(unsigned ipl);
50
50
extern void cpu_deassert_irq (unsigned ipl );
51
51
extern void advance_time (uint64_t nanoseconds );
52
52
extern uint16_t cpu6_dma_count (void );
53
+ extern void cpu6_dma_write (uint8_t );
54
+ extern uint8_t cpu6_dma_read (void );
You can’t perform that action at this time.
0 commit comments