Skip to content

Commit 8862a44

Browse files
committed
add: Implementation of usbmload module
1 parent fb6ac5d commit 8862a44

File tree

7 files changed

+1227
-0
lines changed

7 files changed

+1227
-0
lines changed

iop/usb/usbmload/Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# _____ ___ ____ ___ ____
2+
# ____| | ____| | | |____|
3+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
4+
#-----------------------------------------------------------------------
5+
# Copyright ps2dev - http://www.ps2dev.org
6+
# Licenced under Academic Free License version 2.0
7+
# Review ps2sdk README & LICENSE files for further details.
8+
9+
IOP_BIN ?= usbmload.irx
10+
11+
IOP_IMPORT_INCS += \
12+
system/sysmem \
13+
system/loadcore \
14+
system/intrman \
15+
system/stdio \
16+
system/sysclib \
17+
system/modload \
18+
system/ioman \
19+
system/threadman \
20+
usb/usbd
21+
22+
IOP_OBJS = usbmload.o exports.o imports.o
23+
24+
include $(PS2SDKSRC)/Defs.make
25+
include $(PS2SDKSRC)/iop/Rules.bin.make
26+
include $(PS2SDKSRC)/iop/Rules.make
27+
include $(PS2SDKSRC)/iop/Rules.release

iop/usb/usbmload/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# USB Automatic Module Loader
2+
3+
This module provides functions to allow IOP modules to be automatically loaded
4+
and unloaded when a USB device is plugged based on its characteristics.
5+
6+
## Configurations
7+
8+
There are multiple configurations of this library, allowing the choice of
9+
balancing between size, speed, and features.
10+
11+
* `usbmload` -> The recommended version.
12+
13+
## How to use this module in your program
14+
15+
In order to use this module in your program, use `LoadModule` or \
16+
`LoadModuleBuffer` with no arguments.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
#ifndef _USBMLOAD_H
12+
#define _USBMLOAD_H
13+
14+
typedef struct _USBDEV_t
15+
{
16+
struct _USBDEV_t *forw;
17+
char *dispname;
18+
int vendor;
19+
int product;
20+
int release;
21+
int class_;
22+
int subclass;
23+
int protocol;
24+
char *category;
25+
char *path;
26+
char *argv[8];
27+
int argc;
28+
char activate_flag;
29+
int modid;
30+
char modname[56];
31+
int load_result;
32+
} USBDEV_t;
33+
34+
typedef USBDEV_t *(*sceUsbmlPopDevinfo)(void);
35+
36+
typedef void (*sceUsbmlLoadFunc)(sceUsbmlPopDevinfo pop_devinfo);
37+
38+
extern int sceUsbmlDisable(void);
39+
extern int sceUsbmlEnable(void);
40+
extern int sceUsbmlActivateCategory(const char *category);
41+
extern int sceUsbmlInactivateCategory(const char *category);
42+
extern int sceUsbmlRegisterLoadFunc(sceUsbmlLoadFunc loadfunc);
43+
extern void sceUsbmlUnregisterLoadFunc(void);
44+
extern int sceUsbmlLoadConffile(const char *conffile);
45+
extern int sceUsbmlRegisterDevice(USBDEV_t *device);
46+
extern int sceUsbmlChangeThreadPriority(int prio1);
47+
48+
#define usbmload_IMPORTS_start DECLARE_IMPORT_TABLE(usbmload, 1, 3)
49+
#define usbmload_IMPORTS_end END_IMPORT_TABLE
50+
51+
#define I_sceUsbmlDisable DECLARE_IMPORT(4, sceUsbmlDisable)
52+
#define I_sceUsbmlEnable DECLARE_IMPORT(5, sceUsbmlEnable)
53+
#define I_sceUsbmlActivateCategory DECLARE_IMPORT(6, sceUsbmlActivateCategory)
54+
#define I_sceUsbmlInactivateCategory DECLARE_IMPORT(7, sceUsbmlInactivateCategory)
55+
#define I_sceUsbmlRegisterLoadFunc DECLARE_IMPORT(8, sceUsbmlRegisterLoadFunc)
56+
#define I_sceUsbmlUnregisterLoadFunc DECLARE_IMPORT(9, sceUsbmlUnregisterLoadFunc)
57+
#define I_sceUsbmlLoadConffile DECLARE_IMPORT(10, sceUsbmlLoadConffile)
58+
#define I_sceUsbmlRegisterDevice DECLARE_IMPORT(11, sceUsbmlRegisterDevice)
59+
#define I_sceUsbmlChangeThreadPriority DECLARE_IMPORT(12, sceUsbmlChangeThreadPriority)
60+
61+
#endif

