mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-09-29 02:54:39 +00:00
Fixed hard disk support
Compiles, still unfinished
This commit is contained in:
parent
ee9573327c
commit
aa1d23e08b
@ -6,6 +6,7 @@ file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/adb/*.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/adb/*.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/i2c/*.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/i2c/*.cpp"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/ide/*.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/pci/*.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/pci/*.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/scsi/*.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/common/scsi/*.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/ethernet/*.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/ethernet/*.cpp"
|
||||||
|
@ -402,7 +402,7 @@ bool ADB_Bus::adb_keybd_listen(int reg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ADB_Bus::adb_mouse_listen(int reg) {
|
bool ADB_Bus::adb_mouse_listen(int reg) {
|
||||||
if ((reg != 0) | (reg != 3)) {
|
if ((reg != 0) || (reg != 3)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ enum HWCompType {
|
|||||||
SCSI_BUS = 1ULL << 20, /* SCSI bus */
|
SCSI_BUS = 1ULL << 20, /* SCSI bus */
|
||||||
SCSI_HOST = 1ULL << 21, /* SCSI host adapter */
|
SCSI_HOST = 1ULL << 21, /* SCSI host adapter */
|
||||||
SCSI_DEV = 1ULL << 22, /* SCSI device */
|
SCSI_DEV = 1ULL << 22, /* SCSI device */
|
||||||
|
IDE_DEV = 1ULL << 25, /* IDE device */
|
||||||
SND_SERVER = 1ULL << 31, /* host sound server */
|
SND_SERVER = 1ULL << 31, /* host sound server */
|
||||||
FLOPPY_CTRL = 1ULL << 32, /* floppy disk controller */
|
FLOPPY_CTRL = 1ULL << 32, /* floppy disk controller */
|
||||||
FLOPPY_DRV = 1ULL << 33, /* floppy disk drive */
|
FLOPPY_DRV = 1ULL << 33, /* floppy disk drive */
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
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 Heathrow hard drive controller */
|
|
||||||
|
|
||||||
#include "heath_ide.h"
|
|
||||||
#include <fstream>
|
|
||||||
#include <limits>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <loguru.hpp>
|
|
||||||
|
|
||||||
#define sector_size 512
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
HeathIDE::HeathIDE(std::string filename) {
|
|
||||||
this->hdd_img;
|
|
||||||
|
|
||||||
// Taken from:
|
|
||||||
// https://stackoverflow.com/questions/22984956/tellg-function-give-wrong-size-of-file/22986486
|
|
||||||
this->hdd_img.ignore(std::numeric_limits<std::streamsize>::max());
|
|
||||||
this->img_size = this->hdd_img.gcount();
|
|
||||||
this->hdd_img.clear(); // Since ignore will have set eof.
|
|
||||||
this->hdd_img.seekg(0, std::ios_base::beg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t HeathIDE::read(int reg) {
|
|
||||||
uint32_t res = 0;
|
|
||||||
switch (reg) {
|
|
||||||
case HEATH_DATA:
|
|
||||||
res = heath_regs[HEATH_DATA];
|
|
||||||
case HEATH_ERROR:
|
|
||||||
res = heath_regs[HEATH_ERROR];
|
|
||||||
case HEATH_SEC_COUNT:
|
|
||||||
res = heath_regs[HEATH_SEC_COUNT];
|
|
||||||
case HEATH_SEC_NUM:
|
|
||||||
res = heath_regs[HEATH_SEC_NUM];
|
|
||||||
default:
|
|
||||||
LOG_F(WARNING, "Attempted to read unknown IDE register: %x", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HeathIDE::write(int reg, uint32_t value) {
|
|
||||||
switch (reg) {
|
|
||||||
case HEATH_DATA:
|
|
||||||
res = heath_regs[HEATH_DATA];
|
|
||||||
case HEATH_CMD:
|
|
||||||
perform_command(value);
|
|
||||||
default:
|
|
||||||
LOG_F(WARNING, "Attempted to write unknown IDE register: %x", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeathIDE::perform_command(uint32_t command) {
|
|
||||||
LOG_F(WARNING, "Attempted to execute IDE command: %x", command);
|
|
||||||
}
|
|
117
devices/common/ide/ide_hd.cpp
Normal file
117
devices/common/ide/ide_hd.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
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 Heathrow hard drive controller */
|
||||||
|
|
||||||
|
#include <devices/common/ide/ide_hd.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <limits>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <loguru.hpp>
|
||||||
|
|
||||||
|
#define sector_size 512
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
IdeHardDisk::IdeHardDisk() {
|
||||||
|
this->name = "IDE0";
|
||||||
|
supports_types(HWCompType::IDE_DEV);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IdeHardDisk::insert_image(std::string filename) {
|
||||||
|
hdd_img.open(filename);
|
||||||
|
|
||||||
|
// Taken from:
|
||||||
|
// https://stackoverflow.com/questions/22984956/tellg-function-give-wrong-size-of-file/22986486
|
||||||
|
hdd_img.ignore(std::numeric_limits<std::streamsize>::max());
|
||||||
|
img_size = this->hdd_img.gcount();
|
||||||
|
hdd_img.clear(); // Since ignore will have set eof.
|
||||||
|
hdd_img.seekg(0, std::ios_base::beg);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t IdeHardDisk::read(int reg) {
|
||||||
|
switch (reg) {
|
||||||
|
case IDE_Reg::IDE_DATA:
|
||||||
|
LOG_F(0, "Retrieving DATA from IDE: %x", regs[IDE_Reg::IDE_DATA]);
|
||||||
|
return regs[IDE_Reg::IDE_DATA];
|
||||||
|
case IDE_Reg::ERROR:
|
||||||
|
return regs[IDE_Reg::ERROR];
|
||||||
|
case IDE_Reg::SEC_COUNT:
|
||||||
|
return regs[IDE_Reg::SEC_COUNT];
|
||||||
|
case IDE_Reg::SEC_NUM:
|
||||||
|
return regs[IDE_Reg::SEC_NUM];
|
||||||
|
case IDE_Reg::CYL_LOW:
|
||||||
|
return regs[IDE_Reg::CYL_LOW];
|
||||||
|
case IDE_Reg::CYL_HIGH:
|
||||||
|
return regs[IDE_Reg::CYL_HIGH];
|
||||||
|
case IDE_Reg::DRIVE_HEAD:
|
||||||
|
return regs[IDE_Reg::DRIVE_HEAD];
|
||||||
|
case IDE_Reg::STATUS:
|
||||||
|
return regs[IDE_Reg::STATUS];
|
||||||
|
case IDE_Reg::ALT_STATUS:
|
||||||
|
return regs[IDE_Reg::ALT_STATUS];
|
||||||
|
case IDE_Reg::TIME_CONFIG:
|
||||||
|
return regs[IDE_Reg::TIME_CONFIG];
|
||||||
|
default:
|
||||||
|
LOG_F(WARNING, "Attempted to read unknown IDE register: %x", reg);
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IdeHardDisk::write(int reg, uint32_t value) {
|
||||||
|
switch (reg) {
|
||||||
|
case IDE_Reg::IDE_DATA:
|
||||||
|
regs[IDE_Reg::IDE_DATA] = value;
|
||||||
|
case IDE_Reg::FEATURES:
|
||||||
|
regs[IDE_Reg::FEATURES] = value;
|
||||||
|
case IDE_Reg::SEC_COUNT:
|
||||||
|
regs[IDE_Reg::SEC_COUNT] = value;
|
||||||
|
case IDE_Reg::SEC_NUM:
|
||||||
|
regs[IDE_Reg::SEC_NUM] = value;
|
||||||
|
case IDE_Reg::CYL_LOW:
|
||||||
|
regs[IDE_Reg::CYL_LOW] = value;
|
||||||
|
case IDE_Reg::CYL_HIGH:
|
||||||
|
regs[IDE_Reg::CYL_HIGH] = value;
|
||||||
|
case IDE_Reg::DRIVE_HEAD:
|
||||||
|
regs[IDE_Reg::DRIVE_HEAD] = value;
|
||||||
|
case IDE_Reg::COMMAND:
|
||||||
|
LOG_F(0, "Executing COMMAND for IDE: %x", value);
|
||||||
|
perform_command(value);
|
||||||
|
case IDE_Reg::DEV_CTRL:
|
||||||
|
regs[IDE_Reg::DEV_CTRL] = value;
|
||||||
|
case IDE_Reg::TIME_CONFIG:
|
||||||
|
regs[IDE_Reg::TIME_CONFIG] = value;
|
||||||
|
default:
|
||||||
|
LOG_F(WARNING, "Attempted to write unknown IDE register: %x", reg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IdeHardDisk::perform_command(uint32_t command) {
|
||||||
|
switch (command) {
|
||||||
|
case IDE_Cmd::READ_SECTOR:
|
||||||
|
LOG_F(WARNING, "Trying to read sector with: %x", command);
|
||||||
|
case IDE_Cmd::WRITE_SECTOR:
|
||||||
|
LOG_F(WARNING, "Trying to write sector with: %x", command);
|
||||||
|
default:
|
||||||
|
LOG_F(WARNING, "Attempted to execute IDE command: %x", command);
|
||||||
|
}
|
||||||
|
}
|
@ -21,16 +21,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
/** @file ATA hard drive support */
|
/** @file ATA hard drive support */
|
||||||
|
|
||||||
#ifndef ATA_HD_H
|
#ifndef IDE_HD_H
|
||||||
#define ATA_HD_H
|
#define IDE_HD_H
|
||||||
|
|
||||||
|
#include <devices/common/hwcomponent.h>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
#include <fstream>
|
||||||
|
#include <memory>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define SEC_SIZE 512
|
#define SEC_SIZE 512
|
||||||
|
|
||||||
/** Heath IDE register offsets. */
|
using namespace std;
|
||||||
|
|
||||||
|
/** IDE register offsets. */
|
||||||
enum IDE_Reg : int {
|
enum IDE_Reg : int {
|
||||||
IDE_DATA = 0x0,
|
IDE_DATA = 0x0,
|
||||||
ERROR = 0x1, // error (read)
|
ERROR = 0x1, // error (read)
|
||||||
@ -41,13 +46,13 @@ enum IDE_Reg : int {
|
|||||||
CYL_HIGH = 0x5, // cylinder high
|
CYL_HIGH = 0x5, // cylinder high
|
||||||
DRIVE_HEAD = 0x6, // drive/head
|
DRIVE_HEAD = 0x6, // drive/head
|
||||||
STATUS = 0x7, // status (read)
|
STATUS = 0x7, // status (read)
|
||||||
CMD = 0x7, // command (write)
|
COMMAND = 0x7, // command (write)
|
||||||
ALT_STATUS = 0x16, // alt status (read)
|
ALT_STATUS = 0x16, // alt status (read)
|
||||||
DEV_CTRL = 0x16, // device control (write)
|
DEV_CTRL = 0x16, // device control (write)
|
||||||
TIME_CONFIG = 0x20,
|
TIME_CONFIG = 0x20
|
||||||
};
|
};
|
||||||
|
|
||||||
enum IDE_Status {
|
enum IDE_Status : int {
|
||||||
ERR = 0x1,
|
ERR = 0x1,
|
||||||
IDX = 0x2,
|
IDX = 0x2,
|
||||||
CORR = 0x4,
|
CORR = 0x4,
|
||||||
@ -59,24 +64,39 @@ enum IDE_Status {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Heath IDE commands. */
|
/** Heath IDE commands. */
|
||||||
enum IDE_Cmd {
|
enum IDE_Cmd : int {
|
||||||
|
IDE_NOP = 0x00,
|
||||||
RESET_ATAPI = 0x08,
|
RESET_ATAPI = 0x08,
|
||||||
RECALIBRATE = 0x10,
|
RECALIBRATE = 0x10,
|
||||||
READ_SECTOR = 0x20,
|
READ_SECTOR = 0x20,
|
||||||
|
READ_LONG = 0x22,
|
||||||
WRITE_SECTOR = 0x30,
|
WRITE_SECTOR = 0x30,
|
||||||
|
WRITE_LONG = 0x32,
|
||||||
|
WRITE_VERIFY = 0x40,
|
||||||
FORMAT_TRACKS = 0x50,
|
FORMAT_TRACKS = 0x50,
|
||||||
DIAGNOSTICS = 0x90,
|
DIAGNOSTICS = 0x90,
|
||||||
|
READ_DMA = 0xC8,
|
||||||
|
WRITE_DMA = 0xCA,
|
||||||
};
|
};
|
||||||
|
|
||||||
class HeathIDE : public HWComponent {
|
class IdeHardDisk : public HWComponent {
|
||||||
public:
|
public:
|
||||||
HeathIDE(std::string filename);
|
IdeHardDisk();
|
||||||
|
~IdeHardDisk() = default;
|
||||||
|
|
||||||
|
static std::unique_ptr<HWComponent> create() {
|
||||||
|
return std::unique_ptr<IdeHardDisk>(new IdeHardDisk());
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_image(std::string filename);
|
||||||
uint32_t read(int reg);
|
uint32_t read(int reg);
|
||||||
void write(int reg, uint32_t value);
|
void write(int reg, uint32_t value);
|
||||||
|
|
||||||
void perform_command(uint32_t command);
|
void perform_command(uint32_t command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::fstream hdd_img;
|
||||||
|
uint64_t img_size;
|
||||||
uint32_t regs[33];
|
uint32_t regs[33];
|
||||||
uint8_t buffer[SEC_SIZE];
|
uint8_t buffer[SEC_SIZE];
|
||||||
};
|
};
|
@ -58,7 +58,7 @@ enum ScsiMsg : int {
|
|||||||
BUS_PHASE_CHANGE,
|
BUS_PHASE_CHANGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ScsiCommamd : int {
|
enum ScsiCommand : int {
|
||||||
TEST_UNITY_READY = 0x0,
|
TEST_UNITY_READY = 0x0,
|
||||||
REWIND = 0x1,
|
REWIND = 0x1,
|
||||||
REQ_SENSE = 0x3,
|
REQ_SENSE = 0x3,
|
||||||
@ -94,8 +94,19 @@ enum ScsiSense : int {
|
|||||||
BLANK_CHECK = 0x8,
|
BLANK_CHECK = 0x8,
|
||||||
VOL_OVERFLOW = 0xD,
|
VOL_OVERFLOW = 0xD,
|
||||||
MISCOMPARE = 0xE,
|
MISCOMPARE = 0xE,
|
||||||
COMPLETED = 0xF,
|
COMPLETED = 0xF
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ScsiError : int {
|
||||||
|
NO_ERROR = 0x0,
|
||||||
|
NO_SECTOR = 0x1,
|
||||||
|
WRITE_FAULT = 0x3,
|
||||||
|
DEV_NOT_READY = 0x4,
|
||||||
|
INVALID_CMD = 0x20,
|
||||||
|
INVALID_LBA = 0x21,
|
||||||
|
INVALID_CDB = 0x24,
|
||||||
|
INVALID_LUN = 0x25,
|
||||||
|
WRITE_PROTECT = 0x27
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Standard SCSI bus timing values measured in ns. */
|
/** Standard SCSI bus timing values measured in ns. */
|
||||||
@ -114,7 +125,6 @@ public:
|
|||||||
~ScsiDevice() = default;
|
~ScsiDevice() = default;
|
||||||
|
|
||||||
virtual void notify(ScsiMsg msg_type, int param) = 0;
|
virtual void notify(ScsiMsg msg_type, int param) = 0;
|
||||||
virtual void select() = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int scsi_id;
|
int scsi_id;
|
||||||
|
@ -34,7 +34,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
SCSI_HD::SCSI_HD() {
|
ScsiHardDisk::ScsiHardDisk() {
|
||||||
supports_types(HWCompType::SCSI_DEV);
|
supports_types(HWCompType::SCSI_DEV);
|
||||||
|
|
||||||
std::string hd_image_path = GET_STR_PROP("hdd_img");
|
std::string hd_image_path = GET_STR_PROP("hdd_img");
|
||||||
@ -51,32 +51,37 @@ SCSI_HD::SCSI_HD() {
|
|||||||
this->hdd_img.seekg(0, std::ios_base::beg);
|
this->hdd_img.seekg(0, std::ios_base::beg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SCSI_HD::test_unit_ready() {
|
int ScsiHardDisk::test_unit_ready() {
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SCSI_HD::req_sense(uint8_t alloc_len) {
|
int ScsiHardDisk::req_sense(uint8_t alloc_len) {
|
||||||
if (alloc_len != 252) {
|
if (alloc_len != 252) {
|
||||||
LOG_F(WARNING, "Inappropriate Allocation Length: %%d", alloc_len);
|
LOG_F(WARNING, "Inappropriate Allocation Length: %%d", alloc_len);
|
||||||
}
|
}
|
||||||
return 0x0; //placeholder - no sense
|
return ScsiError::NO_ERROR; // placeholder - no sense
|
||||||
}
|
}
|
||||||
|
|
||||||
int SCSI_HD::inquiry() {
|
int ScsiHardDisk::inquiry() {
|
||||||
return 0x1000000F;
|
return 0x1000000F;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SCSI_HD::send_diagnostic() {
|
int ScsiHardDisk::send_diagnostic() {
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SCSI_HD::read_capacity_10() {
|
int ScsiHardDisk::mode_select() {
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ScsiHardDisk::read_capacity_10() {
|
||||||
return this->img_size;
|
return this->img_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSI_HD::format() {}
|
void ScsiHardDisk::format() {
|
||||||
|
}
|
||||||
|
|
||||||
void SCSI_HD::read(uint32_t lba, uint16_t transfer_len) {
|
void ScsiHardDisk::read(uint32_t lba, uint16_t transfer_len) {
|
||||||
uint32_t transfer_size = (transfer_len == 0) ? 256 : transfer_len;
|
uint32_t transfer_size = (transfer_len == 0) ? 256 : transfer_len;
|
||||||
transfer_size *= sector_size;
|
transfer_size *= sector_size;
|
||||||
uint32_t device_offset = lba * sector_size;
|
uint32_t device_offset = lba * sector_size;
|
||||||
@ -85,7 +90,7 @@ void SCSI_HD::read(uint32_t lba, uint16_t transfer_len) {
|
|||||||
this->hdd_img.read(img_buffer, transfer_size);
|
this->hdd_img.read(img_buffer, transfer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSI_HD::write(uint32_t lba, uint16_t transfer_len) {
|
void ScsiHardDisk::write(uint32_t lba, uint16_t transfer_len) {
|
||||||
uint32_t transfer_size = (transfer_len == 0) ? 256 : transfer_len;
|
uint32_t transfer_size = (transfer_len == 0) ? 256 : transfer_len;
|
||||||
transfer_size *= sector_size;
|
transfer_size *= sector_size;
|
||||||
uint32_t device_offset = lba * sector_size;
|
uint32_t device_offset = lba * sector_size;
|
||||||
@ -95,11 +100,11 @@ void SCSI_HD::write(uint32_t lba, uint16_t transfer_len) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSI_HD::seek(uint32_t lba) {
|
void ScsiHardDisk::seek(uint32_t lba) {
|
||||||
this->hdd_img.seekg(0, this->hdd_img.beg);
|
this->hdd_img.seekg(0, this->hdd_img.beg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSI_HD::rewind() {
|
void ScsiHardDisk::rewind() {
|
||||||
this->hdd_img.seekg(0, this->hdd_img.beg);
|
this->hdd_img.seekg(0, this->hdd_img.beg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,18 +30,20 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class SCSI_HD : public ScsiDevice {
|
class ScsiHardDisk : public ScsiDevice {
|
||||||
public:
|
public:
|
||||||
SCSI_HD();
|
ScsiHardDisk();
|
||||||
~SCSI_HD() = default;
|
~ScsiHardDisk() = default;
|
||||||
|
|
||||||
virtual void notify(ScsiMsg msg_type, int param) = 0;
|
virtual void notify(ScsiMsg msg_type, int param) = 0;
|
||||||
|
|
||||||
int test_unit_ready();
|
int test_unit_ready();
|
||||||
int req_sense(uint8_t alloc_len);
|
int req_sense(uint8_t alloc_len);
|
||||||
int read_capacity_10();
|
|
||||||
int inquiry();
|
int inquiry();
|
||||||
int send_diagnostic();
|
int send_diagnostic();
|
||||||
|
int mode_select();
|
||||||
|
|
||||||
|
uint64_t read_capacity_10();
|
||||||
|
|
||||||
void format();
|
void format();
|
||||||
void read(uint32_t lba, uint16_t transfer_len);
|
void read(uint32_t lba, uint16_t transfer_len);
|
||||||
@ -57,6 +59,10 @@ protected:
|
|||||||
uint8_t scsi_command[12];
|
uint8_t scsi_command[12];
|
||||||
uint64_t file_offset = 0;
|
uint64_t file_offset = 0;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
|
|
||||||
|
//inquiry info
|
||||||
|
char vendor_info[8] = {'D', 'i', 'n', 'g', 'u', 's', 'D', '\0'};
|
||||||
|
char prod_info[16] = {'E', 'm', 'u', 'l', 'a', 't', 'e', 'd', ' ', 'D', 'i', 's', 'k', '\0'};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -24,7 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <devices/common/dbdma.h>
|
#include <devices/common/dbdma.h>
|
||||||
#include <devices/common/hwcomponent.h>
|
#include <devices/common/hwcomponent.h>
|
||||||
#include <devices/common/viacuda.h>
|
#include <devices/common/viacuda.h>
|
||||||
#include <devices/common/ide/heath_ide.h>
|
#include <devices/common/ide/ide_hd.h>
|
||||||
#include <devices/floppy/swim3.h>
|
#include <devices/floppy/swim3.h>
|
||||||
#include <devices/ioctrl/macio.h>
|
#include <devices/ioctrl/macio.h>
|
||||||
#include <devices/serial/escc.h>
|
#include <devices/serial/escc.h>
|
||||||
@ -80,7 +80,7 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
|||||||
this->mesh = dynamic_cast<MESHController*>(gMachineObj->get_comp_by_name("Mesh"));
|
this->mesh = dynamic_cast<MESHController*>(gMachineObj->get_comp_by_name("Mesh"));
|
||||||
|
|
||||||
// connect IDE HW
|
// connect IDE HW
|
||||||
this->ide_0 = dynamic_cast<HeathIDE*>(gMachineObj->get_comp_by_name("IDE0"));
|
this->ide_0 = dynamic_cast<IdeHardDisk*>(gMachineObj->get_comp_by_name("IDE0"));
|
||||||
|
|
||||||
// connect serial HW
|
// connect serial HW
|
||||||
this->escc = dynamic_cast<EsccController*>(gMachineObj->get_comp_by_name("Escc"));
|
this->escc = dynamic_cast<EsccController*>(gMachineObj->get_comp_by_name("Escc"));
|
||||||
@ -214,7 +214,7 @@ void HeathrowIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
|
|||||||
this->viacuda->write((offset - 0x16000) >> 9, value);
|
this->viacuda->write((offset - 0x16000) >> 9, value);
|
||||||
break;
|
break;
|
||||||
case 0x20:
|
case 0x20:
|
||||||
this->ide_0->write((offset - 0x20000) >> 9, value);
|
this->ide_0->write((offset - 0x20000) >> 4, value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (sub_addr >= 0x60) {
|
if (sub_addr >= 0x60) {
|
||||||
|
@ -54,7 +54,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <devices/common/dbdma.h>
|
#include <devices/common/dbdma.h>
|
||||||
#include <devices/common/mmiodevice.h>
|
#include <devices/common/mmiodevice.h>
|
||||||
#include <devices/common/nvram.h>
|
#include <devices/common/nvram.h>
|
||||||
#include <devices/common/ide/heath_ide.h>
|
#include <devices/common/ide/ide_hd.h>
|
||||||
#include <devices/common/pci/pcidevice.h>
|
#include <devices/common/pci/pcidevice.h>
|
||||||
#include <devices/common/pci/pcihost.h>
|
#include <devices/common/pci/pcihost.h>
|
||||||
#include <devices/common/scsi/mesh.h>
|
#include <devices/common/scsi/mesh.h>
|
||||||
@ -138,7 +138,7 @@ private:
|
|||||||
MaceController* mace;
|
MaceController* mace;
|
||||||
ViaCuda* viacuda; // VIA cell with Cuda MCU attached to it
|
ViaCuda* viacuda; // VIA cell with Cuda MCU attached to it
|
||||||
EsccController* escc; // ESCC serial controller
|
EsccController* escc; // ESCC serial controller
|
||||||
HeathIDE* ide_0; // Internal ATA
|
IdeHardDisk* ide_0; // Internal ATA
|
||||||
Sc53C94* scsi_0; // external SCSI
|
Sc53C94* scsi_0; // external SCSI
|
||||||
Swim3::Swim3Ctrl* swim3; // floppy disk controller
|
Swim3::Swim3Ctrl* swim3; // floppy disk controller
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ private:
|
|||||||
ViaCuda* viacuda; // VIA cell with Cuda MCU attached to it
|
ViaCuda* viacuda; // VIA cell with Cuda MCU attached to it
|
||||||
MESHController* mesh; // MESH SCSI cell instance
|
MESHController* mesh; // MESH SCSI cell instance
|
||||||
EsccController* escc; // ESCC serial controller
|
EsccController* escc; // ESCC serial controller
|
||||||
HeathIDE* ide_0; // Internal ATA
|
IdeHardDisk* ide_0; // Internal ATA
|
||||||
Swim3::Swim3Ctrl* swim3; // floppy disk controller
|
Swim3::Swim3Ctrl* swim3; // floppy disk controller
|
||||||
|
|
||||||
std::unique_ptr<DMAChannel> snd_out_dma;
|
std::unique_ptr<DMAChannel> snd_out_dma;
|
||||||
|
Loading…
Reference in New Issue
Block a user