change log for rtems (2010-08-17)

rtems-vc at rtems.org rtems-vc at rtems.org
Tue Aug 17 14:10:32 UTC 2010


 *sh*:
2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* libchip/ide/ata_internal.h, libchip/ide/ata.c: Moved code into
	separate functions.  Added public ata_breq_init(),
	ata_identify_device(), and ata_process_request_on_init_phase()
	functions.

M  1.529  c/src/ChangeLog
M   1.39  c/src/libchip/ide/ata.c
M   1.13  c/src/libchip/ide/ata_internal.h

diff -u rtems/c/src/ChangeLog:1.528 rtems/c/src/ChangeLog:1.529
--- rtems/c/src/ChangeLog:1.528	Thu Jun 24 02:54:14 2010
+++ rtems/c/src/ChangeLog	Tue Aug 17 08:41:28 2010
@@ -1,3 +1,10 @@
+2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+	* libchip/ide/ata_internal.h, libchip/ide/ata.c: Moved code into
+	separate functions.  Added public ata_breq_init(),
+	ata_identify_device(), and ata_process_request_on_init_phase()
+	functions.
+
 2010-06-24	Arnout Vandecappelle <arnout at mind.be>
 
 	PR 1586/misc

diff -u rtems/c/src/libchip/ide/ata.c:1.38 rtems/c/src/libchip/ide/ata.c:1.39
--- rtems/c/src/libchip/ide/ata.c:1.38	Mon May 17 21:12:39 2010
+++ rtems/c/src/libchip/ide/ata.c	Tue Aug 17 08:41:29 2010
@@ -118,13 +118,6 @@
 /* FIXME: case if ATA device is FLASH device need more attention */
 #undef ATA_DEV_IS_FLASH_DISK
 
-/* Block device request with a single buffer provided */
-typedef struct blkdev_request1 {
-    rtems_blkdev_request   req;
-    rtems_blkdev_sg_buffer sg[1];
-} blkdev_request1;
-
-
 /* Array indexed by controllers minor number */
 static ata_ide_ctrl_t ata_ide_ctrls[IDE_CTRL_MAX_MINOR_NUMBER];
 
@@ -152,10 +145,6 @@
 ata_process_request(rtems_device_minor_number ctrl_minor);
 
 static void
-ata_process_request_on_init_phase(rtems_device_minor_number  ctrl_minor,
-                                  ata_req_t                 *areq);
-
-static void
 ata_add_to_controller_queue(rtems_device_minor_number  ctrl_minor,
                             ata_req_t                 *areq);
 
@@ -1037,6 +1026,97 @@
     return 0;
 }
 
+static void ata_execute_device_diagnostic(
+  rtems_device_minor_number ctrl_minor,
+  uint16_t *sector_buffer
+)
+{
+#if ATA_EXEC_DEVICE_DIAGNOSTIC
+  ata_req_t areq;
+  blkdev_request1 breq;
+
+  ata_breq_init(&breq, sector_buffer);
+
+  /*
+   * Issue EXECUTE DEVICE DIAGNOSTIC ATA command for explore is
+   * there any ATA device on the controller.
+   *
+   * This command may fail and it assumes we have a master device and may
+   * be a slave device. I think the identify command will handle
+   * detection better than this method.
+   */
+  memset(&areq, 0, sizeof(ata_req_t));
+  areq.type = ATA_COMMAND_TYPE_NON_DATA;
+  areq.regs.to_write = ATA_REGISTERS_VALUE(IDE_REGISTER_COMMAND);
+  areq.regs.regs[IDE_REGISTER_COMMAND] =
+                            ATA_COMMAND_EXECUTE_DEVICE_DIAGNOSTIC;
+  areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_ERROR);
+
+  areq.breq = (rtems_blkdev_request *)&breq;
+
+  /*
+   * Process the request. Special processing of requests on
+   * initialization phase is needed because at this moment there
+   * is no multitasking enviroment
+   */
+  ata_process_request_on_init_phase(ctrl_minor, &areq);
+
+  /*
+   * check status of I/O operation
+   */
+  if (breq.req.status == RTEMS_SUCCESSFUL)
+  {
+    /* disassemble returned diagnostic codes */
+    if (areq.info == ATA_DEV0_PASSED_DEV1_PASSED_OR_NOT_PRSNT)
+    {
+      printk("ATA: ctrl:%d: primary, secondary\n", ctrl_minor);
+      ATA_DEV_INFO(ctrl_minor,0).present = true;
+      ATA_DEV_INFO(ctrl_minor,1).present = true;
+    }
+    else if (areq.info == ATA_DEV0_PASSED_DEV1_FAILED)
+    {
+      printk("ATA: ctrl:%d: primary\n", ctrl_minor);
+      ATA_DEV_INFO(ctrl_minor,0).present = true;
+      ATA_DEV_INFO(ctrl_minor,1).present = false;
+    }
+    else if (areq.info < ATA_DEV1_PASSED_DEV0_FAILED)
+    {
+      printk("ATA: ctrl:%d: secondary\n", ctrl_minor);
+      ATA_DEV_INFO(ctrl_minor,0).present = false;
+      ATA_DEV_INFO(ctrl_minor,1).present = true;
+    }
+    else
+    {
+      printk("ATA: ctrl:%d: none\n", ctrl_minor);
+      ATA_DEV_INFO(ctrl_minor, 0).present = false;
+      ATA_DEV_INFO(ctrl_minor, 1).present = false;
+    }
+
+    /* refine the returned codes */
+    if (ATA_DEV_INFO(ctrl_minor, 1).present)
+    {
+      uint16_t ec = 0;
+      ide_controller_read_register(ctrl_minor, IDE_REGISTER_ERROR, &ec);
+      if (ec & ATA_DEV1_PASSED_DEV0_FAILED)
+      {
+        printk("ATA: ctrl:%d: secondary inforced\n", ctrl_minor);
+        ATA_DEV_INFO(ctrl_minor, 1).present = true;
+      }
+      else
+      {
+        printk("ATA: ctrl:%d: secondary removed\n", ctrl_minor);
+        ATA_DEV_INFO(ctrl_minor, 1).present = false;
+      }
+    }
+  }
+  else
+#endif
+  {
+    ATA_DEV_INFO(ctrl_minor, 0).present = true;
+    ATA_DEV_INFO(ctrl_minor,1).present = true;
+  }
+}
+
 /*
  * ata_initialize --
  *     Initializes all ATA devices found on initialized IDE controllers.
@@ -1057,13 +1137,8 @@
 {
     uint32_t           ctrl_minor;
     rtems_status_code  status;
-    ata_req_t          areq;
-    blkdev_request1    breq;
-    uint8_t            i, dev = 0;
     uint16_t          *buffer;
-#if ATA_EXEC_DEVICE_DIAGNOSTIC
-    uint16_t           ec;
-#endif
+    int                i, dev = 0;
     char               name[ATA_MAX_NAME_LENGTH];
     dev_t              device;
     ata_int_st_t      *int_st;
@@ -1169,12 +1244,6 @@
      * requests should be formed; ATA requests contain block device request,
      * so form block device request first
      */
