Index: c/src/libchip/ide/ata.c
===================================================================
--- c/src/libchip/ide/ata.c	(revision 73b5bd5d0e7481ac2459b682a88ac43383265448)
+++ c/src/libchip/ide/ata.c	(revision a3d3d9aeda34fd9c4535b6d59cf90f42528d273a)
@@ -2,6 +2,6 @@
  * ata.c
  *
- * ATA RTEMS driver. ATA driver is hardware independant implementation of 
- * ATA-2 standart, working draft X3T10/0948D, revision 4c. ATA driver bases 
+ * ATA RTEMS driver. ATA driver is hardware independant implementation of
+ * ATA-2 standart, working draft X3T10/0948D, revision 4c. ATA driver bases
  * on RTEMS IDE controller driver.
  *
@@ -12,7 +12,7 @@
  * found in the file LICENSE in this distribution or at
  * http://www.rtems.com/license/LICENSE.
- * 
+ *
  * $Id$
- * 
+ *
  */
 #include <errno.h>
@@ -50,5 +50,5 @@
 
 #else
- 
+
 typedef boolean preemption_key;
 
@@ -58,5 +58,5 @@
         _Thread_Executing->is_preemptible = 0;       \
     } while (0)
-    
+
 #define ENABLE_PREEMPTION(key) \
     do {                                             \
@@ -82,5 +82,5 @@
 
 /*
- * Mapping from ATA-minor numbers to 
+ * Mapping from ATA-minor numbers to
  * controller-minor and device on this controller.
  */
@@ -97,5 +97,5 @@
 
 /* Mapping of interrupt vectors to devices */
-static Chain_Control ata_int_vec[ATA_MAX_RTEMS_INT_VEC_NUMBER + 1];  
+static Chain_Control ata_int_vec[ATA_MAX_RTEMS_INT_VEC_NUMBER + 1];
 
 static void
@@ -106,17 +106,17 @@
                                   ata_req_t                 *areq);
 
-static void 
-ata_add_to_controller_queue(rtems_device_minor_number  ctrl_minor, 
+static void
+ata_add_to_controller_queue(rtems_device_minor_number  ctrl_minor,
                             ata_req_t                 *areq);
 
 /*
- * read/write, open/close and ioctl are provided by general block device 
+ * read/write, open/close and ioctl are provided by general block device
  * driver. Only initialization and ata-specific ioctl are here.
  */
 
-/* ata_io_data_request -- 
- *     Form read/write request for an ATA device and enqueue it to 
- *     IDE controller. 
- * 
+/* ata_io_data_request --
+ *     Form read/write request for an ATA device and enqueue it to
+ *     IDE controller.
+ *
  * PARAMETERS:
  *     device - device identifier
@@ -125,5 +125,5 @@
  * RETURNS:
  *     RTEMS_SUCCESSFUL on success, or error code if
- *     error occured 
+ *     error occured
  */
 static rtems_status_code
@@ -131,13 +131,13 @@
 {
     ata_req_t                 *areq; /* ATA request */
-    rtems_device_minor_number  rel_minor; /* relative minor which indexes 
+    rtems_device_minor_number  rel_minor; /* relative minor which indexes
                                            * ata_devs array
                                            */
     rtems_device_minor_number  ctrl_minor;
     uint8_t                    dev;
-    
-    rel_minor = (rtems_filesystem_dev_minor_t(device)) / 
+
+    rel_minor = (rtems_filesystem_dev_minor_t(device)) /
                 ATA_MINOR_NUM_RESERVED_PER_ATA_DEVICE;
-    
+
     /* get controller which serves the ATA device */
     ctrl_minor = ata_devs[rel_minor].ctrl_minor;
@@ -151,16 +151,16 @@
         return RTEMS_NO_MEMORY;
     }
-                                                            
+
     areq->breq = req;
     areq->cnt = req->count;
     areq->cbuf = 0;
     areq->pos = 0;
-    
-    /* set up registers masks */   
+
+    /* set up registers masks */
     areq->regs.to_write = ATA_REGISTERS_POSITION;
     areq->regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
-    
+
     /* choose device on the controller for which the command will be issued */
-    areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] = 
+    areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] =
                                     (dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS);
 
@@ -172,24 +172,24 @@
         if (req->req == BLKDEV_REQ_READ)
             areq->regs.regs[IDE_REGISTER_COMMAND] = ATA_COMMAND_READ_DMA;
-        else 
+        else
             areq->regs.regs[IDE_REGISTER_COMMAND] = ATA_COMMAND_WRITE_DMA;
     }
