~ubuntu-branches/ubuntu/precise/mame/precise-proposed

« back to all changes in this revision

Viewing changes to src/emu/machine/idectrl.c

  • Committer: Package Import Robot
  • Author(s): Cesare Falco
  • Date: 2011-11-30 18:50:10 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111130185010-02hcxybht1mn082w
Tags: 0.144-0ubuntu1
* New upstream release (LP: #913550)
* mame.install:
  - Added artwork/ images to be used with -effect switch
  - Be more selective with hash/ contents
* contrib/mame.ini: added /usr/share/games/mame/artwork/ to artpath

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
#define IDE_COMMAND_VERIFY_NORETRY              0x41
83
83
#define IDE_COMMAND_ATAPI_IDENTIFY              0xa1
84
84
#define IDE_COMMAND_RECALIBRATE                 0x10
 
85
#define IDE_COMMAND_SEEK                                0x70
85
86
#define IDE_COMMAND_IDLE_IMMEDIATE              0xe1
86
87
#define IDE_COMMAND_IDLE                                0xe3
87
88
#define IDE_COMMAND_TAITO_GNET_UNLOCK_1 0xfe
154
155
 
155
156
        chd_file       *handle;
156
157
        hard_disk_file *disk;
 
158
        bool                    is_image_device;
157
159
        emu_timer *             last_status_timer;
158
160
        emu_timer *             reset_timer;
159
161
 
163
165
        const UINT8 *   user_password;
164
166
 
165
167
        UINT8                   gnetreadlock;
 
168
        ide_hardware *  hardware;
166
169
};
167
170
 
168
171
 
732
735
        /* now do the read */
733
736
        if (ide->disk)
734
737
                count = hard_disk_read(ide->disk, lba, ide->buffer);
 
738
        else if (ide->hardware != NULL) {
 
739
                count = ide->hardware->read_sector(ide->device, lba, ide->buffer);
 
740
        }
735
741
 
736
742
        /* by default, mark the buffer ready and the seek complete */
737
743
        if (!ide->verify_only)
930
936
        /* now do the write */
931
937
        if (ide->disk)
932
938
                count = hard_disk_write(ide->disk, lba, ide->buffer);
 
939
        else if (ide->hardware != NULL) {
 
940
                count = ide->hardware->write_sector(ide->device, lba, ide->buffer);
 
941
        }
933
942
 
934
943
        /* by default, mark the buffer ready and the seek complete */
935
944
        ide->status |= IDE_STATUS_BUFFER_READY;
1253
1262
                        signal_interrupt(ide);
1254
1263
                        break;
1255
1264
 
 
1265
                case IDE_COMMAND_SEEK:
 
1266
                        /*
 
1267
                cur_cylinder, cur_sector and cur_head
 
1268
                are all already set in this case so no need
 
1269
                so that implements actual seek
 
1270
            */
 
1271
                        /* clear the error too */
 
1272
                        ide->error = IDE_ERROR_NONE;
 
1273
 
 
1274
                        /* for timeout disabled value is 0 */
 
1275
                        ide->sector_count = 0;
 
1276
                        /* signal an interrupt */
 
1277
                        signal_interrupt(ide);
 
1278
                        break;
 
1279
 
 
1280
 
1256
1281
                default:
1257
1282
                        LOGPRINT(("IDE unknown command (%02X)\n", command));
1258
1283
                        ide->status |= IDE_STATUS_ERROR;
1835
1860
        config = (const ide_config *)downcast<const legacy_device_base *>(device)->inline_config();
1836
1861
        ide->handle = get_disk_handle(device->machine(), (config->master != NULL) ? config->master : device->tag());
1837
1862
        ide->disk = hard_disk_open(ide->handle);
 
1863
        ide->is_image_device = false;
1838
1864
        assert_always(config->slave == NULL, "IDE controller does not yet support slave drives\n");
1839
1865
 
1840
1866
        /* find the bus master space */
1866
1892
 
1867
1893
                /* build the features page */
1868
1894
                ide_build_features(ide);
 
1895
        } else if (config->hardware != NULL) {
 
1896
                ide->hardware = (ide_hardware *)config->hardware;
 
1897
                ide->hardware->get_info(ide->device, ide->features, ide->num_cylinders, ide->num_sectors, ide->num_heads);
 
1898
                ide_generate_features (ide);
1869
1899
        }
1870
1900
 
1871
1901
        /* create a timer for timing status */
1927
1957
static DEVICE_STOP( ide_controller )
1928
1958
{
1929
1959
        ide_state *ide = get_safe_token(device);
1930
 
 
1931
 
        /* close the hard disk */
1932
 
        if (ide->disk != NULL)
1933
 
                hard_disk_close(ide->disk);
 
1960
        if (!ide->is_image_device) {
 
1961
                /* close the hard disk */
 
1962
                if (ide->disk != NULL)
 
1963
                        hard_disk_close(ide->disk);
 
1964
        }
1934
1965
}
1935
1966
 
1936
1967
 
1943
1974
        ide_state *ide = get_safe_token(device);
1944
1975
 
1945
1976
        LOG(("IDE controller reset performed\n"));
 
1977
        astring hardtag;
 
1978
        device->siblingtag(hardtag, "harddisk");
1946
1979
 
1947
 
        if (device->machine().device( "harddisk" )) {
 
1980
        if (device->machine().device( hardtag.cstr() )) {
1948
1981
                if (!ide->disk)
1949
1982
                {
1950
 
                        ide->handle = device->machine().device<harddisk_image_device>("harddisk")->get_chd_file();      // should be config->master
 
1983
                        ide->handle = device->machine().device<harddisk_image_device>(hardtag.cstr())->get_chd_file();  // should be config->master
1951
1984
 
1952
1985
                        if (ide->handle)
1953
1986
                        {
1954
 
                                ide->disk = device->machine().device<harddisk_image_device>("harddisk")->get_hard_disk_file();  // should be config->master
 
1987
                                ide->disk = device->machine().device<harddisk_image_device>(hardtag.cstr())->get_hard_disk_file();      // should be config->master
 
1988
                                ide->is_image_device = true;
1955
1989
 
1956
1990
                                if (ide->disk != NULL)
1957
1991
                                {
1971
2005
                                }
1972
2006
                        }
1973
2007
                }
 
2008
        } else if (ide->hardware != NULL) {
 
2009
                ide->hardware->get_info(ide->device, ide->features, ide->num_cylinders, ide->num_sectors, ide->num_heads);
 
2010
                ide_generate_features (ide);
1974
2011
        }
1975
2012
 
1976
2013
        /* reset the drive state */