-    memset(&breq, 0, sizeof(blkdev_request1));
-    breq.req.req_done = NULL;
-    breq.req.done_arg = &breq;
-    breq.req.bufnum = 1;
-    breq.req.bufs[0].length = ATA_SECTOR_SIZE;
-    breq.req.bufs[0].buffer = buffer;
 
     /*
      * for each presented IDE controller execute EXECUTE DEVICE DIAGNOSTIC
@@ -1267,161 +1336,31 @@
                                           IDE_REGISTER_DEVICE_CONTROL_nIEN);
         }
 
-#if ATA_EXEC_DEVICE_DIAGNOSTIC
-        /*
-         * Issue EXECUTE DEVICE DIAGNOSTIC ATA command for explore is
-         * there any ATA device on the controller.
-         *
-         * This command may fail and it assumes we have a master device and may
-         * be a slave device. I think the identify command will handle
-         * detection better than this method.
-         */
-        memset(&areq, 0, sizeof(ata_req_t));
-        areq.type = ATA_COMMAND_TYPE_NON_DATA;
-        areq.regs.to_write = ATA_REGISTERS_VALUE(IDE_REGISTER_COMMAND);
-        areq.regs.regs[IDE_REGISTER_COMMAND] =
-                                  ATA_COMMAND_EXECUTE_DEVICE_DIAGNOSTIC;
-        areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_ERROR);
-
-        areq.breq = (rtems_blkdev_request *)&breq;
-
-        /*
-         * Process the request. Special processing of requests on
-         * initialization phase is needed because at this moment there
-         * is no multitasking enviroment
-         */
-        ata_process_request_on_init_phase(ctrl_minor, &areq);
-
-        /*
-         * check status of I/O operation
-         */
-        if (breq.req.status == RTEMS_SUCCESSFUL)
-        {
-          /* disassemble returned diagnostic codes */
-          if (areq.info == ATA_DEV0_PASSED_DEV1_PASSED_OR_NOT_PRSNT)
-          {
-            printk("ATA: ctrl:%d: primary, secondary\n", ctrl_minor);
-            ATA_DEV_INFO(ctrl_minor,0).present = true;
-            ATA_DEV_INFO(ctrl_minor,1).present = true;
-          }
-          else if (areq.info == ATA_DEV0_PASSED_DEV1_FAILED)
-          {
-            printk("ATA: ctrl:%d: primary\n", ctrl_minor);
-            ATA_DEV_INFO(ctrl_minor,0).present = true;
-            ATA_DEV_INFO(ctrl_minor,1).present = false;
-          }
-          else if (areq.info < ATA_DEV1_PASSED_DEV0_FAILED)
-          {
-            printk("ATA: ctrl:%d: secondary\n", ctrl_minor);
-            ATA_DEV_INFO(ctrl_minor,0).present = false;
-            ATA_DEV_INFO(ctrl_minor,1).present = true;
-          }
-          else
-          {
-            printk("ATA: ctrl:%d: none\n", ctrl_minor);
-            ATA_DEV_INFO(ctrl_minor, 0).present = false;
-            ATA_DEV_INFO(ctrl_minor, 1).present = false;
-          }
-
-          /* refine the returned codes */
-          if (ATA_DEV_INFO(ctrl_minor, 1).present)
-          {
-            ide_controller_read_register(ctrl_minor, IDE_REGISTER_ERROR, &ec);
-            if (ec & ATA_DEV1_PASSED_DEV0_FAILED)
-            {
-              printk("ATA: ctrl:%d: secondary inforced\n", ctrl_minor);
-              ATA_DEV_INFO(ctrl_minor, 1).present = true;
-            }
-            else
-            {
-              printk("ATA: ctrl:%d: secondary removed\n", ctrl_minor);
-              ATA_DEV_INFO(ctrl_minor, 1).present = false;
-            }
-          }
-        }
-        else
-#endif
-        {
-          ATA_DEV_INFO(ctrl_minor, 0).present = true;
-          ATA_DEV_INFO(ctrl_minor,1).present = true;
-        }
+        ata_execute_device_diagnostic(ctrl_minor, buffer);
 
         /* for each found ATA device obtain it configuration */
         for (dev = 0; dev < 2; dev++)
         if (ATA_DEV_INFO(ctrl_minor, dev).present)
         {
-            /*
-             * Issue DEVICE IDENTIFY ATA command and get device
-             * configuration
-             */
-            memset(&areq, 0, sizeof(ata_req_t));
-            areq.type = ATA_COMMAND_TYPE_PIO_IN;
-            areq.regs.to_write = ATA_REGISTERS_VALUE(IDE_REGISTER_COMMAND);
-            areq.regs.regs[IDE_REGISTER_COMMAND] =
-                                              ATA_COMMAND_IDENTIFY_DEVICE;
-            areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
-            areq.breq = (rtems_blkdev_request *)&breq;
-
-            areq.cnt = breq.req.bufnum;
-
-            areq.regs.regs[IDE_REGISTER_DEVICE_HEAD] |=
-                                    (dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS);
-
-            /*
-             * Process the request. Special processing of requests on
-             * initialization phase is needed because at this moment there
-             * is no multitasking enviroment
-             */
-            ata_process_request_on_init_phase(ctrl_minor, &areq);
+            status = ata_identify_device(
+               ctrl_minor,
+               dev,
+               buffer,
+               &ATA_DEV_INFO(ctrl_minor, dev));
+            if (status != RTEMS_SUCCESSFUL)
+               continue;
 
-            /* check status of I/O operation */
-            if (breq.req.status != RTEMS_SUCCESSFUL)
-                continue;
+	    /*
+	     * choose most appropriate ATA device data I/O speed supported
+	     * by the controller
+	     */
+	    status = ide_controller_config_io_speed(
+               ctrl_minor,
+               ATA_DEV_INFO(ctrl_minor, dev).modes_available);
+	    if (status != RTEMS_SUCCESSFUL)
+               continue;
 
             /*
-             * Parse returned device configuration and fill in ATA internal
-             * device info structure
-             */
-            ATA_DEV_INFO(ctrl_minor, dev).cylinders =
-                CF_LE_W(buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_CLNDS]);
-            ATA_DEV_INFO(ctrl_minor, dev).heads =
-                CF_LE_W(buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_HEADS]);
-            ATA_DEV_INFO(ctrl_minor, dev).sectors =
-                CF_LE_W(buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_SECS]);
-            ATA_DEV_INFO(ctrl_minor, dev).lba_sectors =
-                CF_LE_W(buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS1]);
-            ATA_DEV_INFO(ctrl_minor, dev).lba_sectors <<= 16;
-            ATA_DEV_INFO(ctrl_minor, dev).lba_sectors += CF_LE_W(buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS0]);
-            ATA_DEV_INFO(ctrl_minor, dev).lba_avaible =
-                (CF_LE_W(buffer[ATA_IDENT_WORD_CAPABILITIES]) >> 9) & 0x1;
-
-            if ((CF_LE_W(buffer[ATA_IDENT_WORD_FIELD_VALIDITY]) &
-                 ATA_IDENT_BIT_VALID) == 0) {
-	      /* no "supported modes" info -> use default */
-	      ATA_DEV_INFO(ctrl_minor, dev).mode_active = ATA_MODES_PIO3;
-	    }
-	    else {
-	      ATA_DEV_INFO(ctrl_minor, dev).modes_available =
-		((CF_LE_W(buffer[64]) & 0x1) ? ATA_MODES_PIO3 : 0) |
-		((CF_LE_W(buffer[64]) & 0x2) ? ATA_MODES_PIO4 : 0) |
-		((CF_LE_W(buffer[63]) & 0x1) ? ATA_MODES_DMA0 : 0) |
-		((CF_LE_W(buffer[63]) & 0x2) ?
-		 ATA_MODES_DMA0 | ATA_MODES_DMA1 : 0) |
-		((CF_LE_W(buffer[63]) & 0x4) ?
-		 ATA_MODES_DMA0 | ATA_MODES_DMA1 | ATA_MODES_DMA2 : 0);
-	      if (ATA_DEV_INFO(ctrl_minor, dev).modes_available == 0)
-                continue;
-	      /*
-	       * choose most appropriate ATA device data I/O speed supported
-	       * by the controller
-	       */
-	      status = ide_controller_config_io_speed(
-                ctrl_minor,
-                ATA_DEV_INFO(ctrl_minor, dev).modes_available);
-	      if (status != RTEMS_SUCCESSFUL)
-                continue;
-	    }
-            /*
              * Ok, let register new ATA device in the system
              */
             ata_devs[ata_devs_number].ctrl_minor = ctrl_minor;
