1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
//! ATA: the drive, independent of whatever is talking to it.
//!
//! [`disk`] holds the whole of it — the command block registers, the command
//! set, the busy/DRQ handshake, CHS and LBA addressing and the 256-word
//! `IDENTIFY DEVICE` response. That module's own documentation argues where the
//! line between a drive and a host adapter falls and why it falls there; the
//! short version is that "IDE" means the controller is *on the drive*, so what
//! is left on the motherboard is address decode, and address decode is nearly
//! all [`crate::dev::pc::ide`] contains.
//!
//! The falsifiable form of that claim, which is the point of stating it:
//!
//! * `src/dev/ata/disk.rs` contains **no I/O port address and no register
//! offset**. A register is named ([`Reg`]), never numbered.
//! * `src/dev/pc/ide.rs` contains **no ATA command opcode, no `IDENTIFY` word
//! index and no status- or error-register bit**. It knows eight register
//! names, two chip selects and an interrupt line.
//!
//! If either grep starts returning hits, the split has rotted.
//!
//! # Two front doors, one command set
//!
//! Eight ports written in the right order is the right model of a ribbon cable
//! and the wrong model of a Serial ATA link, which carries the whole command
//! block at once in a structure with no ordering and no register offset in it.
//! [`disk::taskfile`] is the second door: a [`Taskfile`] of six named fields,
//! loaded into the very same command block registers a port write would have
//! left, dispatched by the very same `AtaDisk::command`, with its data phase
//! running the identical busy/DRQ handshake in bulk.
//!
//! The falsifiable form of *that* claim: **delete [`disk::taskfile`] and
//! [`crate::dev::pc::ide`] is unchanged**; delete `AtaDisk::command` and both
//! adapters stop working. `dev/ahci` is the second caller and it did not need a
//! line of `pc/ide` to change.
//!
//! **ATAPI is out of scope.** There is no packet interface here, no SCSI
//! command descriptor block and no CD-ROM: `IDENTIFY PACKET DEVICE` is aborted,
//! which is exactly what a non-packet device does and exactly how a driver
//! finds out. Half a CD-ROM would be worse than none.
//!
//! # Finding each other
//!
//! A drive and its host adapter are separate objects in a machine description,
//! and there is no `core::bus` yet, so they meet through [`bays`] — a named
//! drive bay in the build's [`HostObjects`](crate::core::hosts::HostObjects),
//! the same rendezvous pattern [`crate::dev::sd::slots`], `bus::spi::buses` and
//! `host::chardev::ports` use. Both ends name the same bay (`bay = "ata0"`), and
//! whichever is constructed first creates it. An empty bay is an empty bay: the
//! adapter finds nothing, the command block reads back as zero, and a driver
//! concludes there is no drive there — which is what an unpopulated cable
//! position does.
//!
//! # What the platter is
//!
//! [`medium`] is the seam between the protocol and the storage. A drive built
//! from a media slot gets a `RamStore` and costs its whole capacity in host
//! memory; one whose slot a host filled with a [`Medium`] gets that instead —
//! `dev/blk` supplies a host file through `fstool`, so sparse raw, qcow2, DMG and
//! LUKS images all work and nothing above [`AtaDisk`]'s five methods changes.
//! **Both paths are supported**: the media slot is what keeps this device
//! `no_std`, and the file is what keeps a 16 GiB drive out of RAM.
//!
//! # Sources
//!
//! The **AT Attachment with Packet Interface** standards from T13 — ATA/ATAPI-6
//! (T13/1410D) for the command set and the register file, and its 48-bit
//! Address feature set — and the *IBM Personal Computer AT Technical Reference*
//! for the board's side of it. Clause and command names are cited on the items
//! they justify.
//!
//! **No emulator source of any licence was consulted, and no operating
//! system's ATA driver was opened** (`CLAUDE.md`, provenance).
pub use ;
pub use ;
pub use ;
/// The bay name a drive and an adapter get when neither says.
pub const DEFAULT_BAY: &str = "ata0";
/// Named drive bays: how a drive and its host adapter find each other.
///
/// A [`Bay`](bays::Bay) is the cable position, not the drive. It exists whether
/// or not something is in it, because that is the honest model of a ribbon
/// cable with one connector unused — and because the adapter is usually
/// constructed before the drive.
/// Add every `ata` class to a registry.
///
/// # Errors
///
/// [`crate::Error::Config`] if something already claimed one of the names.
/// Bind every `ata` class into the machine graph.
///
/// # Errors
///
/// [`crate::Error::Config`] if a class is already bound.
/// What the validator should know about the `ata` classes.