[4f5caea] | 1 | /*
|
---|
[07039850] | 2 | * Copyright (c) 2025 Jiri Svoboda
|
---|
[4f5caea] | 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 |
|
---|
[59c0f478] | 29 | /** @addtogroup isa-ide
|
---|
[4f5caea] | 30 | * @{
|
---|
| 31 | */
|
---|
[59c0f478] | 32 | /** @file ISA IDE driver definitions.
|
---|
[4f5caea] | 33 | */
|
---|
| 34 |
|
---|
[59c0f478] | 35 | #ifndef ISA_IDE_H
|
---|
| 36 | #define ISA_IDE_H
|
---|
[4f5caea] | 37 |
|
---|
[2791fbb7] | 38 | #include <ata/ata.h>
|
---|
| 39 | #include <ata/ata_hw.h>
|
---|
[66cb7a2] | 40 | #include <ddf/driver.h>
|
---|
[1e4cada] | 41 | #include <fibril_synch.h>
|
---|
[64cf7a3] | 42 | #include <stdbool.h>
|
---|
[8d2dd7f2] | 43 | #include <stdint.h>
|
---|
[66cb7a2] | 44 |
|
---|
[59c0f478] | 45 | #define NAME "isa-ide"
|
---|
[4f5caea] | 46 |
|
---|
[59c0f478] | 47 | /** ISA IDE hardware resources */
|
---|
[e092dc5] | 48 | typedef struct {
|
---|
[646849b3] | 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 */
|
---|
[59c0f478] | 55 | } isa_ide_hwres_t;
|
---|
[e092dc5] | 56 |
|
---|
[646849b3] | 57 | /** ISA IDE channel */
|
---|
| 58 | typedef struct isa_ide_channel {
|
---|
| 59 | /** Parent controller */
|
---|
| 60 | struct isa_ide_ctrl *ctrl;
|
---|
[96cbd18] | 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;
|
---|
[64cf7a3] | 70 | /** IRQ (-1 if not used) */
|
---|
| 71 | int irq;
|
---|
| 72 | /** IRQ handle */
|
---|
| 73 | cap_irq_handle_t ihandle;
|
---|
[96cbd18] | 74 |
|
---|
[64cf7a3] | 75 | /** Synchronize controller access */
|
---|
[66cb7a2] | 76 | fibril_mutex_t lock;
|
---|
[64cf7a3] | 77 | /** Value of status register read by interrupt handler */
|
---|
| 78 | uint8_t irq_status;
|
---|
[2791fbb7] | 79 |
|
---|
| 80 | /** Libata ATA channel */
|
---|
| 81 | ata_channel_t *channel;
|
---|
[59c0f478] | 82 | struct isa_ide_fun *fun[2];
|
---|
[646849b3] | 83 |
|
---|
| 84 | /** Channel ID */
|
---|
| 85 | unsigned chan_id;
|
---|
| 86 | } isa_ide_channel_t;
|
---|
| 87 |
|
---|
| 88 | /** ISA IDE controller */
|
---|
| 89 | typedef 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];
|
---|
[59c0f478] | 95 | } isa_ide_ctrl_t;
|
---|
[96cbd18] | 96 |
|
---|
[646849b3] | 97 | /** ISA IDE function */
|
---|
[59c0f478] | 98 | typedef struct isa_ide_fun {
|
---|
[66cb7a2] | 99 | ddf_fun_t *fun;
|
---|
[2791fbb7] | 100 | void *charg;
|
---|
[59c0f478] | 101 | } isa_ide_fun_t;
|
---|
[66cb7a2] | 102 |
|
---|
[646849b3] | 103 | extern errno_t isa_ide_channel_init(isa_ide_ctrl_t *, isa_ide_channel_t *,
|
---|
| 104 | unsigned, isa_ide_hwres_t *);
|
---|
| 105 | extern errno_t isa_ide_channel_fini(isa_ide_channel_t *);
|
---|
[07039850] | 106 | extern void isa_ide_channel_quiesce(isa_ide_channel_t *);
|
---|
[66cb7a2] | 107 |
|
---|
[4f5caea] | 108 | #endif
|
---|
| 109 |
|
---|
| 110 | /** @}
|
---|
| 111 | */
|
---|