You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
4.1 KiB
102 lines
4.1 KiB
#include "bios.h"
|
|
#include "../../core/base/basicTypes.h"
|
|
#include "syscallnr.h"
|
|
|
|
#define sps2_bios_sc_in0_out0( CALL ) __asm__ __volatile__( "li $3, " ZSTR(CALL) " \nsyscall \nnop \n" )
|
|
#define sps2_bios_sc_in1_out0( CALL, ARG0 ) __asm__ __volatile__( "li $3, " ZSTR(CALL) " \nori $4, %0, 0 \nsyscall \nnop \n" :: "r" (ARG0) )
|
|
#define sps2_bios_sc_in2_out0( CALL, ARG0, ARG1 ) __asm__ __volatile__( "li $3, " ZSTR(CALL) " \nori $4, %0, 0 \nori $5, %0, 0 \nsyscall \nnop \n" :: "r" (ARG0), "r" (ARG1) )
|
|
#define sps2_bios_sc_in3_out0( CALL, ARG0, ARG1, ARG2 ) __asm__ __volatile__( "li $3, " ZSTR(CALL) " \nori $4, %0, 0 \nori $5, %1, 0 \nori $6, %2, 0 \nsyscall \nnop \n" :: "r" (ARG0), "r" (ARG1), "r" (ARG2) )
|
|
#define sps2_bios_sc_in4_out0( CALL, ARG0, ARG1, ARG2, ARG2 ) __asm__ __volatile__( "li $3, " ZSTR(CALL) " \nori $4, %0, 0 \nori $5, %1, 0 \nori $6, %2, 0 \nori $7, %3, 0 \nsyscall \nnop \n" :: "r" (ARG0), "r" (ARG1), "r" (ARG2), "r" (ARG3) )
|
|
|
|
#define sps2_bios_sc_in0_out1( CALL, RVAL0 ) __asm__ __volatile__( "li $3, " ZSTR(CALL) " \nsyscall \nnop \n" : "r=" (ARG0) )
|
|
|
|
#define ZSTR( X ) #X
|
|
|
|
void sps2_ee_reset( uint32_t init_bitfield ){
|
|
sps2_bios_sc_in1_out0( __NR_ResetEE, init_bitfield );
|
|
};
|
|
|
|
void sps2_gs_set_mode( uint32_t interlace, uint32_t mode, uint32_t field ){
|
|
sps2_bios_sc_in3_out0( __NR_SetGsCrt, interlace, mode, field );
|
|
};
|
|
|
|
void sps2_exit( void ){
|
|
sps2_bios_sc_in0_out0( __NR__Exit );
|
|
};
|
|
|
|
void sps2_load_exec( const char *fileName, uint32_t argc, char **argv ){
|
|
sps2_bios_sc_in3_out0( __NR__LoadExecPS2, fileName, argc, argv );
|
|
};
|
|
|
|
void sps2_mem_exec( void *ptr, uint32_t gp_paramu, int32_t argc, char **argv ){
|
|
sps2_bios_sc_in4_out0( __NR__ExecPS2, address, gp_paramu, argc, argv );
|
|
};
|
|
|
|
void sps2_set_sbus_int_handler( uint32_t int_id, (*handler)(unsigned int int_id) ){
|
|
sps2_bios_sc_in2_out0( __NR_AddIntcHandler, int_id, handler );
|
|
};
|
|
|
|
void sps2_del_sbus_int_handler( uint32_t int_id ){
|
|
sps2_bios_sc_in1_out0( __NR_RemoveSbusIntcHandler, int_id );
|
|
};
|
|
|
|
//Returns int ?? what purpose ?
|
|
void sps2_trig_iop_int( uint32_t int_id ){
|
|
sps2_bios_sc_in1_out0( __NR_Interrupt2Iop, int_id );
|
|
};
|
|
|
|
|
|
// Info obtained from:
|
|
// - Gustavo Scotti (gustavo@scotti.com)
|
|
// - Marcus R. Brown (mrbrown@0xd6.org)
|
|
// - Herben (?) - Video mode information.
|
|
// - Loser (?) - More video mode information.
|
|
// - Hiryu (?) - Even more video mode information.
|
|
/*
|
|
void gs_setmode(int interlace, int mode, int field) {
|
|
__asm__ __volatile__(
|
|
"li $3, 0x02 \n" // Specify the syscall. (reg 3)
|
|
"add $4, $0, %0 \n" // Specify the arguments. (regs 4 - 11)
|
|
"add $5, $0, %1 \n" //
|
|
"add $6, $0, %2 \n" //
|
|
"syscall \n" // Perform the syscall.
|
|
"nop \n" //
|
|
:
|
|
: "r" (interlace), "r" (mode), "r" (field)
|
|
);
|
|
};
|
|
*/
|
|
__asm__ (
|
|
".set push\n"
|
|
".set noreorder\n"
|
|
".text\n"
|
|
".align 4\n"
|
|
".globl __syscall\n"
|
|
".type __syscall,@function\n"
|
|
".ent __syscall,0\n"
|
|
"__syscall:\n"
|
|
"\tmfc0 $2, $12\n\t" // Move From System Control Coprocessor GPR[$2] <- CPR[0,$12]
|
|
"andi $2, $2, 0x18\n\t" // AND IMIDIATE GRP[$2] = 0x18 & GPR[$2]
|
|
"beqz $2, _kMode\n\t" // if GPR[$2] == 0 -> _KMode
|
|
"slt $2, $3, $0\n\t" // if ( GPR[$3] < GPR[$0] ) GPR[$2] = 1 else GPR[$2] = 0
|
|
"syscall\n\t" // real syscal
|
|
"jr $31\n\t" // sets GPR[$31] tp a PC .... goto address in GPR[$31]
|
|
"nop\n"
|
|
"_kMode:\n\t"
|
|
"subu $26, $0, $3\n\t"
|
|
"movn $3, $26, $2\n\t"
|
|
"sll $3, $3, 2\n\t"
|
|
"lui $26, 0x8000\n\t"
|
|
"lhu $2, 0x02F0($26)\n\t"
|
|
"sll $2, $2, 16\n\t"
|
|
"lh $26, 0x02F8($26)\n\t"
|
|
"add $2, $26\n\t"
|
|
"addu $3, $2\n\t"
|
|
"lw $26, 0x00($3)\n\t"
|
|
"jr $26\n\t"
|
|
"nop\n"
|
|
".end __syscall\n"
|
|
".size __syscall,.-__syscall\n"
|
|
".set pop\n"
|
|
);
|
|
|