diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6845c6a..6f48636 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,7 +79,8 @@ add_subdirectory(thirdparty/cubeb EXCLUDE_FROM_ALL)
set(CLI11_ROOT ${PROJECT_SOURCE_DIR}/thirdparty/CLI11)
-include_directories("${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/devices"
+include_directories("${PROJECT_SOURCE_DIR}"
+ "${PROJECT_SOURCE_DIR}/devices"
"${PROJECT_SOURCE_DIR}/cpu/ppc"
"${PROJECT_SOURCE_DIR}/debugger"
"${PROJECT_SOURCE_DIR}/utils"
diff --git a/cpu/ppc/ppcemu.h b/cpu/ppc/ppcemu.h
index 960f465..1530ed8 100644
--- a/cpu/ppc/ppcemu.h
+++ b/cpu/ppc/ppcemu.h
@@ -22,8 +22,9 @@ along with this program. If not, see .
#ifndef PPCEMU_H
#define PPCEMU_H
-#include "devices/memctrlbase.h"
-#include "endianswap.h"
+#include
+#include
+
#include
#include
#include
@@ -213,7 +214,7 @@ enum CRx_bit : uint32_t {
};
enum CR1_bit : uint32_t {
- CR1_OX = 24,
+ CR1_OX = 24,
CR1_VX,
CR1_FEX,
CR1_FX,
@@ -259,7 +260,7 @@ enum FPOP : int {
SUB = 0x14,
ADD = 0x15,
MUL = 0x19,
- FMSUB = 0x1C,
+ FMSUB = 0x1C,
FMADD = 0x1D,
FNMSUB = 0x1E,
FNMADD = 0x1F,
diff --git a/cpu/ppc/ppcmmu.cpp b/cpu/ppc/ppcmmu.cpp
index 10a2ec3..6700216 100644
--- a/cpu/ppc/ppcmmu.cpp
+++ b/cpu/ppc/ppcmmu.cpp
@@ -21,10 +21,11 @@ along with this program. If not, see .
/** @file PowerPC Memory Management Unit emulation. */
-#include "ppcmmu.h"
-#include "devices/memctrlbase.h"
-#include "memaccess.h"
+#include
+#include
#include "ppcemu.h"
+#include "ppcmmu.h"
+
#include
#include
#include
diff --git a/cpu/ppc/ppcmmu.h b/cpu/ppc/ppcmmu.h
index 7b18427..69a5e98 100644
--- a/cpu/ppc/ppcmmu.h
+++ b/cpu/ppc/ppcmmu.h
@@ -24,11 +24,12 @@ along with this program. If not, see .
#ifndef PPCMMU_H
#define PPCMMU_H
+#include
+
#include
#include
#include
#include
-#include "devices/memctrlbase.h"
/* Uncomment this to exhaustive MMU integrity checks. */
//#define MMU_INTEGRITY_CHECKS
diff --git a/devices/CMakeLists.txt b/devices/CMakeLists.txt
index 7913765..8d6ff94 100644
--- a/devices/CMakeLists.txt
+++ b/devices/CMakeLists.txt
@@ -2,7 +2,17 @@ include_directories("${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/thirdparty/loguru/"
"${PROJECT_SOURCE_DIR}/thirdparty/SDL2/")
-file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
+file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/common/adb/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/common/i2c/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/common/pci/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/common/scsi/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/ioctrl/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/memctrl/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/sound/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/video/*.cpp"
+ )
add_library(devices OBJECT ${SOURCES})
target_link_libraries(devices PRIVATE cubeb)
diff --git a/devices/adb.cpp b/devices/common/adb/adb.cpp
similarity index 99%
rename from devices/adb.cpp
rename to devices/common/adb/adb.cpp
index 842c3eb..d2ee48e 100644
--- a/devices/adb.cpp
+++ b/devices/common/adb/adb.cpp
@@ -25,7 +25,9 @@ along with this program. If not, see .
*/
-#include "devices/adb.h"
+#include
+#include
+
#include
#include
@@ -37,8 +39,6 @@ along with this program. If not, see .
#include
#endif
-#include
-
using namespace std;
ADB_Bus::ADB_Bus() {
diff --git a/devices/adb.h b/devices/common/adb/adb.h
similarity index 100%
rename from devices/adb.h
rename to devices/common/adb/adb.h
diff --git a/devices/dbdma.cpp b/devices/common/dbdma.cpp
similarity index 98%
rename from devices/dbdma.cpp
rename to devices/common/dbdma.cpp
index f813b25..9578aa3 100644
--- a/devices/dbdma.cpp
+++ b/devices/common/dbdma.cpp
@@ -21,10 +21,11 @@ along with this program. If not, see .
/** @file Descriptor-based direct memory access emulation. */
-#include "dmacore.h"
-#include "dbdma.h"
-#include "cpu/ppc/ppcmmu.h"
-#include "endianswap.h"
+#include
+#include
+#include
+#include
+
#include
#include
#include
diff --git a/devices/dbdma.h b/devices/common/dbdma.h
similarity index 98%
rename from devices/dbdma.h
rename to devices/common/dbdma.h
index 2b2d743..669a43b 100644
--- a/devices/dbdma.h
+++ b/devices/common/dbdma.h
@@ -29,7 +29,8 @@ along with this program. If not, see .
#ifndef DB_DMA_H
#define DB_DMA_H
-#include "dmacore.h"
+#include
+
#include
#include
diff --git a/devices/dmacore.h b/devices/common/dmacore.h
similarity index 100%
rename from devices/dmacore.h
rename to devices/common/dmacore.h
diff --git a/devices/hwcomponent.h b/devices/common/hwcomponent.h
similarity index 100%
rename from devices/hwcomponent.h
rename to devices/common/hwcomponent.h
diff --git a/devices/i2c.h b/devices/common/i2c/i2c.h
similarity index 100%
rename from devices/i2c.h
rename to devices/common/i2c/i2c.h
diff --git a/devices/machineid.h b/devices/common/machineid.h
similarity index 97%
rename from devices/machineid.h
rename to devices/common/machineid.h
index 4e6eae1..9ea80ab 100644
--- a/devices/machineid.h
+++ b/devices/common/machineid.h
@@ -22,8 +22,9 @@ along with this program. If not, see .
#ifndef MACHINE_ID_H
#define MACHINE_ID_H
-#include "hwcomponent.h"
-#include "mmiodevice.h"
+#include
+#include
+
#include
/**
diff --git a/devices/mmiodevice.h b/devices/common/mmiodevice.h
similarity index 97%
rename from devices/mmiodevice.h
rename to devices/common/mmiodevice.h
index 9bdf1d1..7892368 100644
--- a/devices/mmiodevice.h
+++ b/devices/common/mmiodevice.h
@@ -22,7 +22,8 @@ along with this program. If not, see .
#ifndef MMIO_DEVICE_H
#define MMIO_DEVICE_H
-#include "hwcomponent.h"
+#include
+
#include
#include
diff --git a/devices/nvram.cpp b/devices/common/nvram.cpp
similarity index 98%
rename from devices/nvram.cpp
rename to devices/common/nvram.cpp
index cd88e9a..a3e2544 100644
--- a/devices/nvram.cpp
+++ b/devices/common/nvram.cpp
@@ -19,7 +19,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#include "nvram.h"
+#include
+
#include
#include
#include
diff --git a/devices/nvram.h b/devices/common/nvram.h
similarity index 100%
rename from devices/nvram.h
rename to devices/common/nvram.h
diff --git a/devices/pcidevice.h b/devices/common/pci/pcidevice.h
similarity index 96%
rename from devices/pcidevice.h
rename to devices/common/pci/pcidevice.h
index 2b1c5b4..643b5ba 100644
--- a/devices/pcidevice.h
+++ b/devices/common/pci/pcidevice.h
@@ -22,8 +22,9 @@ along with this program. If not, see .
#ifndef PCI_DEVICE_H
#define PCI_DEVICE_H
-#include "mmiodevice.h"
-#include "pcihost.h"
+#include
+#include
+
#include
#include
diff --git a/devices/pcihost.h b/devices/common/pci/pcihost.h
similarity index 100%
rename from devices/pcihost.h
rename to devices/common/pci/pcihost.h
diff --git a/devices/mesh.cpp b/devices/common/scsi/mesh.cpp
similarity index 98%
rename from devices/mesh.cpp
rename to devices/common/scsi/mesh.cpp
index 395ad40..2644b89 100644
--- a/devices/mesh.cpp
+++ b/devices/common/scsi/mesh.cpp
@@ -21,7 +21,8 @@ along with this program. If not, see .
/** @file MESH (Macintosh Enhanced SCSI Hardware) controller emulation. */
-#include "mesh.h"
+#include
+
#include
#include
diff --git a/devices/mesh.h b/devices/common/scsi/mesh.h
similarity index 100%
rename from devices/mesh.h
rename to devices/common/scsi/mesh.h
diff --git a/devices/viacuda.cpp b/devices/common/viacuda.cpp
similarity index 96%
rename from devices/viacuda.cpp
rename to devices/common/viacuda.cpp
index 6bc313b..0337e25 100644
--- a/devices/viacuda.cpp
+++ b/devices/common/viacuda.cpp
@@ -24,11 +24,12 @@ along with this program. If not, see .
Author: Max Poliakovski 2019
*/
-#include "adb.h"
-#include "memaccess.h"
-#include "viacuda.h"
-#include
+#include
+#include
#include
+#include
+
+#include
#include
using namespace std;
diff --git a/devices/viacuda.h b/devices/common/viacuda.h
similarity index 95%
rename from devices/viacuda.h
rename to devices/common/viacuda.h
index ef20f5a..ef57ae5 100644
--- a/devices/viacuda.h
+++ b/devices/common/viacuda.h
@@ -45,10 +45,11 @@ along with this program. If not, see .
#ifndef VIACUDA_H
#define VIACUDA_H
-#include "adb.h"
-#include "hwcomponent.h"
-#include "i2c.h"
-#include "nvram.h"
+#include
+#include
+#include
+#include
+
#include
/** VIA register offsets. */
diff --git a/devices/amic.cpp b/devices/ioctrl/amic.cpp
similarity index 98%
rename from devices/amic.cpp
rename to devices/ioctrl/amic.cpp
index 57369b8..ae50789 100644
--- a/devices/amic.cpp
+++ b/devices/ioctrl/amic.cpp
@@ -24,12 +24,12 @@ along with this program. If not, see .
Author: Max Poliakovski
*/
-#include "amic.h"
-#include "cpu/ppc/ppcmmu.h"
-#include "dmacore.h"
-#include "machines/machinebase.h"
-#include "memctrlbase.h"
-#include "viacuda.h"
+#include
+#include
+#include
+#include
+#include
+
#include
#include
#include
diff --git a/devices/amic.h b/devices/ioctrl/amic.h
similarity index 97%
rename from devices/amic.h
rename to devices/ioctrl/amic.h
index 3156bbe..eb8229f 100644
--- a/devices/amic.h
+++ b/devices/ioctrl/amic.h
@@ -24,10 +24,10 @@ along with this program. If not, see .
#ifndef AMIC_H
#define AMIC_H
-#include "awacs.h"
-#include "dmacore.h"
-#include "mmiodevice.h"
-#include "viacuda.h"
+#include
+#include
+#include
+
#include
#include
diff --git a/devices/heathrow.cpp b/devices/ioctrl/heathrow.cpp
similarity index 97%
rename from devices/heathrow.cpp
rename to devices/ioctrl/heathrow.cpp
index f8fc229..1ed3569 100644
--- a/devices/heathrow.cpp
+++ b/devices/ioctrl/heathrow.cpp
@@ -19,16 +19,17 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#include "awacs.h"
-#include "dbdma.h"
-#include "machines/machinebase.h"
-#include "macio.h"
-#include "viacuda.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
#include
#include
#include
#include
-#include
/** Heathrow Mac I/O device emulation.
diff --git a/devices/macio.h b/devices/ioctrl/macio.h
similarity index 93%
rename from devices/macio.h
rename to devices/ioctrl/macio.h
index 3810e2f..d9d7105 100644
--- a/devices/macio.h
+++ b/devices/ioctrl/macio.h
@@ -51,16 +51,17 @@ along with this program. If not, see .
#ifndef MACIO_H
#define MACIO_H
-#include "awacs.h"
-#include "dbdma.h"
-#include "hwcomponent.h"
-#include "memctrlbase.h"
-#include "mesh.h"
-#include "mmiodevice.h"
-#include "nvram.h"
-#include "pcidevice.h"
-#include "pcihost.h"
-#include "viacuda.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
#include
/**
diff --git a/devices/hmc.cpp b/devices/memctrl/hmc.cpp
similarity index 98%
rename from devices/hmc.cpp
rename to devices/memctrl/hmc.cpp
index 9ff874a..798b2f9 100644
--- a/devices/hmc.cpp
+++ b/devices/memctrl/hmc.cpp
@@ -24,7 +24,7 @@ along with this program. If not, see .
Author: Max Poliakovski
*/
-#include "hmc.h"
+#include
HMC::HMC() : MemCtrlBase()
{
diff --git a/devices/hmc.h b/devices/memctrl/hmc.h
similarity index 92%
rename from devices/hmc.h
rename to devices/memctrl/hmc.h
index fa54281..3ed2745 100644
--- a/devices/hmc.h
+++ b/devices/memctrl/hmc.h
@@ -31,9 +31,10 @@ along with this program. If not, see .
#ifndef HMC_H
#define HMC_H
-#include "hwcomponent.h"
-#include "memctrlbase.h"
-#include "mmiodevice.h"
+#include
+#include
+#include
+
#include
class HMC : public MemCtrlBase, public MMIODevice {
diff --git a/devices/memctrlbase.cpp b/devices/memctrl/memctrlbase.cpp
similarity index 99%
rename from devices/memctrlbase.cpp
rename to devices/memctrl/memctrlbase.cpp
index d48f26c..5e1804d 100644
--- a/devices/memctrlbase.cpp
+++ b/devices/memctrl/memctrlbase.cpp
@@ -19,13 +19,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+#include
+
#include // to shut up MSVC errors (:
#include
#include
#include
-#include "memctrlbase.h"
-
MemCtrlBase::~MemCtrlBase() {
for (auto& entry : address_map) {
diff --git a/devices/memctrlbase.h b/devices/memctrl/memctrlbase.h
similarity index 98%
rename from devices/memctrlbase.h
rename to devices/memctrl/memctrlbase.h
index 2695d3f..d22d994 100644
--- a/devices/memctrlbase.h
+++ b/devices/memctrl/memctrlbase.h
@@ -22,7 +22,8 @@ along with this program. If not, see .
#ifndef MEMORY_CONTROLLER_BASE_H
#define MEMORY_CONTROLLER_BASE_H
-#include "mmiodevice.h"
+#include
+
#include
#include
#include
diff --git a/devices/mpc106.cpp b/devices/memctrl/mpc106.cpp
similarity index 94%
rename from devices/mpc106.cpp
rename to devices/memctrl/mpc106.cpp
index 41e2281..8f24c3b 100644
--- a/devices/mpc106.cpp
+++ b/devices/memctrl/mpc106.cpp
@@ -24,17 +24,17 @@ along with this program. If not, see .
Author: Max Poliakovski
*/
+#include
+#include
+#include
+#include
+#include
+
#include
#include
#include
#include
-#include "hwcomponent.h"
-#include "memctrlbase.h"
-#include "memaccess.h"
-#include "mmiodevice.h"
-#include "mpc106.h"
-
MPC106::MPC106() : MemCtrlBase(), PCIDevice("Grackle PCI host bridge") {
this->name = "Grackle";
diff --git a/devices/mpc106.h b/devices/memctrl/mpc106.h
similarity index 94%
rename from devices/mpc106.h
rename to devices/memctrl/mpc106.h
index ead9f4e..fed82cb 100644
--- a/devices/mpc106.h
+++ b/devices/memctrl/mpc106.h
@@ -35,11 +35,12 @@ along with this program. If not, see .
#ifndef MPC106_H_
#define MPC106_H_
-#include "hwcomponent.h"
-#include "memctrlbase.h"
-#include "mmiodevice.h"
-#include "pcidevice.h"
-#include "pcihost.h"
+#include
+#include
+#include
+#include
+#include
+
#include
#include
diff --git a/devices/spdram.h b/devices/memctrl/spdram.h
similarity index 98%
rename from devices/spdram.h
rename to devices/memctrl/spdram.h
index dacb84a..a3609a7 100644
--- a/devices/spdram.h
+++ b/devices/memctrl/spdram.h
@@ -47,12 +47,13 @@ along with this program. If not, see .
#ifndef SPD_EEPROM_H
#define SPD_EEPROM_H
-#include "hwcomponent.h"
-#include "i2c.h"
+#include
+#include
+#include
+
#include
#include
#include
-#include
enum RAMType : int { SDRAM = 4 };
diff --git a/devices/awacs.cpp b/devices/sound/awacs.cpp
similarity index 97%
rename from devices/awacs.cpp
rename to devices/sound/awacs.cpp
index 74ade0b..8fda847 100644
--- a/devices/awacs.cpp
+++ b/devices/sound/awacs.cpp
@@ -28,11 +28,12 @@ along with this program. If not, see .
Author: Max Poliakovski 2019-21
*/
-#include "awacs.h"
-#include "dbdma.h"
-#include "endianswap.h"
-#include "machines/machinebase.h"
-#include "soundserver.h"
+#include
+#include
+#include
+#include
+#include
+
#include
#include
#include
diff --git a/devices/awacs.h b/devices/sound/awacs.h
similarity index 96%
rename from devices/awacs.h
rename to devices/sound/awacs.h
index 83d3205..9f327eb 100644
--- a/devices/awacs.h
+++ b/devices/sound/awacs.h
@@ -28,10 +28,11 @@ along with this program. If not, see .
#ifndef AWAC_H
#define AWAC_H
-#include "dmacore.h"
-#include "dbdma.h"
-#include "i2c.h"
-#include "soundserver.h"
+#include
+#include
+#include
+#include
+
#include
#include
diff --git a/devices/soundserver.cpp b/devices/sound/soundserver.cpp
similarity index 98%
rename from devices/soundserver.cpp
rename to devices/sound/soundserver.cpp
index 72d8ea2..118775c 100644
--- a/devices/soundserver.cpp
+++ b/devices/sound/soundserver.cpp
@@ -19,9 +19,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#include "dmacore.h"
-#include "endianswap.h"
-#include "soundserver.h"
+#include
+#include
+#include
+
#include
#include
#ifdef _WIN32
diff --git a/devices/soundserver.h b/devices/sound/soundserver.h
similarity index 97%
rename from devices/soundserver.h
rename to devices/sound/soundserver.h
index 6402096..e333658 100644
--- a/devices/soundserver.h
+++ b/devices/sound/soundserver.h
@@ -34,8 +34,8 @@ along with this program. If not, see .
#ifndef SOUND_SERVER_H
#define SOUND_SERVER_H
-#include "hwcomponent.h"
#include
+#include
enum {
SND_SERVER_DOWN = 0,
diff --git a/devices/atirage.cpp b/devices/video/atirage.cpp
similarity index 99%
rename from devices/atirage.cpp
rename to devices/video/atirage.cpp
index 3772cd7..7bcc9ed 100644
--- a/devices/atirage.cpp
+++ b/devices/video/atirage.cpp
@@ -19,15 +19,16 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#include "displayid.h"
-#include "endianswap.h"
-#include "memaccess.h"
-#include "pcidevice.h"
-#include
+#include
+#include
+#include
+#include
+#include
+#include
+
#include
#include
#include