-    else 
+    else
     {
         if (req->req == BLKDEV_REQ_READ)
         {
             areq->type = ATA_COMMAND_TYPE_PIO_IN;
-              
-            /* 
-             * choose command to issue: if the number of blocks to be 
+
+            /*
+             * choose command to issue: if the number of blocks to be
              * exchanged is greater then 1 and for ATA command READ MULTIPLE
              * data block consists of more then 1 sector choose READ MULTIPLE
              * otherwise READ SECTORS
              */
-            areq->regs.regs[IDE_REGISTER_COMMAND] = 
-                ((ATA_DEV_INFO(ctrl_minor, dev).max_multiple) && 
-                 (req->count > 1) && 
-                 (ATA_DEV_INFO(ctrl_minor, dev).current_multiple > 1)) ? 
-                 ATA_COMMAND_READ_MULTIPLE : 
+            areq->regs.regs[IDE_REGISTER_COMMAND] =
+                ((ATA_DEV_INFO(ctrl_minor, dev).max_multiple) &&
+                 (req->count > 1) &&
+                 (ATA_DEV_INFO(ctrl_minor, dev).current_multiple > 1)) ?
+                 ATA_COMMAND_READ_MULTIPLE :
                  ATA_COMMAND_READ_SECTORS;
         }
@@ -198,15 +198,15 @@
             areq->type = ATA_COMMAND_TYPE_PIO_OUT;
 
-            /* 
-             * choose command to issue: if the number of blocks to be 
+            /*
+             * choose command to issue: if the number of blocks to be
              * exchanged is greater then 1 and for ATA command WRITE MULTIPLE
              * data block consists of more then 1 sector choose WRITE MULTIPLE
              * otherwise WRITE SECTORS
              */
-            areq->regs.regs[IDE_REGISTER_COMMAND] = 
+            areq->regs.regs[IDE_REGISTER_COMMAND] =
               ((ATA_DEV_INFO(ctrl_minor, dev).max_multiple) &&
                (req->count > 1) &&
-               (ATA_DEV_INFO(ctrl_minor, dev).current_multiple > 1)) ? 
-               ATA_COMMAND_WRITE_MULTIPLE : 
+               (ATA_DEV_INFO(ctrl_minor, dev).current_multiple > 1)) ?
+               ATA_COMMAND_WRITE_MULTIPLE :
                ATA_COMMAND_WRITE_SECTORS;
         }
@@ -233,5 +233,5 @@
         /* now count = number of tracks: */
         count /= ATA_DEV_INFO(ctrl_minor, dev).sectors;
-        areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] |= 
+        areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] |=
                           (count / ATA_DEV_INFO(ctrl_minor, dev).cylinders);
 
@@ -240,5 +240,5 @@
         areq->regs.regs[IDE_REGISTER_CYLINDER_LOW] = (uint8_t)count;
         areq->regs.regs[IDE_REGISTER_CYLINDER_HIGH] = (uint8_t)(count >> 8);
-        areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &= 
+        areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &=
                                                 ~IDE_REGISTER_DEVICE_HEAD_L;
     }
@@ -246,15 +246,15 @@
     /* fill sector count register */
     areq->regs.regs[IDE_REGISTER_SECTOR_COUNT] = areq->breq->count;
-    
+
     /* add request to the queue of awaiting requests to the controller */
     ata_add_to_controller_queue(ctrl_minor, areq);
- 
+
     return RTEMS_SUCCESSFUL;
 }
 
-/* ata_non_data_request -- 
- *     Form and serve request of NON DATA type for an ATA device. 
+/* ata_non_data_request --
+ *     Form and serve request of NON DATA type for an ATA device.
  *     Processing of NON DATA request is SYNChronous operation.
- * 
+ *
  * PARAMETERS:
  *     device - device identifier
@@ -264,5 +264,5 @@
  * RETURNS:
  *     RTEMS_SUCCESSFUL on success, or error code if
- *     error occured 
+ *     error occured
  */
 static rtems_status_code
@@ -276,8 +276,8 @@
     rtems_device_minor_number  ctrl_minor;
     uint8_t                    dev;
-    ata_queue_msg_t            msg;    
-    
+    ata_queue_msg_t            msg;
+
     rel_minor = (rtems_filesystem_dev_minor_t(device)) /
-                ATA_MINOR_NUM_RESERVED_PER_ATA_DEVICE; 
+                ATA_MINOR_NUM_RESERVED_PER_ATA_DEVICE;
 
     /* get controller which serves the ATA device */
@@ -293,36 +293,36 @@
         return RTEMS_NO_MEMORY;
     }
-    memset(areq, 0, sizeof(ata_req_t));    
+    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_DEVICE_HEAD] |= 
+    areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] |=
                                     (dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS);
     areq->breq = NULL;
     areq->regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_ERROR);
-    
-    /* 
-     * depending on command fill command register and additional registers 
+
+    /*
+     * depending on command fill command register and additional registers
      * which are needed for command execution
      */
     switch(cmd)
-    { 
+    {
         case ATAIO_SET_MULTIPLE_MODE:
-            areq->regs.regs[IDE_REGISTER_COMMAND] = 
+            areq->regs.regs[IDE_REGISTER_COMMAND] =
                                                 ATA_COMMAND_SET_MULTIPLE_MODE;
-            areq->regs.to_write |= 
+            areq->regs.to_write |=
                                ATA_REGISTERS_VALUE(IDE_REGISTER_SECTOR_COUNT);
             areq->regs.regs[IDE_REGISTER_SECTOR_COUNT] = *(uint8_t*)argp;
             break;
-        
+
         default:
             free(areq);
             return RTEMS_INVALID_NUMBER;
-            break;                                
-    }  
-
-    rc = rtems_semaphore_create(rtems_build_name('I', 'D', 'E', 'S'), 
-                                0, 
-                                RTEMS_FIFO | RTEMS_COUNTING_SEMAPHORE | 
+            break;
+    }
+
+    rc = rtems_semaphore_create(rtems_build_name('I', 'D', 'E', 'S'),
+                                0,
+                                RTEMS_FIFO | RTEMS_COUNTING_SEMAPHORE |
                                 RTEMS_NO_INHERIT_PRIORITY |
                                 RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL,
@@ -333,8 +333,8 @@
         free(areq);
         return rc;
-    }                                 
-                                        
+    }
+
     ata_add_to_controller_queue(ctrl_minor, areq);
-    
+
     /* wait for request processing... */
     rc = rtems_semaphore_obtain(areq->sema, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
@@ -343,48 +343,48 @@
         free(areq);
         return rc;
-    }                                 
+    }
 
     rtems_semaphore_delete(areq->sema);
