All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Enable writing to ATA devices, fix several bugs
@ 2008-07-03  0:17 Pavel Roskin
  2008-07-03 14:10 ` Robert Millan
  2008-07-03 18:27 ` Marco Gerards
  0 siblings, 2 replies; 17+ messages in thread
From: Pavel Roskin @ 2008-07-03  0:17 UTC (permalink / raw)
  To: grub-devel, Marco Gerards

We have save_env now, so we can use the write capability.  This also
fixes the last compiler warning in GRUB.

Sorry, Marco, please ignore the previous message, as it didn't get to
the list.

ChangeLog:

	* 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.
---

 disk/ata.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/disk/ata.c b/disk/ata.c
index 02c4b06..c9b0498 100644
--- a/disk/ata.c
+++ b/disk/ata.c
@@ -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 =



^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-07-21 16:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03  0:17 [PATCH] Enable writing to ATA devices, fix several bugs Pavel Roskin
2008-07-03 14:10 ` Robert Millan
2008-07-03 18:27 ` Marco Gerards
2008-07-03 20:50   ` Pavel Roskin
2008-07-04 11:50     ` Marco Gerards
2008-07-04 17:07       ` Pavel Roskin
2008-07-20 18:55         ` Marco Gerards
2008-07-20 20:24           ` Pavel Roskin
2008-07-21 12:49             ` Marco Gerards
2008-07-21 13:19               ` Javier Martín
2008-07-21 15:20                 ` Marco Gerards
2008-07-21 15:33                   ` Javier Martín
2008-07-21 15:56                     ` Marco Gerards
2008-07-21 15:41                   ` Pavel Roskin
2008-07-21 15:53                     ` Marco Gerards
2008-07-21 16:00                       ` Pavel Roskin
2008-07-21 16:10                         ` Marco Gerards

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.