2021-10-04 21:46:19 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2022-10-20 11:20:06 +00:00
|
|
|
Copyright (C) 2018-22 divingkatae and maximum
|
2021-10-04 21:46:19 +00:00
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file Core definitions for direct memory access (DMA) emulation. */
|
|
|
|
|
|
|
|
#ifndef DMA_CORE_H
|
|
|
|
#define DMA_CORE_H
|
|
|
|
|
2024-03-11 06:01:43 +00:00
|
|
|
#include <cstdint>
|
2023-07-27 18:30:30 +00:00
|
|
|
#include <string>
|
2021-10-04 21:46:19 +00:00
|
|
|
|
|
|
|
enum DmaPullResult : int {
|
|
|
|
MoreData, // data source has more data to be pulled
|
|
|
|
NoMoreData, // data source has no more data to be pulled
|
|
|
|
};
|
|
|
|
|
|
|
|
class DmaOutChannel {
|
|
|
|
public:
|
2023-07-27 18:30:30 +00:00
|
|
|
DmaOutChannel(std::string name) { this->name = name; };
|
|
|
|
|
2023-11-22 04:36:43 +00:00
|
|
|
virtual bool is_out_active() { return true; };
|
2022-02-15 14:53:18 +00:00
|
|
|
virtual DmaPullResult pull_data(uint32_t req_len, uint32_t *avail_len,
|
|
|
|
uint8_t **p_data) = 0;
|
2023-07-27 18:30:30 +00:00
|
|
|
|
|
|
|
std::string get_name(void) { return this->name; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name;
|
2022-02-15 14:53:18 +00:00
|
|
|
};
|
|
|
|
|
2022-10-20 11:20:06 +00:00
|
|
|
class DmaInChannel {
|
2022-02-15 14:53:18 +00:00
|
|
|
public:
|
2023-07-27 18:30:30 +00:00
|
|
|
DmaInChannel(std::string name) { this->name = name; };
|
|
|
|
|
2023-11-22 04:36:43 +00:00
|
|
|
virtual bool is_in_active() { return true; };
|
|
|
|
virtual int push_data(const char* src_ptr, int len) = 0;
|
|
|
|
|
2023-07-27 18:30:30 +00:00
|
|
|
std::string get_name(void) { return this->name; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name;
|
2022-10-20 11:20:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Base class for bidirectional DMA channels.
|
|
|
|
class DmaBidirChannel : public DmaOutChannel, public DmaInChannel {
|
2023-07-27 18:30:30 +00:00
|
|
|
public:
|
|
|
|
DmaBidirChannel(std::string name) : DmaOutChannel(name + " Out"),
|
|
|
|
DmaInChannel(name + std::string(" In")) { this->name = name; };
|
|
|
|
|
|
|
|
std::string get_name(void) { return this->name; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name;
|
2021-10-04 21:46:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DMA_CORE_H
|