source: mainline/uspace/drv/block/isa-ide/isa-ide.h

Last change on this file was 07039850, checked in by Jiri Svoboda <jiri@…>, 6 months ago

Implement quiesce in ISA and PCI IDE and in PC Floppy.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2025 Jiri Svoboda
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/** @addtogroup isa-ide
30 * @{
31 */
32/** @file ISA IDE driver definitions.
33 */
34
35#ifndef ISA_IDE_H
36#define ISA_IDE_H
37
38#include <ata/ata.h>
39#include <ata/ata_hw.h>
40#include <ddf/driver.h>
41#include <fibril_synch.h>
42#include <stdbool.h>
43#include <stdint.h>
44
45#define NAME "isa-ide"
46
47/** ISA IDE hardware resources */
48typedef struct {
49 uintptr_t cmd1; /**< Primary channel command block base address. */
50 uintptr_t ctl1; /**< Primary channel control block base address. */
51 uintptr_t cmd2; /**< Secondary channel command block base address. */
52 uintptr_t ctl2; /**< Secondary channel control block base address. */
53 int irq1; /**< Primary channel IRQ */
54 int irq2; /**< Secondary channel IRQ */
55} isa_ide_hwres_t;
56
57/** ISA IDE channel */
58typedef struct isa_ide_channel {
59 /** Parent controller */
60 struct isa_ide_ctrl *ctrl;
61 /** I/O base address of the command registers */
62 uintptr_t cmd_physical;
63 /** I/O base address of the control registers */
64 uintptr_t ctl_physical;
65
66 /** Command registers */
67 ata_cmd_t *cmd;
68 /** Control registers */
69 ata_ctl_t *ctl;
70 /** IRQ (-1 if not used) */
71 int irq;
72 /** IRQ handle */
73 cap_irq_handle_t ihandle;
74
75 /** Synchronize controller access */
76 fibril_mutex_t lock;
77 /** Value of status register read by interrupt handler */
78 uint8_t irq_status;
79
80 /** Libata ATA channel */
81 ata_channel_t *channel;
82 struct isa_ide_fun *fun[2];
83
84 /** Channel ID */
85 unsigned chan_id;
86} isa_ide_channel_t;
87
88/** ISA IDE controller */
89typedef struct isa_ide_ctrl {
90 /** DDF device */
91 ddf_dev_t *dev;
92
93 /** Primary and secondary channel */
94 isa_ide_channel_t channel[2];
95} isa_ide_ctrl_t;
96
97/** ISA IDE function */
98typedef struct isa_ide_fun {
99 ddf_fun_t *fun;
100 void *charg;
101} isa_ide_fun_t;
102
103extern errno_t isa_ide_channel_init(isa_ide_ctrl_t *, isa_ide_channel_t *,
104 unsigned, isa_ide_hwres_t *);
105extern errno_t isa_ide_channel_fini(isa_ide_channel_t *);
106extern void isa_ide_channel_quiesce(isa_ide_channel_t *);
107
108#endif
109
110/** @}
111 */
Note: See TracBrowser for help on using the repository browser.