Skip to contentSkip to conversation

ATAPI split-off

PATCH Marco Gerards 1 participant 1 message Aug 12, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

Here is a patch to remove the ATAPI code and add support for SCSI commands. I changed ata.c to use scsi.c. This results in cleaner, sharable code. Meanwhile, the hard coded disk size is removed, together with some other hacks.

You can make me happy by testing this :-)

--
Marco

2008-08-12 Marco Gerards <[email protected]>

* conf/i386-pc.rmk (pkglib_MODULES): Add scsi.mod. (scsi_mod_SOURCES): New variable. (scsi_mod_CFLAGS): Likewise (scsi_mod_LDFLAGS): Likewise.

* disk/scsi.c: New file.

* include/grub/scsi.h: Likewise.

* include/grub/scsicmd.h: Likewise.

* disk/ata.c: Include <grub/scsi.h>. (grub_atapi_packet): Do not use grub_ata_cmd, use registers instead.
(grub_ata_iterate): Skip ATAPI devices. (grub_ata_open): Only handle ATAPI devices. (struct grub_atapi_read): Removed. (grub_atapi_readsector): Likewise. (grub_ata_read): No longer handle ATAPI devices. (grub_ata_write): Likewise. (grub_atapi_iterate): New function. (grub_atapi_read): Likewise.
(grub_atapi_write): Likewise.
(grub_atapi_open): Likewise.
(grub_atapi_close): Likewise.
(grub_atapi_dev): New variable. (GRUB_MOD_INIT(ata)): Register ATAPI as SCSI device. (GRUB_MOD_FINI(ata)): Unregister ATAPI.

* include/grub/disk.h (enum grub_disk_dev_id): Add `GRUB_DISK_DEVICE_SCSI_ID'.

i386-pc.rmk +6 -1
Index: conf/i386-pc.rmk
===================================================================
@@ -163,7 +163,7 @@ pkglib_MODULES = biosdisk.mod _chain.mod
 	vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
 	videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod	\
 	ata.mod vga.mod memdisk.mod jpeg.mod png.mod pci.mod lspci.mod \
-	aout.mod _bsd.mod bsd.mod pxe.mod pxecmd.mod
+	aout.mod _bsd.mod bsd.mod pxe.mod pxecmd.mod scsi.mod
 
 # For biosdisk.mod.
 biosdisk_mod_SOURCES = disk/i386/pc/biosdisk.c
@@ -340,4 +340,9 @@ pxecmd_mod_SOURCES = commands/i386/pc/px
 pxecmd_mod_CFLAGS = $(COMMON_CFLAGS)
 pxecmd_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For scsi.mod
+scsi_mod_SOURCES = disk/scsi.c
+scsi_mod_CFLAGS = $(COMMON_CFLAGS)
+scsi_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
scsi.c +377 -0

377 lines not on this page · raw message

ata.c +118 -72

256 lines not on this page · raw message

grub/scsi.h +88 -0

88 lines not on this page · raw message

grub/scsicmd.h +122 -0

122 lines not on this page · raw message

grub/disk.h +1 -0
Index: include/grub/disk.h
===================================================================
@@ -40,6 +40,7 @@ enum grub_disk_dev_id
     GRUB_DISK_DEVICE_NAND_ID,
     GRUB_DISK_DEVICE_UUID_ID,
     GRUB_DISK_DEVICE_PXE_ID,
+    GRUB_DISK_DEVICE_SCSI_ID,
   };
 
 struct grub_disk;