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