]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h
Update prototype of DxeLoadCore().
[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
511 )\r
11f43dfd 512;\r
513\r
bcd70414 514/**\r
515 Create floppy control instance on controller.\r
516 \r
517 @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
518 @param Controller driver controller handle\r
519 @param RemainingDevicePath Children's device path\r
520 \r
521 @retval whether success to create floppy control instance.\r
522**/\r
11f43dfd 523EFI_STATUS\r
524EFIAPI\r
525FdcControllerDriverStart (\r
526 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
527 IN EFI_HANDLE Controller,\r
528 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
529 )\r
bcd70414 530;\r
11f43dfd 531\r
bcd70414 532/**\r
533 Stop this driver on ControllerHandle. Support stoping any child handles\r
534 created by this driver.\r
11f43dfd 535\r
bcd70414 536 @param This Protocol instance pointer.\r
fdb05fa3 537 @param Controller Handle of device to stop driver on\r
bcd70414 538 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
539 children is zero stop the entire bus driver.\r
540 @param ChildHandleBuffer List of Child Handles to Stop.\r
11f43dfd 541\r
bcd70414 542 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
543 @retval other This driver was not removed from this device\r
11f43dfd 544\r
bcd70414 545**/\r
11f43dfd 546EFI_STATUS\r
547EFIAPI\r
548FdcControllerDriverStop (\r
549 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
550 IN EFI_HANDLE Controller,\r
551 IN UINTN NumberOfChildren,\r
552 IN EFI_HANDLE *ChildHandleBuffer\r
553 )\r
11f43dfd 554;\r
555\r
556//\r
557// EFI Block I/O Protocol Functions\r
558//\r
bcd70414 559/**\r
560 Reset the Floppy Logic Drive, call the FddReset function \r
561 \r
562 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
563 @param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more \r
564 exhaustive verification operation of the device during \r
565 reset, now this par is ignored in this driver \r
566 @retval EFI_SUCCESS: The Floppy Logic Drive is reset\r
567 @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly \r
568 and can not be reset\r
569\r
570**/\r
11f43dfd 571EFI_STATUS\r
572EFIAPI\r
573FdcReset (\r
574 IN EFI_BLOCK_IO_PROTOCOL *This,\r
575 IN BOOLEAN ExtendedVerification\r
576 )\r
11f43dfd 577;\r
578\r
bcd70414 579/**\r
580 Flush block via fdd controller\r
581 \r
582 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
583 @return EFI_SUCCESS\r
584\r
585**/\r
11f43dfd 586EFI_STATUS\r
587EFIAPI\r
588FddFlushBlocks (\r
589 IN EFI_BLOCK_IO_PROTOCOL *This\r
590 )\r
11f43dfd 591;\r
592\r
bcd70414 593/**\r
594 Read the requested number of blocks from the device \r
595 \r
596 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
597 @param MediaId UINT32: The media id that the read request is for \r
598 @param LBA EFI_LBA: The starting logic block address to read from on the device\r
599 @param BufferSize UINTN: The size of the Buffer in bytes\r
600 @param Buffer VOID *: A pointer to the destination buffer for the data\r
601 \r
602 @retval EFI_SUCCESS: The data was read correctly from the device\r
603 @retval EFI_DEVICE_ERROR:The device reported an error while attempting to perform\r
604 the read operation\r
605 @retval EFI_NO_MEDIA: There is no media in the device\r
606 @retval EFI_MEDIA_CHANGED: The MediaId is not for the current media\r
607 @retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
608 intrinsic block size of the device\r
609 @retval EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid, \r
610 or the buffer is not on proper alignment \r
611\r
612**/\r
11f43dfd 613EFI_STATUS\r
614EFIAPI\r
615FddReadBlocks (\r
616 IN EFI_BLOCK_IO_PROTOCOL *This,\r
617 IN UINT32 MediaId,\r
618 IN EFI_LBA LBA,\r
619 IN UINTN BufferSize,\r
620 OUT VOID *Buffer\r
621 )\r
11f43dfd 622;\r
623\r
bcd70414 624/**\r
625 Write a specified number of blocks to the device \r
626 \r
627 @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface\r
628 @param MediaId UINT32: The media id that the write request is for \r
629 @param LBA EFI_LBA: The starting logic block address to be written\r
630 @param BufferSize UINTN: The size in bytes in Buffer\r
631 @param Buffer VOID *: A pointer to the source buffer for the data\r
632 \r
633 @retval EFI_SUCCESS: The data were written correctly to the device\r
634 @retval EFI_WRITE_PROTECTED: The device can not be written to \r
635 @retval EFI_NO_MEDIA: There is no media in the device\r
636 @retval EFI_MEDIA_CHANGED: The MediaId is not for the current media\r
637 @retval EFI_DEVICE_ERROR: The device reported an error while attempting to perform \r
638 the write operation \r
639 @retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the \r
640 intrinsic block size of the device\r
641 @retval EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid, \r
642 or the buffer is not on proper alignment \r
643**/\r
11f43dfd 644EFI_STATUS\r
645EFIAPI\r
646FddWriteBlocks (\r
647 IN EFI_BLOCK_IO_PROTOCOL *This,\r
648 IN UINT32 MediaId,\r
649 IN EFI_LBA LBA,\r
650 IN UINTN BufferSize,\r
651 IN VOID *Buffer\r
652 )\r
11f43dfd 653;\r
654\r
655//\r
656// Prototypes of internal functions\r
657//\r
bcd70414 658/**\r
659\r
660 Detect the floppy drive is presented or not\r
661 \r
662 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
663 @retval EFI_SUCCESS Drive is presented\r
664 @retval EFI_NOT_FOUND Drive is not presented\r
665\r
666**/\r
11f43dfd 667EFI_STATUS\r
668DiscoverFddDevice (\r
669 IN FDC_BLK_IO_DEV *FdcDev\r
670 )\r
bcd70414 671;\r
11f43dfd 672\r
bcd70414 673/**\r
11f43dfd 674\r
bcd70414 675 Do recalibrate and see the drive is presented or not\r
676 Set the media parameters\r
677 \r
678 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
679 @return the drive is presented or not\r
11f43dfd 680\r
bcd70414 681**/\r
11f43dfd 682EFI_STATUS\r
683FddIdentify (\r
684 IN FDC_BLK_IO_DEV *FdcDev\r
685 )\r
bcd70414 686;\r
11f43dfd 687\r
bcd70414 688/**\r
11f43dfd 689\r
bcd70414 690 Reset the Floppy Logic Drive\r
691 \r
692 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
693 \r
694 @retval EFI_SUCCESS: The Floppy Logic Drive is reset\r
695 @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and\r
696 can not be reset\r
11f43dfd 697\r
bcd70414 698**/\r
11f43dfd 699EFI_STATUS\r
700FddReset (\r
701 IN FDC_BLK_IO_DEV *FdcDev\r
702 )\r
bcd70414 703;\r
11f43dfd 704\r
bcd70414 705/**\r
11f43dfd 706\r
bcd70414 707 Turn the drive's motor on\r
708 The drive's motor must be on before any command can be executed\r
709 \r
710 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
711 \r
712 @retval EFI_SUCCESS: Turn the drive's motor on successfully\r
713 @retval EFI_DEVICE_ERROR: The drive is busy, so can not turn motor on\r
714 @retval EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)\r
11f43dfd 715\r
bcd70414 716**/\r
11f43dfd 717EFI_STATUS\r
718MotorOn (\r
719 IN FDC_BLK_IO_DEV *FdcDev\r
720 )\r
bcd70414 721;\r
11f43dfd 722\r
bcd70414 723/**\r
11f43dfd 724\r
bcd70414 725 Set a Timer and when Timer goes off, turn the motor off\r
726 \r
727 \r
728 @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV\r
729 \r
730 @retval EFI_SUCCESS: Set the Timer successfully\r
731 @retval EFI_INVALID_PARAMETER: Fail to Set the timer\r
11f43dfd 732\r
bcd70414 733**/\r
11f43dfd 734EFI_STATUS\r
735MotorOff (\r
736 IN FDC_BLK_IO_DEV *FdcDev\r
737 )\r
11f43dfd 738;\r
739\r
bcd70414 740/**\r
741 Detect the disk in the drive is changed or not\r
742 \r
743 \r
744 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
745 \r
746 @retval EFI_SUCCESS: No disk media change\r
747 @retval EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation\r
748 @retval EFI_NO_MEDIA: No disk in the drive\r
749 @retval EFI_MEDIA_CHANGED: There is a new disk in the drive\r
750**/\r
11f43dfd 751EFI_STATUS\r
752DisketChanged (\r
753 IN FDC_BLK_IO_DEV *FdcDev\r
754 )\r
11f43dfd 755;\r
756\r
bcd70414 757/**\r
758 Do the Specify command, this command sets DMA operation\r
759 and the initial values for each of the three internal\r
760 times: HUT, SRT and HLT\r
761 \r
fdb05fa3 762 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
bcd70414 763 \r
764 @retval EFI_SUCCESS: Execute the Specify command successfully\r
765 @retval EFI_DEVICE_ERROR: Fail to execute the command\r
766\r
767**/\r
11f43dfd 768EFI_STATUS\r
769Specify (\r
770 IN FDC_BLK_IO_DEV *FdcDev\r
771 )\r
11f43dfd 772;\r
773\r
bcd70414 774/**\r
775 Set the head of floppy drive to track 0\r
776 \r
777 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
778 @retval EFI_SUCCESS: Execute the Recalibrate operation successfully\r
779 @retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation\r
780\r
781**/\r
11f43dfd 782EFI_STATUS\r
783Recalibrate (\r
784 IN FDC_BLK_IO_DEV *FdcDev\r
785 )\r
11f43dfd 786;\r
787\r
bcd70414 788/**\r
789 Set the head of floppy drive to the new cylinder\r
790 \r
791 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
792 @param Lba EFI_LBA : The logic block address want to seek\r
793 \r
794 @retval EFI_SUCCESS: Execute the Seek operation successfully\r
795 @retval EFI_DEVICE_ERROR: Fail to execute the Seek operation\r
796\r
797**/\r
11f43dfd 798EFI_STATUS\r
799Seek (\r
800 IN FDC_BLK_IO_DEV *FdcDev,\r
801 IN EFI_LBA Lba\r
802 )\r
11f43dfd 803;\r
804\r
bcd70414 805/**\r
806 Do the Sense Interrupt Status command, this command\r
807 resets the interrupt signal\r
808 \r
fdb05fa3 809 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
bcd70414 810 @param StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC\r
811 @param PresentCylinderNumber UINT8 *: Be used to save present cylinder number\r
812 read from FDC\r
813 \r
814 @retval EFI_SUCCESS: Execute the Sense Interrupt Status command successfully\r
815 @retval EFI_DEVICE_ERROR: Fail to execute the command\r
816\r
817**/\r
11f43dfd 818EFI_STATUS\r
819SenseIntStatus (\r
820 IN FDC_BLK_IO_DEV *FdcDev,\r
821 IN OUT UINT8 *StatusRegister0,\r
822 IN OUT UINT8 *PresentCylinderNumber\r
823 )\r
11f43dfd 824;\r
825\r
bcd70414 826/**\r
827 Do the Sense Drive Status command\r
828 \r
829 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
830 @param Lba EFI_LBA : Logic block address\r
831 \r
832 @retval EFI_SUCCESS: Execute the Sense Drive Status command successfully\r
833 @retval EFI_DEVICE_ERROR: Fail to execute the command\r
834 @retval EFI_WRITE_PROTECTED:The disk is write protected\r
835\r
836**/\r
11f43dfd 837EFI_STATUS\r
838SenseDrvStatus (\r
839 IN FDC_BLK_IO_DEV *FdcDev,\r
840 IN EFI_LBA Lba\r
841 )\r
11f43dfd 842;\r
843\r
bcd70414 844/**\r
845 Update the disk media properties and if necessary\r
846 reinstall Block I/O interface\r
847 \r
848 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
849 \r
850 @retval EFI_SUCCESS: Do the operation successfully\r
851 @retval EFI_DEVICE_ERROR: Fail to the operation\r
852\r
853**/\r
11f43dfd 854EFI_STATUS\r
855DetectMedia (\r
856 IN FDC_BLK_IO_DEV *FdcDev\r
857 )\r
11f43dfd 858;\r
859\r
bcd70414 860/**\r
861 Set the data rate and so on\r
862 \r
863 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
864\r
865 @retval EFI_SUCCESS success to set the data rate\r
866**/\r
11f43dfd 867EFI_STATUS\r
868Setup (\r
869 IN FDC_BLK_IO_DEV *FdcDev\r
870 )\r
11f43dfd 871;\r
872\r
bcd70414 873/**\r
874 Read or Write a number of blocks in the same cylinder\r
875 \r
876 @param FdcDev A pointer to Data Structure FDC_BLK_IO_DEV\r
877 @param HostAddress device address \r
878 @param Lba The starting logic block address to read from on the device\r
879 @param NumberOfBlocks The number of block wanted to be read or write\r
880 @param Read Operation type: read or write\r
881 \r
882 @retval EFI_SUCCESS Success operate\r
883\r
884**/\r
11f43dfd 885EFI_STATUS\r
886ReadWriteDataSector (\r
887 IN FDC_BLK_IO_DEV *FdcDev,\r
888 IN VOID *HostAddress,\r
889 IN EFI_LBA Lba,\r
890 IN UINTN NumberOfBlocks,\r
891 IN BOOLEAN Read\r
892 )\r
11f43dfd 893;\r
894\r
bcd70414 895/**\r
896 Fill in FDD command's parameter\r
897 \r
898 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
899 @param Lba The starting logic block address to read from on the device\r
900 @param Command FDD command\r
901\r
902**/\r
11f43dfd 903VOID\r
904FillPara (\r
905 IN FDC_BLK_IO_DEV *FdcDev,\r
906 IN EFI_LBA Lba,\r
907 IN FDD_COMMAND_PACKET1 *Command\r
908 )\r
11f43dfd 909;\r
910\r
bcd70414 911/**\r
912 Read result byte from Data Register of FDC\r
913 \r
914 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
915 @param Pointer UINT8 *: Be used to save result byte read from FDC\r
916 \r
917 \r
918 @retval EFI_SUCCESS: Read result byte from FDC successfully\r
919 @retval EFI_DEVICE_ERROR: The FDC is not ready to be read\r
920\r
921**/\r
11f43dfd 922EFI_STATUS\r
923DataInByte (\r
924 IN FDC_BLK_IO_DEV *FdcDev,\r
925 IN UINT8 *Pointer\r
926 )\r
11f43dfd 927;\r
928\r
bcd70414 929/**\r
930 Write command byte to Data Register of FDC\r
931 \r
932 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
933 @param Pointer Be used to save command byte written to FDC\r
934 \r
935 @retval EFI_SUCCESS: Write command byte to FDC successfully\r
936 @retval EFI_DEVICE_ERROR: The FDC is not ready to be written\r
937\r
938**/\r
11f43dfd 939EFI_STATUS\r
940DataOutByte (\r
941 IN FDC_BLK_IO_DEV *FdcDev,\r
942 IN UINT8 *Pointer\r
943 )\r
11f43dfd 944;\r
945\r
bcd70414 946/**\r
947 Detect the specified floppy logic drive is busy or\r
948 not within a period of time\r
949 \r
fdb05fa3 950 @param FdcDev Indicate it is drive A or drive B\r
bcd70414 951 @param TimeoutInSeconds the time period for waiting\r
952 \r
953 @retval EFI_SUCCESS: The drive and command are not busy\r
954 @retval EFI_TIMEOUT: The drive or command is still busy after a period time that\r
955 set by TimeoutInSeconds\r
956\r
957**/\r
11f43dfd 958EFI_STATUS\r
959FddWaitForBSYClear (\r
960 IN FDC_BLK_IO_DEV *FdcDev,\r
961 IN UINTN TimeoutInSeconds\r
962 )\r
bcd70414 963;\r
11f43dfd 964\r
bcd70414 965/**\r
11f43dfd 966\r
bcd70414 967 Routine Description: Determine whether FDC is ready to write or read\r
968 \r
969 @param FdcDev Pointer to instance of FDC_BLK_IO_DEV\r
970 @param Dio BOOLEAN: Indicate the FDC is waiting to write or read\r
971 @param TimeoutInSeconds UINTN: The time period for waiting\r
972 \r
973 @retval EFI_SUCCESS: FDC is ready to write or read\r
974 @retval EFI_NOT_READY: FDC is not ready within the specified time period\r
11f43dfd 975\r
bcd70414 976**/\r
11f43dfd 977EFI_STATUS\r
978FddDRQReady (\r
979 IN FDC_BLK_IO_DEV *FdcDev,\r
980 IN BOOLEAN Dio,\r
981 IN UINTN TimeoutInSeconds\r
982 )\r
bcd70414 983;\r
11f43dfd 984\r
bcd70414 985/**\r
986 Set FDC control structure's attribute according to\r
987 result \r
11f43dfd 988\r
bcd70414 989 @param Result Point to result structure\r
990 @param FdcDev FDC control structure\r
11f43dfd 991\r
fdb05fa3 992 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
993 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
994 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
995 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
11f43dfd 996\r
bcd70414 997**/\r
11f43dfd 998EFI_STATUS\r
999CheckResult (\r
1000 IN FDD_RESULT_PACKET *Result,\r
1001 IN OUT FDC_BLK_IO_DEV *FdcDev\r
1002 )\r
11f43dfd 1003;\r
1004\r
bcd70414 1005/**\r
1006 Check the drive status information\r
1007 \r
1008 @param StatusRegister3 the value of Status Register 3\r
1009 \r
1010 @retval EFI_SUCCESS The disk is not write protected\r
1011 @retval EFI_WRITE_PROTECTED: The disk is write protected\r
1012\r
1013**/\r
11f43dfd 1014EFI_STATUS\r
1015CheckStatus3 (\r
1016 IN UINT8 StatusRegister3\r
1017 )\r
11f43dfd 1018;\r
1019\r
bcd70414 1020/**\r
1021 Calculate the number of block in the same cylinder\r
1022 according to LBA\r
1023 \r
1024 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
1025 @param LBA EFI_LBA: The starting logic block address\r
1026 @param NumberOfBlocks UINTN: The number of blocks\r
1027 \r
1028 @return The number of blocks in the same cylinder which the starting\r
1029 logic block address is LBA\r
1030\r
1031**/\r
11f43dfd 1032UINTN\r
1033GetTransferBlockCount (\r
1034 IN FDC_BLK_IO_DEV *FdcDev,\r
1035 IN EFI_LBA LBA,\r
1036 IN UINTN NumberOfBlocks\r
1037 )\r
11f43dfd 1038;\r
1039\r
bcd70414 1040/**\r
1041 When the Timer(2s) off, turn the drive's motor off\r
1042 \r
1043 @param Event EFI_EVENT: Event(the timer) whose notification function is being\r
1044 invoked\r
1045 @param Context VOID *: Pointer to the notification function's context\r
1046\r
1047**/\r
11f43dfd 1048VOID\r
1049EFIAPI\r
1050FddTimerProc (\r
1051 IN EFI_EVENT Event,\r
1052 IN VOID *Context\r
1053 )\r
11f43dfd 1054;\r
1055\r
bcd70414 1056/**\r
1057 Read I/O port for FDC\r
1058 \r
1059 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
1060 @param Offset The offset address of port\r
1061\r
1062**/\r
11f43dfd 1063UINT8\r
1064FdcReadPort (\r
1065 IN FDC_BLK_IO_DEV *FdcDev,\r
1066 IN UINT32 Offset\r
1067 )\r
11f43dfd 1068;\r
1069\r
bcd70414 1070/**\r
1071 Write I/O port for FDC\r
1072 \r
1073 @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV\r
1074 @param Offset The offset address of port\r
fdb05fa3 1075 @param Data Value written to port\r
1076 \r
bcd70414 1077**/\r
11f43dfd 1078VOID\r
1079FdcWritePort (\r
1080 IN FDC_BLK_IO_DEV *FdcDev,\r
1081 IN UINT32 Offset,\r
1082 IN UINT8 Data\r
1083 )\r
bcd70414 1084;\r
11f43dfd 1085\r
bcd70414 1086/**\r
1087 Read or Write a number of blocks to floppy device\r
11f43dfd 1088\r
bcd70414 1089 @param This Pointer to instance of EFI_BLOCK_IO_PROTOCOL\r
1090 @param MediaId The media id of read/write request\r
1091 @param LBA The starting logic block address to read from on the device\r
1092 @param BufferSize The size of the Buffer in bytes\r
1093 @param Operation - GC_TODO: add argument description\r
fdb05fa3 1094 @param Buffer - GC_TODO: add argument description\r
11f43dfd 1095\r
bcd70414 1096 @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
1097 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
1098 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1099 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1100 @retval EFI_NO_MEDIA - GC_TODO: Add description for return value\r
1101 @retval EFI_MEDIA_CHANGED - GC_TODO: Add description for return value\r
1102 @retval EFI_WRITE_PROTECTED - GC_TODO: Add description for return value\r
1103 @retval EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value\r
1104 @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
1105 @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
1106 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
1107 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1108 @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
1109 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
11f43dfd 1110\r
bcd70414 1111**/\r
11f43dfd 1112EFI_STATUS\r
1113FddReadWriteBlocks (\r
1114 IN EFI_BLOCK_IO_PROTOCOL *This,\r
1115 IN UINT32 MediaId,\r
1116 IN EFI_LBA LBA,\r
1117 IN UINTN BufferSize,\r
1118 IN BOOLEAN Operation,\r
1119 OUT VOID *Buffer\r
1120 )\r
11f43dfd 1121;\r
1122\r
bcd70414 1123/**\r
1124 Common interface for free cache \r
1125 \r
fdb05fa3 1126 @param FdcDev Pointer of FDC_BLK_IO_DEV instance\r
bcd70414 1127 \r
1128**/\r
11f43dfd 1129VOID\r
1130FdcFreeCache (\r
1131 IN FDC_BLK_IO_DEV *FdcDev\r
1132 )\r
11f43dfd 1133;\r
1134\r
1135#endif\r
bcd70414 1136\r