aboutsummaryrefslogtreecommitdiff
path: root/src/inc/ide.h
diff options
context:
space:
mode:
authorMarvin Borner2020-07-23 21:06:44 +0200
committerMarvin Borner2020-07-23 21:06:44 +0200
commit6becbff5724d79cb3a958db297b5c3310200daea (patch)
tree295a5b4bf7ee2234fdc56c24fec28f936927de21 /src/inc/ide.h
parenta0b8c61b09200aa3f9e27878cb866648a7d26502 (diff)
Added *very* simple ide and ext2 support
Diffstat (limited to 'src/inc/ide.h')
-rw-r--r--src/inc/ide.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/inc/ide.h b/src/inc/ide.h
new file mode 100644
index 0000000..9d753ae
--- /dev/null
+++ b/src/inc/ide.h
@@ -0,0 +1,40 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#ifndef IDE_H
+#define IDE_H
+
+#include <def.h>
+
+#define BLOCK_SIZE 1024
+#define SECTOR_SIZE 512
+
+#define IDE_BUSY (1 << 7)
+#define IDE_READY (1 << 6)
+#define IDE_DRIVE_FAULT (1 << 5)
+#define IDE_ERROR (1 << 0)
+
+#define IDE_IO 0x1F0
+#define IDE_DATA 0x0
+#define IDE_FEATURES 0x1
+#define IDE_SECTOR_COUNT 0x2
+#define IDE_LOW 0x3
+#define IDE_MID 0x4
+#define IDE_HIGH 0x5
+#define IDE_HEAD 0x6
+#define IDE_CMD 0x7
+#define IDE_ALTERNATE 0x3F6
+
+#define LBA_LOW(c) ((u8)(c & 0xFF))
+#define LBA_MID(c) ((u8)(c >> 8) & 0xFF)
+#define LBA_HIGH(c) ((u8)(c >> 16) & 0xFF)
+#define LBA_LAST(c) ((u8)(c >> 24) & 0xF)
+
+#define IDE_CMD_READ (BLOCK_SIZE / SECTOR_SIZE == 1) ? 0x20 : 0xC4
+#define IDE_CMD_WRITE (BLOCK_SIZE / SECTOR_SIZE == 1) ? 0x30 : 0xC5
+#define IDE_CMD_READ_MUL 0xC4
+#define IDE_CMD_WRITE_MUL 0xC5
+
+int ide_wait(int check);
+void *ide_read(void *b, u32 block);
+
+#endif