-    
-    /* 
-     * if no error occurred and if necessary, update internal ata driver data 
+
+    /*
+     * if no error occurred and if necessary, update internal ata driver data
      * structures to reflect changes (in device configuration, for example)
-     */ 
+     */
     if (areq->status == RTEMS_SUCCESSFUL)
     {
         switch(cmd)
-        { 
+        {
             case ATAIO_SET_MULTIPLE_MODE:
-                ATA_DEV_INFO(ctrl_minor, dev).current_multiple = 
+                ATA_DEV_INFO(ctrl_minor, dev).current_multiple =
                                                            *(uint8_t*)argp;
                 break;
-        
+
             default:
                 rc = RTEMS_INVALID_NUMBER;
-                break;                                
-        }  
-    }    
-    else    
-    {    
-        /* XXX: should be correct error processing: for ex, may be 
+                break;
+        }
+    }
+    else
+    {
+        /* XXX: should be correct error processing: for ex, may be
          * ABRT and then we should return RTEMS_NOT_IMPLEMENTED
          */
         rc = RTEMS_IO_ERROR;
-    }    
-    
+    }
+
     /* tell ata driver that controller ready to serve next request */
     ATA_SEND_EVT(msg, ATA_MSG_SUCCESS_EVT, ctrl_minor, 0);
-                                                 
+
     return rc;
 }
 
-/* ata_process_request -- 
- *     Get first request from controller's queue and process it. 
- * 
+/* ata_process_request --
+ *     Get first request from controller's queue and process it.
+ *
  * PARAMETERS:
  *     ctrl_minor - controller identifier
  *
  * RETURNS:
- *     NONE 
+ *     NONE
  */
 static void
@@ -396,9 +396,9 @@
     uint8_t          i, dev;
     uint16_t         val;
-    uint16_t         data_bs; /* the number of 512-bytes sectors in one 
-                               * data block 
+    uint16_t         data_bs; /* the number of 512-bytes sectors in one
+                               * data block
                                */
-    ISR_Level        level;                           
-        
+    ISR_Level        level;
+
     /* if no requests to controller then do nothing */
     if (Chain_Is_empty(&ata_ide_ctrls[ctrl_minor].reqs))
@@ -409,20 +409,20 @@
     areq = (ata_req_t *)(ata_ide_ctrls[ctrl_minor].reqs.first);
     _ISR_Enable(level);
-    
+
     /* get ATA device identifier (0 or 1) */
-    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] & 
+    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
            IDE_REGISTER_DEVICE_HEAD_DEV;
 
     /* get data block size */
-    data_bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?  
-              ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;      
-    
+    data_bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?
+              ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;
+
     /* execute device select protocol */
-    ide_controller_write_register(ctrl_minor, IDE_REGISTER_DEVICE_HEAD, 
+    ide_controller_write_register(ctrl_minor, IDE_REGISTER_DEVICE_HEAD,
                                   areq->regs.regs[IDE_REGISTER_DEVICE_HEAD]);
-    
+
     do {
         ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &byte);
-    } while ((byte & IDE_REGISTER_STATUS_BSY) || 
+    } while ((byte & IDE_REGISTER_STATUS_BSY) ||
              (!(byte & IDE_REGISTER_STATUS_DRDY)));
 
@@ -439,5 +439,5 @@
     {
         do {
-            ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, 
+            ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS,
                                          &byte);
         } while (byte & IDE_REGISTER_STATUS_BSY);
@@ -446,16 +446,16 @@
         {
             ide_controller_write_data_block(
-                ctrl_minor, 
+                ctrl_minor,
                 MIN(data_bs, areq->cnt) * ATA_SECTOR_SIZE,
                 areq->breq->bufs, &areq->cbuf,
                 &areq->pos);
             areq->cnt -= MIN(data_bs, areq->cnt);
-        }    
+        }
         else
-        {    
+        {
             if (IDE_Controller_Table[ctrl_minor].int_driven == 0)
             {
                 ide_controller_read_register(
-                    ctrl_minor, 
+                    ctrl_minor,
                     IDE_REGISTER_ALTERNATE_STATUS_OFFSET,
                     &val);
@@ -463,8 +463,8 @@
                                              &val);
 
-                ATA_SEND_EVT(msg, ATA_MSG_ERROR_EVT, ctrl_minor, 
+                ATA_SEND_EVT(msg, ATA_MSG_ERROR_EVT, ctrl_minor,
                              RTEMS_IO_ERROR);
             }
-        }    
+        }
     }
 
@@ -472,18 +472,18 @@
     {
         do {
-            ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, 
+            ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS,
                                          &byte);
         } while (byte & IDE_REGISTER_STATUS_BSY);
-        
+
         ATA_SEND_EVT(msg, ATA_MSG_GEN_EVT, ctrl_minor, 0);
-    }    
+    }
 }
 
-/* ata_request_done -- 
+/* ata_request_done --
  *     Extract request from controller queue, execute callback if necessary
  *     and process next request for the controller.
- * 
+ *
  * PARAMETERS:
- *     areq       - ATA request 
+ *     areq       - ATA request
  *     ctrl_minor - controller identifier
  *     status     - status with which request has been done
@@ -512,12 +512,12 @@
         return;
     }
-    ENABLE_PREEMPTION(key); 
+    ENABLE_PREEMPTION(key);
 }
 
-/* ata_non_data_request_done -- 
+/* ata_non_data_request_done --
  *     Set up request status and release request's semaphore.
- * 
+ *
  * PARAMETERS:
- *     areq       - ATA request 
+ *     areq       - ATA request
  *     ctrl_minor - controller identifier
  *     status     - status with which request has been done
@@ -528,5 +528,5 @@
  */
 static inline void
