source: mainline/uspace/drv/block/pci-ide/pci-ide.h@ 3526f4f3

Last change on this file since 3526f4f3 was 443695e, checked in by Jiri Svoboda <jiri@…>, 15 months ago

Basic PCI-IDE driver (no DMA support)

Also, make sure we avoid attaching ISA IDE and PCI IDE
at the same time. For simplicity, use ISA IDE on ISA systems
and PCI IDE on PCI-based systems.

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