Skip to contentSkip to conversation

Support LBA48 MODE

PATCH New Chen Gong 1 participant 1 message Aug 30, 2007

lore
Share & tools
lore

Chen Gong

author
#0 lore raw

PATCH 1/1 Support LBA48 MODE

This patch add a new SCSI command READ16 to support LBA48 mode. But it is not complete because only 32bit not 48bit can be supported. Now it can read correct capacity and boot from a big hard disk( >137G & <2T)

---
 common/cmd_scsi.c             |   31 +++++++++-
 drivers/ahci.c                |  132 +++++++++++++++++++++++++++++++++++-----
 include/ata.h                 |    1 +
 include/configs/MPC8641HPCN.h |    1 +
 include/scsi.h                |    1 +
 5 files changed, 148 insertions(+), 18 deletions(-)
common/cmd_scsi.c +30 -1
index 00b84fa..49ae5c7 100644
@@ -31,6 +31,7 @@
 #include <command.h>
 #include <asm/processor.h>
 #include <scsi.h>
+#include <ata.h>
 #include <image.h>
 #include <pci.h>
 
@@ -70,6 +71,8 @@ void scsi_setup_test_unit_ready(ccb * pccb);
 void scsi_setup_read_capacity(ccb * pccb);
 void scsi_setup_read6(ccb * pccb, unsigned long start, unsigned short blocks);
 void scsi_setup_read_ext(ccb * pccb, unsigned long start, unsigned short blocks);
+void scsi_setup_read16_ext(ccb * pccb, unsigned long start,
+		unsigned short blocks);
 void scsi_setup_inquiry(ccb * pccb);
 void scsi_ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
 
@@ -539,6 +542,33 @@ void scsi_setup_read_capacity(ccb * pccb)
 
 }
 
+/* FIXME: only support 32bit address, not 48bit */
+void scsi_setup_read16_ext(ccb * pccb, unsigned long start,
+		unsigned short blocks)
+{
+	pccb->cmd[0] = SCSI_READ16;
+	pccb->cmd[1] = pccb->lun<<5;
+	pccb->cmd[2] = 0;
+	pccb->cmd[3] = 0;
+	pccb->cmd[4] = 0;
+	pccb->cmd[5] = 0;
+	pccb->cmd[6] = ((unsigned char) (start>>24))&0xff;
+	pccb->cmd[7] = ((unsigned char) (start>>16))&0xff;
+	pccb->cmd[8] = ((unsigned char) (start>>8))&0xff;
+	pccb->cmd[9] = ((unsigned char) (start))&0xff;
+	pccb->cmd[10] = 0;
+	pccb->cmd[11] = 0;
+	pccb->cmd[12] = ((unsigned char) (blocks>>8))&0xff;
+	pccb->cmd[13] = (unsigned char) blocks & 0xff;
+	pccb->cmdlen = 16;
+	pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */
+	debug ("scsi_setup_read16_ext: cmd: %02X %02X startblk "
+		"%02X%02X%02X%02X blccnt %02X%02X\n",
+		pccb->cmd[0], pccb->cmd[1],
+		pccb->cmd[6], pccb->cmd[7], pccb->cmd[8], pccb->cmd[9],
+		pccb->cmd[12], pccb->cmd[13]);
+}
+
 void scsi_setup_read_ext(ccb * pccb, unsigned long start, unsigned short blocks)
 {
 	pccb->cmd[0]=SCSI_READ10;
@@ -550,7 +580,6 @@ void scsi_setup_read_ext(ccb * pccb, unsigned long start, unsigned short blocks)
 	pccb->cmd[6]=0;
 	pccb->cmd[7]=((unsigned char) (blocks>>8))&0xff;
 	pccb->cmd[8]=(unsigned char) blocks & 0xff;
-	pccb->cmd[6]=0;
 	pccb->cmdlen=10;
 	pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
 	debug ("scsi_setup_read_ext: cmd: %02X %02X startblk %02X%02X%02X%02X blccnt %02X%02X\n",
drivers/ahci.c +115 -17

185 lines not on this page · raw message

include/ata.h +1 -0
index 8584226..4973020 100644
@@ -99,6 +99,7 @@
 #define ATA_CMD_WR_MULT	0xC5	/* Write Multiple		*/
 #define ATA_CMD_SETMULT	0xC6	/* Set Multiple Mode		*/
 #define ATA_CMD_RD_DMA	0xC8	/* Read DMA (with retries)	*/
+#define ATA_CMD_RD_DMAX	0x25	/* Read DMA EXT (with retries)	*/
 #define ATA_CMD_RD_DMAN	0xC9	/* Read DMS ( no  retries)	*/
 #define ATA_CMD_WR_DMA	0xCA	/* Write DMA (with retries)	*/
 #define ATA_CMD_WR_DMAN	0xCB	/* Write DMA ( no  retires)	*/
include/configs/MPC8641HPCN.h +1 -0
index 94f1428..5b69d60 100644
@@ -384,6 +384,7 @@
 #define CONFIG_SCSI_AHCI
 
 #ifdef CONFIG_SCSI_AHCI
+#define CONFIG_LBA48
 #define CONFIG_SATA_ULI5288
 #define CFG_SCSI_MAX_SCSI_ID	4
 #define CFG_SCSI_MAX_LUN	1
include/scsi.h +1 -0
index 2be4d40..28382f6 100644
@@ -147,6 +147,7 @@ typedef struct SCSI_cmd_block{
 #define SCSI_MED_REMOVL	0x1E		/* Prevent/Allow medium Removal (O) */
 #define SCSI_READ6		0x08		/* Read 6-byte (MANDATORY) */
 #define SCSI_READ10		0x28		/* Read 10-byte (MANDATORY) */
+#define SCSI_READ16		0x88		/* Read 16-byte (MANDATORY) */
 #define SCSI_RD_CAPAC	0x25		/* Read Capacity (MANDATORY) */
 #define SCSI_RD_DEFECT	0x37		/* Read Defect Data (O) */
 #define SCSI_READ_LONG	0x3E		/* Read Long (O) */
Signature · 1 line
1.5.2