PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
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#include <cdvdman.h>
8
9#include "ff.h"
10#include "fs_driver.h"
11
12//#define DEBUG //comment out this line when not debugging
13#include "module_debug.h"
14
15#define MAJOR_VER 1
16#define MINOR_VER 4
17
18IRX_ID("bdmff", MAJOR_VER, MINOR_VER);
19
20static struct file_system g_fs = {
21 .priv = NULL,
22 .name = "fatfs",
23 .connect_bd = connect_bd,
24 .disconnect_bd = disconnect_bd,
25};
26
27int _start(int argc, char *argv[])
28{
29 (void)argc;
30 (void)argv;
31
32 printf("BDM FatFs driver (FAT/exFAT) v%d.%d\n", MAJOR_VER, MINOR_VER);
33
34 // initialize the file system driver
35 if (InitFS() != 0) {
36 M_DEBUG("Error initializing FatFs driver!\n");
37 return MODULE_NO_RESIDENT_END;
38 }
39
40 // Connect to block device manager
41 bdm_connect_fs(&g_fs);
42
43 // return resident
44 return MODULE_RESIDENT_END;
45}
46
47void *malloc(int size)
48{
49 void *result;
50 int OldState;
51
52 CpuSuspendIntr(&OldState);
53 result = AllocSysMemory(ALLOC_FIRST, size, NULL);
54 CpuResumeIntr(OldState);
55
56 return result;
57}
58
59void free(void *ptr)
60{
61 int OldState;
62
63 CpuSuspendIntr(&OldState);
64 FreeSysMemory(ptr);
65 CpuResumeIntr(OldState);
66}
int CpuResumeIntr(int state)
Definition intrman.c:227
int CpuSuspendIntr(int *state)
Definition intrman.c:205