The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
ata.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
block_device.h
"
4
5
/**
6
* ATA channel selection.
7
* each channel has its own I/O base and control port.
8
*/
9
typedef
enum
10
{
11
ATA_CHANNEL_PRIMARY
= 0,
// primary channel: I/O base 0x1F0, control 0x3F6
12
ATA_CHANNEL_SECONDARY
= 1,
// secondary channel: I/O base 0x170, control 0x376
13
}
ata_channel_t
;
14
15
/**
16
* ATA drive selection within a channel.
17
*/
18
typedef
enum
19
{
20
ATA_DRIVE_MASTER
= 0,
// drive select byte 0xE0 (LBA mode, master)
21
ATA_DRIVE_SLAVE
= 1,
// drive select byte 0xF0 (LBA mode, slave)
22
}
ata_drive_t
;
23
24
/**
25
* ATA device structure.
26
* carries per-device I/O port state so multiple devices on different
27
* channels or drive positions can coexist without hardcoded port macros.
28
*/
29
typedef
struct
30
{
31
block_device_t
block
;
// block device interface, must be first for safe casting.
32
uint16_t
io_base
;
// I/O base port (0x1F0 primary, 0x170 secondary).
33
uint16_t
control_base
;
// control/alt-status port (0x3F6 primary, 0x376 secondary).
34
uint8_t
drive_select
;
// drive-select byte written to the drive/head register.
35
uint64_t
sector_count
;
// total addressable sectors reported by IDENTIFY DEVICE.
36
}
ata_device_t
;
37
38
/**
39
* initialize an ATA device on the specified channel and drive position.
40
* issues IDENTIFY DEVICE to confirm the drive is present and is not ATAPI.
41
* populates all port fields and wires up the block device interface.
42
*
43
* @param device ATA device object to initialize.
44
* @param channel ATA_CHANNEL_PRIMARY or ATA_CHANNEL_SECONDARY.
45
* @param drive ATA_DRIVE_MASTER or ATA_DRIVE_SLAVE.
46
* @return true on success, false if no drive responds or device is ATAPI.
47
*/
48
bool
ata_initialize
(
ata_device_t
*
device
,
ata_channel_t
channel,
ata_drive_t
drive);
ata_initialize
bool ata_initialize(ata_device_t *device, ata_channel_t channel, ata_drive_t drive)
initialize an ATA device on the specified channel and drive position.
Definition
ata.c:402
ata_drive_t
ata_drive_t
ATA drive selection within a channel.
Definition
ata.h:19
ATA_DRIVE_SLAVE
@ ATA_DRIVE_SLAVE
Definition
ata.h:21
ATA_DRIVE_MASTER
@ ATA_DRIVE_MASTER
Definition
ata.h:20
ata_channel_t
ata_channel_t
ATA channel selection.
Definition
ata.h:10
ATA_CHANNEL_SECONDARY
@ ATA_CHANNEL_SECONDARY
Definition
ata.h:12
ATA_CHANNEL_PRIMARY
@ ATA_CHANNEL_PRIMARY
Definition
ata.h:11
block_device.h
block_device_t
struct block_device block_device_t
Definition
block_device.h:5
uint8_t
unsigned char uint8_t
Definition
fb.h:18
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
uint16_t
unsigned short uint16_t
Definition
stdint.h:13
ata_device_t
ATA device structure.
Definition
ata.h:30
ata_device_t::control_base
uint16_t control_base
Definition
ata.h:33
ata_device_t::sector_count
uint64_t sector_count
Definition
ata.h:35
ata_device_t::block
block_device_t block
Definition
ata.h:31
ata_device_t::drive_select
uint8_t drive_select
Definition
ata.h:34
ata_device_t::io_base
uint16_t io_base
Definition
ata.h:32
device
a registered device.
Definition
device.h:114
src
drivers
disk
ata.h
Generated by
1.18.0