AMD Rev F support
[coreboot.git] / src / stream / ide_stream.c
index d05c6aab917094140c3394a27e4863fb1f157690..0dd9a912585fed457cb99bbe41f02636665441be 100644 (file)
@@ -4,11 +4,11 @@
 #include <stream/read_bytes.h>
 #include <delay.h>
 #include <string.h>
+#include <pc80/ide.h>
 
-/* read a sector or a partial sector */
-extern int ide_read_sector(int drive, void * buffer, unsigned int block, int byte_offset, 
-       int n_bytes);
-extern int ide_init(void);
+#ifndef IDE_BOOT_DRIVE
+#define IDE_BOOT_DRIVE 0
+#endif
 
 static unsigned long offset;
 int stream_init(void)
@@ -31,7 +31,7 @@ int stream_init(void)
 #else
        offset = 0x7e00;
 #endif
-       res = ide_init();
+       res = ide_probe(IDE_BOOT_DRIVE);
        delay(1);
        return res;
 }
@@ -41,33 +41,15 @@ void stream_fini(void)
        return;
 }
 
-#ifdef IDE_SWAB
-/* from string/swab.c */
-void
-swab (const char *from, char *to, int n)
-{
-       n &= ~1;
-       while (n > 1)
-       {
-               const char b0 = from[--n], b1 = from[--n];
-               to[n] = b0;
-               to[n + 1] = b1;
-       }
-}
-#endif
-
 static unsigned char buffer[512];
 static unsigned int block_num = 0;
 static unsigned int first_fill = 1;
-#ifndef IDE_BOOT_DRIVE
-#define IDE_BOOT_DRIVE 0
-#endif
-static byte_offset_t ide_read(void *vdest, byte_offset_t offset, byte_offset_t count)
+static byte_offset_t stream_ide_read(void *vdest, byte_offset_t offset, byte_offset_t count)
 {
        byte_offset_t bytes = 0;
        unsigned char *dest = vdest;
 
-       //printk_debug("ide_read count = %x\n", count);
+       //printk_debug("stream_ide_read count = %x\n", count);
        while (bytes < count) {
                unsigned int byte_offset, len;
 
@@ -75,8 +57,7 @@ static byte_offset_t ide_read(void *vdest, byte_offset_t offset, byte_offset_t c
                if (block_num != offset / 512 || first_fill) {
                        block_num  = offset / 512;
                        printk_notice (".");
-                       ide_read_sector(IDE_BOOT_DRIVE, buffer, block_num,
-                                       0, 512);
+                       ide_read(IDE_BOOT_DRIVE, block_num, buffer);
                        first_fill = 0;
                }
 
@@ -86,11 +67,7 @@ static byte_offset_t ide_read(void *vdest, byte_offset_t offset, byte_offset_t c
                        len = (count - bytes);
                }
 
-#ifdef IDE_SWAB
-               swab(buffer + byte_offset, dest, len);
-#else
                memcpy(dest, buffer + byte_offset, len);
-#endif
 
                offset += len;
                bytes += len;
@@ -104,7 +81,7 @@ byte_offset_t stream_read(void *vdest, byte_offset_t count)
 {
        byte_offset_t len;
 
-       len = ide_read(vdest, offset, count);
+       len = stream_ide_read(vdest, offset, count);
        if (len > 0) {
                offset += len;
        }