From 2525398b6e265a9d6f6bc336ccce6445a1283504 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Tue, 15 Feb 2022 15:53:18 +0100 Subject: [PATCH] SWIM3: add support for floppy DMA. --- devices/common/dmacore.h | 11 ++++++++++- devices/floppy/swim3.h | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/devices/common/dmacore.h b/devices/common/dmacore.h index 72bedb8..5737cd2 100644 --- a/devices/common/dmacore.h +++ b/devices/common/dmacore.h @@ -33,7 +33,16 @@ enum DmaPullResult : int { class DmaOutChannel { public: - virtual bool is_active() = 0; + virtual bool is_active() { return true; }; + virtual DmaPullResult pull_data(uint32_t req_len, uint32_t *avail_len, + uint8_t **p_data) = 0; +}; + +// Base class for bidirectional DMA channels. +class DmaBidirChannel { +public: + virtual bool is_active() { return true; }; + virtual int push_data(const char* src_ptr, int len) = 0; virtual DmaPullResult pull_data(uint32_t req_len, uint32_t *avail_len, uint8_t **p_data) = 0; }; diff --git a/devices/floppy/swim3.h b/devices/floppy/swim3.h index 2b5a154..05acf8e 100644 --- a/devices/floppy/swim3.h +++ b/devices/floppy/swim3.h @@ -24,6 +24,7 @@ along with this program. If not, see . #ifndef SWIM3_H #define SWIM3_H +#include #include #include #include @@ -78,6 +79,10 @@ public: uint8_t read(uint8_t reg_offset); void write(uint8_t reg_offset, uint8_t value); + void set_dma_channel(DmaBidirChannel *dma_ch) { + this->dma_ch = dma_ch; + }; + protected: void update_irq(); void start_stepping(); @@ -89,6 +94,8 @@ protected: private: std::unique_ptr int_drive; + DmaBidirChannel* dma_ch; + uint8_t setup_reg; uint8_t mode_reg; uint8_t error;