aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs/ata_pio.c
diff options
context:
space:
mode:
authorMarvin Borner2020-01-20 23:12:54 +0100
committerMarvin Borner2020-01-20 23:12:54 +0100
commit391ed256d21a6ae2e2456d1809f357e6e96e15d1 (patch)
tree0fe9ffb3c59bbfeb3d8a04ab7fc6efba60d81e79 /src/kernel/fs/ata_pio.c
parentd5d1749257ff8b9aa6b5ace4b4720b484a2860f3 (diff)
Added pure awesomeness
Actually quite some days of work but ok
Diffstat (limited to 'src/kernel/fs/ata_pio.c')
-rw-r--r--src/kernel/fs/ata_pio.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/kernel/fs/ata_pio.c b/src/kernel/fs/ata_pio.c
index 0134ee4..fef3a32 100644
--- a/src/kernel/fs/ata_pio.c
+++ b/src/kernel/fs/ata_pio.c
@@ -1,35 +1,35 @@
#include <kernel/io/io.h>
-#include <kernel/lib/stdlib.h>
#include <kernel/fs/ata_pio.h>
+#include <kernel/memory/kheap.h>
struct ata_interface *new_ata(uint8_t master, uint16_t port_base)
{
- struct ata_interface *ret = kmalloc(sizeof(struct ata_interface));
+ struct ata_interface *ret = (struct ata_interface *) kmalloc(sizeof(struct ata_interface));
ret->master = master;
ret->data_port = port_base;
- ret->error_port = port_base + 0x1;
- ret->sector_count_port = port_base + 0x2;
- ret->lba_low_port = port_base + 0x3;
- ret->lba_mid_port = port_base + 0x4;
- ret->lba_high_port = port_base + 0x5;
- ret->device_port = port_base + 0x6;
- ret->command_port = port_base + 0x7;
- ret->control_port = port_base + 0x206;
+ ret->error_port = (uint16_t) (port_base + 0x1);
+ ret->sector_count_port = (uint16_t) (port_base + 0x2);
+ ret->lba_low_port = (uint16_t) (port_base + 0x3);
+ ret->lba_mid_port = (uint16_t) (port_base + 0x4);
+ ret->lba_high_port = (uint16_t) (port_base + 0x5);
+ ret->device_port = (uint16_t) (port_base + 0x6);
+ ret->command_port = (uint16_t) (port_base + 0x7);
+ ret->control_port = (uint16_t) (port_base + 0x206);
return ret;
}
uint8_t ata_identify(struct ata_interface *interface, uint16_t *ret_data)
{
- outb(interface->device_port, interface->master ? 0xA0 : 0xB0);
+ outb(interface->device_port, (uint8_t) (interface->master ? 0xA0 : 0xB0));
outb(interface->control_port, 0);
outb(interface->device_port, 0xA0);
uint8_t status = inb(interface->command_port);
if (status == 0xFF) return 1;
- outb(interface->device_port, interface->master ? 0xA0 : 0xB0);
+ outb(interface->device_port, (uint8_t) (interface->master ? 0xA0 : 0xB0));
outb(interface->sector_count_port, 0);
outb(interface->lba_low_port, 0);
outb(interface->lba_mid_port, 0);
@@ -53,7 +53,7 @@ uint8_t *ata_read28(struct ata_interface *interface, uint32_t sector)
{
if (sector > 0x0FFFFFFF) return 0;
- outb(interface->device_port, (interface->master ? 0xE0 : 0xF0) | ((sector & 0x0F000000) >> 24));
+ outb(interface->device_port, (uint8_t) ((interface->master ? 0xE0 : 0xF0) | ((sector & 0x0F000000) >> 24)));
uint8_t status = 0;
for (int i = 0; i < 5; i++) status = inb(interface->command_port);
@@ -61,19 +61,19 @@ uint8_t *ata_read28(struct ata_interface *interface, uint32_t sector)
outb(interface->error_port, 0);
outb(interface->sector_count_port, 1);
- outb(interface->lba_low_port, sector & 0x000000FF);
- outb(interface->lba_mid_port, (sector & 0x0000FF00) >> 8);
- outb(interface->lba_high_port, (sector & 0x00FF0000) >> 16);
+ outb(interface->lba_low_port, (uint8_t) (sector & 0x000000FF));
+ outb(interface->lba_mid_port, (uint8_t) ((sector & 0x0000FF00) >> 8));
+ outb(interface->lba_high_port, (uint8_t) ((sector & 0x00FF0000) >> 16));
outb(interface->command_port, 0x20); // Read command
status = inb(interface->command_port);
while ((status & 0x80) && !(status & 0x01)) status = inb(interface->command_port);
- uint8_t *ret = kmalloc(BYTES_PER_SECTOR);
+ uint8_t *ret = (uint8_t *) kmalloc(BYTES_PER_SECTOR);
for (int i = 0; i < BYTES_PER_SECTOR; i += 2) {
uint16_t data = inw(interface->data_port);
- ret[i] = data & 0xFF;
- ret[i + 1] = (data >> 8) & 0xFF;
+ ret[i] = (uint8_t) (data & 0xFF);
+ ret[i + 1] = (uint8_t) ((data >> 8) & 0xFF);
}
return ret;
}
@@ -83,7 +83,7 @@ uint8_t ata_write28(struct ata_interface *interface, uint32_t sector, const uint
if (sector > 0x0FFFFFFF) return 1;
asm ("cli");
- outb(interface->device_port, (interface->master ? 0xE0 : 0xF0) | ((sector & 0x0F000000) >> 24));
+ outb(interface->device_port, (uint8_t) ((interface->master ? 0xE0 : 0xF0) | ((sector & 0x0F000000) >> 24)));
uint8_t status = 0;
for (int i = 0; i < 5; i++) status = inb(interface->command_port);
@@ -91,9 +91,9 @@ uint8_t ata_write28(struct ata_interface *interface, uint32_t sector, const uint
outb(interface->error_port, 0);
outb(interface->sector_count_port, 1);
- outb(interface->lba_low_port, sector & 0x000000FF);
- outb(interface->lba_mid_port, (sector & 0x0000FF00) >> 8);
- outb(interface->lba_high_port, (sector & 0x00FF0000) >> 16);
+ outb(interface->lba_low_port, (uint8_t) (sector & 0x000000FF));
+ outb(interface->lba_mid_port, (uint8_t) ((sector & 0x0000FF00) >> 8));
+ outb(interface->lba_high_port, (uint8_t) ((sector & 0x00FF0000) >> 16));
outb(interface->command_port, 0x30); // Write command
while ((status & 0x80) || !(status & 0x08)) status = inb(interface->command_port);