2 * Acess2 IDE Harddisk Driver
11 #include <tpl_drv_common.h>
12 #include <tpl_drv_disk.h>
15 #define IO_DELAY() do{inb(0x80); inb(0x80); inb(0x80); inb(0x80);}while(0)
23 } __attribute__ ((packed)) tPRDT_Ent;
27 Uint16 Usused1[9]; // 10
28 char SerialNum[20]; // 20
29 Uint16 Usused2[3]; // 23
30 char FirmwareVer[8]; // 27
31 char ModelNumber[40]; // 47
32 Uint16 SectPerInt; // 48 - AND with 0xFF to get true value;
34 Uint16 Capabilities[2]; // 51
35 Uint16 Unused4[2]; // 53
36 Uint16 ValidExtData; // 54
37 Uint16 Unused5[5]; // 59
38 Uint16 SizeOfRWMultiple; // 60
39 Uint32 Sectors28; // 62
40 Uint16 Unused6[100-62];
42 Uint16 Unused7[256-104];
43 } __attribute__ ((packed)) tIdentify;
46 extern void ATA_ParseMBR(int Disk, tMBR *MBR);
51 void ATA_SetupPartitions();
53 int ATA_ScanDisk(int Disk);
54 void ATA_ParseGPT(int Disk);
55 void ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start, Uint64 Length);
56 Uint16 ATA_GetBasePort(int Disk);
57 // Filesystem Interface
58 char *ATA_ReadDir(tVFS_Node *Node, int Pos);
59 tVFS_Node *ATA_FindDir(tVFS_Node *Node, char *Name);
60 Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
61 Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
62 int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data);
63 // Read/Write Interface/Quantiser
64 Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk);
65 Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk);
67 int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer);
68 int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer);
70 void ATA_IRQHandlerPri(int unused);
71 void ATA_IRQHandlerSec(int unused);
73 Uint8 ATA_int_BusMasterReadByte(int Ofs);
74 void ATA_int_BusMasterWriteByte(int Ofs, Uint8 Value);
75 void ATA_int_BusMasterWriteDWord(int Ofs, Uint32 Value);
78 MODULE_DEFINE(0, 0x0032, i386ATA, ATA_Install, NULL, "PCI", NULL);
79 tDevFS_Driver gATA_DriverInfo = {
84 .Flags = VFS_FFLAG_DIRECTORY,
85 .ACLs = &gVFS_ACL_EveryoneRX,
86 .ReadDir = ATA_ReadDir,
87 .FindDir = ATA_FindDir
90 tATA_Disk gATA_Disks[MAX_ATA_DISKS];
92 tVFS_Node **gATA_Nodes;
93 Uint16 gATA_BusMasterBase = 0;
94 Uint8 *gATA_BusMasterBasePtr = 0;
97 int giaATA_ControllerLock[2] = {0}; //!< Spinlocks for each controller
98 Uint8 gATA_Buffers[2][(MAX_DMA_SECTORS+0xFFF)&~0xFFF] __attribute__ ((section(".padata")));
99 volatile int gaATA_IRQs[2] = {0};
100 tPRDT_Ent gATA_PRDTs[2] = {
101 {0, 512, IDE_PRDT_LAST},
102 {0, 512, IDE_PRDT_LAST}
107 * \fn int ATA_Install()
116 ATA_SetupPartitions();
120 if( DevFS_AddDevice( &gATA_DriverInfo ) == 0 )
121 return MODULE_ERR_MISC;
123 return MODULE_ERR_OK;
127 * \fn int ATA_SetupIO()
128 * \brief Sets up the ATA controller's DMA mode
137 // Get IDE Controller's PCI Entry
138 ent = PCI_GetDeviceByClass(0x0101, 0xFFFF, -1);
139 LOG("ent = %i", ent);
140 gATA_BusMasterBase = PCI_GetBAR4( ent );
141 if( gATA_BusMasterBase == 0 ) {
142 Log_Warning("ATA", "It seems that there is no Bus Master Controller on this machine. Get one");
143 // TODO: Use PIO mode instead
144 LEAVE('i', MODULE_ERR_NOTNEEDED);
145 return MODULE_ERR_NOTNEEDED;
149 if( !(gATA_BusMasterBase & 1) )
151 if( gATA_BusMasterBase < 0x100000 )
152 gATA_BusMasterBasePtr = (void*)(KERNEL_BASE | (tVAddr)gATA_BusMasterBase);
154 gATA_BusMasterBasePtr = (void*)( MM_MapHWPages( gATA_BusMasterBase, 1 ) + (gATA_BusMasterBase&0xFFF) );
155 LOG("gATA_BusMasterBasePtr = %p", gATA_BusMasterBasePtr);
158 // Bit 0 is left set as a flag to other functions
159 LOG("gATA_BusMasterBase = 0x%x", gATA_BusMasterBase & ~1);
162 // Register IRQs and get Buffers
163 IRQ_AddHandler( gATA_IRQPri, ATA_IRQHandlerPri );
164 IRQ_AddHandler( gATA_IRQSec, ATA_IRQHandlerSec );
166 gATA_PRDTs[0].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[0] );
167 gATA_PRDTs[1].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[1] );
169 LOG("gATA_PRDTs = {PBufAddr: 0x%x, PBufAddr: 0x%x}", gATA_PRDTs[0].PBufAddr, gATA_PRDTs[1].PBufAddr);
171 addr = MM_GetPhysAddr( (tVAddr)&gATA_PRDTs[0] );
172 LOG("addr = 0x%x", addr);
173 ATA_int_BusMasterWriteDWord(4, addr);
174 addr = MM_GetPhysAddr( (tVAddr)&gATA_PRDTs[1] );
175 LOG("addr = 0x%x", addr);
176 ATA_int_BusMasterWriteDWord(12, addr);
178 // Enable controllers
179 outb(IDE_PRI_BASE+1, 1);
180 outb(IDE_SEC_BASE+1, 1);
183 LEAVE('i', MODULE_ERR_OK);
184 return MODULE_ERR_OK;
188 * \fn void ATA_SetupPartitions()
190 void ATA_SetupPartitions()
193 for( i = 0; i < MAX_ATA_DISKS; i ++ )
195 if( !ATA_ScanDisk(i) ) {
196 gATA_Disks[i].Name[0] = '\0'; // Mark as unused
203 * \fn void ATA_SetupVFS()
204 * \brief Sets up the ATA drivers VFS information and registers with DevFS
210 // Count number of nodes needed
212 for( i = 0; i < MAX_ATA_DISKS; i++ )
214 if(gATA_Disks[i].Name[0] == '\0') continue; // Ignore
216 giATA_NumNodes += gATA_Disks[i].NumPartitions;
219 // Allocate Node space
220 gATA_Nodes = malloc( giATA_NumNodes * sizeof(void*) );
224 for( i = 0; i < MAX_ATA_DISKS; i++ )
226 if(gATA_Disks[i].Name[0] == '\0') continue; // Ignore
227 gATA_Nodes[ k++ ] = &gATA_Disks[i].Node;
228 for( j = 0; j < gATA_Disks[i].NumPartitions; j ++ )
229 gATA_Nodes[ k++ ] = &gATA_Disks[i].Partitions[j].Node;
232 gATA_DriverInfo.RootNode.Size = giATA_NumNodes;
236 * \fn int ATA_ScanDisk(int Disk)
238 int ATA_ScanDisk(int Disk)
250 ENTER("iDisk", Disk);
252 base = ATA_GetBasePort( Disk );
254 LOG("base = 0x%x", base);
256 // Send Disk Selector
257 if(Disk == 1 || Disk == 3)
263 // Check for a floating bus
264 if( 0xFF == inb(base+7) ) {
270 // Check for the controller
271 outb(base+0x02, 0x66);
272 outb(base+0x03, 0xFF);
273 if(inb(base+0x02) != 0x66 || inb(base+0x03) != 0xFF) {
274 LOG("No controller");
282 val = inb(base+7); // Read status
283 LOG("val = 0x%02x", val);
286 return 0; // Disk does not exist
289 // Poll until BSY clears and DRQ sets or ERR is set
290 while( ((val & 0x80) || !(val & 0x08)) && !(val & 1)) val = inb(base+7);
294 return 0; // Error occured, so return false
298 for(i=0;i<256;i++) data.buf[i] = inw(base);
300 // Populate Disk Structure
301 if(data.identify.Sectors48 != 0)
302 gATA_Disks[ Disk ].Sectors = data.identify.Sectors48;
304 gATA_Disks[ Disk ].Sectors = data.identify.Sectors28;
307 LOG("gATA_Disks[ %i ].Sectors = 0x%x", Disk, gATA_Disks[ Disk ].Sectors);
310 Uint64 val = gATA_Disks[ Disk ].Sectors / 2;
316 else if( val > 4*1024 ) {
320 else if( val > 4*1024 ) {
324 Log_Log("ATA", "Disk %i: 0x%llx Sectors (%lli %s)", Disk,
325 gATA_Disks[ Disk ].Sectors, val, units);
329 gATA_Disks[ Disk ].Name[0] = 'A'+Disk;
330 gATA_Disks[ Disk ].Name[1] = '\0';
332 // Get pointer to vfs node and populate it
333 node = &gATA_Disks[ Disk ].Node;
334 node->Size = gATA_Disks[Disk].Sectors * SECTOR_SIZE;
335 node->NumACLs = 0; // Means Superuser only can access it
336 node->Inode = (Disk << 8) | 0xFF;
337 node->ImplPtr = gATA_Disks[ Disk ].Name;
339 node->ATime = node->MTime
340 = node->CTime = now();
342 node->Read = ATA_ReadFS;
343 node->Write = ATA_WriteFS;
344 node->IOCtl = ATA_IOCtl;
346 // --- Scan Partitions ---
349 ATA_ReadDMA( Disk, 0, 1, &data.mbr );
351 // Check for a GPT table
352 if(data.mbr.Parts[0].SystemID == 0xEE)
354 else // No? Just parse the MBR
355 ATA_ParseMBR(Disk, &data.mbr);
357 ATA_ReadDMA( Disk, 1, 1, &data );
358 Debug_HexDump("ATA_ScanDisk", &data, 512);
365 * \fn void ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start, Uint64 Length)
366 * \brief Fills a parition's information structure
368 void ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start, Uint64 Length)
370 ENTER("pPart iDisk iNum XStart XLength", Part, Disk, Num, Start, Length);
372 Part->Length = Length;
373 Part->Name[0] = 'A'+Disk;
375 Part->Name[1] = '1'+Num/10;
376 Part->Name[2] = '1'+Num%10;
377 Part->Name[3] = '\0';
379 Part->Name[1] = '1'+Num;
380 Part->Name[2] = '\0';
382 Part->Node.NumACLs = 0; // Only root can read/write raw block devices
383 Part->Node.Inode = (Disk << 8) | Num;
384 Part->Node.ImplPtr = Part->Name;
386 Part->Node.Read = ATA_ReadFS;
387 Part->Node.Write = ATA_WriteFS;
388 Part->Node.IOCtl = ATA_IOCtl;
389 Log_Notice("ATA", "Note '%s' at 0x%llx, 0x%llx long", Part->Name, Part->Start, Part->Length);
390 LOG("Made '%s' (&Node=%p)", Part->Name, &Part->Node);
395 * \fn void ATA_ParseGPT(int Disk)
396 * \brief Parses the GUID Partition Table
398 void ATA_ParseGPT(int Disk)
400 ///\todo Support GPT Disks
401 Warning("GPT Disks are currently unsupported");
405 * \fn Uint16 ATA_GetPortBase(int Disk)
406 * \brief Returns the base port for a given disk
408 Uint16 ATA_GetBasePort(int Disk)
412 case 0: case 1: return IDE_PRI_BASE;
413 case 2: case 3: return IDE_SEC_BASE;
419 * \fn char *ATA_ReadDir(tVFS_Node *Node, int Pos)
421 char *ATA_ReadDir(tVFS_Node *Node, int Pos)
423 if(Pos >= giATA_NumNodes || Pos < 0) return NULL;
424 return strdup( gATA_Nodes[Pos]->ImplPtr );
428 * \fn tVFS_Node *ATA_FindDir(tVFS_Node *Node, char *Name)
430 tVFS_Node *ATA_FindDir(tVFS_Node *Node, char *Name)
435 // Check first character
436 if(Name[0] < 'A' || Name[0] > 'A'+MAX_ATA_DISKS)
438 disk = &gATA_Disks[Name[0]-'A'];
440 if(Name[1] == '\0') {
441 if( disk->Sectors == 0 && disk->Name[0] == '\0')
447 if(Name[1] < '0' || '9' < Name[1]) return NULL;
448 if(Name[2] == '\0') { // <= 9
449 part = Name[1] - '0';
451 return &disk->Partitions[part].Node;
454 if('0' > Name[2] || '9' < Name[2]) return NULL;
455 if(Name[3] != '\0') return NULL;
457 part = (Name[1] - '0') * 10;
458 part += Name[2] - '0';
460 return &disk->Partitions[part].Node;
465 * \fn Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
467 Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
469 int disk = Node->Inode >> 8;
470 int part = Node->Inode & 0xFF;
472 ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
477 if( Offset >= gATA_Disks[disk].Sectors * SECTOR_SIZE ) {
481 if( Offset + Length > gATA_Disks[disk].Sectors*SECTOR_SIZE )
482 Length = gATA_Disks[disk].Sectors*SECTOR_SIZE - Offset;
487 if( Offset >= gATA_Disks[disk].Partitions[part].Length * SECTOR_SIZE ) {
491 if( Offset + Length > gATA_Disks[disk].Partitions[part].Length * SECTOR_SIZE )
492 Length = gATA_Disks[disk].Partitions[part].Length * SECTOR_SIZE - Offset;
493 Offset += gATA_Disks[disk].Partitions[part].Start * SECTOR_SIZE;
497 int ret = DrvUtil_ReadBlock(Offset, Length, Buffer, ATA_ReadRaw, SECTOR_SIZE, disk);
498 Debug_HexDump("ATA_ReadFS", Buffer, Length);
505 * \fn Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
507 Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
509 int disk = Node->Inode >> 8;
510 int part = Node->Inode & 0xFF;
515 if( Offset >= gATA_Disks[disk].Sectors * SECTOR_SIZE )
517 if( Offset + Length > gATA_Disks[disk].Sectors*SECTOR_SIZE )
518 Length = gATA_Disks[disk].Sectors*SECTOR_SIZE - Offset;
523 if( Offset >= gATA_Disks[disk].Partitions[part].Length * SECTOR_SIZE )
525 if( Offset + Length > gATA_Disks[disk].Partitions[part].Length * SECTOR_SIZE )
526 Length = gATA_Disks[disk].Partitions[part].Length * SECTOR_SIZE - Offset;
527 Offset += gATA_Disks[disk].Partitions[part].Start * SECTOR_SIZE;
530 Log("ATA_WriteFS: (Node=%p, Offset=0x%llx, Length=0x%llx, Buffer=%p)", Node, Offset, Length, Buffer);
531 Debug_HexDump("ATA_WriteFS", Buffer, Length);
532 return DrvUtil_WriteBlock(Offset, Length, Buffer, ATA_ReadRaw, ATA_WriteRaw, SECTOR_SIZE, disk);
536 * \fn int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data)
537 * \brief IO Control Funtion
539 int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data)
543 case DRV_IOCTL_TYPE: return DRV_TYPE_DISK;
548 // --- Disk Access ---
550 * \fn Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
552 Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
558 // Pass straight on to ATA_ReadDMAPage if we can
559 if(Count <= MAX_DMA_SECTORS)
561 ret = ATA_ReadDMA(Disk, Address, Count, Buffer);
562 if(ret == 0) return 0;
566 // Else we will have to break up the transfer
568 while(Count > MAX_DMA_SECTORS)
570 ret = ATA_ReadDMA(Disk, Address+offset, MAX_DMA_SECTORS, Buffer+offset);
572 if(ret != 1) return done;
574 done += MAX_DMA_SECTORS;
575 Count -= MAX_DMA_SECTORS;
576 offset += MAX_DMA_SECTORS*SECTOR_SIZE;
579 ret = ATA_ReadDMA(Disk, Address+offset, Count, Buffer+offset);
580 if(ret != 1) return 0;
585 * \fn Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
587 Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
593 // Pass straight on to ATA_WriteDMA, if we can
594 if(Count <= MAX_DMA_SECTORS)
596 ret = ATA_WriteDMA(Disk, Address, Count, Buffer);
597 if(ret == 0) return 0;
601 // Else we will have to break up the transfer
603 while(Count > MAX_DMA_SECTORS)
605 ret = ATA_WriteDMA(Disk, Address+offset, MAX_DMA_SECTORS, Buffer+offset);
607 if(ret != 1) return done;
609 done += MAX_DMA_SECTORS;
610 Count -= MAX_DMA_SECTORS;
611 offset += MAX_DMA_SECTORS*SECTOR_SIZE;
614 ret = ATA_WriteDMA(Disk, Address+offset, Count, Buffer+offset);
615 if(ret != 1) return 0;
620 * \fn int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
622 int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
624 int cont = (Disk>>1)&1; // Controller ID
629 ENTER("iDisk XAddress iCount pBuffer", Disk, Address, Count, Buffer);
631 // Check if the count is small enough
632 if(Count > MAX_DMA_SECTORS) {
633 Warning("Passed too many sectors for a bulk DMA read (%i > %i)",
634 Count, MAX_DMA_SECTORS);
639 // Get exclusive access to the disk controller
640 LOCK( &giaATA_ControllerLock[ cont ] );
643 gATA_PRDTs[ cont ].Bytes = Count * SECTOR_SIZE;
646 base = ATA_GetBasePort(Disk);
649 gaATA_IRQs[cont] = 0;
652 outb(base+0x01, 0x00);
653 if( Address > 0x0FFFFFFF ) // Use LBA48
655 outb(base+0x6, 0x40 | (disk << 4));
656 outb(base+0x2, 0 >> 8); // Upper Sector Count
657 outb(base+0x3, Address >> 24); // Low 2 Addr
658 outb(base+0x4, Address >> 28); // Mid 2 Addr
659 outb(base+0x5, Address >> 32); // High 2 Addr
663 outb(base+0x06, 0xE0 | (disk << 4) | ((Address >> 24) & 0x0F)); // Magic, Disk, High addr
666 outb(base+0x02, (Uint8) Count); // Sector Count
667 outb(base+0x03, (Uint8) Address); // Low Addr
668 outb(base+0x04, (Uint8) (Address >> 8)); // Middle Addr
669 outb(base+0x05, (Uint8) (Address >> 16)); // High Addr
671 LOG("Starting Transfer");
672 if( Address > 0x0FFFFFFF )
673 outb(base+0x07, HDD_DMA_R48); // Read Command (LBA48)
675 outb(base+0x07, HDD_DMA_R28); // Read Command (LBA28)
677 ATA_int_BusMasterWriteByte( cont << 3, 9 ); // Read and start
679 // Wait for transfer to complete
681 while( gaATA_IRQs[cont] == 0 && !(val & 0x4) ) {
682 val = ATA_int_BusMasterReadByte( (cont << 3) + 2 );
683 //LOG("val = 0x%02x", val);
688 ATA_int_BusMasterWriteByte( cont << 3, 8 ); // Read and stop
691 LOG("Status byte = 0x%02x", val);
693 LOG("Transfer Completed & Acknowledged");
695 // Copy to destination buffer
696 memcpy( Buffer, gATA_Buffers[cont], Count*SECTOR_SIZE );
698 // Release controller lock
699 RELEASE( &giaATA_ControllerLock[ cont ] );
706 * \fn int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
708 int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
710 int cont = (Disk>>1)&1; // Controller ID
714 // Check if the count is small enough
715 if(Count > MAX_DMA_SECTORS) return 0;
717 // Get exclusive access to the disk controller
718 LOCK( &giaATA_ControllerLock[ cont ] );
721 gATA_PRDTs[ cont ].Bytes = Count * SECTOR_SIZE;
724 base = ATA_GetBasePort(Disk);
727 outb(base+0x01, 0x00);
728 if( Address > 0x0FFFFFFF ) // Use LBA48
730 outb(base+0x6, 0x40 | (disk << 4));
731 outb(base+0x2, 0 >> 8); // Upper Sector Count
732 outb(base+0x3, Address >> 24); // Low 2 Addr
733 outb(base+0x3, Address >> 28); // Mid 2 Addr
734 outb(base+0x3, Address >> 32); // High 2 Addr
738 outb(base+0x06, 0xE0 | (disk << 4) | ((Address >> 24) & 0x0F)); //Disk,Magic,High addr
741 outb(base+0x02, (Uint8) Count); // Sector Count
742 outb(base+0x03, (Uint8) Address); // Low Addr
743 outb(base+0x04, (Uint8) (Address >> 8)); // Middle Addr
744 outb(base+0x05, (Uint8) (Address >> 16)); // High Addr
745 if( Address > 0x0FFFFFFF )
746 outb(base+0x07, HDD_DMA_W48); // Write Command (LBA48)
748 outb(base+0x07, HDD_DMA_W28); // Write Command (LBA28)
751 gaATA_IRQs[cont] = 0;
753 // Copy to output buffer
754 memcpy( gATA_Buffers[cont], Buffer, Count*SECTOR_SIZE );
757 ATA_int_BusMasterWriteByte( cont << 3, 1 ); // Write and start
759 // Wait for transfer to complete
760 while( gaATA_IRQs[cont] == 0 ) Threads_Yield();
763 ATA_int_BusMasterWriteByte( cont << 3, 0 ); // Write and stop
765 // Release controller lock
766 RELEASE( &giaATA_ControllerLock[ cont ] );
772 * \fn void ATA_IRQHandlerPri(int unused)
774 void ATA_IRQHandlerPri(int unused)
778 // IRQ bit set for Primary Controller
779 val = ATA_int_BusMasterReadByte( 0x2 );
780 LOG("IRQ val = 0x%x", val);
782 LOG("IRQ hit (val = 0x%x)", val);
783 ATA_int_BusMasterWriteByte( 0x2, 4 );
790 * \fn void ATA_IRQHandlerSec(int unused)
792 void ATA_IRQHandlerSec(int unused)
795 // IRQ bit set for Secondary Controller
796 val = ATA_int_BusMasterReadByte( 0xA );
797 LOG("IRQ val = 0x%x", val);
799 LOG("IRQ hit (val = 0x%x)", val);
800 ATA_int_BusMasterWriteByte( 0xA, 4 );
807 * \fn Uint8 ATA_int_BusMasterReadByte(int Ofs)
809 Uint8 ATA_int_BusMasterReadByte(int Ofs)
811 if( gATA_BusMasterBase & 1 )
812 return inb( (gATA_BusMasterBase & ~1) + Ofs );
814 return *(Uint8*)(gATA_BusMasterBasePtr + Ofs);
818 * \fn void ATA_int_BusMasterWriteByte(int Ofs, Uint8 Value)
819 * \brief Writes a byte to a Bus Master Register
821 void ATA_int_BusMasterWriteByte(int Ofs, Uint8 Value)
823 if( gATA_BusMasterBase & 1 )
824 outb( (gATA_BusMasterBase & ~1) + Ofs, Value );
826 *(Uint8*)(gATA_BusMasterBasePtr + Ofs) = Value;
830 * \fn void ATA_int_BusMasterWriteDWord(int Ofs, Uint32 Value)
831 * \brief Writes a dword to a Bus Master Register
833 void ATA_int_BusMasterWriteDWord(int Ofs, Uint32 Value)
836 if( gATA_BusMasterBase & 1 )
837 outd( (gATA_BusMasterBase & ~1) + Ofs, Value );
839 *(Uint32*)(gATA_BusMasterBasePtr + Ofs) = Value;