1 #include <console/console.h>
4 #include <stream/read_bytes.h>
9 #ifndef CONFIG_IDE_BOOT_DRIVE
10 #define CONFIG_IDE_BOOT_DRIVE 0
13 static unsigned long offset;
19 printk_debug ("Trying polled ide\n");
20 printk_debug ("Waiting for ide disks to spin up\n");
21 printk_notice ("This is a hard coded delay and longer than necessary.\n");
22 for (i = 0; i < 2; i++) {
29 offset = (ONE_TRACK*512);
30 #elif defined(CONFIG_IDE_OFFSET)
31 offset = CONFIG_IDE_OFFSET;
35 res = ide_probe(CONFIG_IDE_BOOT_DRIVE);
40 void stream_fini(void)
45 static unsigned char buffer[512];
46 static unsigned int block_num = 0;
47 static unsigned int first_fill = 1;
49 static byte_offset_t stream_ide_read(void *vdest, byte_offset_t offs, byte_offset_t count)
51 byte_offset_t bytes = 0;
52 unsigned char *dest = vdest;
54 //printk_debug("stream_ide_read count = %x\n", count);
55 while (bytes < count) {
56 unsigned int byte_offset, len;
58 /* The block is not cached in memory or frist time called */
59 if (block_num != offs / 512 || first_fill) {
60 block_num = offs / 512;
62 ide_read(CONFIG_IDE_BOOT_DRIVE, block_num, buffer);
66 byte_offset = offs % 512;
67 len = 512 - byte_offset;
68 if (len > (count - bytes)) {
69 len = (count - bytes);
72 memcpy(dest, buffer + byte_offset, len);
82 byte_offset_t stream_read(void *vdest, byte_offset_t count)
86 len = stream_ide_read(vdest, offset, count);
94 byte_offset_t stream_skip(byte_offset_t count)