Changeset ebb1489 in mainline for uspace/lib/ata/include/ata/ata.h
- Timestamp:
- 2024-10-13T08:23:40Z (2 months ago)
- Children:
- 0472cf17
- Parents:
- 2a0c827c (diff), b3b79981 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2024-10-13 08:23:40)
- git-committer:
- GitHub <noreply@…> (2024-10-13 08:23:40)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ata/include/ata/ata.h
r2a0c827c rebb1489 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup ata_bd29 /** @addtogroup libata 30 30 * @{ 31 31 */ 32 /** @file ATA driver definitions.33 */ 34 35 #ifndef __ATA_BD_H__36 #define __ATA_BD_H__32 /** @file ATA driver library definitions. 33 */ 34 35 #ifndef LIBATA_ATA_H 36 #define LIBATA_ATA_H 37 37 38 38 #include <async.h> 39 39 #include <bd_srv.h> 40 #include <ddf/driver.h>41 40 #include <fibril_synch.h> 41 #include <stdbool.h> 42 42 #include <str.h> 43 43 #include <stdint.h> … … 45 45 #include "ata_hw.h" 46 46 47 #define NAME "ata_bd" 48 49 /** Base addresses for ATA I/O blocks. */ 47 struct ata_device; 48 49 /** ATA DMA direction */ 50 typedef enum { 51 /** DMA read */ 52 ata_dma_read, 53 /** DMA write */ 54 ata_dma_write 55 } ata_dma_dir_t; 56 57 /** ATA channel creation parameters */ 50 58 typedef struct { 51 uintptr_t cmd; /**< Command block base address. */ 52 uintptr_t ctl; /**< Control block base address. */ 53 } ata_base_t; 59 /** Argument to callback functions */ 60 void *arg; 61 /** IRQ is available */ 62 bool have_irq; 63 /** Use DMA transfers */ 64 bool use_dma; 65 /** Maximum number of bytes that we can DMA in one I/O operation */ 66 size_t max_dma_xfer; 67 /** Read 16 bits from the data port */ 68 void (*write_data_16)(void *, uint16_t *, size_t); 69 /** Write 16 bits to the data port */ 70 void (*read_data_16)(void *, uint16_t *, size_t); 71 /** Read 8 bits from an 8-bit command register */ 72 void (*write_cmd_8)(void *, uint16_t, uint8_t); 73 /** Writes 8 bits to an 8-bit command register */ 74 uint8_t (*read_cmd_8)(void *, uint16_t); 75 /** Read 8 bits from a control register */ 76 void (*write_ctl_8)(void *, uint16_t, uint8_t); 77 /** Write 8 bits to a control register */ 78 uint8_t (*read_ctl_8)(void *, uint16_t); 79 /** Enable interrupts */ 80 errno_t (*irq_enable)(void *); 81 /** Disable interrupts */ 82 errno_t (*irq_disable)(void *); 83 /** Set up DMA channel */ 84 void (*dma_chan_setup)(void *, void *, size_t, ata_dma_dir_t); 85 /** Set up DMA channel */ 86 void (*dma_chan_teardown)(void *); 87 /** Add new device */ 88 errno_t (*add_device)(void *, unsigned, void *); 89 /** Remove device */ 90 errno_t (*remove_device)(void *, unsigned); 91 /** Log notice message */ 92 void (*msg_note)(void *, char *); 93 /** Log error message */ 94 void (*msg_error)(void *, char *); 95 /** Log warning message */ 96 void (*msg_warn)(void *, char *); 97 /** Log debug message */ 98 void (*msg_debug)(void *, char *); 99 } ata_params_t; 54 100 55 101 /** Timeout definitions. Unit is 10 ms. */ … … 99 145 100 146 /** ATA device state structure. */ 101 typedef struct {147 typedef struct ata_device { 102 148 bool present; 103 struct ata_ctrl *ctrl; 104 struct ata_fun *afun; 149 struct ata_channel *chan; 105 150 106 151 /** Device type */ … … 124 169 char model[STR_BOUNDS(40) + 1]; 125 170 126 int disk_id; 127 } disk_t; 128 129 /** ATA controller */ 130 typedef struct ata_ctrl { 131 /** DDF device */ 132 ddf_dev_t *dev; 133 /** I/O base address of the command registers */ 134 uintptr_t cmd_physical; 135 /** I/O base address of the control registers */ 136 uintptr_t ctl_physical; 171 int device_id; 172 bd_srvs_t bds; 173 } ata_device_t; 174 175 /** ATA channel */ 176 typedef struct ata_channel { 177 /** Parameters */ 178 ata_params_t params; 137 179 138 180 /** Command registers */ … … 141 183 ata_ctl_t *ctl; 142 184 143 /** Per-disk state. */ 144 disk_t disk[MAX_DISKS]; 145 185 /** Per-device state. */ 186 ata_device_t device[MAX_DEVICES]; 187 188 /** Synchronize channel access */ 146 189 fibril_mutex_t lock; 147 } ata_ctrl_t; 148 149 typedef struct ata_fun { 150 ddf_fun_t *fun; 151 disk_t *disk; 152 bd_srvs_t bds; 153 } ata_fun_t; 154 155 extern errno_t ata_ctrl_init(ata_ctrl_t *, ata_base_t *); 156 extern errno_t ata_ctrl_remove(ata_ctrl_t *); 157 extern errno_t ata_ctrl_gone(ata_ctrl_t *); 158 159 extern bd_ops_t ata_bd_ops; 190 /** Synchronize access to irq_fired/irq_status */ 191 fibril_mutex_t irq_lock; 192 /** Signalled by IRQ handler */ 193 fibril_condvar_t irq_cv; 194 /** Set to true when interrupt occurs */ 195 bool irq_fired; 196 /** Value of status register read by interrupt handler */ 197 uint8_t irq_status; 198 } ata_channel_t; 199 200 extern errno_t ata_channel_create(ata_params_t *, ata_channel_t **); 201 extern errno_t ata_channel_initialize(ata_channel_t *); 202 extern errno_t ata_channel_destroy(ata_channel_t *); 203 extern void ata_channel_irq(ata_channel_t *, uint8_t); 204 extern void ata_connection(ipc_call_t *, ata_device_t *); 160 205 161 206 #endif
Note:
See TracChangeset
for help on using the changeset viewer.