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