aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers/ide.c
diff options
context:
space:
mode:
authorMarvin Borner2020-09-20 17:11:29 +0200
committerMarvin Borner2020-09-20 17:11:29 +0200
commitb6c8b7df4344d45ced50bea24cbb4de3ef229330 (patch)
tree0999810b9e3ff17cc4715cfd171464f761a9a55f /kernel/drivers/ide.c
parent667ce77a5de7183654cb6f8752c6d120b1b3ae19 (diff)
Started rtl8139 driver
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;
}