PS2SDK
PS2 Homebrew Libraries
usbhdfsd.c
1 /*
2  * usb_mass.c - USB Mass storage driver for PS2
3  */
4 
5 #define MAJOR_VER 1
6 #define MINOR_VER 6
7 
8 #include <loadcore.h>
9 #include <intrman.h>
10 #include <stdio.h>
11 #include <sysmem.h>
12 #include <usbhdfsd.h>
13 
14 #include <irx.h>
15 #include "mass_debug.h"
16 IRX_ID(MODNAME, MAJOR_VER, MINOR_VER);
17 
18 extern int InitFAT();
19 extern int InitFS();
20 extern int InitUSB();
21 
22 extern struct irx_export_table _exp_usbmass;
23 
24 int _start(int argc, char *argv[])
25 {
26  (void)argc;
27  (void)argv;
28 
29  printf("USB HDD FileSystem Driver v%d.%d\n", MAJOR_VER, MINOR_VER);
30 
31  if (RegisterLibraryEntries(&_exp_usbmass) != 0) {
32  printf("USBHDFSD: Already registered.\n");
33  return MODULE_NO_RESIDENT_END;
34  }
35 
36  // initialize the FAT driver
37  if (InitFAT() != 0) {
38  printf("USBHDFSD: Error initializing FAT driver!\n");
39  return MODULE_NO_RESIDENT_END;
40  }
41 
42  // initialize the USB driver
43  if (InitUSB() != 0) {
44  printf("USBHDFSD: Error initializing USB driver!\n");
45  return MODULE_NO_RESIDENT_END;
46  }
47 
48  // initialize the file system driver
49  if (InitFS() != 0) {
50  printf("USBHDFSD: Error initializing FS driver!\n");
51  return MODULE_NO_RESIDENT_END;
52  }
53 
54  // return resident
55  return MODULE_RESIDENT_END;
56 }
57 
58 #ifndef WIN32
59 void *malloc(int size)
60 {
61  void *result;
62  int OldState;
63 
64  CpuSuspendIntr(&OldState);
65  result = AllocSysMemory(ALLOC_FIRST, size, NULL);
66  CpuResumeIntr(OldState);
67 
68  return result;
69 }
70 
71 void free(void *ptr)
72 {
73  int OldState;
74 
75  CpuSuspendIntr(&OldState);
76  FreeSysMemory(ptr);
77  CpuResumeIntr(OldState);
78 }
79 #endif
CpuSuspendIntr
int CpuSuspendIntr(int *state)
Definition: intrman.c:195
loadcore.h
irx.h
irx_export_table
Definition: irx.h:90
stdio.h
CpuResumeIntr
int CpuResumeIntr(int state)
Definition: intrman.c:217
sysmem.h
intrman.h
usbhdfsd.h