4 * Routines to add hook functions that are callable from the SH4
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
26 syscall_hook_func_t hook;
30 void syscall_add_hook( uint32_t hook_id, syscall_hook_func_t hook )
33 if( syscall_hooks[hook_id].hook != NULL )
34 WARN( "Overwriting existing hook %02X", hook_id );
35 syscall_hooks[hook_id].hook = hook;
36 syscall_hooks[hook_id].vector = 0;
39 void syscall_add_hook_vector( uint32_t hook_id, uint32_t vector_addr,
40 syscall_hook_func_t hook )
43 syscall_add_hook( hook_id, hook );
44 syscall_hooks[hook_id].vector = vector_addr;
45 sh4_write_long( vector_addr, 0xFFFFFF00 + hook_id );
48 void syscall_invoke( uint32_t hook_id )
51 syscall_hook_func_t hook = syscall_hooks[hook_id].hook;
53 WARN( "Invoked non-existent hook %02X", hook_id );
59 void syscall_repatch_vectors( )
62 for( i=0; i<256; i++ ) {
63 if( syscall_hooks[i].hook != NULL &&
64 syscall_hooks[i].vector != 0 ) {
65 sh4_write_long( syscall_hooks[i].vector, 0xFFFFFF00 + i );
.