#include <stdio.h>
#include <libarch/ddi.h>
#include <ddi.h>
#include <ipc/bd.h>
#include <async.h>
#include <as.h>
#include <fibril_synch.h>
#include <stdint.h>
#include <str.h>
#include <devmap.h>
#include <sys/types.h>
#include <inttypes.h>
#include <errno.h>
#include <bool.h>
#include <byteorder.h>
#include <task.h>
#include <macros.h>
#include "ata_hw.h"
#include "ata_bd.h"
Go to the source code of this file.
Defines | |
#define | LEGACY_CTLS 4 |
Number of defined legacy controller base addresses. | |
#define | NAME "ata_bd" |
#define | NAMESPACE "bd" |
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 int | identify_pkt_dev (int dev_idx, void *buf) |
Issue Identify Packet Device command. | |
int | main (int argc, char **argv) |
static void | print_syntax (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 ata_cmd_t * | cmd |
static uintptr_t | cmd_physical |
I/O base address of the command registers. | |
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 disk_t | disk [MAX_DISKS] |
Per-disk state. | |
static const size_t | identify_data_size = 512 |
Size of data returned from Identify Device or Identify Packet Device command. | |
static ata_base_t | legacy_base [LEGACY_CTLS] |
I/O base addresses for legacy (ISA-compatible) controllers. |
This driver supports CHS, 28-bit and 48-bit LBA addressing. It only uses PIO transfers. There is no support DMA, the PACKET feature set or any other fancy features such as S.M.A.R.T, removable devices, etc.
This driver is based on the ATA-1, ATA-2, ATA-3 and ATA/ATAPI-4 through 7 standards, as published by the ANSI, NCITS and INCITS standards bodies, which are freely available. This driver contains no vendor-specific code at this moment.
The driver services a single controller which can have up to two disks attached.
Definition in file ata_bd.c.