18e62a8d0308b49750c17b17796119bef3a4bb40
[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 MAX_DMA_SECTORS (0x1000 / SECTOR_SIZE)
15
16 #define IDE_PRI_BASE    0x1F0
17 #define IDE_SEC_BASE    0x170
18
19 #define IDE_PRDT_LAST   0x8000
20 /**
21  \enum HddControls
22  \brief Commands to be sent to HDD_CMD
23 */
24 enum HddControls {
25         HDD_PIO_R28 = 0x20,
26         HDD_PIO_R48 = 0x24,
27         HDD_DMA_R48 = 0x25,
28         HDD_PIO_W28 = 0x30,
29         HDD_PIO_W48 = 0x34,
30         HDD_DMA_W48 = 0x35,
31         HDD_DMA_R28 = 0xC8,
32         HDD_DMA_W28 = 0xCA,
33 };
34
35 // === STRUCTURES ===
36 typedef struct
37 {
38         Uint8   BootCode[0x1BE];
39         struct {
40                 Uint8   Boot;
41                 Uint8   Unused1;        // Also CHS Start
42                 Uint16  StartHi;        // Also CHS Start
43                 Uint8   SystemID;
44                 Uint8   Unused2;        // Also CHS Length
45                 Uint16  LengthHi;       // Also CHS Length
46                 Uint32  LBAStart;
47                 Uint32  LBALength;
48         } __attribute__ ((packed)) Parts[4];
49         Uint16  BootFlag;       // = 0xAA 55
50 } __attribute__ ((packed))      tMBR;
51
52 typedef struct
53 {
54         Uint64  Start;
55         Uint64  Length;
56         char    Name[4];
57         tVFS_Node       Node;
58 }       tATA_Partition;
59
60 typedef struct
61 {
62         Uint64  Sectors;
63         char    Name[2];
64         tVFS_Node       Node;
65          int    NumPartitions;
66         tATA_Partition  *Partitions;
67 }       tATA_Disk;
68
69 // === GLOBALS ===
70 extern tATA_Disk        gATA_Disks[];
71
72 // === FUNCTIONS ===
73 extern void     ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start, Uint64 Length);
74 extern int      ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer);
75 extern int      ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer);
76
77 #endif

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