1/* 2 * Copyright (c) 2011 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef _AHCI_H 11#define _AHCI_H 12 13#include <barrelfish/waitset.h> 14#include <barrelfish/idc.h> 15#include <barrelfish/event_mutex.h> 16#include <flounder/flounder.h> 17#include <ahci/ahci_util.h> 18#include <ahci/ahci_dma_pool.h> 19#include <dev/ata_identify_dev.h> 20 21struct ahci_binding; 22 23typedef void ahci_bind_continuation_fn(void *st, errval_t err, 24 struct ahci_binding *_binding); 25typedef bool ahci_can_send_fn(struct ahci_binding *_binding); 26typedef errval_t ahci_register_send_fn(struct ahci_binding *_binding, 27 struct waitset *ws, struct event_closure _continuation); 28typedef errval_t ahci_change_waitset_fn(struct ahci_binding *_binding, 29 struct waitset *ws); 30typedef errval_t ahci_control_fn(struct ahci_binding *_binding, 31 idc_control_t control); 32typedef void ahci_error_handler_fn(struct ahci_binding *_binding, errval_t err); 33 34/* 35 * Message type signatures (receive) 36 */ 37typedef void ahci_command_completed_method_fn(struct ahci_binding *_binding, 38 void *tag); 39 40/* 41 * Receive VTable 42 */ 43struct ahci_rx_vtbl { 44 ahci_command_completed_method_fn *command_completed; 45}; 46 47/* 48 * The binding structure 49 */ 50struct ahci_binding { 51 /* user state */ 52 void *st; 53 54 /* waitset for receive handlers and send continuations */ 55 struct waitset *waitset; 56 57 /* Mutex for the use of user code. */ 58 /* Must be held before any operation where there is a possibility of */ 59 /* concurrent access to the same binding (eg. multiple threads, or */ 60 /* asynchronous event handlers that use the same binding object). */ 61 struct event_mutex mutex; 62 63 /* returns true iff a message could currently be accepted by the binding */ 64 ahci_can_send_fn *can_send; 65 66 /* register an event for when a message is likely to be able to be sent */ 67 ahci_register_send_fn *register_send; 68 69 /* change the waitset used by a binding */ 70 ahci_change_waitset_fn *change_waitset; 71 72 /* perform control operations */ 73 ahci_control_fn *control; 74 75 /* error handler for async errors */ 76 ahci_error_handler_fn *error_handler; 77 78 /* Message receive functions (filled in by user) */ 79 struct ahci_rx_vtbl rx_vtbl; 80 81 /* Private state belonging to the binding implementation */ 82 uint8_t port_id; 83 struct ahci_port_info port_info; 84 struct waitset_chanstate register_chanstate; 85 struct waitset_chanstate tx_cont_chanstate; 86 87 uint8_t *identify_data; 88 size_t identify_length; 89 ata_identify_t identify; 90}; 91 92errval_t ahci_issue_command(struct ahci_binding *_binding, 93 struct event_closure _continuation, void *tag, uint8_t *fis, 94 size_t fis_length, bool is_write, struct ahci_dma_region *buf, 95 size_t buflen); 96 97errval_t ahci_close(struct ahci_binding *_binding, 98 struct event_closure _continuation); 99 100errval_t ahci_init(uint8_t port, ahci_bind_continuation_fn *_continuation, 101 void *st, struct waitset *waitset); 102 103#endif // _AHCI_H 104