sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
usbhdfsd.h
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Licenced under Academic Free License version 2.0
7
# Review ps2sdk README & LICENSE files for further details.
8
*/
9
15
16
#ifndef __USBHDFSD_H__
17
#define __USBHDFSD_H__
18
19
#include <types.h>
20
#include <
irx.h
>
21
#include <
usbhdfsd-common.h
>
22
23
// Structure definitions
24
typedef
struct
UsbMassDeviceInfo
25
{
27
unsigned
short
int
status
;
28
unsigned
short
int
SectorSize;
29
unsigned
int
MaxLBA;
30
} UsbMassDeviceInfo_t;
31
32
typedef
void (*usbmass_cb_t)(
int
cause);
33
34
struct
_cache_set
;
35
typedef
struct
_cache_set
cache_set;
36
struct
_mass_dev
;
37
typedef
struct
_mass_dev
mass_dev;
38
39
// number of cache slots (1 slot = block)
40
#define CACHE_SIZE 32
41
42
typedef
struct
_cache_record
43
{
44
unsigned
int
sector;
45
int
tax;
46
char
writeDirty;
47
} cache_record;
48
49
struct
_cache_set
50
{
51
mass_dev *dev;
52
unsigned
int
sectorSize;
53
unsigned
int
indexLimit;
54
unsigned
char
*sectorBuf;
// = NULL; //sector content - the cache buffer
55
cache_record rec[CACHE_SIZE];
// cache info record
56
57
#ifdef SCACHE_RECORD_STATS
58
// statistical information
59
unsigned
int
cacheAccess;
60
unsigned
int
cacheHits;
61
#endif
62
unsigned
int
writeFlag;
63
};
64
65
struct
_mass_dev
66
{
67
int
controlEp;
// config endpoint id
68
int
bulkEpI;
// in endpoint id
69
int
bulkEpO;
// out endpoint id
70
int
devId;
// device id
71
unsigned
char
configId;
// configuration id
72
unsigned
char
status;
73
unsigned
char
interfaceNumber;
// interface number
74
unsigned
char
interfaceAlt;
// interface alternate setting
75
unsigned
int
sectorSize;
// = 512; // store size of sector from usb mass
76
unsigned
int
maxLBA;
77
int
ioSema;
78
cache_set *cache;
79
usbmass_cb_t callback;
80
};
81
82
typedef
struct
_fat_bpb
83
{
84
unsigned
int
sectorSize;
// bytes per sector - should be 512
85
unsigned
char
clusterSize;
// sectors per cluster - power of two
86
unsigned
int
resSectors;
// reserved sectors - typically 1 (boot sector)
87
unsigned
char
fatCount;
// number of FATs - must be 2
88
unsigned
int
rootSize;
// number of rootdirectory entries - typically 512
89
unsigned
int
fatSize;
// sectors per FAT - varies
90
unsigned
int
trackSize;
// sectors per track
91
unsigned
int
headCount;
// number of heads
92
unsigned
int
sectorCount;
// number of sectors
93
unsigned
int
partStart;
// sector where partition starts (boot sector)
94
unsigned
int
rootDirStart;
// sector where root directory starts
95
unsigned
int
rootDirCluster;
// fat32 - cluster of the root directory
96
unsigned
int
activeFat;
// fat32 - current active fat number
97
unsigned
char
fatType;
// 12-FAT16, 16-FAT16, 32-FAT32
98
unsigned
char
fatId[9];
// File system ID. "FAT12", "FAT16" or "FAT " - for debug only
99
unsigned
int
dataStart;
// sector where data starts
100
} fat_bpb;
101
102
typedef
struct
_fat_driver
103
{
104
mass_dev *dev;
105
fat_bpb partBpb;
// partition bios parameter block
106
107
// modified by Hermes
108
#define MAX_DIR_CLUSTER 512
109
unsigned
int
cbuf[MAX_DIR_CLUSTER];
// cluster index buffer // 2048 by Hermes
110
111
unsigned
int
lastChainCluster;
112
int
lastChainResult;
113
114
/* enough for long filename of length 260 characters (20*13) and one short filename */
115
#define MAX_DE_STACK 21
116
unsigned
int
deSec[MAX_DE_STACK];
// direntry sector
117
int
deOfs[MAX_DE_STACK];
// direntry offset
118
int
deIdx;
// direntry index
119
120
#define SEQ_MASK_SIZE 2048
// Allow 2K files per directory
121
u8 seq_mask[SEQ_MASK_SIZE / 8];
// bitmask for consumed seq numbers
122
#define DIR_MASK_SIZE 2048 * 11
// Allow 2K maxed fullnames per directory
123
u8 dir_used_mask[DIR_MASK_SIZE / 8];
// bitmask for used directory entries
124
125
#define MAX_CLUSTER_STACK 128
126
unsigned
int
clStack[MAX_CLUSTER_STACK];
// cluster allocation stack
127
int
clStackIndex;
128
unsigned
int
clStackLast;
// last free cluster of the fat table
129
} fat_driver;
130
131
// Exported functions
132
extern
int
UsbMassGetDeviceInfo(
int
device, UsbMassDeviceInfo_t *info);
133
extern
int
UsbMassRegisterCallback(
int
device, usbmass_cb_t callback);
134
extern
fat_driver *UsbMassFatGetData(
int
device);
135
extern
int
UsbMassReadSector(fat_driver *fatd,
void
**buffer, u32 sector);
136
extern
int
UsbMassWriteSector(fat_driver *fatd, u32 sector);
137
extern
void
UsbMassFlushCache(fat_driver *fatd);
138
extern
int
UsbMassFatGetClusterChain(fat_driver *fatd,
unsigned
int
cluster,
unsigned
int
*buf,
unsigned
int
bufSize,
int
startFlag);
139
140
#define usbmass_IMPORTS_start DECLARE_IMPORT_TABLE(usbmass, 1, 2)
141
#define usbmass_IMPORTS_end END_IMPORT_TABLE
142
143
#define I_UsbMassGetDeviceInfo DECLARE_IMPORT(4, UsbMassGetDeviceInfo)
144
#define I_UsbMassRegisterCallback DECLARE_IMPORT(5, UsbMassRegisterCallback)
145
#define I_UsbMassFatGetData DECLARE_IMPORT(6, UsbMassFatGetData)
146
#define I_UsbMassReadSector DECLARE_IMPORT(7, UsbMassReadSector)
147
#define I_UsbMassWriteSector DECLARE_IMPORT(8, UsbMassWriteSector)
148
#define I_UsbMassFlushCache DECLARE_IMPORT(9, UsbMassFlushCache)
149
#define I_UsbMassFatGetClusterChain DECLARE_IMPORT(10, UsbMassFatGetClusterChain)
150
151
#endif
/* __USBHDFSD_H__ */
irx.h
UsbMassDeviceInfo
Definition
usbhdfsd.h:25
UsbMassDeviceInfo::status
unsigned short int status
Definition
usbhdfsd.h:27
_cache_record
Definition
usbhdfsd.h:43
_cache_set
Definition
usbhdfsd.h:50
_fat_bpb
Definition
usbhdfsd.h:83
_fat_driver
Definition
usbhdfsd.h:103
_mass_dev
Definition
usbhdfsd.h:66
usbhdfsd-common.h
core
usbhdfsd
include
usbhdfsd.h
Generated by
1.18.0