blob: c509f528a033c59d161cd0a2bc2cc6529c53f9b7 [file] [log] [blame]
swissChili1a3f07f2021-04-05 20:01:55 -07001#pragma once
2
3#include <kint.h>
4
5/**
6 * ATA PIO Driver for Bluejay. This should be replaced by a proper
7 * ATAPI driver later on, but for now this will do. It is going to
8 * be horribly slow by virtue of having to pass all data through
9 * in() and out().
10 */
11
12// status codes
13enum
14{
15 ATA_BSY = 0x80, // Busy
16 ATA_RDY = 0x40, // Ready for command
17 ATA_DRQ = 0x08, // Ready for data
18 ATA_DF = 0x20,
19 ATA_ERR = 0x01, // Error code placed in error register
20};
21
22// IO ports
23enum
24{
25 ATA_PORT_CMD = 0x1f7,
26 ATA_PORT_DATA = 0x1f0,
27 ATA_PORT_DRIVE_SEL = 0x1f6,
28 ATA_PORT_SECTOR_COUNT = 0x1f2,
29 ATA_PORT_LBA_LOW,
30 ATA_PORT_LBA_MID,
31 ATA_PORT_LBA_HIGH,
32};
33
34// Commands
35enum
36{
37 ATA_CMD_READ = 0x20,
38 ATA_CMD_WRITE = 0x30,
39};
40
41void ata_pio_wait_bsy();
42void ata_pio_wait_drq();
swissChili83db6fd2021-04-05 21:32:49 -070043void ata_pio_read_sectors(void *buffer, uint lba, uchar num_sectors);
44void ata_pio_write_sectors(uint lba, uchar num_sectors, void *buffer);
45uint ata_pio_get_error();
swissChili1a3f07f2021-04-05 20:01:55 -070046
47void test_ata_pio();