Kernel - Slight reworks to timer code
[tpg/acess2.git] / Modules / Storage / ATA / common.h
1 /*
2  * Acess2 IDE Harddisk Driver
3  * - main.c
4  */
5 #ifndef _COMMON_H_
6 #define _COMMON_H_
7
8 #include <acess.h>
9 #include <vfs.h>
10
11 // === CONSTANTS ===
12 #define MAX_ATA_DISKS   4
13 #define SECTOR_SIZE     512
14 #define ATA_TIMEOUT     2000    // 2s timeout
15 // Needed out of io.c because it's the max for Read/WriteDMA
16 #define MAX_DMA_SECTORS (0x1000 / SECTOR_SIZE)
17
18 // === STRUCTURES ===
19 typedef struct
20 {
21         Uint8   BootCode[0x1BE];
22         struct {
23                 Uint8   Boot;
24                 Uint8   Unused1;        // Also CHS Start
25                 Uint16  StartHi;        // Also CHS Start
26                 Uint8   SystemID;
27                 Uint8   Unused2;        // Also CHS Length
28                 Uint16  LengthHi;       // Also CHS Length
29                 Uint32  LBAStart;
30                 Uint32  LBALength;
31         } __attribute__ ((packed)) Parts[4];
32         Uint16  BootFlag;       // = 0xAA 55
33 } __attribute__ ((packed))      tMBR;
34
35 typedef struct
36 {
37         Uint64  Start;
38         Uint64  Length;
39         char    Name[4];
40         tVFS_Node       Node;
41 }       tATA_Partition;
42
43 typedef struct
44 {
45         Uint64  Sectors;
46         char    Name[2];
47         tVFS_Node       Node;
48          int    NumPartitions;
49         tATA_Partition  *Partitions;
50 }       tATA_Disk;
51
52 // === GLOBALS ===
53 extern tATA_Disk        gATA_Disks[];
54
55 // === FUNCTIONS ===
56 // --- Common ---
57 extern void     ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start, Uint64 Length);
58
59 // --- MBR Parsing ---
60 extern void     ATA_ParseMBR(int Disk, tMBR *MBR);
61
62 // --- IO Functions ---
63 extern int      ATA_SetupIO(void);
64 extern Uint64   ATA_GetDiskSize(int Disk);
65 extern int      ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer);
66 extern int      ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer);
67
68 #endif

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