PS2SDK
PS2 Homebrew Libraries
bdm.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 #ifndef __BDM_H__
16 #define __BDM_H__
17 
18 #include <irx.h>
19 #include <types.h>
20 
22 {
23  // Private driver data
24  void *priv;
25 
26  // Device name + number + partition number
27  // Can be used to create device names like:
28  // - mass0p1
29  char *name;
30  unsigned int devNr;
31  unsigned int parNr;
32  unsigned char parId;
33 
34  unsigned int sectorSize; // Size of a sector in bytes
35  u64 sectorOffset; // Starting sector number
36  u64 sectorCount; // Maximum number of sectors usable
37 
38  int (*read)(struct block_device *bd, u64 sector, void *buffer, u16 count);
39  int (*write)(struct block_device *bd, u64 sector, const void *buffer, u16 count);
40  void (*flush)(struct block_device *bd);
41  int (*stop)(struct block_device *bd);
42 
43  // Desired iomanX path prefix for this device type (e.g. "usb", "ata").
44  // When set, the fatfs driver exposes the device under this prefix (e.g. usb0:, ata0:).
45  // Partition drivers should copy this from the parent block device.
46  // NULL means the device is only accessible via the legacy "mass:" prefix.
47  char *path;
48 };
49 
51 {
52  // Private driver data
53  void *priv;
54 
55  // Filesystem (/partition) name
56  char *name;
57 
58  // mount / umount block device
59  int (*connect_bd)(struct block_device *bd);
60  void (*disconnect_bd)(struct block_device *bd);
61 };
62 
63 typedef void (*bdm_cb)(int event);
64 
65 // Exported functions
66 extern void bdm_connect_bd(struct block_device *bd);
67 extern void bdm_disconnect_bd(struct block_device *bd);
68 extern void bdm_connect_fs(struct file_system *fs);
69 extern void bdm_disconnect_fs(struct file_system *fs);
70 extern void bdm_get_bd(struct block_device **pbd, unsigned int count);
71 extern void bdm_RegisterCallback(bdm_cb cb);
72 
73 #define bdm_IMPORTS_start DECLARE_IMPORT_TABLE(bdm, 1, 1)
74 #define bdm_IMPORTS_end END_IMPORT_TABLE
75 
76 #define I_bdm_connect_bd DECLARE_IMPORT(4, bdm_connect_bd)
77 #define I_bdm_disconnect_bd DECLARE_IMPORT(5, bdm_disconnect_bd)
78 #define I_bdm_connect_fs DECLARE_IMPORT(6, bdm_connect_fs)
79 #define I_bdm_disconnect_fs DECLARE_IMPORT(7, bdm_disconnect_fs)
80 #define I_bdm_get_bd DECLARE_IMPORT(8, bdm_get_bd)
81 #define I_bdm_RegisterCallback DECLARE_IMPORT(9, bdm_RegisterCallback)
82 
83 #endif
event
Definition: thcommon.h:71
count
u32 count
start sector of fragmented bd/file
Definition: usbhdfsd-common.h:3
irx.h
block_device
Definition: bdm.h:21
file_system
Definition: bdm.h:50