2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
7 [ SCSI hard disk drive ]
14 void SCSI_HDD::release()
16 for(int i = 0; i < 8; i++) {
25 bool SCSI_HDD::is_device_existing()
27 for(int i = 0; i < 8; i++) {
28 if(disk[i] != NULL && disk[i]->mounted()) {
35 uint32_t SCSI_HDD::physical_block_size()
37 HARDDISK *unit = disk[get_logical_unit_number()];
39 if(unit != NULL && unit->mounted()) {
40 return unit->sector_size;
45 uint32_t SCSI_HDD::logical_block_size()
47 HARDDISK *unit = disk[get_logical_unit_number()];
49 if(unit != NULL && unit->mounted()) {
50 return unit->sector_size;
55 uint32_t SCSI_HDD::max_logical_block_addr()
57 HARDDISK *unit = disk[get_logical_unit_number()];
59 if(unit != NULL && unit->mounted()) {
60 return unit->cylinders * unit->surfaces * unit->sectors;
65 void SCSI_HDD::read_buffer(int length)
67 HARDDISK *unit = disk[get_logical_unit_number()];
69 if(unit != NULL && unit->mounted()) {
71 uint8_t tmp_buffer[SCSI_BUFFER_SIZE];
72 int tmp_length = min(length, (int)sizeof(tmp_buffer));
74 unit->read_buffer((long)position, tmp_length, tmp_buffer);
75 for(int i = 0; i < tmp_length; i++) {
76 buffer->write(tmp_buffer[i]);
79 position += tmp_length;
84 void SCSI_HDD::write_buffer(int length)
86 HARDDISK *unit = disk[get_logical_unit_number()];
88 if(unit != NULL && unit->mounted()) {
90 uint8_t tmp_buffer[SCSI_BUFFER_SIZE];
91 int tmp_length = min(length, (int)sizeof(tmp_buffer));
93 for(int i = 0; i < tmp_length; i++) {
94 tmp_buffer[i] = buffer->read();
96 unit->write_buffer((long)position, tmp_length, tmp_buffer);
98 position += tmp_length;
103 #define STATE_VERSION 1
105 #include "../statesub.h"
107 void SCSI_HDD::decl_state()
109 enter_decl_state(STATE_VERSION);
113 SCSI_DEV::decl_state();
116 void SCSI_HDD::save_state(FILEIO* state_fio)
118 uint32_t crc_value = 0xffffffff;
119 if(state_entry != NULL) {
120 state_entry->save_state(state_fio, &crc_value);
122 // state_fio->FputUint32(STATE_VERSION);
123 // state_fio->FputInt32(this_device_id);
125 for(int i = 0; i < 8; i++) {
126 if(disk[i] != NULL) {
127 disk[i]->save_state(state_fio);
131 // SCSI_DEV::save_state(state_fio);
134 bool SCSI_HDD::load_state(FILEIO* state_fio)
136 uint32_t crc_value = 0xffffffff;
139 if(state_entry != NULL) {
140 mb = state_entry->load_state(state_fio, &crc_value);
142 if(!mb) return false;
143 // if(state_fio->FgetUint32() != STATE_VERSION) {
146 // if(state_fio->FgetInt32() != this_device_id) {
150 for(int i = 0; i < 8; i++) {
151 if(disk[i] != NULL) {
152 if(!disk[i]->load_state(state_fio)) {
158 // return SCSI_DEV::load_state(state_fio);