iop/usb/usbmload/src/exports.tab

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
DECLARE_EXPORT_TABLE(usbmload, 1, 3)
3+
DECLARE_EXPORT(_start)
4+
DECLARE_EXPORT(_retonly)
5+
DECLARE_EXPORT(_retonly)
6+
DECLARE_EXPORT(_retonly)
7+
DECLARE_EXPORT(sceUsbmlDisable)
8+
DECLARE_EXPORT(sceUsbmlEnable)
9+
DECLARE_EXPORT(sceUsbmlActivateCategory)
10+
DECLARE_EXPORT(sceUsbmlInactivateCategory)
11+
DECLARE_EXPORT(sceUsbmlRegisterLoadFunc)
12+
DECLARE_EXPORT(sceUsbmlUnregisterLoadFunc)
13+
DECLARE_EXPORT(sceUsbmlLoadConffile)
14+
DECLARE_EXPORT(sceUsbmlRegisterDevice)
15+
DECLARE_EXPORT(sceUsbmlChangeThreadPriority)
16+
END_EXPORT_TABLE
17+
18+
void _retonly() {}

iop/usb/usbmload/src/imports.lst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
sysmem_IMPORTS_start
3+
I_AllocSysMemory
4+
I_FreeSysMemory
5+
sysmem_IMPORTS_end
6+
7+
loadcore_IMPORTS_start
8+
I_RegisterLibraryEntries
9+
I_ReleaseLibraryEntries
10+
loadcore_IMPORTS_end
11+
12+
intrman_IMPORTS_start
13+
I_CpuSuspendIntr
14+
I_CpuResumeIntr
15+
intrman_IMPORTS_end
16+
17+
stdio_IMPORTS_start
18+
I_printf
19+
stdio_IMPORTS_end
20+
21+
thbase_IMPORTS_start
22+
I_CreateThread
23+
I_DeleteThread
24+
I_StartThread
25+
I_TerminateThread
26+
I_ChangeThreadPriority
27+
thbase_IMPORTS_end
28+
29+
thevent_IMPORTS_start
30+
I_CreateEventFlag
31+
I_DeleteEventFlag
32+
I_SetEventFlag
33+
I_WaitEventFlag
34+
thevent_IMPORTS_end
35+
36+
sysclib_IMPORTS_start
37+
I_strcmp
38+
I_strcpy
39+
I_strlen
40+
I_strtol
41+
I_memcpy
42+
sysclib_IMPORTS_end
43+
44+
xmodload_IMPORTS_start
45+
I_LoadStartModule
46+
I_ReferModuleStatus
47+
I_StopModule
48+
I_UnloadModule
49+
xmodload_IMPORTS_end
50+
51+
ioman_IMPORTS_start
52+
I_open
53+
I_close
54+
I_read
55+
ioman_IMPORTS_end
56+
57+
usbd_IMPORTS_start
58+
I_sceUsbdScanStaticDescriptor
59+
I_sceUsbdRegisterAutoloader
60+
I_sceUsbdUnregisterAutoloader
61+
usbd_IMPORTS_end

iop/usb/usbmload/src/irx_imports.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
#
10+
# Defines all IRX imports.
11+
*/
12+
13+
#ifndef IOP_IRX_IMPORTS_H
14+
#define IOP_IRX_IMPORTS_H
15+
16+
#include <irx.h>
17+
18+
/* Please keep these in alphabetical order! */
19+
20+
#include <intrman.h>
21+
#include <ioman.h>
22+
#include <loadcore.h>
23+
#include <stdio.h>
24+
#include <sysclib.h>
25+
#include <sysmem.h>
26+
#include <thbase.h>
27+
#include <thevent.h>
28+
#include <usbd.h>
29+
#include <xmodload.h>
30+
31+
#endif /* IOP_IRX_IMPORTS_H */

0 commit comments

Comments
 (0)