]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-07-03 Pavel Roskin <proski@gnu.org>
authorproski <proski@localhost>
Thu, 3 Jul 2008 20:53:00 +0000 (20:53 +0000)
committerproski <proski@localhost>
Thu, 3 Jul 2008 20:53:00 +0000 (20:53 +0000)
* disk/ata.c (grub_ata_pio_write): Check status before writing,
like we do in grub_ata_pio_read().
(grub_ata_readwrite): Always write individual sectors.  Fix the
sector count for the remainder.
(grub_ata_write): Enable writing to ATA devices.  Correctly
report error for ATAPI devices.

ChangeLog
disk/ata.c

index d2a7af460861251cbe35bb7d9874c6447087c697..21925bc00f4b552eff0f5be28750dd70a6a5c60d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-07-03  Pavel Roskin  <proski@gnu.org>
+
+       * disk/ata.c (grub_ata_pio_write): Check status before writing,
+       like we do in grub_ata_pio_read().
+       (grub_ata_readwrite): Always write individual sectors.  Fix the
+       sector count for the remainder.
+       (grub_ata_write): Enable writing to ATA devices.  Correctly
+       report error for ATAPI devices.
+
 2008-07-02  Pavel Roskin  <proski@gnu.org>
 
        * boot/i386/pc/cdboot.S: Add _start entry to fix a linker
index 02c4b068aa81502a0e3d4639914103791cd3498b..c9b0498250a1dda38bbfc356681569d6a6cafe9f 100644 (file)
@@ -187,6 +187,9 @@ grub_ata_pio_write (struct grub_ata_device *dev, char *buf,
   grub_uint16_t *buf16 = (grub_uint16_t *) buf;
   unsigned int i;
 
+  if (grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & 1)
+    return grub_ata_regget (dev, GRUB_ATA_REG_ERROR);
+
   /* Wait until the device is ready to write.  */
   grub_ata_wait_drq (dev);
 
@@ -562,10 +565,9 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
       /* Write sectors.  */
       grub_ata_regset (dev, GRUB_ATA_REG_CMD, cmd_write);
       grub_ata_wait ();
-      for (sect = 0; sect < batch; sect++)
+      for (sect = 0; sect < (size % batch); sect++)
        {
-         if (grub_ata_pio_write (dev, buf,
-                                 (size % batch) * GRUB_DISK_SECTOR_SIZE))
+         if (grub_ata_pio_write (dev, buf, GRUB_DISK_SECTOR_SIZE))
            return grub_error (GRUB_ERR_WRITE_ERROR, "ATA write error");
          buf += GRUB_DISK_SECTOR_SIZE;
        }
@@ -705,11 +707,12 @@ grub_ata_write (grub_disk_t disk,
                grub_size_t size,
                const char *buf)
 {
-#if 1
-  return GRUB_ERR_NOT_IMPLEMENTED_YET;
-#else
-  return grub_ata_readwrite (disk, sector, size, (char *) buf, 1);
-#endif
+  struct grub_ata_device *dev = (struct grub_ata_device *) disk->data;
+
+  if (! dev->atapi)
+    return grub_ata_readwrite (disk, sector, size, (char *) buf, 1);
+
+  return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "ATAPI write not supported");
 }
 
 static struct grub_disk_dev grub_atadisk_dev =