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