@@ -1473,7 +1412,7 @@
  * RETURNS:
  *     NONE
  */
-static void
+void
 ata_process_request_on_init_phase(rtems_device_minor_number  ctrl_minor,
                                   ata_req_t                 *areq)
 {
@@ -1571,3 +1510,89 @@
             break;
     }
 }
+
+void ata_breq_init(blkdev_request1 *breq, uint16_t *sector_buffer)
+{
+  memset(breq, 0, sizeof(*breq));
+
+  breq->req.done_arg = breq;
+  breq->req.bufnum = 1;
+  breq->req.bufs [0].length = ATA_SECTOR_SIZE;
+  breq->req.bufs [0].buffer = sector_buffer;
+}
+
+rtems_status_code ata_identify_device(
+  rtems_device_minor_number ctrl_minor,
+  int dev,
+  uint16_t *sector_buffer,
+  ata_dev_t *device_entry
+)
+{
+  ata_req_t areq;
+  blkdev_request1 breq;
+
+  ata_breq_init(&breq, sector_buffer);
+
+  /*
+   * Issue DEVICE IDENTIFY ATA command and get device
+   * configuration
+   */
+  memset(&areq, 0, sizeof(ata_req_t));
+  areq.type = ATA_COMMAND_TYPE_PIO_IN;
+  areq.regs.to_write = ATA_REGISTERS_VALUE(IDE_REGISTER_COMMAND);
+  areq.regs.regs [IDE_REGISTER_COMMAND] = ATA_COMMAND_IDENTIFY_DEVICE;
+  areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
+  areq.breq = (rtems_blkdev_request *)&breq;
+  areq.cnt = breq.req.bufnum;
+  areq.regs.regs [IDE_REGISTER_DEVICE_HEAD] |=
+    dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS;
+
+  /*
+   * Process the request. Special processing of requests on
+   * initialization phase is needed because at this moment there
+   * is no multitasking enviroment
+   */
+  ata_process_request_on_init_phase(ctrl_minor, &areq);
+
+  /* check status of I/O operation */
+  if (breq.req.status != RTEMS_SUCCESSFUL) {
+    return RTEMS_IO_ERROR;
+  }
+
+  /*
+   * Parse returned device configuration and fill in ATA internal
+   * device info structure
+   */
+  device_entry->cylinders =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_CLNDS]);
+  device_entry->heads =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_HEADS]);
+  device_entry->sectors =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_SECS]);
+  device_entry->lba_sectors =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS1]);
+  device_entry->lba_sectors <<= 16;
+  device_entry->lba_sectors += CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS0]);
+  device_entry->lba_avaible =
+      (CF_LE_W(sector_buffer[ATA_IDENT_WORD_CAPABILITIES]) >> 9) & 0x1;
+
+  if ((CF_LE_W(sector_buffer[ATA_IDENT_WORD_FIELD_VALIDITY]) &
+       ATA_IDENT_BIT_VALID) == 0) {
+    /* no "supported modes" info -> use default */
+    device_entry->mode_active = ATA_MODES_PIO3;
+  } else {
+    device_entry->modes_available =
+      ((CF_LE_W(sector_buffer[64]) & 0x1) ? ATA_MODES_PIO3 : 0) |
+      ((CF_LE_W(sector_buffer[64]) & 0x2) ? ATA_MODES_PIO4 : 0) |
+      ((CF_LE_W(sector_buffer[63]) & 0x1) ? ATA_MODES_DMA0 : 0) |
+      ((CF_LE_W(sector_buffer[63]) & 0x2) ?
+       ATA_MODES_DMA0 | ATA_MODES_DMA1 : 0) |
+      ((CF_LE_W(sector_buffer[63]) & 0x4) ?
+       ATA_MODES_DMA0 | ATA_MODES_DMA1 | ATA_MODES_DMA2 : 0);
+    if (device_entry->modes_available == 0) {
+      return RTEMS_IO_ERROR;
+    }
+  }
+
+  return RTEMS_SUCCESSFUL;
+}

