PS2SDK
PS2 Homebrew Libraries
main.c
1 #include <bdm.h>
2 #include <intrman.h>
3 #include <irx.h>
4 #include <loadcore.h>
5 #include <stdio.h>
6 #include <sysmem.h>
7 
8 #include "fat_driver.h"
9 
10 // #define DEBUG //comment out this line when not debugging
11 #include "mass_debug.h"
12 
13 #define MAJOR_VER 1
14 #define MINOR_VER 1
15 
16 IRX_ID("bdmvfat", MAJOR_VER, MINOR_VER);
17 
18 extern int InitFAT(void);
19 extern int InitFS(void);
20 
21 static struct file_system g_fs = {
22  .priv = NULL,
23  .name = "vfat",
24  .connect_bd = fat_mount,
25  .disconnect_bd = fat_forceUnmount,
26 };
27 
28 int _start(int argc, char *argv[])
29 {
30  (void)argc;
31  (void)argv;
32 
33  printf("BDM VFAT driver (FAT12/16/32) v%d.%d\n", MAJOR_VER, MINOR_VER);
34 
35  // initialize the FAT driver
36  if (InitFAT() != 0) {
37  M_DEBUG("Error initializing FAT driver!\n");
38  return MODULE_NO_RESIDENT_END;
39  }
40 
41  // initialize the file system driver
42  if (InitFS() != 0) {
43  M_DEBUG("Error initializing FS driver!\n");
44  return MODULE_NO_RESIDENT_END;
45  }
46 
47  // Connect to block device manager
48  bdm_connect_fs(&g_fs);
49 
50  // return resident
51  return MODULE_RESIDENT_END;
52 }
53 
54 void *malloc(int size)
55 {
56  void *result;
57  int OldState;
58 
59  CpuSuspendIntr(&OldState);
60  result = AllocSysMemory(ALLOC_FIRST, size, NULL);
61  CpuResumeIntr(OldState);
62 
63  return result;
64 }
65 
66 void free(void *ptr)
67 {
68  int OldState;
69 
70  CpuSuspendIntr(&OldState);
71  FreeSysMemory(ptr);
72  CpuResumeIntr(OldState);
73 }
bdm.h
CpuSuspendIntr
int CpuSuspendIntr(int *state)
Definition: intrman.c:195
_start
int _start(int argc, char *argv[])
Definition: main.c:46
loadcore.h
irx.h
stdio.h
CpuResumeIntr
int CpuResumeIntr(int state)
Definition: intrman.c:217
sysmem.h
intrman.h
file_system
Definition: bdm.h:50