mirror of
https://github.com/joel16/uofw.git
synced 2024-11-23 03:29:43 +00:00
Worked a bit on the build system (to do: move the library name before each library, remove the sections and add the two other segments found in SCE modules)
This commit is contained in:
parent
95c6f16688
commit
0202f8712a
32
COPYING
32
COPYING
@ -18,3 +18,35 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
This software also includes code from PSPSDK, with the following license:
|
||||
Copyright (c) 2005 adresd
|
||||
Copyright (c) 2005 Marcus R. Brown
|
||||
Copyright (c) 2005 James Forshaw
|
||||
Copyright (c) 2005 John Kelley
|
||||
Copyright (c) 2005 Jesper Svennevid
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The names of the authors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
20
include/pspmoduleexport.h
Normal file
20
include/pspmoduleexport.h
Normal file
@ -0,0 +1,20 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef PSPMODULEEXPORT_H
|
||||
#define PSPMODULEEXPORT_H
|
||||
|
||||
/** Structure to hold a single export entry */
|
||||
struct _PspLibraryEntry {
|
||||
const char * name;
|
||||
unsigned short version;
|
||||
unsigned short attribute;
|
||||
unsigned char entLen;
|
||||
unsigned char varCount;
|
||||
unsigned short funcCount;
|
||||
void * entrytable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
35
lib/build.mak
Normal file
35
lib/build.mak
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
CC = psp-gcc
|
||||
CXX = psp-g++
|
||||
AS = psp-gcc
|
||||
FIXUP = psp-fixup-imports
|
||||
|
||||
CFLAGS := -I../../include -O1 -G0 -Wall -Wextra -Werror -nostdlib
|
||||
LDFLAGS := -specs=../../lib/prxspecs -Wl,-q,-T../../lib/linkfile.prx
|
||||
|
||||
# Setup default exports if needed
|
||||
ifdef PRX_EXPORTS
|
||||
EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS))
|
||||
else
|
||||
$(error You have to define PRX_EXPORTS in your Makefile)
|
||||
endif
|
||||
|
||||
all: $(TARGET).prx
|
||||
|
||||
$(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
|
||||
$(LINK.c) $^ $(LIBS) -o $@
|
||||
-$(FIXUP) $@
|
||||
|
||||
%.prx: %.elf
|
||||
psp-prxgen $< $@
|
||||
|
||||
%.c: %.exp
|
||||
psp-build-exports -b $< > $@
|
||||
|
||||
clean:
|
||||
-rm -f $(TARGET).prx $(TARGET).elf $(EXPORT_OBJ) $(OBJS)
|
||||
|
||||
rebuild: clean all
|
||||
|
245
lib/linkfile.prx
Normal file
245
lib/linkfile.prx
Normal file
@ -0,0 +1,245 @@
|
||||
/* Default linker script, for normal executables */
|
||||
OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
|
||||
"elf32-littlemips")
|
||||
OUTPUT_ARCH(mips:allegrex)
|
||||
/* SEARCH_DIR("/usr/local/pspdev/psp/lib"); */
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
PROVIDE (__executable_start = 0x0); . = 0x0;
|
||||
.interp : { *(.interp) }
|
||||
.dynamic : { *(.dynamic) }
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
|
||||
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
|
||||
.rel.init : { *(.rel.init) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rel.fini : { *(.rel.fini) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
/* PSP-specific relocations. */
|
||||
.rel.sceStub.text : { *(.rel.sceStub.text) *(SORT(.rel.sceStub.text.*)) }
|
||||
.rel.lib.ent.top : { *(.rel.lib.ent.top) }
|
||||
.rel.lib.ent : { *(.rel.lib.ent) }
|
||||
.rel.lib.ent.btm : { *(.rel.lib.ent.btm) }
|
||||
.rel.lib.stub.top : { *(.rel.lib.stub.top) }
|
||||
.rel.lib.stub : { *(.rel.lib.stub) }
|
||||
.rel.lib.stub.btm : { *(.rel.lib.stub.btm) }
|
||||
.rel.rodata.sceModuleInfo : { *(.rel.rodata.sceModuleInfo) }
|
||||
.rel.rodata.sceResident : { *(.rel.rodata.sceResident) }
|
||||
.rel.rodata.sceNid : { *(.rel.rodata.sceNid) }
|
||||
.rel.rodata.sceVstub : { *(.rel.rodata.sceVstub) *(SORT(.rel.rodata.sceVstub.*)) }
|
||||
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
|
||||
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
|
||||
.rel.data.rel.ro : { *(.rel.data.rel.ro*) }
|
||||
.rela.data.rel.ro : { *(.rel.data.rel.ro*) }
|
||||
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
|
||||
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
|
||||
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
|
||||
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
|
||||
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
|
||||
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
|
||||
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
|
||||
.rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
|
||||
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
|
||||
.rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
|
||||
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
|
||||
.rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
|
||||
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
|
||||
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
|
||||
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.text :
|
||||
{
|
||||
_ftext = . ;
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
KEEP (*(.text.*personality*))
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.mips16.fn.*) *(.mips16.call.*)
|
||||
} =0
|
||||
.init :
|
||||
{
|
||||
KEEP (*(.init))
|
||||
} =0
|
||||
.plt : { *(.plt) }
|
||||
.fini :
|
||||
{
|
||||
KEEP (*(.fini))
|
||||
} =0
|
||||
/* PSP library stub functions. */
|
||||
.sceStub.text : { *(.sceStub.text) *(SORT(.sceStub.text.*)) }
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
/* PSP library entry table and library stub table. */
|
||||
.lib.ent.top : { *(.lib.ent.top) }
|
||||
.lib.ent : { *(.lib.ent) }
|
||||
.lib.ent.btm : { *(.lib.ent.btm) }
|
||||
.lib.stub.top : { *(.lib.stub.top) }
|
||||
.lib.stub : { *(.lib.stub) }
|
||||
.lib.stub.btm : { *(.lib.stub.btm) }
|
||||
/* PSP read-only data for module info, NIDs, and Vstubs. The
|
||||
.rodata.sceModuleInfo section must appear before the .rodata section
|
||||
otherwise it would get absorbed into .rodata and the PSP bootloader
|
||||
would be unable to locate the module info structure. */
|
||||
.rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) }
|
||||
.rodata.sceResident : { *(.rodata.sceResident) }
|
||||
.rodata.sceNid : { KEEP (*(.rodata.sceNid)) }
|
||||
.rodata.sceVstub : { *(.rodata.sceVstub) *(SORT(.rodata.sceVstub.*)) }
|
||||
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
|
||||
.rodata1 : { *(.rodata1) }
|
||||
.sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
|
||||
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
|
||||
.gcc_except_table : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
|
||||
/* Adjust the address for the data segment. We want to adjust up to
|
||||
the same address within the page on the next page up. */
|
||||
. = ALIGN(256) + (. & (256 - 1));
|
||||
/* Exception handling */
|
||||
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
|
||||
.gcc_except_table : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
|
||||
/* Thread Local Storage sections */
|
||||
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
|
||||
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
|
||||
/* Ensure the __preinit_array_start label is properly aligned. We
|
||||
could instead move the label definition inside the section, but
|
||||
the linker would then create the section even if it turns out to
|
||||
be empty, which isn't pretty. */
|
||||
. = ALIGN(32 / 8);
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
.preinit_array : { KEEP (*(.preinit_array)) }
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
PROVIDE (__init_array_start = .);
|
||||
.init_array : { KEEP (*(.init_array)) }
|
||||
PROVIDE (__init_array_end = .);
|
||||
PROVIDE (__fini_array_start = .);
|
||||
.fini_array : { KEEP (*(.fini_array)) }
|
||||
PROVIDE (__fini_array_end = .);
|
||||
.ctors :
|
||||
{
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin*.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
}
|
||||
.dtors :
|
||||
{
|
||||
KEEP (*crtbegin*.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
}
|
||||
.jcr : { KEEP (*(.jcr)) }
|
||||
.data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
|
||||
.data :
|
||||
{
|
||||
_fdata = . ;
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||
SORT(CONSTRUCTORS)
|
||||
}
|
||||
.data1 : { *(.data1) }
|
||||
. = .;
|
||||
_gp = ALIGN(16) + 0x7ff0;
|
||||
.got : { *(.got.plt) *(.got) }
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
.sdata :
|
||||
{
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
}
|
||||
.lit8 : { *(.lit8) }
|
||||
.lit4 : { *(.lit4) }
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
__bss_start = .;
|
||||
_fbss = .;
|
||||
.sbss :
|
||||
{
|
||||
PROVIDE (__sbss_start = .);
|
||||
PROVIDE (___sbss_start = .);
|
||||
*(.dynsbss)
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
PROVIDE (__sbss_end = .);
|
||||
PROVIDE (___sbss_end = .);
|
||||
}
|
||||
.bss :
|
||||
{
|
||||
*(.dynbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
/* Align here to ensure that the .bss section occupies space up to
|
||||
_end. Align after .bss to ensure correct alignment even if the
|
||||
.bss section disappears because there are no input sections. */
|
||||
. = ALIGN(32 / 8);
|
||||
}
|
||||
. = ALIGN(32 / 8);
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/DISCARD/ : { *(.comment) *(.pdr) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
2
lib/prxspecs
Normal file
2
lib/prxspecs
Normal file
@ -0,0 +1,2 @@
|
||||
*startfile:
|
||||
crt0_prx%O%s crti%O%s crtbegin%O%s
|
10
src/exceptionman/Makefile
Normal file
10
src/exceptionman/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
TARGET = exceptionman
|
||||
OBJS = excep.o exceptions.o intr.o nmi.o
|
||||
|
||||
PRX_EXPORTS=exports.exp
|
||||
|
||||
include ../../lib/build.mak
|
||||
|
390
src/exceptionman/excep.S
Normal file
390
src/exceptionman/excep.S
Normal file
@ -0,0 +1,390 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
|
||||
.globl sub_0000
|
||||
sub_0000:
|
||||
lui $a0, %hi(sub_00F8)
|
||||
addiu $a0, $a0, %lo(sub_00F8)
|
||||
ctc0 $a0, $9
|
||||
lui $a0, %hi(sub_0040)
|
||||
addiu $a0, $a0, %lo(sub_0040)
|
||||
jr $ra
|
||||
mtc0 $a0, $25
|
||||
|
||||
# At 0x0000001C
|
||||
.globl ExceptionManagerForKernel_96D47F7E
|
||||
ExceptionManagerForKernel_96D47F7E:
|
||||
lui $v0, %hi(sub_0070)
|
||||
jr $ra
|
||||
addiu $v0, $v0, %lo(sub_0070)
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
sub_0040:
|
||||
ctc0 $v0, $4
|
||||
ctc0 $v1, $5
|
||||
mfc0 $v0, $13
|
||||
mfc0 $v1, $12
|
||||
ctc0 $v0, $3
|
||||
ctc0 $v1, $2
|
||||
andi $v0, $v0, 0x7C
|
||||
li $v1, 32
|
||||
bne $v0, $v1, loc_00000098
|
||||
mfc0 $v1, $14
|
||||
|
||||
.globl sub_0068
|
||||
sub_0068:
|
||||
j sub_0068
|
||||
ctc0 $v1, $0
|
||||
|
||||
sub_0070:
|
||||
ctc0 $v0, $4
|
||||
ctc0 $v1, $5
|
||||
mfc0 $v0, $13
|
||||
mfc0 $v1, $12
|
||||
ctc0 $v0, $3
|
||||
ctc0 $v1, $2
|
||||
lui $v1, %hi(sub_0040)
|
||||
addiu $v1, $v1, %lo(sub_0040)
|
||||
mtc0 $v1, $25
|
||||
mfc0 $v1, $14
|
||||
|
||||
loc_00000098:
|
||||
ctc0 $v1, $0
|
||||
|
||||
loc_0000009C:
|
||||
lui $v1, %hi(ExcepManCB)
|
||||
ins $v1, $v0, 0, 7
|
||||
lw $v0, %lo(ExcepManCB)($v1)
|
||||
cfc0 $v1, $25
|
||||
bnezl $v1, loc_000000BC
|
||||
sw $v0, 12($v1)
|
||||
jr $v0
|
||||
nop
|
||||
|
||||
loc_000000BC:
|
||||
lw $v1, 0($v1)
|
||||
lw $v0, 0($v1)
|
||||
sw $0, 0($v1)
|
||||
sync
|
||||
cfc0 $v1, $25
|
||||
lw $v1, 8($v1)
|
||||
bnez $v1, loc_000000E0
|
||||
cfc0 $v1, $25
|
||||
sw $v0, 4($v1)
|
||||
|
||||
loc_000000E0:
|
||||
lw $v0, 8($v1)
|
||||
addiu $v0, $v0, 1
|
||||
sw $v0, 8($v1)
|
||||
lw $v0, 12($v1)
|
||||
jr $v0
|
||||
nop
|
||||
|
||||
sub_00F8:
|
||||
ctc0 $v1, $7
|
||||
mfc0 $v0, $13
|
||||
mfc0 $v1, $30
|
||||
ctc0 $v0, $20
|
||||
ctc0 $v1, $1
|
||||
mfc0 $v1, $12
|
||||
ctc0 $v1, $19
|
||||
li $v0, 124
|
||||
b loc_0000009C
|
||||
nop
|
||||
|
||||
.globl sub_0120
|
||||
sub_0120:
|
||||
ctc0 $v0, $6
|
||||
mfc0 $v0, $22
|
||||
bne $0, $v0, ExceptionManagerForKernel_79454858
|
||||
nop
|
||||
|
||||
.globl sub_0130
|
||||
sub_0130:
|
||||
cfc0 $v0, $9
|
||||
jr $v0
|
||||
nop
|
||||
nop
|
||||
|
||||
.globl sub_0140
|
||||
sub_0140:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
# At 0x00000160
|
||||
.globl ExceptionManagerForKernel_79454858
|
||||
ExceptionManagerForKernel_79454858:
|
||||
li $v0, 92
|
||||
b loc_0000009C
|
||||
nop
|
||||
|
||||
.globl sub_016C
|
||||
sub_016C:
|
||||
nop
|
||||
nop
|
||||
|
||||
loc_00000174:
|
||||
b loc_00000174
|
||||
nop
|
||||
nop
|
||||
|
||||
.globl sub_0180
|
||||
sub_0180:
|
||||
lui $v0, 0xBC10
|
||||
lui $v1, 0xFFFF
|
||||
ori $v1, $v1, 0xFFFF
|
||||
sw $v1, 4($v0)
|
||||
lui $v1, %hi(g_0D40)
|
||||
sw $0, %lo(g_0D40)($v1)
|
||||
lui $v1, %hi(g_0D44)
|
||||
jr $ra
|
||||
sw $0, %lo(g_0D44)($v1)
|
||||
nop
|
||||
nop
|
||||
|
||||
.globl sub_01A4
|
||||
sub_01A4:
|
||||
lui $v1, %hi(g_0D40)
|
||||
lw $v0, %lo(g_0D40)($v1)
|
||||
bnez $v0, loc_000004E0
|
||||
addi $v0, $v0, 1
|
||||
sw $v0, %lo(g_0D40)($v1)
|
||||
lui $v0, %hi(g_0D44)
|
||||
sw $0, %lo(g_0D44)($v0)
|
||||
move $v0, $sp
|
||||
lui $sp, %hi(g_stackCtx)
|
||||
addiu $sp, $sp, %lo(g_stackCtx)
|
||||
sw $at, 4($sp)
|
||||
sw $a0, 16($sp)
|
||||
sw $a1, 20($sp)
|
||||
sw $a2, 24($sp)
|
||||
sw $a3, 28($sp)
|
||||
sw $t0, 32($sp)
|
||||
sw $t1, 36($sp)
|
||||
sw $t2, 40($sp)
|
||||
sw $t3, 44($sp)
|
||||
sw $t4, 48($sp)
|
||||
sw $t5, 52($sp)
|
||||
sw $t6, 56($sp)
|
||||
sw $t7, 60($sp)
|
||||
sw $s0, 64($sp)
|
||||
sw $s1, 68($sp)
|
||||
sw $s2, 72($sp)
|
||||
sw $s3, 76($sp)
|
||||
sw $s4, 80($sp)
|
||||
sw $s5, 84($sp)
|
||||
sw $s6, 88($sp)
|
||||
sw $s7, 92($sp)
|
||||
sw $t8, 96($sp)
|
||||
sw $t9, 100($sp)
|
||||
sw $k0, 104($sp)
|
||||
sw $k1, 108($sp)
|
||||
sw $gp, 112($sp)
|
||||
sw $v0, 116($sp)
|
||||
sw $fp, 120($sp)
|
||||
sw $ra, 124($sp)
|
||||
mfhi $v0
|
||||
mflo $v1
|
||||
sw $v0, 128($sp)
|
||||
sw $v1, 132($sp)
|
||||
lui $v0, 0xBC10
|
||||
lw $s0, 0($v0)
|
||||
move $s1, $0
|
||||
lui $v0, 0xFFFF
|
||||
ori $v0, $v0, 0xFFFF
|
||||
and $v0, $v0, $s0
|
||||
beqz $v0, loc_000002A0
|
||||
bitrev $v1, $s0
|
||||
clz $s2, $v1
|
||||
li $v0, 0xFFFF
|
||||
and $v0, $v0, $s0
|
||||
bnez $v0, loc_000002F0
|
||||
li $a0, 0
|
||||
addiu $s2, $s2, -16
|
||||
lui $v0, 0xFFFF
|
||||
and $v0, $v0, $s0
|
||||
bnez $v0, loc_000002F0
|
||||
li $a0, 1
|
||||
|
||||
loc_000002A0:
|
||||
mfc0 $v0, $24
|
||||
andi $v0, $v0, 0x1
|
||||
beqz $v0, loc_000002E8
|
||||
nop
|
||||
li $s2, 16
|
||||
lui $s1, 0xA7F0
|
||||
lw $s1, 4($s1)
|
||||
lui $v0, 0x2222
|
||||
ori $v0, $v0, 0x2222
|
||||
move $a1, $s1
|
||||
li $a2, -1
|
||||
and $a0, $s1, $v0
|
||||
bnez $a0, loc_00000374
|
||||
li $a0, 0
|
||||
sll $v0, $v0, 1
|
||||
and $a0, $s1, $v0
|
||||
bnez $a0, loc_00000374
|
||||
li $a0, 2
|
||||
|
||||
loc_000002E8:
|
||||
j loc_000004DC
|
||||
nop
|
||||
|
||||
loc_000002F0:
|
||||
lui $v0, 0xBC10
|
||||
li $at, 8
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0x10
|
||||
li $at, 9
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0x14
|
||||
li $at, 10
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0xA0
|
||||
li $at, 11
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0xA4
|
||||
li $at, 12
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0xC
|
||||
li $at, 13
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0x88
|
||||
li $at, 14
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0xE0
|
||||
li $at, 15
|
||||
beql $s2, $at, loc_00000368
|
||||
ori $v0, $v0, 0xE4
|
||||
sll $k0, $s2, 2
|
||||
li $k1, 52
|
||||
subu $k1, $k1, $k0
|
||||
lui $v0, 0xBC10
|
||||
addu $v0, $v0, $k1
|
||||
|
||||
loc_00000368:
|
||||
lw $a2, 0($v0)
|
||||
ext $a1, $a2, 31, 1
|
||||
ins $a2, $0, 0, 31
|
||||
|
||||
loc_00000374:
|
||||
cfc0 $a3, $0
|
||||
cfc0 $t0, $1
|
||||
cfc0 $v0, $18
|
||||
sll $v1, $s2, 2
|
||||
addu $k0, $v0, $v1
|
||||
lw $s3, 0($k0)
|
||||
lui $at, %hi(g_0D44)
|
||||
sw $s3, %lo(g_0D44)($at)
|
||||
beqz $s3, loc_000003D4
|
||||
nop
|
||||
beqz $s0, loc_000003AC
|
||||
lui $k0, 0xBC10
|
||||
sw $s0, 4($k0)
|
||||
sync
|
||||
|
||||
loc_000003AC:
|
||||
beqz $s1, loc_000003C4
|
||||
lui $k0, 0xA7F8
|
||||
lw $0, 0($k0)
|
||||
lui $k0, 0xA7F0
|
||||
sw $s1, 32($k0)
|
||||
sync
|
||||
|
||||
loc_000003C4:
|
||||
lui $sp, %hi(g_stackCtx)
|
||||
addiu $sp, $sp, %lo(g_stackCtx)
|
||||
jalr $s3
|
||||
nop
|
||||
|
||||
loc_000003D4:
|
||||
lui $sp, %hi(g_stackCtx)
|
||||
addiu $sp, $sp, %lo(g_stackCtx)
|
||||
lw $k0, 128($sp)
|
||||
lw $k1, 132($sp)
|
||||
mthi $k0
|
||||
mtlo $k1
|
||||
lw $a0, 16($sp)
|
||||
lw $a1, 20($sp)
|
||||
lw $a2, 24($sp)
|
||||
lw $a3, 28($sp)
|
||||
lw $t0, 32($sp)
|
||||
lw $t1, 36($sp)
|
||||
lw $t2, 40($sp)
|
||||
lw $t3, 44($sp)
|
||||
lw $t4, 48($sp)
|
||||
lw $t5, 52($sp)
|
||||
lw $t6, 56($sp)
|
||||
lw $t7, 60($sp)
|
||||
lw $s0, 64($sp)
|
||||
lw $s1, 68($sp)
|
||||
lw $s2, 72($sp)
|
||||
lw $s3, 76($sp)
|
||||
lw $s4, 80($sp)
|
||||
lw $s5, 84($sp)
|
||||
lw $s6, 88($sp)
|
||||
lw $s7, 92($sp)
|
||||
lw $t8, 96($sp)
|
||||
lw $t9, 100($sp)
|
||||
lw $k0, 104($sp)
|
||||
lw $k1, 108($sp)
|
||||
lw $gp, 112($sp)
|
||||
lw $fp, 120($sp)
|
||||
lw $ra, 124($sp)
|
||||
lw $at, 4($sp)
|
||||
lw $sp, 116($sp)
|
||||
lui $v0, %hi(g_0D40)
|
||||
sw $0, %lo(g_0D40)($v0)
|
||||
cfc0 $v1, $19
|
||||
lui $v0, 0xFFBF
|
||||
ori $v0, $v0, 0xFFFF
|
||||
and $v1, $v1, $v0
|
||||
mtc0 $v1, $12
|
||||
lui $v0, %hi(g_0D44)
|
||||
lw $v1, %lo(g_0D44)($v0)
|
||||
beqz $v1, loc_000004CC
|
||||
nop
|
||||
mfc0 $v1, $12
|
||||
lui $v0, 0xFFEF
|
||||
ori $v0, $v0, 0xFFFF
|
||||
and $v1, $v1, $v0
|
||||
mtc0 $v1, $12
|
||||
cfc0 $v1, $20
|
||||
mtc0 $v1, $13
|
||||
cfc0 $v1, $1
|
||||
mtc0 $v1, $30
|
||||
cfc0 $v0, $6
|
||||
cfc0 $v1, $7
|
||||
nop
|
||||
nop
|
||||
eret
|
||||
nop
|
||||
nop
|
||||
|
||||
loc_000004CC:
|
||||
lui $v0, %hi(sub_01A4)
|
||||
lw $v0, %lo(sub_01A4)($v0)
|
||||
jr $v0
|
||||
nop
|
||||
|
||||
loc_000004DC:
|
||||
break 0x20000
|
||||
|
||||
loc_000004E0:
|
||||
break 0x20000
|
||||
|
14
src/exceptionman/excep.h
Normal file
14
src/exceptionman/excep.h
Normal file
@ -0,0 +1,14 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
void sub_0000();
|
||||
void sub_0068();
|
||||
void sub_0120();
|
||||
void sub_0130();
|
||||
void sub_0140();
|
||||
void ExceptionManagerForKernel_79454858();
|
||||
void sub_016C();
|
||||
void sub_0180();
|
||||
void sub_01A4();
|
||||
|
283
src/exceptionman/exceptions.c
Normal file
283
src/exceptionman/exceptions.c
Normal file
@ -0,0 +1,283 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
#include "excep.h"
|
||||
#include "intr.h"
|
||||
#include "nmi.h"
|
||||
|
||||
#include "exceptions.h"
|
||||
|
||||
typedef struct SceExceptionHandler
|
||||
{
|
||||
struct SceExceptionHandler *next;
|
||||
void *cb;
|
||||
} SceExceptionHandler;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SceExceptionHandler *hdlr1[32];
|
||||
SceExceptionHandler *hdlr2[32];
|
||||
SceExceptionHandler *defaultHdlr;
|
||||
SceExceptionHandler *curPool;
|
||||
SceExceptionHandler pool[32];
|
||||
} SceExceptions;
|
||||
|
||||
PSP_MODULE_INFO("sceExceptionManager", PSP_MODULE_NO_STOP | PSP_MODULE_SINGLE_LOAD | PSP_MODULE_SINGLE_START | PSP_MODULE_KERNEL, 1, 3);
|
||||
PSP_SDK_VERSION(0x06060010);
|
||||
PSP_MODULE_BOOTSTART("ExcepManInit");
|
||||
|
||||
void build_exectbl(void);
|
||||
SceExceptionHandler *newExcepCB(void);
|
||||
void FreeExcepCB(SceExceptionHandler *ex);
|
||||
void Allocexceppool(void);
|
||||
|
||||
int g_0D40;
|
||||
int g_0D44;
|
||||
|
||||
// 0D48 (?)
|
||||
char g_stack[2108];
|
||||
|
||||
// 1580
|
||||
char g_stackCtx[192];
|
||||
|
||||
// 1640
|
||||
SceExceptions ExcepManCB;
|
||||
|
||||
int ExcepManInit(void)
|
||||
{
|
||||
int oldIntr = suspendIntr();
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
ExcepManCB.hdlr2[i] = NULL;
|
||||
ExcepManCB.defaultHdlr = NULL;
|
||||
Allocexceppool();
|
||||
COP0_CTRL_SET(25, 0);
|
||||
sub_0000();
|
||||
int cpuid;
|
||||
COP0_STATE_GET(cpuid, 22);
|
||||
int *src, *srcEnd, *dst;
|
||||
if (cpuid == 1)
|
||||
{
|
||||
// 05A4
|
||||
src = (int*)&sub_0130;
|
||||
dst = (int*)(0xBFC00000 + (int)ExceptionManagerForKernel_79454858 - (int)sub_0120);
|
||||
srcEnd = (int*)&sub_0140;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst = (int*)(0xBFC00000);
|
||||
src = (int*)&sub_0120;
|
||||
srcEnd = (int*)&ExceptionManagerForKernel_79454858;
|
||||
}
|
||||
// 0550
|
||||
// 055C
|
||||
while (src != srcEnd)
|
||||
*(dst++) = *(src++);
|
||||
// 0578
|
||||
sceKernelRegisterDefaultExceptionHandler(sub_016C);
|
||||
NmiManInit();
|
||||
resumeIntr(oldIntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelRegisterPriorityExceptionHandler(int exno, int prio, void (*func)())
|
||||
{
|
||||
int oldIntr = suspendIntr();
|
||||
if (*(int*)(func) != 0)
|
||||
{
|
||||
// 06B0
|
||||
resumeIntr(oldIntr);
|
||||
return 0x80020034;
|
||||
}
|
||||
if (exno < 0 || exno >= 32)
|
||||
{
|
||||
// 069C
|
||||
resumeIntr(oldIntr);
|
||||
return 0x80020032;
|
||||
}
|
||||
prio &= 0x3;
|
||||
SceExceptionHandler *newEx = newExcepCB();
|
||||
SceExceptionHandler *ex = ExcepManCB.hdlr1[exno];
|
||||
SceExceptionHandler *lastEx = ex;
|
||||
newEx->cb = (void*)(((int)func & 0xFFFFFFFC) | prio);
|
||||
// 0640
|
||||
while (ex != NULL)
|
||||
{
|
||||
if (((int)ex->cb & 3) >= prio)
|
||||
break;
|
||||
lastEx = ex;
|
||||
ex = ex->next;
|
||||
}
|
||||
// (0668)
|
||||
newEx->next = ex;
|
||||
// 066C
|
||||
lastEx->next = newEx;
|
||||
build_exectbl();
|
||||
resumeIntr(oldIntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelRegisterDefaultExceptionHandler(void *func)
|
||||
{
|
||||
int oldIntr = suspendIntr();
|
||||
SceExceptionHandler *handler = func;
|
||||
if (handler->next != NULL || (func == sub_016C && ExcepManCB.defaultHdlr != NULL)) // 0734
|
||||
{
|
||||
// 0744
|
||||
resumeIntr(oldIntr);
|
||||
return 0x80020034;
|
||||
}
|
||||
// 0700
|
||||
handler->next = ExcepManCB.defaultHdlr;
|
||||
ExcepManCB.defaultHdlr = func + 8;
|
||||
build_exectbl();
|
||||
resumeIntr(oldIntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelReleaseExceptionHandler(int exno, void (*func)())
|
||||
{
|
||||
int oldIntr = suspendIntr();
|
||||
if (exno < 0 || exno >= 32)
|
||||
{
|
||||
// 080C
|
||||
resumeIntr(oldIntr);
|
||||
return 0x80020032;
|
||||
}
|
||||
SceExceptionHandler *lastEx = ExcepManCB.hdlr1[exno];
|
||||
SceExceptionHandler *ex = lastEx->next;
|
||||
// 07A0
|
||||
while (ex != NULL)
|
||||
{
|
||||
if ((void*)((int)ex->cb & 0xFFFFFFFC) == func)
|
||||
{
|
||||
// 07E8
|
||||
*(int*)(ex->cb) = 0;
|
||||
lastEx->next = ex->next;
|
||||
FreeExcepCB(ex);
|
||||
build_exectbl();
|
||||
resumeIntr(oldIntr);
|
||||
return 0;
|
||||
}
|
||||
lastEx = ex;
|
||||
ex = ex->next;
|
||||
}
|
||||
// 07C0
|
||||
resumeIntr(oldIntr);
|
||||
return 0x80020033;
|
||||
}
|
||||
|
||||
int sceKernelReleaseDefaultExceptionHandler(void (*func)())
|
||||
{
|
||||
int oldIntr = suspendIntr();
|
||||
void (*actualFunc)() = func + 8;
|
||||
SceExceptionHandler *releaseEx = (SceExceptionHandler*)func;
|
||||
SceExceptionHandler *ex = (SceExceptionHandler*)func;
|
||||
if (func != sub_016C)
|
||||
{
|
||||
SceExceptionHandler *next = ExcepManCB.defaultHdlr->next;
|
||||
// 085C
|
||||
while (next != NULL)
|
||||
{
|
||||
void (*nextFunc) = ex->next;
|
||||
if (nextFunc == actualFunc)
|
||||
{
|
||||
// 0898
|
||||
ex->next = releaseEx->next;
|
||||
releaseEx->next = 0;
|
||||
build_exectbl();
|
||||
resumeIntr(oldIntr);
|
||||
return 0;
|
||||
}
|
||||
ex = nextFunc - 8;
|
||||
next = ex->next;
|
||||
}
|
||||
}
|
||||
// 0874
|
||||
resumeIntr(oldIntr);
|
||||
return 0x80020033;
|
||||
}
|
||||
|
||||
void build_exectbl(void)
|
||||
{
|
||||
// 08C8
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
SceExceptionHandler *hdlr = ExcepManCB.hdlr2[i];
|
||||
if (hdlr != NULL)
|
||||
{
|
||||
// 08DC
|
||||
while (hdlr->next != NULL) {
|
||||
*(int*)((int)hdlr->cb & 0xFFFFFFFC) = ((int)hdlr->next->cb & 0xFFFFFFFC) + 8;
|
||||
hdlr = hdlr->next;
|
||||
}
|
||||
// 0908
|
||||
*(void**)((int)hdlr->cb & 0xFFFFFFFC) = ExcepManCB.defaultHdlr;
|
||||
}
|
||||
// 0918
|
||||
}
|
||||
int op = *(int*)(sub_0068);
|
||||
// 0948
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
SceExceptionHandler *hdlr2 = ExcepManCB.hdlr2[i];
|
||||
if (hdlr2 != NULL) {
|
||||
// 0994
|
||||
hdlr2 = (void*)(((int)hdlr2->cb & 0xFFFFFFFC) + 8);
|
||||
}
|
||||
else
|
||||
hdlr2 = ExcepManCB.defaultHdlr;
|
||||
|
||||
// 0958
|
||||
ExcepManCB.hdlr1[i] = hdlr2;
|
||||
if (i == 8)
|
||||
{
|
||||
// 097C
|
||||
op = (((int)ExcepManCB.hdlr1[8] >> 2) & 0x03FFFFFF) + 0x08000000;
|
||||
CACHE(0x1A, &sub_0068);
|
||||
}
|
||||
// 0964
|
||||
}
|
||||
*(int*)(sub_0068) = op;
|
||||
}
|
||||
|
||||
SceExceptionHandler *newExcepCB(void)
|
||||
{
|
||||
SceExceptionHandler *excep = ExcepManCB.curPool;
|
||||
if (excep != NULL)
|
||||
ExcepManCB.curPool = ExcepManCB.curPool->next;
|
||||
return excep;
|
||||
}
|
||||
|
||||
void FreeExcepCB(SceExceptionHandler *ex)
|
||||
{
|
||||
ex->next = ExcepManCB.curPool;
|
||||
ExcepManCB.curPool = ex;
|
||||
}
|
||||
|
||||
void Allocexceppool(void)
|
||||
{
|
||||
ExcepManCB.curPool = &ExcepManCB.pool[0];
|
||||
// 09F4
|
||||
int i;
|
||||
for (i = 0; i < 31; i++)
|
||||
ExcepManCB.pool[i].next = &ExcepManCB.pool[i + 1];
|
||||
ExcepManCB.hdlr2[30] = NULL;
|
||||
}
|
||||
|
||||
int sceKernelRegisterExceptionHandler(int exno, void (*func)())
|
||||
{
|
||||
return sceKernelRegisterPriorityExceptionHandler(exno, 2, func);
|
||||
}
|
||||
|
||||
SceExceptionHandler *sceKernelGetActiveDefaultExceptionHandler(void)
|
||||
{
|
||||
if ((void*)ExcepManCB.defaultHdlr == sub_016C)
|
||||
return NULL;
|
||||
return ExcepManCB.defaultHdlr;
|
||||
}
|
||||
|
10
src/exceptionman/exceptions.h
Normal file
10
src/exceptionman/exceptions.h
Normal file
@ -0,0 +1,10 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
int sceKernelRegisterPriorityExceptionHandler(int exno, int prio, void (*func)());
|
||||
int sceKernelRegisterDefaultExceptionHandler(void *func);
|
||||
int sceKernelReleaseExceptionHandler(int exno, void (*func)());
|
||||
int sceKernelReleaseDefaultExceptionHandler(void (*func)());
|
||||
int sceKernelRegisterExceptionHandler(int exno, void (*func)());
|
||||
|
27
src/exceptionman/exports.exp
Normal file
27
src/exceptionman/exports.exp
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
# Automatically exports file generated with prxtool
|
||||
PSP_BEGIN_EXPORTS
|
||||
|
||||
PSP_EXPORT_START(syslib, 0x0000, 0x8000)
|
||||
PSP_EXPORT_FUNC_HASH(module_bootstart)
|
||||
PSP_EXPORT_VAR_HASH(module_info)
|
||||
PSP_EXPORT_VAR_NID(syslib_11B97506, 0x11B97506)
|
||||
PSP_EXPORT_END
|
||||
|
||||
PSP_EXPORT_START(ExceptionManagerForKernel, 0x0011, 0x0001)
|
||||
PSP_EXPORT_FUNC_NID(sceKernelRegisterDefaultExceptionHandler, 0x0A998599)
|
||||
PSP_EXPORT_FUNC_HASH(sceKernelRegisterNmiHandler)
|
||||
PSP_EXPORT_FUNC_NID(sceKernelGetActiveDefaultExceptionHandler, 0x27E6A663)
|
||||
PSP_EXPORT_FUNC_NID(sceKernelReleaseDefaultExceptionHandler, 0x409DBB53)
|
||||
PSP_EXPORT_FUNC_NID(sceKernelReleaseExceptionHandler, 0x54B0CAD2)
|
||||
PSP_EXPORT_FUNC_NID(ExceptionManagerForKernel_79454858, 0x79454858)
|
||||
PSP_EXPORT_FUNC_NID(sceKernelRegisterPriorityExceptionHandler, 0x7C11759D)
|
||||
PSP_EXPORT_FUNC_NID(ExceptionManagerForKernel_96D47F7E, 0x96D47F7E)
|
||||
PSP_EXPORT_FUNC_HASH(sceKernelReleaseNmiHandler)
|
||||
PSP_EXPORT_FUNC_NID(sceKernelRegisterExceptionHandler, 0xFBC2353A)
|
||||
PSP_EXPORT_VAR_NID(ExcepManCB, 0x6437D22A)
|
||||
PSP_EXPORT_END
|
||||
|
||||
PSP_END_EXPORTS
|
33
src/exceptionman/intr.S
Normal file
33
src/exceptionman/intr.S
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
|
||||
.globl suspendIntr
|
||||
suspendIntr:
|
||||
mfic $v0, $0
|
||||
mtic $0, $0
|
||||
beqz $v0, ret
|
||||
nop
|
||||
nop
|
||||
|
||||
retWithNop:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
ret:
|
||||
jr $ra
|
||||
nop
|
||||
sync
|
||||
nop
|
||||
|
||||
.globl resumeIntr
|
||||
resumeIntr:
|
||||
mtic $a0, $0
|
||||
j retWithNop
|
||||
nop
|
||||
|
7
src/exceptionman/intr.h
Normal file
7
src/exceptionman/intr.h
Normal file
@ -0,0 +1,7 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
int suspendIntr(void);
|
||||
void resumeIntr(int);
|
||||
|
54
src/exceptionman/nmi.c
Normal file
54
src/exceptionman/nmi.c
Normal file
@ -0,0 +1,54 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
#include "excep.h"
|
||||
#include "exceptions.h"
|
||||
#include "intr.h"
|
||||
|
||||
// 1848
|
||||
void *g_nmiHandlers[16];
|
||||
|
||||
int NmiManInit(void)
|
||||
{
|
||||
int oldIntr = suspendIntr();
|
||||
COP0_CTRL_SET(18, 0);
|
||||
// 0AEC
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
g_nmiHandlers[i] = NULL;
|
||||
sub_0180();
|
||||
COP0_CTRL_SET(18, g_nmiHandlers);
|
||||
sceKernelRegisterPriorityExceptionHandler(31, 1, sub_01A4);
|
||||
resumeIntr(oldIntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelRegisterNmiHandler(int nmino, void (*func)())
|
||||
{
|
||||
if (nmino < 0 || nmino >= 17)
|
||||
return 0x8002003A;
|
||||
int oldIntr = suspendIntr();
|
||||
g_nmiHandlers[nmino] = func;
|
||||
resumeIntr(oldIntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelReleaseNmiHandler(int nmino)
|
||||
{
|
||||
int ret = 0;
|
||||
if (nmino < 0 || nmino >= 17)
|
||||
return 0x8002003A;
|
||||
int oldIntr = suspendIntr();
|
||||
if (g_nmiHandlers[nmino] != NULL)
|
||||
g_nmiHandlers[nmino] = NULL;
|
||||
else
|
||||
ret = 0x80020068;
|
||||
|
||||
// 0BFC
|
||||
resumeIntr(oldIntr);
|
||||
return ret;
|
||||
}
|
||||
|
6
src/exceptionman/nmi.h
Normal file
6
src/exceptionman/nmi.h
Normal file
@ -0,0 +1,6 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
int NmiManInit(void);
|
||||
|
66
src/global.h
66
src/global.h
@ -24,6 +24,69 @@ typedef s32 SceMode;
|
||||
typedef u32 SceSize;
|
||||
typedef SceInt64 SceOff;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short modattribute;
|
||||
unsigned char modversion[2];
|
||||
char modname[27];
|
||||
char terminal;
|
||||
void * gp_value;
|
||||
void * ent_top;
|
||||
void * ent_end;
|
||||
void * stub_top;
|
||||
void * stub_end;
|
||||
} _sceModuleInfo;
|
||||
|
||||
typedef const _sceModuleInfo SceModuleInfo;
|
||||
|
||||
extern char _gp[];
|
||||
|
||||
enum PspModuleInfoAttr
|
||||
{
|
||||
PSP_MODULE_USER = 0,
|
||||
PSP_MODULE_NO_STOP = 0x0001,
|
||||
PSP_MODULE_SINGLE_LOAD = 0x0002,
|
||||
PSP_MODULE_SINGLE_START = 0x0004,
|
||||
PSP_MODULE_KERNEL = 0x1000,
|
||||
};
|
||||
|
||||
/* Declare a module. This must be specified in the source of a library or executable. */
|
||||
#define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
|
||||
__asm__ ( \
|
||||
" .set push\n" \
|
||||
" .section .lib.ent.top, \"a\", @progbits\n" \
|
||||
" .align 2\n" \
|
||||
" .word 0\n" \
|
||||
"__lib_ent_top:\n" \
|
||||
" .section .lib.ent.btm, \"a\", @progbits\n" \
|
||||
" .align 2\n" \
|
||||
"__lib_ent_bottom:\n" \
|
||||
" .word 0\n" \
|
||||
" .section .lib.stub.top, \"a\", @progbits\n" \
|
||||
" .align 2\n" \
|
||||
" .word 0\n" \
|
||||
"__lib_stub_top:\n" \
|
||||
" .section .lib.stub.btm, \"a\", @progbits\n" \
|
||||
" .align 2\n" \
|
||||
"__lib_stub_bottom:\n" \
|
||||
" .word 0\n" \
|
||||
" .set pop\n" \
|
||||
" .text\n" \
|
||||
); \
|
||||
extern char __lib_ent_top[], __lib_ent_bottom[]; \
|
||||
extern char __lib_stub_top[], __lib_stub_bottom[]; \
|
||||
SceModuleInfo module_info \
|
||||
__attribute__((section(".rodata.sceModuleInfo"), \
|
||||
aligned(16), unused)) = { \
|
||||
attributes, { minor_version, major_version }, name, 0, _gp, \
|
||||
__lib_ent_top, __lib_ent_bottom, \
|
||||
__lib_stub_top, __lib_stub_bottom \
|
||||
}
|
||||
|
||||
#define PSP_SDK_VERSION(ver) int syslib_11B97506 = ver
|
||||
|
||||
#define PSP_MODULE_BOOTSTART(name) int module_bootstart(int arglen, void *argp) __attribute__((alias(name)))
|
||||
|
||||
/********** TEMPORARY: it'll be in their corresponding module's header *********/
|
||||
typedef int (*SceKernelCallbackFunction)(int arg1, int arg2, void *arg);
|
||||
|
||||
@ -119,12 +182,9 @@ typedef struct
|
||||
void (*ops[14])();
|
||||
} SceKernelDeci2Ops;
|
||||
|
||||
int sceKernelRegisterExceptionHandler(int exno, void *func); // ExceptionManagerForKernel_06372550
|
||||
int sceKernelRegisterPriorityExceptionHandler(int exno, int priority, void *func); // ExceptionManagerForKernel_7D995AE8
|
||||
int sceKernelRegisterSuspendHandler(int no, void *func, int num); // sceSuspendForKernel_91A77137
|
||||
int sceKernelRegisterResumeHandler(int no, void *func, int num); // sceSuspendForKernel_B43D1A8C
|
||||
int sceKernelRegisterLibrary(char **name); // LoadCoreForKernel_211FEA3D
|
||||
int sceKernelReleaseExceptionHandler(int exno, void *func); // ExceptionManagerForKernel_51763A88
|
||||
int sceKernelGetModuleGPByAddressForKernel(void *func); // LoadCoreForKernel_18CFDAA0
|
||||
|
||||
SceUID sceKernelCreateHeap(SceUID partitionid, SceSize size, int unk, const char *name); // SysMemForKernel_AF85EB1B
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include "../global.h"
|
||||
#include "interruptman.h"
|
||||
|
||||
#include <pspmoduleinfo.h>
|
||||
|
||||
extern int sub_0038();
|
||||
extern int sub_091C();
|
||||
extern int sub_0A74();
|
||||
|
@ -1,3 +1,7 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@ -160,7 +164,7 @@ std::string getInstrType(std::string line)
|
||||
|
||||
bool isBranch(std::string line)
|
||||
{
|
||||
return (getInstrType(line)[0] == 'b');
|
||||
return (getInstrType(line)[0] == 'b' && getInstrType(line) != "break");
|
||||
}
|
||||
|
||||
bool isJump(std::string line)
|
||||
|
Loading…
Reference in New Issue
Block a user