diff -u rtems/c/src/libchip/ide/ata_internal.h:1.12 rtems/c/src/libchip/ide/ata_internal.h:1.13
--- rtems/c/src/libchip/ide/ata_internal.h:1.12	Tue Jan 19 03:10:03 2010
+++ rtems/c/src/libchip/ide/ata_internal.h	Tue Aug 17 08:41:29 2010
@@ -300,4 +300,24 @@
     rtems_chain_control reqs; /* requests chain */
 } ata_ide_ctrl_t;
 
+/* Block device request with a single buffer provided */
+typedef struct blkdev_request1 {
+    rtems_blkdev_request   req;
+    rtems_blkdev_sg_buffer sg[1];
+} blkdev_request1;
+
+void ata_breq_init(blkdev_request1 *breq, uint16_t *sector_buffer);
+
+rtems_status_code ata_identify_device(
+  rtems_device_minor_number ctrl_minor,
+  int dev,
+  uint16_t *sector_buffer,
+  ata_dev_t *device_entry
+);
+
+void ata_process_request_on_init_phase(
+  rtems_device_minor_number ctrl_minor,
+  ata_req_t *areq
+);
+
 #endif /* __ATA_INTERNAL_H__ */


 *sh*:
2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* libchip/ide/ata_util.c: New file.
	* libchip/Makefile.am: Reflect change from above.
	* libchip/ide/ata.c: Moved ata_breq_init(), ata_identify_device(), and
	ata_process_request_on_init_phase() into new file.

