UbixOS V2 2.0

hd.c
Go to the documentation of this file.
1 /*-
2 * Copyright (c) 2002-2018 The UbixOS Project.
3 * All rights reserved.
4 *
5 * This was developed by Christopher W. Olsen for the UbixOS Project.
6 *
7 * Redistribution and use in source and binary forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
10 * 1) Redistributions of source code must retain the above copyright notice, this list of
11 * conditions, the following disclaimer and the list of authors.
12 * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13 * conditions, the following disclaimer and the list of authors in the documentation and/or
14 * other materials provided with the distribution.
15 * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16 * endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <pci/hd.h>
30 #include <sys/io.h>
31 #include <sys/device.h>
32 #include <lib/kmalloc.h>
33 #include <lib/kprintf.h>
34 #include <devfs/devfs.h>
35 #include <string.h>
36 #include <fs/common/gpt.h>
37
38 static const uuid_t freebsd_ufs_uuid = GPT_ENT_TYPE_FREEBSD_UFS;
39
40 static hdC = 0;
41
42 int initHardDisk() {
43 _initHardDisk(0xE0);
44 _initHardDisk(0xF0);
45 }
46
47 int _initHardDisk(int hdD) {
48 int i = 0x0;
49 int x = 0x0;
50 int minor = 0x0;
51 struct device_interface *devInfo = 0x0;
52 struct device_interface *devInfo2 = 0x0;
53 struct dos_partition *d = 0x0;
54 struct driveInfo *hdd = 0x0;
55 struct driveInfo *hdd2 = 0x0;
56 char *data = 0x0;
57 char *data2 = 0x0;
58 char name[16];
59 struct bsd_disklabel *bsdd = 0x0;
60
61 //GPT
62 char *secbuf = 0x0;
63
64 hdd = (struct driveInfo *) kmalloc(sizeof(struct driveInfo));
65 hdd->ata_identify = (struct ata_identify_data *) kmalloc(sizeof(struct ata_identify_data));
66 hdd->hdPort = 0x1F0;
67 hdd->hdDev = hdD; //0x40;
68 hdd->parOffset = 0x0;
69 hdd->part = 0x2;
70
71 /* Alloc memory for device structure and set it up correctly */
72 devInfo = (struct device_interface *) kmalloc(sizeof(struct device_interface));
73 devInfo->read = (void *) &hdRead;
74 devInfo->write = (void *) &hdWrite;
75 devInfo->reset = (void *) &hdReset;
76 devInfo->init = (void *) &hdInit;
77 devInfo->ioctl = (void *) &hdIoctl;
78 devInfo->stop = (void *) &hdStop;
79 devInfo->start = (void *) &hdStart;
80 devInfo->standby = (void *) &hdStandby;
81 devInfo->info = hdd;
82
83 devInfo->major = hdC + 0x1;
84
85 data = (char *) kmalloc(512);
86 d = (struct dos_partition *) (data + 0x1BE);
87
88 data2 = (char *) kmalloc(512);
89 bsdd = (struct bsd_disklabel *) data2;
90
91 if (device_add(0, 'c', devInfo) == 0x0) {
92 kprintf("ad%i - Start: [0x0], Size: [0x%x/0x%X]\n", hdC, hdd->hdSize, hdd->hdSize * 512);
93 sprintf(name, "ad%ip%i", hdC, hdd->part);
94 devfs_makeNode(name, 'b', 0x1, 0x0);
95 hdRead(devInfo->info, data, 0x0, 0x1);
96
97 if (d[0].dp_type == 0xEE) {
98 // MrOlsen (2016-01-14) DEBUG: This was just to help debug
99 //kprintf( "%s - Type: [0x%X - %s], Start: [0x%X], Size: [0x%X]\n", name, d[0].dp_type, (d[0].dp_type >= 0 && d[0].dp_type <= 255) ? part_types[d[0].dp_type] : "Unknown", d[0].dp_start, d[0].dp_size );
100
101 secbuf = (char *) kmalloc(65536);
102
103 if (gptread(&freebsd_ufs_uuid, devInfo, secbuf) == -1) {
104 kprintf("%s: unable to load GPT\n", "KERNEL");
105 //return (-1);
106 }
107 else {
108 devInfo2 = (struct device_interface *) kmalloc(sizeof(struct device_interface));
109 hdd2 = (struct driveInfo *) kmalloc(sizeof(struct driveInfo));
110 memcpy(devInfo2, devInfo, sizeof(struct device_interface));
111 memcpy(hdd2, hdd, sizeof(struct driveInfo));
112 //hdd2->parOffset = d[i].dp_start;
113 devInfo2->info = hdd2;
114 minor++;
115
116 if (gptfind(&freebsd_ufs_uuid, devInfo2, hdd->part) == -1) {
117 //MrOlsen (2016-01-11) FIX: I am using "1" as partition 1
118 kprintf("%s: no UFS partition was found\n", "KERNEL");
119 //return (-1);
120 }
121
122 //MrOlsen (2016-01-14) DEBUG: This was just debugging code
123 //kprintf("[%i - %i]\n", hdd->parOffset, hdd2->parOffset);
124
125 if (device_add(minor, 'c', devInfo2) == 0x0) {
126 sprintf(name, "ad%ip%i", hdC, hdd->part);
127 kprintf("%s - Type: [0x%X - %s], Start: [%i], Offset: [%i], Size: [%i], MM: [%i:%i]\n", name, d[0].dp_type, (d[0].dp_type >= 0 && d[0].dp_type <= 255) ? part_types[d[0].dp_type] : "Unknown", hdd2->lba_start, hdd2->parOffset, hdd2->lba_end - hdd2->lba_start, devInfo->major, minor);
128 devfs_makeNode(name, 'c', 0x1, minor);
129 }
130 }
131
132 }
133 else {
134
135 for (i = 0x0; i < 0x4; i++) {
136
137 //MrOlsen (2016-01-14) DEBUG: This was just debugging code
138 //kprintf( "Type: 0x%X\n", d[i].dp_type );
139
140 if (d[i].dp_type == 0xEE)
141 kprintf("Motherfucker Jones! We're GPT.... Lick My Nuts Now Bitch!\n");
142
143 if (d[i].dp_type != 0x0) {
144 devInfo2 = (struct device_interface *) kmalloc(sizeof(struct device_interface));
145 hdd2 = (struct driveInfo *) kmalloc(sizeof(struct driveInfo));
146 memcpy(devInfo2, devInfo, sizeof(struct device_interface));
147 memcpy(hdd2, hdd, sizeof(struct driveInfo));
148 hdd2->parOffset = d[i].dp_start;
149 devInfo2->info = hdd2;
150 minor++;
151
152 if (device_add(minor, 'c', devInfo2) == 0x0) {
153 sprintf(name, "ad%is%i", hdC, i + 1);
154 kprintf("%s - Type: [0x%X - %s], Start: [0x%X], Size: [0x%X], MM: [%i:%i]\n", name, d[i].dp_type, (d[i].dp_type >= 0 && d[i].dp_type <= 255) ? part_types[d[i].dp_type] : "Unknown", d[i].dp_start, d[i].dp_size, devInfo->major, minor);
155
156 devfs_makeNode(name, 'c', 0x1, minor);
157
158 if (d[i].dp_type == 0xA5) {
159 //Why do i need to add 1?
160 hdRead(devInfo->info, data2, d[i].dp_start + 1, 0x1);
161
162 for (x = 0; x < bsdd->d_npartitions; x++) {
163 if (bsdd->d_partitions[x].p_size > 0) {
164 sprintf(name, "ad%is%i%c", hdC, i + 1, 'a' + x);
165 //New Nodes
166 devInfo2 = (struct device_interface *) kmalloc(sizeof(struct device_interface));
167 hdd2 = (struct driveInfo *) kmalloc(sizeof(struct driveInfo));
168 memcpy(devInfo2, devInfo, sizeof(struct device_interface));
169 memcpy(hdd2, hdd, sizeof(struct driveInfo));
170 //hdd2->parOffset = d[i].dp_start + bsdd->d_partitions[x].p_offset;
171 hdd2->lba_start = d[i].dp_start;
172 hdd2->parOffset = bsdd->d_partitions[x].p_offset;
173 devInfo2->info = hdd2;
174 minor++;
175 device_add(minor, 'c', devInfo2);
176 devfs_makeNode(name, 'c', 0x1, minor);
177 kprintf("%s - Type: [%s], Start: [0x%X], Size: [0x%X], MM: [%i:%i]\n", name, fstypenames[bsdd->d_partitions[x].p_fstype], bsdd->d_partitions[x].p_offset, bsdd->d_partitions[x].p_size, devInfo->major, minor);
178 }
179
180 }
181
182 }
183
184 }
185
186 }
187
188 }
189 }
190 }
191 kfree(data);
192 hdC++;
193 return (0x0);
194 }
195
196 int hdStandby() {
197 /* Not Implemented */
198 return (0x0);
199 }
200
201 int hdStart() {
202 /* Not Implemented */
203 return (0x0);
204 }
205
206 int hdStop() {
207 /* Not Implemented */
208 return (0x0);
209 }
210
211 int hdIoctl() {
212 /* Not Implemented */
213 return (0x0);
214 }
215
216 int hdReset() {
217 /* Not Implemented */
218 return (0x0);
219 }
220
221 int hdInit(struct device_node *dev) {
222 u_int8_t retVal = 0x0;
223 int counter = 0x0;
224 u_int16_t *tmp = 0x0;
225 struct driveInfo *hdd = dev->devInfo->info;
226
227 for (counter = 1000000; counter >= 0; counter--) {
228 retVal = inportByte(hdd->hdPort + ATA_COMMAND) & ATA_S_BUSY;
229
230 if (!retVal)
231 goto ready;
232
233 }
234
235 kprintf("Error Initializing Drive\n");
236 return (1);
237
238 ready:
239
240 outportByte(hdd->hdPort + ATA_DRIVE, hdd->hdDev);
241 outportByte(hdd->hdPort + ATA_COMMAND, ATA_IDENTIFY);
242
243 //for (counter = 1000000; counter >= 0; counter--) {
244 for (counter = 10000000; counter >= 0; counter--) {
245 retVal = inportByte(hdd->hdPort + ATA_COMMAND);
246 if ((retVal & 1) != 0x0) {
247 kprintf("Error Drive Not Available\n");
248 return (1);
249 }
250 if ((retVal & 8) != 0x0) {
251 goto go;
252 }
253 }
254
255 kprintf("Time Out Waiting On Drive\n");
256 return (1);
257
258 go:
259
260 tmp = (u_int16_t *) hdd->ata_identify;
261
262 for (counter = 0; counter < 256; counter++) {
263 tmp[counter] = inportWord(hdd->hdPort + ATA_DATA);
264 }
265
266 retVal = tmp[0x2F] & 0xFF;
267
268 switch (retVal) {
269 case 0:
270 hdd->hdShift = 0;
271 hdd->hdMulti = 1;
272 break;
273 case 2:
274 hdd->hdShift = 1;
275 hdd->hdMulti = retVal;
276 break;
277 case 4:
278 hdd->hdShift = 2;
279 hdd->hdMulti = retVal;
280 break;
281 case 8:
282 hdd->hdShift = 3;
283 hdd->hdMulti = retVal;
284 break;
285 case 16:
286 hdd->hdShift = 4;
287 hdd->hdMulti = retVal;
288 break;
289 case 32:
290 hdd->hdShift = 5;
291 hdd->hdMulti = retVal;
292 break;
293 case 64:
294 hdd->hdShift = 6;
295 hdd->hdMulti = retVal;
296 break;
297 case 128:
298 hdd->hdShift = 7;
299 hdd->hdMulti = retVal;
300 break;
301 default:
302 kprintf("Error BLOCK Mode Unavailable: [%x]\n", retVal);
303 return (1);
304 }
305
306 if (hdd->ata_identify->command_set_enabled1 & ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE) {
307 hdd->lba_high = hdd->ata_identify->max_48bit_lba[7] << 24;
308 hdd->lba_high |= hdd->ata_identify->max_48bit_lba[6] << 16;
309 hdd->lba_high |= hdd->ata_identify->max_48bit_lba[5] << 8;
310 hdd->lba_high |= hdd->ata_identify->max_48bit_lba[4];
311
312 hdd->lba_low = hdd->ata_identify->max_48bit_lba[3] << 24;
313 hdd->lba_low |= hdd->ata_identify->max_48bit_lba[2] << 16;
314 hdd->lba_low |= hdd->ata_identify->max_48bit_lba[1] << 8;
315 hdd->lba_low |= hdd->ata_identify->max_48bit_lba[0];
316 }
317 else {
318 hdd->lba_high = 0;
319 hdd->lba_low = hdd->ata_identify->total_num_sectors[3] << 24;
320 hdd->lba_low |= hdd->ata_identify->total_num_sectors[2] << 16;
321 hdd->lba_low |= hdd->ata_identify->total_num_sectors[1] << 8;
322 hdd->lba_low |= hdd->ata_identify->total_num_sectors[0];
323 }
324
325 // If the ATA device reports its sector size (bit 12 of Word 106), then use that instead.
326 if (hdd->ata_identify->physical_logical_sector_info & ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE) {
327 hdd->sector_size = hdd->ata_identify->words_per_logical_sector[3] << 24;
328 hdd->sector_size |= hdd->ata_identify->words_per_logical_sector[2] << 16;
329 hdd->sector_size |= hdd->ata_identify->words_per_logical_sector[1] << 8;
330 hdd->sector_size |= hdd->ata_identify->words_per_logical_sector[0];
331 }
332 else {
333 // Default the sector size to 512 bytes
334 hdd->sector_size = 512;
335 }
336
337 kprintf("LBA [0x%X - 0x%X], LBA_HIGH: %i, LBA_LOW: %i, SECTOR_SIZE: %i\n", hdd->ata_identify->command_set_enabled1, hdd->ata_identify->command_set_enabled1 & ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE, hdd->lba_high, hdd->lba_low, hdd->sector_size);
338
339 outportByte(hdd->hdPort + hdSecCount, retVal);
340 outportByte(hdd->hdPort + hdHead, hdd->hdDev);
341 outportByte(hdd->hdPort + hdCmd, 0xC6);
342
343 hdd->hdMask = retVal;
344 //hdd->hdSize = (hdd->hdSector[0x7B] * 256 * 256 * 256) + (hdd->hdSector[0x7A] * 256 * 256) + (hdd->hdSector[0x79] * 256) + hdd->hdSector[0x78];
345
346 // MrOlsen (2016-01-11) NOTE: Must phase out hdSize
347 hdd->hdSize = hdd->lba_low + hdd->lba_high;
348 hdd->hdEnable = 1;
349
350 kprintf("Drive: [0x%X/0x%X], Size: [%i Sectors/%i MB]\n", hdd->hdPort, hdd->hdDev, hdd->hdSize, hdd->hdSize / 2048);
351 dev->devInfo->size = hdd->hdSize * 512;
352 dev->devInfo->initialized = 0x1;
353 return (0x0);
354 }
355
356 int hdWrite(struct driveInfo *hdd, void *baseAddr, uInt32 startSector, uInt32 sectorCount) {
357 long counter = 0x0;
358 long retVal = 0x0;
359 short transactionCount = 0x0;
360 short *tmp = (short *) baseAddr;
361 if (hdd->lba_start == 0)
362 startSector += hdd->parOffset;
363 else
364 startSector += hdd->lba_start;
365
366 if (hdd->hdEnable == 0x0) {
367 kprintf("Invalid Drive\n");
368 return (1);
369 }
370 if ((sectorCount >> hdd->hdShift) == 0x0) {
371 hdd->hdCalc = sectorCount; /* hdd->hdMask; */
372 transactionCount = 1;
373 }
374 else {
375 hdd->hdCalc = hdd->hdMulti;
376 transactionCount = sectorCount >> hdd->hdShift;
377 }
378 for (; transactionCount > 0; transactionCount--) {
379 //for (counter = 1000000; counter >= 0; counter--) {
380 for (counter = 10000000; counter >= 0; counter--) {
381 retVal = inportByte(hdd->hdPort + hdStat) & 0x80;
382 if (!retVal)
383 goto ready;
384 }
385 kprintf("Time Out Waiting On Drive\n");
386 return (1);
387 ready: outportByte(hdd->hdPort + hdSecCount, hdd->hdCalc);
388 outportByte(hdd->hdPort + hdSecNum, (startSector & 0xFF));
389 retVal = startSector >> 8;
390 outportByte(hdd->hdPort + hdCylLow, (retVal & 0xFF));
391 retVal >>= 8;
392 outportByte(hdd->hdPort + hdCylHi, (retVal & 0xFF));
393 retVal >>= 8;
394 retVal &= 0x0F;
395 retVal |= (hdd->hdDev | 0xA0); //Test As Per TJ
396 outportByte(hdd->hdPort + hdHead, (retVal & 0xFF));
397 if (hdd->hdShift > 0)
398 outportByte(hdd->hdPort + hdCmd, 0xC5);
399 else
400 outportByte(hdd->hdPort + hdCmd, 0x30);
401 //for (counter = 1000000; counter >= 0; counter--) {
402 for (counter = 10000000; counter >= 0; counter--) {
403 retVal = inportByte(hdd->hdPort + hdStat);
404 if ((retVal & 1) != 0x0) {
405 kprintf("HD Write Error\n");
406 return (1);
407 }
408 if ((retVal & 8) != 0x0) {
409 goto go;
410 }
411 }
412 kprintf("Time Out Waiting On Drive\n");
413 return (1);
414 go: for (counter = 0; counter < (hdd->hdCalc << 8); counter++) {
415 outportWord(hdd->hdPort + hdData, (short) tmp[counter]);
416 }
417 tmp += (counter + 0);
418 startSector += hdd->hdCalc;
419 }
420 return (0);
421 }
422
423 int hdRead(struct driveInfo *hdd, void *baseAddr, uInt32 startSector, uInt32 sectorCount) {
424 long counter = 0x0;
425 long retVal = 0x0;
426 short transactionCount = 0x0;
427 short *tmp = (short *) baseAddr;
428 startSector += hdd->parOffset;
429 startSector += hdd->lba_start;
430
431 if (hdd->hdEnable == 0x0) {
432 kprintf("Invalid Drive\n");
433 return (1);
434 }
435 if ((sectorCount >> hdd->hdShift) == 0x0) {
436 hdd->hdCalc = sectorCount; /* hdd->hdMask); */
437 transactionCount = 1;
438 }
439 else {
440 hdd->hdCalc = hdd->hdMulti;
441 transactionCount = sectorCount >> hdd->hdShift;
442 }
443 for (; transactionCount > 0; transactionCount--) {
444 //for (counter = 1000000; counter >= 0; counter--) {
445 for (counter = 10000000; counter >= 0; counter--) {
446 retVal = inportByte(hdd->hdPort + hdStat) & 0x80;
447 if (!retVal)
448 goto ready;
449 }
450 kprintf("Time Out Waiting On Drive\n");
451 return (1);
452 ready: outportByte(hdd->hdPort + hdSecCount, hdd->hdCalc);
453 outportByte(hdd->hdPort + hdSecNum, (startSector & 0xFF));
454 retVal = startSector >> 8;
455 outportByte(hdd->hdPort + hdCylLow, (retVal & 0xFF));
456 retVal >>= 8;
457 outportByte(hdd->hdPort + hdCylHi, (retVal & 0xFF));
458 retVal >>= 8;
459 retVal &= 0x0F;
460 retVal |= (hdd->hdDev | 0xA0); //Test as per TJ
461 //retVal |= hdd->hdDev; //retVal |= (hdd->hdDev | 0xA0); //Test as per TJ
462 outportByte(hdd->hdPort + hdHead, (retVal & 0xFF));
463 if (hdd->hdShift > 0)
464 outportByte(hdd->hdPort + hdCmd, 0xC4);
465 else
466 outportByte(hdd->hdPort + hdCmd, 0x20);
467 //for (counter = 1000000; counter >= 0; counter--) {
468 for (counter = 10000000; counter >= 0; counter--) {
469 retVal = inportByte(hdd->hdPort + hdStat);
470 if ((retVal & 1) != 0x0) {
471 kprintf("HD Read Error: [%i:0x%X:%i]\n", counter, (uInt32) baseAddr, startSector);
472 return (1);
473 }
474 if ((retVal & 8) != 0x0) {
475 goto go;
476 }
477 }
478 kprintf("Error: Time Out Waiting On Drive\n");
479 return (1);
480 go: for (counter = 0; counter < (hdd->hdCalc << 8); counter++) {
481 tmp[counter] = inportWord(hdd->hdPort + hdData);
482 //kprintf("[0x%X]", tmp[counter]);
483 }
484 tmp += (counter + 0);
485 startSector += hdd->hdCalc;
486 }
487 return (0);
488 }
489
490 /***
491 $Log: hd.c,v $
492 Revision 1.5 2006/10/12 15:00:26 reddawg
493 More changes
494
495 Revision 1.4 2006/10/10 14:14:01 reddawg
496 UFS Reading
497
498 Revision 1.3 2006/10/09 02:58:05 reddawg
499 Fixing UFS
500
501 Revision 1.2 2006/10/06 15:48:01 reddawg
502 Starting to make ubixos work with UFS2
503
504 Revision 1.1.1.1 2006/06/01 12:46:16 reddawg
505 ubix2
506
507 Revision 1.2 2005/10/12 00:13:37 reddawg
508 Removed
509
510 Revision 1.1.1.1 2005/09/26 17:24:34 reddawg
511 no message
512
513 Revision 1.16 2004/08/26 22:51:19 reddawg
514 TCA touched me :( i think he likes men....
515
516
517 sched.h: kTask_t added parentPid
518 endtask.c: fixed term back to parentPid
519 exec.c: cleaned warnings
520 fork.c: fixed term to childPid
521 sched.c: clean up for dead tasks
522 systemtask.c: clean up dead tasks
523 kmalloc.c: cleaned up warnings
524 udp.c: cleaned up warnings
525 bot.c: cleaned up warnings
526 shell.c: cleaned up warnings
527 tcpdump.c: took a dump
528 hd.c: cleaned up warnings
529 ubixfs.c: stopped prning debug info
530
531 Revision 1.15 2004/08/15 00:33:02 reddawg
532 Wow the ide driver works again
533
534 Revision 1.14 2004/08/14 21:56:44 reddawg
535 Added initialized byte to the device system to make it easy to add child devices which use parent hardware.
536
537 Revision 1.13 2004/08/02 11:43:17 reddawg
538 Fixens
539
540 Revision 1.12 2004/07/21 10:02:09 reddawg
541 devfs: renamed functions
542 device system: renamed functions
543 fdc: fixed a few potential bugs and cleaned up some unused variables
544 strol: fixed definition
545 endtask: made it print out freepage debug info
546 kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost
547 ld: fixed a pointer conversion
548 file: cleaned up a few unused variables
549 sched: broke task deletion
550 kprintf: fixed ogPrintf definition
551
552 Revision 1.11 2004/05/19 23:36:52 reddawg
553 Bug Fixes
554
555 Revision 1.10 2004/05/19 15:20:06 reddawg
556 Fixed reference problems due to changes in drive subsystem
557
558 Revision 1.9 2004/05/19 15:07:59 reddawg
559 Typo defInfo should of been devInfo
560
561 Revision 1.7 2004/05/19 04:07:43 reddawg
562 kmalloc(size,pid) no more it is no kmalloc(size); the way it should of been
563
564 Revision 1.6 2004/04/28 21:10:40 reddawg
565 Lots Of changes to make it work with existing os
566
567 Revision 1.5 2004/04/28 02:37:34 reddawg
568 More updates for using the new driver subsystem
569
570 Revision 1.4 2004/04/28 02:22:54 reddawg
571 This is a fiarly large commit but we are starting to use new driver model
572 all around
573
574 Revision 1.3 2004/04/27 21:05:19 reddawg
575 Updating drivers to use new model
576
577 Revision 1.2 2004/04/26 22:22:33 reddawg
578 DevFS now uses correct size of device
579
580 Revision 1.1.1.1 2004/04/15 12:07:16 reddawg
581 UbixOS v1.0
582
583 Revision 1.12 2004/04/13 16:36:33 reddawg
584 Changed our copyright, it is all now under a BSD-Style license
585
586 END
587 ***/
hdStart
int hdStart()
Definition: hd.c:201
hdStat
#define hdStat
Definition: hd.h:42
device_interface::initialized
uInt8 initialized
Definition: device.h:48
device_interface
Definition: device.h:47
ata_identify_data::words_per_logical_sector
u_int8_t words_per_logical_sector[4]
Definition: hd.h:369
dos_partition
Definition: hd.h:195
driveInfo::lba_high
uint32_t lba_high
Definition: hd.h:167
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
_initHardDisk
int _initHardDisk(int hdD)
Definition: hd.c:47
ata_identify_data::total_num_sectors
u_int8_t total_num_sectors[4]
Definition: hd.h:326
hdWrite
int hdWrite(struct driveInfo *hdd, void *baseAddr, uInt32 startSector, uInt32 sectorCount)
Definition: hd.c:356
gptfind
int gptfind(const uuid_t *uuid, struct device_interface *devInfo, int part)
Definition: gpt.c:99
string.h
outportWord
void outportWord(unsigned int, unsigned short)
outputut one word to specified port
Definition: io.c:103
driveInfo::ata_identify
struct ata_identify_data * ata_identify
Definition: hd.h:166
outportByte
void outportByte(unsigned int, unsigned char)
outputut one byte to specified port
Definition: io.c:72
kfree
void kfree(void *baseAddr)
Definition: kmalloc.c:342
hdStandby
int hdStandby()
Definition: hd.c:196
device_interface::stop
void(* stop)(void *)
Definition: device.h:57
driveInfo
Definition: hd.h:164
driveInfo::hdDev
char hdDev
Definition: hd.h:171
hdInit
int hdInit(struct device_node *dev)
Definition: hd.c:221
ata_identify_data::physical_logical_sector_info
u_int16_t physical_logical_sector_info
Definition: hd.h:364
hdCylLow
#define hdCylLow
Definition: hd.h:39
device_interface::ioctl
void(* ioctl)(void *)
Definition: device.h:56
device_add
int device_add(int, char, struct device_interface *)
Definition: device.c:49
ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE
#define ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE
Definition: hd.h:47
GPT_ENT_TYPE_FREEBSD_UFS
#define GPT_ENT_TYPE_FREEBSD_UFS
Definition: gpt.h:98
device_interface::size
uInt32 size
Definition: device.h:49
ATA_DRIVE
#define ATA_DRIVE
Definition: hd.h:61
driveInfo::hdEnable
char hdEnable
Definition: hd.h:170
device_interface::standby
void(* standby)(void *)
Definition: device.h:59
gpt.h
driveInfo::hdSize
long hdSize
Definition: hd.h:177
memcpy
void * memcpy(const void *dst, const void *src, size_t length)
hdData
#define hdData
Definition: hd.h:35
sprintf
int sprintf(char *buf, const char *fmt,...)
Definition: kprintf.c:278
inportByte
unsigned char inportByte(unsigned int)
input one byte from specified port
Definition: io.c:38
u_int16_t
__uint16_t u_int16_t
Definition: types.h:52
ata_identify_data::command_set_enabled1
u_int16_t command_set_enabled1
Definition: hd.h:348
driveInfo::lba_low
uint32_t lba_low
Definition: hd.h:168
device_interface::start
void(* start)(void *)
Definition: device.h:58
gptread
int gptread(const uuid_t *uuid, struct device_interface *devInfo, char *buf)
Definition: gpt.c:305
driveInfo::part
int part
Definition: hd.h:180
hdIoctl
int hdIoctl()
Definition: hd.c:211
kprintf.h
u_int8_t
__uint8_t u_int8_t
Definition: types.h:51
hdStop
int hdStop()
Definition: hd.c:206
device_node
Definition: device.h:34
hdSecCount
#define hdSecCount
Definition: hd.h:37
device_interface::init
int(* init)(void *)
Definition: device.h:55
driveInfo::hdShift
char hdShift
Definition: hd.h:173
driveInfo::hdPort
long hdPort
Definition: hd.h:176
ata_identify_data
Definition: hd.h:300
device_interface::reset
void(* reset)(void *)
Definition: device.h:54
ATA_COMMAND
#define ATA_COMMAND
Definition: hd.h:65
devfs_makeNode
int devfs_makeNode(char *name, uInt8 type, uInt16 major, uInt16 minor)
Definition: devfs.c:174
device_interface::write
int(* write)(void *, void *, uInt32, uInt32)
Definition: device.h:53
driveInfo::lba_start
long lba_start
Definition: hd.h:181
hd.h
inportWord
unsigned short inportWord(unsigned int)
input one word from specified port
Definition: io.c:55
driveInfo::sector_size
uint32_t sector_size
Definition: hd.h:169
bsd_disklabel::d_npartitions
u_int16_t d_npartitions
Definition: hd.h:272
device_interface::read
int(* read)(void *, void *, uInt32, uInt32)
Definition: device.h:52
ATA_DATA
#define ATA_DATA
Definition: hd.h:50
bsd_disklabel::partition::p_fstype
u_int8_t p_fstype
Definition: hd.h:279
devfs.h
name
const char * name
Definition: pci.c:37
driveInfo::parOffset
long parOffset
Definition: hd.h:179
device.h
bsd_disklabel::d_partitions
struct bsd_disklabel::partition d_partitions[8]
driveInfo::lba_end
long lba_end
Definition: hd.h:182
driveInfo::hdCalc
long hdCalc
Definition: hd.h:178
hdCylHi
#define hdCylHi
Definition: hd.h:40
device_interface::info
void * info
Definition: device.h:51
kmalloc
void * kmalloc(uInt32 len)
Definition: kmalloc.c:241
io.h
ata_identify_data::max_48bit_lba
u_int8_t max_48bit_lba[8]
Definition: hd.h:361
hdSecNum
#define hdSecNum
Definition: hd.h:38
uuid
Definition: uuid.h:45
hdHead
#define hdHead
Definition: hd.h:41
device_node::devInfo
struct device_interface * devInfo
Definition: device.h:37
hdCmd
#define hdCmd
Definition: hd.h:43
kprintf
int kprintf(const char *,...)
Definition: kprintf.c:259
device_interface::major
int major
Definition: device.h:50
bsd_disklabel::partition::p_size
uint32_t p_size
Definition: hd.h:276
ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE
#define ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE
Definition: hd.h:46
hdRead
int hdRead(struct driveInfo *hdd, void *baseAddr, uInt32 startSector, uInt32 sectorCount)
Definition: hd.c:423
bsd_disklabel::partition::p_offset
uint32_t p_offset
Definition: hd.h:277
dos_partition::dp_start
uInt32 dp_start
Definition: hd.h:204
driveInfo::hdMask
long hdMask
Definition: hd.h:174
bsd_disklabel
Definition: hd.h:210
kmalloc.h
driveInfo::hdMulti
uint32_t hdMulti
Definition: hd.h:175
ATA_S_BUSY
#define ATA_S_BUSY
Definition: hd.h:95
hdReset
int hdReset()
Definition: hd.c:216
ATA_IDENTIFY
#define ATA_IDENTIFY
Definition: hd.h:112
initHardDisk
int initHardDisk()
Definition: hd.c:42