Files | |
file | ata_bd.c |
ATA disk driver. | |
file | file_bd.c |
File-backed block device driver. | |
file | gpt.h |
file | guid_part.c |
GUID partition table driver. | |
file | gxe_bd.c |
GXemul disk driver. | |
file | mbr_part.c |
PC MBR partition driver. | |
Data Structures | |
struct | ata_base_t |
Base addresses for ATA I/O blocks. More... | |
union | ata_cmd_t |
ATA Command Register Block. More... | |
union | ata_ctl_t |
struct | ata_inquiry_data_t |
Data returned from Inquiry command (mandatory part). More... | |
struct | ata_pcmd_inquiry_t |
ATAPI Inquiry command. More... | |
struct | ata_pcmd_read_12_t |
ATAPI Read(12) command. More... | |
struct | block_coord_t |
Block coordinates. More... | |
struct | br_block_t |
Structure of a boot-record block. More... | |
struct | disk_t |
ATA device state structure. More... | |
struct | gpt_entry_t |
GPT partition entry. More... | |
struct | gpt_header_t |
GPT header. More... | |
struct | gxe_bd_t |
struct | identify_data_t |
Data returned from identify device and identify packet device command. More... | |
struct | part |
Partition. More... | |
struct | part |
Partition. More... | |
struct | pt_entry_t |
Structure of a partition table entry. More... | |
Defines | |
#define | DEFAULT_BLOCK_SIZE 512 |
#define | GPT_HDR_BA 1 |
Block address of GPT header. | |
#define | INQUIRY_PDEV_TYPE(val) ((val) & 0x1f) |
Extract value of ata_inquiry_data_t.pdev_type. | |
#define | LEGACY_CTLS 4 |
Number of defined legacy controller base addresses. | |
#define | NAME "mbr_part" |
#define | NAME "guid_part" |
#define | NAME "gxe_bd" |
#define | NAME "file_bd" |
#define | NAME "ata_bd" |
#define | NAMESPACE "bd" |
#define | NAMESPACE "bd" |
Typedefs | |
typedef part | part_t |
Partition. | |
typedef part | part_t |
Partition. | |
Enumerations | |
enum | |
enum | |
enum | |
enum | |
enum | |
enum | |
enum | { N_PRIMARY = 4, BR_SIGNATURE = 0xAA55 } |
enum | ata_command |
enum | ata_cs1 { cs1_addr48 = 0x0400 } |
Bits of identify_data_t.cmd_set1 . More... | |
enum | ata_dev_type |
enum | ata_pdev_signature { PDEV_SIGNATURE_BC = 0xEB14 } |
enum | ata_pdev_type |
Values for ata_inquiry_data_t.pdev_type. | |
enum | ata_pkt_command |
ATA packet command codes. | |
enum | ata_pktdev_caps |
Capability bits for packet device. | |
enum | ata_regdev_caps |
Capability bits for register device. | |
enum | ata_timeout |
Timeout definitions. More... | |
enum | devctl_bits { DCR_SRST = 0x04, DCR_nIEN = 0x02 } |
enum | drive_head_bits { DHR_LBA = 0x40, DHR_DRV = 0x10 } |
enum | error_bits { ER_BBK = 0x80, ER_UNC = 0x40, ER_MC = 0x20, ER_IDNF = 0x10, ER_MCR = 0x08, ER_ABRT = 0x04, ER_TK0NF = 0x02, ER_AMNF = 0x01 } |
enum | ptype { PT_UNUSED = 0x00, PT_EXTENDED = 0x05 } |
enum | rd_addr_mode { am_chs, am_lba28, am_lba48 } |
Register device block addressing mode. More... | |
enum | status_bits { SR_BSY = 0x80, SR_DRDY = 0x40, SR_DWF = 0x20, SR_DSC = 0x10, SR_DRQ = 0x08, SR_CORR = 0x04, SR_IDX = 0x02, SR_ERR = 0x01 } |
Functions | |
static void | ata_bd_connection (ipc_callid_t iid, ipc_call_t *icall) |
Block device connection handler. | |
static int | ata_bd_init (void) |
Register driver and enable device I/O. | |
static int | ata_bd_read_blocks (int disk_id, uint64_t ba, size_t cnt, void *buf) |
Read multiple blocks from the device. | |
static int | ata_bd_write_blocks (int disk_id, uint64_t ba, size_t cnt, const void *buf) |
Write multiple blocks to the device. | |
static int | ata_cmd_packet (int dev_idx, const void *cpkt, size_t cpkt_size, void *obuf, size_t obuf_size) |
Issue packet command (i. | |
static int | ata_pcmd_inquiry (int dev_idx, void *obuf, size_t obuf_size) |
Issue ATAPI Inquiry. | |
static int | ata_pcmd_read_12 (int dev_idx, uint64_t ba, size_t cnt, void *obuf, size_t obuf_size) |
Issue ATAPI read(12) command. | |
static int | ata_rcmd_read (int disk_id, uint64_t ba, size_t blk_cnt, void *buf) |
Read a physical from the device. | |
static int | ata_rcmd_write (int disk_id, uint64_t ba, size_t cnt, const void *buf) |
Write a physical block to the device. | |
static int | coord_calc (disk_t *d, uint64_t ba, block_coord_t *bc) |
Calculate block coordinates. | |
static void | coord_sc_program (const block_coord_t *bc, uint16_t scnt) |
Program block coordinates and sector count into ATA registers. | |
static int | disk_init (disk_t *d, int disk_id) |
Initialize a disk. | |
static void | disk_print_summary (disk_t *d) |
Print one-line device summary. | |
static int | drive_identify (int disk_id, void *buf) |
Issue IDENTIFY command. | |
static void | file_bd_connection (ipc_callid_t iid, ipc_call_t *icall) |
static int | file_bd_init (const char *fname) |
static int | file_bd_read_blocks (uint64_t ba, size_t cnt, void *buf) |
Read blocks from the device. | |
static int | file_bd_write_blocks (uint64_t ba, size_t cnt, const void *buf) |
Write blocks to the device. | |
static int | gpt_bd_read (part_t *p, aoff64_t ba, size_t cnt, void *buf) |
Read blocks from partition. | |
static int | gpt_bd_write (part_t *p, aoff64_t ba, size_t cnt, const void *buf) |
Write blocks to partition. | |
static int | gpt_bsa_translate (part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba) |
Translate block segment address with range checking. | |
static void | gpt_connection (ipc_callid_t iid, ipc_call_t *icall) |
static int | gpt_init (const char *dev_name) |
static part_t * | gpt_part_new (void) |
Allocate a new part_t structure. | |
static void | gpt_pte_to_part (const gpt_entry_t *pte, part_t *part) |
Parse partition table entry. | |
static int | gpt_read (void) |
Read in partition records. | |
static void | gxe_bd_connection (ipc_callid_t iid, ipc_call_t *icall) |
static int | gxe_bd_init (void) |
static int | gxe_bd_read_block (int disk_id, uint64_t ba, void *buf) |
Read a block from the device. | |
static int | gxe_bd_read_blocks (int disk_id, uint64_t ba, unsigned cnt, void *buf) |
Read multiple blocks from the device. | |
static int | gxe_bd_write_block (int disk_id, uint64_t ba, const void *buf) |
Write a block to the device. | |
static int | gxe_bd_write_blocks (int disk_id, uint64_t ba, unsigned cnt, const void *buf) |
Write multiple blocks to the device. | |
static int | identify_pkt_dev (int dev_idx, void *buf) |
Issue Identify Packet Device command. | |
int | main (int argc, char **argv) |
static int | mbr_bd_read (part_t *p, uint64_t ba, size_t cnt, void *buf) |
Read blocks from partition. | |
static int | mbr_bd_write (part_t *p, uint64_t ba, size_t cnt, const void *buf) |
Write blocks to partition. | |
static int | mbr_bsa_translate (part_t *p, uint64_t ba, size_t cnt, uint64_t *gba) |
Translate block segment address with range checking. | |
static void | mbr_connection (ipc_callid_t iid, ipc_call_t *icall) |
static int | mbr_init (const char *dev_name) |
static part_t * | mbr_part_new (void) |
Allocate a new part_t structure. | |
static int | mbr_part_read (void) |
Read in partition records. | |
static void | mbr_pte_to_part (uint32_t base, const pt_entry_t *pte, part_t *part) |
Parse partition table entry. | |
static void | print_syntax (void) |
static void | print_usage (void) |
static int | wait_status (unsigned set, unsigned n_reset, uint8_t *pstatus, unsigned timeout) |
Wait until some status bits are set and some are reset. | |
Variables | |
static size_t | block_size |
static size_t | block_size |
static const size_t | block_size = 512 |
static size_t | block_size |
static ata_cmd_t * | cmd |
static uintptr_t | cmd_physical |
I/O base address of the command registers. | |
static size_t | comm_size |
static size_t | comm_size |
Size of the communication area. | |
static ata_ctl_t * | ctl |
static uintptr_t | ctl_physical |
I/O base address of the control registers. | |
static gxe_bd_t * | dev |
static fibril_mutex_t | dev_lock [MAX_DISKS] |
static fibril_mutex_t | dev_lock |
static uintptr_t | dev_physical = 0x13000000 |
static devmap_handle_t | devmap_handle [MAX_DISKS] |
static devmap_handle_t | devmap_handle |
static disk_t | disk [MAX_DISKS] |
Per-disk state. | |
const uint8_t | efi_signature [8] |
static const size_t | identify_data_size = 512 |
Size of data returned from Identify Device or Identify Packet Device command. | |
static FILE * | img |
static devmap_handle_t | indev_handle |
Partitioned device (inbound device). | |
static devmap_handle_t | indev_handle |
Partitioned device (inbound device). | |
static ata_base_t | legacy_base [LEGACY_CTLS] |
I/O base addresses for legacy (ISA-compatible) controllers. | |
static aoff64_t | num_blocks |
static part_t | plist_head |
List of partitions. | |
static part_t | plist_head |
List of partitions. |
anonymous enum |
Definition at line 78 of file mbr_part.c.
enum ata_cs1 |
Bits of identify_data_t.cmd_set1
.
enum ata_pdev_signature |
enum ata_timeout |
enum devctl_bits |
enum drive_head_bits |
enum error_bits |
enum ptype |
Definition at line 86 of file mbr_part.c.
enum rd_addr_mode |
enum status_bits |
static int ata_cmd_packet | ( | int | dev_idx, | |
const void * | cpkt, | |||
size_t | cpkt_size, | |||
void * | obuf, | |||
size_t | obuf_size | |||
) | [static] |
Issue packet command (i.
e. write a command packet to the device).
Only data-in commands are supported (e.g. inquiry, read).
dev_idx | Device index (0 or 1) | |
obuf | Buffer for storing data read from device | |
obuf_size | Size of obuf in bytes |
static int ata_pcmd_inquiry | ( | int | dev_idx, | |
void * | obuf, | |||
size_t | obuf_size | |||
) | [static] |
static int ata_pcmd_read_12 | ( | int | dev_idx, | |
uint64_t | ba, | |||
size_t | cnt, | |||
void * | obuf, | |||
size_t | obuf_size | |||
) | [static] |
Issue ATAPI read(12) command.
Output buffer must be large enough to hold the data, otherwise the function will fail.
dev_idx | Device index (0 or 1) | |
ba | Starting block address | |
cnt | Number of blocks to read | |
obuf | Buffer for storing inquiry data read from device | |
obuf_size | Size of obuf in bytes |
static int ata_rcmd_read | ( | int | disk_id, | |
uint64_t | ba, | |||
size_t | blk_cnt, | |||
void * | buf | |||
) | [static] |
static int ata_rcmd_write | ( | int | disk_id, | |
uint64_t | ba, | |||
size_t | cnt, | |||
const void * | buf | |||
) | [static] |
static int coord_calc | ( | disk_t * | d, | |
uint64_t | ba, | |||
block_coord_t * | bc | |||
) | [static] |
Calculate block coordinates.
Calculates block coordinates in the best coordinate system supported by the device. These can be later programmed into the device using coord_sc_program()
.
static void coord_sc_program | ( | const block_coord_t * | bc, | |
uint16_t | scnt | |||
) | [static] |
static int disk_init | ( | disk_t * | d, | |
int | disk_id | |||
) | [static] |
static int drive_identify | ( | int | disk_id, | |
void * | buf | |||
) | [static] |
Issue IDENTIFY command.
Reads identify
data into the provided buffer. This is used to detect whether an ATA device is present and if so, to determine its parameters.
disk_id | Device ID, 0 or 1. | |
buf | Pointer to a 512-byte buffer. |
static int identify_pkt_dev | ( | int | dev_idx, | |
void * | buf | |||
) | [static] |
static int wait_status | ( | unsigned | set, | |
unsigned | n_reset, | |||
uint8_t * | pstatus, | |||
unsigned | timeout | |||
) | [static] |
Wait until some status bits are set and some are reset.
Example: wait_status(SR_DRDY, ~SR_BSY) waits for SR_DRDY to become set and SR_BSY to become reset.
set | Combination if bits which must be all set. | |
n_reset | Negated combination of bits which must be all reset. | |
pstatus | Pointer where to store last read status or NULL. | |
timeout | Timeout in 10ms units. |
part_t plist_head [static] |
part_t plist_head [static] |