M  1.530  c/src/ChangeLog
M   1.48  c/src/libchip/Makefile.am
M   1.40  c/src/libchip/ide/ata.c
A    1.1  c/src/libchip/ide/ata_util.c

diff -u rtems/c/src/ChangeLog:1.529 rtems/c/src/ChangeLog:1.530
--- rtems/c/src/ChangeLog:1.529	Tue Aug 17 08:41:28 2010
+++ rtems/c/src/ChangeLog	Tue Aug 17 08:54:49 2010
@@ -1,5 +1,12 @@
 2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
+	* libchip/ide/ata_util.c: New file.
+	* libchip/Makefile.am: Reflect change from above.
+	* libchip/ide/ata.c: Moved ata_breq_init(), ata_identify_device(), and
+	ata_process_request_on_init_phase() into new file.
+
+2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
 	* libchip/ide/ata_internal.h, libchip/ide/ata.c: Moved code into
 	separate functions.  Added public ata_breq_init(),
 	ata_identify_device(), and ata_process_request_on_init_phase()

diff -u rtems/c/src/libchip/Makefile.am:1.47 rtems/c/src/libchip/Makefile.am:1.48
--- rtems/c/src/libchip/Makefile.am:1.47	Tue Oct 20 21:30:21 2009
+++ rtems/c/src/libchip/Makefile.am	Tue Aug 17 08:54:50 2010
@@ -30,7 +30,8 @@
     ide/ide_ctrl_io.h
 
 noinst_LIBRARIES += libide.a
-libide_a_SOURCES = ide/ata.c ide/ide_controller.c ide/ata_internal.h
+libide_a_SOURCES = ide/ata.c ide/ata_util.c ide/ide_controller.c \
+    ide/ata_internal.h
 libide_a_CPPFLAGS = $(AM_CPPFLAGS)
 
 # network

diff -u rtems/c/src/libchip/ide/ata.c:1.39 rtems/c/src/libchip/ide/ata.c:1.40
--- rtems/c/src/libchip/ide/ata.c:1.39	Tue Aug 17 08:41:29 2010
+++ rtems/c/src/libchip/ide/ata.c	Tue Aug 17 08:54:50 2010
@@ -1400,199 +1400,3 @@
     ata_initialized = true;
     return RTEMS_SUCCESSFUL;
 }