-ata_non_data_request_done(ata_req_t *areq, 
+ata_non_data_request_done(ata_req_t *areq,
                           rtems_device_minor_number ctrl_minor,
                           rtems_status_code status, int error)
@@ -538,10 +538,10 @@
 
 
-/* ata_add_to_controller_queue -- 
+/* ata_add_to_controller_queue --
  *     Add request to the controller's queue.
- * 
+ *
  * PARAMETERS:
  *     ctrl_minor - controller identifier
- *     areq       - ATA request 
+ *     areq       - ATA request
  *
  * RETURNS:
@@ -549,5 +549,5 @@
  */
 static void
-ata_add_to_controller_queue(rtems_device_minor_number  ctrl_minor, 
+ata_add_to_controller_queue(rtems_device_minor_number  ctrl_minor,
                             ata_req_t                 *areq)
 {
@@ -559,10 +559,10 @@
 
 #ifdef DEBUG
-        /* 
+        /*
          * read IDE_REGISTER_ALTERNATE_STATUS instead IDE_REGISTER_STATUS
          * to prevent clearing of pending interrupt
          */
-        ide_controller_read_register(ctrl_minor, 
-                                     IDE_REGISTER_ALTERNATE_STATUS, 
+        ide_controller_read_register(ctrl_minor,
+                                     IDE_REGISTER_ALTERNATE_STATUS,
                                      &val);
         if (val & IDE_REGISTER_STATUS_BSY)
@@ -570,15 +570,15 @@
 #endif
         ATA_SEND_EVT(msg, ATA_MSG_PROCESS_NEXT_EVT, ctrl_minor, 0);
-    }    
-}                            
-
-
-/* ata_interrupt_handler -- 
+    }
+}
+
+
+/* ata_interrupt_handler --
  *     ATA driver interrrupt handler. If interrrupt happend it mapped it to
  *     controller (controllerS, if a number of controllers share one int line)
  *     and generates ATA event(s).
- * 
+ *
  * PARAMETERS:
- *     vec - interrupt vector  
+ *     vec - interrupt vector
  *
  * RETURNS:
@@ -591,5 +591,5 @@
     ata_queue_msg_t  msg;
     uint16_t         byte; /* emphasize that only 8 low bits is meaningful */
-    
+
     for ( ; !Chain_Is_tail(&ata_int_vec[vec], the_node) ; )
     {
@@ -601,18 +601,18 @@
         {
             msg.ctrl_minor = ((ata_int_st_t *)the_node)->ctrl_minor;
-            ide_controller_read_register(msg.ctrl_minor, IDE_REGISTER_STATUS, 
+            ide_controller_read_register(msg.ctrl_minor, IDE_REGISTER_STATUS,
                                          &byte);
-            ATA_SEND_EVT(msg, ATA_MSG_GEN_EVT, msg.ctrl_minor, 0);                             
+            ATA_SEND_EVT(msg, ATA_MSG_GEN_EVT, msg.ctrl_minor, 0);
         }
         the_node = the_node->next;
-    }   
+    }
 }
 
-/* ata_pio_in_protocol -- 
+/* ata_pio_in_protocol --
  *     ATA PIO_IN protocol implementation, see specification
- * 
+ *
  * PARAMETERS:
  *     ctrl_minor - controller identifier
- *     areq       - ATA request 
+ *     areq       - ATA request
  *
  * RETURNS:
@@ -626,15 +626,15 @@
     uint32_t        min_val;
     ata_queue_msg_t msg;
-        
-    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] & 
+
+    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
            IDE_REGISTER_DEVICE_HEAD_DEV;
 
-    bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?  
-         ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;      
+    bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?
+         ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;
     min_val = MIN(bs, areq->cnt);
-    
-    ide_controller_read_data_block(ctrl_minor, min_val * ATA_SECTOR_SIZE, 
+
+    ide_controller_read_data_block(ctrl_minor, min_val * ATA_SECTOR_SIZE,
                                    areq->breq->bufs, &areq->cbuf, &areq->pos);
-              
+
     areq->cnt -= min_val;
     if (areq->cnt == 0)
@@ -647,15 +647,15 @@
            ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &val);
         } while (val & IDE_REGISTER_STATUS_BSY);
-        
+
         ATA_SEND_EVT(msg, ATA_MSG_GEN_EVT, ctrl_minor, 0);
     }
 }
 
-/* ata_pio_out_protocol -- 
+/* ata_pio_out_protocol --
  *     ATA PIO_OUT protocol implementation, see specification
- * 
+ *
  * PARAMETERS:
  *     ctrl_minor - controller identifier
- *     areq       - ATA request 
+ *     areq       - ATA request
  *
  * RETURNS:
@@ -669,12 +669,12 @@
     uint32_t        min_val;
     ata_queue_msg_t msg;
-    
-    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] & 
+
+    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
            IDE_REGISTER_DEVICE_HEAD_DEV;
 
-    bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?  
-         ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;      
-
-    min_val = MIN(bs, areq->cnt);     
+    bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?
+         ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;
+
+    min_val = MIN(bs, areq->cnt);
 
     if (areq->cnt == 0)
@@ -682,8 +682,8 @@
         ata_request_done(areq, ctrl_minor, RTEMS_SUCCESSFUL, RTEMS_SUCCESSFUL);
     }
-    else 
+    else
     {
         ide_controller_write_data_block(ctrl_minor, min_val * ATA_SECTOR_SIZE,
-                                        areq->breq->bufs, &areq->cbuf, 
+                                        areq->breq->bufs, &areq->cbuf,
                                         &areq->pos);
         areq->cnt -= min_val;
@@ -691,5 +691,5 @@
         {
             do {
-                ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, 
+                ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS,
                                              &val);
             } while (val & IDE_REGISTER_STATUS_BSY);
@@ -700,7 +700,7 @@
 }
 
-/* ata_queue_task -- 
+/* ata_queue_task --
  *     Task which manages ATA driver events queue.
- * 
+ *
  * PARAMETERS:
  *     arg - ignored
@@ -710,5 +710,5 @@
  *
  * NOTES:
- *     should be non-preemptive 
+ *     should be non-preemptive
  */
 static rtems_task
@@ -727,17 +727,17 @@
     {
         /* get event which has happend */
-        rc = rtems_message_queue_receive(ata_queue_id, &msg, &size, RTEMS_WAIT, 
+        rc = rtems_message_queue_receive(ata_queue_id, &msg, &size, RTEMS_WAIT,
                                          RTEMS_NO_TIMEOUT);
         if (rc != RTEMS_SUCCESSFUL)
             rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR);
-                                             
+
         /* get controller on which event has happend */
         ctrl_minor = msg.ctrl_minor;
-        
+
         /* get current request to the controller */
-        _ISR_Disable(level);        
+        _ISR_Disable(level);
         areq = (ata_req_t *)(ata_ide_ctrls[ctrl_minor].reqs.first);
         _ISR_Enable(level);
-        
+
         switch(msg.type)
         {
@@ -748,45 +748,45 @@
 
             case ATA_MSG_SUCCESS_EVT:
-                /* 
-                 * finish processing of current request with successful 
-                 * status and start processing of the next request in the 
+                /*
+                 * finish processing of current request with successful
+                 * status and start processing of the next request in the
                  * controller queue
                  */
-                ata_request_done(areq, ctrl_minor, RTEMS_SUCCESSFUL, 
+                ata_request_done(areq, ctrl_minor, RTEMS_SUCCESSFUL,
                                  msg.error);
                 break;
-                
+
             case ATA_MSG_ERROR_EVT:
-                /* 
-                 * finish processing of current request with error 
-                 * status and start processing of the next request in the 
+                /*
+                 * finish processing of current request with error
+                 * status and start processing of the next request in the
                  * controller queue
                  */
-                ata_request_done(areq, ctrl_minor, RTEMS_UNSATISFIED, 
+                ata_request_done(areq, ctrl_minor, RTEMS_UNSATISFIED,
                                  msg.error);
                 break;
-                
+
             case ATA_MSG_GEN_EVT:
-                /* 
-                 * continue processing of the current request to the 
-                 * controller according to current request state and 
+                /*
+                 * continue processing of the current request to the
+                 * controller according to current request state and
                  * ATA protocol
                  */
-                ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, 
+                ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS,
                                            &val);
                 /* process error case */
                 if (val & IDE_REGISTER_STATUS_ERR)
-                { 
-                    ide_controller_read_register(ctrl_minor, 
-                                                 IDE_REGISTER_ERROR, 
+                {
+                    ide_controller_read_register(ctrl_minor,
+                                                 IDE_REGISTER_ERROR,
                                                  &val);
                     if (areq->type == ATA_COMMAND_TYPE_NON_DATA)
-                        ata_non_data_request_done(areq, ctrl_minor, 
-                                                  RTEMS_UNSATISFIED, 
+                        ata_non_data_request_done(areq, ctrl_minor,
+                                                  RTEMS_UNSATISFIED,
                                                   RTEMS_IO_ERROR);
-                    else                             
-                        ata_request_done(areq, ctrl_minor, RTEMS_UNSATISFIED, 
+                    else
+                        ata_request_done(areq, ctrl_minor, RTEMS_UNSATISFIED,
                                          RTEMS_IO_ERROR);
-                    break;                                  
+                    break;
                 }
 
@@ -796,12 +796,12 @@
                         ata_pio_in_protocol(ctrl_minor, areq);
                         break;
-                
+
                     case ATA_COMMAND_TYPE_PIO_OUT:
                         ata_pio_out_protocol(ctrl_minor, areq);
                         break;
-                
+
                     case ATA_COMMAND_TYPE_NON_DATA:
-                        ide_controller_read_register(ctrl_minor, 
-                                                      IDE_REGISTER_ERROR, 
+                        ide_controller_read_register(ctrl_minor,
+                                                      IDE_REGISTER_ERROR,
                                                      &val1);
                         ata_non_data_request_done(areq, ctrl_minor,
@@ -809,5 +809,5 @@
                                                   val1);
                         break;
-            
+
                     default:
                         printf("ata_queue_task: non-supported command type\n");
@@ -815,7 +815,7 @@
                                          RTEMS_UNSATISFIED,
                                          RTEMS_NOT_IMPLEMENTED);
-                        break;          
+                        break;
                 }
-                break;    
+                break;
 
             default:
@@ -826,7 +826,7 @@
 }
 
-/* ata_ioctl -- 
+/* ata_ioctl --
  *     ATA driver ioctl interface.
- * 
+ *
  * PARAMETERS:
  *     device - device identifier
@@ -837,33 +837,33 @@
  *     depend on 'cmd'
  */
-int 
+int
 ata_ioctl(dev_t device, int cmd, void *argp)
 {
     rtems_status_code         status;
     rtems_device_minor_number rel_minor;
-    
+
     rel_minor = (rtems_filesystem_dev_minor_t(device)) /
                 ATA_MINOR_NUM_RESERVED_PER_ATA_DEVICE;
 
-    /* 
+    /*
      * in most cases this means that device 'device' is not an registred ATA
      * device
-     */ 
+     */
     if (ata_devs[rel_minor].device == ATA_UNDEFINED_VALUE)
     {
         errno = ENODEV;
         return -1;
-    }    
-
-    switch (cmd) 
+    }
+
+    switch (cmd)
     {
         case BLKIO_REQUEST:
             status = ata_io_data_request(device, (blkdev_request *)argp);
             break;
-        
+
         case ATAIO_SET_MULTIPLE_MODE:
             status = ata_non_data_request(device, cmd, argp);
             break;
-      
+
         default:
             errno = EBADRQC;
@@ -875,5 +875,5 @@
     {
         errno = EIO;
-        return -1; 
+        return -1;
     }
     return 0;
@@ -883,5 +883,5 @@
  * ata_initialize --
  *     Initializes all ATA devices found on initialized IDE controllers.
- * 
+ *
  * PARAMETERS:
  *     major - device major number
@@ -891,9 +891,9 @@
  * RETURNS:
  *     RTEMS_SUCCESSFUL on success, or error code if
- *     error occured 
- */
-rtems_device_driver 
-ata_initialize(rtems_device_major_number major, 
-               rtems_device_minor_number minor_arg, 
+ *     error occured
+ */
+rtems_device_driver
+ata_initialize(rtems_device_major_number major,
+               rtems_device_minor_number minor_arg,
                void *args)
 {
@@ -901,5 +901,5 @@
     rtems_status_code  status;
     ata_req_t          areq;
-    blkdev_request1    breq;     
+    blkdev_request1    breq;
     uint8_t            i, dev = 0;
     uint16_t          *buffer;
@@ -912,10 +912,10 @@
     if (ata_initialized)
         return RTEMS_SUCCESSFUL;
-            
+
     /* initialization of disk devices library */
     status = rtems_disk_io_initialize();
     if (status != RTEMS_SUCCESSFUL)
         return status;
-        
+
     /* create queue for asynchronous requests handling */
     status = rtems_message_queue_create(
@@ -929,9 +929,9 @@
         rtems_disk_io_done();
         return status;
-    }    
-
-    /* 
-     * create ATA driver task, see comments for task implementation for 
-     * details 
+    }
+
+    /*
+     * create ATA driver task, see comments for task implementation for
+     * details
      */
     status = rtems_task_create(
@@ -939,5 +939,5 @@
                  ATA_DRIVER_TASK_PRIORITY,
                  ATA_DRIVER_TASK_STACK_SIZE,
-                 RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | 
+                 RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR |
                  RTEMS_INTERRUPT_LEVEL(0),
                  RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
@@ -948,11 +948,11 @@
         rtems_disk_io_done();
         return status;
-    }    
-    
-    /* 
-     * start ATA driver task. Actually the task will not start immediately - 
+    }
+
+    /*
+     * start ATA driver task. Actually the task will not start immediately -
      * it will start only after multitasking support will be started
-     */ 
-    status = rtems_task_start(ata_task_id, ata_queue_task, 0); 
+     */
+    status = rtems_task_start(ata_task_id, ata_queue_task, 0);
     if (status != RTEMS_SUCCESSFUL)
     {
@@ -961,6 +961,6 @@
         rtems_disk_io_done();
         return status;
-    }    
-    
+    }
+
     buffer = (uint16_t*)malloc(ATA_SECTOR_SIZE);
     if (buffer == NULL)
@@ -970,6 +970,6 @@
         rtems_disk_io_done();
         return RTEMS_NO_MEMORY;
-    }    
-        
+    }
+
     ata_devs_number = 0;
 
@@ -981,8 +981,8 @@
         Chain_Initialize_empty(&ata_int_vec[i]);
 
-    /* 
-     * during ATA driver initialization EXECUTE DEVICE DIAGNOSTIC and 
-     * IDENTIFY DEVICE ATA command should be issued; for these purposes ATA 
-     * requests should be formed; ATA requests contain block device request, 
+    /*
+     * during ATA driver initialization EXECUTE DEVICE DIAGNOSTIC and
+     * IDENTIFY DEVICE ATA command should be issued; for these purposes ATA
+     * requests should be formed; ATA requests contain block device request,
      * so form block device request first
      */
@@ -995,8 +995,8 @@
     breq.req.bufs[0].buffer = buffer;
 
-    /* 
+    /*
      * for each presented IDE controller execute EXECUTE DEVICE DIAGNOSTIC
-     * ATA command; for each found device execute IDENTIFY DEVICE ATA 
-     * command 
+     * ATA command; for each found device execute IDENTIFY DEVICE ATA
+     * command
      */
     for (ctrl_minor = 0; ctrl_minor < IDE_Controller_Count; ctrl_minor++)
@@ -1004,5 +1004,5 @@
     {
         Chain_Initialize_empty(&ata_ide_ctrls[ctrl_minor].reqs);
-        
+
         if (IDE_Controller_Table[ctrl_minor].int_driven == TRUE)
         {
@@ -1015,11 +1015,11 @@
                 rtems_disk_io_done();
                 return RTEMS_NO_MEMORY;
-            }       
+            }
 
             int_st->ctrl_minor = ctrl_minor;
 
             status = rtems_interrupt_catch(
-                         ata_interrupt_handler, 
-                         IDE_Controller_Table[ctrl_minor].int_vec, 
+                         ata_interrupt_handler,
+                         IDE_Controller_Table[ctrl_minor].int_vec,
                          &old_isr);
             if (status != RTEMS_SUCCESSFUL)
@@ -1031,5 +1031,5 @@
                 rtems_disk_io_done();
                 return status;
-            } 
+            }
             Chain_Append(
                 &ata_int_vec[IDE_Controller_Table[ctrl_minor].int_vec],
@@ -1037,6 +1037,6 @@
 
             /* disable interrupts */
-            ide_controller_write_register(ctrl_minor, 
-                                          IDE_REGISTER_DEVICE_CONTROL_OFFSET, 
+            ide_controller_write_register(ctrl_minor,
+                                          IDE_REGISTER_DEVICE_CONTROL_OFFSET,
                                           IDE_REGISTER_DEVICE_CONTROL_nIEN);
         }
@@ -1049,5 +1049,5 @@
         areq.type = ATA_COMMAND_TYPE_NON_DATA;
         areq.regs.to_write = ATA_REGISTERS_VALUE(IDE_REGISTER_COMMAND);
-        areq.regs.regs[IDE_REGISTER_COMMAND] = 
+        areq.regs.regs[IDE_REGISTER_COMMAND] =
                                   ATA_COMMAND_EXECUTE_DEVICE_DIAGNOSTIC;
         areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_ERROR);
@@ -1055,7 +1055,7 @@
         areq.breq = (blkdev_request *)&breq;
 
-        /* 
-         * Process the request. Special processing of requests on 
-         * initialization phase is needed because at this moment there 
+        /*
+         * Process the request. Special processing of requests on
+         * initialization phase is needed because at this moment there
          * is no multitasking enviroment
          */
@@ -1067,10 +1067,10 @@
         if (breq.req.status != RTEMS_SUCCESSFUL)
             continue;
-      
-        /* disassemble returned diagnostic codes */ 
+
+        /* disassemble returned diagnostic codes */
         if (breq.req.error == ATA_DEV0_PASSED_DEV1_PASSED_OR_NOT_PRSNT)
         {
             ATA_DEV_INFO(ctrl_minor, 0).present = 1;
-            ATA_DEV_INFO(ctrl_minor,1).present = 1; 
+            ATA_DEV_INFO(ctrl_minor,1).present = 1;
         }
         else if (breq.req.error == ATA_DEV0_PASSED_DEV1_FAILED)
@@ -1105,15 +1105,15 @@
         {
             /*
-             * Issue DEVICE IDENTIFY ATA command and get device 
-             * configuration           
+             * 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] = 
+            areq.regs.regs[IDE_REGISTER_COMMAND] =
                                               ATA_COMMAND_IDENTIFY_DEVICE;
             areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
             areq.breq = (blkdev_request *)&breq;
-            
+
             areq.cnt = breq.req.count;
 
@@ -1121,7 +1121,7 @@
                                     (dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS);
 
-            /* 
-             * Process the request. Special processing of requests on 
-             * initialization phase is needed because at this moment there 
+            /*
+             * Process the request. Special processing of requests on
+             * initialization phase is needed because at this moment there
              * is no multitasking enviroment
              */
@@ -1133,26 +1133,26 @@
 
             /*
-             * Parse returned device configuration and fill in ATA internal 
+             * Parse returned device configuration and fill in ATA internal
              * device info structure
              */
-            ATA_DEV_INFO(ctrl_minor, dev).cylinders = 
+            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 = 
+            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 = 
+            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_SECS0]) << 16) + 
+            ATA_DEV_INFO(ctrl_minor, dev).lba_sectors =
+                (CF_LE_W(buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS0]) << 16) +
                  CF_LE_W(buffer[ATA_IDENT_WORD_NUM_OF_USR_SECS1]);
-            ATA_DEV_INFO(ctrl_minor, dev).lba_avaible = 
+            ATA_DEV_INFO(ctrl_minor, dev).lba_avaible =
                 (CF_LE_W(buffer[ATA_IDENT_WORD_CAPABILITIES]) >> 9) & 0x1;
-            ATA_DEV_INFO(ctrl_minor, dev).max_multiple = 
+            ATA_DEV_INFO(ctrl_minor, dev).max_multiple =
                 (uint8_t) (CF_LE_W(buffer[ATA_IDENT_WORD_RW_MULT]));
-            ATA_DEV_INFO(ctrl_minor, dev).current_multiple = 
-                (CF_LE_W(buffer[ATA_IDENT_WORD_MULT_SECS]) & 0x100) ? 
+            ATA_DEV_INFO(ctrl_minor, dev).current_multiple =
+                (CF_LE_W(buffer[ATA_IDENT_WORD_MULT_SECS]) & 0x100) ?
                 (uint8_t)(CF_LE_W(buffer[ATA_IDENT_WORD_MULT_SECS])) :
                  0;
 
-            if ((CF_LE_W(buffer[ATA_IDENT_WORD_FIELD_VALIDITY]) & 
+            if ((CF_LE_W(buffer[ATA_IDENT_WORD_FIELD_VALIDITY]) &
                  ATA_IDENT_BIT_VALID) == 0) {
 	      /* no "supported modes" info -> use default */
@@ -1164,20 +1164,20 @@
 		((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) ? 
+		((CF_LE_W(buffer[63]) & 0x2) ?
 		 ATA_MODES_DMA0 | ATA_MODES_DMA1 : 0) |
-		((CF_LE_W(buffer[63]) & 0x4) ? 
+		((CF_LE_W(buffer[63]) & 0x4) ?
 		 ATA_MODES_DMA0 | ATA_MODES_DMA1 | ATA_MODES_DMA2 : 0);
 	      if (ATA_DEV_INFO(ctrl_minor, dev).modes_avaible == 0)
                 continue;
-	      /* 
+	      /*
 	       * choose most appropriate ATA device data I/O speed supported
 	       * by the controller
 	       */
 	      status = ide_controller_config_io_speed(
-                ctrl_minor, 
+                ctrl_minor,
                 ATA_DEV_INFO(ctrl_minor, dev).modes_avaible);
 	      if (status != RTEMS_SUCCESSFUL)
                 continue;
-	    }      
+	    }
             /*
              * Ok, let register new ATA device in the system
@@ -1191,11 +1191,11 @@
 
             device = rtems_filesystem_make_dev_t(
-                         major, 
-                         (ata_devs_number * 
+                         major,
+                         (ata_devs_number *
                           ATA_MINOR_NUM_RESERVED_PER_ATA_DEVICE));
 
-            status = rtems_disk_create_phys(device, ATA_SECTOR_SIZE, 
-                ATA_DEV_INFO(ctrl_minor, dev).lba_avaible ? 
-                ATA_DEV_INFO(ctrl_minor, dev).lba_sectors : 
+            status = rtems_disk_create_phys(device, ATA_SECTOR_SIZE,
+                ATA_DEV_INFO(ctrl_minor, dev).lba_avaible ?
+                ATA_DEV_INFO(ctrl_minor, dev).lba_sectors :
                 (ATA_DEV_INFO(ctrl_minor, dev).heads *
                  ATA_DEV_INFO(ctrl_minor, dev).cylinders *
@@ -1206,11 +1206,11 @@
                 ata_devs[ata_devs_number].device = ATA_UNDEFINED_VALUE;
                 continue;
-            }       
+            }
             ata_devs_number++;
         }
         if (IDE_Controller_Table[ctrl_minor].int_driven == TRUE)
-        {    
-            ide_controller_write_register(ctrl_minor, 
-                                          IDE_REGISTER_DEVICE_CONTROL_OFFSET, 
+        {
+            ide_controller_write_register(ctrl_minor,
+                                          IDE_REGISTER_DEVICE_CONTROL_OFFSET,
                                           0x00);
         }
@@ -1222,8 +1222,8 @@
 }
 
-/* ata_process_request_on_init_phase -- 
- *     Process the ATA request during system initialization. Request 
+/* 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
@@ -1231,5 +1231,5 @@
  *
  * RETURNS:
- *     NONE 
+ *     NONE
  */
 static void
@@ -1240,21 +1240,21 @@
     uint8_t            i, dev;
     uint16_t           val, val1;
-    uint16_t           data_bs; /* the number of 512 bytes sectors into one 
-                                 * data block 
+    uint16_t           data_bs; /* the number of 512 bytes sectors into one
+                                 * data block
                                  */
     assert(areq);
-    
-    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] & 
+
+    dev =  areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
            IDE_REGISTER_DEVICE_HEAD_DEV;
 
-    data_bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?  
-              ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;      
-    
-    ide_controller_write_register(ctrl_minor, IDE_REGISTER_DEVICE_HEAD, 
+    data_bs = ATA_DEV_INFO(ctrl_minor, dev).current_multiple ?
+              ATA_DEV_INFO(ctrl_minor, dev).current_multiple : 1;
+
+    ide_controller_write_register(ctrl_minor, IDE_REGISTER_DEVICE_HEAD,
                                   areq->regs.regs[IDE_REGISTER_DEVICE_HEAD]);
-    
+
     do {
         ide_controller_read_register(ctrl_minor, IDE_REGISTER_STATUS, &byte);
-    } while ((byte & IDE_REGISTER_STATUS_BSY) || 
+    } while ((byte & IDE_REGISTER_STATUS_BSY) ||
              (!(byte & IDE_REGISTER_STATUS_DRDY)));
 
@@ -1263,5 +1263,5 @@
         uint32_t   reg = (1 << i);
         if (areq->regs.to_write & reg)
-            ide_controller_write_register(ctrl_minor, i, 
+            ide_controller_write_register(ctrl_minor, i,
                                           areq->regs.regs[i]);
     }
@@ -1280,14 +1280,14 @@
         return;
     }
- 
+
     switch(areq->type)
     {
         case ATA_COMMAND_TYPE_PIO_IN:
             ide_controller_read_data_block(
-                ctrl_minor, 
+                ctrl_minor,
                 MIN(data_bs, areq->cnt) * ATA_SECTOR_SIZE,
                 areq->breq->bufs, &areq->cbuf,
                 &areq->pos);
-              
+
             areq->cnt -= MIN(data_bs, areq->cnt);
             if (areq->cnt == 0)
@@ -1295,24 +1295,24 @@
                 areq->breq->status = RTEMS_SUCCESSFUL;
             }
-            else 
+            else
             {
-                /* 
-                 * this shouldn't happend on the initialization 
-                 * phase! 
+                /*
+                 * this shouldn't happend on the initialization
+                 * phase!
                  */
-                rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR); 
+                rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR);
             }
             break;
-                
+
         case ATA_COMMAND_TYPE_NON_DATA:
             areq->breq->status = RTEMS_SUCCESSFUL;
             areq->breq->error = val1;
             break;
-            
+
         default:
             printf("ata_queue_task: non-supported command type\n");
             areq->breq->status = RTEMS_UNSATISFIED;
             areq->breq->error = RTEMS_NOT_IMPLEMENTED;
-            break;          
+            break;
     }
 }
