3 * Floppy Disk Access Code
\r
8 #include <fs_devfs.h>
\r
9 #include <tpl_drv_disk.h>
\r
11 #include <iocache.h>
\r
15 // === CONSTANTS ===
\r
16 // --- Current Version
\r
17 #define FDD_VERSION ((0<<8)|(75))
\r
20 #define FDD_SEEK_TIMEOUT 10 // Timeout for a seek operation
\r
21 #define MOTOR_ON_DELAY 500 // Miliseconds
\r
22 #define MOTOR_OFF_DELAY 2000 // Miliseconds
\r
23 #define FDD_MAX_READWRITE_ATTEMPTS 16
\r
27 * \brief Representation of a floppy drive
\r
29 typedef struct sFloppyDrive
\r
32 volatile int motorState; //2 - On, 1 - Spinup, 0 - Off
\r
37 tIOCache *CacheHandle;
\r
42 * \brief Cached Sector
\r
47 Uint16 sector; // Allows 32Mb of addressable space (Plenty for FDD)
\r
51 // === CONSTANTS ===
\r
52 static const char *cFDD_TYPES[] = {"None", "360kB 5.25\"", "1.2MB 5.25\"", "720kB 3.5\"", "1.44MB 3.5\"", "2.88MB 3.5\"" };
\r
53 static const int cFDD_SIZES[] = { 0, 360*1024, 1200*1024, 720*1024, 1440*1024, 2880*1024 };
\r
54 static const short cPORTBASE[] = { 0x3F0, 0x370 };
\r
56 static const char *cFDD_STATUSES[] = {NULL, "Error", "Invalid command", "Drive not ready"};
\r
62 PORT_DIGOUTPUT = 0x2,
\r
63 PORT_MAINSTATUS = 0x4,
\r
64 PORT_DATARATE = 0x4,
\r
66 PORT_DIGINPUT = 0x7,
\r
67 PORT_CONFIGCTRL = 0x7
\r
70 enum FloppyCommands {
\r
71 FIX_DRIVE_DATA = 0x03,
\r
72 HECK_DRIVE_STATUS = 0x04,
\r
73 CALIBRATE_DRIVE = 0x07,
\r
74 CHECK_INTERRUPT_STATUS = 0x08,
\r
76 READ_SECTOR_ID = 0x4A,
\r
77 FORMAT_TRACK = 0x4D,
\r
80 WRITE_SECTOR = 0xC5,
\r
81 WRITE_DELETE_SECTOR = 0xC9,
\r
82 READ_DELETE_SECTOR = 0xCC,
\r
85 // === PROTOTYPES ===
\r
87 int FDD_Install(char **Arguments);
\r
88 void FDD_UnloadModule();
\r
90 char *FDD_ReadDir(tVFS_Node *Node, int pos);
\r
91 tVFS_Node *FDD_FindDir(tVFS_Node *dirNode, char *Name);
\r
92 int FDD_IOCtl(tVFS_Node *Node, int ID, void *Data);
\r
93 Uint64 FDD_ReadFS(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer);
\r
94 // --- Functions for IOCache/DrvUtil
\r
95 Uint FDD_ReadSectors(Uint64 SectorAddr, Uint Count, void *Buffer, Uint Disk);
\r
96 // --- Raw Disk Access
\r
97 int FDD_ReadSector(Uint32 disk, Uint64 lba, void *Buffer);
\r
98 int FDD_WriteSector(Uint32 Disk, Uint64 LBA, void *Buffer);
\r
100 void FDD_IRQHandler(int Num);
\r
101 inline void FDD_WaitIRQ();
\r
102 void FDD_SensInt(int base, Uint8 *sr0, Uint8 *cyl);
\r
103 void FDD_int_SendByte(int base, char byte);
\r
104 int FDD_int_GetByte(int base);
\r
105 void FDD_Reset(int id);
\r
106 void FDD_Recalibrate(int disk);
\r
107 int FDD_int_SeekTrack(int disk, int head, int track);
\r
108 void FDD_int_TimerCallback(int arg);
\r
109 void FDD_int_StopMotor(int disk);
\r
110 void FDD_int_StartMotor(int disk);
\r
111 int FDD_int_GetDims(int type, int lba, int *c, int *h, int *s, int *spt);
\r
114 MODULE_DEFINE(0, FDD_VERSION, FDD, FDD_Install, NULL, "ISADMA", NULL);
\r
115 t_floppyDevice gFDD_Devices[2];
\r
117 volatile int gbFDD_IrqFired = 0;
\r
118 tDevFS_Driver gFDD_DriverInfo = {
\r
123 .ACLs = &gVFS_ACL_EveryoneRX,
\r
124 .Flags = VFS_FFLAG_DIRECTORY,
\r
125 .ReadDir = FDD_ReadDir,
\r
126 .FindDir = FDD_FindDir,
\r
133 * \fn int FDD_Install(char **Arguments)
\r
134 * \brief Installs floppy driver
\r
136 int FDD_Install(char **Arguments)
\r
140 // Determine Floppy Types (From CMOS)
\r
143 gFDD_Devices[0].type = data >> 4;
\r
144 gFDD_Devices[1].type = data & 0xF;
\r
145 gFDD_Devices[0].track[0] = -1;
\r
146 gFDD_Devices[1].track[1] = -1;
\r
148 Log_Log("FDD", "Detected Disk 0: %s and Disk 1: %s", cFDD_TYPES[data>>4], cFDD_TYPES[data&0xF]);
\r
151 return MODULE_ERR_NOTNEEDED;
\r
154 // Clear FDD IRQ Flag
\r
155 FDD_SensInt(0x3F0, NULL, NULL);
\r
156 // Install IRQ6 Handler
\r
157 IRQ_AddHandler(6, FDD_IRQHandler);
\r
158 // Reset Primary FDD Controller
\r
161 // Initialise Root Node
\r
162 gFDD_DriverInfo.RootNode.CTime = gFDD_DriverInfo.RootNode.MTime
\r
163 = gFDD_DriverInfo.RootNode.ATime = now();
\r
165 // Initialise Child Nodes
\r
166 gFDD_Devices[0].Node.Inode = 0;
\r
167 gFDD_Devices[0].Node.Flags = 0;
\r
168 gFDD_Devices[0].Node.NumACLs = 0;
\r
169 gFDD_Devices[0].Node.Read = FDD_ReadFS;
\r
170 gFDD_Devices[0].Node.Write = NULL;//FDD_WriteFS;
\r
171 memcpy(&gFDD_Devices[1].Node, &gFDD_Devices[0].Node, sizeof(tVFS_Node));
\r
173 gFDD_Devices[1].Node.Inode = 1;
\r
176 gFDD_Devices[0].Node.Size = cFDD_SIZES[data >> 4];
\r
177 gFDD_Devices[1].Node.Size = cFDD_SIZES[data & 0xF];
\r
179 // Create Sector Cache
\r
180 if( cFDD_SIZES[data >> 4] )
\r
182 gFDD_Devices[0].CacheHandle = IOCache_Create(
\r
183 FDD_WriteSector, 0, 512,
\r
184 gFDD_Devices[0].Node.Size / (512*4)
\r
185 ); // Cache is 1/4 the size of the disk
\r
187 if( cFDD_SIZES[data & 15] )
\r
189 gFDD_Devices[1].CacheHandle = IOCache_Create(
\r
190 FDD_WriteSector, 0, 512,
\r
191 gFDD_Devices[1].Node.Size / (512*4)
\r
192 ); // Cache is 1/4 the size of the disk
\r
195 // Register with devfs
\r
196 DevFS_AddDevice(&gFDD_DriverInfo);
\r
198 return MODULE_ERR_OK;
\r
202 * \brief Prepare the module for removal
\r
204 void FDD_UnloadModule()
\r
207 //DevFS_DelDevice( &gFDD_DriverInfo );
\r
210 Time_RemoveTimer(gFDD_Devices[i].timer);
\r
211 FDD_int_StopMotor(i);
\r
218 * \fn char *FDD_ReadDir(tVFS_Node *Node, int pos)
\r
219 * \brief Read Directory
\r
221 char *FDD_ReadDir(tVFS_Node *Node, int Pos)
\r
223 char name[2] = "0\0";
\r
225 if(Pos >= 2 || Pos < 0) return NULL;
\r
227 if(gFDD_Devices[Pos].type == 0) return VFS_SKIP;
\r
231 return strdup(name);
\r
235 * \fn tVFS_Node *FDD_FindDir(tVFS_Node *Node, char *filename);
\r
236 * \brief Find File Routine (for vfs_node)
\r
238 tVFS_Node *FDD_FindDir(tVFS_Node *Node, char *Filename)
\r
242 ENTER("sFilename", Filename);
\r
244 // Sanity check string
\r
245 if(Filename == NULL) {
\r
250 // Check string length (should be 1)
\r
251 if(Filename[0] == '\0' || Filename[1] != '\0') {
\r
256 // Get First character
\r
257 i = Filename[0] - '0';
\r
259 // Check for 1st disk and if it is present return
\r
260 if(i == 0 && gFDD_Devices[0].type != 0) {
\r
261 LEAVE('p', &gFDD_Devices[0].Node);
\r
262 return &gFDD_Devices[0].Node;
\r
265 // Check for 2nd disk and if it is present return
\r
266 if(i == 1 && gFDD_Devices[1].type != 0) {
\r
267 LEAVE('p', &gFDD_Devices[1].Node);
\r
268 return &gFDD_Devices[1].Node;
\r
271 // Else return null
\r
276 static const char *casIOCTLS[] = {DRV_IOCTLNAMES,DRV_DISK_IOCTLNAMES,NULL};
\r
278 * \fn int FDD_IOCtl(tVFS_Node *Node, int id, void *data)
\r
279 * \brief Stub ioctl function
\r
281 int FDD_IOCtl(tVFS_Node *Node, int ID, void *Data)
\r
285 case DRV_IOCTL_TYPE: return DRV_TYPE_DISK;
\r
286 case DRV_IOCTL_IDENT: return ModUtil_SetIdent(Data, "FDD");
\r
287 case DRV_IOCTL_VERSION: return FDD_VERSION;
\r
288 case DRV_IOCTL_LOOKUP: return ModUtil_LookupString((char**)casIOCTLS, Data);
\r
290 case DISK_IOCTL_GETBLOCKSIZE: return 512;
\r
298 * \fn Uint64 FDD_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
\r
299 * \brief Read Data from a disk
\r
301 Uint64 FDD_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
\r
305 ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
\r
312 if(Node->Inode != 0 && Node->Inode != 1) {
\r
317 ret = DrvUtil_ReadBlock(Offset, Length, Buffer, FDD_ReadSectors, 512, Node->Inode);
\r
323 * \brief Reads \a Count contiguous sectors from a disk
\r
324 * \param SectorAddr Address of the first sector
\r
325 * \param Count Number of sectors to read
\r
326 * \param Buffer Destination Buffer
\r
327 * \param Disk Disk Number
\r
328 * \return Number of sectors read
\r
329 * \note Used as a ::DrvUtil_ReadBlock helper
\r
331 Uint FDD_ReadSectors(Uint64 SectorAddr, Uint Count, void *Buffer, Uint Disk)
\r
336 if( FDD_ReadSector(Disk, SectorAddr, Buffer) != 1 )
\r
339 Buffer = (void*)( (tVAddr)Buffer + 512 );
\r
346 int FDD_int_ReadWriteSector(Uint32 Disk, Uint64 SectorAddr, int Write, void *Buffer)
\r
348 int cyl, head, sec;
\r
351 int lba = SectorAddr;
\r
352 Uint8 st0, st1, st2, rcy, rhe, rse, bps; // Status Values
\r
354 ENTER("iDisk XSectorAddr pBuffer", Disk, SectorAddr, Buffer);
\r
356 base = cPORTBASE[Disk >> 1];
\r
358 LOG("Calculating Disk Dimensions");
\r
359 // Get CHS position
\r
360 if(FDD_int_GetDims(gFDD_Devices[Disk].type, lba, &cyl, &head, &sec, &spt) != 1)
\r
365 LOG("Cyl=%i, Head=%i, Sector=%i", cyl, head, sec);
\r
367 LOCK(&glFDD); // Lock to stop the motor stopping on us
\r
368 Time_RemoveTimer(gFDD_Devices[Disk].timer); // Remove Old Timer
\r
369 // Start motor if needed
\r
370 if(gFDD_Devices[Disk].motorState != 2) FDD_int_StartMotor(Disk);
\r
373 LOG("Wait for the motor to spin up");
\r
376 while(gFDD_Devices[Disk].motorState == 1) Threads_Yield();
\r
378 LOG("Acquire Spinlock");
\r
382 outb(base + CALIBRATE_DRIVE, 0);
\r
384 while(FDD_int_SeekTrack(Disk, head, (Uint8)cyl) == 0 && i++ < FDD_SEEK_TIMEOUT )
\r
386 if( i > FDD_SEEK_TIMEOUT ) {
\r
391 //FDD_SensInt(base, NULL, NULL); // Wait for IRQ
\r
393 // Read Data from DMA
\r
394 LOG("Setting DMA for read");
\r
395 DMA_SetChannel(2, 512, !Write); // Read 512 Bytes from channel 2
\r
397 LOG("Sending command");
\r
399 //Threads_Wait(100); // Wait for Head to settle
\r
402 for( i = 0; i < FDD_MAX_READWRITE_ATTEMPTS; i ++ )
\r
405 FDD_int_SendByte(base, READ_SECTOR); // Was 0xE6
\r
407 FDD_int_SendByte(base, READ_SECTOR); // Was 0xE6
\r
408 FDD_int_SendByte(base, (head << 2) | (Disk&1));
\r
409 FDD_int_SendByte(base, (Uint8)cyl);
\r
410 FDD_int_SendByte(base, (Uint8)head);
\r
411 FDD_int_SendByte(base, (Uint8)sec);
\r
412 FDD_int_SendByte(base, 0x02); // Bytes Per Sector (Real BPS=128*2^{val})
\r
413 FDD_int_SendByte(base, spt); // SPT
\r
414 FDD_int_SendByte(base, 0x1B); // Gap Length (27 is default)
\r
415 FDD_int_SendByte(base, 0xFF); // Data Length
\r
419 LOG("Writing Data");
\r
420 DMA_WriteData(2, 512, Buffer);
\r
421 LOG("Waiting for Data to be written");
\r
425 LOG("Waiting for data to be read");
\r
427 LOG("Reading Data");
\r
428 DMA_ReadData(2, 512, Buffer);
\r
431 // Clear Input Buffer
\r
432 LOG("Clearing Input Buffer");
\r
434 st0 = FDD_int_GetByte(base);
\r
435 st1 = FDD_int_GetByte(base);
\r
436 st2 = FDD_int_GetByte(base);
\r
438 // Cylinder, Head and Sector (mutilated in some way
\r
439 rcy = FDD_int_GetByte(base);
\r
440 rhe = FDD_int_GetByte(base);
\r
441 rse = FDD_int_GetByte(base);
\r
442 // Should be the BPS set above (0x02)
\r
443 bps = FDD_int_GetByte(base);
\r
448 LOG("Error (st0 & 0xC0) \"%s\"", cFDD_STATUSES[st0 >> 6]);
\r
452 if(st0 & 0x08) { LOG("Drive not ready"); continue; }
\r
453 if(st1 & 0x80) { LOG("End of Cylinder"); continue; }
\r
454 if(st1 & 0x20) { LOG("CRC Error"); continue; }
\r
455 if(st1 & 0x10) { LOG("Controller Timeout"); continue; }
\r
456 if(st1 & 0x04) { LOG("No Data Found"); continue; }
\r
457 if(st1 & 0x01 || st2 & 0x01) {
\r
458 LOG("No Address mark found");
\r
461 if(st2 & 0x40) { LOG("Deleted address mark"); continue; }
\r
462 if(st2 & 0x20) { LOG("CRC error in data"); continue; }
\r
463 if(st2 & 0x10) { LOG("Wrong Cylinder"); continue; }
\r
464 if(st2 & 0x04) { LOG("uPD765 sector not found"); continue; }
\r
465 if(st2 & 0x02) { LOG("Bad Cylinder"); continue; }
\r
468 LOG("Returned BPS = 0x%02x, not 0x02", bps);
\r
473 LOG("Floppy not writable");
\r
474 i = FDD_MAX_READWRITE_ATTEMPTS+1;
\r
482 // Release Spinlock
\r
483 LOG("Realeasing Spinlock and setting motor to stop");
\r
486 if(i == FDD_MAX_READWRITE_ATTEMPTS) {
\r
487 Log_Warning("FDD", "Exceeded %i attempts in %s the disk",
\r
488 FDD_MAX_READWRITE_ATTEMPTS,
\r
489 (Write ? "writing to" : "reading from")
\r
493 // Don't turn the motor off now, wait for a while
\r
494 gFDD_Devices[Disk].timer = Time_CreateTimer(MOTOR_OFF_DELAY, FDD_int_StopMotor, (void*)Disk);
\r
496 if( i < FDD_MAX_READWRITE_ATTEMPTS ) {
\r
507 * \fn int FDD_ReadSector(Uint32 Disk, Uint64 SectorAddr, void *Buffer)
\r
508 * \brief Read a sector from disk
\r
509 * \todo Make real-hardware safe (account for read errors)
\r
511 int FDD_ReadSector(Uint32 Disk, Uint64 SectorAddr, void *Buffer)
\r
515 ENTER("iDisk XSectorAddr pBuffer", Disk, SectorAddr, Buffer);
\r
517 if( IOCache_Read( gFDD_Devices[Disk].CacheHandle, SectorAddr, Buffer ) == 1 ) {
\r
522 // Pass to general function
\r
523 ret = FDD_int_ReadWriteSector(Disk, SectorAddr, 0, Buffer);
526 IOCache_Add( gFDD_Devices[Disk].CacheHandle, SectorAddr, Buffer );
531 LOG("Reading failed");
\r
538 * \fn int FDD_WriteSector(Uint32 Disk, Uint64 LBA, void *Buffer)
\r
539 * \brief Write a sector to the floppy disk
\r
540 * \note Not Implemented
\r
542 int FDD_WriteSector(Uint32 Disk, Uint64 LBA, void *Buffer)
\r
544 Warning("[FDD ] Read Only at the moment");
\r
549 * \fn int FDD_int_SeekTrack(int disk, int track)
\r
550 * \brief Seek disk to selected track
\r
552 int FDD_int_SeekTrack(int disk, int head, int track)
\r
557 base = cPORTBASE[disk>>1];
\r
559 // Check if seeking is needed
\r
560 if(gFDD_Devices[disk].track[head] == track)
\r
564 FDD_int_SendByte(base, SEEK_TRACK);
\r
565 FDD_int_SendByte(base, (head<<2)|(disk&1));
\r
566 FDD_int_SendByte(base, track); // Send Seek command
\r
568 FDD_SensInt(base, &sr0, &cyl); // Wait for IRQ
\r
569 if((sr0 & 0xF0) != 0x20) {
570 LOG("sr0 = 0x%x", sr0);
571 return 0; //Check Status
573 if(cyl != track) return 0;
\r
575 // Set Track in structure
\r
576 gFDD_Devices[disk].track[head] = track;
\r
581 * \fn int FDD_int_GetDims(int type, int lba, int *c, int *h, int *s, int *spt)
\r
582 * \brief Get Dimensions of a disk
\r
584 int FDD_int_GetDims(int type, int lba, int *c, int *h, int *s, int *spt)
\r
593 *s = (lba % 9) + 1;
\r
595 *h = (lba / 9) & 1;
\r
601 *s = (lba % 15) + 1;
\r
603 *h = (lba / 15) & 1;
\r
609 *s = (lba % 9) + 1;
\r
611 *h = (lba / 9) & 1;
\r
617 *s = (lba % 18) + 1;
\r
619 *h = (lba / 18) & 1;
\r
620 //Log("1440k - lba=%i(0x%x), *s=%i,*c=%i,*h=%i", lba, lba, *s, *c, *h);
\r
626 *s = (lba % 36) + 1;
\r
628 *h = (lba / 32) & 1;
\r
638 * \fn void FDD_IRQHandler(int Num)
\r
639 * \brief Handles IRQ6
\r
641 void FDD_IRQHandler(int Num)
\r
643 gbFDD_IrqFired = 1;
\r
647 * \fn FDD_WaitIRQ()
\r
648 * \brief Wait for an IRQ6
\r
650 inline void FDD_WaitIRQ()
\r
653 while(!gbFDD_IrqFired) Threads_Yield();
\r
654 gbFDD_IrqFired = 0;
\r
657 void FDD_SensInt(int base, Uint8 *sr0, Uint8 *cyl)
\r
659 FDD_int_SendByte(base, CHECK_INTERRUPT_STATUS);
\r
660 if(sr0) *sr0 = FDD_int_GetByte(base);
\r
661 else FDD_int_GetByte(base);
\r
662 if(cyl) *cyl = FDD_int_GetByte(base);
\r
663 else FDD_int_GetByte(base);
\r
667 * void FDD_int_SendByte(int base, char byte)
\r
668 * \brief Sends a command to the controller
\r
670 void FDD_int_SendByte(int base, char byte)
\r
672 volatile int state;
\r
674 for( ; timeout--; )
\r
676 state = inb(base + PORT_MAINSTATUS);
\r
677 if ((state & 0xC0) == 0x80)
\r
679 outb(base + PORT_DATA, byte);
\r
686 Warning("FDD_int_SendByte - Timeout sending byte 0x%x to base 0x%x\n", byte, base);
\r
691 * int FDD_int_GetByte(int base, char byte)
\r
692 * \brief Receive data from fdd controller
\r
694 int FDD_int_GetByte(int base)
\r
696 volatile int state;
\r
698 for( timeout = 128; timeout--; )
\r
700 state = inb((base + PORT_MAINSTATUS));
\r
701 if ((state & 0xd0) == 0xd0)
\r
702 return inb(base + PORT_DATA);
\r
709 * \brief Recalibrate the specified disk
\r
711 void FDD_Recalibrate(int disk)
\r
713 ENTER("idisk", disk);
\r
715 LOG("Starting Motor");
\r
716 FDD_int_StartMotor(disk);
\r
718 while(gFDD_Devices[disk].motorState == 1) Threads_Yield();
\r
720 LOG("Sending Calibrate Command");
\r
721 FDD_int_SendByte(cPORTBASE[disk>>1], CALIBRATE_DRIVE);
\r
722 FDD_int_SendByte(cPORTBASE[disk>>1], disk&1);
\r
724 LOG("Waiting for IRQ");
\r
726 FDD_SensInt(cPORTBASE[disk>>1], NULL, NULL);
\r
728 LOG("Stopping Motor");
\r
729 FDD_int_StopMotor(disk);
\r
734 * \brief Reset the specified FDD controller
\r
736 void FDD_Reset(int id)
\r
738 int base = cPORTBASE[id];
\r
742 outb(base + PORT_DIGOUTPUT, 0); // Stop Motors & Disable FDC
\r
743 outb(base + PORT_DIGOUTPUT, 0x0C); // Re-enable FDC (DMA and Enable)
\r
745 LOG("Awaiting IRQ");
\r
748 FDD_SensInt(base, NULL, NULL);
\r
750 LOG("Setting Driver Info");
\r
751 outb(base + PORT_DATARATE, 0); // Set data rate to 500K/s
\r
752 FDD_int_SendByte(base, FIX_DRIVE_DATA); // Step and Head Load Times
\r
753 FDD_int_SendByte(base, 0xDF); // Step Rate Time, Head Unload Time (Nibble each)
\r
754 FDD_int_SendByte(base, 0x02); // Head Load Time >> 1
\r
755 while(FDD_int_SeekTrack(0, 0, 1) == 0); // set track
\r
756 while(FDD_int_SeekTrack(0, 1, 1) == 0); // set track
\r
758 LOG("Recalibrating Disk");
\r
759 FDD_Recalibrate((id<<1)|0);
\r
760 FDD_Recalibrate((id<<1)|1);
766 * \fn void FDD_int_TimerCallback()
\r
767 * \brief Called by timer
\r
769 void FDD_int_TimerCallback(int arg)
\r
771 ENTER("iarg", arg);
\r
772 if(gFDD_Devices[arg].motorState == 1)
\r
773 gFDD_Devices[arg].motorState = 2;
\r
774 Time_RemoveTimer(gFDD_Devices[arg].timer);
\r
775 gFDD_Devices[arg].timer = -1;
\r
780 * \fn void FDD_int_StartMotor(char disk)
\r
781 * \brief Starts FDD Motor
\r
783 void FDD_int_StartMotor(int disk)
\r
786 state = inb( cPORTBASE[ disk>>1 ] + PORT_DIGOUTPUT );
\r
787 state |= 1 << (4+disk);
\r
788 outb( cPORTBASE[ disk>>1 ] + PORT_DIGOUTPUT, state );
\r
789 gFDD_Devices[disk].motorState = 1;
\r
790 gFDD_Devices[disk].timer = Time_CreateTimer(MOTOR_ON_DELAY, FDD_int_TimerCallback, (void*)disk);
\r
794 * \fn void FDD_int_StopMotor(int disk)
\r
795 * \brief Stops FDD Motor
\r
797 void FDD_int_StopMotor(int disk)
\r
800 if( IS_LOCKED(&glFDD) ) return ;
\r
801 ENTER("iDisk", disk);
\r
803 state = inb( cPORTBASE[ disk>>1 ] + PORT_DIGOUTPUT );
\r
804 state &= ~( 1 << (4+disk) );
\r
805 outb( cPORTBASE[ disk>>1 ] + PORT_DIGOUTPUT, state );
\r
806 gFDD_Devices[disk].motorState = 0;
\r