-
-/* ata_process_request_on_init_phase --
- *     Process the ATA request during system initialization. Request
- *     processing is syncronous and doesn't use multiprocessing enviroment.
- *
- * PARAMETERS:
- *     ctrl_minor - controller identifier
- *     areq       - ATA request
- *
- * RETURNS:
- *     NONE
- */
-void
-ata_process_request_on_init_phase(rtems_device_minor_number  ctrl_minor,
-                                  ata_req_t                 *areq)
-{
-    uint16_t           byte;/* emphasize that only 8 low bits is meaningful */
-    uint8_t            i, dev;
-    uint16_t           val, val1;
-    volatile unsigned  retries;
-
-    assert(areq);
-
-    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
-           IDE_REGISTER_DEVICE_HEAD_DEV;
-
-    ide_controller_write_register(ctrl_minor, IDE_REGISTER_DEVICE_HEAD,
-                                  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD]);
-
-	retries = 0;
-    do {
-        ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &byte);
-        /* If device (on INIT, i.e. it should be idle) is neither
-         * busy nor ready something's fishy, i.e., there is probably
-         * no device present.
-         * I'd like to do a proper timeout but don't know of a portable
-         * timeout routine (w/o using multitasking / rtems_task_wake_after())
-         */
-        if ( ! (byte & (IDE_REGISTER_STATUS_BSY | IDE_REGISTER_STATUS_DRDY))) {
-            retries++;
-            if ( 10000 == retries ) {
-              /* probably no drive connected */
-              areq->breq->status = RTEMS_UNSATISFIED;
-              return;
-            }
-        }
-    } while ((byte & IDE_REGISTER_STATUS_BSY) ||
-             (!(byte & IDE_REGISTER_STATUS_DRDY)));
-
-    for (i=0; i< ATA_MAX_CMD_REG_OFFSET; i++)
-    {
-        uint32_t   reg = (1 << i);
-        if (areq->regs.to_write & reg)
-            ide_controller_write_register(ctrl_minor, i,
-                                          areq->regs.regs[i]);
-    }
-
-    do {
-        ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &byte);
-    } while (byte & IDE_REGISTER_STATUS_BSY);
-
-    ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &val);
-    ide_controller_read_register(ctrl_minor, IDE_REGISTER_ERROR, &val1);
-
-    if (val & IDE_REGISTER_STATUS_ERR)
-    {
-        areq->breq->status = RTEMS_IO_ERROR;
-        return;
-    }
-
-    switch(areq->type)
-    {
-        case ATA_COMMAND_TYPE_PIO_IN:
-            if (areq->cnt)
-            {
-              int ccbuf = areq->cbuf;
-              ide_controller_read_data_block(ctrl_minor,
-                                             areq->breq->bufs[0].length * areq->cnt,
-                                             areq->breq->bufs, &areq->cbuf,
-                                             &areq->pos);
-              ccbuf = areq->cbuf - ccbuf;
-              areq->cnt -= ccbuf;
-            }
-            if (areq->cnt == 0)
-            {
-                areq->breq->status = RTEMS_SUCCESSFUL;
-            }
-            else
-            {
-                /*
-                 * this shouldn't happend on the initialization
-                 * phase!
-                 */
-                rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR);
-            }
-            break;
-
-        case ATA_COMMAND_TYPE_NON_DATA:
-            areq->breq->status = RTEMS_SUCCESSFUL;
-            areq->info = val1;
-            break;
-
-        default:
-#if ATA_DEBUG
-            ata_printf("ata_queue_task: non-supported command type\n");
-#endif
-            areq->breq->status = RTEMS_IO_ERROR;
-            break;
-    }
-}
-
-void ata_breq_init(blkdev_request1 *breq, uint16_t *sector_buffer)
-{
-  memset(breq, 0, sizeof(*breq));
-
-  breq->req.done_arg = breq;
-  breq->req.bufnum = 1;
-  breq->req.bufs [0].length = ATA_SECTOR_SIZE;
-  breq->req.bufs [0].buffer = sector_buffer;
-}
-
-rtems_status_code ata_identify_device(
-  rtems_device_minor_number ctrl_minor,
-  int dev,
-  uint16_t *sector_buffer,
-  ata_dev_t *device_entry
-)
-{
-  ata_req_t areq;
-  blkdev_request1 breq;
-
-  ata_breq_init(&breq, sector_buffer);
-
-  /*
-   * Issue DEVICE IDENTIFY ATA command and get device
-   * configuration
-   */
-  memset(&areq, 0, sizeof(ata_req_t));
-  areq.type = ATA_COMMAND_TYPE_PIO_IN;
-  areq.regs.to_write = ATA_REGISTERS_VALUE(IDE_REGISTER_COMMAND);
-  areq.regs.regs [IDE_REGISTER_COMMAND] = ATA_COMMAND_IDENTIFY_DEVICE;
-  areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
-  areq.breq = (rtems_blkdev_request *)&breq;
-  areq.cnt = breq.req.bufnum;
-  areq.regs.regs [IDE_REGISTER_DEVICE_HEAD] |=
-    dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS;
-
-  /*
-   * Process the request. Special processing of requests on
-   * initialization phase is needed because at this moment there
-   * is no multitasking enviroment
-   */
-  ata_process_request_on_init_phase(ctrl_minor, &areq);
-
-  /* check status of I/O operation */
-  if (breq.req.status != RTEMS_SUCCESSFUL) {
-    return RTEMS_IO_ERROR;
-  }
-
-  /*
-   * Parse returned device configuration and fill in ATA internal
-   * device info structure
-   */
-  device_entry->cylinders =
-      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_CLNDS]);
-  device_entry->heads =
-      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_HEADS]);
-  device_entry->sectors =
-      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_SECS]);
-  device_entry->lba_sectors =
-      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS1]);
-  device_entry->lba_sectors <<= 16;
-  device_entry->lba_sectors += CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS0]);
-  device_entry->lba_avaible =
-      (CF_LE_W(sector_buffer[ATA_IDENT_WORD_CAPABILITIES]) >> 9) & 0x1;
-
-  if ((CF_LE_W(sector_buffer[ATA_IDENT_WORD_FIELD_VALIDITY]) &
-       ATA_IDENT_BIT_VALID) == 0) {
-    /* no "supported modes" info -> use default */
-    device_entry->mode_active = ATA_MODES_PIO3;
-  } else {
-    device_entry->modes_available =
-      ((CF_LE_W(sector_buffer[64]) & 0x1) ? ATA_MODES_PIO3 : 0) |
-      ((CF_LE_W(sector_buffer[64]) & 0x2) ? ATA_MODES_PIO4 : 0) |
-      ((CF_LE_W(sector_buffer[63]) & 0x1) ? ATA_MODES_DMA0 : 0) |
-      ((CF_LE_W(sector_buffer[63]) & 0x2) ?
-       ATA_MODES_DMA0 | ATA_MODES_DMA1 : 0) |
-      ((CF_LE_W(sector_buffer[63]) & 0x4) ?
-       ATA_MODES_DMA0 | ATA_MODES_DMA1 | ATA_MODES_DMA2 : 0);
-    if (device_entry->modes_available == 0) {
-      return RTEMS_IO_ERROR;
-    }
-  }
-
-  return RTEMS_SUCCESSFUL;
-}

