mesh: self-registration with the device registry.

This commit is contained in:
Maxim Poliakovski 2022-07-17 12:53:44 +02:00
parent 7db0a31cc5
commit 9971052a78
2 changed files with 19 additions and 2 deletions

View File

@ -22,6 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
/** @file MESH (Macintosh Enhanced SCSI Hardware) controller emulation. */
#include <devices/common/scsi/mesh.h>
#include <devices/deviceregistry.h>
#include <cinttypes>
#include <loguru.hpp>
@ -69,3 +70,9 @@ void MESHController::write(uint8_t reg_offset, uint8_t value)
LOG_F(WARNING, "MESH: write to unimplemented register at offset %d", reg_offset);
}
}
static const DeviceDescription Mesh_Descriptor = {
MESHController::create, {}, {}
};
REGISTER_DEVICE(Mesh, Mesh_Descriptor);

View File

@ -24,7 +24,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef MESH_H
#define MESH_H
#include <devices/common/hwcomponent.h>
#include <cinttypes>
#include <memory>
// Chip ID returned by the MESH cell inside the Heathrow ASIC
#define HeathrowMESHID 4
@ -53,11 +56,18 @@ enum MeshReg : uint8_t {
}; // namespace MeshScsi
class MESHController {
class MESHController : public HWComponent {
public:
MESHController(uint8_t mesh_id) { this->chip_id = mesh_id; };
MESHController(uint8_t mesh_id) {
supports_types(HWCompType::SCSI_HOST | HWCompType::SCSI_DEV);
this->chip_id = mesh_id;
};
~MESHController() = default;
static std::unique_ptr<HWComponent> create() {
return std::unique_ptr<MESHController>(new MESHController(HeathrowMESHID));
}
// MESH registers access
uint8_t read(uint8_t reg_offset);
void write(uint8_t reg_offset, uint8_t value);