mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 05:29:43 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
93fae1ee68
76
devices/common/i2c/i2cprom.cpp
Normal file
76
devices/common/i2c/i2cprom.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-22 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 Generic PROM device programmable over I2C. */
|
||||
|
||||
#include <devices/common/i2c/i2cprom.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
I2CProm::I2CProm(uint8_t dev_addr, int size)
|
||||
{
|
||||
supports_types(HWCompType::I2C_DEV);
|
||||
|
||||
this->my_addr = dev_addr;
|
||||
this->rom_size = size;
|
||||
|
||||
// allocate storage for ROM data
|
||||
this->data = std::unique_ptr<uint8_t[]> (new uint8_t[this->rom_size]);
|
||||
}
|
||||
|
||||
void I2CProm::fill_memory(int start, int size, uint8_t c)
|
||||
{
|
||||
if ((start + size) <= this->rom_size) {
|
||||
std::memset(&this->data[start], c, size);
|
||||
}
|
||||
}
|
||||
|
||||
void I2CProm::set_memory(int start, const uint8_t* in_data, int size)
|
||||
{
|
||||
if ((start + size) <= this->rom_size) {
|
||||
std::memcpy(&this->data[start], in_data, size);
|
||||
}
|
||||
}
|
||||
|
||||
void I2CProm::start_transaction() {
|
||||
this->pos = 0;
|
||||
};
|
||||
|
||||
bool I2CProm::send_subaddress(uint8_t sub_addr) {
|
||||
this->pos = sub_addr;
|
||||
return true;
|
||||
};
|
||||
|
||||
bool I2CProm::send_byte(uint8_t data) {
|
||||
LOG_F(9, "I2CRom: 0x%X received", data);
|
||||
return true;
|
||||
};
|
||||
|
||||
bool I2CProm::receive_byte(uint8_t* p_data) {
|
||||
if (this->pos >= this->rom_size) {
|
||||
this->pos = 0; // attempt to read past last byte should wrap around
|
||||
}
|
||||
*p_data = this->data[this->pos++];
|
||||
return true;
|
||||
};
|
57
devices/common/i2c/i2cprom.h
Normal file
57
devices/common/i2c/i2cprom.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-22 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 Generic PROM device programmable over I2C. */
|
||||
|
||||
#ifndef I2C_PROM_H
|
||||
#define I2C_PROM_H
|
||||
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/i2c/i2c.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <memory>
|
||||
|
||||
class I2CProm : public I2CDevice, public HWComponent
|
||||
{
|
||||
public:
|
||||
I2CProm(uint8_t dev_addr, int size);
|
||||
~I2CProm() = default;
|
||||
|
||||
// I2CDevice methods
|
||||
void start_transaction();
|
||||
bool send_subaddress(uint8_t sub_addr);
|
||||
bool send_byte(uint8_t data);
|
||||
bool receive_byte(uint8_t* p_data);
|
||||
|
||||
// data management methods
|
||||
void fill_memory(int start, int size, uint8_t c);
|
||||
void set_memory(int start, const uint8_t* in_data, int size);
|
||||
|
||||
private:
|
||||
std::unique_ptr<uint8_t[]> data;
|
||||
|
||||
int rom_size = 0;
|
||||
int pos = 0;
|
||||
uint8_t my_addr = 0xA0;
|
||||
};
|
||||
|
||||
#endif // I2C_PROM_H
|
@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
/** AWAC sound devices family definitions.
|
||||
|
||||
Audio Waveform Aplifier and Converters (AWACs) is a family of custom audio
|
||||
Audio Waveform Amplifier and Converters (AWACs) is a family of custom audio
|
||||
chips used in Power Macintosh.
|
||||
*/
|
||||
|
||||
|
@ -26,6 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <cpu/ppc/ppcemu.h>
|
||||
#include <devices/common/i2c/athens.h>
|
||||
#include <devices/common/i2c/i2cprom.h>
|
||||
#include <devices/common/machineid.h>
|
||||
#include <devices/floppy/floppyimg.h>
|
||||
#include <devices/ioctrl/macio.h>
|
||||
@ -41,6 +42,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
// EEPROM ID content for a Whisper personality card.
|
||||
const uint8_t WhisperID[16] = {
|
||||
0x0F, 0xAA, 0x55, 0xAA, 0x57, 0x68, 0x69, 0x73, 0x70, 0x65, 0x72, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02
|
||||
};
|
||||
|
||||
static void setup_ram_slot(std::string name, int i2c_addr, int capacity_megs) {
|
||||
if (!capacity_megs)
|
||||
return;
|
||||
@ -95,6 +102,14 @@ int initialize_gossamer(std::string& id)
|
||||
I2CBus* i2c_bus = dynamic_cast<I2CBus*>(gMachineObj->get_comp_by_type(HWCompType::I2C_HOST));
|
||||
i2c_bus->register_device(0x28, dynamic_cast<I2CDevice*>(gMachineObj->get_comp_by_name("Athens")));
|
||||
|
||||
// create ID EEPROM for the Whisper personality card and register it with the I2C host
|
||||
gMachineObj->add_device("Perch", std::unique_ptr<I2CProm>(new I2CProm(0x53, 256)));
|
||||
I2CProm* perch_id = dynamic_cast<I2CProm*>(gMachineObj->get_comp_by_name("Perch"));
|
||||
perch_id->fill_memory(0, 256, 0);
|
||||
perch_id->fill_memory(32, 223, 0xFF);
|
||||
perch_id->set_memory(0, WhisperID, sizeof(WhisperID));
|
||||
i2c_bus->register_device(0x53, perch_id);
|
||||
|
||||
// initialize virtual CPU and request MPC750 CPU aka G3
|
||||
ppc_cpu_init(grackle_obj, PPC_VER::MPC750, 16705000ULL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user