Commits

Michael Jimenez committed 7fbb1c8

cdvdfsv: implemented sceCdChangeThreadPriority export (as suggested by romz)

  • Participants
  • Parent commits 95161ec

Comments (0)

Files changed (4)

File modules/iopcore/cdvdfsv/Makefile

 # $Id: $
 
 IOP_BIN = cdvdfsv.irx
-IOP_OBJS = cdvdfsv.o imports.o
+IOP_OBJS = cdvdfsv.o imports.o exports.o
 
 ifeq ($(DEBUG),1)
 DEBUG_FLAGS = -DDEBUG

File modules/iopcore/cdvdfsv/cdvdfsv.c

 
 #define CDVDFSV_BUF_SECTORS		2
 
+int init_thread_id;
+int rpc0_thread_id, rpc1_thread_id, rpc2_thread_id;
+
+struct irx_export_table _exp_cdvdfsv;
+
 //-------------------------------------------------------------------------
 int _start(int argc, char** argv)
 {
 	iop_thread_t thread_param;
-	int thread_id;
+
+	RegisterLibraryEntries(&_exp_cdvdfsv);
 
 	FlushDcache();
 	CpuEnableIntr();
 	thread_param.attr = TH_C;
 	thread_param.option = 0;
 	thread_param.thread = (void *)init_thread;
-	thread_param.stacksize = 0x2000;
-	thread_param.priority = 0x51;
+	thread_param.stacksize = 0x800;
+	thread_param.priority = 0x50;
 
-	thread_id = CreateThread(&thread_param);
-	StartThread(thread_id, 0);
+	init_thread_id = CreateThread(&thread_param);
+	StartThread(init_thread_id, 0);
 
 	return MODULE_RESIDENT_END;
 }
 void cdvdfsv_startrpcthreads(void)
 {
 	iop_thread_t thread_param;
-	int thread_id;
 
 	thread_param.attr = TH_C;
 	thread_param.option = 0;
 	thread_param.stacksize = 0x1900;
 	thread_param.priority = 0x51;
 
-	thread_id = CreateThread(&thread_param);
-	StartThread(thread_id, 0);
+	rpc1_thread_id = CreateThread(&thread_param);
+	StartThread(rpc1_thread_id, 0);
 
 	thread_param.attr = TH_C;
 	thread_param.option = 0;
 	thread_param.stacksize = 0x1900;
 	thread_param.priority = 0x51;
 
-	thread_id = CreateThread(&thread_param);
-	StartThread(thread_id, 0);
+	rpc2_thread_id = CreateThread(&thread_param);
+	StartThread(rpc2_thread_id, 0);
 
-	if (!g_reduced_iopmemusage) {
-		thread_param.attr = TH_C;
-		thread_param.option = 0;
-		thread_param.thread = (void *)cdvdfsv_rpc0_th;
-		thread_param.stacksize = 0x800;
-		thread_param.priority = 0x51;
+	thread_param.attr = TH_C;
+	thread_param.option = 0;
+	thread_param.thread = (void *)cdvdfsv_rpc0_th;
+	thread_param.stacksize = 0x800;
+	thread_param.priority = 0x51;
 
-		thread_id = CreateThread(&thread_param);
-		StartThread(thread_id, 0);
-	}
+	rpc0_thread_id = CreateThread(&thread_param);
+	StartThread(rpc0_thread_id, 0);
 }
 
 //-------------------------------------------------------------------------
 }
 
 //-------------------------------------------------------------------------
+int sceCdChangeThreadPriority(int priority)
+{
+	iop_thread_info_t th_info;
+
+	if ((u32)(priority - 9) < 0x73) {
+		if (priority == 9)
+			priority = 10;
+
+		ReferThreadStatus(0, &th_info);
+
+		ChangeThreadPriority(0, 0x08);
+		ChangeThreadPriority(init_thread_id, priority-1);
+		ChangeThreadPriority(rpc0_thread_id, priority);
+		ChangeThreadPriority(rpc2_thread_id, priority);
+		ChangeThreadPriority(rpc1_thread_id, priority);
+
+		return 0;
+	}
+ 
+	return -403;
+}
+
+//-------------------------------------------------------------------------
 DECLARE_IMPORT_TABLE(cdvdman, 1, 1)
 DECLARE_IMPORT(4, sceCdInit)
 DECLARE_IMPORT(5, sceCdStandby)

File modules/iopcore/cdvdfsv/exports.tab

+void _retonly(void) {}
+
+int _dummy(void) {
+	return 0;
+}
+
+// cdvdfsv export table
+DECLARE_EXPORT_TABLE(cdvdfsv, 1, 1)
+	DECLARE_EXPORT(_start)
+	DECLARE_EXPORT(_retonly)
+	DECLARE_EXPORT(_retonly)
+	DECLARE_EXPORT(_retonly)
+	DECLARE_EXPORT(_dummy)
+	DECLARE_EXPORT(sceCdChangeThreadPriority)
+END_EXPORT_TABLE
+

File modules/iopcore/cdvdfsv/imports.lst

 
 loadcore_IMPORTS_start
 I_FlushDcache
+I_RegisterLibraryEntries
 loadcore_IMPORTS_end
 
 sifcmd_IMPORTS_start
 I_StartThread
 I_GetThreadId
 I_SleepThread
+I_ReferThreadStatus
+I_ChangeThreadPriority
 thbase_IMPORTS_end