diff -u /dev/null rtems/c/src/libchip/ide/ata_util.c:1.1
--- /dev/null	Tue Aug 17 09:10:31 2010
+++ rtems/c/src/libchip/ide/ata_util.c	Tue Aug 17 08:54:50 2010
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2010 embedded brains GmbH.
+ *
+ * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
+ * Authors: Eugeny S. Mints <Eugeny.Mints at oktet.ru>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include "ata_internal.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include <libchip/ide_ctrl_io.h>
+#include <libchip/ide_ctrl_cfg.h>
+
+/* ata_process_request_on_init_phase --
+ *     Process the ATA request during system initialization. Request
+ *     processing is syncronous and doesn't use multiprocessing enviroment.
+ *
+ * PARAMETERS:
+ *     ctrl_minor - controller identifier
+ *     areq       - ATA request
+ *
+ * RETURNS:
+ *     NONE
+ */
+void
+ata_process_request_on_init_phase(rtems_device_minor_number  ctrl_minor,
+                                  ata_req_t                 *areq)
+{
+    uint16_t           byte;/* emphasize that only 8 low bits is meaningful */
+    uint8_t            i, dev;
+    uint16_t           val, val1;
+    volatile unsigned  retries;
+
+    assert(areq);
+
+    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
+           IDE_REGISTER_DEVICE_HEAD_DEV;
+
+    ide_controller_write_register(ctrl_minor, IDE_REGISTER_DEVICE_HEAD,
+                                  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD]);
+
+	retries = 0;
+    do {
+        ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &byte);
+        /* If device (on INIT, i.e. it should be idle) is neither
+         * busy nor ready something's fishy, i.e., there is probably
+         * no device present.
+         * I'd like to do a proper timeout but don't know of a portable
+         * timeout routine (w/o using multitasking / rtems_task_wake_after())
+         */
+        if ( ! (byte & (IDE_REGISTER_STATUS_BSY | IDE_REGISTER_STATUS_DRDY))) {
+            retries++;
+            if ( 10000 == retries ) {
+              /* probably no drive connected */
+              areq->breq->status = RTEMS_UNSATISFIED;
+              return;
+            }
+        }
+    } while ((byte & IDE_REGISTER_STATUS_BSY) ||
+             (!(byte & IDE_REGISTER_STATUS_DRDY)));
+
+    for (i=0; i< ATA_MAX_CMD_REG_OFFSET; i++)
+    {
+        uint32_t   reg = (1 << i);
+        if (areq->regs.to_write & reg)
+            ide_controller_write_register(ctrl_minor, i,
+                                          areq->regs.regs[i]);
+    }
+
+    do {
+        ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &byte);
+    } while (byte & IDE_REGISTER_STATUS_BSY);
+
+    ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &val);
+    ide_controller_read_register(ctrl_minor, IDE_REGISTER_ERROR, &val1);
+
+    if (val & IDE_REGISTER_STATUS_ERR)
+    {
+        areq->breq->status = RTEMS_IO_ERROR;
+        return;
+    }
+
+    switch(areq->type)
+    {
+        case ATA_COMMAND_TYPE_PIO_IN:
+            if (areq->cnt)
+            {
+              int ccbuf = areq->cbuf;
+              ide_controller_read_data_block(ctrl_minor,
+                                             areq->breq->bufs[0].length * areq->cnt,
+                                             areq->breq->bufs, &areq->cbuf,
+                                             &areq->pos);
+              ccbuf = areq->cbuf - ccbuf;
+              areq->cnt -= ccbuf;
+            }
+            if (areq->cnt == 0)
+            {
+                areq->breq->status = RTEMS_SUCCESSFUL;
+            }
+            else
+            {
+                /*
+                 * this shouldn't happend on the initialization
+                 * phase!
+                 */
+                rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR);
+            }
+            break;
+
+        case ATA_COMMAND_TYPE_NON_DATA:
+            areq->breq->status = RTEMS_SUCCESSFUL;
+            areq->info = val1;
+            break;
+
+        default:
+            areq->breq->status = RTEMS_IO_ERROR;
+            break;
+    }
+}
+
+void ata_breq_init(blkdev_request1 *breq, uint16_t *sector_buffer)
+{
+  memset(breq, 0, sizeof(*breq));
+
+  breq->req.done_arg = breq;
+  breq->req.bufnum = 1;
+  breq->req.bufs [0].length = ATA_SECTOR_SIZE;
+  breq->req.bufs [0].buffer = sector_buffer;
+}
+
+rtems_status_code ata_identify_device(
+  rtems_device_minor_number ctrl_minor,
+  int dev,
+  uint16_t *sector_buffer,
+  ata_dev_t *device_entry
+)
+{
+  ata_req_t areq;
+  blkdev_request1 breq;
+
+  ata_breq_init(&breq, sector_buffer);
+
+  /*
+   * Issue DEVICE IDENTIFY ATA command and get device
+   * configuration
+   */
+  memset(&areq, 0, sizeof(ata_req_t));
+  areq.type = ATA_COMMAND_TYPE_PIO_IN;
+  areq.regs.to_write = ATA_REGISTERS_VALUE(IDE_REGISTER_COMMAND);
+  areq.regs.regs [IDE_REGISTER_COMMAND] = ATA_COMMAND_IDENTIFY_DEVICE;
+  areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
+  areq.breq = (rtems_blkdev_request *)&breq;
+  areq.cnt = breq.req.bufnum;
+  areq.regs.regs [IDE_REGISTER_DEVICE_HEAD] |=
+    dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS;
+
+  /*
+   * Process the request. Special processing of requests on
+   * initialization phase is needed because at this moment there
+   * is no multitasking enviroment
+   */
+  ata_process_request_on_init_phase(ctrl_minor, &areq);
+
+  /* check status of I/O operation */
+  if (breq.req.status != RTEMS_SUCCESSFUL) {
+    return RTEMS_IO_ERROR;
+  }
+
+  /*
+   * Parse returned device configuration and fill in ATA internal
+   * device info structure
+   */
+  device_entry->cylinders =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_CLNDS]);
+  device_entry->heads =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_HEADS]);
+  device_entry->sectors =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_CURR_LOG_SECS]);
+  device_entry->lba_sectors =
+      CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS1]);
+  device_entry->lba_sectors <<= 16;
+  device_entry->lba_sectors += CF_LE_W(sector_buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS0]);
+  device_entry->lba_avaible =
+      (CF_LE_W(sector_buffer[ATA_IDENT_WORD_CAPABILITIES]) >> 9) & 0x1;
+
+  if ((CF_LE_W(sector_buffer[ATA_IDENT_WORD_FIELD_VALIDITY]) &
+       ATA_IDENT_BIT_VALID) == 0) {
+    /* no "supported modes" info -> use default */
+    device_entry->mode_active = ATA_MODES_PIO3;
+  } else {
+    device_entry->modes_available =
+      ((CF_LE_W(sector_buffer[64]) & 0x1) ? ATA_MODES_PIO3 : 0) |
+      ((CF_LE_W(sector_buffer[64]) & 0x2) ? ATA_MODES_PIO4 : 0) |
+      ((CF_LE_W(sector_buffer[63]) & 0x1) ? ATA_MODES_DMA0 : 0) |
+      ((CF_LE_W(sector_buffer[63]) & 0x2) ?
+       ATA_MODES_DMA0 | ATA_MODES_DMA1 : 0) |
+      ((CF_LE_W(sector_buffer[63]) & 0x4) ?
+       ATA_MODES_DMA0 | ATA_MODES_DMA1 | ATA_MODES_DMA2 : 0);
+    if (device_entry->modes_available == 0) {
+      return RTEMS_IO_ERROR;
+    }
+  }
+
+  return RTEMS_SUCCESSFUL;
+}


 *sh*:
