* Acess2 IDE Harddisk Driver
* - main.c
*/
-#define DEBUG 1
+#define DEBUG 0
#define VERSION 0x0032
#include <acess.h>
#include <modules.h>
#include <vfs.h>
#include <fs_devfs.h>
-#include <tpl_drv_common.h>
-#include <tpl_drv_disk.h>
+#include <api_drv_common.h>
+#include <api_drv_disk.h>
#include "common.h"
// === MACROS ===
Uint16 ATA_GetBasePort(int Disk);
// Filesystem Interface
char *ATA_ReadDir(tVFS_Node *Node, int Pos);
-tVFS_Node *ATA_FindDir(tVFS_Node *Node, char *Name);
+tVFS_Node *ATA_FindDir(tVFS_Node *Node, const char *Name);
Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data);
// Read/Write Interface/Quantiser
Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk);
-Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk);
+Uint ATA_WriteRaw(Uint64 Address, Uint Count, const void *Buffer, Uint Disk);
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, i386ATA, ATA_Install, NULL, "PCI", NULL);
+tVFS_NodeType gATA_RootNodeType = {
+ .TypeName = "ATA Root Node",
+ .ReadDir = ATA_ReadDir,
+ .FindDir = ATA_FindDir
+ };
+tVFS_NodeType gATA_DiskNodeType = {
+ .TypeName = "ATA Volume",
+ .Read = ATA_ReadFS,
+ .Write = ATA_WriteFS,
+ .IOCtl = ATA_IOCtl
+ };
tDevFS_Driver gATA_DriverInfo = {
NULL, "ata",
{
.Size = -1,
.Flags = VFS_FFLAG_DIRECTORY,
.ACLs = &gVFS_ACL_EveryoneRX,
- .ReadDir = ATA_ReadDir,
- .FindDir = ATA_FindDir
+ .Type = &gATA_RootNodeType
}
};
tATA_Disk gATA_Disks[MAX_ATA_DISKS];
LOG("gATA_Disks[ %i ].Sectors = 0x%x", Disk, gATA_Disks[ Disk ].Sectors);
+ // Create Name
+ gATA_Disks[ Disk ].Name[0] = 'A'+Disk;
+ gATA_Disks[ Disk ].Name[1] = '\0';
+
+ #if 1
{
Uint64 val = gATA_Disks[ Disk ].Sectors / 2;
char *units = "KiB";
val /= 1024;
units = "TiB";
}
- Log_Log("ATA", "Disk %i: 0x%llx Sectors (%lli %s)", Disk,
- gATA_Disks[ Disk ].Sectors, val, units);
+ Log_Notice("ATA", "Disk %s: 0x%llx Sectors (%lli %s)",
+ gATA_Disks[ Disk ].Name, gATA_Disks[ Disk ].Sectors, val, units);
}
-
- // Create Name
- gATA_Disks[ Disk ].Name[0] = 'A'+Disk;
- gATA_Disks[ Disk ].Name[1] = '\0';
+ #endif
// Get pointer to vfs node and populate it
node = &gATA_Disks[ Disk ].Node;
node->Inode = (Disk << 8) | 0xFF;
node->ImplPtr = gATA_Disks[ Disk ].Name;
- node->ATime = node->MTime
- = node->CTime = now();
+ node->ATime = node->MTime = node->CTime = now();
- node->Read = ATA_ReadFS;
- node->Write = ATA_WriteFS;
- node->IOCtl = ATA_IOCtl;
+ node->Type = &gATA_DiskNodeType;
// --- Scan Partitions ---
LOG("Reading MBR");
// Read Boot Sector
- ATA_ReadDMA( Disk, 0, 1, &mbr );
+ if( ATA_ReadDMA( Disk, 0, 1, &mbr ) != 0 ) {
+ Log_Warning("ATA", "Error in reading MBR on %i", Disk);
+ LEAVE('i', 0);
+ return 0;
+ }
// Check for a GPT table
if(mbr.Parts[0].SystemID == 0xEE)
Debug_HexDump("ATA_ScanDisk", &mbr, 512);
#endif
- LEAVE('i', 0);
+ LEAVE('i', 1);
return 1;
}
Part->Node.Inode = (Disk << 8) | Num;
Part->Node.ImplPtr = Part->Name;
- Part->Node.Read = ATA_ReadFS;
- Part->Node.Write = ATA_WriteFS;
- Part->Node.IOCtl = ATA_IOCtl;
- Log_Notice("ATA", "Note '%s' at 0x%llx, 0x%llx long", Part->Name, Part->Start, Part->Length);
+ Part->Node.Type = &gATA_DiskNodeType;
+ Log_Notice("ATA", "Partition %s at 0x%llx+0x%llx", Part->Name, Part->Start, Part->Length);
LOG("Made '%s' (&Node=%p)", Part->Name, &Part->Node);
LEAVE('-');
}
}
/**
- * \fn tVFS_Node *ATA_FindDir(tVFS_Node *Node, char *Name)
+ * \fn tVFS_Node *ATA_FindDir(tVFS_Node *Node, const char *Name)
*/
-tVFS_Node *ATA_FindDir(tVFS_Node *UNUSED(Node), char *Name)
+tVFS_Node *ATA_FindDir(tVFS_Node *UNUSED(Node), const char *Name)
{
int part;
tATA_Disk *disk;
{
int ret = DrvUtil_ReadBlock(Offset, Length, Buffer, ATA_ReadRaw, SECTOR_SIZE, disk);
- Log("ATA_ReadFS: disk=%i, Offset=%lli, Length=%lli", disk, Offset, Length);
- Debug_HexDump("ATA_ReadFS", Buffer, Length);
+ //Log("ATA_ReadFS: disk=%i, Offset=%lli, Length=%lli", disk, Offset, Length);
+ //Debug_HexDump("ATA_ReadFS", Buffer, Length);
LEAVE('i', ret);
return ret;
}
}
/**
- * \fn Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+ * \fn Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
*/
-Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
int disk = Node->Inode >> 8;
int part = Node->Inode & 0xFF;
}
/**
- * \fn Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
+ * \fn Uint ATA_WriteRaw(Uint64 Address, Uint Count, const void *Buffer, Uint Disk)
*/
-Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
+Uint ATA_WriteRaw(Uint64 Address, Uint Count, const void *Buffer, Uint Disk)
{
int ret;
Uint offset;