aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers/ide.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/ide.c')
-rw-r--r--kernel/drivers/ide.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/drivers/ide.c b/kernel/drivers/ide.c
index d637a2b..eda18e9 100644
--- a/kernel/drivers/ide.c
+++ b/kernel/drivers/ide.c
@@ -3,6 +3,7 @@
#include <cpu.h>
#include <def.h>
#include <ide.h>
+#include <print.h>
int ide_wait(int check)
{
@@ -18,24 +19,37 @@ int ide_wait(int check)
return 0;
}
-void __attribute__((optimize("O0"))) * ide_read(void *b, u32 block)
+// TODO: Fix strange print workaround
+void *ide_read(void *b, u32 block)
{
int sector_per_block = BLOCK_SIZE / SECTOR_SIZE; // 2
int sector = block * sector_per_block;
+ print("");
ide_wait(0);
+ print("");
outb(IDE_IO | IDE_SECTOR_COUNT, sector_per_block); // Number of sectors
+ print("");
outb(IDE_IO | IDE_LOW, LBA_LOW(sector));
+ print("");
outb(IDE_IO | IDE_MID, LBA_MID(sector));
+ print("");
outb(IDE_IO | IDE_HIGH, LBA_HIGH(sector));
+ print("");
// Slave/Master << 4 and last 4 bits
+ print("");
outb(IDE_IO | IDE_HEAD, 0xE0 | (1 << 4) | LBA_LAST(sector));
+ print("");
outb(IDE_IO | IDE_CMD, IDE_CMD_READ);
+ print("");
ide_wait(0);
+ print("");
// Read-only
+ print("");
insl(IDE_IO, b, BLOCK_SIZE / 4);
+ print("");
return b;
}