2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* libchip/Makefile.am, libchip/preinstall.am: Install
	<libchip/ata_internal.h>.

M  1.531  c/src/ChangeLog
M   1.49  c/src/libchip/Makefile.am
M   1.20  c/src/libchip/preinstall.am

diff -u rtems/c/src/ChangeLog:1.530 rtems/c/src/ChangeLog:1.531
--- rtems/c/src/ChangeLog:1.530	Tue Aug 17 08:54:49 2010
+++ rtems/c/src/ChangeLog	Tue Aug 17 09:06:56 2010
@@ -1,5 +1,10 @@
 2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
+	* libchip/Makefile.am, libchip/preinstall.am: Install
+	<libchip/ata_internal.h>.
+
+2010-08-17	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
 	* libchip/ide/ata_util.c: New file.
 	* libchip/Makefile.am: Reflect change from above.
 	* libchip/ide/ata.c: Moved ata_breq_init(), ata_identify_device(), and

diff -u rtems/c/src/libchip/Makefile.am:1.48 rtems/c/src/libchip/Makefile.am:1.49
--- rtems/c/src/libchip/Makefile.am:1.48	Tue Aug 17 08:54:50 2010
+++ rtems/c/src/libchip/Makefile.am	Tue Aug 17 09:06:56 2010
@@ -27,11 +27,10 @@
 
 # ide
 include_libchip_HEADERS += ide/ata.h ide/ide_ctrl_cfg.h ide/ide_ctrl.h \
-    ide/ide_ctrl_io.h
+    ide/ide_ctrl_io.h ide/ata_internal.h
 
 noinst_LIBRARIES += libide.a
-libide_a_SOURCES = ide/ata.c ide/ata_util.c ide/ide_controller.c \
-    ide/ata_internal.h
+libide_a_SOURCES = ide/ata.c ide/ata_util.c ide/ide_controller.c
 libide_a_CPPFLAGS = $(AM_CPPFLAGS)
 
 # network

diff -u rtems/c/src/libchip/preinstall.am:1.19 rtems/c/src/libchip/preinstall.am:1.20
--- rtems/c/src/libchip/preinstall.am:1.19	Tue Oct 20 21:30:35 2009
+++ rtems/c/src/libchip/preinstall.am	Tue Aug 17 09:06:56 2010
@@ -57,6 +57,10 @@
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libchip/ide_ctrl_io.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/libchip/ide_ctrl_io.h
 
+$(PROJECT_INCLUDE)/libchip/ata_internal.h: ide/ata_internal.h $(PROJECT_INCLUDE)/libchip/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libchip/ata_internal.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libchip/ata_internal.h
+
 if HAS_NETWORKING
 $(PROJECT_INCLUDE)/libchip/cs8900.h: network/cs8900.h $(PROJECT_INCLUDE)/libchip/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libchip/cs8900.h



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100817/752c9478/attachment.html>


More information about the vc mailing list