dingusppc/devices/common/ata/atahd.h

70 lines
1.8 KiB
C
Raw Normal View History

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