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