Renamed tpl_drv_* to api_drv_* (a more fitting name)
[tpg/acess2.git] / Modules / Storage / ATA / main.c
index 9760b4d..11498da 100644 (file)
@@ -2,14 +2,14 @@
  * 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 ===
@@ -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);
@@ -179,7 +179,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 +196,7 @@ int ATA_ScanDisk(int Disk)
        Debug_HexDump("ATA_ScanDisk", &mbr, 512);
        #endif
 
-       LEAVE('i', 0);
+       LEAVE('i', 1);
        return 1;
 }
 
@@ -246,9 +250,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;
@@ -316,8 +320,8 @@ Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
 
        {
                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;
        }

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