mgh: fix for default HDD DMA mode, that wasn't correctly set
[open-ps2-loader.git] / modules / hdd / ps2hdd / hdd.h
blob336f1ce908c6b3994ebe99b96f9f838a41f2d964
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
10 # $Id: hdd.h 1421 2007-07-07 01:56:53Z radad $
11 # Main APA Header file
14 #ifndef _HDD_H
15 #define _HDD_H
17 #include <types.h>
18 #include <defs.h>
19 #include <irx.h>
20 #include "atad.h"
21 #include <dev9.h>
22 #include <loadcore.h>
23 #include <poweroff.h>
24 #include <sysmem.h>
25 #include <stdio.h>
26 #include <sysclib.h>
27 #include <errno.h>
28 #include <sys/fcntl.h>
29 #include <sys/stat.h>
30 #include <iomanX.h>
31 #include <thbase.h>
32 #include <thsemap.h>
33 #include <intrman.h>
34 #include <cdvdman.h>
36 #include "helper.h"// for old atad, dev9 names need..
38 #define DEBUG_LEVEL1
39 //#define DEBUG_LEVEL2
41 #ifdef DEBUG_LEVEL1
42 #define dprintf1 printf
43 #else
44 #define dprintf1 printf(format, args...)
45 #endif
47 #ifdef DEBUG_LEVEL2
48 #define dprintf2 printf
49 #else
50 #define dprintf2(format, args...)
51 #endif
53 typedef struct
55 u32 totalLBA;
56 u32 partitionMaxSize;
57 u32 format;
58 u32 status;
59 } hdd_device_t;
61 // modes for cacheGetHeader
62 #define THEADER_MODE_READ 0x00
63 #define THEADER_MODE_WRITE 0x01
66 typedef struct {
67 u8 unused;
68 u8 sec;
69 u8 min;
70 u8 hour;
71 u8 day;
72 u8 month;
73 u16 year;
74 } ps2time;
77 // MAIN APA defines/struct
79 typedef struct { // for a hack :P
80 u32 start; // Sector address
81 u32 length; // Sector count
82 } apa_subs;
84 // Sectors for this and that ;)
85 #define APA_SECTOR_MBR 0
86 #define APA_SECTOR_SECTOR_ERROR 6// use for last sector that had a error...
87 #define APA_SECTOR_PART_ERROR 7// use for last partition that had a error...
88 #define APA_SECTOR_APAL 8
89 #define APA_SECTOR_APAL_HEADERS 10 // 10-262
91 // APA Partition
92 #define APA_MAGIC 0x00415041 // 'APA\0'
93 #define APA_IDMAX 32
94 #define APA_MAXSUB 64 // Maximum # of sub-partitions
95 #define APA_PASSMAX 8
96 #define APA_FLAG_SUB 0x0001
97 #define APA_MBR_VERSION 2
98 // format/types
99 #define APA_TYPE_FREE 0x0000
100 #define APA_TYPE_MBR 0x0001 // Master Boot Record
101 #define APA_TYPE_EXT2SWAP 0x0082
102 #define APA_TYPE_EXT2 0x0083
103 #define APA_TYPE_PFS 0x0100
104 #define APA_TYPE_CFS 0x0101
106 #define APA_MODVER 0x0201
108 typedef struct
110 u32 checksum;
111 u32 magic; // APA_MAGIC
112 u32 next;
113 u32 prev;
114 char id[APA_IDMAX]; // 16
115 char rpwd[APA_PASSMAX]; // 48
116 char fpwd[APA_PASSMAX]; // 56
117 u32 start; // 64
118 u32 length; // 68
119 u16 type; // 72
120 u16 flags; // 74
121 u32 nsub; // 76
122 ps2time created; // 80
123 u32 main; // 88
124 u32 number; // 92
125 u32 modver; // 96
126 u32 pading1[7]; // 100
127 char pading2[128]; // 128
128 struct { // 256
129 char magic[32];
130 u32 version;
131 u32 nsector;
132 ps2time created;
133 u32 osdStart;
134 u32 osdSize;
135 char pading3[200];
136 } mbr;
137 struct {
138 u32 start;
139 u32 length;
140 } subs[APA_MAXSUB];
141 } apa_header;
144 typedef struct
146 char id[APA_IDMAX];
147 u32 size;
148 u16 type;
149 u16 flags;
150 u32 main;
151 u32 number;
152 } input_param;
154 typedef struct
156 iop_file_t *f; // used to see if open...
157 u32 post; // offset/post....
158 u16 nsub;
159 u16 type;
160 char id[APA_IDMAX];
161 u32 start; // <--- TODO move to subs ..., has not been moved to risk e of fucking it up ;)
162 u32 length;
163 struct { // Sub-partition data
164 u32 start; // Sector address
165 u32 length; // Sector count
166 } subs[APA_MAXSUB];
167 } hdd_file_slot_t;
170 ///////////////////////////////////////////////////////////////////////////////
171 // Externs
172 extern hdd_device_t hddDeviceBuf[2];
173 extern u32 maxOpen;
174 extern hdd_file_slot_t *fileSlots;
175 extern char mbrMagic[0x20];
176 extern char myPassHash[APA_PASSMAX];
177 ///////////////////////////////////////////////////////////////////////////////
178 // Function declerations
179 int inputError(char *input);
180 int unlockDrive(u32 device);
182 #include "cache.h"
183 #include "apa.h"
184 #include "misc.h"
185 #include "journal.h"
186 #include "hdd_fio.h"
187 #endif