17#define AHCI_PORT_DET_PRESENT 3
18#define AHCI_PORT_IPM_ACTIVE 1
19#define AHCI_PORT_CMD_ST (1 << 0)
20#define AHCI_PORT_CMD_FRE (1 << 4)
21#define AHCI_PORT_CMD_FR (1 << 14)
22#define AHCI_PORT_CMD_CR (1 << 15)
23#define READ_DMA_EXT 0x25
24#define SECTOR_SIZE 512
26#define ATA_CMD_WRITE_DMA_EXT 0x35
27#define ATA_CMD_IDENTIFY 0xEC
29#define MAX_PARTITIONS 128
30#define MAX_BLOCK_DEVICES 64
32#define AHCI_MAX_PRDT 16
33#define PRDT_MAX_BYTES (4 * 1024 * 1024)
39#define sata_disk 0x00000101
40#define satapi_disk 0xEB140101
41#define semb_disk 0xC33C0101
42#define port_multiplier 0x96690101
59#define AHCI_CMD_HDR_CFL_MASK 0x001F
60#define AHCI_CMD_HDR_A_BIT 0x0020
61#define AHCI_CMD_HDR_W_BIT 0x0040
62#define AHCI_CMD_HDR_P_BIT 0x0080
63#define AHCI_CMD_HDR_R_BIT 0x0100
64#define AHCI_CMD_HDR_B_BIT 0x0200
65#define AHCI_CMD_HDR_C_BIT 0x0400
66#define AHCI_CMD_HDR_PMP_MASK 0xF000
86 prdt_entry_t prdt[AHCI_MAX_PRDT];
90 ahci_cmd_header_t* cmd_list;
91 ahci_cmd_table_t* cmd_tables[32];
101 typedef volatile struct {
123typedef volatile struct {
135 uint8_t rsv[0xA0 - 0x2C];
136 uint8_t vendor[0x100 - 0xA0];
142 uint64_t total_sectors;
148 BLOCK_DEVICE_AHCI = 0,
150} block_device_type_t;
153 block_device_type_t type;
156 uint32_t sector_size;
157 uint64_t total_sectors;
193} partition_table_type_t;
196 partition_table_type_t table_type;
213 uint8_t gpt_type_guid[16];
231extern mount_entry_t mounted_partitions[MAX_PARTITIONS];
233extern int general_partition_count;
234extern int mounted_partition_count;
235extern int block_device_count;
248void handle_sata_disk(
int portno);
249void handle_satapi_disk(
int portno);
250void ahci_init_port(
int portno);
251int ahci_read_sector(
int portno, uint64_t lba,
void* buffer, uint32_t count);
252int ahci_write_sector(
int portno, uint64_t lba,
void* buffer, uint32_t count);
253int ahci_identify(
int portno,
void* buffer);
255int block_register_device(
256 block_device_type_t type,
258 uint64_t total_sectors,
259 uint32_t sector_size,
263const char* block_get_device_name(
int device_id);
264int block_read_sector(
int device_id, uint64_t lba,
void* buffer, uint32_t count);
265int block_write_sector(
int device_id, uint64_t lba,
void* buffer, uint32_t count);
268 partition_table_type_t table_type,
277 const uint8_t* gpt_guid
282mount_entry_t* add_mount(
const char* mount_point,
const char* part_name,
partition_fs_type_t type,
void* fs_ptr);
283mount_entry_t* find_mount_by_point(
const char* mount_point);
struct acpi_gas __attribute__
Physical Region Descriptor Table (PRDT) entry.
partition_fs_type_t
GENERAL PARITION LAYOUT BEGIN.
void detect_ahci_devices(ahci_hba_mem_t *ahci_ctrl)
Probes and detects all AHCI devices connected to the controller.
ahci_hba_mem_t * global_ahci_ctrl
Global AHCI controller pointer.
This is a basic header files with FrostWing specific short forms and basically a good for life header...
Contains all the print functions.
AHCI port registers and command header pointer.