1 |
786 |
skrzyp |
#ifndef CYGONCE_IDE_DISK_H
|
2 |
|
|
#define CYGONCE_IDE_DISK_H
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// ide_disk.h
|
6 |
|
|
//
|
7 |
|
|
// IDE polled mode disk driver defines
|
8 |
|
|
//
|
9 |
|
|
//==========================================================================
|
10 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//==========================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): iz
|
45 |
|
|
// Contributors:
|
46 |
|
|
// Date: 2004-10-16
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//==========================================================================
|
51 |
|
|
|
52 |
|
|
// IDE Register Indices
|
53 |
|
|
#define IDE_REG_DATA 0
|
54 |
|
|
#define IDE_REG_ERROR 1
|
55 |
|
|
#define IDE_REG_FEATURES 1
|
56 |
|
|
#define IDE_REG_COUNT 2
|
57 |
|
|
#define IDE_REG_REASON 2 // ATAPI
|
58 |
|
|
#define IDE_REG_LBALOW 3
|
59 |
|
|
#define IDE_REG_LBAMID 4
|
60 |
|
|
#define IDE_REG_LBAHI 5
|
61 |
|
|
#define IDE_REG_DEVICE 6
|
62 |
|
|
#define IDE_REG_STATUS 7
|
63 |
|
|
#define IDE_REG_COMMAND 7
|
64 |
|
|
|
65 |
|
|
#define IDE_STAT_BSY 0x80
|
66 |
|
|
#define IDE_STAT_DRDY 0x40
|
67 |
|
|
#define IDE_STAT_SERVICE 0x10
|
68 |
|
|
#define IDE_STAT_DRQ 0x08
|
69 |
|
|
#define IDE_STAT_CORR 0x04
|
70 |
|
|
#define IDE_STAT_ERR 0x01
|
71 |
|
|
|
72 |
|
|
#define IDE_REASON_REL 0x04
|
73 |
|
|
#define IDE_REASON_IO 0x02
|
74 |
|
|
#define IDE_REASON_COD 0x01
|
75 |
|
|
|
76 |
|
|
/* flag values */
|
77 |
|
|
#define IDE_DEV_PRESENT 1 // Device is present
|
78 |
|
|
#define IDE_DEV_PACKET 2 // Supports packet interface
|
79 |
|
|
#define IDE_DEV_ADDR48 3 // Supports 48bit addressing
|
80 |
|
|
|
81 |
|
|
typedef struct ide_identify_data_t_ {
|
82 |
|
|
cyg_uint16 general_conf; // 00 : general configuration
|
83 |
|
|
cyg_uint16 num_cylinders; // 01 : number of cylinders (default CHS trans)
|
84 |
|
|
cyg_uint16 reserved0; // 02 : reserved
|
85 |
|
|
cyg_uint16 num_heads; // 03 : number of heads (default CHS trans)
|
86 |
|
|
cyg_uint16 num_ub_per_track; // 04 : number of unformatted bytes per track
|
87 |
|
|
cyg_uint16 num_ub_per_sector; // 05 : number of unformatted bytes per sector
|
88 |
|
|
cyg_uint16 num_sectors; // 06 : number of sectors per track (default CHS trans)
|
89 |
|
|
cyg_uint16 num_card_sectors[2]; // 07-08 : number of sectors per card
|
90 |
|
|
cyg_uint16 reserved1; // 09 : reserved
|
91 |
|
|
cyg_uint16 serial[10]; // 10-19 : serial number (string)
|
92 |
|
|
cyg_uint16 buffer_type; // 20 : buffer type (dual ported)
|
93 |
|
|
cyg_uint16 buffer_size; // 21 : buffer size in 512 increments
|
94 |
|
|
cyg_uint16 num_ECC_bytes; // 22 : number of ECC bytes passed on R/W Long cmds
|
95 |
|
|
cyg_uint16 firmware_rev[4]; // 23-26 : firmware revision (string)
|
96 |
|
|
cyg_uint16 model_num[20]; // 27-46 : model number (string)
|
97 |
|
|
cyg_uint16 rw_mult_support; // 47 : max number of sectors on R/W multiple cmds
|
98 |
|
|
cyg_uint16 reserved2; // 48 : reserved
|
99 |
|
|
cyg_uint16 capabilities; // 49 : LBA, DMA, IORDY support indicator
|
100 |
|
|
cyg_uint16 reserved3; // 50 : reserved
|
101 |
|
|
cyg_uint16 pio_xferc_timing; // 51 : PIO data transfer cycle timing mode
|
102 |
|
|
cyg_uint16 dma_xferc_timing; // 52 : single word DMA data transfer cycle timing mode
|
103 |
|
|
cyg_uint16 cur_field_validity; // 53 : words 54-58 validity (0 == not valid)
|
104 |
|
|
cyg_uint16 cur_cylinders; // 54 : number of current cylinders
|
105 |
|
|
cyg_uint16 cur_heads; // 55 : number of current heads
|
106 |
|
|
cyg_uint16 cur_spt; // 56 : number of current sectors per track
|
107 |
|
|
cyg_uint16 cur_capacity[2]; // 57-58 : current capacity in sectors
|
108 |
|
|
cyg_uint16 mult_sectors; // 59 : multiple sector setting
|
109 |
|
|
cyg_uint16 lba_total_sectors[2]; // 60-61 : total sectors in LBA mode
|
110 |
|
|
cyg_uint16 sw_dma; // 62 : single word DMA support
|
111 |
|
|
cyg_uint16 mw_dma; // 63 : multi word DMA support
|
112 |
|
|
cyg_uint16 apio_modes; // 64 : advanced PIO transfer mode supported
|
113 |
|
|
cyg_uint16 min_dma_timing; // 65 : minimum multiword DMA transfer cycle
|
114 |
|
|
cyg_uint16 rec_dma_timing; // 66 : recommended multiword DMA cycle
|
115 |
|
|
cyg_uint16 min_pio_timing; // 67 : min PIO transfer time without flow control
|
116 |
|
|
cyg_uint16 min_pio_iordy_timing; // 68 : min PIO transfer time with IORDY flow control
|
117 |
|
|
// cyg_uint16 reserved4[187]; // 69-255: reserved
|
118 |
|
|
} ide_identify_data_t;
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
typedef struct ide_disk_info_t_ {
|
122 |
|
|
cyg_uint8 port;
|
123 |
|
|
cyg_uint8 chan;
|
124 |
|
|
} ide_disk_info_t;
|
125 |
|
|
|
126 |
|
|
// ----------------------------------------------------------------------------
|
127 |
|
|
|
128 |
|
|
static cyg_bool ide_disk_init(struct cyg_devtab_entry *tab);
|
129 |
|
|
|
130 |
|
|
static Cyg_ErrNo ide_disk_read(disk_channel *chan,
|
131 |
|
|
void *buf,
|
132 |
|
|
cyg_uint32 len,
|
133 |
|
|
cyg_uint32 block_num);
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
static Cyg_ErrNo ide_disk_write(disk_channel *chan,
|
137 |
|
|
const void *buf,
|
138 |
|
|
cyg_uint32 len,
|
139 |
|
|
cyg_uint32 block_num);
|
140 |
|
|
|
141 |
|
|
static Cyg_ErrNo ide_disk_get_config(disk_channel *chan,
|
142 |
|
|
cyg_uint32 key,
|
143 |
|
|
const void *xbuf,
|
144 |
|
|
cyg_uint32 *len);
|
145 |
|
|
|
146 |
|
|
static Cyg_ErrNo ide_disk_set_config(disk_channel *chan,
|
147 |
|
|
cyg_uint32 key,
|
148 |
|
|
const void *xbuf,
|
149 |
|
|
cyg_uint32 *len);
|
150 |
|
|
|
151 |
|
|
static Cyg_ErrNo ide_disk_lookup(struct cyg_devtab_entry **tab,
|
152 |
|
|
struct cyg_devtab_entry *sub_tab,
|
153 |
|
|
const char *name);
|
154 |
|
|
|
155 |
|
|
DISK_FUNS(ide_disk_funs,
|
156 |
|
|
ide_disk_read,
|
157 |
|
|
ide_disk_write,
|
158 |
|
|
ide_disk_get_config,
|
159 |
|
|
ide_disk_set_config
|
160 |
|
|
);
|
161 |
|
|
|
162 |
|
|
// ----------------------------------------------------------------------------
|
163 |
|
|
|
164 |
|
|
#define IDE_DISK_INSTANCE(_number_,_port_,_chan_,_mbr_supp_,_name_) \
|
165 |
|
|
static ide_disk_info_t ide_disk_info##_number_ = { \
|
166 |
|
|
port: (cyg_uint8) _port_, \
|
167 |
|
|
chan: (cyg_uint8) _chan_ \
|
168 |
|
|
}; \
|
169 |
|
|
DISK_CHANNEL(ide_disk_channel##_number_, \
|
170 |
|
|
ide_disk_funs, \
|
171 |
|
|
ide_disk_info##_number_, \
|
172 |
|
|
ide_disk_controller, \
|
173 |
|
|
_mbr_supp_, \
|
174 |
|
|
4 \
|
175 |
|
|
); \
|
176 |
|
|
BLOCK_DEVTAB_ENTRY(ide_disk_io##_number_, \
|
177 |
|
|
_name_, \
|
178 |
|
|
0, \
|
179 |
|
|
&cyg_io_disk_devio, \
|
180 |
|
|
ide_disk_init, \
|
181 |
|
|
ide_disk_lookup, \
|
182 |
|
|
&ide_disk_channel##_number_ \
|
183 |
|
|
);
|
184 |
|
|
|
185 |
|
|
// ----------------------------------------------------------------------------
|
186 |
|
|
|
187 |
|
|
#endif // CYGONCE_IDE_DISK_H
|