Misc - Cleaning up logging output
[tpg/acess2.git] / Modules / Storage / ATA / main.c
index 05caaab..958855f 100644 (file)
@@ -8,8 +8,8 @@
 #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 ===
@@ -25,7 +25,7 @@ void  ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start
 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);
  int   ATA_IOCtl(tVFS_Node *Node, int Id, void *Data);
@@ -139,6 +139,11 @@ int ATA_ScanDisk(int Disk)
 
        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";
@@ -154,13 +159,10 @@ int ATA_ScanDisk(int Disk)
                        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;
@@ -179,7 +181,11 @@ int ATA_ScanDisk(int Disk)
        // --- 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)
@@ -192,7 +198,7 @@ int ATA_ScanDisk(int Disk)
        Debug_HexDump("ATA_ScanDisk", &mbr, 512);
        #endif
 
-       LEAVE('i', 0);
+       LEAVE('i', 1);
        return 1;
 }
 
@@ -221,7 +227,7 @@ void ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start
        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);
+       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('-');
 }
@@ -246,9 +252,9 @@ char *ATA_ReadDir(tVFS_Node *UNUSED(Node), int Pos)
 }
 
 /**
- * \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;

UCC git Repository :: git.ucc.asn.au