2022-12-07 23:36:56 +01:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2023-04-17 09:56:03 +02:00
|
|
|
Copyright (C) 2018-23 divingkatae and maximum
|
2022-12-07 23:36:56 +01:00
|
|
|
(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/>.
|
|
|
|
*/
|
|
|
|
|
2023-04-17 09:56:03 +02:00
|
|
|
/** @file ATA hard disk definitions. */
|
2022-12-07 23:36:56 +01:00
|
|
|
|
|
|
|
#ifndef ATA_HARD_DISK_H
|
|
|
|
#define ATA_HARD_DISK_H
|
|
|
|
|
|
|
|
#include <devices/common/ata/atabasedevice.h>
|
2023-09-16 14:17:27 -07:00
|
|
|
#include <utils/imgfile.h>
|
|
|
|
|
2022-12-09 00:52:39 +01:00
|
|
|
#include <string>
|
2022-12-07 23:36:56 +01:00
|
|
|
|
2023-04-17 09:56:03 +02:00
|
|
|
#define ATA_HD_SEC_SIZE 512
|
|
|
|
|
2022-12-07 23:36:56 +01:00
|
|
|
class AtaHardDisk : public AtaBaseDevice
|
|
|
|
{
|
|
|
|
public:
|
2023-11-22 17:08:23 +01:00
|
|
|
AtaHardDisk(std::string name);
|
2022-12-07 23:36:56 +01:00
|
|
|
~AtaHardDisk() = default;
|
|
|
|
|
2023-11-22 17:08:23 +01:00
|
|
|
static std::unique_ptr<HWComponent> create() {
|
|
|
|
return std::unique_ptr<AtaHardDisk>(new AtaHardDisk("ATA-HD"));
|
|
|
|
}
|
|
|
|
|
|
|
|
int device_postinit() override;
|
|
|
|
|
2022-12-09 00:52:39 +01:00
|
|
|
void insert_image(std::string filename);
|
2023-04-24 23:02:32 +02:00
|
|
|
int perform_command() override;
|
2022-12-09 00:52:39 +01:00
|
|
|
|
2023-11-22 17:08:23 +01:00
|
|
|
protected:
|
|
|
|
void prepare_identify_info();
|
|
|
|
uint64_t get_lba();
|
|
|
|
|
2022-12-09 00:52:39 +01:00
|
|
|
private:
|
2023-09-16 14:17:27 -07:00
|
|
|
ImgFile hdd_img;
|
2022-12-09 00:52:39 +01:00
|
|
|
uint64_t img_size;
|
2023-11-22 17:08:23 +01:00
|
|
|
|
|
|
|
// fictive disk geometry for CHS-to-LBA translation
|
|
|
|
uint16_t cylinders;
|
|
|
|
uint8_t heads;
|
|
|
|
uint8_t sectors;
|
|
|
|
|
2022-12-09 00:52:39 +01:00
|
|
|
char * buffer = new char[1 <<17];
|
2022-12-11 16:08:43 -07:00
|
|
|
|
2023-04-17 09:56:03 +02:00
|
|
|
uint8_t hd_id_data[ATA_HD_SEC_SIZE] = {};
|
2022-12-07 23:36:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ATA_HARD_DISK_H
|