~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to grub-core/disk/ata.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-05-17 23:59:10 UTC
  • mto: (17.3.55 sid)
  • mto: This revision was merged to the branch mainline in revision 122.
  • Revision ID: james.westby@ubuntu.com-20110517235910-ma8u889vyjdfro27
Tags: upstream-1.99
ImportĀ upstreamĀ versionĀ 1.99

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <grub/scsi.h>
27
27
#include <grub/cs5536.h>
28
28
 
 
29
GRUB_MOD_LICENSE ("GPLv3+");
 
30
 
29
31
/* At the moment, only two IDE ports are supported.  */
30
32
static const grub_port_t grub_ata_ioaddress[] = { GRUB_ATA_CH0_PORT1,
31
33
                                                  GRUB_ATA_CH1_PORT1 };
158
160
 
159
161
  grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4);
160
162
  grub_ata_wait ();
161
 
  if (grub_ata_check_ready (dev))
 
163
  if ((grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
 
164
      && grub_ata_wait_not_busy (dev, dev->present ? GRUB_ATA_TOUT_DEV_INIT 
 
165
                                 : GRUB_ATA_TOUT_STD))
162
166
    {
163
167
      grub_free (info);
 
168
      dev->present = 0;
164
169
      return grub_errno;
165
170
    }
166
171
 
167
172
  grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_PACKET_DEVICE);
168
173
  grub_ata_wait ();
169
174
 
170
 
  if (grub_ata_wait_drq (dev, 0, GRUB_ATA_TOUT_STD))
 
175
  if (grub_ata_wait_drq (dev, 0, dev->present ? GRUB_ATA_TOUT_DEV_INIT 
 
176
                         : GRUB_ATA_TOUT_STD))
171
177
    {
172
178
      grub_free (info);
 
179
      dev->present = 0;
173
180
      return grub_errno;
174
181
    }
175
182
  grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE);
256
263
 
257
264
  grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4);
258
265
  grub_ata_wait ();
259
 
  if (grub_ata_check_ready (dev))
 
266
  if ((grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
 
267
      && grub_ata_wait_not_busy (dev, dev->present ? GRUB_ATA_TOUT_DEV_INIT 
 
268
                                 : GRUB_ATA_TOUT_STD))
260
269
    {
 
270
      dev->present = 0;
261
271
      grub_free (info);
262
272
      return grub_errno;
263
273
    }
265
275
  grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_DEVICE);
266
276
  grub_ata_wait ();
267
277
 
268
 
  if (grub_ata_wait_drq (dev, 0, GRUB_ATA_TOUT_STD))
 
278
  if (grub_ata_wait_drq (dev, 0, dev->present ? GRUB_ATA_TOUT_DEV_INIT 
 
279
                         : GRUB_ATA_TOUT_STD))
269
280
    {
270
281
      grub_free (info);
271
282
      grub_errno = GRUB_ERR_NONE;
278
289
        return grub_atapi_identify (dev);
279
290
 
280
291
      else if (sts == 0x00)
281
 
        /* No device, return error but don't print message.  */
282
 
        return GRUB_ERR_UNKNOWN_DEVICE;
283
 
 
 
292
        {
 
293
          dev->present = 0;
 
294
          /* No device, return error but don't print message.  */
 
295
          return GRUB_ERR_UNKNOWN_DEVICE;
 
296
        }
284
297
      else
285
 
        /* Other Error.  */
286
 
        return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
287
 
                           "device cannot be identified");
 
298
        {
 
299
          dev->present = 0;
 
300
          /* Other Error.  */
 
301
          return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
 
302
                             "device cannot be identified");
 
303
        }
288
304
    }
289
305
 
290
306
  grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE);
379
395
  dev->device = device;
380
396
  dev->ioaddress = addr + GRUB_MACHINE_PCI_IO_BASE;
381
397
  dev->ioaddress2 = addr2 + GRUB_MACHINE_PCI_IO_BASE;
 
398
  dev->present = 1;
382
399
  dev->next = NULL;
383
400
 
384
401
  /* Register the device.  */