Add MACE Ethernet emulation stub.

This commit is contained in:
Maxim Poliakovski 2021-10-24 21:02:30 +02:00
parent 281aaa1902
commit 6a756df5e3
5 changed files with 143 additions and 0 deletions

View File

@ -8,6 +8,7 @@ file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.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}/ethernet/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ioctrl/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/memctrl/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/sound/*.cpp"

55
devices/ethernet/mace.cpp Normal file
View File

@ -0,0 +1,55 @@
/*
DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-21 divingkatae and maximum
(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 Media Access Controller for Ethernet (MACE) emulation. */
#include "mace.h"
#include <loguru.hpp>
#include <cinttypes>
uint8_t MaceController::read(uint8_t reg_offset)
{
switch(reg_offset) {
case MaceReg::Interrupt:
LOG_F(INFO, "MACE: all interrupt flags cleared");
return 0;
default:
LOG_F(INFO, "Reading MACE register %d", reg_offset);
}
return 0;
}
void MaceController::write(uint8_t reg_offset, uint8_t value)
{
switch(reg_offset) {
case MaceReg::BIU_Config_Ctrl:
if (value & 1) {
LOG_F(INFO, "MACE Reset issued");
} else {
LOG_F(INFO, "MACE BIU Config set to 0x%X", value);
}
break;
default:
LOG_F(INFO, "Writing 0x%X to MACE register %d", value, reg_offset);
}
}

78
devices/ethernet/mace.h Normal file
View File

@ -0,0 +1,78 @@
/*
DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-21 divingkatae and maximum
(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 Media Access Controller for Ethernet (MACE) definitions. */
#ifndef MACE_H
#define MACE_H
#include <cinttypes>
// MACE Chip ID from AMD datasheet
// TODO: compare with real HW
#define MACE_ID 0x3940
// MACE registers offsets
// Refer to the Am79C940 datasheet for details
enum MaceReg : uint8_t {
Rcv_FIFO = 0,
Xmit_FIFO = 1,
Xmit_Frame_Ctrl = 2,
Xmit_Frame_Stat = 3,
Xmit_Retry_Cnt = 4,
Rcv_Frame_Ctrl = 5,
Rcv_Frame_Stat = 6,
FIFO_Frame_Cnt = 7,
Interrupt = 8,
Interrupt_Mask = 9,
Poll = 0x0A,
BIU_Config_Ctrl = 0x0B,
FIFO_Config = 0x0C,
MAC_Config_Ctrl = 0x0D,
PLS_Config_Ctrl = 0x0E,
PHY_Config_Ctrl = 0x0F,
Chip_ID_Lo = 0x10,
Chip_ID_Hi = 0x11,
Addr_Config = 0x12,
Log_Addr_Flt = 0x14,
Phys_Addr = 0x15,
Missed_Pkt_Cnt = 0x18,
Runt_Pkt_Cnt = 0x1A, // not used in Macintosh?
Rcv_Collis_Cnt = 0x1B, // not used in Macintosh?
User_Test = 0x1D,
Rsrvd_Test_1 = 0x1E, // not used in Macintosh?
Rsrvd_Test_2 = 0x1F, // not used in Macintosh?
};
class MaceController {
public:
MaceController(uint16_t id) { this->chip_id = id; };
~MaceController() = default;
// MACE registers access
uint8_t read(uint8_t reg_offset);
void write(uint8_t reg_offset, uint8_t value);
private:
uint16_t chip_id; // per-instance MACE Chip ID
};
#endif // MACE_H

View File

@ -26,6 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cpu/ppc/ppcmmu.h>
#include <devices/common/viacuda.h>
#include <devices/ethernet/mace.h>
#include <devices/ioctrl/amic.h>
#include <machines/machinebase.h>
#include <devices/memctrl/memctrlbase.h>
@ -47,6 +48,7 @@ AMIC::AMIC()
LOG_F(ERROR, "Couldn't register AMIC registers!");
}
this->mace = std::unique_ptr<MaceController> (new MaceController(MACE_ID));
this->viacuda = std::unique_ptr<ViaCuda> (new ViaCuda());
this->snd_out_dma = std::unique_ptr<AmicSndOutDma> (new AmicSndOutDma());
@ -74,6 +76,8 @@ uint32_t AMIC::read(uint32_t reg_start, uint32_t offset, int size)
case 4: // SCC registers
LOG_F(WARNING, "AMIC: read attempt from unimplemented SCC register");
return 0;
case 0xA: // MACE registers
return this->mace->read((offset >> 4) & 0xFF);
case 0x10: // SCSI registers
LOG_F(WARNING, "AMIC: read attempt from unimplemented SCSI register");
return 0;
@ -121,6 +125,9 @@ void AMIC::write(uint32_t reg_start, uint32_t offset, uint32_t value, int size)
case 1:
this->viacuda->write(offset >> 9, value);
return;
case 0xA: // MACE registers
this->mace->write((offset >> 4) & 0xFF, value);
return;
case 0x14: // Sound registers
switch(offset) {
case AMICReg::Snd_Ctrl_0:

View File

@ -26,6 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <devices/common/mmiodevice.h>
#include <devices/common/viacuda.h>
#include <devices/ethernet/mace.h>
#include <devices/sound/awacs.h>
#include <cinttypes>
@ -141,6 +142,7 @@ private:
uint8_t scsi_dma_cs = 0; // SCSI DMA control/status register value
std::unique_ptr<MaceController> mace;
std::unique_ptr<ViaCuda> viacuda;
std::unique_ptr<AwacDevicePdm> awacs;