1 #include <console/console.h>
4 #include <stream/read_bytes.h>
10 #define IDE_BOOT_DRIVE 0
13 static unsigned long offset;
18 printk_debug ("Trying polled ide\n");
19 printk_debug ("Waiting for ide disks to spin up\n");
20 printk_notice ("This is a hard coded delay and longer than necessary.\n");
21 for (i = 0; i < 2; i++) {
28 offset = (ONE_TRACK*512);
29 #elif defined(IDE_OFFSET)
34 res = ide_probe(IDE_BOOT_DRIVE);
39 void stream_fini(void)
44 static unsigned char buffer[512];
45 static unsigned int block_num = 0;
46 static unsigned int first_fill = 1;
47 static byte_offset_t stream_ide_read(void *vdest, byte_offset_t offset, byte_offset_t count)
49 byte_offset_t bytes = 0;
50 unsigned char *dest = vdest;
52 //printk_debug("stream_ide_read count = %x\n", count);
53 while (bytes < count) {
54 unsigned int byte_offset, len;
56 /* The block is not cached in memory or frist time called */
57 if (block_num != offset / 512 || first_fill) {
58 block_num = offset / 512;
60 ide_read(IDE_BOOT_DRIVE, block_num, buffer);
64 byte_offset = offset % 512;
65 len = 512 - byte_offset;
66 if (len > (count - bytes)) {
67 len = (count - bytes);
70 memcpy(dest, buffer + byte_offset, len);
80 byte_offset_t stream_read(void *vdest, byte_offset_t count)
84 len = stream_ide_read(vdest, offset, count);
92 byte_offset_t stream_skip(byte_offset_t count)