Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
Testing/
.cache/
.cache/
doc/doxygen/
39 changes: 39 additions & 0 deletions EMUAPI
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
mfdemu/plugin/api.{hpp,cpp}
-> General API implementation
- Accessors to System, CPU, Config, etc.
- Plugin load method, returns devices
mfdemu/plugin/config.{hpp,cpp}
-> Config
mfdemu/plugin/device.{hpp,cpp}
-> PluginDevice
public:
::LoadDevice(API &api) virtual
-> PluginAioDevice : AioDevice, PluginDevice
protected:
::read(u16 addr) -> u16
::write(u16 addr, u16 val)
-> PluginGioDevice : GioDevice
protected:
::read(u16 addr) -> u16
::write(u16 addr, u8 val, bool low)
mfdemu/plugin/internal/
loaded_mri
-> Contains the MRI given to the emulator, AIO Device
zero_AIO
zero_GIO
-> Initialised with 0, ignores writes if configured appropriately

/* overriden from mfdemu::plugin::PluginAioDevice */
ABC16::LoadDevice(API &api) {
ABC16Cfg cfg;
cfg.load(api.getConfig().getDevice("mfd_abc16"));
}

EMU
|
ABC16
|
+--------------+------------+
| | |
internal:zero internal:loaded_mri bmg

6 changes: 3 additions & 3 deletions asm/doxyfile → doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "MCFG/2"
PROJECT_NAME = "MFD0816"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand Down Expand Up @@ -864,7 +864,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = mfdasm
INPUT = asm/ emu/ shared/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -1061,7 +1061,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.

USE_MDFILE_AS_MAINPAGE = ./README.md
USE_MDFILE_AS_MAINPAGE =

#---------------------------------------------------------------------------
# Configuration options related to source browsing
Expand Down
172 changes: 172 additions & 0 deletions emu/api_include/mfdemu_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/*
* Copyright (C) 2024 Marie Eckert
*
* 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 mfdemu_api.h
* @brief Type and Function-Prototype definitions for the MFDEMU device plugin
* API.
*/

#ifndef __MFDEMU_API_H
#define __MFDEMU_API_H

#ifdef __cplusplus
namespace mfdemu::api {
#endif

#include <stdint.h>

#define MFDEMU_DEVICE_API_H_VERSION 0

extern uint32_t mfdemuApiVersion;

/**
* @brief Used to represent the current state of CPU pins relevant for Address
* Bus devices.
*/
typedef struct {
/**
* @brief The current state of the AIO pins. This value may be modified, but
* modifications are ignored unless the CPU is currently at the T3 stage of
* an Address Bus read.
*/
u16 busPins;

/**
* @brief The current value of the AMS pin.
*/
u8 mode;
u8 pad;
} AioState;

/**
* @brief Used to represent the current state of CPU pins relevant for I/O Bus
* devices.
*/
typedef struct {
/**
* @brief The current state of the GIO pins. This value may be modified, but
* modifications are ignored unless the CPU is currently at the T3 or T4
* stage of an I/O Bus read.
*/
u8 busPins;

/**
* @brief The current value of the GMS pin.
*/
u8 mode;
u16 pad;
} GioState;

/**
* @brief The possible datatypes contained within a MFDEMU configuration.
*/
typedef enum {
String,

/**
* @brief Corresponds to the C++ default bool type.
*/
Boolean,

/**
* @brief Corresponds to the systems default character type.
*/
Character,

/**
* @brief Corresponds to ínt64_t.
*/
Integer,

/**
* @brief Corresponds to uint64_t.
*/
Unsigned,

/**
* @brief Corresponds to 32-bit floats.
*/
Float,

/**
* @brief Corresponds to the native pointer type. If the pointer is valid,
* the underlying value's type corresponds to the type used for JSON objects
* by the used JSON implementation.
*/
Object,
} ConfigDataType;

/**
* @brief A result from a config inquiry.
*/
typedef struct {
ConfigDataType type;

/**
* @brief If value is nullptr, the result is invalid.
*/
void *value;
} ConfigValueResult;

/**
* @defgroup EmuApi-EmuCalls Functions called by the Emulator.
* @{
*/

/**
* @brief Used to signal that the CLK pin connected to the address bus device has been
* pulled high.
*/
void AioClk(AioState *state);

/**
* @brief Used to signal that the CLK pin connected to the i/o bus device has been
* pulled high.
*/
void GioClk(GioState *state);

/**
* @brief Used to initialise a device plugin.
* @param handle The handle to the API.
*/
void DeviceInit(APIHandle handle);

/** @} */
/**
* @defgroup EmuApi-DevCalls Functions called by Devices.
* @{
*/

/**
* @brief Used to get a value from the emulators configuration.
* @param handle The API Handle.
* @param nameLength The name of the proceeding name string.
* @param name The name of the value to get.
* @param baseObject Optionally set the object from which the value should be
* acquired. Only pointers returned from this function with the associated
* `ConfigDataType` of `Object` can possibly be valid.
*/
ConfigValueResult
GetConfigValue(APIHandle handle, size_t nameLength, const char *name, void *baseObject = nullptr);

/** @} */

#ifdef __cplusplus
}
#endif
#endif
48 changes: 48 additions & 0 deletions emu/mfdemu/plugin/api.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2025 Marie Eckert
*
* 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/>.
*/

#ifndef MFDEMU_PLUGIN_API_HPP
#define MFDEMU_PLUGIN_API_HPP

#include <optional>

#include <mfdemu/impl/bus/aio_device.hpp>
#include <mfdemu/impl/bus/gio_device.hpp>

namespace mfdemu::plugin {

/* Dummy declarations because the config class doesn't exist yet */
class Config {};
class PluginDevice {};
class PluginAioDevice : public PluginDevice, public impl::AioDevice {};
class PluginGioDevice : public PluginDevice, public impl::GioDevice {};

class PluginAPI {
public:
const Config &getConfig() const;

std::optional<std::shared_ptr<PluginDevice>> loadPluginDevice(const std::string &path);

private:
Config m_cfg;
std::shared_ptr<PluginAioDevice> m_attachedAddressDevice;
std::shared_ptr<PluginGioDevice> m_attachedGioDevice;
};

} // namespace mfdemu::plugin

#endif
61 changes: 61 additions & 0 deletions mfd-c16..json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"devices": {
"mfd0816": {
"address_device": "mfd_abc16.so",
"gio_device": "internal:zero"
},
"internal:loaded_mri": {
"available_sections": [
{
"start": "0x0000",
"end": "0x4fff"
},
{
"start": "0xfffd",
"end": "0xffff"
}
]
},
"mfd_abc16": {
"devices": [
{
"name": "program",
"access": "r",
"device": "internal:loaded_mri",
"start": "0x0000",
"end": "0x4fff",
"normalize": false
},
{
"name": "ram0",
"access": "rw",
"device": "internal:zero",
"start": "0x5000",
"end": "0x7fff"
},
{
"name": "mfd_bmg",
"access": "rw",
"device": "mfd_bmg.so",
"start": "0x8000",
"end": "0x8fff"
},
{
"name": "ram1",
"access": "rw",
"device": "internal:zero",
"start": "0x9000",
"end": "0xfffc"
},
{
"name": "vectors",
"access": "r",
"device": "internal:zero",
"start": "0xfffd",
"end": "0xffff",
"normalize": false
}
]
}
}
}