This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with IDE disk


Hello
the attached patch corrects two problems with the ide_disk driver.

1. The check for hard disks does not work. The line
"if (((ide_idData->general_conf>>8)&0x1f)!=2) " returns true with my hard disk. (ide_idData->general_conf = 0x0040)


2. I have to wait for "not busy" before sending a command to the device.

Knud

diff -Naur ecos.orig/packages/devs/disk/ide/current/ChangeLog ecos/packages/devs/disk/ide/current/ChangeLog
--- ecos.orig/packages/devs/disk/ide/current/ChangeLog	2004-12-08 16:46:07.462501700 +0100
+++ ecos/packages/devs/disk/ide/current/ChangeLog	2005-02-02 13:06:19.202279300 +0100
@@ -1,3 +1,9 @@
+2005-02-02 Knud Woehler <knud.woehler@microplex.de>
+
+	* src/ide_disk.c: 
+	check for hard disk does not work
+	wait for not busy before sending a command to the device
+	
 2004-10-17 Iztok Zupet <iz@elsis.si>
 
 	* include/ide_disk.h : moved to ->
diff -Naur ecos.orig/packages/devs/disk/ide/current/src/ide_disk.c ecos/packages/devs/disk/ide/current/src/ide_disk.c
--- ecos.orig/packages/devs/disk/ide/current/src/ide_disk.c	2004-12-08 16:46:07.540627700 +0100
+++ ecos/packages/devs/disk/ide/current/src/ide_disk.c	2005-02-02 12:20:02.155884100 +0100
@@ -118,13 +118,28 @@
 }
 
 static inline int
+__wait_busy(int ctlr)
+{
+    cyg_uint8 status;
+    cyg_ucount32 tries;
+
+	for (tries=0; tries<1000000; tries++) {
+		CYGACC_CALL_IF_DELAY_US(10);
+		HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
+		if ((status & IDE_STAT_BSY) == 0)
+			return 1;
+	}
+	return 0;   
+}
+
+static inline int
 __wait_for_drq(int ctlr)
 {
     cyg_uint8 status;
     cyg_ucount32 tries;
 
-    CYGACC_CALL_IF_DELAY_US(10);
     for (tries=0; tries<1000000; tries++) {
+        CYGACC_CALL_IF_DELAY_US(10);
         HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status);
         if (!(status & IDE_STAT_BSY)) {
             if (status & IDE_STAT_DRQ)
@@ -133,6 +148,7 @@
                 return 0;
         }
     }
+	return 0;
 }
 
 // Return true if any devices attached to controller
@@ -195,6 +211,8 @@
 {
     int i;
 
+	if(!__wait_busy(ctlr))
+        return 0;
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_DEVICE, dev << 4);
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COMMAND, 0xEC);
     CYGACC_CALL_IF_DELAY_US((cyg_uint32)50000);
@@ -217,6 +235,8 @@
     cyg_uint16 p;
     cyg_uint8 * b=buf;
 
+	if(!__wait_busy(ctlr))
+        return 0;
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COUNT, 1);    // count =1
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBALOW, start & 0xff);
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAMID, (start >>  8) & 0xff);
@@ -248,6 +268,8 @@
     cyg_uint16 p;
     cyg_uint8 * b=buf;
 
+	if(!__wait_busy(ctlr))
+        return 0;
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_COUNT, 1);    // count =1
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBALOW, start & 0xff);
     HAL_IDE_WRITE_UINT8(ctlr, IDE_REG_LBAMID, (start >>  8) & 0xff);
@@ -332,12 +354,13 @@
     D("\tC/H/S : %d/%d/%d\n", ident.cylinders_num, 
                               ident.heads_num, ident.sectors_num);
     D("\tKind : %x\n", (ide_idData->general_conf>>8)&0x1f);
-    
-    if (((ide_idData->general_conf>>8)&0x1f)!=2) {
-        diag_printf("IDE device %d:%d is not a hard disk!\n",
-                    info->port, info->chan);
-        return false;
-    }
+
+// This does not work.
+//    if (((ide_idData->general_conf>>8)&0x1f)!=2) {
+//        diag_printf("IDE device %d:%d is not a hard disk!\n",
+//                    info->port, info->chan);
+//        return false;
+//    }
     if (!(chan->callbacks->disk_init)(tab))
         return false;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]