src/mess/machine/990_hd.c
| r3065 | r3066 | |
| 159 | 159 | static hdc_t hdc; |
| 160 | 160 | |
| 161 | 161 | |
| 162 | | /* |
| 163 | | Initialize hard disk unit |
| 164 | | */ |
| 165 | | DEVICE_START( ti990_hd ) |
| 162 | static int get_id_from_device( const device_config *device ) |
| 166 | 163 | { |
| 167 | | hd_unit_t *d; |
| 168 | | int id = image_index_in_device(device); |
| 164 | int id = -1; |
| 169 | 165 | |
| 170 | | assert ((id >= 0) && (id < MAX_DISK_UNIT)); |
| 166 | if ( ! strcmp( "harddisk1", device->tag ) ) |
| 167 | { |
| 168 | id = 0; |
| 169 | } |
| 170 | else if ( ! strcmp( "harddisk2", device->tag ) ) |
| 171 | { |
| 172 | id = 1; |
| 173 | } |
| 174 | else if ( ! strcmp( "harddisk3", device->tag ) ) |
| 175 | { |
| 176 | id = 2; |
| 177 | } |
| 178 | else if ( ! strcmp( "harddisk4", device->tag ) ) |
| 179 | { |
| 180 | id = 3; |
| 181 | } |
| 182 | assert( id >= 0 ); |
| 171 | 183 | |
| 172 | | d = &hdc.d[id]; |
| 173 | | memset(d, 0, sizeof(*d)); |
| 184 | return id; |
| 185 | } |
| 174 | 186 | |
| 175 | | d->img = device; |
| 176 | | d->format = format_mame; /* don't care */ |
| 177 | | d->hd_handle = NULL; |
| 178 | | d->wp = 1; |
| 179 | | d->unsafe = 1; |
| 180 | 187 | |
| 181 | | /* clear attention line */ |
| 182 | | /*hdc.w[0] &= ~ (0x80 >> id);*/ |
| 183 | | |
| 184 | | DEVICE_START_CALL(mess_hd); |
| 185 | | } |
| 186 | | |
| 187 | 188 | /*DEVICE_STOP( ti990_hd ) |
| 188 | 189 | { |
| 189 | 190 | d->img = NULL; |
| r3065 | r3066 | |
| 194 | 195 | */ |
| 195 | 196 | DEVICE_IMAGE_LOAD( ti990_hd ) |
| 196 | 197 | { |
| 197 | | int id = image_index_in_device(image); |
| 198 | int id = get_id_from_device( image ); |
| 198 | 199 | hd_unit_t *d; |
| 199 | | char tag[8]; |
| 200 | | const hard_disk_info *standard_header; |
| 201 | | disk_image_header custom_header; |
| 202 | | int bytes_read; |
| 200 | hard_disk_file *hd_file; |
| 203 | 201 | |
| 202 | d = &hdc.d[id]; |
| 203 | d->img = image; |
| 204 | 204 | |
| 205 | | if ((id < 0) || (id >= MAX_DISK_UNIT)) |
| 206 | | return INIT_FAIL; |
| 205 | hd_file = mess_hd_get_hard_disk_file( image ); |
| 207 | 206 | |
| 208 | | d = &hdc.d[id]; |
| 209 | | |
| 210 | | bytes_read = image_fread(image, tag, sizeof(tag)); |
| 211 | | if (bytes_read != sizeof(tag)) |
| 212 | | return INIT_FAIL;; |
| 213 | | if (! strncmp(tag, "MComprHD", 8)) |
| 207 | if ( hd_file ) |
| 214 | 208 | { |
| 215 | | /* standard hard disk format */ |
| 209 | const hard_disk_info *standard_header; |
| 216 | 210 | |
| 217 | | /* open image */ |
| 218 | | if (device_load_mess_hd(image)) |
| 219 | | return INIT_FAIL; |
| 211 | d->format = format_mame; |
| 212 | d->hd_handle = hd_file; |
| 220 | 213 | |
| 221 | | /* set file descriptor */ |
| 222 | | d->format = format_mame; |
| 223 | | d->hd_handle = mess_hd_get_hard_disk_file(image); |
| 224 | | /* tell whether the image is writable */ |
| 225 | | d->wp = !image_is_writable(image); |
| 214 | /* use standard hard disk image header. */ |
| 215 | standard_header = hard_disk_get_info(d->hd_handle); |
| 216 | |
| 217 | d->cylinders = standard_header->cylinders; |
| 218 | d->heads = standard_header->heads; |
| 219 | d->sectors_per_track = standard_header->sectors; |
| 220 | d->bytes_per_sector = standard_header->sectorbytes; |
| 226 | 221 | } |
| 227 | 222 | else |
| 228 | 223 | { |
| 229 | 224 | /* older, custom format */ |
| 225 | disk_image_header custom_header; |
| 226 | int bytes_read; |
| 230 | 227 | |
| 231 | 228 | /* set file descriptor */ |
| 232 | 229 | d->format = format_old; |
| 233 | 230 | d->hd_handle = NULL; |
| 234 | | /* tell whether the image is writable */ |
| 235 | | d->wp = ! image_is_writable(image); |
| 236 | | } |
| 237 | 231 | |
| 238 | | d->unsafe = 1; |
| 239 | | /* set attention line */ |
| 240 | | hdc.w[0] |= (0x80 >> id); |
| 241 | | |
| 242 | | /* read geometry */ |
| 243 | | switch (d->format) |
| 244 | | { |
| 245 | | case format_mame: |
| 246 | | /* use standard hard disk image header. */ |
| 247 | | standard_header = hard_disk_get_info(d->hd_handle); |
| 248 | | |
| 249 | | d->cylinders = standard_header->cylinders; |
| 250 | | d->heads = standard_header->heads; |
| 251 | | d->sectors_per_track = standard_header->sectors; |
| 252 | | d->bytes_per_sector = standard_header->sectorbytes; |
| 253 | | break; |
| 254 | | |
| 255 | | case format_old: |
| 256 | 232 | /* use custom image header. */ |
| 257 | 233 | /* to convert old header-less images to this format, insert a 16-byte |
| 258 | 234 | header as follow: 00 00 03 8f 00 00 00 05 00 00 00 21 00 00 01 00 */ |
| r3065 | r3066 | |
| 260 | 236 | bytes_read = image_fread(d->img, &custom_header, sizeof(custom_header)); |
| 261 | 237 | if (bytes_read != sizeof(custom_header)) |
| 262 | 238 | { |
| 263 | | device_unload_ti990_hd(image); |
| 239 | d->format = format_mame; /* don't care */ |
| 240 | d->wp = 1; |
| 241 | d->unsafe = 1; |
| 264 | 242 | return INIT_FAIL; |
| 265 | 243 | } |
| 266 | 244 | |
| r3065 | r3066 | |
| 268 | 246 | d->heads = get_UINT32BE(custom_header.heads); |
| 269 | 247 | d->sectors_per_track = get_UINT32BE(custom_header.sectors_per_track); |
| 270 | 248 | d->bytes_per_sector = get_UINT32BE(custom_header.bytes_per_sector); |
| 271 | | break; |
| 272 | 249 | } |
| 273 | 250 | |
| 274 | 251 | if (d->bytes_per_sector > MAX_SECTOR_SIZE) |
| 275 | 252 | { |
| 276 | | device_unload_ti990_hd(image); |
| 253 | d->format = format_mame; |
| 254 | d->hd_handle = NULL; |
| 255 | d->wp = 1; |
| 256 | d->unsafe = 1; |
| 277 | 257 | return INIT_FAIL; |
| 278 | 258 | } |
| 279 | 259 | |
| 260 | /* tell whether the image is writable */ |
| 261 | d->wp = ! image_is_writable( image ); |
| 262 | |
| 263 | d->unsafe = 1; |
| 264 | /* set attention line */ |
| 265 | hdc.w[0] |= (0x80 >> id); |
| 266 | |
| 280 | 267 | return INIT_PASS; |
| 281 | 268 | } |
| 282 | 269 | |
| r3065 | r3066 | |
| 285 | 272 | */ |
| 286 | 273 | DEVICE_IMAGE_UNLOAD( ti990_hd ) |
| 287 | 274 | { |
| 288 | | int id = image_index_in_device(image); |
| 275 | int id = get_id_from_device( image ); |
| 289 | 276 | hd_unit_t *d; |
| 290 | 277 | |
| 291 | | if ((id < 0) || (id >= MAX_DISK_UNIT)) |
| 292 | | return; |
| 293 | | |
| 294 | 278 | d = &hdc.d[id]; |
| 295 | 279 | |
| 296 | | switch (d->format) |
| 297 | | { |
| 298 | | case format_mame: |
| 299 | | device_unload_mess_hd(image); |
| 300 | | break; |
| 301 | | |
| 302 | | case format_old: |
| 303 | | /* no additional clean up is needed */ |
| 304 | | break; |
| 305 | | } |
| 306 | | |
| 307 | 280 | d->format = format_mame; /* don't care */ |
| 308 | 281 | d->hd_handle = NULL; |
| 309 | 282 | d->wp = 1; |
| r3065 | r3066 | |
| 337 | 310 | /* |
| 338 | 311 | Init the hdc core |
| 339 | 312 | */ |
| 340 | | void ti990_hdc_init(void (*interrupt_callback)(int state)) |
| 313 | MACHINE_START(ti990_hdc) |
| 341 | 314 | { |
| 342 | 315 | int i; |
| 343 | 316 | |
| 317 | /* initialize harddisk information */ |
| 318 | /* attention lines will be set by DEVICE_IMAGE_LOD */ |
| 319 | for (i=0; i<MAX_DISK_UNIT; i++) |
| 320 | { |
| 321 | hdc.d[i].format = format_mame; |
| 322 | hdc.d[i].hd_handle = NULL; |
| 323 | hdc.d[i].wp = 1; |
| 324 | hdc.d[i].unsafe = 1; |
| 325 | } |
| 326 | } |
| 344 | 327 | |
| 328 | |
| 329 | void ti990_hdc_init(running_machine *machine, void (*interrupt_callback)(int state)) |
| 330 | { |
| 345 | 331 | memset(hdc.w, 0, sizeof(hdc.w)); |
| 346 | 332 | hdc.w[7] = w7_idle; |
| 347 | | /* set attention lines */ |
| 348 | | for (i=0; i<MAX_DISK_UNIT; i++) |
| 349 | | if (is_unit_loaded(i)) |
| 350 | | hdc.w[0] |= (0x80 >> i); |
| 351 | 333 | |
| 334 | /* get references to harddisk devices */ |
| 335 | hdc.d[0].img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk1" ); |
| 336 | hdc.d[1].img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk2" ); |
| 337 | hdc.d[2].img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk3" ); |
| 338 | hdc.d[3].img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, "harddisk4" ); |
| 339 | |
| 352 | 340 | hdc.interrupt_callback = interrupt_callback; |
| 353 | 341 | |
| 354 | 342 | update_interrupt(); |
| 355 | 343 | } |
| 356 | 344 | |
| 345 | |
| 357 | 346 | /* |
| 358 | 347 | Parse the disk select lines, and return the corresponding tape unit. |
| 359 | 348 | (-1 if none) |
| r3065 | r3066 | |
| 1035 | 1024 | } |
| 1036 | 1025 | } |
| 1037 | 1026 | } |
| 1027 | |
| 1028 | |
| 1029 | static const struct harddisk_callback_config ti990_harddisk_config = |
| 1030 | { |
| 1031 | DEVICE_IMAGE_LOAD_NAME( ti990_hd ), |
| 1032 | DEVICE_IMAGE_UNLOAD_NAME( ti990_hd ) |
| 1033 | }; |
| 1034 | |
| 1035 | MACHINE_DRIVER_START( ti990_hdc ) |
| 1036 | MDRV_DEVICE_ADD( "harddisk1", HARDDISK ) |
| 1037 | MDRV_DEVICE_CONFIG( ti990_harddisk_config ) |
| 1038 | MDRV_DEVICE_ADD( "harddisk2", HARDDISK ) |
| 1039 | MDRV_DEVICE_CONFIG( ti990_harddisk_config ) |
| 1040 | MDRV_DEVICE_ADD( "harddisk3", HARDDISK ) |
| 1041 | MDRV_DEVICE_CONFIG( ti990_harddisk_config ) |
| 1042 | MDRV_DEVICE_ADD( "harddisk4", HARDDISK ) |
| 1043 | MDRV_DEVICE_CONFIG( ti990_harddisk_config ) |
| 1044 | MACHINE_DRIVER_END |
| 1045 | |
src/mess/machine/corvushd.c
| r3065 | r3066 | |
| 369 | 369 | // |
| 370 | 370 | // Prototypes |
| 371 | 371 | // |
| 372 | | static hard_disk_file *corvus_hdc_file(int id); |
| 372 | static hard_disk_file *corvus_hdc_file(running_machine *machine, int id); |
| 373 | 373 | static TIMER_CALLBACK(corvus_hdc_callback); |
| 374 | 374 | |
| 375 | 375 | // |
| r3065 | r3066 | |
| 554 | 554 | |
| 555 | 555 | LOG(("corvus_write_sector: Write Drive: %d, physical sector: 0x%5.5x\n", drv, sector)); |
| 556 | 556 | |
| 557 | | if(drv >= device_count(machine, IO_HARDDISK)) { |
| 558 | | logerror("corvus_write_sector: Attempt to write to non-existant drive: %d\n", drv); |
| 559 | | return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE; |
| 560 | | } |
| 561 | | |
| 562 | | disk = corvus_hdc_file(drv); |
| 557 | disk = corvus_hdc_file(machine, drv); |
| 563 | 558 | if(!disk) { |
| 564 | 559 | logerror("corvus_write_sector: Failure returned by corvus_hdc_file(%d)\n", drv); |
| 565 | 560 | return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE; |
| r3065 | r3066 | |
| 670 | 665 | |
| 671 | 666 | LOG(("corvus_read_sector: Read Drive: %d, physical sector: 0x%5.5x\n", drv, sector)); |
| 672 | 667 | |
| 673 | | if(drv >= device_count(machine, IO_HARDDISK)) { |
| 674 | | logerror("corvus_read_sector: Attempt to read from non-existant drive: %d\n", drv); |
| 675 | | return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE; |
| 676 | | } |
| 677 | | |
| 678 | | disk = corvus_hdc_file(drv); |
| 668 | disk = corvus_hdc_file(machine, drv); |
| 679 | 669 | if(!disk) { |
| 680 | 670 | logerror("corvus_read_sector: Failure returned by corvus_hdc_file(%d)\n", drv); |
| 681 | 671 | return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE; |
| r3065 | r3066 | |
| 966 | 956 | // |
| 967 | 957 | drv -= 1; // Internally, drives start at 0 |
| 968 | 958 | |
| 969 | | if(drv >= device_count(machine, IO_HARDDISK)) { |
| 959 | if ( ! corvus_hdc_file( machine, drv ) ) |
| 960 | { |
| 970 | 961 | logerror("corvus_get_drive_parameters: Attempt to retrieve parameters from non-existant drive: %d\n", drv); |
| 971 | 962 | c->xmit_bytes = 1; |
| 972 | 963 | return STAT_FATAL_ERR | STAT_DRIVE_NOT_ONLINE; |
| r3065 | r3066 | |
| 1181 | 1172 | // Returns: |
| 1182 | 1173 | // hard_disk_file object |
| 1183 | 1174 | // |
| 1184 | | static hard_disk_file *corvus_hdc_file(int id) { |
| 1185 | | |
| 1175 | static hard_disk_file *corvus_hdc_file(running_machine *machine, int id) { |
| 1176 | const char *tags[] = { |
| 1177 | "harddisk1" |
| 1178 | }; |
| 1186 | 1179 | const device_config *img; |
| 1187 | 1180 | |
| 1188 | | img = image_from_devtype_and_index(IO_HARDDISK, id); |
| 1181 | /* Only one harddisk supported right now */ |
| 1182 | assert ( id == 0 ); |
| 1183 | |
| 1184 | img = device_list_find_by_tag( machine->config->devicelist, HARDDISK, tags[id] ); |
| 1185 | |
| 1186 | if ( !img ) |
| 1187 | return NULL; |
| 1188 | |
| 1189 | 1189 | if (!image_exists(img)) |
| 1190 | 1190 | return NULL; |
| 1191 | 1191 | |
| r3065 | r3066 | |
| 1433 | 1433 | // Returns: |
| 1434 | 1434 | // NULL if there's no file to attach to |
| 1435 | 1435 | // |
| 1436 | | UINT8 corvus_hdc_init() { |
| 1436 | UINT8 corvus_hdc_init(running_machine *machine) { |
| 1437 | 1437 | |
| 1438 | 1438 | corvus_hdc_t *c = &corvus_hdc; // Pick up global controller structure |
| 1439 | 1439 | hard_disk_file *disk; // Structures for interface to CHD routines |
| 1440 | 1440 | hard_disk_info *info; |
| 1441 | 1441 | |
| 1442 | | if((disk = corvus_hdc_file(0))) // Attach to the CHD file |
| 1442 | if((disk = corvus_hdc_file(machine, 0))) // Attach to the CHD file |
| 1443 | 1443 | info = hard_disk_get_info(disk); // Pick up the Head/Cylinder/Sector info |
| 1444 | 1444 | else |
| 1445 | 1445 | return 0; |
src/mess/devices/idedrive.c
| r3065 | r3066 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | idedrive.c |
| 4 | | |
| 5 | | Code to interface the MESS image code with MAME's IDE core |
| 6 | | |
| 7 | | Raphael Nabet 2003 |
| 8 | | |
| 9 | | *********************************************************************/ |
| 10 | | |
| 11 | | #include "driver.h" |
| 12 | | #include "idedrive.h" |
| 13 | | #include "harddriv.h" |
| 14 | | #include "machine/idectrl.h" |
| 15 | | |
| 16 | | /* FIXME - this is so completely broken until we device-ize IDE drives */ |
| 17 | | struct ide_interface; |
| 18 | | |
| 19 | | static void ide_get_params(const device_config *image, int *which_bus, int *which_address, |
| 20 | | struct ide_interface **intf, |
| 21 | | device_start_func *parent_init, |
| 22 | | device_image_load_func *parent_load, |
| 23 | | device_image_unload_func *parent_unload) |
| 24 | | { |
| 25 | | const mess_device_class *devclass = mess_devclass_from_core_device(image); |
| 26 | | mess_device_class parent_devclass; |
| 27 | | |
| 28 | | *which_bus = image_index_in_device(image); |
| 29 | | *which_address = (int) mess_device_get_info_int(devclass, DEVINFO_INT_IDEDRIVE_ADDRESS); |
| 30 | | *intf = (struct ide_interface *) mess_device_get_info_ptr(devclass, DEVINFO_PTR_IDEDRIVE_INTERFACE); |
| 31 | | |
| 32 | | parent_devclass = *devclass; |
| 33 | | parent_devclass.get_info = harddisk_device_getinfo; |
| 34 | | |
| 35 | | if (parent_init) |
| 36 | | *parent_init = (device_start_func) mess_device_get_info_fct(&parent_devclass, MESS_DEVINFO_PTR_START); |
| 37 | | if (parent_load) |
| 38 | | *parent_load = (device_image_load_func) mess_device_get_info_fct(&parent_devclass, MESS_DEVINFO_PTR_LOAD); |
| 39 | | if (parent_unload) |
| 40 | | *parent_unload = (device_image_unload_func) mess_device_get_info_fct(&parent_devclass, MESS_DEVINFO_PTR_UNLOAD); |
| 41 | | |
| 42 | | assert(*which_address == 0); |
| 43 | | assert(*intf); |
| 44 | | } |
| 45 | | |
| 46 | | |
| 47 | | |
| 48 | | /*------------------------------------------------- |
| 49 | | DEVICE_START(ide_hd) - Init an IDE hard disk device |
| 50 | | -------------------------------------------------*/ |
| 51 | | |
| 52 | | static DEVICE_START(ide_hd) |
| 53 | | { |
| 54 | | int which_bus, which_address; |
| 55 | | struct ide_interface *intf; |
| 56 | | device_start_func parent_init; |
| 57 | | |
| 58 | | /* get the basics */ |
| 59 | | ide_get_params(device, &which_bus, &which_address, &intf, &parent_init, NULL, NULL); |
| 60 | | |
| 61 | | /* call the parent init function */ |
| 62 | | parent_init(device); |
| 63 | | |
| 64 | | /* configure IDE */ |
| 65 | | /* FIXME IDE */ |
| 66 | | /* ide_controller_init_custom(which_bus, intf, NULL); */ |
| 67 | | } |
| 68 | | |
| 69 | | |
| 70 | | |
| 71 | | /*------------------------------------------------- |
| 72 | | DEVICE_IMAGE_LOAD(ide_hd) - Load an IDE hard disk image |
| 73 | | -------------------------------------------------*/ |
| 74 | | |
| 75 | | static DEVICE_IMAGE_LOAD(ide_hd) |
| 76 | | { |
| 77 | | int result, which_bus, which_address; |
| 78 | | struct ide_interface *intf; |
| 79 | | device_image_load_func parent_load; |
| 80 | | |
| 81 | | /* get the basics */ |
| 82 | | ide_get_params(image, &which_bus, &which_address, &intf, NULL, &parent_load, NULL); |
| 83 | | |
| 84 | | /* call the parent load function */ |
| 85 | | result = parent_load(image); |
| 86 | | if (result != INIT_PASS) |
| 87 | | return result; |
| 88 | | |
| 89 | | /* configure IDE */ |
| 90 | | /* FIXME IDE */ |
| 91 | | /* ide_controller_init_custom(which_bus, intf, mess_hd_get_chd_file(image)); */ |
| 92 | | /* ide_controller_reset(which_bus); */ |
| 93 | | return INIT_PASS; |
| 94 | | } |
| 95 | | |
| 96 | | |
| 97 | | |
| 98 | | /*------------------------------------------------- |
| 99 | | DEVICE_IMAGE_UNLOAD(ide_hd) - Unload an IDE hard disk image |
| 100 | | -------------------------------------------------*/ |
| 101 | | |
| 102 | | static DEVICE_IMAGE_UNLOAD(ide_hd) |
| 103 | | { |
| 104 | | int which_bus, which_address; |
| 105 | | struct ide_interface *intf; |
| 106 | | device_image_unload_func parent_unload; |
| 107 | | |
| 108 | | /* get the basics */ |
| 109 | | ide_get_params(image, &which_bus, &which_address, &intf, NULL, NULL, &parent_unload); |
| 110 | | |
| 111 | | /* call the parent unload function */ |
| 112 | | parent_unload(image); |
| 113 | | |
| 114 | | /* configure IDE */ |
| 115 | | /* FIXME IDE */ |
| 116 | | /* ide_controller_init_custom(which_bus, intf, NULL); */ |
| 117 | | /* ide_controller_reset(which_bus); */ |
| 118 | | } |
| 119 | | |
| 120 | | |
| 121 | | |
| 122 | | /*------------------------------------------------- |
| 123 | | ide_hd_validity_check - check this device's validity |
| 124 | | -------------------------------------------------*/ |
| 125 | | |
| 126 | | static int ide_hd_validity_check(const mess_device_class *devclass) |
| 127 | | { |
| 128 | | int error = 0; |
| 129 | | int which_address; |
| 130 | | INT64 count; |
| 131 | | struct ide_interface *intf; |
| 132 | | |
| 133 | | which_address = (int) mess_device_get_info_int(devclass, DEVINFO_INT_IDEDRIVE_ADDRESS); |
| 134 | | intf = (struct ide_interface *) mess_device_get_info_ptr(devclass, DEVINFO_PTR_IDEDRIVE_INTERFACE); |
| 135 | | count = mess_device_get_info_int(devclass, MESS_DEVINFO_INT_COUNT); |
| 136 | | |
| 137 | | if (which_address != 0) |
| 138 | | { |
| 139 | | mame_printf_error("%s: IDE device has non-zero address\n", devclass->gamedrv->name); |
| 140 | | error = 1; |
| 141 | | } |
| 142 | | |
| 143 | | if (!intf) |
| 144 | | { |
| 145 | | mame_printf_error("%s: IDE device does not specify an interface\n", devclass->gamedrv->name); |
| 146 | | error = 1; |
| 147 | | } |
| 148 | | |
| 149 | | return error; |
| 150 | | } |
| 151 | | |
| 152 | | |
| 153 | | |
| 154 | | /*------------------------------------------------- |
| 155 | | ide_harddisk_device_getinfo - Get info proc |
| 156 | | -------------------------------------------------*/ |
| 157 | | |
| 158 | | void ide_harddisk_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 159 | | { |
| 160 | | switch(state) |
| 161 | | { |
| 162 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 163 | | case MESS_DEVINFO_PTR_START: info->start = DEVICE_START_NAME(ide_hd); break; |
| 164 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(ide_hd); break; |
| 165 | | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(ide_hd); break; |
| 166 | | case MESS_DEVINFO_PTR_VALIDITY_CHECK: info->validity_check = ide_hd_validity_check; break; |
| 167 | | |
| 168 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 169 | | case MESS_DEVINFO_STR_NAME: strcpy(info->s = device_temp_str(), "ideharddrive"); break; |
| 170 | | case MESS_DEVINFO_STR_SHORT_NAME: strcpy(info->s = device_temp_str(), "idehd"); break; |
| 171 | | case MESS_DEVINFO_STR_DESCRIPTION: strcpy(info->s = device_temp_str(), "IDE Hard Disk"); break; |
| 172 | | |
| 173 | | default: harddisk_device_getinfo(devclass, state, info); break; |
| 174 | | } |
| 175 | | } |
src/mess/devices/harddriv.c
| r3065 | r3066 | |
| 21 | 21 | #include "harddriv.h" |
| 22 | 22 | |
| 23 | 23 | |
| 24 | | #define MAX_HARDDISKS 8 |
| 25 | | #define USE_CHD_OPEN 0 |
| 26 | | |
| 27 | 24 | static const char *const error_strings[] = |
| 28 | 25 | { |
| 29 | 26 | "no error", |
| r3065 | r3066 | |
| 50 | 47 | "unsupported CHD version" |
| 51 | 48 | }; |
| 52 | 49 | |
| 53 | | static hard_disk_file *drive_handles[MAX_HARDDISKS]; |
| 54 | | |
| 55 | 50 | static const char *chd_get_error_string(int chderr) |
| 56 | 51 | { |
| 57 | 52 | if ((chderr < 0 ) || (chderr >= (sizeof(error_strings) / sizeof(error_strings[0])))) |
| r3065 | r3066 | |
| 73 | 68 | "C1-[512]-1024;H1/2/[4]/8;S1-[16]-64;L128/256/[512]/1024;K512/1024/2048/[4096]"; |
| 74 | 69 | |
| 75 | 70 | |
| 76 | | #define MESSHDTAG "mess_hd" |
| 77 | | |
| 78 | | struct mess_hd |
| 71 | typedef struct _dev_harddisk_t dev_harddisk_t; |
| 72 | struct _dev_harddisk_t |
| 79 | 73 | { |
| 80 | | chd_file *chd; |
| 81 | | hard_disk_file *hard_disk_handle; |
| 74 | const struct harddisk_callback_config *config; |
| 75 | chd_file *chd; |
| 76 | hard_disk_file *hard_disk_handle; |
| 82 | 77 | }; |
| 83 | 78 | |
| 84 | | static struct mess_hd *get_drive(const device_config *img) |
| 85 | | { |
| 86 | | return image_lookuptag(img, MESSHDTAG); |
| 87 | | } |
| 88 | 79 | |
| 89 | | |
| 90 | | |
| 91 | | /************************************* |
| 92 | | * |
| 93 | | * device_init_mess_hd() |
| 94 | | * |
| 95 | | * Device init |
| 96 | | * |
| 97 | | *************************************/ |
| 98 | | |
| 99 | | DEVICE_START( mess_hd ) |
| 80 | INLINE dev_harddisk_t *get_safe_token(const device_config *device) |
| 100 | 81 | { |
| 101 | | struct mess_hd *hd; |
| 102 | | hd = image_alloctag(device, MESSHDTAG, sizeof(struct mess_hd)); |
| 103 | | hd->hard_disk_handle = NULL; |
| 82 | assert( device != NULL ); |
| 83 | assert( device->token != NULL ); |
| 84 | assert( ( device->type == DEVICE_GET_INFO_NAME(mess_hd) ) || |
| 85 | ( device->type == DEVICE_GET_INFO_NAME(mess_ide) ) ); |
| 86 | return (dev_harddisk_t *) device->token; |
| 104 | 87 | } |
| 105 | 88 | |
| 106 | 89 | |
| 107 | | |
| 108 | 90 | /************************************* |
| 109 | 91 | * |
| 110 | | * DEVICE_IMAGE_LOAD_NAME(mess_hd) |
| 111 | | * DEVICE_IMAGE_CREATE_NAME(mess_hd) |
| 92 | * DEVICE_IMAGE_LOAD(mess_hd) |
| 93 | * DEVICE_IMAGE_CREATE(mess_hd) |
| 112 | 94 | * |
| 113 | 95 | * Device load and create |
| 114 | 96 | * |
| r3065 | r3066 | |
| 116 | 98 | |
| 117 | 99 | static int internal_load_mess_hd(const device_config *image, const char *metadata) |
| 118 | 100 | { |
| 119 | | chd_error err = 0; |
| 120 | | struct mess_hd *hd; |
| 121 | | int is_writeable; |
| 122 | | int id = image_index_in_device(image); |
| 101 | dev_harddisk_t *harddisk = get_safe_token( image ); |
| 102 | chd_error err = 0; |
| 103 | int is_writeable; |
| 123 | 104 | |
| 124 | | hd = get_drive(image); |
| 125 | | |
| 126 | 105 | /* open the CHD file */ |
| 127 | 106 | do |
| 128 | 107 | { |
| 129 | 108 | is_writeable = image_is_writable(image); |
| 130 | | hd->chd = NULL; |
| 131 | | err = chd_open_file(image_core_file(image), is_writeable ? CHD_OPEN_READWRITE : CHD_OPEN_READ, NULL, &hd->chd); |
| 109 | harddisk->chd = NULL; |
| 110 | err = chd_open_file(image_core_file(image), is_writeable ? CHD_OPEN_READWRITE : CHD_OPEN_READ, NULL, &harddisk->chd); |
| 132 | 111 | |
| 133 | 112 | /* special case; if we get CHDERR_FILE_NOT_WRITEABLE, make the |
| 134 | 113 | * image read only and repeat */ |
| 135 | 114 | if (err == CHDERR_FILE_NOT_WRITEABLE) |
| 136 | 115 | image_make_readonly(image); |
| 137 | 116 | } |
| 138 | | while(!hd->chd && is_writeable && (err == CHDERR_FILE_NOT_WRITEABLE)); |
| 139 | | if (!hd->chd) |
| 117 | while(!harddisk->chd && is_writeable && (err == CHDERR_FILE_NOT_WRITEABLE)); |
| 118 | if (!harddisk->chd) |
| 140 | 119 | goto done; |
| 141 | 120 | |
| 142 | 121 | /* if we created the image and hence, have metadata to set, set the metadata */ |
| 143 | 122 | if (metadata) |
| 144 | 123 | { |
| 145 | | err = chd_set_metadata(hd->chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1); |
| 124 | err = chd_set_metadata(harddisk->chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1); |
| 146 | 125 | if (err != CHDERR_NONE) |
| 147 | 126 | goto done; |
| 148 | 127 | } |
| 149 | 128 | |
| 150 | 129 | /* open the hard disk file */ |
| 151 | | hd->hard_disk_handle = hard_disk_open(hd->chd); |
| 152 | | if (!hd->hard_disk_handle) |
| 130 | harddisk->hard_disk_handle = hard_disk_open(harddisk->chd); |
| 131 | if (!harddisk->hard_disk_handle) |
| 153 | 132 | goto done; |
| 154 | 133 | |
| 155 | | drive_handles[id] = hd->hard_disk_handle; |
| 156 | | |
| 157 | 134 | done: |
| 158 | 135 | if (err) |
| 159 | 136 | { |
| 160 | 137 | /* if we had an error, close out the CHD */ |
| 161 | | if (hd->chd != NULL) |
| 138 | if (harddisk->chd != NULL) |
| 162 | 139 | { |
| 163 | | chd_close(hd->chd); |
| 164 | | hd->chd = NULL; |
| 140 | chd_close(harddisk->chd); |
| 141 | harddisk->chd = NULL; |
| 165 | 142 | } |
| 166 | 143 | |
| 167 | 144 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, chd_get_error_string(err)); |
| r3065 | r3066 | |
| 173 | 150 | |
| 174 | 151 | DEVICE_IMAGE_LOAD( mess_hd ) |
| 175 | 152 | { |
| 176 | | return internal_load_mess_hd(image, NULL); |
| 153 | dev_harddisk_t *harddisk = get_safe_token( image ); |
| 154 | int our_result; |
| 155 | |
| 156 | our_result = internal_load_mess_hd(image, NULL); |
| 157 | |
| 158 | /* Check if there is an image_load callback defined */ |
| 159 | if ( harddisk->config && harddisk->config->device_image_load ) |
| 160 | { |
| 161 | /* Let the override do some additional work/checks */ |
| 162 | our_result = harddisk->config->device_image_load( image ); |
| 163 | } |
| 164 | return our_result; |
| 177 | 165 | } |
| 178 | 166 | |
| 179 | 167 | |
| r3065 | r3066 | |
| 208 | 196 | |
| 209 | 197 | /************************************* |
| 210 | 198 | * |
| 211 | | * DEVICE_IMAGE_UNLOAD_NAME(mess_hd) |
| 199 | * DEVICE_IMAGE_UNLOAD(mess_hd) |
| 212 | 200 | * |
| 213 | 201 | * Device unload |
| 214 | 202 | * |
| r3065 | r3066 | |
| 216 | 204 | |
| 217 | 205 | DEVICE_IMAGE_UNLOAD( mess_hd ) |
| 218 | 206 | { |
| 219 | | struct mess_hd *hd = get_drive(image); |
| 207 | dev_harddisk_t *harddisk = get_safe_token( image ); |
| 220 | 208 | |
| 221 | | if (hd->hard_disk_handle != NULL) |
| 209 | /* Check if there is an image_unload callback defined */ |
| 210 | if ( harddisk->config && harddisk->config->device_image_unload ) |
| 222 | 211 | { |
| 223 | | hard_disk_close(hd->hard_disk_handle); |
| 224 | | hd->hard_disk_handle = NULL; |
| 212 | harddisk->config->device_image_unload( image ); |
| 225 | 213 | } |
| 226 | 214 | |
| 227 | | if (hd->chd != NULL) |
| 215 | if (harddisk->hard_disk_handle != NULL) |
| 228 | 216 | { |
| 229 | | chd_close(hd->chd); |
| 230 | | hd->chd = NULL; |
| 217 | hard_disk_close(harddisk->hard_disk_handle); |
| 218 | harddisk->hard_disk_handle = NULL; |
| 231 | 219 | } |
| 232 | 220 | |
| 233 | | drive_handles[image_index_in_device(image)] = NULL; |
| 221 | if (harddisk->chd != NULL) |
| 222 | { |
| 223 | chd_close(harddisk->chd); |
| 224 | harddisk->chd = NULL; |
| 225 | } |
| 234 | 226 | } |
| 235 | 227 | |
| 236 | 228 | |
| 237 | | |
| 238 | 229 | /************************************* |
| 239 | 230 | * |
| 240 | | * Get the MESS/MAME hard disk handle (from the src/harddisk.c core) |
| 231 | * Get the MESS/MAME hard disk handle (from the src/harddisk.c core) |
| 241 | 232 | * after an image has been opened with the mess_hd core |
| 242 | 233 | * |
| 243 | 234 | *************************************/ |
| 244 | 235 | |
| 245 | | hard_disk_file *mess_hd_get_hard_disk_file(const device_config *image) |
| 236 | hard_disk_file *mess_hd_get_hard_disk_file(const device_config *device) |
| 246 | 237 | { |
| 247 | | struct mess_hd *hd = get_drive(image); |
| 248 | | return hd->hard_disk_handle; |
| 238 | dev_harddisk_t *harddisk = get_safe_token( device ); |
| 239 | |
| 240 | return harddisk->hard_disk_handle; |
| 249 | 241 | } |
| 250 | 242 | |
| 251 | 243 | |
| 252 | | |
| 253 | 244 | /************************************* |
| 254 | 245 | * |
| 255 | 246 | * Get the MESS/MAME CHD file (from the src/chd.c core) |
| r3065 | r3066 | |
| 257 | 248 | * |
| 258 | 249 | *************************************/ |
| 259 | 250 | |
| 260 | | chd_file *mess_hd_get_chd_file(const device_config *image) |
| 251 | chd_file *mess_hd_get_chd_file(const device_config *device) |
| 261 | 252 | { |
| 262 | 253 | chd_file *result = NULL; |
| 263 | 254 | hard_disk_file *hd_file; |
| 264 | 255 | |
| 265 | | if (image) |
| 256 | if (device) |
| 266 | 257 | { |
| 267 | | hd_file = mess_hd_get_hard_disk_file(image); |
| 258 | hd_file = mess_hd_get_hard_disk_file(device); |
| 268 | 259 | if (hd_file) |
| 269 | 260 | result = hard_disk_get_chd(hd_file); |
| 270 | 261 | } |
| r3065 | r3066 | |
| 272 | 263 | } |
| 273 | 264 | |
| 274 | 265 | |
| 266 | /*------------------------------------------------- |
| 267 | DEVICE_START(mess_hd) |
| 268 | -------------------------------------------------*/ |
| 275 | 269 | |
| 276 | | /************************************* |
| 277 | | * |
| 278 | | * Device specification function |
| 279 | | * |
| 280 | | *************************************/ |
| 270 | static DEVICE_START(mess_hd) |
| 271 | { |
| 272 | dev_harddisk_t *harddisk = get_safe_token( device ); |
| 281 | 273 | |
| 282 | | void harddisk_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 274 | harddisk->config = device->static_config; |
| 275 | harddisk->chd = NULL; |
| 276 | harddisk->hard_disk_handle = NULL; |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /*------------------------------------------------- |
| 281 | DEVICE_GET_INFO(mess_hd) |
| 282 | -------------------------------------------------*/ |
| 283 | |
| 284 | DEVICE_GET_INFO(mess_hd) |
| 283 | 285 | { |
| 284 | | switch(state) |
| 286 | switch( state ) |
| 285 | 287 | { |
| 286 | 288 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 287 | | case MESS_DEVINFO_INT_TYPE: info->i = IO_HARDDISK; break; |
| 288 | | case MESS_DEVINFO_INT_READABLE: info->i = 1; break; |
| 289 | | case MESS_DEVINFO_INT_WRITEABLE: info->i = 1; break; |
| 290 | | case MESS_DEVINFO_INT_CREATABLE: info->i = 0; break; |
| 291 | | case MESS_DEVINFO_INT_CREATE_OPTCOUNT: info->i = 1; break; |
| 289 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(dev_harddisk_t); break; |
| 290 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 291 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 292 | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_HARDDISK; break; |
| 293 | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 294 | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 295 | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 0; break; |
| 296 | case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT: info->i = 1; break; |
| 292 | 297 | |
| 293 | 298 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 294 | | case MESS_DEVINFO_PTR_START: info->start = DEVICE_START_NAME(mess_hd); break; |
| 295 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(mess_hd); break; |
| 296 | | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(mess_hd); break; |
| 297 | | case MESS_DEVINFO_PTR_CREATE: info->create = DEVICE_IMAGE_CREATE_NAME(mess_hd); break; |
| 298 | | case MESS_DEVINFO_PTR_CREATE_OPTGUIDE: info->p = (void *) mess_hd_option_guide; break; |
| 299 | | case MESS_DEVINFO_PTR_CREATE_OPTSPEC+0: info->p = (void *) mess_hd_option_spec; |
| 299 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mess_hd); break; |
| 300 | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(mess_hd); break; |
| 301 | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(mess_hd); break; |
| 302 | case DEVINFO_FCT_IMAGE_CREATE: info->f = (genf *) DEVICE_IMAGE_CREATE_NAME(mess_hd); break; |
| 303 | case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE: info->p = (void *) mess_hd_option_guide; break; |
| 304 | case DEVINFO_PTR_IMAGE_CREATE_OPTSPEC+0: info->p = (void *) mess_hd_option_spec; break; |
| 300 | 305 | |
| 301 | 306 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 302 | | case MESS_DEVINFO_STR_DEV_FILE: strcpy(info->s = device_temp_str(), __FILE__); break; |
| 303 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "chd,hd"); break; |
| 304 | | case MESS_DEVINFO_STR_CREATE_OPTNAME+0: strcpy(info->s = device_temp_str(), "chd"); break; |
| 305 | | case MESS_DEVINFO_STR_CREATE_OPTDESC+0: strcpy(info->s = device_temp_str(), "MAME/MESS CHD Hard drive"); break; |
| 306 | | case MESS_DEVINFO_STR_CREATE_OPTEXTS+0: strcpy(info->s = device_temp_str(), "chd,hd"); break; |
| 307 | case DEVINFO_STR_NAME: info->s = "Harddisk"; break; |
| 308 | case DEVINFO_STR_FAMILY: info->s = "Harddisk"; break; |
| 309 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 310 | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: info->s = "chd,hd"; break; |
| 311 | case DEVINFO_STR_IMAGE_CREATE_OPTNAME+0: info->s = "chd"; break; |
| 312 | case DEVINFO_STR_IMAGE_CREATE_OPTDESC+0: info->s = "MAME/MESS CHD Hard drive"; break; |
| 313 | case DEVINFO_STR_IMAGE_CREATE_OPTEXTS+0: info->s = "chd,hd"; break; |
| 307 | 314 | } |
| 308 | 315 | } |
| 309 | 316 | |
| 310 | | hard_disk_file *mess_hd_get_hard_disk_file_by_number(const char *diskregion) |
| 317 | |
| 318 | static DEVICE_START(mess_ide) |
| 311 | 319 | { |
| 312 | | const device_config *device; |
| 313 | | device = device_list_find_by_tag(Machine->config->devicelist, DEVICE_TYPE_WILDCARD, diskregion); |
| 314 | | return mess_hd_get_hard_disk_file(device); |
| 320 | /* old code from idedrive.c */ |
| 321 | #ifdef UNUSED_FUNCTION |
| 322 | int which_bus, which_address; |
| 323 | struct ide_interface *intf; |
| 324 | device_start_func parent_init; |
| 325 | |
| 326 | /* get the basics */ |
| 327 | ide_get_params(device, &which_bus, &which_address, &intf, &parent_init, NULL, NULL); |
| 328 | |
| 329 | /* call the parent init function */ |
| 330 | parent_init(device); |
| 331 | |
| 332 | /* configure IDE */ |
| 333 | /* FIXME IDE */ |
| 334 | /* ide_controller_init_custom(which_bus, intf, NULL); */ |
| 335 | #endif |
| 336 | |
| 337 | DEVICE_START_CALL(mess_hd); |
| 315 | 338 | } |
| 316 | 339 | |
| 340 | |
| 341 | static DEVICE_IMAGE_LOAD(mess_ide) |
| 342 | { |
| 343 | /* old code from idedrive.c */ |
| 344 | #ifdef UNUSED_FUNCTION |
| 345 | int result, which_bus, which_address; |
| 346 | struct ide_interface *intf; |
| 347 | device_image_load_func parent_load; |
| 348 | |
| 349 | /* get the basics */ |
| 350 | ide_get_params(image, &which_bus, &which_address, &intf, NULL, &parent_load, NULL); |
| 351 | |
| 352 | /* call the parent load function */ |
| 353 | result = parent_load(image); |
| 354 | if (result != INIT_PASS) |
| 355 | return result; |
| 356 | |
| 357 | /* configure IDE */ |
| 358 | /* FIXME IDE */ |
| 359 | /* ide_controller_init_custom(which_bus, intf, mess_hd_get_chd_file(image)); */ |
| 360 | /* ide_controller_reset(which_bus); */ |
| 361 | return INIT_PASS; |
| 362 | #endif |
| 363 | return device_load_mess_hd( image ); |
| 364 | } |
| 365 | |
| 366 | |
| 367 | static DEVICE_IMAGE_UNLOAD(mess_ide) |
| 368 | { |
| 369 | /* old code from idedrive.c */ |
| 370 | #ifdef UNUSED_FUNCTION |
| 371 | int which_bus, which_address; |
| 372 | struct ide_interface *intf; |
| 373 | device_image_unload_func parent_unload; |
| 374 | |
| 375 | /* get the basics */ |
| 376 | ide_get_params(image, &which_bus, &which_address, &intf, NULL, NULL, &parent_unload); |
| 377 | |
| 378 | /* call the parent unload function */ |
| 379 | parent_unload(image); |
| 380 | |
| 381 | /* configure IDE */ |
| 382 | /* FIXME IDE */ |
| 383 | /* ide_controller_init_custom(which_bus, intf, NULL); */ |
| 384 | /* ide_controller_reset(which_bus); */ |
| 385 | #endif |
| 386 | device_unload_mess_hd( image ); |
| 387 | } |
| 388 | |
| 389 | |
| 390 | #ifdef UNSUED_FUNCTION |
| 391 | /*------------------------------------------------- |
| 392 | ide_hd_validity_check - check this device's validity |
| 393 | -------------------------------------------------*/ |
| 394 | |
| 395 | static int ide_hd_validity_check(const mess_device_class *devclass) |
| 396 | { |
| 397 | int error = 0; |
| 398 | int which_address; |
| 399 | INT64 count; |
| 400 | struct ide_interface *intf; |
| 401 | |
| 402 | which_address = (int) mess_device_get_info_int(devclass, DEVINFO_INT_IDEDRIVE_ADDRESS); |
| 403 | intf = (struct ide_interface *) mess_device_get_info_ptr(devclass, DEVINFO_PTR_IDEDRIVE_INTERFACE); |
| 404 | count = mess_device_get_info_int(devclass, MESS_DEVINFO_INT_COUNT); |
| 405 | |
| 406 | if (which_address != 0) |
| 407 | { |
| 408 | mame_printf_error("%s: IDE device has non-zero address\n", devclass->gamedrv->name); |
| 409 | error = 1; |
| 410 | } |
| 411 | |
| 412 | if (!intf) |
| 413 | { |
| 414 | mame_printf_error("%s: IDE device does not specify an interface\n", devclass->gamedrv->name); |
| 415 | error = 1; |
| 416 | } |
| 417 | |
| 418 | return error; |
| 419 | } |
| 420 | #endif |
| 421 | |
| 422 | |
| 423 | DEVICE_GET_INFO(mess_ide) |
| 424 | { |
| 425 | switch( state ) |
| 426 | { |
| 427 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 428 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mess_ide); break; |
| 429 | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(mess_ide); break; |
| 430 | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(mess_ide); break; |
| 431 | // case DEVINFO_FCT_IMAGE_VERIFY: info->f = (genf *) ide_hd_validity_check; break; |
| 432 | |
| 433 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 434 | case DEVINFO_STR_NAME: info->s = "IDE harddisk"; break; |
| 435 | case DEVINFO_STR_IMAGE_INSTANCE_NAME: info->s = "ideharddrive"; break; |
| 436 | case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME: info->s = "idehd"; break; |
| 437 | |
| 438 | default: DEVICE_GET_INFO_CALL( mess_hd ); break; |
| 439 | } |
| 440 | } |
| 441 | |
src/mess/drivers/pc.c
| r3065 | r3066 | |
| 1338 | 1338 | MDRV_DEVICE_CONFIG( ibm5150_pic8259_slave_config ) |
| 1339 | 1339 | |
| 1340 | 1340 | MDRV_DEVICE_ADD( "ppi8255", PPI8255 ) |
| 1341 | | MDRV_DEVICE_CONFIG( ibm5150_ppi8255_interface ) |
| 1341 | MDRV_DEVICE_CONFIG( ibm5160_ppi8255_interface ) |
| 1342 | 1342 | |
| 1343 | 1343 | MDRV_DEVICE_ADD( "ins8250_0", INS8250 ) /* TODO: Verify model */ |
| 1344 | 1344 | MDRV_DEVICE_CONFIG( ibm5150_com_interface[0] ) |
| r3065 | r3066 | |
| 1375 | 1375 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1376 | 1376 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1377 | 1377 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1378 | |
| 1379 | /* harddisk */ |
| 1380 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1378 | 1381 | MACHINE_DRIVER_END |
| 1379 | 1382 | |
| 1380 | 1383 | |
| r3065 | r3066 | |
| 1401 | 1404 | MDRV_DEVICE_CONFIG( ibm5150_pic8259_slave_config ) |
| 1402 | 1405 | |
| 1403 | 1406 | MDRV_DEVICE_ADD( "ppi8255", PPI8255 ) |
| 1404 | | MDRV_DEVICE_CONFIG( ibm5150_ppi8255_interface ) |
| 1407 | MDRV_DEVICE_CONFIG( ibm5160_ppi8255_interface ) |
| 1405 | 1408 | |
| 1406 | 1409 | MDRV_DEVICE_ADD( "ins8250_0", INS8250 ) /* TODO: Verify model */ |
| 1407 | 1410 | MDRV_DEVICE_CONFIG( ibm5150_com_interface[0] ) |
| r3065 | r3066 | |
| 1438 | 1441 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1439 | 1442 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1440 | 1443 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1444 | |
| 1445 | /* harddisk */ |
| 1446 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1441 | 1447 | MACHINE_DRIVER_END |
| 1442 | 1448 | |
| 1443 | 1449 | static MACHINE_DRIVER_START( ibm5150 ) |
| r3065 | r3066 | |
| 1504 | 1510 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1505 | 1511 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1506 | 1512 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1513 | |
| 1514 | /* harddisk */ |
| 1515 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1507 | 1516 | MACHINE_DRIVER_END |
| 1508 | 1517 | |
| 1509 | 1518 | static MACHINE_DRIVER_START( pccga ) |
| r3065 | r3066 | |
| 1567 | 1576 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1568 | 1577 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1569 | 1578 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1579 | |
| 1580 | /* harddisk */ |
| 1581 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1570 | 1582 | MACHINE_DRIVER_END |
| 1571 | 1583 | |
| 1572 | 1584 | |
| r3065 | r3066 | |
| 1623 | 1635 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1624 | 1636 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1625 | 1637 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1638 | |
| 1639 | /* harddisk */ |
| 1640 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1626 | 1641 | MACHINE_DRIVER_END |
| 1627 | 1642 | |
| 1628 | 1643 | |
| r3065 | r3066 | |
| 1685 | 1700 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1686 | 1701 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1687 | 1702 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1703 | |
| 1704 | /* harddisk */ |
| 1705 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1688 | 1706 | MACHINE_DRIVER_END |
| 1689 | 1707 | |
| 1690 | 1708 | |
| r3065 | r3066 | |
| 1734 | 1752 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1735 | 1753 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1736 | 1754 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1755 | |
| 1756 | /* harddisk */ |
| 1757 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1737 | 1758 | MACHINE_DRIVER_END |
| 1738 | 1759 | |
| 1739 | 1760 | |
| r3065 | r3066 | |
| 1785 | 1806 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1786 | 1807 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1787 | 1808 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1809 | |
| 1810 | /* harddisk */ |
| 1811 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1788 | 1812 | MACHINE_DRIVER_END |
| 1789 | 1813 | |
| 1790 | 1814 | |
| r3065 | r3066 | |
| 1839 | 1863 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1840 | 1864 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1841 | 1865 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1866 | |
| 1867 | /* harddisk */ |
| 1868 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1842 | 1869 | MACHINE_DRIVER_END |
| 1843 | 1870 | |
| 1844 | 1871 | |
| r3065 | r3066 | |
| 1897 | 1924 | MDRV_SOUND_ADD("saa1099.2", SAA1099, 4772720) |
| 1898 | 1925 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1899 | 1926 | #endif |
| 1927 | |
| 1928 | /* harddisk */ |
| 1929 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1900 | 1930 | MACHINE_DRIVER_END |
| 1901 | 1931 | |
| 1902 | 1932 | |
| r3065 | r3066 | |
| 1944 | 1974 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1945 | 1975 | MDRV_DEVICE_ADD("printer2", PRINTER) |
| 1946 | 1976 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1977 | |
| 1978 | /* harddisk */ |
| 1979 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1947 | 1980 | MACHINE_DRIVER_END |
| 1948 | 1981 | |
| 1949 | 1982 | |
| r3065 | r3066 | |
| 2431 | 2464 | } |
| 2432 | 2465 | } |
| 2433 | 2466 | |
| 2434 | | static void ibmpc_harddisk_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 2435 | | { |
| 2436 | | /* harddisk */ |
| 2437 | | switch(state) |
| 2438 | | { |
| 2439 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2440 | | case MESS_DEVINFO_INT_COUNT: info->i = 4; break; |
| 2441 | 2467 | |
| 2442 | | default: harddisk_device_getinfo(devclass, state, info); break; |
| 2443 | | } |
| 2444 | | } |
| 2445 | | |
| 2446 | 2468 | static void pcjr_cartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 2447 | 2469 | { |
| 2448 | 2470 | switch( state ) |
| r3065 | r3066 | |
| 2465 | 2487 | CONFIG_RAM_DEFAULT( 640 * 1024 ) |
| 2466 | 2488 | CONFIG_DEVICE(ibmpc_cassette_getinfo) |
| 2467 | 2489 | CONFIG_DEVICE(ibmpc_floppy_getinfo) |
| 2468 | | CONFIG_DEVICE(ibmpc_harddisk_getinfo) |
| 2469 | 2490 | SYSTEM_CONFIG_END |
| 2470 | 2491 | |
| 2471 | 2492 | |
| 2472 | 2493 | static SYSTEM_CONFIG_START(ibm5160) |
| 2473 | 2494 | CONFIG_RAM_DEFAULT( 640 * 1024 ) |
| 2474 | 2495 | CONFIG_DEVICE(ibmpc_floppy_getinfo) |
| 2475 | | CONFIG_DEVICE(ibmpc_harddisk_getinfo) |
| 2476 | 2496 | SYSTEM_CONFIG_END |
| 2477 | 2497 | |
| 2478 | 2498 | |
src/mess/drivers/ti99_4x.c
| r3065 | r3066 | |
| 35 | 35 | #include "machine/smartmed.h" |
| 36 | 36 | #include "sound/5220intf.h" |
| 37 | 37 | #include "machine/idectrl.h" |
| 38 | #include "machine/smc92x4.h" |
| 38 | 39 | |
| 39 | 40 | /* |
| 40 | 41 | memory map |
| r3065 | r3066 | |
| 530 | 531 | |
| 531 | 532 | /* devices */ |
| 532 | 533 | MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt ) /* FIXME */ |
| 534 | |
| 535 | MDRV_IMPORT_FROM( smc92x4_hd ) |
| 536 | |
| 537 | MDRV_DEVICE_ADD( "ide_harddisk", IDE_HARDDISK ) |
| 533 | 538 | MACHINE_DRIVER_END |
| 534 | 539 | |
| 535 | 540 | static MACHINE_DRIVER_START(ti99_4_50hz) |
| r3065 | r3066 | |
| 561 | 566 | |
| 562 | 567 | /* devices */ |
| 563 | 568 | MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt ) /* FIXME */ |
| 569 | |
| 570 | MDRV_IMPORT_FROM( smc92x4_hd ) |
| 571 | |
| 572 | MDRV_DEVICE_ADD( "ide_harddisk", IDE_HARDDISK ) |
| 564 | 573 | MACHINE_DRIVER_END |
| 565 | 574 | |
| 566 | 575 | static MACHINE_DRIVER_START(ti99_4a_60hz) |
| r3065 | r3066 | |
| 592 | 601 | |
| 593 | 602 | /* devices */ |
| 594 | 603 | MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt ) /* FIXME */ |
| 604 | |
| 605 | MDRV_IMPORT_FROM( smc92x4_hd ) |
| 606 | |
| 607 | MDRV_DEVICE_ADD( "ide_harddisk", IDE_HARDDISK ) |
| 595 | 608 | MACHINE_DRIVER_END |
| 596 | 609 | |
| 597 | 610 | |
| r3065 | r3066 | |
| 624 | 637 | |
| 625 | 638 | /* devices */ |
| 626 | 639 | MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt ) /* FIXME */ |
| 640 | |
| 641 | MDRV_IMPORT_FROM( smc92x4_hd ) |
| 642 | |
| 643 | MDRV_DEVICE_ADD( "ide_harddisk", IDE_HARDDISK ) |
| 627 | 644 | MACHINE_DRIVER_END |
| 628 | 645 | |
| 629 | 646 | |
| r3065 | r3066 | |
| 664 | 681 | |
| 665 | 682 | /* devices */ |
| 666 | 683 | MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt ) /* FIXME */ |
| 684 | |
| 685 | MDRV_IMPORT_FROM( smc92x4_hd ) |
| 686 | |
| 687 | MDRV_DEVICE_ADD( "ide_harddisk", IDE_HARDDISK ) |
| 667 | 688 | MACHINE_DRIVER_END |
| 668 | 689 | |
| 669 | 690 | |
| r3065 | r3066 | |
| 820 | 841 | } |
| 821 | 842 | } |
| 822 | 843 | |
| 823 | | static void ti99_4_harddisk_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 824 | | { |
| 825 | | /* harddisk */ |
| 826 | | switch(state) |
| 827 | | { |
| 828 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 829 | | case MESS_DEVINFO_INT_TYPE: info->i = IO_HARDDISK; break; |
| 830 | | case MESS_DEVINFO_INT_READABLE: info->i = 1; break; |
| 831 | | case MESS_DEVINFO_INT_WRITEABLE: info->i = 1; break; |
| 832 | | case MESS_DEVINFO_INT_CREATABLE: info->i = 0; break; |
| 833 | | case MESS_DEVINFO_INT_COUNT: info->i = 3; break; |
| 834 | | |
| 835 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 836 | | case MESS_DEVINFO_PTR_START: info->start = DEVICE_START_NAME(mess_hd); break; |
| 837 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(ti99_hd); break; |
| 838 | | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(ti99_hd); break; |
| 839 | | |
| 840 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 841 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "hd"); break; |
| 842 | | case MESS_DEVINFO_STR_DEV_TAG: strcpy(info->s = device_temp_str(), "ti99_4x_hd"); break; |
| 843 | | } |
| 844 | | } |
| 845 | | |
| 846 | 844 | static void ti99_4_parallel_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 847 | 845 | { |
| 848 | 846 | /* parallel */ |
| r3065 | r3066 | |
| 932 | 930 | CONFIG_DEVICE(ti99_4_cassette_getinfo) |
| 933 | 931 | CONFIG_DEVICE(ti99_4_cartslot_getinfo) |
| 934 | 932 | CONFIG_DEVICE(ti99_4_floppy_getinfo) |
| 935 | | CONFIG_DEVICE(ti99_4_harddisk_getinfo) |
| 936 | | CONFIG_DEVICE(ti99_ide_harddisk_getinfo) |
| 937 | 933 | CONFIG_DEVICE(ti99_4_parallel_getinfo) |
| 938 | 934 | CONFIG_DEVICE(ti99_4_serial_getinfo) |
| 939 | 935 | /*CONFIG_DEVICE(ti99_4_quickload_getinfo)*/ |