[9904eb90] | 1 | /*
|
---|
| 2 | * Copyright (c) 2012 Petr Jerman
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @file
|
---|
| 30 | * Header for AHCI driver.
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | #ifndef __AHCI_H__
|
---|
| 34 | #define __AHCI_H__
|
---|
| 35 |
|
---|
[56fd7cf] | 36 | #include <async.h>
|
---|
[9904eb90] | 37 | #include <sys/types.h>
|
---|
| 38 | #include <devman.h>
|
---|
| 39 | #include <ddf/interrupt.h>
|
---|
| 40 | #include <stdio.h>
|
---|
| 41 | #include "ahci_hw.h"
|
---|
| 42 |
|
---|
| 43 | /** AHCI Device. */
|
---|
| 44 | typedef struct {
|
---|
| 45 | /** Pointer to ddf device. */
|
---|
| 46 | ddf_dev_t *dev;
|
---|
| 47 |
|
---|
| 48 | /** Pointer to AHCI memory registers. */
|
---|
[ae3ff9f5] | 49 | volatile ahci_memregs_t *memregs;
|
---|
[9904eb90] | 50 |
|
---|
| 51 | /** Pointers to sata devices. */
|
---|
[eb3683a] | 52 | void *sata_devs[AHCI_MAX_PORTS];
|
---|
[56fd7cf] | 53 |
|
---|
| 54 | /** Parent session */
|
---|
| 55 | async_sess_t *parent_sess;
|
---|
[9904eb90] | 56 | } ahci_dev_t;
|
---|
| 57 |
|
---|
| 58 | /** SATA Device. */
|
---|
| 59 | typedef struct {
|
---|
| 60 | /** Pointer to AHCI device. */
|
---|
| 61 | ahci_dev_t *ahci;
|
---|
| 62 |
|
---|
[56fd7cf] | 63 | /** Pointer to ddf function. */
|
---|
| 64 | ddf_fun_t *fun;
|
---|
| 65 |
|
---|
[eb3683a] | 66 | /** SATA port number (0-31). */
|
---|
[9904eb90] | 67 | uint8_t port_num;
|
---|
| 68 |
|
---|
| 69 | /** Device in invalid state (disconnected and so on). */
|
---|
[ae3ff9f5] | 70 | bool is_invalid_device;
|
---|
[9904eb90] | 71 |
|
---|
| 72 | /** Pointer to SATA port. */
|
---|
| 73 | volatile ahci_port_t *port;
|
---|
[ae3ff9f5] | 74 |
|
---|
[9904eb90] | 75 | /** Pointer to command header. */
|
---|
| 76 | volatile ahci_cmdhdr_t *cmd_header;
|
---|
[ae3ff9f5] | 77 |
|
---|
[9904eb90] | 78 | /** Pointer to command table. */
|
---|
| 79 | volatile uint32_t *cmd_table;
|
---|
| 80 |
|
---|
| 81 | /** Mutex for single operation on device. */
|
---|
| 82 | fibril_mutex_t lock;
|
---|
| 83 |
|
---|
| 84 | /** Mutex for event signaling condition variable. */
|
---|
| 85 | fibril_mutex_t event_lock;
|
---|
[eb3683a] | 86 |
|
---|
[9904eb90] | 87 | /** Event signaling condition variable. */
|
---|
| 88 | fibril_condvar_t event_condvar;
|
---|
| 89 |
|
---|
[eb3683a] | 90 | /** Event interrupt state. */
|
---|
| 91 | ahci_port_is_t event_pxis;
|
---|
| 92 |
|
---|
[9904eb90] | 93 | /** Block device service id. */
|
---|
[eb3683a] | 94 | service_id_t service_id;
|
---|
[9904eb90] | 95 |
|
---|
| 96 | /** Number of device data blocks. */
|
---|
| 97 | uint64_t blocks;
|
---|
[eb3683a] | 98 |
|
---|
[9904eb90] | 99 | /** Size of device data blocks. */
|
---|
| 100 | size_t block_size;
|
---|
| 101 |
|
---|
| 102 | /** Name of SATA device. */
|
---|
| 103 | char model[STR_BOUNDS(40) + 1];
|
---|
| 104 |
|
---|
| 105 | /** Device in invalid state (disconnected and so on). */
|
---|
[ae3ff9f5] | 106 | bool is_packet_device;
|
---|
[9904eb90] | 107 |
|
---|
| 108 | /** Highest UDMA mode supported. */
|
---|
| 109 | uint8_t highest_udma_mode;
|
---|
| 110 | } sata_dev_t;
|
---|
| 111 |
|
---|
| 112 | #endif
|
---|