Move internal defs from ata.h to ata.c.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 23 Mar 2008 04:04:54 +0000 (00:04 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 23 Mar 2008 04:04:54 +0000 (00:04 -0400)
With -fwhole-program it is not necessary to put inline functions into
    headers.  So, move the internal defs and code to ata.c.

src/ata.c
src/ata.h

index cfe4b1eee7e4357afc7c0609401b2535038f99f8..eba9972a5057c2efc641ee8de837cf8a171884a4 100644 (file)
--- a/src/ata.c
+++ b/src/ata.c
@@ -139,6 +139,24 @@ ata_reset(u16 device)
       // 6 : no sectors left to write
       // 7 : more sectors to write
 
+struct ata_pio_command {
+    void *far_buffer;
+    u8 biosid;
+
+    u8 feature;
+    u8 sector_count;
+    u8 lba_low;
+    u8 lba_mid;
+    u8 lba_high;
+    u8 device;
+    u8 command;
+
+    u8 sector_count2;
+    u8 lba_low2;
+    u8 lba_mid2;
+    u8 lba_high2;
+};
+
 static int
 send_cmd(struct ata_pio_command *cmd)
 {
@@ -183,7 +201,7 @@ send_cmd(struct ata_pio_command *cmd)
     return 0;
 }
 
-int
+static int
 ata_transfer(struct ata_pio_command *cmd)
 {
     DEBUGF("ata_transfer id=%d cmd=%d lba=%d count=%d buf=%p\n"
@@ -258,6 +276,36 @@ ata_transfer(struct ata_pio_command *cmd)
     return 0;
 }
 
+inline int
+ata_cmd_data(u16 biosid, u16 command, u32 lba, u16 count, void *far_buffer)
+{
+    u8 slave   = biosid % 2;
+
+    struct ata_pio_command cmd;
+    cmd.far_buffer = far_buffer;
+    cmd.biosid = biosid;
+
+    if (count >= (1<<8) || lba + count >= (1<<28)) {
+        cmd.sector_count2 = count >> 8;
+        cmd.lba_low2 = lba >> 24;
+        cmd.lba_mid2 = 0;
+        cmd.lba_high2 = 0;
+
+        command |= 0x04;
+        lba &= 0xffffff;
+    }
+
+    cmd.feature = 0;
+    cmd.sector_count = count;
+    cmd.lba_low = lba;
+    cmd.lba_mid = lba >> 8;
+    cmd.lba_high = lba >> 16;
+    cmd.device = ((slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0)
+                  | ((lba >> 24) & 0xf) | ATA_CB_DH_LBA);
+    cmd.command = command;
+    return ata_transfer(&cmd);
+}
+
 // ---------------------------------------------------------------------------
 // ATA/ATAPI driver : execute a packet command
 // ---------------------------------------------------------------------------
index 074ed555770ea686afb6c890713d4f1caaffbf58..5d430a00563097b42d6af013e2090fb5420e367d 100644 (file)
--- a/src/ata.h
+++ b/src/ata.h
 #include "types.h" // u16
 #include "atabits.h" // ATA_CB_DH_DEV1
 
-struct ata_pio_command {
-    void *far_buffer;
-    u8 biosid;
-
-    u8 feature;
-    u8 sector_count;
-    u8 lba_low;
-    u8 lba_mid;
-    u8 lba_high;
-    u8 device;
-    u8 command;
-
-    u8 sector_count2;
-    u8 lba_low2;
-    u8 lba_mid2;
-    u8 lba_high2;
-};
-
 // Function definitions
 void ata_reset(u16 device);
-int ata_transfer(struct ata_pio_command *cmd);
+int ata_cmd_data(u16 biosid, u16 command, u32 lba, u16 count, void *far_buffer);
 int ata_cmd_packet(u16 device, u8 *cmdbuf, u8 cmdlen
                    , u32 length, void *far_buffer);
 int cdrom_read(u16 device, u32 lba, u32 count, void *far_buffer);
 int cdrom_read_512(u16 device, u32 lba, u32 count, void *far_buffer);
 void ata_detect();
 
-static inline int
-ata_cmd_data(u16 biosid, u16 command, u32 lba, u16 count, void *far_buffer)
-{
-    u8 slave   = biosid % 2;
-
-    struct ata_pio_command cmd;
-    cmd.far_buffer = far_buffer;
-    cmd.biosid = biosid;
-
-    if (count >= (1<<8) || lba + count >= (1<<28)) {
-        cmd.sector_count2 = count >> 8;
-        cmd.lba_low2 = lba >> 24;
-        cmd.lba_mid2 = 0;
-        cmd.lba_high2 = 0;
-
-        command |= 0x04;
-        lba &= 0xffffff;
-    }
-
-    cmd.feature = 0;
-    cmd.sector_count = count;
-    cmd.lba_low = lba;
-    cmd.lba_mid = lba >> 8;
-    cmd.lba_high = lba >> 16;
-    cmd.device = ((slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0)
-                  | ((lba >> 24) & 0xf) | ATA_CB_DH_LBA);
-    cmd.command = command;
-    return ata_transfer(&cmd);
-}
-
 #endif /* __ATA_H */