]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h
Isa Floppy driver code scrub.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaFloppyDxe / IsaFloppy.h
... / ...
CommitLineData
1/** @file\r
2 Include file for ISA Floppy Driver\r
3 \r
4Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _ISA_FLOPPY_H_\r
16#define _ISA_FLOPPY_H_\r
17\r
18#include <Uefi.h>\r
19\r
20#include <Protocol/BlockIo.h>\r
21#include <Protocol/IsaIo.h>\r
22#include <Protocol/DevicePath.h>\r
23#include <Guid/StatusCodeDataTypeId.h>\r
24\r
25#include <Library/TimerLib.h>\r
26#include <Library/DebugLib.h>\r
27#include <Library/UefiDriverEntryPoint.h>\r
28#include <Library/BaseLib.h>\r
29#include <Library/UefiLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/MemoryAllocationLib.h>\r
32#include <Library/UefiBootServicesTableLib.h>\r
33#include <Library/ReportStatusCodeLib.h>\r
34#include <Library/PcdLib.h>\r
35\r
36extern EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver;\r
37\r
38#define STALL_1_SECOND 1000000\r
39#define STALL_1_MSECOND 1000\r
40\r
41#define DATA_IN 1\r
42#define DATA_OUT 0\r
43#define READ 0\r
44#define WRITE 1\r
45\r
46//\r
47// Internal Data Structures\r
48//\r
49#define FDC_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('F', 'B', 'I', 'O')\r
50#define FLOPPY_CONTROLLER_CONTEXT_SIGNATURE SIGNATURE_32 ('F', 'D', 'C', 'C')\r
51\r
52typedef enum {\r
53 FdcDisk0 = 0,\r
54 FdcDisk1 = 1,\r
55 FdcMaxDisk = 2\r
56} EFI_FDC_DISK;\r
57\r
58typedef struct {\r
59 UINT32 Signature;\r
60 LIST_ENTRY Link;\r
61 BOOLEAN FddResetPerformed;\r
62 EFI_STATUS FddResetStatus;\r
63 BOOLEAN NeedRecalibrate;\r
64 UINT8 NumberOfDrive;\r
65 UINT16 BaseAddress;\r
66} FLOPPY_CONTROLLER_CONTEXT;\r
67\r
68typedef struct {\r
69 UINTN Signature;\r
70 EFI_HANDLE Handle;\r
71 EFI_BLOCK_IO_PROTOCOL BlkIo;\r
72 EFI_BLOCK_IO_MEDIA BlkMedia;\r
73\r
74 EFI_ISA_IO_PROTOCOL *IsaIo;\r
75\r
76 UINT16 BaseAddress;\r
77\r
78 EFI_FDC_DISK Disk;\r
79 UINT8 PresentCylinderNumber;\r
80 UINT8 *Cache;\r
81\r
82 EFI_EVENT Event;\r
83 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
84 FLOPPY_CONTROLLER_CONTEXT *ControllerState;\r
85\r
86 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
87} FDC_BLK_IO_DEV;\r
88\r
89#include "ComponentName.h"\r
90\r
91#define FDD_BLK_IO_FROM_THIS(a) CR (a, FDC_BLK_IO_DEV, BlkIo, FDC_BLK_IO_DEV_SIGNATURE)\r
92#define FLOPPY_CONTROLLER_FROM_LIST_ENTRY(a) \\r
93 CR (a, \\r
94 FLOPPY_CONTROLLER_CONTEXT, \\r
95 Link, \\r
96 FLOPPY_CONTROLLER_CONTEXT_SIGNATURE \\r
97 )\r
98\r
99#define DISK_1440K_EOT 0x12\r
100#define DISK_1440K_GPL 0x1b\r
101#define DISK_1440K_DTL 0xff\r
102#define DISK_1440K_NUMBER 0x02\r
103#define DISK_1440K_MAXTRACKNUM 0x4f\r
104#define DISK_1440K_BYTEPERSECTOR 512\r
105\r
106typedef struct {\r
107 UINT8 CommandCode;\r
108 UINT8 DiskHeadSel;\r
109 UINT8 Cylinder;\r
110 UINT8 Head;\r
111 UINT8 Sector;\r
112 UINT8 Number;\r
113 UINT8 EndOfTrack;\r
114 UINT8 GapLength;\r
115 UINT8 DataLength;\r
116} FDD_COMMAND_PACKET1;\r
117\r
118typedef struct {\r
119 UINT8 CommandCode;\r
120 UINT8 DiskHeadSel;\r
121} FDD_COMMAND_PACKET2;\r
122\r
123typedef struct {\r
124 UINT8 CommandCode;\r
125 UINT8 SrtHut;\r
126 UINT8 HltNd;\r
127} FDD_SPECIFY_CMD;\r
128\r
129typedef struct {\r
130 UINT8 CommandCode;\r
131 UINT8 DiskHeadSel;\r
132 UINT8 NewCylinder;\r
133} FDD_SEEK_CMD;\r
134\r
135typedef struct {\r
136 UINT8 CommandCode;\r
137 UINT8 DiskHeadSel;\r
138 UINT8 Cylinder;\r
139 UINT8 Head;\r
140 UINT8 Sector;\r
141 UINT8 EndOfTrack;\r
142 UINT8 GapLength;\r
143 UINT8 ScanTestPause;\r
144} FDD_SCAN_CMD;\r
145\r
146typedef struct {\r
147 UINT8 Status0;\r
148 UINT8 Status1;\r
149 UINT8 Status2;\r
150 UINT8 Cylinder;\r
151 UINT8 Head;\r
152 UINT8 Sector;\r
153 UINT8 Number;\r
154} FDD_RESULT_PACKET;\r
155\r
156//\r
157// FDC Registers\r
158//\r
159//\r
160// Digital Output Register address offset\r
161//\r
162#define FDC_REGISTER_DOR 2\r
163\r
164//\r
165// Main Status Register address offset\r
166//\r
167#define FDC_REGISTER_MSR 4\r
168\r
169//\r
170// Data Register address offset\r
171//\r
172#define FDC_REGISTER_DTR 5\r
173\r
174//\r
175// Configuration Control Register(data rate select) address offset\r
176//\r
177#define FDC_REGISTER_CCR 7\r
178\r
179//\r
180// Digital Input Register(diskchange) address offset\r
181//\r
182#define FDC_REGISTER_DIR 7\r
183\r
184\r
185//\r
186// FDC Register Bit Definitions\r
187//\r
188//\r
189// Digital Out Register(WO)\r
190//\r
191//\r
192// Select Drive: 0=A 1=B\r
193//\r
194#define SELECT_DRV BIT0\r
195\r
196//\r
197// Reset FDC\r
198//\r
199#define RESET_FDC BIT2\r
200\r
201//\r
202// Enable Int & DMA\r
203//\r
204#define INT_DMA_ENABLE BIT3\r
205\r
206//\r
207// Turn On Drive A Motor\r
208//\r
209#define DRVA_MOTOR_ON BIT4\r
210\r
211//\r
212// Turn On Drive B Motor\r
213//\r
214#define DRVB_MOTOR_ON BIT5\r
215\r
216//\r
217// Main Status Register(RO)\r
218//\r
219//\r
220// Drive A Busy\r
221//\r
222#define MSR_DAB BIT0\r
223\r
224//\r
225// Drive B Busy\r
226//\r
227#define MSR_DBB BIT1\r
228\r
229//\r
230// FDC Busy\r
231//\r
232#define MSR_CB BIT4\r
233\r
234//\r
235// Non-DMA Mode\r
236//\r
237#define MSR_NDM BIT5\r
238\r
239//\r
240// Data Input/Output\r
241//\r
242#define MSR_DIO BIT6\r
243\r
244//\r
245// Request For Master\r
246//\r
247#define MSR_RQM BIT7\r
248\r
249//\r
250// Configuration Control Register(WO)\r
251//\r
252//\r
253// Data Rate select\r
254//\r
255#define CCR_DRC (BIT0 | BIT1)\r
256\r
257//\r
258// Digital Input Register(RO)\r
259//\r
260//\r
261// Disk change line\r
262//\r
263#define DIR_DCL BIT7\r
264//\r
265// #define CCR_DCL BIT7 // Diskette change\r
266//\r
267// 500K\r
268//\r
269#define DRC_500KBS 0x0\r
270\r
271//\r
272// 300K\r
273//\r
274#define DRC_300KBS 0x01\r
275\r
276//\r
277// 250K\r
278//\r
279#define DRC_250KBS 0x02\r
280\r
281//\r
282// FDC Command Code\r
283//\r
284#define READ_DATA_CMD 0x06\r
285#define WRITE_DATA_CMD 0x05\r
286#define WRITE_DEL_DATA_CMD 0x09\r
287#define READ_DEL_DATA_CMD 0x0C\r
288#define READ_TRACK_CMD 0x02\r
289#define READ_ID_CMD 0x0A\r
290#define FORMAT_TRACK_CMD 0x0D\r
291#define SCAN_EQU_CMD 0x11\r
292#define SCAN_LOW_EQU_CMD 0x19\r
293#define SCAN_HIGH_EQU_CMD 0x1D\r
294#define SEEK_CMD 0x0F\r
295#define RECALIBRATE_CMD 0x07\r
296#define SENSE_INT_STATUS_CMD 0x08\r
297#define SPECIFY_CMD 0x03\r
298#define SENSE_DRV_STATUS_CMD 0x04\r
299\r
300//\r
301// CMD_MT: Multi_Track Selector\r
302// when set , this flag selects the multi-track operating mode.\r
303// In this mode, the FDC treats a complete cylinder under head0 and 1\r
304// as a single track\r
305//\r
306#define CMD_MT BIT7\r
307\r
308//\r
309// CMD_MFM: MFM/FM Mode Selector\r
310// A one selects the double density(MFM) mode\r
311// A zero selects single density (FM) mode\r
312//\r
313#define CMD_MFM BIT6\r
314\r
315//\r
316// CMD_SK: Skip Flag\r
317// When set to 1, sectors containing a deleted data address mark will\r
318// automatically be skipped during the execution of Read Data.\r
319// When set to 0, the sector is read or written the same as the read and\r
320// write commands.\r
321//\r
322#define CMD_SK BIT5\r
323\r
324//\r
325// FDC Status Register Bit Definitions\r
326//\r
327//\r
328// Status Register 0\r
329//\r
330//\r
331// Interrupt Code\r
332//\r
333#define STS0_IC (BIT7 | BIT6)\r
334\r
335//\r
336// Seek End: the FDC completed a seek or recalibrate command\r
337//\r
338#define STS0_SE BIT5\r
339\r
340//\r
341// Equipment Check\r
342//\r
343#define STS0_EC BIT4\r
344\r
345//\r
346// Not Ready(unused), this bit is always 0\r
347//\r
348#define STS0_NR BIT3\r
349\r
350//\r
351// Head Address: the current head address\r
352//\r
353#define STS0_HA BIT2\r
354\r
355//\r
356// STS0_US1 & STS0_US0: Drive Select(the current selected drive)\r
357//\r
358//\r
359// Unit Select1\r
360//\r
361#define STS0_US1 BIT1\r
362\r
363//\r
364// Unit Select0\r
365//\r
366#define STS0_US0 BIT0\r
367\r
368//\r
369// Status Register 1\r
370//\r
371//\r
372// End of Cylinder\r
373//\r
374#define STS1_EN BIT7\r
375\r
376//\r
377// BIT6 is unused\r
378//\r
379//\r
380// Data Error: The FDC detected a CRC error in either the ID field or\r
381// data field of a sector\r
382//\r
383#define STS1_DE BIT5\r
384\r
385//\r
386// Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service\r
387// within the required time interval\r
388//\r
389#define STS1_OR BIT4\r
390\r
391//\r
392// BIT3 is unused\r
393//\r
394//\r
395// No data\r
396//\r
397#define STS1_ND BIT2\r
398\r
399//\r
400// Not Writable\r
401//\r
402#define STS1_NW BIT1\r
403\r
404//\r
405// Missing Address Mark\r
406//\r
407#define STS1_MA BIT0\r
408\r
409//\r
410// Control Mark\r
411//\r
412#define STS2_CM BIT6\r
413\r
414//\r
415// Data Error in Data Field: The FDC detected a CRC error in the data field\r
416//\r
417#define STS2_DD BIT5\r
418\r
419//\r
420// Wrong Cylinder: The track address from sector ID field is different from\r
421// the track address maintained inside FDC\r
422//\r
423#define STS2_WC BIT4\r
424\r
425//\r
426// Bad Cylinder\r
427//\r
428#define STS2_BC BIT1\r
429\r
430//\r
431// Missing Address Mark in Data Field\r
432//\r
433#define STS2_MD BIT0\r
434\r
435//\r
436// Write Protected\r
437//\r
438#define STS3_WP BIT6\r
439\r
440//\r
441// Track 0\r
442//\r
443#define STS3_T0 BIT4\r
444\r
445//\r
446// Head Address\r
447//\r
448#define STS3_HD BIT2\r
449\r
450//\r
451// STS3_US1 & STS3_US0 : Drive Select\r
452//\r
453#define STS3_US1 BIT1\r
454#define STS3_US0 BIT0\r
455\r
456//\r
457// Status Register 0 Interrupt Code Description\r
458//\r
459//\r
460// Normal Termination of Command\r
461//\r
462#define IC_NT 0x0\r
463\r
464//\r
465// Abnormal Termination of Command\r
466//\r
467#define IC_AT 0x40\r
468\r
469//\r
470// Invalid Command\r
471//\r
472#define IC_IC 0x80\r
473\r
474//\r
475// Abnormal Termination caused by Polling\r
476//\r
477#define IC_ATRC 0xC0\r
478\r
479//\r
480// EFI Driver Binding Protocol Functions\r
481//\r
482\r
483/**\r
484 Test controller is a floppy disk drive device\r
485 \r
486 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. \r
487 @param[in] Controller The handle of the controller to test.\r
488 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.\r
489 \r
490 @retval EFI_SUCCESS The device is supported by this driver.\r
491 @retval EFI_ALREADY_STARTED The device is already being managed by this driver.\r
492 @retval EFI_ACCESS_DENIED The device is already being managed by a different driver \r
493 or an application that requires exclusive access.\r
494**/\r
495EFI_STATUS\r
496EFIAPI\r
497FdcControllerDriverSupported (\r
498 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
499 IN EFI_HANDLE Controller,\r
500 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
501 );\r
502\r
503/**\r
504 Start this driver on Controller.\r
505\r
506 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
507 @param[in] ControllerHandle The handle of the controller to start. This handle \r
508 must support a protocol interface that supplies \r
509 an I/O abstraction to the driver.\r
510 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. \r
511 This parameter is ignored by device drivers, and is optional for bus drivers.\r
512\r
513 @retval EFI_SUCCESS The device was started.\r
514 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.\r
515 Currently not implemented.\r
516 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
517 @retval Others The driver failded to start the device.\r
518**/\r
519EFI_STATUS\r
520EFIAPI\r
521FdcControllerDriverStart (\r
522 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
523 IN EFI_HANDLE Controller,\r
524 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
525 );\r
526\r
527/**\r
528 Stop this driver on ControllerHandle.\r
529\r
530 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
531 @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
532 support a bus specific I/O protocol for the driver \r
533 to use to stop the device.\r
534 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
535 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
536 if NumberOfChildren is 0.\r
537\r
538 @retval EFI_SUCCESS The device was stopped.\r
539 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
540**/\r
541EFI_STATUS\r
542EFIAPI\r
543FdcControllerDriverStop (\r
544 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
545 IN EFI_HANDLE Controller,\r
546 IN UINTN NumberOfChildren,\r
547 IN EFI_HANDLE *ChildHandleBuffer\r
548 );\r
549\r
550//\r
551// EFI Block I/O Protocol Functions\r
552//\r
553\r
554/**\r
555 Reset the Floppy Logic Drive, call the FddReset function. \r
556 \r
557 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
558 @param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more \r
559 exhaustive verification operation of the device during \r
560 reset, now this par is ignored in this driver \r
561 @retval EFI_SUCCESS: The Floppy Logic Drive is reset\r
562 @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly \r
563 and can not be reset\r
564\r
565**/\r
566EFI_STATUS\r
567EFIAPI\r
568FdcReset (\r
569 IN EFI_BLOCK_IO_PROTOCOL *This,\r
570 IN BOOLEAN ExtendedVerification\r
571 );\r
572\r
573/**\r
574 Flush block via fdd controller.\r
575 \r
576 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
577 @return EFI_SUCCESS\r
578\r
579**/\r
580EFI_STATUS\r
581EFIAPI\r
582FddFlushBlocks (\r
583 IN EFI_BLOCK_IO_PROTOCOL *This\r
584 );\r
585\r
586/**\r
587 Read the requested number of blocks from the device. \r
588 \r
589 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
590 @param MediaId UINT32: The media id that the read request is for \r
591 @param Lba EFI_LBA: The starting logic block address to read from on the device\r
592 @param BufferSize UINTN: The size of the Buffer in bytes\r
593 @param Buffer VOID *: A pointer to the destination buffer for the data\r
594 \r
595 @retval EFI_SUCCESS: The data was read correctly from the device\r
596 @retval EFI_DEVICE_ERROR:The device reported an error while attempting to perform\r
597 the read operation\r
598 @retval EFI_NO_MEDIA: There is no media in the device\r
599 @retval EFI_MEDIA_CHANGED: The MediaId is not for the current media\r
600 @retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
601 intrinsic block size of the device\r
602 @retval EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid, \r
603 or the buffer is not on proper alignment \r
604\r
605**/\r
606EFI_STATUS\r
607EFIAPI\r
608FddReadBlocks (\r
609 IN EFI_BLOCK_IO_PROTOCOL *This,\r
610 IN UINT32 MediaId,\r
611 IN EFI_LBA Lba,\r
612 IN UINTN BufferSize,\r
613 OUT VOID *Buffer\r
614 );\r
615\r
616/**\r
617 Write a specified number of blocks to the device. \r
618 \r
619 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
620 @param MediaId UINT32: The media id that the write request is for \r
621 @param Lba EFI_LBA: The starting logic block address to be written\r
622 @param BufferSize UINTN: The size in bytes in Buffer\r
623 @param Buffer VOID *: A pointer to the source buffer for the data\r
624 \r
625 @retval EFI_SUCCESS: The data were written correctly to the device\r
626 @retval EFI_WRITE_PROTECTED: The device can not be written to \r
627 @retval EFI_NO_MEDIA: There is no media in the device\r
628 @retval EFI_MEDIA_CHANGED: The MediaId is not for the current media\r
629 @retval EFI_DEVICE_ERROR: The device reported an error while attempting to perform \r
630 the write operation \r
631 @retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
632 intrinsic block size of the device\r
633 @retval EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid, \r
634 or the buffer is not on proper alignment \r
635**/\r
636EFI_STATUS\r
637EFIAPI\r
638FddWriteBlocks (\r
639 IN EFI_BLOCK_IO_PROTOCOL *This,\r
640 IN UINT32 MediaId,\r
641 IN EFI_LBA Lba,\r
642 IN UINTN BufferSize,\r
643 IN VOID *Buffer\r
644 );\r
645\r
646//\r
647// Prototypes of internal functions\r
648//\r
649/**\r
650\r
651 Detect the floppy drive is presented or not.\r
652 \r
653 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
654 @retval EFI_SUCCESS Drive is presented\r
655 @retval EFI_NOT_FOUND Drive is not presented\r
656\r
657**/\r
658EFI_STATUS\r
659DiscoverFddDevice (\r
660 IN FDC_BLK_IO_DEV *FdcDev\r
661 );\r
662\r
663/**\r
664\r
665 Do recalibrate and see the drive is presented or not.\r
666 Set the media parameters.\r
667 \r
668 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
669 @return the drive is presented or not\r
670\r
671**/\r
672EFI_STATUS\r
673FddIdentify (\r
674 IN FDC_BLK_IO_DEV *FdcDev\r
675 );\r
676\r
677/**\r
678\r
679 Reset the Floppy Logic Drive.\r
680 \r
681 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
682 \r
683 @retval EFI_SUCCESS: The Floppy Logic Drive is reset\r
684 @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and\r
685 can not be reset\r
686\r
687**/\r
688EFI_STATUS\r
689FddReset (\r
690 IN FDC_BLK_IO_DEV *FdcDev\r
691 );\r
692\r
693/**\r
694\r
695 Turn the drive's motor on.\r
696 The drive's motor must be on before any command can be executed.\r
697 \r
698 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
699 \r
700 @retval EFI_SUCCESS: Turn the drive's motor on successfully\r
701 @retval EFI_DEVICE_ERROR: The drive is busy, so can not turn motor on\r
702 @retval EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)\r
703\r
704**/\r
705EFI_STATUS\r
706MotorOn (\r
707 IN FDC_BLK_IO_DEV *FdcDev\r
708 );\r
709\r
710/**\r
711\r
712 Set a Timer and when Timer goes off, turn the motor off.\r
713 \r
714 \r
715 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
716 \r
717 @retval EFI_SUCCESS: Set the Timer successfully\r
718 @retval EFI_INVALID_PARAMETER: Fail to Set the timer\r
719\r
720**/\r
721EFI_STATUS\r
722MotorOff (\r
723 IN FDC_BLK_IO_DEV *FdcDev\r
724 );\r
725\r
726/**\r
727 Detect the disk in the drive is changed or not.\r
728 \r
729 \r
730 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
731 \r
732 @retval EFI_SUCCESS: No disk media change\r
733 @retval EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation\r
734 @retval EFI_NO_MEDIA: No disk in the drive\r
735 @retval EFI_MEDIA_CHANGED: There is a new disk in the drive\r
736**/\r
737EFI_STATUS\r
738DisketChanged (\r
739 IN FDC_BLK_IO_DEV *FdcDev\r
740 );\r
741\r
742/**\r
743 Do the Specify command, this command sets DMA operation\r
744 and the initial values for each of the three internal\r
745 times: HUT, SRT and HLT.\r
746 \r
747 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
748 \r
749 @retval EFI_SUCCESS: Execute the Specify command successfully\r
750 @retval EFI_DEVICE_ERROR: Fail to execute the command\r
751\r
752**/\r
753EFI_STATUS\r
754Specify (\r
755 IN FDC_BLK_IO_DEV *FdcDev\r
756 );\r
757\r
758/**\r
759 Set the head of floppy drive to track 0.\r
760 \r
761 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
762 @retval EFI_SUCCESS: Execute the Recalibrate operation successfully\r
763 @retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation\r
764\r
765**/\r
766EFI_STATUS\r
767Recalibrate (\r
768 IN FDC_BLK_IO_DEV *FdcDev\r
769 );\r
770\r
771/**\r
772 Set the head of floppy drive to the new cylinder.\r
773 \r
774 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
775 @param Lba EFI_LBA : The logic block address want to seek\r
776 \r
777 @retval EFI_SUCCESS: Execute the Seek operation successfully\r
778 @retval EFI_DEVICE_ERROR: Fail to execute the Seek operation\r
779\r
780**/\r
781EFI_STATUS\r
782Seek (\r
783 IN FDC_BLK_IO_DEV *FdcDev,\r
784 IN EFI_LBA Lba\r
785 );\r
786\r
787/**\r
788 Do the Sense Interrupt Status command, this command resets the interrupt signal.\r
789 \r
790 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
791 @param StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC\r
792 @param PresentCylinderNumber UINT8 *: Be used to save present cylinder number\r
793 read from FDC\r
794 \r
795 @retval EFI_SUCCESS: Execute the Sense Interrupt Status command successfully\r
796 @retval EFI_DEVICE_ERROR: Fail to execute the command\r
797\r
798**/\r
799EFI_STATUS\r
800SenseIntStatus (\r
801 IN FDC_BLK_IO_DEV *FdcDev,\r
802 IN OUT UINT8 *StatusRegister0,\r
803 IN OUT UINT8 *PresentCylinderNumber\r
804 );\r
805\r
806/**\r
807 Do the Sense Drive Status command.\r
808 \r
809 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
810 @param Lba EFI_LBA : Logic block address\r
811 \r
812 @retval EFI_SUCCESS: Execute the Sense Drive Status command successfully\r
813 @retval EFI_DEVICE_ERROR: Fail to execute the command\r
814 @retval EFI_WRITE_PROTECTED:The disk is write protected\r
815\r
816**/\r
817EFI_STATUS\r
818SenseDrvStatus (\r
819 IN FDC_BLK_IO_DEV *FdcDev,\r
820 IN EFI_LBA Lba\r
821 );\r
822\r
823/**\r
824 Update the disk media properties and if necessary reinstall Block I/O interface.\r
825 \r
826 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
827 \r
828 @retval EFI_SUCCESS: Do the operation successfully\r
829 @retval EFI_DEVICE_ERROR: Fail to the operation\r
830\r
831**/\r
832EFI_STATUS\r
833DetectMedia (\r
834 IN FDC_BLK_IO_DEV *FdcDev\r
835 );\r
836\r
837/**\r
838 Set the data rate and so on.\r
839 \r
840 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
841\r
842 @retval EFI_SUCCESS success to set the data rate\r
843**/\r
844EFI_STATUS\r
845Setup (\r
846 IN FDC_BLK_IO_DEV *FdcDev\r
847 );\r
848\r
849/**\r
850 Read or Write a number of blocks in the same cylinder.\r
851 \r
852 @param FdcDev A pointer to Data Structure FDC_BLK_IO_DEV\r
853 @param HostAddress device address \r
854 @param Lba The starting logic block address to read from on the device\r
855 @param NumberOfBlocks The number of block wanted to be read or write\r
856 @param Read Operation type: read or write\r
857 \r
858 @retval EFI_SUCCESS Success operate\r
859\r
860**/\r
861EFI_STATUS\r
862ReadWriteDataSector (\r
863 IN FDC_BLK_IO_DEV *FdcDev,\r
864 IN VOID *HostAddress,\r
865 IN EFI_LBA Lba,\r
866 IN UINTN NumberOfBlocks,\r
867 IN BOOLEAN Read\r
868 );\r
869\r
870/**\r
871 Fill in FDD command's parameter.\r
872 \r
873 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
874 @param Lba The starting logic block address to read from on the device\r
875 @param Command FDD command\r
876\r
877**/\r
878VOID\r
879FillPara (\r
880 IN FDC_BLK_IO_DEV *FdcDev,\r
881 IN EFI_LBA Lba,\r
882 IN FDD_COMMAND_PACKET1 *Command\r
883 );\r
884\r
885/**\r
886 Read result byte from Data Register of FDC.\r
887 \r
888 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
889 @param Pointer Buffer to store the byte read from FDC\r
890 \r
891 @retval EFI_SUCCESS Read result byte from FDC successfully\r
892 @retval EFI_DEVICE_ERROR The FDC is not ready to be read\r
893\r
894**/\r
895EFI_STATUS\r
896DataInByte (\r
897 IN FDC_BLK_IO_DEV *FdcDev,\r
898 OUT UINT8 *Pointer\r
899 );\r
900\r
901/**\r
902 Write command byte to Data Register of FDC.\r
903 \r
904 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
905 @param Pointer Be used to save command byte written to FDC\r
906 \r
907 @retval EFI_SUCCESS: Write command byte to FDC successfully\r
908 @retval EFI_DEVICE_ERROR: The FDC is not ready to be written\r
909\r
910**/\r
911EFI_STATUS\r
912DataOutByte (\r
913 IN FDC_BLK_IO_DEV *FdcDev,\r
914 IN UINT8 *Pointer\r
915 );\r
916\r
917/**\r
918 Detect the specified floppy logic drive is busy or not within a period of time.\r
919 \r
920 @param FdcDev Indicate it is drive A or drive B\r
921 @param TimeoutInSeconds the time period for waiting\r
922 \r
923 @retval EFI_SUCCESS: The drive and command are not busy\r
924 @retval EFI_TIMEOUT: The drive or command is still busy after a period time that\r
925 set by TimeoutInSeconds\r
926\r
927**/\r
928EFI_STATUS\r
929FddWaitForBSYClear (\r
930 IN FDC_BLK_IO_DEV *FdcDev,\r
931 IN UINTN TimeoutInSeconds\r
932 );\r
933\r
934/**\r
935 Determine whether FDC is ready to write or read.\r
936 \r
937 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
938 @param Dio BOOLEAN: Indicate the FDC is waiting to write or read\r
939 @param TimeoutInSeconds UINTN: The time period for waiting\r
940 \r
941 @retval EFI_SUCCESS: FDC is ready to write or read\r
942 @retval EFI_NOT_READY: FDC is not ready within the specified time period\r
943\r
944**/\r
945EFI_STATUS\r
946FddDRQReady (\r
947 IN FDC_BLK_IO_DEV *FdcDev,\r
948 IN BOOLEAN Dio,\r
949 IN UINTN TimeoutInSeconds\r
950 );\r
951\r
952/**\r
953 Set FDC control structure's attribute according to result.\r
954\r
955 @param Result Point to result structure\r
956 @param FdcDev FDC control structure\r
957\r
958 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
959 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
960 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
961 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
962\r
963**/\r
964EFI_STATUS\r
965CheckResult (\r
966 IN FDD_RESULT_PACKET *Result,\r
967 IN OUT FDC_BLK_IO_DEV *FdcDev\r
968 );\r
969\r
970/**\r
971 Check the drive status information.\r
972 \r
973 @param StatusRegister3 the value of Status Register 3\r
974 \r
975 @retval EFI_SUCCESS The disk is not write protected\r
976 @retval EFI_WRITE_PROTECTED: The disk is write protected\r
977\r
978**/\r
979EFI_STATUS\r
980CheckStatus3 (\r
981 IN UINT8 StatusRegister3\r
982 );\r
983\r
984/**\r
985 Calculate the number of block in the same cylinder according to Lba.\r
986 \r
987 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
988 @param Lba EFI_LBA: The starting logic block address\r
989 @param NumberOfBlocks UINTN: The number of blocks\r
990 \r
991 @return The number of blocks in the same cylinder which the starting\r
992 logic block address is Lba\r
993\r
994**/\r
995UINTN\r
996GetTransferBlockCount (\r
997 IN FDC_BLK_IO_DEV *FdcDev,\r
998 IN EFI_LBA Lba,\r
999 IN UINTN NumberOfBlocks\r
1000 );\r
1001\r
1002/**\r
1003 When the Timer(2s) off, turn the drive's motor off.\r
1004 \r
1005 @param Event EFI_EVENT: Event(the timer) whose notification function is being\r
1006 invoked\r
1007 @param Context VOID *: Pointer to the notification function's context\r
1008\r
1009**/\r
1010VOID\r
1011EFIAPI\r
1012FddTimerProc (\r
1013 IN EFI_EVENT Event,\r
1014 IN VOID *Context\r
1015 );\r
1016\r
1017/**\r
1018 Read I/O port for FDC.\r
1019 \r
1020 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
1021 @param Offset The offset address of port\r
1022\r
1023**/\r
1024UINT8\r
1025FdcReadPort (\r
1026 IN FDC_BLK_IO_DEV *FdcDev,\r
1027 IN UINT32 Offset\r
1028 );\r
1029\r
1030/**\r
1031 Write I/O port for FDC.\r
1032 \r
1033 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
1034 @param Offset The offset address of port\r
1035 @param Data Value written to port\r
1036 \r
1037**/\r
1038VOID\r
1039FdcWritePort (\r
1040 IN FDC_BLK_IO_DEV *FdcDev,\r
1041 IN UINT32 Offset,\r
1042 IN UINT8 Data\r
1043 );\r
1044\r
1045/**\r
1046 Read or Write a number of blocks to floppy device.\r
1047\r
1048 @param This Pointer to instance of EFI_BLOCK_IO_PROTOCOL\r
1049 @param MediaId The media id of read/write request\r
1050 @param Lba The starting logic block address to read from on the device\r
1051 @param BufferSize The size of the Buffer in bytes\r
1052 @param Operation - GC_TODO: add argument description\r
1053 @param Buffer - GC_TODO: add argument description\r
1054\r
1055 @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
1056 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
1057 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1058 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1059 @retval EFI_NO_MEDIA - GC_TODO: Add description for return value\r
1060 @retval EFI_MEDIA_CHANGED - GC_TODO: Add description for return value\r
1061 @retval EFI_WRITE_PROTECTED - GC_TODO: Add description for return value\r
1062 @retval EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value\r
1063 @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
1064 @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
1065 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
1066 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1067 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1068 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
1069\r
1070**/\r
1071EFI_STATUS\r
1072FddReadWriteBlocks (\r
1073 IN EFI_BLOCK_IO_PROTOCOL *This,\r
1074 IN UINT32 MediaId,\r
1075 IN EFI_LBA Lba,\r
1076 IN UINTN BufferSize,\r
1077 IN BOOLEAN Operation,\r
1078 OUT VOID *Buffer\r
1079 );\r
1080\r
1081/**\r
1082 Common interface for free cache. \r
1083 \r
1084 @param FdcDev Pointer of FDC_BLK_IO_DEV instance\r
1085 \r
1086**/\r
1087VOID\r
1088FdcFreeCache (\r
1089 IN FDC_BLK_IO_DEV *FdcDev\r
1090 );\r
1091\r
1092#endif\r
1093\r