From 083eee8bbac9c1a8ed66c3700377d47628104221 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Mon, 27 Jan 2025 18:05:18 -0600 Subject: [PATCH 1/4] cleanup: [ee/mpeg] remove unused s file --- ee/mpeg/src/libmpeg_core.s | 2272 ------------------------------------ 1 file changed, 2272 deletions(-) delete mode 100644 ee/mpeg/src/libmpeg_core.s diff --git a/ee/mpeg/src/libmpeg_core.s b/ee/mpeg/src/libmpeg_core.s deleted file mode 100644 index 669160ef7c9..00000000000 --- a/ee/mpeg/src/libmpeg_core.s +++ /dev/null @@ -1,2272 +0,0 @@ -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright (c) 2006-2007 Eugene Plotnikov -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. - -#define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) -#include "as_reg_compat.h" - -.set push -.set noreorder -.set nomacro -.set noat - -.globl _MPEG_Initialize -.globl _MPEG_Destroy -.globl _MPEG_GetBits -.globl _MPEG_ShowBits -.globl _MPEG_AlignBits -.globl _MPEG_NextStartCode -.globl _MPEG_SetDefQM -.globl _MPEG_SetQM -.globl _MPEG_GetMBAI -.globl _MPEG_GetMBType -.globl _MPEG_GetMotionCode -.globl _MPEG_GetDMVector -.globl _MPEG_SetIDCP -.globl _MPEG_SetQSTIVFAS -.globl _MPEG_SetPCT -.globl _MPEG_BDEC -.globl _MPEG_WaitBDEC -.globl _MPEG_put_block_fr -.globl _MPEG_put_block_fl -.globl _MPEG_put_block_il -.globl _MPEG_add_block_frfr -.globl _MPEG_add_block_ilfl -.globl _MPEG_add_block_frfl -.globl _MPEG_dma_ref_image -.globl _MPEG_do_mc -.globl _MPEG_put_luma -.globl _MPEG_put_chroma -.globl _MPEG_put_luma_X -.globl _MPEG_put_chroma_X -.globl _MPEG_put_luma_Y -.globl _MPEG_put_chroma_Y -.globl _MPEG_put_luma_XY -.globl _MPEG_put_chroma_XY -.globl _MPEG_avg_luma -.globl _MPEG_avg_chroma -.globl _MPEG_avg_luma_X -.globl _MPEG_avg_chroma_X -.globl _MPEG_avg_luma_Y -.globl _MPEG_avg_chroma_Y -.globl _MPEG_avg_luma_XY -.globl _MPEG_avg_chroma_XY -.globl _MPEG_CSCImage -.globl _MPEG_Suspend -.globl _MPEG_Resume - -.sdata -.align 4 -s_DefQM: .word 0x13101008, 0x16161310, 0x16161616, 0x1B1A181A - .word 0x1A1A1B1B, 0x1B1B1A1A, 0x1D1D1D1B, 0x1D222222 - .word 0x1B1B1D1D, 0x20201D1D, 0x26252222, 0x22232325 - .word 0x28262623, 0x30302828, 0x38382E2E, 0x5345453A - .word 0x10101010, 0x10101010, 0x10101010, 0x10101010 - -.section ".sbss" -.align 6 -s_DMAPack : .space 128 -s_DataBuf : .space 8 -s_SetDMA : .space 8 -s_IPUState: .space 32 -s_pEOF : .space 4 -s_Sema : .space 4 -s_CSCParam: .space 12 -s_CSCID : .space 4 -s_CSCFlag : .space 1 - -.text - -_MPEG_Initialize: - addiu $sp, $sp, -48 - lui $v0, 0x1000 - lui $v1, 0x4000 - sw $a1, s_SetDMA + 0 - sw $v1, 0x2010($v0) - sw $a2, s_SetDMA + 4 - sw $a3, s_pEOF -1: - lw $v1, 0x2010($v0) - bltz $v1, 1b - nop - sw $zero, 0x2000($v0) -1: - lw $v1, 0x2010($v0) - bltz $v1, 1b - nop - lui $at, 0x0080 - sw $ra, 0($sp) - or $v1, $v1, $at - sw $v1, 0x2010($v0) - lui $v0, 0x1001 - sw $zero, -20448($v0) - sw $zero, -19424($v0) - sw $zero, 0($a3) - sw $zero, 12($sp) - addiu $v1, $zero, 64 - addu $a0, $sp, 4 - syscall - sw $v0, s_Sema - addiu $a0, $zero, 3 - addiu $v1, $zero, 18 - lui $a1, %hi( _mpeg_dmac_handler ) - la $a3, s_CSCParam - xor $a2, $a2, $a2 - addiu $a1, %lo( _mpeg_dmac_handler ) - lw $ra, 0($sp) - syscall - addiu $sp, $sp, 48 - sw $v0, s_CSCID - jr $ra - sd $zero, s_DataBuf - -_MPEG_Destroy: -1: - lb $v1, s_CSCFlag - bne $v1, $zero, 1b - lw $a1, s_CSCID - addiu $a0, $zero, 3 - addiu $v1, $zero, 19 - syscall - addiu $v1, $zero, 65 - lw $a0, s_Sema - syscall - jr $ra - -_MPEG_Suspend: -1: - lb $v0, s_CSCFlag - bne $v0, $zero, 1b -_ipu_suspend: - lui $a1, 0x1001 - lui $v0, 0x0001 -1: - di - sync.p - mfc0 $at, $12 - and $at, $at, $v0 - bne $at, $zero, 1b - lui $v0, 0x0001 - lw $a2, -2784($a1) - nor $v1, $v0, $zero - or $a2, $a2, $v0 - sw $a2, -2672($a1) - lw $at, -19456($a1) - sra $a3, $v1, 8 - subu $t1, $a1, $v0 - and $at, $at, $a3 - sw $at, -19456($a1) - lw $a2, -2784($a1) - sw $at, s_IPUState + 0 - and $a2, $a2, $v1 - sw $a2, -2672($a1) - ei - lw $at, -19440($a1) - lw $a2, -19424($a1) - sw $at, s_IPUState + 4 - sw $a2, s_IPUState + 8 -1: - lw $at, 0x2010($t1) - andi $at, $at, 0x00F0 - bne $at, $zero, 1b - nop -1: - di - sync.p - mfc0 $at, $12 - and $at, $at, $v0 - bne $at, $zero, 1b - nop - lw $a2, -2784($a1) - or $a2, $a2, $v0 - sw $a2, -2672($a1) - lw $at, -20480($a1) - and $at, $at, $a3 - sw $at, -20480($a1) - lw $a2, -2784($a1) - sw $at, s_IPUState + 12 - and $a2, $a2, $v1 - sw $a2, -2672($a1) - ei - lw $at, -20464($a1) - lw $a2, -20448($a1) - sw $at, s_IPUState + 16 - sw $a2, s_IPUState + 20 - lw $at, 0x2010($t1) - lw $a2, 0x2020($t1) - sw $at, s_IPUState + 24 - jr $ra - sw $a2, s_IPUState + 28 - -_MPEG_Resume: -_ipu_resume: - lw $v1, s_IPUState + 20 - lui $a0, 0x1001 - lui $a1, 0x1000 - addiu $a2, $zero, 0x0100 - beq $v1, $zero, 1f - lw $at, s_IPUState + 28 - lw $a3, s_IPUState + 12 - lw $v0, s_IPUState + 16 - sw $v0, -20464($a0) - or $a3, $a3, $a2 - sw $v1, -20448($a0) - sw $a3, -20480($a0) -1: - lw $a3, s_IPUState + 8 - andi $v0, $at, 0x007F - srl $v1, $at, 16 - srl $at, $at, 8 - andi $v1, $v1, 0x0003 - andi $at, $at, 0x000F - addu $v1, $v1, $at - lw $at, s_IPUState + 4 - addu $a3, $a3, $v1 - beq $a3, $zero, 2f - sll $v1, $v1, 4 - subu $at, $at, $v1 - sw $v0, 0x2000($a1) - lw $v1, s_IPUState + 0 -1: - lw $v0, 0x2010($a1) - bltz $v0, 1b - nop - lw $v0, s_IPUState + 24 - or $v1, $v1, $a2 - sw $v0, 0x2010($a1) - sw $at, -19440($a0) - sw $a3, -19424($a0) - sw $v1, -19456($a0) -2: - jr $ra - addiu $v0, $v0, 1 - -_mpeg_dmac_handler: - lw $at, 8($a1) - beql $at, $zero, 1f - addiu $v1, $zero, -29 - lw $a0, 0($a1) - lw $a2, 4($a1) - addiu $a3, $zero, 1023 - addiu $v1, $zero, 384 - pminw $a3, $a3, $at - lui $t1, 0x1001 - sll $v0, $a3, 10 - mult $v1, $v1, $a3 - subu $at, $at, $a3 - sw $a2, -20464($t1) - sw $a0, -19440($t1) - addu $a2, $a2, $v0 - srl $v0, $v0, 4 - addu $a0, $a0, $v1 - sw $a0, 0($a1) - srl $v1, $v1, 4 - sw $a2, 4($a1) - lui $t0, 0x1000 - sw $at, 8($a1) - sw $v0, -20448($t1) - lui $v0, 0x7000 - sw $v1, -19424($t1) - addiu $v1, $zero, 0x0101 - or $v0, $v0, $a3 - sw $v1, -19456($t1) - andi $v1, 0x0100 - sw $v0, 0x2000($t0) - sw $v1, -20480($t1) - jr $ra - nor $v0, $zero, $zero -1: - addiu $a0, $zero, 3 - syscall - lw $a0, s_Sema - addiu $v1, $zero, -67 - syscall - sb $zero, s_CSCFlag - jr $ra - nor $v0, $zero, $zero - -_MPEG_CSCImage: - addiu $sp, $sp, -16 - sw $ra, 0($sp) - sw $a0, 4($sp) - sw $a1, 8($sp) - bgezal $zero, _ipu_suspend - sw $a2, 12($sp) - sw $zero, 0x2000($t1) - addiu $t0, $zero, 1023 - addiu $v0, $zero, 8 - addiu $a0, $zero, 3 - addiu $v1, $zero, 22 - lw $a2, 12($sp) - addiu $t3, $zero, 384 - sw $v0, -8176($a1) - pminw $t0, $t0, $a2 - lw $t4, 4($sp) - lw $a3, 8($sp) - subu $a2, $a2, $t0 - mult $t3, $t3, $t0 - sll $t5, $t0, 10 - sw $a3, -20464($a1) - sw $t4, -19440($a1) - sw $a2, s_CSCParam + 8 - addu $t4, $t4, $t3 - addu $a3, $a3, $t5 - sw $t4, s_CSCParam - srl $t3, $t3, 4 - sw $a3, s_CSCParam + 4 - srl $t5, $t5, 4 - sw $t3, -19424($a1) - sw $t5, -20448($a1) - sw $t0, 4($sp) - syscall - lw $t0, 4($sp) - addiu $v1, $zero, 0x0101 - lui $at, 0x1001 - lui $v0, 0x7000 - lui $a0, 0x1000 - or $v0, $v0, $t0 - sw $v1, -19456($at) - andi $v1, $v1, 0x0100 - sw $v0, 0x2000($a0) - sw $v1, -20480($at) - lw $a0, s_Sema - addiu $v1, $zero, 68 - sb $v1, s_CSCFlag - syscall - lw $ra, 0($sp) - beq $zero, $zero, _ipu_resume - addiu $sp, $sp, 16 -1: - lw $v1, 0x2010($at) -_ipu_sync: - lui $a1, 0x0003 - andi $a2, $a0, 0xFF00 - and $v0, $a0, $a1 - andi $a0, $a0, 0x007F - addiu $a1, $zero, 0x4000 - srl $a2, $a2, 1 - srl $v0, $v0, 9 - and $a1, $a1, $v1 - addu $a2, $a2, $v0 - subu $a2, $a2, $a0 - bne $a1, $zero, 3f - slti $a2, $a2, 32 - beq $a2, $zero, 2f - lui $a2, 0x1001 - lw $a2, -19424($a2) - bgtzl $a2, 1b - lw $a0, 0x2020($at) - addiu $sp, $sp, -16 - lw $a2, s_SetDMA + 0 - sw $ra, 0($sp) - jalr $a2 - lw $a0, s_SetDMA + 4 - lw $ra, 0($sp) - addiu $sp, $sp, 16 - beql $v0, $zero, 4f - lw $v1, s_pEOF - lui $at, 0x1000 -2: - lw $v1, 0x2010($at) - bltzl $v1, _ipu_sync - lw $a0, 0x2020($at) -3: - jr $ra -4: - addiu $a0, $zero, 32 - addiu $v0, $zero, 0x01B7 - sw $a0, s_DataBuf - sw $v0, s_DataBuf + 4 - jr $ra - sw $a0, 0($v1) - -_ipu_sync_data: - lui $at, 0x1000 - ld $v0, 0x2000($at) - bltzl $v0, 1f - lw $a0, 0x2020($at) - jr $ra -1: - lui $a1, 0x0003 - andi $v1, $a0, 0xFF00 - and $v0, $a0, $a1 - srl $v1, $v1, 1 - srl $v0, $v0, 9 - addu $v1, $v1, $v0 - andi $a0, $a0, 0x7F - subu $v0, $v1, $a0 - sltiu $v0, $v0, 32 - beq $v0, $zero, 2f - lui $v0, 0x1001 - lw $v0, -19424($v0) - bgtzl $v0, 1b - lw $a0, 0x2020($at) - lw $v0, s_SetDMA + 0 - addiu $sp, $sp, -16 - sw $ra, 0($sp) - jalr $v0 - lw $a0, s_SetDMA + 4 - lw $ra, 0($sp) - addiu $sp, $sp, 16 - beql $v0, $zero, 4b - lw $v1, s_pEOF - lui $at, 0x1000 -2: - ld $v0, 0x2000($at) - bltzl $v0, 1b - lw $a0, 0x2020($at) - jr $ra - -_MPEG_GetBits: -_ipu_get_bits: - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sd $ra, 0($sp) - sd $s0, 8($sp) - addu $s0, $zero, $a0 - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lw $v1, s_DataBuf + 0 - slt $v0, $v1, $s0 - beqzl $v0, 1f - lw $v0, s_DataBuf + 4 - lui $at, 0x1000 - lui $a1, 0x4000 - bgezal $zero, _ipu_sync_data - sw $a1, 0x2000($at) - addiu $v1, $zero, 32 -1: - lui $a1, 0x4000 - or $a1, $a1, $s0 - subu $v1, $v1, $s0 - sw $a1, 0x2000($at) - sw $v1, s_DataBuf + 0 - subu $a2, $zero, $s0 - sllv $v1, $v0, $s0 - srlv $v0, $v0, $a2 - sw $v1, s_DataBuf + 4 - ld $ra, 0($sp) - ld $s0, 8($sp) - jr $ra - addiu $sp, $sp, 16 - -_MPEG_ShowBits: -_ipu_show_bits: - lw $v1, s_DataBuf + 0 - slt $v0, $v1, $a0 - beqzl $v0, 1f - lw $v0, s_DataBuf + 4 - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sw $ra, 0($sp) - sw $a0, 4($sp) - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lui $at, 0x1000 - lui $a1, 0x4000 - bgezal $zero, _ipu_sync_data - sw $a1, 0x2000($at) - addiu $v1, $zero, 32 - sw $v1, s_DataBuf + 0 - sw $v0, s_DataBuf + 4 - lw $ra, 0($sp) - lw $a0, 4($sp) - addiu $sp, $sp, 16 -1: - subu $a0, $zero, $a0 - jr $ra - srlv $v0, $v0, $a0 - -_MPEG_AlignBits: -_ipu_align_bits: - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sw $ra, 0($sp) - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lw $a0, 0x2020($at) - andi $a0, $a0, 7 - subu $a0, $zero, $a0 - andi $a0, $a0, 7 - beq $a0, $zero, 1f - lw $ra, 0($sp) - beq $zero, $zero, _ipu_get_bits -1: - addiu $sp, $sp, 16 - jr $ra - nop - -_MPEG_NextStartCode: - addiu $sp, $sp, -16 - sw $ra, 0($sp) - bgezal $zero, _ipu_align_bits - nop -1: - bgezal $zero, _ipu_show_bits - addiu $a0, $zero, 24 - addiu $v1, $zero, 1 -4: - bne $v0, $v1, 5f - addiu $a0, $zero, 32 - lw $ra, 0($sp) - beq $zero, $zero, _ipu_show_bits - addiu $sp, $sp, 16 -5: - bgezal $zero, _ipu_get_bits - addiu $a0, $zero, 8 - beq $zero, $zero, 1b - nop - -_MPEG_SetDefQM: - addiu $sp, $sp, -16 - sw $ra, 0($sp) - bgezal $zero, _ipu_suspend - nop - lui $v1, 0x1000 - la $at, s_DefQM - sw $zero, 0x2000($v1) - lq $a0, 0($at) - lq $a1, 16($at) - lq $a2, 32($at) - lq $a3, 48($at) - lq $t0, 64($at) - lui $v0, 0x5000 -1: - lw $at, 0x2010($v1) - bltz $at, 1b - nop - sq $a0, 0x7010($v1) - sq $a1, 0x7010($v1) - sq $a2, 0x7010($v1) - sq $a3, 0x7010($v1) - sw $v0, 0x2000($v1) - lui $v0, 0x5800 -1: - lw $at, 0x2010($v1) - bltz $at, 1b - nop - sq $t0, 0x7010($v1) - sq $t0, 0x7010($v1) - sq $t0, 0x7010($v1) - sq $t0, 0x7010($v1) - sw $v0, 0x2000($v1) -1: - lw $at, 0x2010($v1) - bltz $at, 1b - nop - lw $ra, 0($sp) - beq $zero, $zero, _ipu_resume - addiu $sp, $sp, 16 - -_MPEG_SetQM: - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sw $ra, 0($sp) - sd $s0, 8($sp) - sll $s0, $a0, 27 - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lui $a0, 0x5000 - or $a0, $a0, $s0 - sw $a0, 0x2000($at) - lw $ra, 0($sp) - ld $s0, 8($sp) - addiu $sp, $sp, 16 - jr $ra - sd $zero, s_DataBuf - -_MPEG_GetMBAI: - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sw $ra, 0($sp) - sd $s0, 8($sp) - addu $s0, $zero, $zero - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) -3: - lui $v0, 0x3000 -4: - bgezal $zero, _ipu_sync_data - sw $v0, 0x2000($at) - beql $v0, $zero, 1f - addu $s0, $zero, $zero - andi $v0, $v0, 0xFFFF - slti $v1, $v0, 0x0022 - bnel $v1, $zero, 2f - addu $s0, $s0, $v0 - addiu $v1, $zero, 0x0023 - beql $v0, $v1, 3b - addiu $s0, $s0, 0x0021 - beq $zero, $zero, 4b - lui $v0, 0x3000 -2: - addiu $v1, $zero, 32 - ld $a0, 0x2030($at) - sw $v1, s_DataBuf + 0 - sw $a0, s_DataBuf + 4 -1: - addu $v0, $zero, $s0 - lw $ra, 0($sp) - ld $s0, 8($sp) - jr $ra - addiu $sp, $sp, 16 - -_MPEG_GetMBType: - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sw $ra, 0($sp) - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lui $a2, 0x3400 - bgezal $zero, _ipu_sync_data - sw $a2, 0x2000($at) - beq $v0, $zero, 1f - addiu $v1, $zero, 32 - ld $a1, 0x2030($at) - andi $v0, $v0, 0xFFFF - sw $v1, s_DataBuf + 0 - sw $a1, s_DataBuf + 4 -1: - lw $ra, 0($sp) - jr $ra - addiu $sp, $sp, 16 - -_MPEG_GetMotionCode: - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sw $ra, 0($sp) - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lui $a2, 0x3800 - bgezal $zero, _ipu_sync_data - sw $a2, 0x2000($at) - beql $v0, $zero, 1f - addiu $v0, $zero, 0x8000 - addiu $v1, $zero, 32 - ld $a1, 0x2030($at) - andi $v0, $v0, 0xFFFF - sw $v1, s_DataBuf + 0 - sw $a1, s_DataBuf + 4 -1: - dsll32 $v0, $v0, 16 - lw $ra, 0($sp) - dsra32 $v0, $v0, 16 - jr $ra - addiu $sp, $sp, 16 - -_MPEG_GetDMVector: - lui $at, 0x1000 - addiu $sp, $sp, -16 - lw $v1, 0x2010($at) - sw $ra, 0($sp) - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lui $a2, 0x3C00 - bgezal $zero, _ipu_sync_data - sw $a2, 0x2000($at) - addiu $v1, $zero, 32 - ld $a1, 0x2030($at) - dsll32 $v0, $v0, 16 - sw $v1, s_DataBuf + 0 - sw $a1, s_DataBuf + 4 - lw $ra, 0($sp) - dsra32 $v0, $v0, 16 - jr $ra - addiu $sp, $sp, 16 - -_MPEG_SetIDCP: - addiu $sp, $sp, -16 - sw $ra, 0($sp) - bgezal $zero, _ipu_get_bits - addiu $a0, $zero, 2 - lui $v1, 0xFFFC - sll $v0, $v0, 16 - lw $a0, 0x2010($at) - ori $v1, $v1, 0xFFFF - lw $ra, 0($sp) - and $a0, $a0, $v1 - addiu $sp, $sp, 16 - or $a0, $a0, $v0 - jr $ra - sw $a0, 0x2010($at) - -_MPEG_SetQSTIVFAS: - addiu $sp, $sp, -16 - sd $ra, 0($sp) - sd $s0, 8($sp) - bgezal $zero, _ipu_get_bits - addiu $a0, $zero, 1 - sll $s0, $v0, 22 - bgezal $zero, _ipu_get_bits - addiu $a0, $zero, 1 - sll $v0, $v0, 21 - addiu $a0, $zero, 1 - bgezal $zero, _ipu_get_bits - or $s0, $s0, $v0 - sll $v0, $v0, 20 - lw $a0, 0x2010($at) - lui $v1, 0xFF8F - or $s0, $s0, $v0 - ori $v1, $v1, 0xFFFF - ld $ra, 0($sp) - and $a0, $a0, $v1 - addiu $sp, $sp, 16 - or $a0, $a0, $s0 - ld $s0, -8($sp) - jr $ra - sw $a0, 0x2010($at) - -_MPEG_SetPCT: - sll $a0, $a0, 24 - addiu $sp, $sp, -16 - lui $at, 0x1000 - sw $ra, 0($sp) - sw $a0, 4($sp) - lw $v1, 0x2010($at) - bltzl $v1, _ipu_sync - lw $a0, 0x2020($at) - lw $v0, 4($sp) - lui $a0, 0xF8FF - ori $a0, $a0, 0xFFFF - and $v1, $v1, $a0 - or $v1, $v1, $v0 - lw $ra, 0($sp) - addiu $sp, $sp, 16 - jr $ra - sw $v1, 0x2010($at) - -_MPEG_BDEC: - addiu $sp, $sp, -16 - sll $a0, $a0, 27 - sd $ra, 0($sp) - sll $a1, $a1, 26 - sd $s0, 8($sp) - lui $s0, 0x2000 - sll $a2, $a2, 25 - or $s0, $s0, $a0 - sll $a3, $a3, 16 - or $s0, $s0, $a1 - lui $a0, 0x8000 - or $s0, $s0, $a2 - sll $t0, $t0, 4 - or $s0, $s0, $a3 - srl $t0, $t0, 4 - lui $a1, 0x1001 - lui $at, 0x1000 - or $t0, $t0, $a0 - lw $v1, 0x2010($at) - addiu $a0, $zero, 48 - addiu $a2, $zero, 0x0100 - sw $t0, -20464($a1) - sw $a0, -20448($a1) - sw $a2, -20480($a1) - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - ld $ra, 0($sp) - sw $s0, 0x2000($at) - ld $s0, 8($sp) - jr $ra - addiu $sp, $sp, 16 - -_MPEG_WaitBDEC: - addiu $sp, $sp, -16 - lui $at, 0x1000 - lw $v1, 0x2010($at) - sw $ra, 0($sp) -1: - bltzall $v1, _ipu_sync - lw $a0, 0x2020($at) - lw $v1, s_pEOF - addiu $a0, $zero, 0x4000 - lw $v1, 0($v1) - lui $a2, 0x1001 - bne $v1, $zero, 3f - lw $v0, 0x2010($at) - and $v0, $v0, $a0 - bne $v0, $zero, 3f - lw $a2, -20448($a2) - addiu $v0, $zero, 1 - bnel $a2, $zero, 1b - lw $v1, 0x2010($at) - ld $v1, 0x2030($at) - addiu $ra, $zero, 32 - addiu $v0, $zero, 1 - pextlw $v1, $v1, $ra -2: - lw $ra, 0($sp) - sd $v1, s_DataBuf - jr $ra - addiu $sp, $sp, 16 -3: - bgezal $zero, _ipu_suspend - lui $t0, 0x4000 - bgezal $zero, _ipu_resume - sw $t0, 0x2010($t1) - lui $v0, 0x0001 -4: - di - sync.p - mfc0 $at, $12 - and $at, $at, $v0 - nor $a2, $v0, $zero - bne $at, $zero, 4b - lw $at, -2784($a0) - xor $v1, $v1, $v1 - or $at, $at, $v0 - sw $at, -2672($a0) - sw $zero, -20480($a0) - lw $at, -2784($a0) - xor $v0, $v0, $v0 - and $at, $at, $a2 - sw $at, -2672($a0) - ei - beq $zero, $zero, 2b - sw $zero, -20448($a0) - -_MPEG_put_block_fr: - lw $a2, 0($a0) - lw $a3, 8($a0) - pnor $v0, $zero, $zero - addiu $v1, $zero, 6 - psrlh $v0, $v0, 8 -1: - lq $t0, 0($a3) - lq $t1, 16($a3) - lq $t2, 32($a3) - lq $t3, 48($a3) - addiu $v1, $v1, -1; - lq $t4, 64($a3) - lq $t5, 80($a3) - lq $t6, 96($a3) - lq $t7, 112($a3) - addiu $a3, $a3, 128 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t0, 0($a2) - sq $t2, 16($a2) - sq $t4, 32($a2) - sq $t6, 48($a2) - bgtzl $v1, 1b - addiu $a2, $a2, 64 - jr $ra - -_MPEG_put_block_fl: - pnor $v0, $zero, $zero - lw $a2, 0($a0) - lw $a3, 8($a0) - addiu $v1, $zero, 4 - psrlh $v0, $v0, 8 -1: - lq $t0, 0($a3) - lq $t1, 16($a3) - lq $t2, 32($a3) - lq $t3, 48($a3) - addiu $v1, $v1, -1 - lq $t4, 256($a3) - lq $t5, 272($a3) - lq $t6, 288($a3) - lq $t7, 304($a3) - addiu $a3, $a3, 64 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t0, 0($a2) - sq $t4, 16($a2) - sq $t2, 32($a2) - sq $t6, 48($a2) - bgtz $v1, 1b - addiu $a2, $a2, 64 - addiu $v1, $v1, 2 -2: - lq $t0, 256($a3) - lq $t1, 272($a3) - lq $t2, 288($a3) - lq $t3, 304($a3) - addiu $v1, $v1, -1 - lq $t4, 320($a3) - lq $t5, 336($a3) - lq $t6, 352($a3) - lq $t7, 368($a3) - addiu $a3, $a3, 128 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t0, 0($a2) - sq $t2, 16($a2) - sq $t4, 32($a2) - sq $t6, 48($a2) - bgtzl $v1, 2b - addiu $a2, $a2, 64 - jr $ra - -_MPEG_put_block_il: - pnor $v0, $zero, $zero - lw $a2, 0($a0) - lw $a3, 8($a0) - lw $at, 24($a0) - addiu $v1, $zero, 4 - psrlh $v0, $v0, 8 - addu $at, $at, $a2 -1: - lq $t0, 0($a3) - lq $t1, 16($a3) - lq $t2, 32($a3) - lq $t3, 48($a3) - addiu $v1, $v1, -1 - lq $t4, 256($a3) - lq $t5, 272($a3) - lq $t6, 288($a3) - lq $t7, 304($a3) - addiu $a3, $a3, 64 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t0, 0($a2) - sq $t2, 32($a2) - addiu $a2, $a2, 64 - sq $t4, 0($at) - sq $t6, 32($at) - bgtzl $v1, 1b - addiu $at, $at, 64 - lw $a2, 4($a0) - lw $at, 24($a0) - addiu $v1, $zero, 2 - addu $at, $at, $a2 -2: - lq $t0, 256($a3) - lq $t1, 272($a3) - lq $t2, 288($a3) - lq $t3, 304($a3) - addiu $v1, $v1, -1 - lq $t4, 320($a3) - lq $t5, 336($a3) - lq $t6, 352($a3) - lq $t7, 368($a3) - addiu $a3, $a3, 128 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t0, $zero, $t0 - ppacb $t1, $zero, $t1 - ppacb $t2, $zero, $t2 - ppacb $t3, $zero, $t3 - ppacb $t4, $zero, $t4 - ppacb $t5, $zero, $t5 - ppacb $t6, $zero, $t6 - ppacb $t7, $zero, $t7 - sd $t0, 0($a2) - sd $t1, 16($a2) - sd $t2, 32($a2) - sd $t3, 48($a2) - sd $t4, 0($at) - sd $t5, 16($at) - sd $t6, 32($at) - sd $t7, 48($at) - addiu $a2, $a2, 64 - bgtzl $v1, 2b - addiu $at, $at, 64 - jr $ra - -_MPEG_add_block_frfr: - pnor $v0, $zero, $zero - lw $a2, 0($a0) - lw $a3, 12($a0) - lw $a0, 16($a0) - addiu $v1, $zero, 6 - psrlh $v0, $v0, 8 -1: - lq $t0, 0($a3) - lq $t1, 16($a3) - lq $t2, 32($a3) - lq $t3, 48($a3) - addiu $v1, $v1, -1 - lq $t4, 0($a0) - lq $t5, 16($a0) - lq $t6, 32($a0) - lq $t7, 48($a0) - paddh $t0, $t0, $t4 - paddh $t1, $t1, $t5 - paddh $t2, $t2, $t6 - paddh $t3, $t3, $t7 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - sq $t0, 0($a2) - sq $t2, 16($a2) - lq $t4, 64($a3) - lq $t5, 80($a3) - lq $t6, 96($a3) - lq $t7, 112($a3) - addiu $a3, $a3, 128 - lq $t0, 64($a0) - lq $t1, 80($a0) - lq $t2, 96($a0) - lq $t3, 112($a0) - addiu $a0, $a0, 128 - paddh $t4, $t4, $t0 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - paddh $t7, $t7, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t4, 32($a2) - sq $t6, 48($a2) - bgtzl $v1, 1b - addiu $a2, $a2, 64 - jr $ra - -_MPEG_add_block_ilfl: - pnor $v0, $zero, $zero - lw $a2, 0($a0) - lw $a3, 12($a0) - lw $at, 24($a0) - lw $a1, 16($a0) - addiu $v1, $zero, 4 - psrlh $v0, $v0, 8 - addu $at, $at, $a2 -1: - lq $t0, 0($a3) - lq $t1, 16($a3) - lq $t2, 32($a3) - lq $t3, 48($a3) - addiu $v1, $v1, -1 - lq $t4, 0($a1) - lq $t5, 16($a1) - lq $t6, 32($a1) - lq $t7, 48($a1) - paddh $t0, $t0, $t4 - paddh $t1, $t1, $t5 - paddh $t2, $t2, $t6 - paddh $t3, $t3, $t7 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - sq $t0, 0($a2) - sq $t2, 32($a2) - lq $t4, 256($a3) - lq $t5, 272($a3) - lq $t6, 288($a3) - lq $t7, 304($a3) - addiu $a3, $a3, 64 - lq $t0, 256($a1) - lq $t1, 272($a1) - lq $t2, 288($a1) - lq $t3, 304($a1) - paddh $t4, $t4, $t0 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - paddh $t7, $t7, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t4, 0($at) - sq $t6, 32($at) - addiu $at, $at, 64 - addiu $a1, $a1, 64 - bgtzl $v1, 1b - addiu $a2, $a2, 64 - lw $a2, 4($a0) - lw $at, 24($a0) - addiu $v1, $zero, 2 - addu $at, $at, $a2 -2: - lq $t0, 256($a3) - lq $t1, 272($a3) - lq $t2, 288($a3) - lq $t3, 304($a3) - addiu $v1, $v1, -1 - lq $t4, 256($a1) - lq $t5, 272($a1) - lq $t6, 288($a1) - lq $t7, 304($a1) - paddh $t0, $t0, $t4 - paddh $t1, $t1, $t5 - paddh $t2, $t2, $t6 - paddh $t3, $t3, $t7 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - ppacb $t0, $zero, $t0 - ppacb $t1, $zero, $t1 - ppacb $t2, $zero, $t2 - ppacb $t3, $zero, $t3 - sd $t0, 0($a2) - sd $t1, 16($a2) - sd $t2, 32($a2) - sd $t3, 48($a2) - lq $t4, 320($a3) - lq $t5, 336($a3) - lq $t6, 352($a3) - lq $t7, 368($a3) - addiu $a3, $a3, 128 - lq $t0, 320($a1) - lq $t1, 336($a1) - lq $t2, 352($a1) - lq $t3, 368($a1) - paddh $t4, $t4, $t0 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - paddh $t7, $t7, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t4, $zero, $t4 - ppacb $t5, $zero, $t5 - ppacb $t6, $zero, $t6 - ppacb $t7, $zero, $t7 - sd $t4, 0($at) - sd $t5, 16($at) - sd $t6, 32($at) - sd $t7, 48($at) - addiu $a2, $a2, 64 - addiu $at, $at, 64 - bgtzl $v1, 2b - addiu $a1, $a1, 128 - jr $ra - -_MPEG_add_block_frfl: - pnor $v0, $zero, $zero - lw $a2, 0($a0) - lw $a3, 12($a0) - lw $a1, 16($a0) - addiu $v1, $zero, 4 - psrlh $v0, $v0, 8 -1: - lq $t0, 0($a3) - lq $t1, 16($a3) - lq $t2, 32($a3) - lq $t3, 48($a3) - addiu $v1, $v1, -1 - lq $t4, 0($a1) - lq $t5, 16($a1) - lq $t6, 256($a1) - lq $t7, 272($a1) - paddh $t0, $t0, $t4 - paddh $t1, $t1, $t5 - paddh $t2, $t2, $t6 - paddh $t3, $t3, $t7 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - sq $t0, 0($a2) - sq $t2, 16($a2) - lq $t4, 64($a3) - lq $t5, 80($a3) - lq $t6, 96($a3) - lq $t7, 112($a3) - addiu $a3, $a3, 128 - lq $t0, 32($a1) - lq $t1, 48($a1) - lq $t2, 288($a1) - lq $t3, 304($a1) - paddh $t4, $t4, $t0 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - paddh $t7, $t7, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t4, 32($a2) - sq $t6, 48($a2) - addiu $a1, $a1, 64 - bgtzl $v1, 1b - addiu $a2, $a2, 64 - lw $a2, 4($a0) - addiu $v1, $zero, 2 -2: - lq $t0, 0($a3) - lq $t1, 16($a3) - lq $t2, 32($a3) - lq $t3, 48($a3) - addiu $v1, $v1, -1 - lq $t4, 256($a1) - lq $t5, 320($a1) - lq $t6, 272($a1) - lq $t7, 336($a1) - paddh $t0, $t0, $t4 - paddh $t1, $t1, $t5 - paddh $t2, $t2, $t6 - paddh $t3, $t3, $t7 - pmaxh $t0, $zero, $t0 - pmaxh $t1, $zero, $t1 - pmaxh $t2, $zero, $t2 - pmaxh $t3, $zero, $t3 - pminh $t0, $v0, $t0 - pminh $t1, $v0, $t1 - pminh $t2, $v0, $t2 - pminh $t3, $v0, $t3 - ppacb $t0, $t1, $t0 - ppacb $t2, $t3, $t2 - sq $t0, 0($a2) - sq $t2, 16($a2) - lq $t4, 64($a3) - lq $t5, 80($a3) - lq $t6, 96($a3) - lq $t7, 112($a3) - addiu $a3, $a3, 128 - lq $t0, 288($a1) - lq $t1, 352($a1) - lq $t2, 304($a1) - lq $t3, 368($a1) - paddh $t4, $t4, $t0 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - paddh $t7, $t7, $t3 - pmaxh $t4, $zero, $t4 - pmaxh $t5, $zero, $t5 - pmaxh $t6, $zero, $t6 - pmaxh $t7, $zero, $t7 - pminh $t4, $v0, $t4 - pminh $t5, $v0, $t5 - pminh $t6, $v0, $t6 - pminh $t7, $v0, $t7 - ppacb $t4, $t5, $t4 - ppacb $t6, $t7, $t6 - sq $t4, 32($a2) - sq $t6, 48($a2) - addiu $a2, $a2, 64 - bgtzl $v1, 2b - addiu $a1, $a1, 128 - jr $ra - -_MPEG_dma_ref_image: - addiu $at, $zero, 4 - pminw $a2, $a2, $at - bgtzl $a2, 1f - addiu $at, $at, 380 - jr $ra -1: - lui $v0, 0x1001 - mult $a3, $a3, $at - sll $at, $a0, 4 - lui $t1, 0x2000 - la $t0, s_DMAPack -1: - lw $v1, -11264($v0) - andi $v1, $v1, 0x0100 - bne $v1, $zero, 1b - nop - srl $at, $at, 4 - sw $zero, -11232($v0) - or $t1, $t1, $t0 - sw $at, -11136($v0) - lui $v1, 0x3000 - sw $t0, -11216($v0) - ori $v1, $v1, 0x0030 -1: - lw $t0, 0($a1) - addiu $a2, $a2, -1 - sw $v1, 0($t1) - sw $t0, 4($t1) - addu $t0, $t0, $a3 - sw $v1, 16($t1) - sw $t0, 20($t1) - sw $a0, 0($a1) - addiu $a1, $a1, 40 - addiu $t1, $t1, 32 - bgtz $a2, 1b - addiu $a0, $a0, 1536 - andi $v1, $v1, 0xFFFF - addiu $at, $zero, 0x0105 - sw $v1, -16($t1) - sw $zero, 32($a1) - sync.l - jr $ra - sw $at, -11264($v0) - -_MPEG_do_mc: - addiu $v0, $zero, 16 - lw $a1, 0($a0) - addiu $sp, $sp, -16 - lw $a2, 4($a0) - lw $a3, 12($a0) - lw $t0, 16($a0) - lw $t1, 20($a0) - lw $t2, 24($a0) - lw $t4, 28($a0) - subu $t0, $t0, $t4 - lw $t5, 32($a0) - sll $t4, $t4, 4 - addu $a1, $a1, $t4 - subu $v1, $v0, $t0 - sllv $t3, $v0, $t2 - srlv $v1, $v1, $t2 - sll $at, $t0, 4 - sw $ra, 0($sp) - addu $a1, $a1, $at - jalr $t5 - subu $at, $t1, $v1 - lw $a1, 0($a0) - lw $a2, 8($a0) - lw $t5, 36($a0) - addiu $a1, $a1, 256 - srl $t4, $t4, 1 - srl $a3, $a3, 1 - srl $t0, $t0, 1 - srl $t1, $t1, 1 - lw $ra, 0($sp) - srlv $t0, $t0, $t2 - addu $a1, $a1, $t4 - addiu $v0, $zero, 8 - sllv $t0, $t0, $t2 - subu $v1, $v0, $t0 - sllv $t3, $v0, $t2 - srlv $v1, $v1, $t2 - sll $at, $t0, 3 - addu $a1, $a1, $at - subu $at, $t1, $v1 - jr $t5 - addiu $sp, $sp, 16 - -_MPEG_put_luma: - mtsab $a3, 0 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t5, $t6, $t5 - pextlb $t6, $zero, $t5 - pextub $t5, $zero, $t5 - sq $t6, 0($a2) - sq $t5, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_put_chroma: - mtsab $a3, 0 -1: - ld $t5, 0($a1) - ld $t6, 64($a1) - ld $t7, 384($a1) - ld $t8, 448($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - pcpyld $t5, $t7, $t5 - pcpyld $t6, $t8, $t6 - qfsrv $t5, $t5, $t5 - qfsrv $t6, $t6, $t6 - pextlb $t5, $zero, $t5 - pextlb $t6, $zero, $t6 - sq $t5, 0($a2) - sq $t6, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_put_luma_X: - pnor $v0, $zero, $zero - psrlh $v0, $v0, 15 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - mtsab $a3, 0 - qfsrv $t7, $t6, $t5 - qfsrv $t8, $t5, $t6 - pextlb $t5, $zero, $t7 - pextub $t6, $zero, $t7 - addu $a1, $a1, $t3 - mtsab $zero, 1 - addiu $v1, $v1, -1 - qfsrv $t8, $t8, $t7 - pextlb $t7, $zero, $t8 - pextub $t8, $zero, $t8 - paddh $t5, $t5, $t7 - paddh $t6, $t6, $t8 - paddh $t5, $t5, $v0 - paddh $t6, $t6, $v0 - psrlh $t5, $t5, 1 - psrlh $t6, $t6, 1 - sq $t5, 0($a2) - sq $t6, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_put_chroma_X: - pnor $v0, $zero, $zero - psrlh $v0, $v0, 15 -1: - ld $t5, 0($a1) - ld $t6, 64($a1) - ld $t7, 384($a1) - ld $t8, 448($a1) - pcpyld $t5, $t7, $t5 - pcpyld $t6, $t8, $t6 - mtsab $a3, 0 - qfsrv $t5, $t5, $t5 - qfsrv $t6, $t6, $t6 - addiu $t9, $zero, 1 - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - mtsab $t9, 0 - qfsrv $t1, $t5, $t5 - qfsrv $t2, $t6, $t6 - pextlb $t5, $zero, $t5 - pextlb $t6, $zero, $t6 - pextlb $t1, $zero, $t1 - pextlb $t2, $zero, $t2 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - paddh $t5, $t5, $v0 - paddh $t6, $t6, $v0 - psrlh $t5, $t5, 1 - psrlh $t6, $t6, 1 - sq $t5, 0($a2) - sq $t6, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_put_luma_Y: - mtsab $a3, 0 - lq $t7, 0($a1) - lq $t8, 384($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t7, $t8, $t7 - pextub $t8, $zero, $t7 - pextlb $t7, $zero, $t7 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t5, $t6, $t5 - pextub $t6, $zero, $t5 - pextlb $t5, $zero, $t5 - paddh $v0, $t6, $t8 - pnor $t8, $zero, $zero - paddh $t9, $t5, $t7 - psrlh $t8, $t8, 15 - por $t7, $zero, $t5 - paddh $t9, $t9, $t8 - paddh $v0, $v0, $t8 - por $t8, $zero, $t6 - psrlh $t9, $t9, 1 - psrlh $v0, $v0, 1 - sq $t9, 0($a2) - sq $v0, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_put_chroma_Y: - mtsab $a3, 0 - ld $a0, 0($a1) - ld $a3, 64($a1) - ld $t0, 384($a1) - ld $t1, 448($a1) - pnor $v0, $zero, $zero - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - psrlh $v0, $v0, 15 - pcpyld $a0, $t0, $a0 - pcpyld $a3, $t1, $a3 - qfsrv $a0, $a0, $a0 - qfsrv $a3, $a3, $a3 - pextlb $a0, $zero, $a0 - pextlb $a3, $zero, $a3 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - ld $t5, 0($a1) - ld $t6, 64($a1) - ld $t7, 384($a1) - ld $t8, 448($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - pcpyld $t5, $t7, $t5 - pcpyld $t6, $t8, $t6 - qfsrv $t5, $t5, $t5 - qfsrv $t6, $t6, $t6 - pextlb $t5, $zero, $t5 - pextlb $t6, $zero, $t6 - paddh $t1, $t5, $a0 - paddh $t2, $t6, $a3 - por $a0, $zero, $t5 - por $a3, $zero, $t6 - paddh $t1, $t1, $v0 - paddh $t2, $t2, $v0 - psrlh $t1, $t1, 1 - psrlh $t2, $t2, 1 - sq $t1, 0($a2) - sq $t2, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_put_luma_XY: - mtsab $a3, 0 - lq $v0, 0($a1) - lq $t7, 384($a1) - addu $a1, $a1, $t3 - qfsrv $t8, $t7, $v0 - qfsrv $t9, $v0, $t7 - addiu $v1, $v1, -1 - pextlb $v0, $zero, $t8 - pextub $t7, $zero, $t8 - mtsab $zero, 1 - qfsrv $t9, $t9, $t8 - pextlb $t8, $zero, $t9 - pextub $t9, $zero, $t9 - paddh $v0, $v0, $t8 - paddh $t7, $t7, $t9 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - mtsab $a3, 0 - addu $a1, $a1, $t3 - qfsrv $t8, $t6, $t5 - qfsrv $t9, $t5, $t6 - addiu $v1, $v1, -1 - pextlb $t5, $zero, $t8 - pextub $t6, $zero, $t8 - mtsab $zero, 1 - qfsrv $t9, $t9, $t8 - pextlb $t8, $zero, $t9 - pextub $t9, $zero, $t9 - paddh $t5, $t5, $t8 - paddh $t6, $t6, $t9 - paddh $t8, $v0, $t5 - paddh $t9, $t7, $t6 - por $v0, $zero, $t5 - pnor $t5, $zero, $zero - por $t7, $zero, $t6 - psrlh $t5, $t5, 15 - psllh $t5, $t5, 1 - paddh $t8, $t8, $t5 - paddh $t9, $t9, $t5 - psrlh $t8, $t8, 2 - psrlh $t9, $t9, 2 - sq $t8, 0($a2) - sq $t9, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_put_chroma_XY: - mtsab $a3, 0 - pnor $t9, $zero, $zero - ld $a0, 0($a1) - ld $v0, 64($a1) - mtsab $zero, 1 - ld $t0, 384($a1) - ld $t1, 448($a1) - pcpyld $a0, $t0, $a0 - pcpyld $v0, $t1, $v0 - qfsrv $a0, $a0, $a0 - qfsrv $v0, $v0, $v0 - psrlh $t9, $t9, 15 - psllh $t9, $t9, 1 - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t0, $a0, $a0 - qfsrv $t1, $v0, $v0 - pextlb $a0, $zero, $a0 - pextlb $v0, $zero, $v0 - pextlb $t0, $zero, $t0 - pextlb $t1, $zero, $t1 - paddh $a0, $a0, $t0 - paddh $t0, $v0, $t1 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - ld $t5, 0($a1) - ld $t7, 64($a1) - mtsab $a3, 0 - ld $t6, 384($a1) - ld $t8, 448($a1) - pcpyld $t5, $t6, $t5 - pcpyld $t7, $t8, $t7 - qfsrv $t5, $t5, $t5 - qfsrv $t7, $t7, $t7 - addiu $v0, $zero, 1 - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - mtsab $v0, 0 - qfsrv $t6, $t5, $t5 - qfsrv $t8, $t7, $t7 - pextlb $t5, $zero, $t5 - pextlb $t7, $zero, $t7 - pextlb $t6, $zero, $t6 - pextlb $t8, $zero, $t8 - paddh $t5, $t5, $t6 - paddh $t6, $t7, $t8 - paddh $t7, $a0, $t5 - paddh $t8, $t0, $t6 - por $a0, $zero, $t5 - por $t0, $zero, $t6 - paddh $t7, $t7, $t9 - paddh $t8, $t8, $t9 - psrlh $t7, $t7, 2 - psrlh $t8, $t8, 2 - sq $t7, 0($a2) - sq $t8, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_luma: - mtsab $a3, 0 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t5, $t6, $t5 - pextlb $t6, $zero, $t5 - pextub $t5, $zero, $t5 - lq $t8, 0($a2) - lq $t9, 16($a2) - paddh $t6, $t6, $t8 - paddh $t5, $t5, $t9 - pcgth $t8, $t6, $zero - pcgth $t9, $t5, $zero - pceqh $v0, $t6, $zero - pceqh $t7, $t5, $zero - psrlh $t8, $t8, 15 - psrlh $t9, $t9, 15 - psrlh $v0, $v0, 15 - psrlh $t7, $t7, 15 - por $t8, $t8, $v0 - por $t9, $t9, $t7 - paddh $t6, $t6, $t8 - paddh $t5, $t5, $t9 - psrlh $t6, $t6, 1 - psrlh $t5, $t5, 1 - sq $t6, 0($a2) - sq $t5, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_chroma: - mtsab $a3, 0 -1: - ld $t5, 0($a1) - ld $t6, 64($a1) - addiu $v1, $v1, -1 - ld $t7, 384($a1) - ld $t8, 448($a1) - addu $a1, $a1, $t3 - pcpyld $t5, $t7, $t5 - pcpyld $t6, $t8, $t6 - qfsrv $t5, $t5, $t5 - qfsrv $t6, $t6, $t6 - pextlb $t5, $zero, $t5 - pextlb $t6, $zero, $t6 - lq $t0, 0($a2) - lq $t1, 128($a2) - paddh $t5, $t5, $t0 - paddh $t6, $t6, $t1 - pcgth $t0, $t5, $zero - pcgth $t1, $t6, $zero - pceqh $v0, $t5, $zero - pceqh $t9, $t6, $zero - psrlh $t0, $t0, 15 - psrlh $t1, $t1, 15 - psrlh $v0, $v0, 15 - psrlh $t9, $t9, 15 - por $t0, $t0, $v0 - por $t1, $t1, $t9 - paddh $t5, $t5, $t0 - paddh $t6, $t6, $t1 - psrlh $t5, $t5, 1 - psrlh $t6, $t6, 1 - sq $t5, 0($a2) - sq $t6, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_luma_X: - pnor $v0, $zero, $zero - psrlh $v0, $v0, 15 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - mtsab $a3, 0 - qfsrv $t7, $t6, $t5 - qfsrv $t8, $t5, $t6 - pextlb $t5, $zero, $t7 - pextub $t6, $zero, $t7 - addu $a1, $a1, $t3 - mtsab $zero, 1 - addiu $v1, $v1, -1 - qfsrv $t8, $t8, $t7 - pextlb $t7, $zero, $t8 - pextub $t8, $zero, $t8 - paddh $t5, $t5, $t7 - paddh $t6, $t6, $t8 - paddh $t5, $t5, $v0 - paddh $t6, $t6, $v0 - psrlh $t5, $t5, 1 - psrlh $t6, $t6, 1 - lq $t8, 0($a2) - lq $t9, 16($a2) - paddh $t5, $t5, $t8 - paddh $t6, $t6, $t9 - pcgth $t8, $t5, $zero - pceqh $t9, $t5, $zero - psrlh $t8, $t8, 15 - psrlh $t9, $t9, 15 - por $t8, $t8, $t9 - paddh $t5, $t5, $t8 - pcgth $t8, $t6, $zero - pceqh $t9, $t6, $zero - psrlh $t8, $t8, 15 - psrlh $t9, $t9, 15 - por $t8, $t8, $t9 - paddh $t6, $t6, $t8 - psrlh $t5, $t5, 1 - psrlh $t6, $t6, 1 - sq $t5, 0($a2) - sq $t6, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_chroma_X: - pnor $v0, $zero, $zero - psrlh $v0, $v0, 15 -1: - ld $t5, 0($a1) - ld $t6, 64($a1) - mtsab $a3, 0 - ld $t7, 384($a1) - ld $t8, 448($a1) - pcpyld $t5, $t7, $t5 - pcpyld $t6, $t8, $t6 - qfsrv $t5, $t5, $t5 - qfsrv $t6, $t6, $t6 - addiu $t9, $zero, 1 - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - mtsab $t9, 0 - qfsrv $t1, $t5, $t5 - qfsrv $t2, $t6, $t6 - pextlb $t5, $zero, $t5 - pextlb $t6, $zero, $t6 - pextlb $t1, $zero, $t1 - pextlb $t2, $zero, $t2 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - paddh $t5, $t5, $v0 - paddh $t6, $t6, $v0 - psrlh $t5, $t5, 1 - psrlh $t6, $t6, 1 - lq $t1, 0($a2) - lq $t2, 128($a2) - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - pcgth $t1, $t5, $zero - pcgth $t2, $t6, $zero - pceqh $t9, $t5, $zero - pceqh $a0, $t6, $zero - psrlh $t1, $t1, 15 - psrlh $t2, $t2, 15 - psrlh $t9, $t9, 15 - psrlh $a0, $a0, 15 - por $t1, $t1, $t9 - por $t2, $t2, $a0 - paddh $t5, $t5, $t1 - paddh $t6, $t6, $t2 - psrlh $t5, $t5, 1 - psrlh $t6, $t6, 1 - sq $t5, 0($a2) - sq $t6, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_luma_Y: - mtsab $a3, 0 - lq $t7, 0($a1) - lq $t8, 384($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t7, $t8, $t7 - pextub $t8, $zero, $t7 - pextlb $t7, $zero, $t7 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t5, $t6, $t5 - pextub $t6, $zero, $t5 - pextlb $t5, $zero, $t5 - paddh $v0, $t6, $t8 - pnor $t8, $zero, $zero - paddh $t9, $t5, $t7 - psrlh $t8, $t8, 15 - por $t7, $zero, $t5 - paddh $t9, $t9, $t8 - paddh $v0, $v0, $t8 - por $t8, $zero, $t6 - psrlh $t9, $t9, 1 - psrlh $v0, $v0, 1 - lq $t5, 0($a2) - lq $t6, 16($a2) - paddh $t9, $t9, $t5 - paddh $v0, $v0, $t6 - pcgth $t5, $t9, $zero - pceqh $t6, $t9, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $t9, $t9, $t5 - pcgth $t5, $v0, $zero - pceqh $t6, $v0, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $v0, $v0, $t5 - psrlh $t9, $t9, 1 - psrlh $v0, $v0, 1 - sq $t9, 0($a2) - sq $v0, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_chroma_Y: - mtsab $a3, 0 - ld $a0, 0($a1) - ld $a3, 64($a1) - ld $t0, 384($a1) - ld $t1, 448($a1) - pnor $v0, $zero, $zero - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - psrlh $v0, $v0, 15 - pcpyld $a0, $t0, $a0 - pcpyld $a3, $t1, $a3 - qfsrv $a0, $a0, $a0 - qfsrv $a3, $a3, $a3 - pextlb $a0, $zero, $a0 - pextlb $a3, $zero, $a3 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - ld $t5, 0($a1) - ld $t6, 64($a1) - addiu $v1, $v1, -1 - ld $t7, 384($a1) - ld $t8, 448($a1) - addu $a1, $a1, $t3 - pcpyld $t5, $t7, $t5 - pcpyld $t6, $t8, $t6 - qfsrv $t5, $t5, $t5 - qfsrv $t6, $t6, $t6 - pextlb $t5, $zero, $t5 - pextlb $t6, $zero, $t6 - paddh $t1, $t5, $a0 - paddh $t2, $t6, $a3 - por $a0, $zero, $t5 - por $a3, $zero, $t6 - paddh $t1, $t1, $v0 - paddh $t2, $t2, $v0 - psrlh $t1, $t1, 1 - psrlh $t2, $t2, 1 - lq $t5, 0($a2) - lq $t6, 128($a2) - paddh $t1, $t1, $t5 - paddh $t2, $t2, $t6 - pcgth $t5, $t1, $zero - pceqh $t6, $t1, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $t1, $t1, $t5 - pcgth $t5, $t2, $zero - pceqh $t6, $t2, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $t2, $t2, $t5 - psrlh $t1, $t1, 1 - psrlh $t2, $t2, 1 - sq $t1, 0($a2) - sq $t2, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_luma_XY: - mtsab $a3, 0 - lq $v0, 0($a1) - lq $t7, 384($a1) - addu $a1, $a1, $t3 - qfsrv $t8, $t7, $v0 - qfsrv $t9, $v0, $t7 - addiu $v1, $v1, -1 - pextlb $v0, $zero, $t8 - pextub $t7, $zero, $t8 - mtsab $zero, 1 - qfsrv $t9, $t9, $t8 - pextlb $t8, $zero, $t9 - pextub $t9, $zero, $t9 - paddh $v0, $v0, $t8 - paddh $t7, $t7, $t9 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - lq $t5, 0($a1) - lq $t6, 384($a1) - mtsab $a3, 0 - addu $a1, $a1, $t3 - qfsrv $t8, $t6, $t5 - qfsrv $t9, $t5, $t6 - addiu $v1, $v1, -1 - pextlb $t5, $zero, $t8 - pextub $t6, $zero, $t8 - mtsab $zero, 1 - qfsrv $t9, $t9, $t8 - pextlb $t8, $zero, $t9 - pextub $t9, $zero, $t9 - paddh $t5, $t5, $t8 - paddh $t6, $t6, $t9 - paddh $t8, $v0, $t5 - paddh $t9, $t7, $t6 - por $v0, $zero, $t5 - pnor $t5, $zero, $zero - por $t7, $zero, $t6 - psrlh $t5, $t5, 15 - psllh $t5, $t5, 1 - paddh $t8, $t8, $t5 - paddh $t9, $t9, $t5 - psrlh $t8, $t8, 2 - psrlh $t9, $t9, 2 - lq $t5, 0($a2) - lq $t6, 16($a2) - paddh $t8, $t8, $t5 - paddh $t9, $t9, $t6 - pcgth $t5, $t8, $zero - pceqh $t6, $t8, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $t8, $t8, $t5 - pcgth $t5, $t9, $zero - pceqh $t6, $t9, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $t9, $t9, $t5 - psrlh $t8, $t8, 1 - psrlh $t9, $t9, 1 - sq $t8, 0($a2) - sq $t9, 16($a2) - bgtz $v1, 1b - addiu $a2, $a2, 32 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 512 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - -_MPEG_avg_chroma_XY: - mtsab $a3, 0 - pnor $t9, $zero, $zero - ld $a0, 0($a1) - ld $v0, 64($a1) - mtsab $zero, 1 - ld $t0, 384($a1) - ld $t1, 448($a1) - pcpyld $a0, $t0, $a0 - pcpyld $v0, $t1, $v0 - qfsrv $a0, $a0, $a0 - qfsrv $v0, $v0, $v0 - psrlh $t9, $t9, 15 - psllh $t9, $t9, 1 - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - qfsrv $t0, $a0, $a0 - qfsrv $t1, $v0, $v0 - pextlb $a0, $zero, $a0 - pextlb $v0, $zero, $v0 - pextlb $t0, $zero, $t0 - pextlb $t1, $zero, $t1 - paddh $a0, $a0, $t0 - paddh $t0, $v0, $t1 - beq $v1, $zero, 2f - addiu $at, $at, 1 -1: - ld $t5, 0($a1) - ld $t7, 64($a1) - mtsab $a3, 0 - ld $t6, 384($a1) - ld $t8, 448($a1) - pcpyld $t5, $t6, $t5 - pcpyld $t7, $t8, $t7 - qfsrv $t5, $t5, $t5 - qfsrv $t7, $t7, $t7 - addiu $v0, $zero, 1 - addu $a1, $a1, $t3 - addiu $v1, $v1, -1 - mtsab $v0, 0 - qfsrv $t6, $t5, $t5 - qfsrv $t8, $t7, $t7 - pextlb $t5, $zero, $t5 - pextlb $t7, $zero, $t7 - pextlb $t6, $zero, $t6 - pextlb $t8, $zero, $t8 - paddh $t5, $t5, $t6 - paddh $t6, $t7, $t8 - paddh $t7, $a0, $t5 - paddh $t8, $t0, $t6 - por $a0, $zero, $t5 - por $t0, $zero, $t6 - paddh $t7, $t7, $t9 - paddh $t8, $t8, $t9 - psrlh $t7, $t7, 2 - psrlh $t8, $t8, 2 - lq $t5, 0($a2) - lq $t6, 128($a2) - paddh $t7, $t7, $t5 - paddh $t8, $t8, $t6 - pcgth $t5, $t7, $zero - pceqh $t6, $t7, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $t7, $t7, $t5 - pcgth $t5, $t8, $zero - pceqh $t6, $t8, $zero - psrlh $t5, $t5, 15 - psrlh $t6, $t6, 15 - por $t5, $t5, $t6 - paddh $t8, $t8, $t5 - psrlh $t7, $t7, 1 - psrlh $t8, $t8, 1 - sq $t7, 0($a2) - sq $t8, 128($a2) - bgtz $v1, 1b - addiu $a2, $a2, 16 -2: - addu $v1, $zero, $at - addiu $a1, $a1, 704 - bgtzl $v1, 1b - addu $at, $zero, $zero - jr $ra - nop - -.set pop From df124d44fb36ad4b6d8f073e06ab21786f734909 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Mon, 27 Jan 2025 18:05:18 -0600 Subject: [PATCH 2/4] cleanup: [iop/kernel] remove unused s files --- iop/kernel/Makefile | 3 - iop/kernel/src/cdvdman.s | 154 -------------------------- iop/kernel/src/heaplib.s | 54 ---------- iop/kernel/src/intrman.s | 76 ------------- iop/kernel/src/ioman.s | 118 -------------------- iop/kernel/src/libsd.s | 162 ---------------------------- iop/kernel/src/loadcore.s | 68 ------------ iop/kernel/src/modload.s | 74 ------------- iop/kernel/src/secrman.s | 112 ------------------- iop/kernel/src/sifcmd.s | 161 --------------------------- iop/kernel/src/sifman.s | 74 ------------- iop/kernel/src/sio2man.S | 61 ----------- iop/kernel/src/stdio.s | 35 ------ iop/kernel/src/sysclib.s | 221 -------------------------------------- iop/kernel/src/sysmem.s | 74 ------------- iop/kernel/src/thbase.s | 170 ----------------------------- iop/kernel/src/thevent.s | 71 ------------ iop/kernel/src/thsemap.s | 72 ------------- iop/kernel/src/timrman.S | 50 --------- iop/kernel/src/usbd.s | 114 -------------------- iop/kernel/src/vblank.s | 56 ---------- 21 files changed, 1980 deletions(-) delete mode 100644 iop/kernel/src/cdvdman.s delete mode 100644 iop/kernel/src/heaplib.s delete mode 100644 iop/kernel/src/intrman.s delete mode 100644 iop/kernel/src/ioman.s delete mode 100644 iop/kernel/src/libsd.s delete mode 100644 iop/kernel/src/loadcore.s delete mode 100644 iop/kernel/src/modload.s delete mode 100644 iop/kernel/src/secrman.s delete mode 100644 iop/kernel/src/sifcmd.s delete mode 100644 iop/kernel/src/sifman.s delete mode 100644 iop/kernel/src/sio2man.S delete mode 100644 iop/kernel/src/stdio.s delete mode 100644 iop/kernel/src/sysclib.s delete mode 100644 iop/kernel/src/sysmem.s delete mode 100644 iop/kernel/src/thbase.s delete mode 100644 iop/kernel/src/thevent.s delete mode 100644 iop/kernel/src/thsemap.s delete mode 100644 iop/kernel/src/timrman.S delete mode 100644 iop/kernel/src/usbd.s delete mode 100644 iop/kernel/src/vblank.s diff --git a/iop/kernel/Makefile b/iop/kernel/Makefile index 593a93d6d06..b838226bff2 100644 --- a/iop/kernel/Makefile +++ b/iop/kernel/Makefile @@ -6,9 +6,6 @@ # Licenced under Academic Free License version 2.0 # Review ps2sdk README & LICENSE files for further details. -# TODO: remove the library because it's deprecated. -# IOP_OBJS = cdvdman.o heaplib.o intrman.o ioman.o libsd.o loadcore.o modload.o secrman.o sifcmd.o sifman.o sio2man.o stdio.o sysclib.o sysmem.o thbase.o thevent.o thsemap.o timrman.o usbd.o vblank.o - include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/iop/Rules.lib.make include $(PS2SDKSRC)/iop/Rules.make diff --git a/iop/kernel/src/cdvdman.s b/iop/kernel/src/cdvdman.s deleted file mode 100644 index e2370a34f1a..00000000000 --- a/iop/kernel/src/cdvdman.s +++ /dev/null @@ -1,154 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# CDVD Manager Functions. -*/ - - .text - .set noreorder - - -/* ############################### CDVDMAN STUB ####### */ -/* # Added by Sjeep, 24th June 2002 # */ - -.local cdvdman_stub -cdvdman_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "cdvdman\0" - .align 2 - - .globl CdInit # 004 -CdInit: - j $31 - li $0, 4 - - .globl CdStandby # 005 -CdStandby: - j $31 - li $0, 5 - - .globl CdRead # 006 -CdRead: - j $31 - li $0, 6 - - .globl CdSeek # 007 -CdSeek: - j $31 - li $0, 7 - - .globl CdGetError # 008 -CdGetError: - j $31 - li $0, 8 - - .globl CdGetToc # 009 -CdGetToc: - j $31 - li $0, 9 - - .globl CdSearchFile # 010 -CdSearchFile: - j $31 - li $0, 10 - - .globl CdSync # 011 -CdSync: - j $31 - li $0, 11 - - .globl CdGetDiskType # 012 -CdGetDiskType: - j $31 - li $0, 12 - - .globl CdDiskReady # 013 -CdDiskReady: - j $31 - li $0, 13 - - .globl CdTrayReq # 014 -CdTrayReq: - j $31 - li $0, 14 - - .globl CdStop # 015 -CdStop: - j $31 - li $0, 15 - - .globl CdPosToInt # 016 -CdPosToInt: - j $31 - li $0, 16 - - .globl CdIntToPos # 017 -CdIntToPos: - j $31 - li $0, 17 - - .globl CdCheckCmd # 021 -CdCheckCmd: - j $31 - li $0, 21 - - .globl CdReadILinkID # 022 -CdReadILinkID: - j $31 - li $0, 22 - - .globl CdReadClock # 024 -CdReadClock: - j $31 - li $0, 24 - - .globl CdStatus # 028 -CdStatus: - j $31 - li $0, 28 - - .globl CdCallback # 037 -CdCallback: - j $31 - li $0, 37 - - .globl CdPause # 038 -CdPause: - j #31 - li $0, 38 - - .globl CdBreak # 039 -CdBreak: - j $31 - li $0, 39 - - .globl CdGetReadPos # 044 -CdGetReadPos: - j $31 - li $0, 44 - - .globl CdRC # 051 -CdRC: - j $31 - li $0, 51 - - .globl CdReadChain # 066 -CdReadChain: - j $31 - li $0, 66 - - .globl CdMmode -CdMmode: - j $31 - li $0, 75 - - .word 0 - .word 0 diff --git a/iop/kernel/src/heaplib.s b/iop/kernel/src/heaplib.s deleted file mode 100644 index 42e2f518600..00000000000 --- a/iop/kernel/src/heaplib.s +++ /dev/null @@ -1,54 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Heap library function imports. -*/ - - .text - .set noreorder - - -/* ############################### SYSMEM STUB ######## */ - .local sysmem_stub -sysmem_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "heaplib\0" - .align 2 - - .globl CreateHeap # 004 -CreateHeap: - j $31 - li $0, 4 - - .globl DestroyHeap # 005 -DestroyHeap: - j $31 - li $0, 5 - - .globl HeapMalloc # 006 -HeapMalloc: - j $31 - li $0, 6 - - .globl HeapFree # 007 -HeapFree: - j $31 - li $0, 7 - - .globl HeapSize # 008 -HeapSize: - j $31 - li $0, 8 - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/intrman.s b/iop/kernel/src/intrman.s deleted file mode 100644 index 8f2001e73a2..00000000000 --- a/iop/kernel/src/intrman.s +++ /dev/null @@ -1,76 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Interrupt Manager Functions. -*/ - - .text - .set noreorder - - -/* ############################### INTRMAN STUB ####### */ -/* # Added by Oobles, 5th March 2002 # */ - - .local intrman_stub -intrman_stub: - .word 0x41e00000 - .word 0 - .word 0x00000102 - .ascii "intrman\0" - .align 2 - - .globl RegisterIntrHandler # 004 -RegisterIntrHandler: - j $31 - li $0, 4 - - .globl ReleaseIntrHandler # 005 -ReleaseIntrHandler: - j $31 - li $0, 5 - - .globl EnableIntr # 006 -EnableIntr: - j $31 - li $0, 6 - - .globl DisableIntr # 007 -DisableIntr: - j $31 - li $0, 7 - - .globl CpuDisableIntr # 008 -CpuDisableIntr: - j $31 - li $0, 8 - - .globl CpuEnableIntr # 009 -CpuEnableIntr: - j $31 - li $0, 9 - - .globl CpuSuspendIntr # 0x11 -CpuSuspendIntr: - j $31 - li $0, 0x11 - - .globl CpuResumeIntr # 0x12 -CpuResumeIntr: - j $31 - li $0, 0x12 - - .globl QueryIntrContext # 0x17 -QueryIntrContext: - j $31 - li $0, 0x17 - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/ioman.s b/iop/kernel/src/ioman.s deleted file mode 100644 index 31dd9ccabd6..00000000000 --- a/iop/kernel/src/ioman.s +++ /dev/null @@ -1,118 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# IOP Basic libraries. -*/ - - .text - .set noreorder - - -/* ############################### IOMAN STUB ######## */ - .local ioman_stub -ioman_stub: - .word 0x41e00000 - .word 0 - .word 0x00000102 - .ascii "ioman\0\0\0" - .align 2 - - .globl open # 004 -open: - j $31 - li $0, 4 - - .globl close # 005 -close: - j $31 - li $0, 5 - - .globl read # 006 -read: - j $31 - li $0, 6 - - .globl write # 007 -write: - j $31 - li $0, 7 - - .globl lseek # 008 -lseek: - j $31 - li $0, 8 - - .globl ioctl -ioctl: - j $31 - li $0, 9 - - .globl remove -remove: - j $31 - li $0, 10 - - .globl mkdir -mkdir: - j $31 - li $0, 11 - - .globl rmdir -rmdir: - j $31 - li $0, 12 - - .globl dopen -dopen: - j $31 - li $0, 13 - - .globl dclose -dclose: - j $31 - li $0, 14 - - .globl dread -dread: - j $31 - li $0, 15 - - .globl getstat -getstat: - j $31 - li $0, 16 - - .globl chstat -chstat: - j $31 - li $0, 17 - - .globl format -format: - j $31 - li $0, 18 - - .globl FILEIO_add # 020 - .globl AddDrv -FILEIO_add: -AddDrv: - j $31 - li $0, 20 - - .globl FILEIO_del # 021 - .globl DelDrv -FILEIO_del: -DelDrv: - j $31 - li $0, 21 - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/libsd.s b/iop/kernel/src/libsd.s deleted file mode 100644 index 92c6960b1ea..00000000000 --- a/iop/kernel/src/libsd.s +++ /dev/null @@ -1,162 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Sound Library -*/ - - .text - .set noreorder - - -/* ############################### LIBSD STUB ######### */ -/* # Added by Oobles, 7th March 2002 # */ - - .local libsd_stub -libsd_stub: - .word 0x41e00000 - .word 0 - .word 0x00000104 - .ascii "libsd\0\0" - .align 2 - -/* Added by Julian Tyler (lovely) */ - .globl SdQuit # 0x02 -SdQuit: - j $31 - li $0, 0x02 - - .globl SdInit # 0x04 -SdInit: - j $31 - li $0, 0x04 - - .globl SdSetParam # 0x05 -SdSetParam: - j $31 - li $0, 0x05 - - .globl SdGetParam # 0x06 -SdGetParam: - j $31 - li $0, 0x06 - - .globl SdSetSwitch # 0x07 -SdSetSwitch: - j $31 - li $0, 0x07 - -/* Added by Julian Tyler (lovely) */ - .globl SdGetSwitch # 0x08 -SdGetSwitch: - j $31 - li $0, 0x08 - - .globl SdSetAddr # 0x09 -SdSetAddr: - j $31 - li $0, 0x09 - - .globl SdGetAddr # 0x0a -SdGetAddr: - j $31 - li $0, 0x0a - - .globl SdSetCoreAttr # 0x0b -SdSetCoreAttr: - j $31 - li $0, 0x0b - -/* Added by Julian Tyler (lovely) 013-016 */ - .globl SdGetCoreAttr # 012 -SdGetCoreAttr: - j $31 - li $0, 0x0c - - .globl SdNote2Pitch # 013 -SdNote2Pitch: - j $31 - li $0, 0x0d - - .globl SdPitch2Note # 014 -SdPitch2Note: - j $31 - li $0, 0x0e - - .globl SdProcBatch # 015 -SdProcBatch: - j $31 - li $0, 0x0f - - .globl SdProcBatchEx # 016 -SdProcBatchEx: - j $31 - li $0, 0x10 - - .globl SdVoiceTrans # 0x11 -SdVoiceTrans: - j $31 - li $0, 0x11 - -/* Added by Julian Tyler (lovely) 018-022 */ - - .globl SdBlockTrans # 018 -SdBlockTrans: - j $31 - li $0, 0x12 - - .globl SdVoiceTransStatus # 019 -SdVoiceTransStatus: - j $31 - li $0, 0x13 - - .globl SdBlockTransStatus # 020 -SdBlockTransStatus: - j $31 - li $0, 0x14 - - .globl SdSetTransCallback # 021 -SdSetTransCallback: - j $31 - li $0, 0x15 - - .globl SdSetIRQCallback # 022 -SdSetIRQCallback: - j $31 - li $0, 0x16 - - .globl SdSetEffectAttr # 0x17 -SdSetEffectAttr: - j $31 - li $0, 0x17 - -/* Added by Julian Tyler (lovely) 024-025 */ - - .globl SdGetEffectAttr # 024 -SdGetEffectAttr: - j $31 - li $0, 0x18 - - .globl SdClearEffectWorkArea # 025 -SdClearEffectWorkArea: - j $31 - li $0, 0x19 - - .globl SdSetTransIntrHandler # 0x1a -SdSetTransIntrHandler: - j $31 - li $0, 0x1a - - .globl SdSetSpu2IntrHandler # 0x1b -SdSetSpu2IntrHandler: - j $31 - li $0, 0x1b - - .word 0 - .word 0 - diff --git a/iop/kernel/src/loadcore.s b/iop/kernel/src/loadcore.s deleted file mode 100644 index 02f3bc77012..00000000000 --- a/iop/kernel/src/loadcore.s +++ /dev/null @@ -1,68 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Core IOP Functions. -*/ - - .text - .set noreorder - - - -/* ############################### LOADCORE STUB ###### */ -/* # Added by Oobles, 5th March 2002 # */ - - .local loadcore_stub -loadcore_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "loadcore" - .align 2 - - .globl GetLibraryEntryTable # 0x03 -GetLibraryEntryTable: - j $31 - li $0, 3 - - .globl FlushIcache # 0x05 -FlushIcache: - j $31 - li $0, 4 - - .globl FlushDcache # 0x05 -FlushDcache: - j $31 - li $0, 5 - - .global RegisterLibraryEntries # 0x06 -RegisterLibraryEntries: - j $31 - li $0, 6 - - .global ReleaseLibraryEntries -ReleaseLibraryEntries: - j $31 - li $0, 7 - - .global QueryLibraryEntryTable -QueryLibraryEntryTable: - j $31 - li $0, 11 - - .globl QueryBootMode # 0x0c -QueryBootMode: - j $31 - li $0, 0x0c - - .word 0 - .word 0 - - - diff --git a/iop/kernel/src/modload.s b/iop/kernel/src/modload.s deleted file mode 100644 index 4cfa37a2712..00000000000 --- a/iop/kernel/src/modload.s +++ /dev/null @@ -1,74 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Module Manager Functions. -*/ - - .text - .set noreorder - - -/* ############################### MODLOAD STUB ####### */ -/* # Added by Sjeep, 28th March 2002 # */ - - .local modload_stub -modload_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "modload\0" - .align 2 - - .globl ReBootStart # 004 -ReBootStart: - jr $31 - li $0, 0x04 - - .globl LoadModuleAddress # 005 -LoadModuleAddress: - jr $31 - li $0, 0x05 - - .globl LoadModule # 006 -LoadModule: - jr $31 - li $0, 0x06 - - .globl LoadStartModule # 007 -LoadStartModule: - jr $31 - li $0, 0x07 - - .globl StartModule # 008 -StartModule: - jr $31 - li $0, 0x08 - - .globl LoadModuleBufferAddress # 009 -LoadModuleBufferAddress: - jr $31 - li $0, 0x09 - - .globl LoadModuleBuffer # 010 -LoadModuleBuffer: - jr $31 - li $0, 0x0A - - .globl SetSecrmanCallbacks # 012 -SetSecrmanCallbacks: - jr $31 - li $0, 0x0C - - .globl SetCheckKelfPathCallback # 013 -SetCheckKelfPathCallback: - jr $31 - li $0, 0x0D - - .word 0 - .word 0 diff --git a/iop/kernel/src/secrman.s b/iop/kernel/src/secrman.s deleted file mode 100644 index f69c6a07258..00000000000 --- a/iop/kernel/src/secrman.s +++ /dev/null @@ -1,112 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# secrman Module Functions. -*/ - - .text - .set noreorder - - -/* ############################### SECRMAN STUB ###### */ -/* # Added by jimmikaelkael, 16th january 2009 # */ - - .local secrman_stub -secrman_stub: - .word 0x41e00000 - .word 0x00000000 - .word 0x00000103 - .ascii "secrman\0" - .align 2 - - .globl SetMcCommandCallback # 004 -SetMcCommandCallback: - jr $31 - li $0, 0x04 - - .globl SetMcDevIDCallback # 005 -SetMcDevIDCallback: - jr $31 - li $0, 0x05 - - .globl SecrAuthCard # 006 -SecrAuthCard: - jr $31 - li $0, 0x06 - - .globl SecrResetAuthCard # 007 -SecrResetAuthCard: - jr $31 - li $0, 0x07 - - .globl SecrCardBootHeader # 008 -SecrCardBootHeader: - jr $31 - li $0, 0x08 - - .globl SecrCardBootBlock # 009 -SecrCardBootBlock: - jr $31 - li $0, 0x09 - - .globl SecrCardBootFile # 010 -SecrCardBootFile: - jr $31 - li $0, 0x0a - - .globl SecrDiskBootHeader # 011 -SecrDiskBootHeader: - jr $31 - li $0, 0x0b - - .globl SecrDiskBootBlock # 012 -SecrDiskBootBlock: - jr $31 - li $0, 0x0c - - .globl SecrDiskBootFile # 013 -SecrDiskBootFile: - jr $31 - li $0, 0x0d - - .globl SecrDownloadHeader # 014 -SecrDownloadHeader: - jr $31 - li $0, 0x0e - - .globl SecrDownloadBlock # 015 -SecrDownloadBlock: - jr $31 - li $0, 0x0f - - .globl SecrDownloadFile # 016 -SecrDownloadFile: - jr $31 - li $0, 0x10 - - .globl SecrDownloadGetKbit # 017 -SecrDownloadGetKbit: - jr $31 - li $0, 0x11 - - .globl SecrDownloadGetKc # 018 -SecrDownloadGetKc: - jr $31 - li $0, 0x12 - - .globl SecrDownloadGetICVPS2 # 019 -SecrDownloadGetICVPS2: - jr $31 - li $0, 0x13 - - .word 0 - .word 0 - - - diff --git a/iop/kernel/src/sifcmd.s b/iop/kernel/src/sifcmd.s deleted file mode 100644 index 5c33c6be7b4..00000000000 --- a/iop/kernel/src/sifcmd.s +++ /dev/null @@ -1,161 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Serial Interface Command Functions. -*/ - - .text - .set noreorder - - -/* ############################### SIFCMD STUB ######## */ -/* # Added by Oobles, 5th March 2002 # */ - - .local sifcmd_stub -sifcmd_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "sifcmd\0\0" - .align 2 - - .globl sceSifInitCmd # 0x04 -sceSifInitCmd: - j $31 - li $0, 0x04 - - .globl sceSifExitCmd # 0x05 -sceSifExitCmd: - j $31 - li $0, 0x05 - - .globl sceSifGetSreg # 0x06 -sceSifGetSreg: - j $31 - li $0, 0x06 - - .globl sceSifSetSreg # 0x07 -sceSifSetSreg: - j $31 - li $0, 0x07 - - .globl sceSifSetCmdBuffer # 0x08 -sceSifSetCmdBuffer: - j $31 - li $0, 0x08 - - .globl sceSifSetSysCmdBuffer # 0x09 -sceSifSetSysCmdBuffer: - j $31 - li $0, 0x09 - - .globl sceSifAddCmdHandler # 0x0a -sceSifAddCmdHandler: - j $31 - li $0, 0x0a - - .globl sceSifRemoveCmdHandler # 0x0b -sceSifRemoveCmdHandler: - j $31 - li $0, 0x0b - - .globl sceSifSendCmd # 0x0c -sceSifSendCmd: - j $31 - li $0, 0x0c - - .globl isceSifSendCmd # 0x0d -isceSifSendCmd: - j $31 - li $0, 0x0d - - .globl sceSifInitRpc # 0x0E -sceSifInitRpc: - j $31 - li $0, 0x0E - - .globl sceSifBindRpc # 0x0F -sceSifBindRpc: - j $31 - li $0, 0x0F - - .globl sceSifCallRpc # 0x10 -sceSifCallRpc: - j $31 - li $0, 0x10 - - .globl sceSifRegisterRpc # 0x11 -sceSifRegisterRpc: - j $31 - li $0, 0x11 - - .globl sceSifCheckStatRpc # 0x12 -sceSifCheckStatRpc: - j $31 - li $0, 0x12 - - .globl sceSifSetRpcQueue # 0x13 -sceSifSetRpcQueue: - j $31 - li $0, 0x13 - - .globl sceSifGetNextRequest # 0x14 -sceSifGetNextRequest: - j $31 - li $0, 0x14 - - .globl sceSifExecRequest # 0x15 -sceSifExecRequest: - j $31 - li $0, 0x15 - - .globl sceSifRpcLoop # 0x16 -sceSifRpcLoop: - j $31 - li $0, 0x16 - - .globl sceSifGetOtherData # 0x17 -sceSifGetOtherData: - j $31 - li $0, 0x17 - - .globl sceSifRemoveRpc # 0x18 -sceSifRemoveRpc: - j $31 - li $0, 0x18 - - .globl sceSifRemoveRpcQueue # 0x19 -sceSifRemoveRpcQueue: - j $31 - li $0, 0x19 - - .globl sceSifSetSif1CB # 0x1A -sceSifSetSif1CB: - j $31 - li $0, 0x1A - - .globl sceSifClearSif1CB # 0x1B -sceSifClearSif1CB: - j $31 - li $0, 0x1B - - .globl sceSifSendCmdIntr # 0x20 -sceSifSendCmdIntr: - j $31 - li $0, 0x20 - - .globl isceSifSendCmdIntr # 0x21 -isceSifSendCmdIntr: - j $31 - li $0, 0x21 - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/sifman.s b/iop/kernel/src/sifman.s deleted file mode 100644 index 580ae2b99ab..00000000000 --- a/iop/kernel/src/sifman.s +++ /dev/null @@ -1,74 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Serial Interface Manager Functions. -*/ - - .text - .set noreorder - - -/* ############################### SIFMAN STUB ######## */ -/* # Added by Oobles, 7th March 2002 # */ - - .local sifman_stub -sifman_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "sifman\0\0" - .align 2 - - .globl sceSifInit # 0x05 -sceSifInit: - j $31 - li $0, 0x05 - - .globl sceSifSetDChain # 0x06 -sceSifSetDChain: - j $31 - li $0, 0x06 - - .globl sceSifSetDma # 0x07 -sceSifSetDma: - j $31 - li $0, 0x07 - - .globl sceSifDmaStat # 0x08 -sceSifDmaStat: - j $31 - li $0, 0x08 - - .globl sceSifGetSMFlag # 0x17 -sceSifGetSMFlag: - j $31 - li $0, 0x17 - - .globl sceSifSetSMFlag # 0x18 -sceSifSetSMFlag: - j $31 - li $0, 0x18 - - .globl sceSifIntrMain # 0x1c -sceSifIntrMain: - j $31 - li $0, 0x1c - - .globl sceSifCheckInit # 0x1d -sceSifCheckInit: - j $31 - li $0, 0x1d - - .globl sceSifSetDmaIntr # 0x20 -sceSifSetDmaIntr: - j $31 - li $0, 0x20 - - .word 0 - .word 0 diff --git a/iop/kernel/src/sio2man.S b/iop/kernel/src/sio2man.S deleted file mode 100644 index 2992a16ee77..00000000000 --- a/iop/kernel/src/sio2man.S +++ /dev/null @@ -1,61 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Serial Input Output 2 Manager Functions. -*/ - -#define DECLARE_EXPORT(name, n) \ - .globl name; \ -name: \ - j $31; \ - li $0, n - - .text - .set noreorder - - -/* ############################## SIO2MAN STUB ######## */ -/* # Added by linuzappz, 6th October 2004 # */ - - .local sio2man_stub -sio2man_stub: - .word 0x41e00000 - .word 0 - .word 0x00000102 - .ascii "sio2man\0" - .align 2 - - DECLARE_EXPORT(sio2_ctrl_set, 4) - DECLARE_EXPORT(sio2_ctrl_get, 5) - DECLARE_EXPORT(sio2_stat6c_get, 6) - DECLARE_EXPORT(sio2_portN_ctrl1_set, 7) - DECLARE_EXPORT(sio2_portN_ctrl1_get, 8) - DECLARE_EXPORT(sio2_portN_ctrl2_set, 9) - DECLARE_EXPORT(sio2_portN_ctrl2_get, 10) - DECLARE_EXPORT(sio2_stat70_get, 11) - DECLARE_EXPORT(sio2_regN_set, 12) - DECLARE_EXPORT(sio2_regN_get, 13) - DECLARE_EXPORT(sio2_stat74_get, 14) - DECLARE_EXPORT(sio2_unkn78_set, 15) - DECLARE_EXPORT(sio2_unkn78_get, 16) - DECLARE_EXPORT(sio2_unkn7c_set, 17) - DECLARE_EXPORT(sio2_unkn7c_get, 18) - DECLARE_EXPORT(sio2_data_out, 19) - DECLARE_EXPORT(sio2_data_in, 20) - DECLARE_EXPORT(sio2_stat_set, 21) - DECLARE_EXPORT(sio2_stat_get, 22) - DECLARE_EXPORT(sio2_pad_transfer_init, 23) - DECLARE_EXPORT(sio2_mc_transfer_init, 24) - DECLARE_EXPORT(sio2_transfer, 25) - DECLARE_EXPORT(sio2_transfer_reset, 26) - DECLARE_EXPORT(sio2_mtap_transfer_init, 48) - - .word 0 - .word 0 - diff --git a/iop/kernel/src/stdio.s b/iop/kernel/src/stdio.s deleted file mode 100644 index 7277a34670c..00000000000 --- a/iop/kernel/src/stdio.s +++ /dev/null @@ -1,35 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Stdio Import Library -*/ - - .text - .set noreorder - - -/* ############################### STDIO STUB ######## */ - .local stdio_stub -stdio_stub: - .word 0x41e00000 - .word 0 - .word 0x00000102 - .ascii "stdio\0\0\0" - .align 2 - - .globl printf # 004 - -printf: - j $31 - li $0, 4 - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/sysclib.s b/iop/kernel/src/sysclib.s deleted file mode 100644 index 89d4cc64416..00000000000 --- a/iop/kernel/src/sysclib.s +++ /dev/null @@ -1,221 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# C Library Functions. -*/ - - .text - .set noreorder - - -/* ############################### SYSCLIB STUB ####### */ -/* # Added by Oobles, 5th March 2002 # */ - - .local sysclib_stub -sysclib_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "sysclib\0" - .align 2 - - .globl setjmp # 0x04 -setjmp: - j $31 - li $0, 0x04 - - .globl longjmp # 0x05 -longjmp: - j $31 - li $0, 0x05 - - .globl toupper # 0x06 -toupper: - j $31 - li $0, 0x06 - - .globl tolower # 0x07 -tolower: - j $31 - li $0, 0x07 - - .globl look_ctype_table # 0x08 -look_ctype_table: - j $31 - li $0, 0x08 - - .globl get_ctype_table # 0x09 -get_ctype_table: - j $31 - li $0, 0x09 - - .globl memchr # 0x0A -memchr: - j $31 - li $0, 0x0A - - .globl memcmp # 0x0B -memcmp: - j $31 - li $0, 0x0B - - .globl memcpy # 0x0C -memcpy: - j $31 - li $0, 0x0C - - .globl memmove # 0x0D -memmove: - j $31 - li $0, 0x0D - - .globl memset # 0x0E -memset: - j $31 - li $0, 0x0E - - .globl bcmp # 0x0F -bcmp: - j $31 - li $0, 0x0F - - .globl bcopy # 0x10 -bcopy: - j $31 - li $0, 0x10 - - .globl bzero # 0x11 -bzero: - j $31 - li $0, 0x11 - - .globl prnt # 0x12 -prnt: - j $31 - li $0, 0x12 - - .globl sprintf # 0x013 -sprintf: - j $31 - li $0, 0x13 - - .globl strcat # 0x14 -strcat: - j $31 - li $0, 0x14 - - .globl strchr # 0x15 -strchr: - j $31 - li $0, 0x15 - - .globl strcmp # 0x16 -strcmp: - j $31 - li $0, 0x16 - - .globl strcpy # 0x17 -strcpy: - j $31 - li $0, 0x17 - - .globl strcspn # 0x18 -strcspn: - j $31 - li $0, 0x18 - - .globl index # 0x19 -index: - j $31 - li $0, 0x19 - - .globl rindex # 0x1A -rindex: - j $31 - li $0, 0x1A - - .globl strlen # 0x1b -strlen: - j $31 - li $0, 0x1b - - .globl strncat # 0x1c -strncat: - j $31 - li $0, 0x1C - - .globl strncmp # 0x1d -strncmp: - j $31 - li $0, 0x1d - - .globl strncpy # 0x1E -strncpy: - j $31 - li $0, 0x1E - - .globl strpbrk # 0x1F -strpbrk: - j $31 - li $0, 0x1F - - .globl strrchr # 0x20 -strrchr: - j $31 - li $0, 0x20 - - .globl strspn # 0x21 -strspn: - j $31 - li $0, 0x21 - - .globl strstr # 0x22 -strstr: - j $31 - li $0, 0x22 - - .globl strtok # 0x23 -strtok: - j $31 - li $0, 0x23 - - .globl strtol # 0x24 -strtol: - j $31 - li $0, 0x24 - - .globl atob # 0x25 -atob: - j $31 - li $0, 0x25 - - .globl strtoul # 0x26 -strtoul: - j $31 - li $0, 0x26 - - .globl wmemcopy # 0x28 -wmemcopy: - j $31 - li $0, 0x28 - - .globl wmemset # 0x29 -wmemset: - j $31 - li $0, 0x29 - - .globl vsprintf # 0x2A -vsprintf: - j $31 - li $0, 0x2A - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/sysmem.s b/iop/kernel/src/sysmem.s deleted file mode 100644 index 739f9ae09d1..00000000000 --- a/iop/kernel/src/sysmem.s +++ /dev/null @@ -1,74 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Memory Function import list. -*/ - - .text - .set noreorder - - -/* ############################### SYSMEM STUB ######## */ - .local sysmem_stub -sysmem_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "sysmem\0\0" - .align 2 - - .globl AllocSysMemory # 004 -AllocSysMemory: - j $31 - li $0, 0x04 - - .globl FreeSysMemory # 005 -FreeSysMemory: - j $31 - li $0, 0x05 - - .globl QueryMemSize # 006 -QueryMemSize: - j $31 - li $0, 0x06 - - .globl QueryMaxFreeMemSize # 007 -QueryMaxFreeMemSize: - j $31 - li $0, 0x07 - - .globl QueryTotalFreeMemSize # 008 -QueryTotalFreeMemSize: - j $31 - li $0, 0x08 - - .globl QueryBlockTopAddress # 009 -QueryBlockTopAddress: - j $31 - li $0, 0x09 - - .globl QueryBlockSize # 00A -QueryBlockSize: - j $31 - li $0, 0x0A - - .globl Kprintf # 0x0E -Kprintf: - j $31 - li $0, 0x0E - - .globl SetKprintf # 0x0F -SetKprintf: - j $31 - li $0, 0x0F - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/thbase.s b/iop/kernel/src/thbase.s deleted file mode 100644 index 02dff975eef..00000000000 --- a/iop/kernel/src/thbase.s +++ /dev/null @@ -1,170 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Base Kernel Functions. -*/ - - .text - .set noreorder - - -/* ############################### THBASE STUB ######## */ -/* # Added by Oobles, 5th March 2002 # */ - - .local thbase_stub -thbase_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "thbase\0\0" - .align 2 - - .globl CreateThread # 004 -CreateThread: - j $31 - li $0, 4 - - .globl DeleteThread # 005 -DeleteThread: - j $31 - li $0, 5 - - .globl StartThread # 006 -StartThread: - j $31 - li $0, 6 - - .globl StartThreadArgs # 007 -StartThreadArgs: - j $31 - li $0, 0x07 - - .globl ExitThread # 008 -ExitThread: - j $31 - li $0, 0x08 - - .globl ExitDeleteThread # 009 -ExitDeleteThread: - j $31 - li $0, 0x09 - - .globl TerminateThread # 010 -TerminateThread: - j $31 - li $0, 0x0A - - .globl iTerminateThread # 011 -iTerminateThread: - j $31 - li $0, 0x0B - - .globl DisableDispatchThread # 012 -DisableDispatchThread: - j $31 - li $0, 0x0C - - .globl EnableDispatchThread # 013 -EnableDispatchThread: - j $31 - li $0, 0x0D - - - .globl ChangeThreadPriority # 014 -ChangeThreadPriority: - j $31 - li $0, 0x0E - - .globl iChangeThreadPriority # 015 -iChangeThreadPriority: - j $31 - li $0, 0x0F - - - .globl ReleaseWaitThread # 018 -ReleaseWaitThread: - j $31 - li $0, 18 - - .globl iReleaseWaitThread # 019 -iReleaseWaitThread: - j $31 - li $0, 19 - - .globl GetThreadId # 0x14 -GetThreadId: - j $31 - li $0, 0x14 - - .globl SleepThread # 0x18 -SleepThread: - j $31 - li $0, 0x18 - - .globl WakeupThread # 0x19 -WakeupThread: - j $31 - li $0, 0x19 - - .globl iWakeupThread # 0x1A -iWakeupThread: - j $31 - li $0, 0x1A - - .globl DelayThread # 0x21 -DelayThread: - j $31 - li $0, 0x21 - - .globl GetSystemTime # 0x22 -GetSystemTime: - j $31 - li $0, 0x22 - - - .globl SetAlarm # 0x23 -SetAlarm: - j $31 - li $0, 0x23 - - .globl iSetAlarm # 0x24 -iSetAlarm: - j $31 - li $0, 0x24 - - .globl CancelAlarm # 0x25 -CancelAlarm: - j $31 - li $0, 0x25 - - .globl iCancelAlarm # 0x26 -iCancelAlarm: - j $31 - li $0, 0x26 - - .globl USec2SysClock # 0x27 -USec2SysClock: - j $31 - li $0, 0x27 - - .globl SysClock2USec # 0x28 -SysClock2USec: - j $31 - li $0, 0x28 - - .globl GetSystemStatusFlag # 0x29 -GetSystemStatusFlag: - j $31 - li $0, 0x29 - - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/thevent.s b/iop/kernel/src/thevent.s deleted file mode 100644 index 11edb75ef2f..00000000000 --- a/iop/kernel/src/thevent.s +++ /dev/null @@ -1,71 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Event Function Imports. -*/ - - .text - .set noreorder - - - .local thevent_stub -thevent_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "thevent\0" - .align 2 - - .globl CreateEventFlag # 004 -CreateEventFlag: - j $31 - li $0, 0x04 - - .globl DeleteEventFlag -DeleteEventFlag: - j $31 - li $0, 0x05 - - .globl SetEventFlag # 006 -SetEventFlag: - j $31 - li $0, 0x06 - - .globl iSetEventFlag # 007 -iSetEventFlag: - j $31 - li $0, 0x07 - - .globl ClearEventFlag # 008 -ClearEventFlag: - j $31 - li $0, 0x08 - - .globl iClearEventFlag # 009 -iClearEventFlag: - j $31 - li $0, 0x09 - - .globl WaitEventFlag # 00A -WaitEventFlag: - j $31 - li $0, 0x0A - - .word 0 - .word 0 - - .globl ReferEventFlagStatus # 00D -ReferEventFlagStatus: - j $31 - li $0, 0x0D - - .globl iReferEventFlagStatus # 00E -iReferEventFlagStatus: - j $31 - li $0, 0x0E diff --git a/iop/kernel/src/thsemap.s b/iop/kernel/src/thsemap.s deleted file mode 100644 index 93f6ef34c2f..00000000000 --- a/iop/kernel/src/thsemap.s +++ /dev/null @@ -1,72 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# -# Semaphore Function Imports. -*/ - - .text - .set noreorder - - -/* ############################### THSEMAP STUB ####### */ -/* # Added by Oobles, 5th March 2002 # */ - - .local thsemap_stub -thsemap_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "thsemap\0" - .align 2 - - .globl CreateSema # 004 -CreateSema: - j $31 - li $0, 4 - - .globl DeleteSema # 005 -DeleteSema: - j $31 - li $0, 5 - - .globl SignalSema # 006 -SignalSema: - j $31 - li $0, 6 - - .globl iSignalSema # 007 -iSignalSema: - j $31 - li $0, 7 - - .globl WaitSema # 008 -WaitSema: - j $31 - li $0, 8 - - .globl PollSema # 009 -PollSema: - j $31 - li $0, 0x09 - - .globl ReferSemaStatus # 00B -ReferSemaStatus: - j $31 - li $0, 0x0B - - .globl iReferSemaStatus # 00C -iReferSemaStatus: - j $31 - li $0, 0x0C - - .word 0 - .word 0 - - diff --git a/iop/kernel/src/timrman.S b/iop/kernel/src/timrman.S deleted file mode 100644 index 1bc0622e9ef..00000000000 --- a/iop/kernel/src/timrman.S +++ /dev/null @@ -1,50 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Serial Input Output 2 Manager Functions. -*/ - -#define DECLARE_EXPORT(name, n) \ - .globl name; \ -name: \ - j $31; \ - li $0, n - - .text - .set noreorder - - -/* ############################## TIMRMAN STUB ######## */ -/* # Added by linuzappz, 18th May 2005 # */ - - .local timrman_stub -timrman_stub: - .word 0x41e00000 - .word 0 - .word 0x00000102 - .ascii "timrman\0" - .align 2 - - DECLARE_EXPORT(AllocHardTimer, 4) - DECLARE_EXPORT(ReferHardTimer, 5) - DECLARE_EXPORT(FreeHardTimer, 6) - DECLARE_EXPORT(SetTimerMode, 7) - DECLARE_EXPORT(GetTimerStatus, 8) - DECLARE_EXPORT(SetTimerCounter, 9) - DECLARE_EXPORT(GetTimerCounter, 10) - DECLARE_EXPORT(SetTimerCompare, 11) - DECLARE_EXPORT(GetTimerCompare, 12) - DECLARE_EXPORT(SetHoldMode, 13) - DECLARE_EXPORT(GetHoldMode, 14) - DECLARE_EXPORT(GetHoldReg, 15) - DECLARE_EXPORT(GetHardTimerIntrCode, 16) - - .word 0 - .word 0 - diff --git a/iop/kernel/src/usbd.s b/iop/kernel/src/usbd.s deleted file mode 100644 index 995ae770cc0..00000000000 --- a/iop/kernel/src/usbd.s +++ /dev/null @@ -1,114 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# USB Driver Import functions. -*/ - - .text - .set noreorder - - .local usbd_stub -usbd_stub: # Module Import Information - .word 0x41e00000 # Import Tag - .word 0x00000000 # Minor Version? - .word 0x00000101 # Major Version? - .ascii "usbd\0\0\0\0" # Library ID - .align 2 - - /* initialize USBD.IRX - * Note: UsbInit is automatically called first whenever USBD.IRX is loaded. - * There should never be a need to reinitialize the driver. In fact, it may - * not even work. But I'm providing the function hook anyhow. - */ - .globl UsbInit -UsbInit: - j $31 - li $0, 0x00 - - /* - * These two functions are used to register and unregister device drivers for - * listening for USB bus events. The events are device probe, connect, and disconnect. - */ - - # register a USB device driver - .globl sceUsbdRegisterLdd -sceUsbdRegisterLdd: - j $31 - li $0, 0x04 - - # unregister a USB device driver - .globl sceUsbdUnregisterLdd -sceUsbdUnregisterLdd: - j $31 - li $0, 0x05 - - /* - * This function is used to get the static descriptors for the specific USB - * device. These descriptors identify the device uniquely and help determine - * what type of device we are dealing with, and what its capabilities and - * features are. - */ - .globl sceUsbdScanStaticDescriptor -sceUsbdScanStaticDescriptor: - j $31 - li $0, 0x06 - - /* - * These two functions are used to assign relevant data to a specific device. - * The type of data is entirely up to the caller. For example, a particular - * USB device driver may store configuration data for each specific device - * under its control. - */ - - # set the private data pointer for a device - .globl sceUsbdSetPrivateData -sceUsbdSetPrivateData: - j $31 - li $0, 0x07 - - # get the private data pointer for a device - .globl sceUsbdGetPrivateData -sceUsbdGetPrivateData: - j $31 - li $0, 0x08 - - /* - * This function returns an endpoint ID for the device ID and endpoint descriptor - * passed in. This endpoint ID is then used when transfering data to the device, - * and to close the endpoint. - */ - .globl sceUsbdOpenPipe -sceUsbdOpenPipe: - j $31 - li $0, 0x09 - - # close an endpoint - .globl sceUsbdClosePipe -sceUsbdClosePipe: - j $31 - li $0, 0x0A - - /* - * This function is used for all types of USB data transfers. Which type of - * transfer is determined by the parameters that are passed in. The types are: - * control, isochronous, interrupt, and bulk transfers. More details can be - * found in usbd.h. - */ - .globl sceUsbdTransferPipe -sceUsbdTransferPipe: - j $31 - li $0, 0x0B - - .globl UsbOpenBulkEndpoint -UsbOpenBulkEndpoint: - j $31 - li $0, 0x0C - - .word 0 - .word 0 diff --git a/iop/kernel/src/vblank.s b/iop/kernel/src/vblank.s deleted file mode 100644 index cb2a8b0d39c..00000000000 --- a/iop/kernel/src/vblank.s +++ /dev/null @@ -1,56 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Vblank Manager Functions. -*/ - - .text - .set noreorder - - -/* ################################ VBLANK STUB ####### */ -/* # Added by Sjeep, 28th March 2002 # */ - - .local vblank_stub -vblank_stub: - .word 0x41e00000 - .word 0 - .word 0x00000101 - .ascii "vblank\0\0" - .align 2 - - .globl WaitVblankStart -WaitVblankStart: - jr $31 - li $0,4 - - .globl WaitVblankEnd -WaitVblankEnd: - jr $31 - li $0,5 - - .globl WaitVblank -WaitVblank: - jr $31 - li $0,6 - - .globl WaitNonVblank -WaitNonVblank: - jr $31 - li $0,7 - - .globl RegisterVblankHandler -RegisterVblankHandler: - jr $31 - li $0,8 - - .globl ReleaseVblankHandler -ReleaseVblankHandler: - jr $31 - li $0,9 From 1ebbc2f7d438187bac2bfaab667b27bb0484738c Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Mon, 27 Jan 2025 18:05:18 -0600 Subject: [PATCH 3/4] refactor: move s file contents to referenced c files --- ee/libprofglue/Makefile | 4 +- ee/libprofglue/src/mcount.S | 39 ---- ee/libprofglue/src/prof.c | 43 ++++ iop/debug/iop_sbusdbg/Makefile | 2 +- iop/debug/iop_sbusdbg/src/main.c | 18 ++ iop/debug/iop_sbusdbg/src/sbus_dbg_low.S | 15 -- iop/system/udnl/Makefile | 2 +- iop/system/udnl/src/udnl.c | 259 +++++++++++++++++++++++ iop/system/udnl/src/udnl_asm.S | 244 --------------------- 9 files changed, 325 insertions(+), 301 deletions(-) delete mode 100644 ee/libprofglue/src/mcount.S delete mode 100644 iop/debug/iop_sbusdbg/src/sbus_dbg_low.S delete mode 100644 iop/system/udnl/src/udnl_asm.S diff --git a/ee/libprofglue/Makefile b/ee/libprofglue/Makefile index 7064b39014c..992d6f624f4 100644 --- a/ee/libprofglue/Makefile +++ b/ee/libprofglue/Makefile @@ -8,7 +8,9 @@ EE_LIB = libprofglue.a -EE_OBJS = prof.o mcount.o +EE_FATLTOFLAGS ?= + +EE_OBJS = prof.o include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/ee/Rules.lib.make diff --git a/ee/libprofglue/src/mcount.S b/ee/libprofglue/src/mcount.S deleted file mode 100644 index 657c48c34ea..00000000000 --- a/ee/libprofglue/src/mcount.S +++ /dev/null @@ -1,39 +0,0 @@ - .set noreorder - .set noat - - .global _mcount - .ent _mcount - -_mcount: - -# Generated code already substracts 8 bytes -# We store our ra, at and a0-a3 - daddiu $sp, $sp, -56 # Adjust stack pointer for 64-bit registers, 7 registers * 8 bytes each - sd $ra, 0($sp) # store ra - sd $at, 8($sp) # at = ra of caller - sd $a0, 16($sp) - sd $a1, 24($sp) - sd $a2, 32($sp) - sd $a3, 40($sp) - -# Call internal C handler - move $a0, $at - move $a1, $ra - jal __mcount - nop - -# Restore registers - ld $ra, 0($sp) - ld $at, 8($sp) - ld $a0, 16($sp) - ld $a1, 24($sp) - ld $a2, 32($sp) - ld $a3, 40($sp) - daddiu $sp, $sp, 56 # Adjust stack pointer back - jr $ra - move $ra, $at # restore caller's ra - - .end _mcount - - .set reorder - .set at diff --git a/ee/libprofglue/src/prof.c b/ee/libprofglue/src/prof.c index 73e2c8f35a8..0e6bc9ec58a 100644 --- a/ee/libprofglue/src/prof.c +++ b/ee/libprofglue/src/prof.c @@ -245,3 +245,46 @@ void __mcount(unsigned int frompc, unsigned int selfpc) arc->count++; } } + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global _mcount" "\n" + "\t" ".ent _mcount" "\n" + + "\t" "_mcount:" "\n" + + // Generated code already substracts 8 bytes + // We store our ra, at and a0-a3 + "\t" "\t" "daddiu $sp, $sp, -56" "\n" // Adjust stack pointer for 64-bit registers, 7 registers * 8 bytes each + "\t" "\t" "sd $ra, 0($sp)" "\n" // store ra + "\t" "\t" "sd $at, 8($sp)" "\n" // at = ra of caller + "\t" "\t" "sd $a0, 16($sp)" "\n" + "\t" "\t" "sd $a1, 24($sp)" "\n" + "\t" "\t" "sd $a2, 32($sp)" "\n" + "\t" "\t" "sd $a3, 40($sp)" "\n" + + // Call internal C handler + "\t" "\t" "move $a0, $at" "\n" + "\t" "\t" "move $a1, $ra" "\n" + "\t" "\t" "jal __mcount" "\n" + "\t" "\t" "nop" "\n" + + // Restore registers + "\t" "\t" "ld $ra, 0($sp)" "\n" + "\t" "\t" "ld $at, 8($sp)" "\n" + "\t" "\t" "ld $a0, 16($sp)" "\n" + "\t" "\t" "ld $a1, 24($sp)" "\n" + "\t" "\t" "ld $a2, 32($sp)" "\n" + "\t" "\t" "ld $a3, 40($sp)" "\n" + "\t" "\t" "daddiu $sp, $sp, 56" "\n" // Adjust stack pointer back + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "move $ra, $at" "\n" // restore caller's ra + + "\t" ".end _mcount" "\n" + + "\t" ".set pop" "\n" +); diff --git a/iop/debug/iop_sbusdbg/Makefile b/iop/debug/iop_sbusdbg/Makefile index e13da04cdb1..d7f2536d480 100644 --- a/iop/debug/iop_sbusdbg/Makefile +++ b/iop/debug/iop_sbusdbg/Makefile @@ -22,7 +22,7 @@ IOP_INCS += \ -I$(PS2SDKSRC)/iop/system/sysmem/include \ -I$(PS2SDKSRC)/iop/system/threadman/include -IOP_OBJS = main.o sbus_dbg_low.o sbus_tty.o sbus_dbg.o imports.o +IOP_OBJS = main.o sbus_tty.o sbus_dbg.o imports.o include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/iop/Rules.bin.make diff --git a/iop/debug/iop_sbusdbg/src/main.c b/iop/debug/iop_sbusdbg/src/main.c index 4e4d66ab59a..aa2e634ff59 100644 --- a/iop/debug/iop_sbusdbg/src/main.c +++ b/iop/debug/iop_sbusdbg/src/main.c @@ -46,6 +46,24 @@ void _iop_ex_handler(IOP_RegFrame *frame) int tid; extern void soft_break(void); +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global soft_break" "\n" + "\t" ".ent soft_break" "\n" + "\t" "soft_break:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "break" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end soft_break" "\n" + + "\t" ".set pop" "\n" +); void _controller_thread(void) { diff --git a/iop/debug/iop_sbusdbg/src/sbus_dbg_low.S b/iop/debug/iop_sbusdbg/src/sbus_dbg_low.S deleted file mode 100644 index 2e776ef2de3..00000000000 --- a/iop/debug/iop_sbusdbg/src/sbus_dbg_low.S +++ /dev/null @@ -1,15 +0,0 @@ -.set push -.set noreorder -.set noat - -.global soft_break -.ent soft_break -soft_break: - nop - break - nop - jr $ra - nop -.end soft_break - -.set pop diff --git a/iop/system/udnl/Makefile b/iop/system/udnl/Makefile index 0a7ef98d8a5..beced330a1c 100644 --- a/iop/system/udnl/Makefile +++ b/iop/system/udnl/Makefile @@ -16,7 +16,7 @@ IOP_INCS += \ -I$(PS2SDKSRC)/iop/system/sysmem/include \ -I$(PS2SDKSRC)/iop/system/threadman/include -IOP_OBJS = udnl.o udnl_asm.o imports.o +IOP_OBJS = udnl.o imports.o include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/iop/Rules.bin.make diff --git a/iop/system/udnl/src/udnl.c b/iop/system/udnl/src/udnl.c index f9ccdd7ee65..9033495a57f 100644 --- a/iop/system/udnl/src/udnl.c +++ b/iop/system/udnl/src/udnl.c @@ -16,6 +16,22 @@ IRX_ID(MODNAME, 1, 1); #ifdef UDNL_T300 int CpuExecuteKmode(void *function, ...); // Exactly the same function as INTRMAN's export 14. +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl CpuExecuteKmode" "\n" + "\t" ".ent CpuExecuteKmode" "\n" + "\t" "CpuExecuteKmode:" "\n" + "\t" "\t" "li $v0, 0x0C" "\n" + "\t" "\t" "syscall" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end CpuExecuteKmode" "\n" + "\t" ".set pop" "\n" +); #endif //#define DEBUG 1 //Comment out to disable debug messages. @@ -367,6 +383,36 @@ static volatile unsigned int *func_00000f80(volatile unsigned int *address) // 0x00001b38 void func_00001b38(unsigned int arg1); +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl func_00001b38" "\n" + "\t" ".ent func_00001b38" "\n" + "\t" "func_00001b38:" "\n" + "\t" "\t" "mfc0 $t0, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "la $t4, func_00001b38_main" "\n" + "\t" "\t" "lui $at, 0xA000" "\n" + "\t" "\t" "or $t4, $t4, $at" "\n" + "\t" "\t" "jr $t4" "\n" + "\t" "\t" "mtc0 $zero, $12" "\n" + "\t" "func_00001b38_main:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "lui $at, 0xFFFE" "\n" + "\t" "\t" "sw $a0, 0x0130($at)" "\n" + "\t" "\t" "lui $at, 0xFFFE" "\n" + "\t" "\t" "lw $zero, 0x0130($at)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $t0, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end func_00001b38" "\n" + "\t" ".set pop" "\n" +); // 0x00000c98 static void TerminateResidentEntriesDI(unsigned int options) @@ -416,6 +462,111 @@ void func_00001930(void); void func_00001440(void); #endif +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + +#ifdef UDNL_T300 + "\t" ".globl func_00001930" "\n" + "\t" ".ent func_00001930" "\n" + "\t" "func_00001930:" "\n" +#else + "\t" ".globl func_00001440" "\n" + "\t" ".ent func_00001440" "\n" + "\t" "func_00001440:" "\n" +#endif + "\t" "\t" "mfc0 $t0, $12" "\n" + "\t" "\t" "nop" "\n" +#ifdef UDNL_T300 + "\t" "\t" "la $t4, func_00001930_main" "\n" +#else + "\t" "\t" "la $t4, func_00001440_main" "\n" +#endif + "\t" "\t" "lui $at, 0xA000" "\n" + "\t" "\t" "or $t4, $t4, $at" "\n" + "\t" "\t" "jr $t4" "\n" +#ifdef UDNL_T300 + "\t" "func_00001930_main:" "\n" +#else + "\t" "func_00001440_main:" "\n" +#endif + "\t" "\t" "mtc0 $zero, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "lui $t6, 0xbf80" "\n" + "\t" "\t" "lw $t6, 0x1450($t6)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "addiu $t7, $zero, 0xfffe" "\n" + "\t" "\t" "and $t1, $t6, $t7" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $t1, 0x1450($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1450($at)" "\n" + "\t" "\t" "lui $t7, 0xbf80" "\n" + "\t" "\t" "lw $t7, 0x1578($t7)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $zero, 0x1578($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1578($at)" "\n" + "\t" "\t" "lui $t5, 0xfffe" "\n" + "\t" "\t" "lw $t5, 0x0130($t5)" "\n" + "\t" "\t" "addiu $t1, $zero, 0x0c04" "\n" + "\t" "\t" "lui $at, 0xfffe" "\n" + "\t" "\t" "sw $t1, 0x0130($at)" "\n" + "\t" "\t" "lui $t4, 0x0001" "\n" + "\t" "\t" "mtc0 $t4, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "addiu $t2, $zero, 0x0000" "\n" + "\t" "\t" "addiu $t3, $zero, 0x0f80" "\n" +#ifdef UDNL_T300 + "\t" "func_00001930_loop:" "\n" +#else + "\t" "func_00001440_loop:" "\n" +#endif + "\t" "\t" "sw $zero, 0x0000($t2)" "\n" + "\t" "\t" "sw $zero, 0x0010($t2)" "\n" + "\t" "\t" "sw $zero, 0x0020($t2)" "\n" + "\t" "\t" "sw $zero, 0x0030($t2)" "\n" + "\t" "\t" "sw $zero, 0x0040($t2)" "\n" + "\t" "\t" "sw $zero, 0x0050($t2)" "\n" + "\t" "\t" "sw $zero, 0x0060($t2)" "\n" + "\t" "\t" "sw $zero, 0x0070($t2)" "\n" +#ifdef UDNL_T300 + "\t" "\t" "bne $t2, $t3, func_00001930_loop" "\n" +#else + "\t" "\t" "bne $t2, $t3, func_00001440_loop" "\n" +#endif + "\t" "\t" "addi $t2, $t2, 0x0080" "\n" + "\t" "\t" "mtc0 $zero, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "lui $at, 0xfffe" "\n" + "\t" "\t" "sw $t5, 0x0130($at)" "\n" + "\t" "\t" "lui $at, 0xfffe" "\n" + "\t" "\t" "lw $zero, 0x0130($at)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $t7, 0x1578($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1578($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $t6, 0x1450($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1450($at)" "\n" + "\t" "\t" "mtc0 $t0, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" +#ifdef UDNL_T300 + "\t" ".end func_00001930" "\n" +#else + "\t" ".end func_00001440" "\n" +#endif + "\t" ".set pop" "\n" +); + enum IOP_MODULE_TYPES { IOP_MOD_TYPE_COFF = 1, IOP_MOD_TYPE_2, @@ -1277,3 +1428,111 @@ static void *AllocMemory(int nbytes) return AllocSysMemory(2, nbytes, BlockTopAddress); } + +#ifdef THIS_IS_UNUSED +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + +// Note: This doesn't seem to be used. +#ifdef UDNL_T300 + "\t" ".globl func_00001a34" "\n" + "\t" ".ent func_00001a34" "\n" + "\t" "func_00001a34:" "\n" +#else + "\t" ".globl func_00001544" "\n" + "\t" ".ent func_00001544" "\n" + "\t" "func_00001544:" "\n" +#endif + "\t" "\t" "mfc0 $t0, $12" "\n" + "\t" "\t" "nop" "\n" +#ifdef UDNL_T300 + "\t" "\t" "la $t4, func_00001a34_main" "\n" +#else + "\t" "\t" "la $t4, func_00001544_main" "\n" +#endif + "\t" "\t" "lui $at, 0xa000" "\n" + "\t" "\t" "or $t4, $t4, $at" "\n" + "\t" "\t" "jr $t4" "\n" +#ifdef UDNL_T300 + "\t" "func_00001a34_main:" "\n" +#else + "\t" "func_00001544_main:" "\n" +#endif + "\t" "\t" "mtc0 $zero, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "lui $t6, 0xbf80" "\n" + "\t" "\t" "lw $t6, 0x1450($t6)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "addiu $t7, $zero, 0xfffe" "\n" + "\t" "\t" "and $t1, $t6, $t7" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $t1, 0x1450($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1450($at)" "\n" + "\t" "\t" "lui $t7, 0xbf80" "\n" + "\t" "\t" "lw $t7, 0x1578($t7)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $zero, 0x1578($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1578($at)" "\n" + "\t" "\t" "lui $t5, 0xfffe" "\n" + "\t" "\t" "lw $t5, 0x0130($t5)" "\n" + "\t" "\t" "addiu $t1, $zero, 0x00c4" "\n" + "\t" "\t" "lui $at, 0xfffe" "\n" + "\t" "\t" "sw $t1, 0x0130($at)" "\n" + "\t" "\t" "lui $t4, 0x0001" "\n" + "\t" "\t" "mtc0 $t4, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "addiu $t2, $zero, 0x0000" "\n" + "\t" "\t" "addiu $t3, $zero, 0x0380" "\n" +#ifdef UDNL_T300 + "\t" "func_00001a34_loop:" "\n" +#else + "\t" "func_00001544_loop:" "\n" +#endif + "\t" "\t" "sw $zero, 0x0000($t2)" "\n" + "\t" "\t" "sw $zero, 0x0010($t2)" "\n" + "\t" "\t" "sw $zero, 0x0020($t2)" "\n" + "\t" "\t" "sw $zero, 0x0030($t2)" "\n" + "\t" "\t" "sw $zero, 0x0040($t2)" "\n" + "\t" "\t" "sw $zero, 0x0050($t2)" "\n" + "\t" "\t" "sw $zero, 0x0060($t2)" "\n" + "\t" "\t" "sw $zero, 0x0070($t2)" "\n" +#ifdef UDNL_T300 + "\t" "\t" "bne $t2, $t3, func_00001a34_loop" "\n" +#else + "\t" "\t" "bne $t2, $t3, func_00001544_loop" "\n" +#endif + "\t" "\t" "addi $t2, $t2, 0x0080" "\n" + "\t" "\t" "mtc0 $zero, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "lui $at, 0xfffe" "\n" + "\t" "\t" "sw $t5, 0x0130($at)" "\n" + "\t" "\t" "lui $at, 0xfffe" "\n" + "\t" "\t" "lw $zero, 0x0130($at)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $t7, 0x1578($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1578($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "sw $t6, 0x1450($at)" "\n" + "\t" "\t" "lui $at, 0xbf80" "\n" + "\t" "\t" "lw $zero, 0x1450($at)" "\n" + "\t" "\t" "mtc0 $t0, $12" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" +#ifdef UDNL_T300 + "\t" ".end func_00001a34" "\n" +#else + "\t" ".end func_00001544" "\n" +#endif + "\t" ".set pop" "\n" +); +#endif diff --git a/iop/system/udnl/src/udnl_asm.S b/iop/system/udnl/src/udnl_asm.S deleted file mode 100644 index 89d8e070c33..00000000000 --- a/iop/system/udnl/src/udnl_asm.S +++ /dev/null @@ -1,244 +0,0 @@ -#include "as_reg_compat.h" - -.ifdef .gasversion. -.section .mdebug.abi32 -.nan legacy -.module softfloat -.module nooddspreg -.endif -.set push -.set noat -.set noreorder - -.text - -#ifdef UDNL_T300 -.globl CpuExecuteKmode -.ent CpuExecuteKmode -CpuExecuteKmode: - li $v0, 0x0C - syscall - jr $ra - nop -.end CpuExecuteKmode - -.globl func_00001b38 -.ent func_00001b38 -func_00001b38: - mfc0 $t0, $12 - nop - la $t4, func_00001b38_main - lui $at, 0xA000 - or $t4, $t4, $at - jr $t4 - mtc0 $zero, $12 -func_00001b38_main: - nop - lui $at, 0xFFFE - sw $a0, 0x0130($at) - lui $at, 0xFFFE - lw $zero, 0x0130($at) - nop - mtc0 $t0, $12 - nop - jr $ra - nop -.end func_00001b38 -#endif - -#ifdef UDNL_T300 -.globl func_00001930 -.ent func_00001930 -func_00001930: -#else -.globl func_00001440 -.ent func_00001440 -func_00001440: -#endif - mfc0 $t0, $12 - nop -#ifdef UDNL_T300 - la $t4, func_00001930_main -#else - la $t4, func_00001440_main -#endif - lui $at, 0xA000 - or $t4, $t4, $at - jr $t4 -#ifdef UDNL_T300 -func_00001930_main: -#else -func_00001440_main: -#endif - mtc0 $zero, $12 - nop - nop - lui $t6, 0xbf80 - lw $t6, 0x1450($t6) - nop - addiu $t7, $zero, 0xfffe - and $t1, $t6, $t7 - lui $at, 0xbf80 - sw $t1, 0x1450($at) - lui $at, 0xbf80 - lw $zero, 0x1450($at) - lui $t7, 0xbf80 - lw $t7, 0x1578($t7) - lui $at, 0xbf80 - sw $zero, 0x1578($at) - lui $at, 0xbf80 - lw $zero, 0x1578($at) - lui $t5, 0xfffe - lw $t5, 0x0130($t5) - addiu $t1, $zero, 0x0c04 - lui $at, 0xfffe - sw $t1, 0x0130($at) - lui $t4, 0x0001 - mtc0 $t4, $12 - nop - nop - addiu $t2, $zero, 0x0000 - addiu $t3, $zero, 0x0f80 -#ifdef UDNL_T300 -func_00001930_loop: -#else -func_00001440_loop: -#endif - sw $zero, 0x0000($t2) - sw $zero, 0x0010($t2) - sw $zero, 0x0020($t2) - sw $zero, 0x0030($t2) - sw $zero, 0x0040($t2) - sw $zero, 0x0050($t2) - sw $zero, 0x0060($t2) - sw $zero, 0x0070($t2) -#ifdef UDNL_T300 - bne $t2, $t3, func_00001930_loop -#else - bne $t2, $t3, func_00001440_loop -#endif - addi $t2, $t2, 0x0080 - mtc0 $zero, $12 - nop - lui $at, 0xfffe - sw $t5, 0x0130($at) - lui $at, 0xfffe - lw $zero, 0x0130($at) - nop - lui $at, 0xbf80 - sw $t7, 0x1578($at) - lui $at, 0xbf80 - lw $zero, 0x1578($at) - lui $at, 0xbf80 - sw $t6, 0x1450($at) - lui $at, 0xbf80 - lw $zero, 0x1450($at) - mtc0 $t0, $12 - nop - jr $ra - nop -#ifdef UDNL_T300 -.end func_00001930 -#else -.end func_00001440 -#endif - -# Note: This doesn't seem to be used. -#ifdef UDNL_T300 -# .globl func_00001a34 -# .ent func_00001a34 -# func_00001a34: -#else -# .globl func_00001544 -# .ent func_00001544 -# func_00001544: -#endif -# mfc0 $t0, $12 -# nop -#ifdef UDNL_T300 -# la $t4, func_00001a34_main -#else -# la $t4, func_00001544_main -#endif -# lui $at, 0xa000 -# or $t4, $t4, $at -# jr $t4 -#ifdef UDNL_T300 -# func_00001a34_main: -#else -# func_00001544_main: -#endif -# mtc0 $zero, $12 -# nop -# nop -# lui $t6, 0xbf80 -# lw $t6, 0x1450($t6) -# nop -# addiu $t7, $zero, 0xfffe -# and $t1, $t6, $t7 -# lui $at, 0xbf80 -# sw $t1, 0x1450($at) -# lui $at, 0xbf80 -# lw $zero, 0x1450($at) -# lui $t7, 0xbf80 -# lw $t7, 0x1578($t7) -# lui $at, 0xbf80 -# sw $zero, 0x1578($at) -# lui $at, 0xbf80 -# lw $zero, 0x1578($at) -# lui $t5, 0xfffe -# lw $t5, 0x0130($t5) -# addiu $t1, $zero, 0x00c4 -# lui $at, 0xfffe -# sw $t1, 0x0130($at) -# lui $t4, 0x0001 -# mtc0 $t4, $12 -# nop -# nop -# addiu $t2, $zero, 0x0000 -# addiu $t3, $zero, 0x0380 -#ifdef UDNL_T300 -# func_00001a34_loop: -#else -# func_00001544_loop: -#endif -# sw $zero, 0x0000($t2) -# sw $zero, 0x0010($t2) -# sw $zero, 0x0020($t2) -# sw $zero, 0x0030($t2) -# sw $zero, 0x0040($t2) -# sw $zero, 0x0050($t2) -# sw $zero, 0x0060($t2) -# sw $zero, 0x0070($t2) -#ifdef UDNL_T300 -# bne $t2, $t3, func_00001a34_loop -#else -# bne $t2, $t3, func_00001544_loop -#endif -# addi $t2, $t2, 0x0080 -# mtc0 $zero, $12 -# nop -# lui $at, 0xfffe -# sw $t5, 0x0130($at) -# lui $at, 0xfffe -# lw $zero, 0x0130($at) -# nop -# lui $at, 0xbf80 -# sw $t7, 0x1578($at) -# lui $at, 0xbf80 -# lw $zero, 0x1578($at) -# lui $at, 0xbf80 -# sw $t6, 0x1450($at) -# lui $at, 0xbf80 -# lw $zero, 0x1450($at) -# mtc0 $t0, $12 -# nop -# jr $ra -# nop -#ifdef UDNL_T300 -# .end func_00001a34 -#else -# .end func_00001544 -#endif - -.set pop From 447d73ca4ed59f88f350066004fc3c13caeaf11d Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Mon, 27 Jan 2025 18:05:18 -0600 Subject: [PATCH 4/4] refactor: reformat s files into c files --- common/sbus/src/ee_low.S | 54 - common/sbus/src/ee_low.c | 58 + .../src/{callstackget.S => callstackget.c} | 34 +- ee/debug/src/hwbp.S | 322 ---- ee/debug/src/hwbp.c | 475 +++++ ee/eedebug/src/ee_dbg_low.S | 228 --- ee/eedebug/src/ee_dbg_low.c | 376 ++++ ee/eedebug/src/ee_exceptions.S | 313 ---- ee/eedebug/src/ee_exceptions.c | 346 ++++ ee/kernel/Makefile | 4 +- ee/kernel/src/eenull/src/eenull.c | 30 + ee/kernel/src/eenull/src/eenull.s | 26 - ee/kernel/src/kernel.S | 1515 ---------------- ee/kernel/src/kernel.c | 1525 +++++++++++++++++ ee/kernel/src/setup_syscalls.S | 35 - ee/kernel/src/setup_syscalls.c | 57 + ee/kernel/src/srcfile/src/dispatch.c | 116 ++ ee/kernel/src/srcfile/src/dispatch.s | 73 - ee/libgs/src/ResetPath.c | 34 + ee/libgs/src/ResetPath.s | 32 - iop/debug/iopdebug/src/iop_dbg_low.S | 172 -- iop/debug/iopdebug/src/iop_dbg_low.c | 275 +++ iop/debug/iopdebug/src/iop_exceptions.S | 288 ---- iop/debug/iopdebug/src/iop_exceptions.c | 293 ++++ iop/debug/ioptrap/src/handler.S | 295 ---- iop/debug/ioptrap/src/handler.c | 294 ++++ iop/sound/ahx/src/hw.S | 36 - iop/sound/ahx/src/hw.c | 37 + iop/sound/audsrv/src/hw.S | 36 - iop/sound/audsrv/src/hw.c | 37 + 30 files changed, 3975 insertions(+), 3441 deletions(-) delete mode 100644 common/sbus/src/ee_low.S create mode 100644 common/sbus/src/ee_low.c rename ee/debug/src/{callstackget.S => callstackget.c} (72%) delete mode 100644 ee/debug/src/hwbp.S create mode 100644 ee/debug/src/hwbp.c delete mode 100644 ee/eedebug/src/ee_dbg_low.S create mode 100644 ee/eedebug/src/ee_dbg_low.c delete mode 100644 ee/eedebug/src/ee_exceptions.S create mode 100644 ee/eedebug/src/ee_exceptions.c create mode 100644 ee/kernel/src/eenull/src/eenull.c delete mode 100644 ee/kernel/src/eenull/src/eenull.s delete mode 100644 ee/kernel/src/kernel.S create mode 100644 ee/kernel/src/kernel.c delete mode 100644 ee/kernel/src/setup_syscalls.S create mode 100644 ee/kernel/src/setup_syscalls.c create mode 100644 ee/kernel/src/srcfile/src/dispatch.c delete mode 100644 ee/kernel/src/srcfile/src/dispatch.s create mode 100644 ee/libgs/src/ResetPath.c delete mode 100755 ee/libgs/src/ResetPath.s delete mode 100644 iop/debug/iopdebug/src/iop_dbg_low.S create mode 100644 iop/debug/iopdebug/src/iop_dbg_low.c delete mode 100644 iop/debug/iopdebug/src/iop_exceptions.S create mode 100644 iop/debug/iopdebug/src/iop_exceptions.c delete mode 100644 iop/debug/ioptrap/src/handler.S create mode 100644 iop/debug/ioptrap/src/handler.c delete mode 100755 iop/sound/ahx/src/hw.S create mode 100644 iop/sound/ahx/src/hw.c delete mode 100755 iop/sound/audsrv/src/hw.S create mode 100644 iop/sound/audsrv/src/hw.c diff --git a/common/sbus/src/ee_low.S b/common/sbus/src/ee_low.S deleted file mode 100644 index 84f11b90dd2..00000000000 --- a/common/sbus/src/ee_low.S +++ /dev/null @@ -1,54 +0,0 @@ -.global WriteBackDCache -.ent WriteBackDCache -WriteBackDCache: - - lui $25, 0xffff - ori $25, $25, 0xffc0 - blez $5, last - addu $10, $4, $5 - and $8, $4, $25 - addiu $10, $10, -1 - and $9, $10, $25 - subu $10, $9, $8 - srl $11, $10, 0x6 - addiu $11, $11, 1 - andi $9, $11, 0x7 - beqz $9, eight - srl $10, $11, 0x3 -loop1: - sync - cache 0x18, 0($8) - sync - addiu $9, $9, -1 - nop - bgtz $9, loop1 - addiu $8, $8, 64 - -eight: - beqz $10, last -loop8: - addiu $10, $10, -1 - sync - cache 0x18, 0($8) - sync - cache 0x18, 64($8) - sync - cache 0x18, 128($8) - sync - cache 0x18, 192($8) - sync - cache 0x18, 256($8) - sync - cache 0x18, 320($8) - sync - cache 0x18, 384($8) - sync - cache 0x18, 448($8) - sync - bgtz $10, loop8 - addiu $8, $8, 512 -last: - jr $31 - nop - -.end WriteBackDCache diff --git a/common/sbus/src/ee_low.c b/common/sbus/src/ee_low.c new file mode 100644 index 00000000000..73bc1a0299e --- /dev/null +++ b/common/sbus/src/ee_low.c @@ -0,0 +1,58 @@ + +__asm__ +( + "\t" ".global WriteBackDCache" "\n" + "\t" ".ent WriteBackDCache" "\n" + "\t" "WriteBackDCache:" "\n" + + "\t" "\t" "lui $25, 0xffff" "\n" + "\t" "\t" "ori $25, $25, 0xffc0" "\n" + "\t" "\t" "blez $5, last" "\n" + "\t" "\t" "addu $10, $4, $5" "\n" + "\t" "\t" "and $8, $4, $25" "\n" + "\t" "\t" "addiu $10, $10, -1" "\n" + "\t" "\t" "and $9, $10, $25" "\n" + "\t" "\t" "subu $10, $9, $8" "\n" + "\t" "\t" "srl $11, $10, 0x6" "\n" + "\t" "\t" "addiu $11, $11, 1" "\n" + "\t" "\t" "andi $9, $11, 0x7" "\n" + "\t" "\t" "beqz $9, eight" "\n" + "\t" "\t" "srl $10, $11, 0x3" "\n" + "\t" "loop1:" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 0($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "addiu $9, $9, -1" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "bgtz $9, loop1" "\n" + "\t" "\t" "addiu $8, $8, 64" "\n" + + "\t" "eight:" "\n" + "\t" "\t" "beqz $10, last" "\n" + "\t" "loop8:" "\n" + "\t" "\t" "addiu $10, $10, -1" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 0($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 64($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 128($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 192($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 256($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 320($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 384($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 448($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "bgtz $10, loop8" "\n" + "\t" "\t" "addiu $8, $8, 512" "\n" + "\t" "last:" "\n" + "\t" "\t" "jr $31" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end WriteBackDCache" "\n" +); diff --git a/ee/debug/src/callstackget.S b/ee/debug/src/callstackget.c similarity index 72% rename from ee/debug/src/callstackget.S rename to ee/debug/src/callstackget.c index cc761acac4d..f5037910b73 100644 --- a/ee/debug/src/callstackget.S +++ b/ee/debug/src/callstackget.c @@ -29,18 +29,24 @@ in this Software without prior written authorization from the X Consortium. * Author: Keith Packard, MIT X Consortium */ - .globl ps2GetReturnAddress - .ent ps2GetReturnAddress -ps2GetReturnAddress: - .frame $sp, 0, $31 - move $2,$31 - j $31 - .end ps2GetReturnAddress +__asm__ +( + "\t" "\t" ".globl ps2GetReturnAddress" "\n" + "\t" "\t" ".ent ps2GetReturnAddress" "\n" + "\t" "ps2GetReturnAddress:" "\n" + "\t" "\t" ".frame $sp, 0, $31" "\n" + "\t" "\t" "move $2,$31" "\n" + "\t" "\t" "j $31" "\n" + "\t" "\t" ".end ps2GetReturnAddress" "\n" +); - .globl ps2GetStackPointer - .ent ps2GetStackPointer -ps2GetStackPointer: - .frame $sp, 0, $31 - move $2,$29 - j $31 - .end ps2GetStackPointer +__asm__ +( + "\t" "\t" ".globl ps2GetStackPointer" "\n" + "\t" "\t" ".ent ps2GetStackPointer" "\n" + "\t" "ps2GetStackPointer:" "\n" + "\t" "\t" ".frame $sp, 0, $31" "\n" + "\t" "\t" "move $2,$29" "\n" + "\t" "\t" "j $31" "\n" + "\t" "\t" ".end ps2GetStackPointer" "\n" +); diff --git a/ee/debug/src/hwbp.S b/ee/debug/src/hwbp.S deleted file mode 100644 index 997d28bd9d2..00000000000 --- a/ee/debug/src/hwbp.S +++ /dev/null @@ -1,322 +0,0 @@ -# -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -# -# Hardware breakpoint functions -# - -#define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) -#include "as_reg_compat.h" - - .text - .p2align 3 - - .set push - .set noreorder - .set noat - - - .global InitBPC - .ent InitBPC - -InitBPC: - sync.p - -# Disable the exception handling - li $t0, (1 << 15) - mtbpc $t0 - - // Clear out the registers - mtiab $0 - li $t0, 0xffffffff - mtiabm $t0 - mtdab $0 - mtdabm $t0 - mtdvb $0 - mtdvbm $t0 - - jr $ra - nop - - .end InitBPC - - .global SetInstructionBP - .ent SetInstructionBP - -# Set the instruction breakpoint registers -# a0 = PC location -# a1 = PC Mask -# a2 = options -SetInstructionBP: - - sync.p - - mfbpc $t0 -# Jump if top bit not set - bgez $t0, 1f - nop - -# Clear top bit - li $t1, (1 << 31) - xor $t0, $t0, $t1 - mtbpc $t0 - - sync.p -1: - mtiab $a0 - mtiabm $a1 - mfbpc $t0 -# Clear flags relating to IAB - li $t1, ~((1 << 26) | (1 << 25) | (1 << 24) | (1 << 23) | (1 << 17) | (1 << 15) | 1) - and $t0, $t0, $t1 - -# Set flags relating to IAB, only enable for user and supervisor modes -# li t1, (BPC_IAE | BPC_IUE | BPC_ISE) - -# Clean up options to ensure we are only setting instruction stuff - li $t1, ((1 << 26) | (1 << 25) | (1 << 24) | (1 << 23)) - and $a2, $a2, $t1 - -# Or in options - li $t1, (1 << 31) - or $t1, $a2, $t1 - -# Or in original bpc - or $t0, $t0, $t1 - mtbpc $t0 - sync.p - - jr $ra - nop - - .end SetInstructionBP - -# Set a data address breakpoint -# a0 - Data address -# a1 - Data address mask -# a2 - options (e.g. BPC_DUE) - .global SetDataAddrBP - .ent SetDataAddrBP -SetDataAddrBP: - sync.l - -# Mask out any data address related bits - mfbpc $t0 - li $t1, ~((1 << 30) | (1 << 29) | (1 << 28) | (1 << 21) | \ - (1 << 20) | (1 << 19) | (1 << 18) | (1 << 16) | \ - (1 << 15) | (1 << 2) | (1 << 1)) - - and $t0, $t0, $t1 - mtbpc $t0 - sync.p - -# Move in address and mask - mtdab $a0 - mtdabm $a1 - -# Mask out all non data address bits - li $t1, ((1 << 30) | (1 << 29) | (1 << 21) | (1 << 20) | (1 << 19) | (1 << 18)) - and $t1, $a2, $t1 - - mfbpc $t0 - or $t0, $t0, $t1 - - mtbpc $t0 - sync.p - - jr $ra - nop - - .end SetDataAddrBP - -# Set a data value breakpoint -# a0 - Data address -# a1 - Data address mask -# a2 - Data value -# a3 - Data value mask -# t0 - options (e.g. BPC_DUE) - .global SetDataValueBP - .ent SetDataValueBP -SetDataValueBP: - sync.l - -# Mask out any data address related bits - mfbpc $t1 - li $t2, ~((1 << 30) | (1 << 29) | (1 << 28) | (1 << 21) | \ - (1 << 20) | (1 << 19) | (1 << 18) | (1 << 16) | \ - (1 << 15) | (1 << 2) | (1 << 1)) - - and $t1, $t1, $t2 - mtbpc $t1 - sync.p - -# Move in address and mask - mtdab $a0 - mtdabm $a1 - mtdvb $a2 - mtdvbm $a3 - -# Mask out all non data address bits - li $t2, ((1 << 30) | (1 << 29) | (1 << 21) | (1 << 20) | (1 << 19) | (1 << 18)) - and $t2, $t0, $t2 - li $t0, (1 << 28) # Data value enable - or $t2, $t2, $t0 - - mfbpc $t1 - or $t1, $t1, $t2 - - mtbpc $t1 - sync.p - - jr $ra - nop - - .end SetDataValueBP - - -# Get the current value of the BPC - .global GetBPC - .ent GetBPC -GetBPC: - sync.l - mfbpc $v0 - jr $ra - nop - - .end GetBPC - -# Set the current value of the BPC - .global SetBPC - .ent SetBPC -SetBPC: - mtbpc $a0 - sync.p - jr $ra - nop - - .end SetBPC - -# Get the current value of the Instruction address register - .global GetIAB - .ent GetIAB -GetIAB: - mfiab $v0 - jr $ra - nop - - .end GetIAB - -# Get the current value of the Instruction address mask register - .global GetIABM - .ent GetIABM -GetIABM: - mfiabm $v0 - jr $ra - nop - - .end GetIABM - -# Get the current value of the data address register - .global GetDAB - .ent GetDAB -GetDAB: - mfdab $v0 - jr $ra - nop - - .end GetDAB - -# Get the current value of the data address mask register - .global GetDABM - .ent GetDABM -GetDABM: - mfdabm $v0 - jr $ra - nop - - .end GetDABM - -# Get the current value of the data value register - .global GetDVB - .ent GetDVB -GetDVB: - mfdvb $v0 - jr $ra - nop - - .end GetDVB - -# Get the current value of the data value mask register - .global GetDVBM - .ent GetDVBM -GetDVBM: - mfdvbm $v0 - jr $ra - nop - - .end GetDVBM - -# Set the current value of the Instruction address register - .global SetIAB - .ent SetIAB -SetIAB: - mtiab $a0 - jr $ra - nop - - .end SetIAB - -# Set the current value of the Instruction address mask register - .global SetIABM - .ent SetIABM -SetIABM: - mtiabm $a0 - jr $ra - nop - - .end SetIABM - -# Set the current value of the data address register - .global SetDAB - .ent SetDAB -SetDAB: - mtdab $a0 - jr $ra - nop - - .end SetDAB - -# Set the current value of the data address mask register - .global SetDABM - .ent SetDABM -SetDABM: - mtdabm $a0 - jr $ra - nop - - .end SetDABM - -# Set the current value of the data value register - .global SetDVB - .ent SetDVB -SetDVB: - mtdvb $a0 - jr $ra - nop - - .end SetDVB - -# Set the current value of the data value mask register - .global SetDVBM - .ent SetDVBM -SetDVBM: - mtdvbm $a0 - jr $ra - nop - - .end SetDVBM diff --git a/ee/debug/src/hwbp.c b/ee/debug/src/hwbp.c new file mode 100644 index 00000000000..00c5ec3a545 --- /dev/null +++ b/ee/debug/src/hwbp.c @@ -0,0 +1,475 @@ +/* +# +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +# +# Hardware breakpoint functions +*/ + +#define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) +#include "as_reg_compat.h" + +#define STRINNER(x) #x +#define STR(x) STRINNER(x) + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + "\t" "\t" ".global InitBPC" "\n" + "\t" "\t" ".ent InitBPC" "\n" + + "\t" "InitBPC:" "\n" + "\t" "\t" "sync.p" "\n" + + // Disable the exception handling + "\t" "\t" "li $" STR(t0) ", (1 << 15)" "\n" + "\t" "\t" "mtbpc $" STR(t0) "" "\n" + + // Clear out the registers + "\t" "\t" "mtiab $0" "\n" + "\t" "\t" "li $" STR(t0) ", 0xffffffff" "\n" + "\t" "\t" "mtiabm $" STR(t0) "" "\n" + "\t" "\t" "mtdab $0" "\n" + "\t" "\t" "mtdabm $" STR(t0) "" "\n" + "\t" "\t" "mtdvb $0" "\n" + "\t" "\t" "mtdvbm $" STR(t0) "" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end InitBPC" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + "\t" " .global SetInstructionBP" "\n" + "\t" " .ent SetInstructionBP" "\n" + + // Set the instruction breakpoint registers + // a0 = PC location + // a1 = PC Mask + // a2 = options + "\t" "SetInstructionBP:" "\n" + + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "mfbpc $" STR(t0) "" "\n" + // Jump if top bit not set + "\t" "\t" "bgez $" STR(t0) ", 1f" "\n" + "\t" "\t" "nop" "\n" + + // Clear top bit + "\t" "\t" "li $" STR(t1) ", (1 << 31)" "\n" + "\t" "\t" "xor $" STR(t0) ", $" STR(t0) ", $" STR(t1) "" "\n" + "\t" "\t" "mtbpc $" STR(t0) "" "\n" + + "\t" "\t" "sync.p" "\n" + "\t" "1:" "\n" + "\t" "\t" "mtiab $a0" "\n" + "\t" "\t" "mtiabm $a1" "\n" + "\t" "\t" "mfbpc $" STR(t0) "" "\n" + // Clear flags relating to IAB + "\t" "\t" "li $" STR(t1) ", ~((1 << 26) | (1 << 25) | (1 << 24) | (1 << 23) | (1 << 17) | (1 << 15) | 1)" "\n" + "\t" "\t" "and $" STR(t0) ", $" STR(t0) ", $" STR(t1) "" "\n" + + // Set flags relating to IAB, only enable for user and supervisor modes + // "\t" "\t" "li " STR(t1) ", " (BPC_IAE | BPC_IUE | BPC_ISE) + + // Clean up options to ensure we are only setting instruction stuff + "\t" "\t" "li $" STR(t1) ", ((1 << 26) | (1 << 25) | (1 << 24) | (1 << 23))" "\n" + "\t" "\t" "and $a2, $a2, $" STR(t1) "" "\n" + + // Or in options + "\t" "\t" "li $" STR(t1) ", (1 << 31)" "\n" + "\t" "\t" "or $" STR(t1) ", $a2, $" STR(t1) "" "\n" + + // Or in original bpc + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $" STR(t1) "" "\n" + "\t" "\t" "mtbpc $" STR(t0) "" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetInstructionBP" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set a data address breakpoint + // a0 - Data address + // a1 - Data address mask + // a2 - options (e.g. BPC_DUE) + "\t" "\t" ".global SetDataAddrBP" "\n" + "\t" "\t" ".ent SetDataAddrBP" "\n" + "\t" "SetDataAddrBP:" "\n" + "\t" "\t" "sync.l" "\n" + + // Mask out any data address related bits + "\t" "\t" "mfbpc $" STR(t0) "" "\n" + "\t" "\t" "li $" STR(t1) ", ~((1 << 30) | (1 << 29) | (1 << 28) | (1 << 21) | (1 << 20) | (1 << 19) | (1 << 18) | (1 << 16) | (1 << 15) | (1 << 2) | (1 << 1))" "\n" + + "\t" "\t" "and $" STR(t0) ", $" STR(t0) ", $" STR(t1) "" "\n" + "\t" "\t" "mtbpc $" STR(t0) "" "\n" + "\t" "\t" "sync.p" "\n" + + // Move in address and mask + "\t" "\t" "mtdab $a0" "\n" + "\t" "\t" "mtdabm $a1" "\n" + + // Mask out all non data address bits + "\t" "\t" "li $" STR(t1) ", ((1 << 30) | (1 << 29) | (1 << 21) | (1 << 20) | (1 << 19) | (1 << 18))" "\n" + "\t" "\t" "and $" STR(t1) ", $a2, $" STR(t1) "" "\n" + + "\t" "\t" "mfbpc $" STR(t0) "" "\n" + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $" STR(t1) "" "\n" + + "\t" "\t" "mtbpc $" STR(t0) "" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetDataAddrBP" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set a data value breakpoint + // a0 - Data address + // a1 - Data address mask + // a2 - Data value + // a3 - Data value mask + // " STR(t0) " - options (e.g. BPC_DUE) + "\t" "\t" ".global SetDataValueBP" "\n" + "\t" "\t" ".ent SetDataValueBP" "\n" + "\t" "SetDataValueBP:" "\n" + "\t" "\t" "sync.l" "\n" + + // Mask out any data address related bits + "\t" "\t" "mfbpc $" STR(t1) "" "\n" + "\t" "\t" "li $" STR(t2) ", ~((1 << 30) | (1 << 29) | (1 << 28) | (1 << 21) | (1 << 20) | (1 << 19) | (1 << 18) | (1 << 16) | (1 << 15) | (1 << 2) | (1 << 1))" "\n" + + "\t" "\t" "and $" STR(t1) ", $" STR(t1) ", $" STR(t2) "" "\n" + "\t" "\t" "mtbpc $" STR(t1) "" "\n" + "\t" "\t" "sync.p" "\n" + + // Move in address and mask + "\t" "\t" "mtdab $a0" "\n" + "\t" "\t" "mtdabm $a1" "\n" + "\t" "\t" "mtdvb $a2" "\n" + "\t" "\t" "mtdvbm $a3" "\n" + + // Mask out all non data address bits + "\t" "\t" "li $" STR(t2) ", ((1 << 30) | (1 << 29) | (1 << 21) | (1 << 20) | (1 << 19) | (1 << 18))" "\n" + "\t" "\t" "and $" STR(t2) ", $" STR(t0) ", $" STR(t2) "" "\n" + "\t" "\t" "li $" STR(t0) ", (1 << 28)" "\n" // Data value enable + "\t" "\t" "or $" STR(t2) ", $" STR(t2) ", $" STR(t0) "" "\n" + + "\t" "\t" "mfbpc $" STR(t1) "" "\n" + "\t" "\t" "or $" STR(t1) ", $" STR(t1) ", $" STR(t2) "" "\n" + + "\t" "\t" "mtbpc $" STR(t1) "" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetDataValueBP" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Get the current value of the BPC + "\t" "\t" ".global GetBPC" "\n" + "\t" "\t" ".ent GetBPC" "\n" + "\t" "GetBPC:" "\n" + "\t" "\t" "sync.l" "\n" + "\t" "\t" "mfbpc $v0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end GetBPC" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set the current value of the BPC + "\t" "\t" ".global SetBPC" "\n" + "\t" "\t" ".ent SetBPC" "\n" + "\t" "SetBPC:" "\n" + "\t" "\t" "mtbpc $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetBPC" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Get the current value of the Instruction address register + "\t" "\t" ".global GetIAB" "\n" + "\t" "\t" ".ent GetIAB" "\n" + "\t" "GetIAB:" "\n" + "\t" "\t" "mfiab $v0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end GetIAB" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Get the current value of the Instruction address mask register + "\t" "\t" ".global GetIABM" "\n" + "\t" "\t" ".ent GetIABM" "\n" + "\t" "GetIABM:" "\n" + "\t" "\t" "mfiabm $v0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end GetIABM" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Get the current value of the data address register + "\t" "\t" ".global GetDAB" "\n" + "\t" "\t" ".ent GetDAB" "\n" + "\t" "GetDAB:" "\n" + "\t" "\t" "mfdab $v0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end GetDAB" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Get the current value of the data address mask register + "\t" "\t" ".global GetDABM" "\n" + "\t" "\t" ".ent GetDABM" "\n" + "\t" "GetDABM:" "\n" + "\t" "\t" "mfdabm $v0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end GetDABM" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Get the current value of the data value register + "\t" "\t" ".global GetDVB" "\n" + "\t" "\t" ".ent GetDVB" "\n" + "\t" "GetDVB:" "\n" + "\t" "\t" "mfdvb $v0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end GetDVB" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Get the current value of the data value mask register + "\t" "\t" ".global GetDVBM" "\n" + "\t" "\t" ".ent GetDVBM" "\n" + "\t" "GetDVBM:" "\n" + "\t" "\t" "mfdvbm $v0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end GetDVBM" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set the current value of the Instruction address register + "\t" "\t" ".global SetIAB" "\n" + "\t" "\t" ".ent SetIAB" "\n" + "\t" "SetIAB:" "\n" + "\t" "\t" "mtiab $a0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetIAB" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set the current value of the Instruction address mask register + "\t" "\t" ".global SetIABM" "\n" + "\t" "\t" ".ent SetIABM" "\n" + "\t" "SetIABM:" "\n" + "\t" "\t" "mtiabm $a0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetIABM" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set the current value of the data address register + "\t" "\t" ".global SetDAB" "\n" + "\t" "\t" ".ent SetDAB" "\n" + "\t" "SetDAB:" "\n" + "\t" "\t" "mtdab $a0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetDAB" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set the current value of the data address mask register + "\t" "\t" ".global SetDABM" "\n" + "\t" "\t" ".ent SetDABM" "\n" + "\t" "SetDABM:" "\n" + "\t" "\t" "mtdabm $a0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetDABM" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set the current value of the data value register + "\t" "\t" ".global SetDVB" "\n" + "\t" "\t" ".ent SetDVB" "\n" + "\t" "SetDVB:" "\n" + "\t" "\t" "mtdvb $a0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetDVB" "\n" + + "\t" "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + + // Set the current value of the data value mask register + "\t" "\t" ".global SetDVBM" "\n" + "\t" "\t" ".ent SetDVBM" "\n" + "\t" "SetDVBM:" "\n" + "\t" "\t" "mtdvbm $a0" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".end SetDVBM" "\n" + + "\t" "\t" ".set pop" "\n" +); diff --git a/ee/eedebug/src/ee_dbg_low.S b/ee/eedebug/src/ee_dbg_low.S deleted file mode 100644 index ffd321e9ace..00000000000 --- a/ee/eedebug/src/ee_dbg_low.S +++ /dev/null @@ -1,228 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2009, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - -/** - * @file - * EEDEBUG - EE debugging library. - * low-level EE "debug" helper functions. - */ - -#include -#include "eedebug_defs.h" - -#define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) -#include "as_reg_compat.h" - -.text - -.set push -.set noreorder -.set noat - -.ent ee_dbg_get_bpc -.global ee_dbg_get_bpc -ee_dbg_get_bpc: - mfbpc $v0 - sync.p - jr $ra - nop - -.end ee_dbg_get_bpc - -.global ee_dbg_get_iab -.ent ee_dbg_get_iab -ee_dbg_get_iab: - mfiab $v0 - sync.p - jr $ra - nop -.end ee_dbg_get_iab - -.global ee_dbg_get_iabm -.ent ee_dbg_get_iabm -ee_dbg_get_iabm: - mfiabm $v0 - sync.p - jr $ra - nop -.end ee_dbg_get_iabm - -.global ee_dbg_get_dab -.ent ee_dbg_get_dab -ee_dbg_get_dab: - mfdab $v0 - sync.p - jr $ra - nop -.end ee_dbg_get_dab - -.global ee_dbg_get_dabm -.ent ee_dbg_get_dabm -ee_dbg_get_dabm: - mfdabm $v0 - sync.p - jr $ra - nop -.end ee_dbg_get_dabm - -.global ee_dbg_get_dvb -.ent ee_dbg_get_dvb -ee_dbg_get_dvb: - mfdvb $v0 - sync.p - jr $ra - nop -.end ee_dbg_get_dvb - -.global ee_dbg_get_dvbm -.ent ee_dbg_get_dvbm -ee_dbg_get_dvbm: - mfdvbm $v0 - sync.p - jr $ra - nop -.end ee_dbg_get_dvbm - -.global ee_dbg_set_bpc -.ent ee_dbg_set_bpc -ee_dbg_set_bpc: - mtbpc $a0 - sync.p - jr $ra - nop -.end ee_dbg_set_bpc - -.global ee_dbg_set_iab -.ent ee_dbg_set_iab -ee_dbg_set_iab: - mtiab $a0 - sync.p - jr $ra - nop -.end ee_dbg_set_iab - -.global ee_dbg_set_iabm -.ent ee_dbg_set_iabm -ee_dbg_set_iabm: - mtiabm $a0 - sync.p - jr $ra - nop -.end ee_dbg_set_iabm - -.global ee_dbg_set_dab -.ent ee_dbg_set_dab -ee_dbg_set_dab: - mtdab $a0 - sync.p - jr $ra - nop -.end ee_dbg_set_dab - -.global ee_dbg_set_dabm -.ent ee_dbg_set_dabm -ee_dbg_set_dabm: - mtdabm $a0 - sync.p - jr $ra - nop -.end ee_dbg_set_dabm - -.global ee_dbg_set_dvb -.ent ee_dbg_set_dvb -ee_dbg_set_dvb: - mtdvb $a0 - sync.p - jr $ra - nop -.end ee_dbg_set_dvb - -.global ee_dbg_set_dvbm -.ent ee_dbg_set_dvbm -ee_dbg_set_dvbm: - mtdvbm $a0 - sync.p - jr $ra - nop -.end ee_dbg_set_dvbm - -.global _ee_dbg_set_bpda -.ent _ee_dbg_set_bpda -_ee_dbg_set_bpda: - - mfbpc $t0 - li $t1, (EE_BPC_BED) - mtbpc $t1 - sync.p - - mtdab $a0 - mtdabm $a1 - sync.p - - li $t1, ~(EE_BPC_DRE | EE_BPC_DWE | EE_BPC_DUE | EE_BPC_DSE | EE_BPC_DKE | EE_BPC_DXE | EE_BPC_DTE | EE_BPC_DWB | EE_BPC_DRB) - and $t0, $t0, $t1 - - li $t1, (EE_BPC_DTE) - or $t0, $t0, $t1 - or $t0, $t0, $a2 - mtbpc $t0 - sync.p - jr $ra - nop - -.end _ee_dbg_set_bpda - -.global _ee_dbg_set_bpdv -.ent _ee_dbg_set_bpdv -_ee_dbg_set_bpdv: - - mfbpc $t0 - li $t1, (EE_BPC_BED) - mtbpc $t1 - sync.p - - mtdvb $a0 - mtdvbm $a1 - sync.p - - li $t1, (EE_BPC_DVE | EE_BPC_DTE) - or $t0, $t0, $t1 - or $t0, $t0, $a2 - mtbpc $t0 - sync.p - jr $ra - nop - -.end _ee_dbg_set_bpdv - -.global _ee_dbg_set_bpx -.ent _ee_dbg_set_bpx -_ee_dbg_set_bpx: - - mfbpc $t0 - li $t1, (EE_BPC_BED) - mtbpc $t1 - sync.p - - mtiab $a0 - mtiabm $a1 - sync.p - - li $t1, (EE_BPC_IAE | EE_BPC_ITE) - or $t0, $t0, $t1 - or $t0, $t0, $a2 - mtbpc $t0 - sync.p - jr $ra - nop - -.end _ee_dbg_set_bpx - -.set pop diff --git a/ee/eedebug/src/ee_dbg_low.c b/ee/eedebug/src/ee_dbg_low.c new file mode 100644 index 00000000000..a25f9b01ad9 --- /dev/null +++ b/ee/eedebug/src/ee_dbg_low.c @@ -0,0 +1,376 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2009, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +/** + * @file + * EEDEBUG - EE debugging library. + * low-level EE "debug" helper functions. + */ + +#include +#include "eedebug_defs.h" + +#define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) +#include "as_reg_compat.h" + +#define STRINNER(x) #x +#define STR(x) STRINNER(x) + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".ent ee_dbg_get_bpc" "\n" + "\t" ".global ee_dbg_get_bpc" "\n" + "\t" "ee_dbg_get_bpc:" "\n" + "\t" "\t" "mfbpc $v0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end ee_dbg_get_bpc" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_get_iab" "\n" + "\t" ".ent ee_dbg_get_iab" "\n" + "\t" "ee_dbg_get_iab:" "\n" + "\t" "\t" "mfiab $v0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_get_iab" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_get_iabm" "\n" + "\t" ".ent ee_dbg_get_iabm" "\n" + "\t" "ee_dbg_get_iabm:" "\n" + "\t" "\t" "mfiabm $v0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_get_iabm" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_get_dab" "\n" + "\t" ".ent ee_dbg_get_dab" "\n" + "\t" "ee_dbg_get_dab:" "\n" + "\t" "\t" "mfdab $v0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_get_dab" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_get_dabm" "\n" + "\t" ".ent ee_dbg_get_dabm" "\n" + "\t" "ee_dbg_get_dabm:" "\n" + "\t" "\t" "mfdabm $v0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_get_dabm" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_get_dvb" "\n" + "\t" ".ent ee_dbg_get_dvb" "\n" + "\t" "ee_dbg_get_dvb:" "\n" + "\t" "\t" "mfdvb $v0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_get_dvb" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_get_dvbm" "\n" + "\t" ".ent ee_dbg_get_dvbm" "\n" + "\t" "ee_dbg_get_dvbm:" "\n" + "\t" "\t" "mfdvbm $v0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_get_dvbm" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_set_bpc" "\n" + "\t" ".ent ee_dbg_set_bpc" "\n" + "\t" "ee_dbg_set_bpc:" "\n" + "\t" "\t" "mtbpc $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_set_bpc" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_set_iab" "\n" + "\t" ".ent ee_dbg_set_iab" "\n" + "\t" "ee_dbg_set_iab:" "\n" + "\t" "\t" "mtiab $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_set_iab" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_set_iabm" "\n" + "\t" ".ent ee_dbg_set_iabm" "\n" + "\t" "ee_dbg_set_iabm:" "\n" + "\t" "\t" "mtiabm $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_set_iabm" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_set_dab" "\n" + "\t" ".ent ee_dbg_set_dab" "\n" + "\t" "ee_dbg_set_dab:" "\n" + "\t" "\t" "mtdab $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_set_dab" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_set_dabm" "\n" + "\t" ".ent ee_dbg_set_dabm" "\n" + "\t" "ee_dbg_set_dabm:" "\n" + "\t" "\t" "mtdabm $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_set_dabm" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_set_dvb" "\n" + "\t" ".ent ee_dbg_set_dvb" "\n" + "\t" "ee_dbg_set_dvb:" "\n" + "\t" "\t" "mtdvb $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_set_dvb" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global ee_dbg_set_dvbm" "\n" + "\t" ".ent ee_dbg_set_dvbm" "\n" + "\t" "ee_dbg_set_dvbm:" "\n" + "\t" "\t" "mtdvbm $a0" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end ee_dbg_set_dvbm" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global _ee_dbg_set_bpda" "\n" + "\t" ".ent _ee_dbg_set_bpda" "\n" + "\t" "_ee_dbg_set_bpda:" "\n" + + "\t" "\t" "mfbpc $" STR(t0) "\n" + "\t" "\t" "li $9, (" STR(EE_BPC_BED) ")" "\n" + "\t" "\t" "mtbpc $9" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "mtdab $a0" "\n" + "\t" "\t" "mtdabm $a1" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "li $9, ~(" STR(EE_BPC_DRE) " | " STR(EE_BPC_DWE) " | " STR(EE_BPC_DUE) " | " STR(EE_BPC_DSE) " | " STR(EE_BPC_DKE) " | " STR(EE_BPC_DXE) " | " STR(EE_BPC_DTE) " | " STR(EE_BPC_DWB) " | " STR(EE_BPC_DRB) ")" "\n" + "\t" "\t" "and $" STR(t0) ", $" STR(t0) ", $9" "\n" + + "\t" "\t" "li $9, (" STR(EE_BPC_DTE) ")" "\n" + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $9" "\n" + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $a2" "\n" + "\t" "\t" "mtbpc $" STR(t0) "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end _ee_dbg_set_bpda" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global _ee_dbg_set_bpdv" "\n" + "\t" ".ent _ee_dbg_set_bpdv" "\n" + "\t" "_ee_dbg_set_bpdv:" "\n" + + "\t" "\t" "mfbpc $" STR(t0) "\n" + "\t" "\t" "li $9, (" STR(EE_BPC_BED) ")" "\n" + "\t" "\t" "mtbpc $9" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "mtdvb $a0" "\n" + "\t" "\t" "mtdvbm $a1" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "li $9, (" STR(EE_BPC_DVE) " | " STR(EE_BPC_DTE) ")" "\n" + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $9" "\n" + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $a2" "\n" + "\t" "\t" "mtbpc $" STR(t0) "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end _ee_dbg_set_bpdv" "\n" + + "\t" " .set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global _ee_dbg_set_bpx" "\n" + "\t" ".ent _ee_dbg_set_bpx" "\n" + "\t" "_ee_dbg_set_bpx:" "\n" + + "\t" "\t" "mfbpc $" STR(t0) "\n" + "\t" "\t" "li $9, (" STR(EE_BPC_BED) ")" "\n" + "\t" "\t" "mtbpc $9" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "mtiab $a0" "\n" + "\t" "\t" "mtiabm $a1" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "li $9, (" STR(EE_BPC_IAE) " | " STR(EE_BPC_ITE) ")" "\n" + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $9" "\n" + "\t" "\t" "or $" STR(t0) ", $" STR(t0) ", $a2" "\n" + "\t" "\t" "mtbpc $" STR(t0) "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end _ee_dbg_set_bpx" "\n" + + "\t" ".set pop" "\n" +); diff --git a/ee/eedebug/src/ee_exceptions.S b/ee/eedebug/src/ee_exceptions.S deleted file mode 100644 index d4d59e52404..00000000000 --- a/ee/eedebug/src/ee_exceptions.S +++ /dev/null @@ -1,313 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2009, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - -/** - * @file - * EEDEBUG - EE debugging library. - * low-level EE exception-handler code. - */ - -#include -#include "eedebug_defs.h" - -#define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) -#include "as_reg_compat.h" - -.text - -.set push -.set noreorder - -.local _ee_save_frame -.ent _ee_save_frame -_ee_save_frame: - sq $zero, 0x000($s0) -.set push -.set noat - sq $at, 0x010($s0) -.set pop - sq $v0, 0x020($s0) - sq $v1, 0x030($s0) - sq $a0, 0x040($s0) - sq $a1, 0x050($s0) - sq $a2, 0x060($s0) - sq $a3, 0x070($s0) - sq $t0, 0x080($s0) - sq $t1, 0x090($s0) - sq $t2, 0x0A0($s0) - sq $t3, 0x0B0($s0) - sq $t4, 0x0C0($s0) - sq $t5, 0x0D0($s0) - sq $t6, 0x0E0($s0) - sq $t7, 0x0F0($s0) -# sq $s0, 0x100($s0) # s0 already saved - sq $s1, 0x110($s0) - sq $s2, 0x120($s0) - sq $s3, 0x130($s0) - sq $s4, 0x140($s0) - sq $s5, 0x150($s0) - sq $s6, 0x160($s0) - sq $s7, 0x170($s0) - - sq $t8, 0x180($s0) - sq $t9, 0x190($s0) - -# sq $k0, 0x1A0($s0) - sq $k1, 0x1B0($s0) - - sq $gp, 0x1C0($s0) -# sq $sp, 0x1D0($s0) - sq $fp, 0x1E0($s0) - -# sq $ra, 0x1F0($s0) - - mfc0 $t1, EE_COP0_Status - sw $t1, 0x200($s0) - - mfc0 $t1, EE_COP0_Cause - sw $t1, 0x204($s0) - - mfc0 $t1, EE_COP0_EPC - sw $t1, 0x208($s0) - - mfc0 $t1, EE_COP0_ErrorEPC - sw $t1, 0x20C($s0) - - mfc0 $t1, EE_COP0_BadVAddr - sw $t1, 0x210($s0) - - mfhi $t1 - sw $t1, 0x214($s0) - - mfhi1 $t1 - sw $t1, 0x218($s0) - - mflo $t1 - sw $t1, 0x21C($s0) - - mflo1 $t1 - sw $t1, 0x220($s0) - - mfsa $t1 - sw $t1, 0x224($s0) - - mfbpc $t1 - sw $t1, 0x228($s0) - sync.l - - li $t1, EE_BPC_BED - mtbpc $t1 - - mfiab $t1 - sw $t1, 0x22C($s0) - - mfiabm $t1 - sw $t1, 0x230($s0) - - mfdab $t1 - sw $t1, 0x234($s0) - - mfdabm $t1 - sw $t1, 0x238($s0) - - mfdvb $t1 - sw $t1, 0x23C($s0) - - mfdvbm $t1 - sw $t1, 0x240($s0) - - jr $ra - nop -.end _ee_save_frame - -.global _ee_load_frame -.ent _ee_load_frame -_ee_load_frame: - lq $zero, 0x000($s0) -.set push -.set noat - lq $at, 0x010($s0) -.set pop - - lq $v0, 0x020($s0) - lq $v1, 0x030($s0) - lq $a0, 0x040($s0) - lq $a1, 0x050($s0) - lq $a2, 0x060($s0) - lq $a3, 0x070($s0) - lq $t1, 0x090($s0) - lq $t2, 0x0A0($s0) - lq $t3, 0x0B0($s0) - lq $t4, 0x0C0($s0) - lq $t5, 0x0D0($s0) - lq $t6, 0x0E0($s0) - lq $t7, 0x0F0($s0) -# lq $s0, 0x100($s0) - lq $s1, 0x110($s0) - lq $s2, 0x120($s0) - lq $s3, 0x130($s0) - lq $s4, 0x140($s0) - lq $s5, 0x150($s0) - lq $s6, 0x160($s0) - lq $s7, 0x170($s0) - - lq $t8, 0x180($s0) - lq $t9, 0x190($s0) - - lq $k0, 0x1A0($s0) - lq $k1, 0x1B0($s0) - - lq $gp, 0x1C0($s0) - lq $sp, 0x1D0($s0) - lq $fp, 0x1E0($s0) -# lq $ra, 0x1F0($s0) - - lw $t0, 0x200($s0) - mtc0 $t0, EE_COP0_Status - - lw $t0, 0x204($s0) - mtc0 $t0, EE_COP0_Cause - - lw $t0, 0x208($s0) - mtc0 $t0, EE_COP0_EPC - - lw $t0, 0x20C($s0) - mtc0 $t0, EE_COP0_ErrorEPC - - lw $t0, 0x210($s0) - mtc0 $t0, EE_COP0_BadVAddr - - lw $t0, 0x214($s0) - mthi $t0 - - lw $t0, 0x218($s0) - mthi $t0 - - lw $t0, 0x21C($s0) - mtlo $t0 - - lw $t0, 0x220($s0) - mtlo1 $t0 - - lw $t0, 0x224($s0) - mtsa $t0 - - lw $t0, 0x22C($s0) - mtiab $t0 - - lw $t0, 0x230($s0) - mtiabm $t0 - - lw $t0, 0x234($s0) - mtdab $t0 - - lw $t0, 0x238($s0) - mtdabm $t0 - - lw $t0, 0x23C($s0) - mtdvb $t0 - - lw $t0, 0x240($s0) - mtdvbm $t0 - sync.p - - lw $t0, 0x228($s0) - mtbpc $t0 - sync.p - - jr $ra - lq $t0, 0x080($s0) -.end _ee_load_frame - -.global __ee_level2_ex_vector -.ent __ee_level2_ex_vector -__ee_level2_ex_vector: - nop - nop - nop - j __ee_level2_ex_handler - nop - nop - nop - nop - -.end __ee_level2_ex_vector - -.global __ee_level1_ex_vector -.ent __ee_level1_ex_vector -__ee_level1_ex_vector: - nop - nop - la $k0, __ee_ex_l1_frame - sq $s0, 0x100($k0) # save s0 - sq $zero, 0x1A0($k0) # k0 is not preserved in l1 exceptions - sq $sp, 0x1D0($k0) # save sp - sq $ra, 0x1F0($k0) # save ra - - la $sp, __ee_ex_l1_stack + (_EX_L1_STACK_SIZE) - move $s0, $k0 - - jal _ee_save_frame - nop - - jal ee_level1_ex_dispatcher - move $a0, $s0 - - jal _ee_load_frame - nop - - lq $ra, 0x1F0($s0) - lq $s0, 0x100($s0) - sync.l - - eret - nop - nop -.end __ee_level1_ex_vector - - -.global __ee_level2_ex_handler -.ent __ee_level2_ex_handler -__ee_level2_ex_handler: - nop - nop - sq $k0, -0x20($0) # preserve k0 - la $k0, __ee_ex_l2_frame - sq $s0, 0x100($k0) # save s0 - sq $sp, 0x1D0($k0) # save sp - lq $sp, -0x20($0) - sq $sp, 0x1A0($k0) # save k0 - sq $ra, 0x1F0($k0) # save ra - - la $sp, __ee_ex_l2_stack + (_EX_L2_STACK_SIZE) - move $s0, $k0 - - jal _ee_save_frame - nop - - jal ee_level2_ex_dispatcher - move $a0, $s0 - - jal _ee_load_frame - nop - - lq $ra, 0x1F0($s0) - lq $s0, 0x100($s0) - sync.l - - eret - nop - nop - -.end __ee_level2_ex_handler - -.balign 128 - -.set pop diff --git a/ee/eedebug/src/ee_exceptions.c b/ee/eedebug/src/ee_exceptions.c new file mode 100644 index 00000000000..f5e3b5cd270 --- /dev/null +++ b/ee/eedebug/src/ee_exceptions.c @@ -0,0 +1,346 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2009, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +/** + * @file + * EEDEBUG - EE debugging library. + * low-level EE exception-handler code. + */ + +#include +#include "eedebug_defs.h" + +#define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) +#include "as_reg_compat.h" + +#define STRINNER(x) #x +#define STR(x) STRINNER(x) + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".local _ee_save_frame" "\n" + "\t" ".ent _ee_save_frame" "\n" + "\t" "_ee_save_frame:" "\n" + "\t" "\t" "sq $zero, 0x000($s0)" "\n" + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" "\t" "sq $at, 0x010($s0)" "\n" + "\t" ".set pop" "\n" + "\t" "\t" "sq $v0, 0x020($s0)" "\n" + "\t" "\t" "sq $v1, 0x030($s0)" "\n" + "\t" "\t" "sq $a0, 0x040($s0)" "\n" + "\t" "\t" "sq $a1, 0x050($s0)" "\n" + "\t" "\t" "sq $a2, 0x060($s0)" "\n" + "\t" "\t" "sq $a3, 0x070($s0)" "\n" + "\t" "\t" "sq $" STR(t0) ", 0x080($s0)" "\n" + "\t" "\t" "sq $" STR(t1) ", 0x090($s0)" "\n" + "\t" "\t" "sq $" STR(t2) ", 0x0A0($s0)" "\n" + "\t" "\t" "sq $" STR(t3) ", 0x0B0($s0)" "\n" + "\t" "\t" "sq $" STR(t4) ", 0x0C0($s0)" "\n" + "\t" "\t" "sq $" STR(t5) ", 0x0D0($s0)" "\n" + "\t" "\t" "sq $" STR(t6) ", 0x0E0($s0)" "\n" + "\t" "\t" "sq $" STR(t7) ", 0x0F0($s0)" "\n" + // "\t" "\t" "sq $s0, 0x100($s0)" "\n" // s0 already saved + "\t" "\t" "sq $s1, 0x110($s0)" "\n" + "\t" "\t" "sq $s2, 0x120($s0)" "\n" + "\t" "\t" "sq $s3, 0x130($s0)" "\n" + "\t" "\t" "sq $s4, 0x140($s0)" "\n" + "\t" "\t" "sq $s5, 0x150($s0)" "\n" + "\t" "\t" "sq $s6, 0x160($s0)" "\n" + "\t" "\t" "sq $s7, 0x170($s0)" "\n" + + "\t" "\t" "sq $t8, 0x180($s0)" "\n" + "\t" "\t" "sq $t9, 0x190($s0)" "\n" + + // "\t" "\t" "sq $k0, 0x1A0($s0)" "\n" + "\t" "\t" "sq $k1, 0x1B0($s0)" "\n" + + "\t" "\t" "sq $gp, 0x1C0($s0)" "\n" + // "\t" "\t" "sq $sp, 0x1D0($s0)" "\n" + "\t" "\t" "sq $fp, 0x1E0($s0)" "\n" + + // "\t" "\t" "sq $ra, 0x1F0($s0)" "\n" + + "\t" "\t" "mfc0 $" STR(t1) ", " STR(EE_COP0_Status) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x200($s0)" "\n" + + "\t" "\t" "mfc0 $" STR(t1) ", " STR(EE_COP0_Cause) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x204($s0)" "\n" + + "\t" "\t" "mfc0 $" STR(t1) ", " STR(EE_COP0_EPC) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x208($s0)" "\n" + + "\t" "\t" "mfc0 $" STR(t1) ", " STR(EE_COP0_ErrorEPC) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x20C($s0)" "\n" + + "\t" "\t" "mfc0 $" STR(t1) ", " STR(EE_COP0_BadVAddr) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x210($s0)" "\n" + + "\t" "\t" "mfhi $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x214($s0)" "\n" + + "\t" "\t" "mfhi1 $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x218($s0)" "\n" + + "\t" "\t" "mflo $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x21C($s0)" "\n" + + "\t" "\t" "mflo1 $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x220($s0)" "\n" + + "\t" "\t" "mfsa $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x224($s0)" "\n" + + "\t" "\t" "mfbpc $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x228($s0)" "\n" + "\t" "\t" "sync.l" "\n" + + "\t" "\t" "li $" STR(t1) ", " STR(EE_BPC_BED) "" "\n" + "\t" "\t" "mtbpc $" STR(t1) "" "\n" + + "\t" "\t" "mfiab $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x22C($s0)" "\n" + + "\t" "\t" "mfiabm $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x230($s0)" "\n" + + "\t" "\t" "mfdab $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x234($s0)" "\n" + + "\t" "\t" "mfdabm $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x238($s0)" "\n" + + "\t" "\t" "mfdvb $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x23C($s0)" "\n" + + "\t" "\t" "mfdvbm $" STR(t1) "" "\n" + "\t" "\t" "sw $" STR(t1) ", 0x240($s0)" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end _ee_save_frame" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".global _ee_load_frame" "\n" + "\t" ".ent _ee_load_frame" "\n" + "\t" "_ee_load_frame:" "\n" + "\t" "\t" "lq $zero, 0x000($s0)" "\n" + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" "\t" "lq $at, 0x010($s0)" "\n" + "\t" ".set pop" "\n" + + "\t" "\t" "lq $v0, 0x020($s0)" "\n" + "\t" "\t" "lq $v1, 0x030($s0)" "\n" + "\t" "\t" "lq $a0, 0x040($s0)" "\n" + "\t" "\t" "lq $a1, 0x050($s0)" "\n" + "\t" "\t" "lq $a2, 0x060($s0)" "\n" + "\t" "\t" "lq $a3, 0x070($s0)" "\n" + "\t" "\t" "lq $" STR(t1) ", 0x090($s0)" "\n" + "\t" "\t" "lq $" STR(t2) ", 0x0A0($s0)" "\n" + "\t" "\t" "lq $" STR(t3) ", 0x0B0($s0)" "\n" + "\t" "\t" "lq $" STR(t4) ", 0x0C0($s0)" "\n" + "\t" "\t" "lq $" STR(t5) ", 0x0D0($s0)" "\n" + "\t" "\t" "lq $" STR(t6) ", 0x0E0($s0)" "\n" + "\t" "\t" "lq $" STR(t7) ", 0x0F0($s0)" "\n" + // "\t" "\t" "lq $s0, 0x100($s0)" "\n" + "\t" "\t" "lq $s1, 0x110($s0)" "\n" + "\t" "\t" "lq $s2, 0x120($s0)" "\n" + "\t" "\t" "lq $s3, 0x130($s0)" "\n" + "\t" "\t" "lq $s4, 0x140($s0)" "\n" + "\t" "\t" "lq $s5, 0x150($s0)" "\n" + "\t" "\t" "lq $s6, 0x160($s0)" "\n" + "\t" "\t" "lq $s7, 0x170($s0)" "\n" + + "\t" "\t" "lq $t8, 0x180($s0)" "\n" + "\t" "\t" "lq $t9, 0x190($s0)" "\n" + + "\t" "\t" "lq $k0, 0x1A0($s0)" "\n" + "\t" "\t" "lq $k1, 0x1B0($s0)" "\n" + + "\t" "\t" "lq $gp, 0x1C0($s0)" "\n" + "\t" "\t" "lq $sp, 0x1D0($s0)" "\n" + "\t" "\t" "lq $fp, 0x1E0($s0)" "\n" + // "\t" "\t" "lq $ra, 0x1F0($s0)" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x200($s0)" "\n" + "\t" "\t" "mtc0 $" STR(t0) ", " STR(EE_COP0_Status) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x204($s0)" "\n" + "\t" "\t" "mtc0 $" STR(t0) ", " STR(EE_COP0_Cause) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x208($s0)" "\n" + "\t" "\t" "mtc0 $" STR(t0) ", " STR(EE_COP0_EPC) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x20C($s0)" "\n" + "\t" "\t" "mtc0 $" STR(t0) ", " STR(EE_COP0_ErrorEPC) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x210($s0)" "\n" + "\t" "\t" "mtc0 $" STR(t0) ", " STR(EE_COP0_BadVAddr) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x214($s0)" "\n" + "\t" "\t" "mthi $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x218($s0)" "\n" + "\t" "\t" "mthi $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x21C($s0)" "\n" + "\t" "\t" "mtlo $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x220($s0)" "\n" + "\t" "\t" "mtlo1 $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x224($s0)" "\n" + "\t" "\t" "mtsa $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x22C($s0)" "\n" + "\t" "\t" "mtiab $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x230($s0)" "\n" + "\t" "\t" "mtiabm $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x234($s0)" "\n" + "\t" "\t" "mtdab $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x238($s0)" "\n" + "\t" "\t" "mtdabm $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x23C($s0)" "\n" + "\t" "\t" "mtdvb $" STR(t0) "" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x240($s0)" "\n" + "\t" "\t" "mtdvbm $" STR(t0) "" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "lw $" STR(t0) ", 0x228($s0)" "\n" + "\t" "\t" "mtbpc $" STR(t0) "" "\n" + "\t" "\t" "sync.p" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "lq $" STR(t0) ", 0x080($s0)" "\n" + "\t" ".end _ee_load_frame" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".global __ee_level2_ex_vector" "\n" + "\t" ".ent __ee_level2_ex_vector" "\n" + "\t" "__ee_level2_ex_vector:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "j __ee_level2_ex_handler" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end __ee_level2_ex_vector" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".global __ee_level1_ex_vector" "\n" + "\t" ".ent __ee_level1_ex_vector" "\n" + "\t" "__ee_level1_ex_vector:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "la $k0, __ee_ex_l1_frame" "\n" + "\t" "\t" "sq $s0, 0x100($k0)" "\n" // save s0 + "\t" "\t" "sq $zero, 0x1A0($k0)" "\n" // k0 is not preserved in l1 exceptions + "\t" "\t" "sq $sp, 0x1D0($k0)" "\n" // save sp + "\t" "\t" "sq $ra, 0x1F0($k0)" "\n" // save ra + + "\t" "\t" "la $sp, __ee_ex_l1_stack + (" STR(_EX_L1_STACK_SIZE) ")" "\n" + "\t" "\t" "move $s0, $k0" "\n" + + "\t" "\t" "jal _ee_save_frame" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "jal ee_level1_ex_dispatcher" "\n" + "\t" "\t" "move $a0, $s0" "\n" + + "\t" "\t" "jal _ee_load_frame" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "lq $ra, 0x1F0($s0)" "\n" + "\t" "\t" "lq $s0, 0x100($s0)" "\n" + "\t" "\t" "sync.l" "\n" + + "\t" "\t" "eret" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end __ee_level1_ex_vector" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".global __ee_level2_ex_handler" "\n" + "\t" ".ent __ee_level2_ex_handler" "\n" + "\t" "__ee_level2_ex_handler:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "sq $k0, -0x20($0)" "\n" // preserve k0 + "\t" "\t" "la $k0, __ee_ex_l2_frame" "\n" + "\t" "\t" "sq $s0, 0x100($k0)" "\n" // save s0 + "\t" "\t" "sq $sp, 0x1D0($k0)" "\n" // save sp + "\t" "\t" "lq $sp, -0x20($0)" "\n" + "\t" "\t" "sq $sp, 0x1A0($k0)" "\n" // save k0 + "\t" "\t" "sq $ra, 0x1F0($k0)" "\n" // save ra + + "\t" "\t" "la $sp, __ee_ex_l2_stack + (" STR(_EX_L2_STACK_SIZE) ")" "\n" + "\t" "\t" "move $s0, $k0" "\n" + + "\t" "\t" "jal _ee_save_frame" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "jal ee_level2_ex_dispatcher" "\n" + "\t" "\t" "move $a0, $s0" "\n" + + "\t" "\t" "jal _ee_load_frame" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "lq $ra, 0x1F0($s0)" "\n" + "\t" "\t" "lq $s0, 0x100($s0)" "\n" + "\t" "\t" "sync.l" "\n" + + "\t" "\t" "eret" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end __ee_level2_ex_handler" "\n" + + "\t" ".set pop" "\n" +); diff --git a/ee/kernel/Makefile b/ee/kernel/Makefile index f073a8ae902..22d50c12bff 100644 --- a/ee/kernel/Makefile +++ b/ee/kernel/Makefile @@ -233,7 +233,7 @@ include $(PS2SDKSRC)/ee/Rules.lib.make include $(PS2SDKSRC)/ee/Rules.make include $(PS2SDKSRC)/ee/Rules.release -$(KERNEL_OBJS:%=$(EE_OBJS_DIR)%): $(EE_SRC_DIR)kernel.S +$(KERNEL_OBJS:%=$(EE_OBJS_DIR)%): $(EE_SRC_DIR)kernel.c $(DIR_GUARD) $(EE_C_COMPILE) -DF_$(*:$(EE_OBJS_DIR)%=%) $< -c -o $@ @@ -329,7 +329,7 @@ $(EE_OBJS_DIR)osdsrc_bin.o: $(EE_OBJS_DIR)osdsrc_bin.c $(DIR_GUARD) $(EE_C_COMPILE) -I$(PS2SDKSRC)/ee/rpc/cdvd/include $< -c -o $@ -$(EE_OBJS_DIR)libosd_syscalls.o: $(EE_SRC_DIR)libosd_syscalls.S +$(EE_OBJS_DIR)libosd_syscalls.o: $(EE_SRC_DIR)libosd_syscalls.c $(DIR_GUARD) $(EE_C_COMPILE) -I$(PS2SDKSRC)/ee/rpc/cdvd/include $< -c -o $@ diff --git a/ee/kernel/src/eenull/src/eenull.c b/ee/kernel/src/eenull/src/eenull.c new file mode 100644 index 00000000000..630187221f3 --- /dev/null +++ b/ee/kernel/src/eenull/src/eenull.c @@ -0,0 +1,30 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +// Will be executed in user mode, but with interrupts disabled. +// Set stack address to 0x00081fc0. This is meant to be the replacement for the built-in dispatcher, +// which also shares the same stack. + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl UModeCallbackDispatcher" "\n" + "\t" ".ent UModeCallbackDispatcher" "\n" + "\t" "UModeCallbackDispatcher:" "\n" + "\t" "\t" "lui $sp, 0x0008" "\n" + "\t" "\t" "jalr $v1" "\n" + "\t" "\t" "addiu $sp, $sp, 0x1fc0" "\n" + "\t" "\t" "addiu $v1, $zero, -8" "\n" + "\t" "\t" "syscall" "\n" + "\t" ".end UModeCallbackDispatcher" "\n" + + "\t" ".set pop" "\n" +); diff --git a/ee/kernel/src/eenull/src/eenull.s b/ee/kernel/src/eenull/src/eenull.s deleted file mode 100644 index d1e8d82d5f7..00000000000 --- a/ee/kernel/src/eenull/src/eenull.s +++ /dev/null @@ -1,26 +0,0 @@ -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. - -.set push -.set noreorder - -#Will be executed in user mode, but with interrupts disabled. -#Set stack address to 0x00081fc0. This is meant to be the replacement for the built-in dispatcher, -#which also shares the same stack. - -.globl UModeCallbackDispatcher -.ent UModeCallbackDispatcher -UModeCallbackDispatcher: - lui $sp, 0x0008 - jalr $v1 - addiu $sp, $sp, 0x1fc0 - addiu $v1, $zero, -8 - syscall -.end UModeCallbackDispatcher -.p2align 4 - -.set pop diff --git a/ee/kernel/src/kernel.S b/ee/kernel/src/kernel.S deleted file mode 100644 index b95ba4b1ba6..00000000000 --- a/ee/kernel/src/kernel.S +++ /dev/null @@ -1,1515 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# (C)2001, Gustavo Scotti (gustavo@scotti.com) -# (c) 2003 Marcus R. Brown (mrbrown@0xd6.org) -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - -/** - * @file - * EE Kernel functions - */ - -#include - - .text - .p2align 3 - -#define SYSCALL(name) \ - SYSCALL_SPECIAL(name, name) - -#ifdef USE_KMODE -#define SYSCALL_SPECIAL(symbol, name) \ - .set push; \ - .set noreorder; \ - .text; \ - .align 4; \ - .globl symbol; \ - .type symbol,@function; \ - .ent symbol,0; \ -symbol: j __syscall; \ - li $3, __NR_##name;\ - nop; \ - .end symbol; \ - .size symbol,.-symbol; \ - .set pop; -#else -#define SYSCALL_SPECIAL(symbol, name) \ - .set push; \ - .set noreorder; \ - .text; \ - .align 4; \ - .globl symbol; \ - .type symbol,@function; \ - .ent symbol,0; \ -symbol: li $3, __NR_##name;\ - syscall; \ - jr $31; \ - nop; \ - .end symbol; \ - .size symbol,.-symbol; \ - .set pop; -#endif - -#ifdef F___syscall -.set push -.set noreorder -.text -.align 4 -.globl __syscall -.type __syscall,@function -.ent __syscall,0 -__syscall: - mfc0 $2, $12 - andi $2, $2, 0x18 - beqz $2, _kMode - slt $2, $3, $0 - syscall - jr $31 - nop -_kMode: - subu $26, $0, $3 - movn $3, $26, $2 - sll $3, $3, 2 - lui $26, 0x8000 - lhu $2, 0x02F0($26) - sll $2, $2, 16 - lh $26, 0x02F8($26) - add $2, $26 - addu $3, $2 - lw $26, 0x00($3) - jr $26 - nop -.end __syscall -.size __syscall,.-__syscall -.set pop -#endif - -#ifdef F_ResetEE -SYSCALL(ResetEE) -#endif - -#ifdef F_SetGsCrt -SYSCALL(SetGsCrt) -#endif - -#ifdef F_KExit -SYSCALL(KExit) -#endif - -#ifdef F__LoadExecPS2 -SYSCALL(_LoadExecPS2) -#endif - -#ifdef F__ExecPS2 -SYSCALL(_ExecPS2) -#endif - -#ifdef F_RFU009 -SYSCALL(RFU009) -#endif - -#ifdef F_AddSbusIntcHandler -SYSCALL(AddSbusIntcHandler) -#endif - -#ifdef F_RemoveSbusIntcHandler -SYSCALL(RemoveSbusIntcHandler) -#endif - -#ifdef F_Interrupt2Iop -SYSCALL(Interrupt2Iop) -#endif - -#ifdef F_SetVTLBRefillHandler -SYSCALL(SetVTLBRefillHandler) -#endif - -#ifdef F_SetVCommonHandler -SYSCALL(SetVCommonHandler) -#endif - -#ifdef F_SetVInterruptHandler -SYSCALL(SetVInterruptHandler) -#endif - -#ifdef F_AddIntcHandler -SYSCALL(AddIntcHandler) -#endif - -#ifdef F_AddIntcHandler2 -SYSCALL(AddIntcHandler2) -#endif - -#ifdef F_RemoveIntcHandler -SYSCALL(RemoveIntcHandler) -#endif - -#ifdef F_AddDmacHandler -SYSCALL(AddDmacHandler) -#endif - -#ifdef F_AddDmacHandler2 -SYSCALL(AddDmacHandler2) -#endif - -#ifdef F_RemoveDmacHandler -SYSCALL(RemoveDmacHandler) -#endif - -#ifdef F__EnableIntc -SYSCALL(_EnableIntc) -#endif - -#ifdef F__DisableIntc -SYSCALL(_DisableIntc) -#endif - -#ifdef F__EnableDmac -SYSCALL(_EnableDmac) -#endif - -#ifdef F__DisableDmac -SYSCALL(_DisableDmac) -#endif - -#ifdef F__SetAlarm -SYSCALL(_SetAlarm) -#endif - -#ifdef F_SetAlarm -SYSCALL(SetAlarm) -#endif - -#ifdef F__ReleaseAlarm -SYSCALL(_ReleaseAlarm) -#endif - -#ifdef F_ReleaseAlarm -SYSCALL(ReleaseAlarm) -#endif - -#ifdef F__iEnableIntc -SYSCALL(_iEnableIntc) -#endif - -#ifdef F__iDisableIntc -SYSCALL(_iDisableIntc) -#endif - -#ifdef F__iEnableDmac -SYSCALL(_iEnableDmac) -#endif - -#ifdef F__iDisableDmac -SYSCALL(_iDisableDmac) -#endif - -#ifdef F__iSetAlarm -SYSCALL(_iSetAlarm) -#endif - -#ifdef F_iSetAlarm -SYSCALL(iSetAlarm) -#endif - -#ifdef F__iReleaseAlarm -SYSCALL(_iReleaseAlarm) -#endif - -#ifdef F_iReleaseAlarm -SYSCALL(iReleaseAlarm) -#endif - -#ifdef F_CreateThread -SYSCALL(CreateThread) -#endif - -#ifdef F_DeleteThread -SYSCALL(DeleteThread) -#endif - -#ifdef F_StartThread -SYSCALL(StartThread) -#endif - -#ifdef F_ExitThread -SYSCALL(ExitThread) -#endif - -#ifdef F_ExitDeleteThread -SYSCALL(ExitDeleteThread) -#endif - -#ifdef F_TerminateThread -SYSCALL(TerminateThread) -#endif - -#ifdef F_iTerminateThread -SYSCALL(iTerminateThread) -#endif - -#ifdef F_DisableDispatchThread -SYSCALL(DisableDispatchThread) -#endif - -#ifdef F_EnableDispatchThread -SYSCALL(EnableDispatchThread) -#endif - -#ifdef F_ChangeThreadPriority -SYSCALL(ChangeThreadPriority) -#endif - -#ifdef F_iChangeThreadPriority -SYSCALL(iChangeThreadPriority) -#endif - -#ifdef F_RotateThreadReadyQueue -SYSCALL(RotateThreadReadyQueue) -#endif - -#ifdef F__iRotateThreadReadyQueue -SYSCALL(_iRotateThreadReadyQueue) -#endif - -#ifdef F_ReleaseWaitThread -SYSCALL(ReleaseWaitThread) -#endif - -#ifdef F_iReleaseWaitThread -SYSCALL(iReleaseWaitThread) -#endif - -#ifdef F_GetThreadId -SYSCALL(GetThreadId) -#endif - -#ifdef F__iGetThreadId -SYSCALL(_iGetThreadId) -#endif - -#ifdef F_ReferThreadStatus -SYSCALL(ReferThreadStatus) -#endif - -#ifdef F_iReferThreadStatus -SYSCALL(iReferThreadStatus) -#endif - -#ifdef F_SleepThread -SYSCALL(SleepThread) -#endif - -#ifdef F_WakeupThread -SYSCALL(WakeupThread) -#endif - -#ifdef F__iWakeupThread -SYSCALL(_iWakeupThread) -#endif - -#ifdef F_CancelWakeupThread -SYSCALL(CancelWakeupThread) -#endif - -#ifdef F_iCancelWakeupThread -SYSCALL(iCancelWakeupThread) -#endif - -#ifdef F_SuspendThread -SYSCALL(SuspendThread) -#endif - -#ifdef F__iSuspendThread -SYSCALL(_iSuspendThread) -#endif - -#ifdef F_ResumeThread -SYSCALL(ResumeThread) -#endif - -#ifdef F_iResumeThread -SYSCALL(iResumeThread) -#endif - -#ifdef F_RFU059 -SYSCALL(RFU059) -#endif - -#ifdef F_RFU060 -SYSCALL(RFU060) -#endif - -#ifdef F_SetupThread -SYSCALL(SetupThread) -#endif - -#ifdef F_RFU061 -SYSCALL(RFU061) -#endif - -#ifdef F_SetupHeap -SYSCALL(SetupHeap) -#endif - -#ifdef F_EndOfHeap -SYSCALL(EndOfHeap) -#endif - -#ifdef F_CreateSema -SYSCALL(CreateSema) -#endif - -#ifdef F_DeleteSema -SYSCALL(DeleteSema) -#endif - -#ifdef F_SignalSema -SYSCALL(SignalSema) -#endif - -#ifdef F_iSignalSema -SYSCALL(iSignalSema) -#endif - -#ifdef F_WaitSema -SYSCALL(WaitSema) -#endif - -#ifdef F_PollSema -SYSCALL(PollSema) -#endif - -#ifdef F_iPollSema -SYSCALL(iPollSema) -#endif - -#ifdef F_ReferSemaStatus -SYSCALL(ReferSemaStatus) -#endif - -#ifdef F_iReferSemaStatus -SYSCALL(iReferSemaStatus) -#endif - -#ifdef F_iDeleteSema -SYSCALL(iDeleteSema) -#endif - -#ifdef F_SetOsdConfigParam -SYSCALL(SetOsdConfigParam) -#endif - -#ifdef F_GetOsdConfigParam -SYSCALL(GetOsdConfigParam) -#endif - -#ifdef F_GetGsHParam -SYSCALL(GetGsHParam) -#endif - -#ifdef F_GetGsVParam -SYSCALL(GetGsVParam) -#endif - -#ifdef F_SetGsHParam -SYSCALL(SetGsHParam) -#endif - -#ifdef F_SetGsVParam -SYSCALL(SetGsVParam) -#endif - -#ifdef F_CreateEventFlag -SYSCALL(CreateEventFlag) -#endif - -#ifdef F_DeleteEventFlag -SYSCALL(DeleteEventFlag) -#endif - -#ifdef F_SetEventFlag -SYSCALL(SetEventFlag) -#endif - -#ifdef F_iSetEventFlag -SYSCALL(iSetEventFlag) -#endif - -#ifdef F_PutTLBEntry -SYSCALL(PutTLBEntry) -#endif - -#ifdef F_iPutTLBEntry -SYSCALL(iPutTLBEntry) -#endif - -#ifdef F__SetTLBEntry -SYSCALL(_SetTLBEntry) -#endif - -#ifdef F_iSetTLBEntry -SYSCALL(iSetTLBEntry) -#endif - -#ifdef F_GetTLBEntry -SYSCALL(GetTLBEntry) -#endif - -#ifdef F_iGetTLBEntry -SYSCALL(iGetTLBEntry) -#endif - -#ifdef F_ProbeTLBEntry -SYSCALL(ProbeTLBEntry) -#endif - -#ifdef F_iProbeTLBEntry -SYSCALL(iProbeTLBEntry) -#endif - -#ifdef F_ExpandScratchPad -SYSCALL(ExpandScratchPad) -#endif - -#ifdef F_EnableIntcHandler -SYSCALL(EnableIntcHandler) -#endif - -#ifdef F_iEnableIntcHandler -SYSCALL(iEnableIntcHandler) -#endif - -#ifdef F_DisableIntcHandler -SYSCALL(DisableIntcHandler) -#endif - -#ifdef F_iDisableIntcHandler -SYSCALL(iDisableIntcHandler) -#endif - -#ifdef F_EnableDmacHandler -SYSCALL(EnableDmacHandler) -#endif - -#ifdef F_iEnableDmacHandler -SYSCALL(iEnableDmacHandler) -#endif - -#ifdef F_DisableDmacHandler -SYSCALL(DisableDmacHandler) -#endif - -#ifdef F_iDisableDmacHandler -SYSCALL(iDisableDmacHandler) -#endif - -#ifdef F_KSeg0 -SYSCALL(KSeg0) -#endif - -#ifdef F_EnableCache -SYSCALL(EnableCache) -#endif - -#ifdef F_DisableCache -SYSCALL(DisableCache) -#endif - -#ifdef F_GetCop0 -SYSCALL(GetCop0) -#endif - -#ifdef F_FlushCache -SYSCALL(FlushCache) -#endif - -#ifdef F_CpuConfig -SYSCALL(CpuConfig) -#endif - -#ifdef F_iGetCop0 -SYSCALL(iGetCop0) -#endif - -#ifdef F_iFlushCache -SYSCALL(iFlushCache) -#endif - -#ifdef F_RFU105 -SYSCALL(RFU105) -#endif - -#ifdef F_iCpuConfig -SYSCALL(iCpuConfig) -#endif - -#ifdef F_sceSifStopDma -SYSCALL(sceSifStopDma) -#endif - -#ifdef F_SetCPUTimerHandler -SYSCALL(SetCPUTimerHandler) -#endif - -#ifdef F_SetCPUTimer -SYSCALL(SetCPUTimer) -#endif - -#ifdef F_SetOsdConfigParam2 -SYSCALL(SetOsdConfigParam2) -#endif - -#ifdef F_GetOsdConfigParam2 -SYSCALL(GetOsdConfigParam2) -#endif - -#ifdef F_GsGetIMR -SYSCALL(GsGetIMR) -#endif - -#ifdef F_iGsGetIMR -SYSCALL(iGsGetIMR) -#endif - -#ifdef F_GsPutIMR -SYSCALL(GsPutIMR) -#endif - -#ifdef F_iGsPutIMR -SYSCALL(iGsPutIMR) -#endif - -#ifdef F_SetPgifHandler -SYSCALL(SetPgifHandler) -#endif - -#ifdef F_SetVSyncFlag -SYSCALL(SetVSyncFlag) -#endif - -#ifdef F_SetSyscall -SYSCALL(SetSyscall) -#endif - -#ifdef F__print -SYSCALL(_print) -#endif - -#ifdef F_sceSifDmaStat -SYSCALL(sceSifDmaStat) -#endif - -#ifdef F_isceSifDmaStat -SYSCALL(isceSifDmaStat) -#endif - -#ifdef F_sceSifSetDma -SYSCALL(sceSifSetDma) -#endif - -#ifdef F_isceSifSetDma -SYSCALL(isceSifSetDma) -#endif - -#ifdef F_sceSifSetDChain -SYSCALL(sceSifSetDChain) -#endif - -#ifdef F_isceSifSetDChain -SYSCALL(isceSifSetDChain) -#endif - -#ifdef F_sceSifSetReg -SYSCALL(sceSifSetReg) -#endif - -#ifdef F_sceSifGetReg -SYSCALL(sceSifGetReg) -#endif - -#ifdef F__ExecOSD -SYSCALL(_ExecOSD) -#endif - -#ifdef F_Deci2Call -SYSCALL(Deci2Call) -#endif - -#ifdef F_PSMode -SYSCALL(PSMode) -#endif - -#ifdef F_MachineType -SYSCALL(MachineType) -#endif - -#ifdef F_GetMemorySize -SYSCALL(GetMemorySize) -#endif - -#ifdef F__GetGsDxDyOffset -SYSCALL(_GetGsDxDyOffset) -#endif - -#ifdef F__InitTLB -SYSCALL(_InitTLB) -#endif - -#ifdef F_SetMemoryMode -SYSCALL(SetMemoryMode) -#endif - -#ifdef F_GetMemoryMode -SYSCALL(GetMemoryMode) -#endif - -#ifdef F_GPfuncs - .text - .align 2 -.globl ChangeGP -.ent ChangeGP -ChangeGP: - move $v0, $gp - jr $ra - move $gp, $a0 -.end ChangeGP - -.globl SetGP -.ent SetGP -SetGP: - jr $ra - move $gp, $a0 -.end SetGP - -.globl GetGP -.ent GetGP -GetGP: - jr $ra - move $v0, $gp -.end GetGP -#endif - -#ifdef F_sceSifWriteBackDCache - - .globl sceSifWriteBackDCache - .ent sceSifWriteBackDCache - .set push - .set noreorder - -sceSifWriteBackDCache: /* DHWBIN: Data cache Hit WriteBack INvalidate. */ - - lui $25, 0xffff - ori $25, $25, 0xffc0 - blez $5, last - addu $10, $4, $5 - and $8, $4, $25 - addiu $10, $10, -1 - and $9, $10, $25 - subu $10, $9, $8 - srl $11, $10, 0x6 - addiu $11, $11, 1 - andi $9, $11, 0x7 - beqz $9, eight - srl $10, $11, 0x3 -loop1: - sync - cache 0x18, 0($8) - sync - addiu $9, $9, -1 - nop - bgtz $9, loop1 - addiu $8, $8, 64 - -eight: - beqz $10, last -loop8: - addiu $10, $10, -1 - sync - cache 0x18, 0($8) - sync - cache 0x18, 64($8) - sync - cache 0x18, 128($8) - sync - cache 0x18, 192($8) - sync - cache 0x18, 256($8) - sync - cache 0x18, 320($8) - sync - cache 0x18, 384($8) - sync - cache 0x18, 448($8) - sync - bgtz $10, loop8 - addiu $8, $8, 512 -last: - jr $31 - nop - - .set pop - .end sceSifWriteBackDCache -#endif - -#define DXWBIN 0x14 /* Data cache: indeX WriteBack INvalidate. */ -#define DXIN 0x16 /* Data cache: indeX INvalidate. */ - -#define opDCache(name, op) \ - .set push; \ - .set noreorder; \ - .set nomacro; \ - .text; \ - .p2align 3; \ - .globl name; \ - .type name,@function; \ - .ent name, 0; \ -name: lui $7, 0xffff; \ - daddu $6, $0, $0; \ - ori $7, 0xf000; \ - nop; \ -1: sync; \ - cache 0x10, 0($6); \ - sync; \ - mfc0 $2, $28; \ - and $2, $7; \ - addu $2, $6; \ - sltu $3, $5, $2; \ - sltu $2, $4; \ - bnez $2, 2f; \ - nop; \ - bnez $3, 2f; \ - nop; \ - sync; \ - cache op, 0($6); \ - sync; \ -2: sync; \ - cache 0x10, 1($6); \ - sync; \ - mfc0 $2, $28; \ - and $2, $7; \ - addu $2, $6; \ - sltu $3, $5, $2; \ - sltu $2, $4; \ - bnez $2, 3f; \ - nop; \ - bnez $3, 3f; \ - nop; \ - sync; \ - cache op, 1($6); \ - sync; \ -3: sync; \ - addiu $6, 64; \ - slti $2, $6, 4096; \ - bnez $2, 1b; \ - nop; \ - jr $31; \ - nop; \ - .end name; \ - .size name,.-name; \ - .set pop; - -#ifdef F__SyncDCache -opDCache(_SyncDCache, DXWBIN) -#endif - -#ifdef F__InvalidDCache -opDCache(_InvalidDCache, DXIN) -#endif - -#ifdef F___errno -/* This is needed in case we are linked against libm (the math library) but - not libc. */ - .globl __errno - .ent __errno - .weak __errno - -__errno: - la $2, errno - jr $31 - nop - .end __errno -#endif - -#ifdef F_errno -/* New applications compiled against ps2lib that use errno will resolve to - this, while existing newlib applications will resolve to __errno. */ - .globl errno - .weak errno - - .data -errno: - .space 4 -#endif - -#ifdef F_strlen -/* Assembler version of strlen that uses quadword instructions. - - Jeff Johnston, Cygnus Solutions, Feb 10/1999. - - ============================================================ - Copyright (C) 1999 by Cygnus Solutions. All rights reserved. - - Permission to use, copy, modify, and distribute this - software is freely granted, provided that this notice - is preserved. - ============================================================ */ - - .text - .align 2 - .globl strlen - .text - .ent strlen - .weak strlen -strlen: - .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0 - .mask 0x00000000,0 - .fmask 0x00000000,0 - -#ifndef __OPTIMIZE_SIZE__ - -/* check if src is quadword aligned, doubleword aligned, or neither in which case - perform checking for null terminator one byte at a time. */ - - andi $2,$4,0x7 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L15 - move $7,$4 - .set pop - - andi $3,$4,0xf - dli $2,0x0101010101010101 - .set push - .set noreorder - .set nomacro - bne $3,$0,$L12 - move $5,$4 - .set pop - -/* src is quadword aligned. Load a quadword at a time and check for null terminator. - If null terminator is found, go and find exact position by looking at each byte - of the last quadword. Otherwise, continue to next quadword and keep searching. */ - - lq $3,0($5) - pcpyld $8,$2,$2 - dli $4,0x8080808080808080 - psubb $2,$3,$8 - pnor $3,$0,$3 - pcpyld $9,$4,$4 - pand $2,$2,$3 - pand $2,$2,$9 - pcpyud $3,$2,$8 - or $6,$3,$2 - .set push - .set noreorder - .set nomacro - bnel $6,$0,$L15 - move $4,$5 - .set pop - - addu $5,$5,16 -$L14: - lq $2,0($5) - #nop - pnor $3,$0,$2 - psubb $2,$2,$8 - pand $2,$2,$3 - pand $4,$2,$9 - pcpyud $3,$4,$6 - or $3,$3,$4 - .set push - .set noreorder - .set nomacro - beql $3,$0,$L14 - addu $5,$5,16 - .set pop - - .set push - .set noreorder - .set nomacro - b $L15 - move $4,$5 - .set pop - -/* src is doubleword aligned. Load a doubleword at a time and check for null terminator. - If null terminator is found, go and find exact position by looking at each byte - of the last doubleword. Otherwise, continue to next doubleword and keep searching. */ - - -$L12: - ld $3,0($5) - dli $4,0x8080808080808080 - dsubu $2,$3,$2 - nor $3,$0,$3 - and $2,$2,$3 - and $2,$2,$4 - .set push - .set noreorder - .set nomacro - bnel $2,$0,$L15 - move $4,$5 - .set pop - - dli $6,0x0101010101010101 - addu $5,$5,8 -$L16: - ld $2,0($5) - #nop - nor $3,$0,$2 - dsubu $2,$2,$6 - and $2,$2,$3 - and $2,$2,$4 - .set push - .set noreorder - .set nomacro - beql $2,$0,$L16 - addu $5,$5,8 - .set pop - - move $4,$5 - -#else /* __OPTIMIZE_SIZE__ */ - - move $7,$4 - -#endif /* __OPTIMIZE_SIZE__ */ - -/* search a byte at a time for null terminator and then calculate length by subtracting - original string address from null terminator address. */ - -$L9: -$L15: - .set push - .set noreorder - .set nomacro - - lb $2,0($4) - #nop - beq $2,$0,1f - addu $4,$4,1 - - lb $2,0($4) - #nop - bne $2,$0,$L9 - addu $4,$4,1 -1: - subu $4,$4,1 - - .set pop - - .set push - .set noreorder - .set nomacro - j $31 - subu $2,$4,$7 - .set pop - - .end strlen -#endif - -#ifdef F_strncpy -/* Assembler version of strncpy using quadword instructions - - Jeff Johnston, Cygnus Solutions, Feb 10/1999. - - ============================================================ - Copyright (C) 1999 by Cygnus Solutions. All rights reserved. - - Permission to use, copy, modify, and distribute this - software is freely granted, provided that this notice - is preserved. - ============================================================ */ - - .text - .p2align 3 - .globl strncpy - .text - .ent strncpy - .weak strncpy -strncpy: - .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0 - .mask 0x00000000,0 - .fmask 0x00000000,0 - - move $8,$4 - -#ifndef __OPTIMIZE_SIZE__ - -/* check if src and dest are doubleword aligned, quadword aligned, or neither in which - case copy byte by byte */ - - or $7,$5,$4 - li $10,0x10 - andi $2,$7,0x7 - li $9,0x8 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L9 - andi $2,$7,0xf - .set pop - movz $9,$10,$2 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L17 - sltu $2,$6,$9 - .set pop - -/* src and dest are quadword aligned. Check a quadword at a time looking for a - null terminator or until the nth byte is reached. Otherwise, copy the - quadword to dest and continue looping checking quadwords. Once a null - terminator is found or n is < 16 go copy a byte at a time. */ - -$L31: - bne $2,$0,$L9 - dli $7,0x0101010101010101 - lq $3,0($5) - pcpyld $9,$7,$7 - pnor $3,$0,$3 - dli $7,0x8080808080808080 - psubb $2,$3,$9 - pcpyld $10,$7,$7 - pand $2,$2,$3 - pand $2,$2,$10 - pcpyud $3,$2,$4 - or $3,$2,$3 - .set push - .set noreorder - .set nomacro - bne $3,$0,$L5 - move $7,$8 - .set pop - lq $3,0($5) - .p2align 3 -$L39: - addu $6,$6,-16 - addu $5,$5,16 - sltu $2,$6,16 - sq $3,0($7) - .set push - .set noreorder - .set nomacro - bne $2,$0,$L5 - addu $7,$7,16 - .set pop - - lq $2,0($5) - #nop - pnor $3,$0,$2 - psubb $2,$2,$9 - pand $2,$2,$3 - pand $2,$2,$10 - pcpyud $3,$2,$4 - or $2,$2,$3 - .set push - .set noreorder - .set nomacro - beql $2,$0,$L19 - lq $3,0($5) - b $L9 - move $4,$7 - .set pop - -/* src and dest are quadword aligned. Check a quadword at a time looking for a - null terminator or until the nth byte is reached. Otherwise, copy the - quadword to dest and continue looping checking quadwords. Once a null - terminator is found or n is < 16 go copy a byte at a time. */ - -$L17: - bne $2,$0,$L9 - ld $3,0($5) - dli $9,0x0101010101010101 - dli $10,0x8080808080808080 - dsubu $2,$3,$9 - nor $3,$0,$3 - and $2,$2,$3 - and $2,$2,$10 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L5 - move $7,$8 - .set pop - ld $3,0($5) - .p2align 3 -$L19: - addu $6,$6,-8 - addu $5,$5,8 - sltu $2,$6,8 - sd $3,0($7) - .set push - .set noreorder - .set nomacro - bne $2,$0,$L5 - addu $7,$7,8 - .set pop - - ld $2,0($5) - #nop - nor $3,$0,$2 - dsubu $2,$2,$9 - and $2,$2,$3 - and $2,$2,$10 - .set push - .set noreorder - .set nomacro - beql $2,$0,$L19 - ld $3,0($5) - .set pop - -$L5: - move $4,$7 - -#endif /* !__OPTIMIZE_SIZE__ */ - -/* check a byte at a time looking for either the null terminator or until n bytes are - copied. If the null terminator is found and n is not reached yet, copy null - bytes until n is reached. */ - - .p2align 3 -$L9: - .set push - .set noreorder - .set nomacro - beq $6,$0,$L18 - move $2,$6 - .set pop - - lbu $2,0($5) - addu $6,$6,-1 - addu $5,$5,1 - sb $2,0($4) - sll $2,$2,24 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L9 - addu $4,$4,1 - .set pop - - move $2,$6 -$L20: - .set push - .set noreorder - .set nomacro - beq $2,$0,$L18 - addu $6,$6,-1 - .set pop - - .p2align 3 -$L16: - sb $0,0($4) - move $2,$6 - addu $4,$4,1 - .set push - .set noreorder - .set nomacro - nop - nop - bne $2,$0,$L16 - addu $6,$6,-1 - .set pop - -$L18: - .set push - .set noreorder - .set nomacro - j $31 - move $2,$8 - .set pop - - .end strncpy -#endif - -#ifdef F_memcpy -/* Assembler version of memcpy using quadword instructions. - - Jeff Johnston, Cygnus Solutions, Feb 10/1999. - - ============================================================ - Copyright (C) 1999 by Cygnus Solutions. All rights reserved. - - Permission to use, copy, modify, and distribute this - software is freely granted, provided that this notice - is preserved. - ============================================================ */ - - .text - .align 2 - .globl memcpy - .text - .ent memcpy - .weak memcpy -memcpy: - .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0 - .mask 0x00000000,0 - .fmask 0x00000000,0 - move $8,$4 - -#ifndef __OPTIMIZE_SIZE__ - -/* if bytes to move are < 32 or src or dest are not quadword aligned, jump to - code that moves one byte at a time */ - - sltu $2,$6,32 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L2 - move $3,$8 - .set pop - - or $2,$5,$8 - andi $2,$2,0xF - .set push - .set noreorder - .set nomacro - bnel $2,$0,$L20 - addu $6,$6,-1 - .set pop - - move $7,$8 - -/* while remainder to move is >= 32 bytes, use LQ/SQ quadword instructions - to move data */ - -$L5: - lq $3,0($5) - addu $6,$6,-32 - addu $5,$5,16 - sltu $4,$6,32 - sq $3,0($7) - addu $7,$7,16 - lq $2,0($5) - addu $5,$5,16 - sq $2,0($7) - .set push - .set noreorder - .set nomacro - beq $4,$0,$L5 - addu $7,$7,16 - .set pop - - sltu $2,$6,8 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L2 - move $3,$7 - .set pop - -/* while remainder to move is >= 8 bytes, use LD/SD doubleword instructions - to move data */ - -$L9: - ld $3,0($5) - addu $6,$6,-8 - addu $5,$5,8 - sltu $2,$6,8 - sd $3,0($7) - .set push - .set noreorder - .set nomacro - beq $2,$0,$L9 - addu $7,$7,8 - .set pop - - move $3,$7 - -#else /* __OPTIMIZE_SIZE__ */ - - move $3,$8 - -#endif /* !__OPTIMIZE_SIZE__ */ - -/* Move any remaining bytes one at a time */ - -$L2: - addu $6,$6,-1 -$L20: - li $2,-1 # 0xffffffffffffffff - .set push - .set noreorder - .set nomacro - beq $6,$2,$L12 - move $4,$2 - .set pop - -$L13: - lbu $2,0($5) - addu $6,$6,-1 - addu $5,$5,1 - sb $2,0($3) - .set push - .set noreorder - .set nomacro - nop - bne $6,$4,$L13 - addu $3,$3,1 - .set pop - -$L12: - .set push - .set noreorder - .set nomacro - j $31 - move $2,$8 - .set pop - - .end memcpy -#endif - -#ifdef F_memset -/* Assembler version of memset using quadword instructions. - - Jeff Johnston, Cygnus Solutions, Feb 10/1999. - - ============================================================ - Copyright (C) 1999 by Cygnus Solutions. All rights reserved. - - Permission to use, copy, modify, and distribute this - software is freely granted, provided that this notice - is preserved. - ============================================================ */ - - .text - .align 2 - .globl memset - .text - .ent memset - .weak memset -memset: - .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0 - .mask 0x00000000,0 - .fmask 0x00000000,0 - -#ifndef __OPTIMIZE_SIZE__ - -/* if not setting a double word or more, go and set one byte at a time */ - - sltu $2,$6,8 - .set push - .set noreorder - .set nomacro - bne $2,$0,$L2 - move $3,$4 - .set pop - -/* if not aligned on a quadword boundary, set one byte at a time */ - - andi $2,$4,0xf - .set push - .set noreorder - .set nomacro - bne $2,$0,$L2 - move $7,$4 - .set pop - -/* otherwise, build a double word containing the bytes to set */ - - andi $9,$5,0xff - sltu $10,$6,32 - move $8,$9 - dsll $3,$8,8 - or $8,$3,$9 - pcpyh $3,$8 - -/* check if setting 32 bytes or more, otherwise set 8 bytes at a time */ - - .set push - .set noreorder - .set nomacro - bne $10,$0,$L31 - sltu $2,$6,8 - .set pop - -/* take double word built from the byte to set and make a quadword */ - - pcpyld $8,$3,$3 - -/* loop while bytes to set >=32 and use quadword stores */ - -$L12: - sq $8,0($7) - addu $6,$6,-32 - addu $7,$7,16 - sltu $2,$6,32 - sq $8,0($7) - .set push - .set noreorder - .set nomacro - beq $2,$0,$L12 - addu $7,$7,16 - .set pop - - .set push - .set noreorder - .set nomacro - b $L31 - sltu $2,$6,8 - .set pop - -$L16: - addu $6,$6,-8 - addu $7,$7,8 - sltu $2,$6,8 -$L31: - .set push - .set noreorder - .set nomacro - nop - nop - beql $2,$0,$L16 - sd $3,0($7) - .set pop - - move $3,$7 - -#else /* __OPTIMIZE_SIZE__ */ - - move $3,$4 - -#endif /* __OPTIMIZE_SIZE__ */ - -/* loop while bytes left to set and set one byte at a time */ - -$L2: - li $2,4294901760 # 0xffff0000 - addu $6,$6,-1 - ori $2,$2,0xffff - beq $6,$2,$L19 - li $2,4294901760 # 0xffff0000 - ori $2,$2,0xffff - -$L20: - sb $5,0($3) - addu $6,$6,-1 - .set push - .set noreorder - .set nomacro - nop - nop - nop - bne $6,$2,$L20 - addu $3,$3,1 - .set pop - -$L19: - .set push - .set noreorder - .set nomacro - j $31 - move $2,$4 - .set pop - - .end memset -#endif - diff --git a/ee/kernel/src/kernel.c b/ee/kernel/src/kernel.c new file mode 100644 index 00000000000..36f340992cc --- /dev/null +++ b/ee/kernel/src/kernel.c @@ -0,0 +1,1525 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# (C)2001, Gustavo Scotti (gustavo@scotti.com) +# (c) 2003 Marcus R. Brown (mrbrown@0xd6.org) +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +/** + * @file + * EE Kernel functions + */ + +#include + +#define STRINNER(x) #x +#define STR(x) STRINNER(x) + +#define SYSCALL(name) \ + SYSCALL_SPECIAL(name, name) + +#ifdef USE_KMODE +#define SYSCALL_SPECIAL(symbol, name) \ + __asm__ ( \ + "\t" "\t" ".set push;" "\n" \ + "\t" "\t" ".set noreorder;" "\n" \ + "\t" "\t" ".globl " STR(symbol) ";" "\n" \ + "\t" "\t" ".type " STR(symbol) ",@function;" "\n" \ + "\t" "\t" ".ent " STR(symbol) ",0;" "\n" \ + "\t" "" STR(symbol) ": j __syscall;" "\n" \ + "\t" "\t" "li $3, " STR(__NR_##name) ";" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" ".end " STR(symbol) ";" "\n" \ + "\t" "\t" ".size " STR(symbol) ",.-" STR(symbol) ";" "\n" \ + "\t" "\t" ".set pop;" "\n" \ + ); +#else +#define SYSCALL_SPECIAL(symbol, name) \ + __asm__ ( \ + "\t" "\t" ".set push;" "\n" \ + "\t" "\t" ".set noreorder;" "\n" \ + "\t" "\t" ".globl " STR(symbol) ";" "\n" \ + "\t" "\t" ".type " STR(symbol) ",@function;" "\n" \ + "\t" "\t" ".ent " STR(symbol) ",0;" "\n" \ + "\t" "" STR(symbol) ": li $3, " STR(__NR_##name) ";" "\n" \ + "\t" "\t" "syscall;" "\n" \ + "\t" "\t" "jr $31;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" ".end " STR(symbol) ";" "\n" \ + "\t" "\t" ".size " STR(symbol) ",.-" STR(symbol) ";" "\n" \ + "\t" "\t" ".set pop;" "\n" \ + ); +#endif + +#ifdef F___syscall +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".globl __syscall" "\n" + "\t" ".type __syscall,@function" "\n" + "\t" ".ent __syscall,0" "\n" + "\t" "__syscall:" "\n" + "\t" "\t" "mfc0 $2, $12" "\n" + "\t" "\t" "andi $2, $2, 0x18" "\n" + "\t" "\t" "beqz $2, _kMode" "\n" + "\t" "\t" "slt $2, $3, $0" "\n" + "\t" "\t" "syscall" "\n" + "\t" "\t" "jr $31" "\n" + "\t" "\t" "nop" "\n" + "\t" "_kMode:" "\n" + "\t" "\t" "subu $26, $0, $3" "\n" + "\t" "\t" "movn $3, $26, $2" "\n" + "\t" "\t" "sll $3, $3, 2" "\n" + "\t" "\t" "lui $26, 0x8000" "\n" + "\t" "\t" "lhu $2, 0x02F0($26)" "\n" + "\t" "\t" "sll $2, $2, 16" "\n" + "\t" "\t" "lh $26, 0x02F8($26)" "\n" + "\t" "\t" "add $2, $26" "\n" + "\t" "\t" "addu $3, $2" "\n" + "\t" "\t" "lw $26, 0x00($3)" "\n" + "\t" "\t" "jr $26" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end __syscall" "\n" + "\t" ".size __syscall,.-__syscall" "\n" + "\t" ".set pop" "\n" +); +#endif + +#ifdef F_ResetEE +SYSCALL(ResetEE) +#endif + +#ifdef F_SetGsCrt +SYSCALL(SetGsCrt) +#endif + +#ifdef F_KExit +SYSCALL(KExit) +#endif + +#ifdef F__LoadExecPS2 +SYSCALL(_LoadExecPS2) +#endif + +#ifdef F__ExecPS2 +SYSCALL(_ExecPS2) +#endif + +#ifdef F_RFU009 +SYSCALL(RFU009) +#endif + +#ifdef F_AddSbusIntcHandler +SYSCALL(AddSbusIntcHandler) +#endif + +#ifdef F_RemoveSbusIntcHandler +SYSCALL(RemoveSbusIntcHandler) +#endif + +#ifdef F_Interrupt2Iop +SYSCALL(Interrupt2Iop) +#endif + +#ifdef F_SetVTLBRefillHandler +SYSCALL(SetVTLBRefillHandler) +#endif + +#ifdef F_SetVCommonHandler +SYSCALL(SetVCommonHandler) +#endif + +#ifdef F_SetVInterruptHandler +SYSCALL(SetVInterruptHandler) +#endif + +#ifdef F_AddIntcHandler +SYSCALL(AddIntcHandler) +#endif + +#ifdef F_AddIntcHandler2 +SYSCALL(AddIntcHandler2) +#endif + +#ifdef F_RemoveIntcHandler +SYSCALL(RemoveIntcHandler) +#endif + +#ifdef F_AddDmacHandler +SYSCALL(AddDmacHandler) +#endif + +#ifdef F_AddDmacHandler2 +SYSCALL(AddDmacHandler2) +#endif + +#ifdef F_RemoveDmacHandler +SYSCALL(RemoveDmacHandler) +#endif + +#ifdef F__EnableIntc +SYSCALL(_EnableIntc) +#endif + +#ifdef F__DisableIntc +SYSCALL(_DisableIntc) +#endif + +#ifdef F__EnableDmac +SYSCALL(_EnableDmac) +#endif + +#ifdef F__DisableDmac +SYSCALL(_DisableDmac) +#endif + +#ifdef F__SetAlarm +SYSCALL(_SetAlarm) +#endif + +#ifdef F_SetAlarm +SYSCALL(SetAlarm) +#endif + +#ifdef F__ReleaseAlarm +SYSCALL(_ReleaseAlarm) +#endif + +#ifdef F_ReleaseAlarm +SYSCALL(ReleaseAlarm) +#endif + +#ifdef F__iEnableIntc +SYSCALL(_iEnableIntc) +#endif + +#ifdef F__iDisableIntc +SYSCALL(_iDisableIntc) +#endif + +#ifdef F__iEnableDmac +SYSCALL(_iEnableDmac) +#endif + +#ifdef F__iDisableDmac +SYSCALL(_iDisableDmac) +#endif + +#ifdef F__iSetAlarm +SYSCALL(_iSetAlarm) +#endif + +#ifdef F_iSetAlarm +SYSCALL(iSetAlarm) +#endif + +#ifdef F__iReleaseAlarm +SYSCALL(_iReleaseAlarm) +#endif + +#ifdef F_iReleaseAlarm +SYSCALL(iReleaseAlarm) +#endif + +#ifdef F_CreateThread +SYSCALL(CreateThread) +#endif + +#ifdef F_DeleteThread +SYSCALL(DeleteThread) +#endif + +#ifdef F_StartThread +SYSCALL(StartThread) +#endif + +#ifdef F_ExitThread +SYSCALL(ExitThread) +#endif + +#ifdef F_ExitDeleteThread +SYSCALL(ExitDeleteThread) +#endif + +#ifdef F_TerminateThread +SYSCALL(TerminateThread) +#endif + +#ifdef F_iTerminateThread +SYSCALL(iTerminateThread) +#endif + +#ifdef F_DisableDispatchThread +SYSCALL(DisableDispatchThread) +#endif + +#ifdef F_EnableDispatchThread +SYSCALL(EnableDispatchThread) +#endif + +#ifdef F_ChangeThreadPriority +SYSCALL(ChangeThreadPriority) +#endif + +#ifdef F_iChangeThreadPriority +SYSCALL(iChangeThreadPriority) +#endif + +#ifdef F_RotateThreadReadyQueue +SYSCALL(RotateThreadReadyQueue) +#endif + +#ifdef F__iRotateThreadReadyQueue +SYSCALL(_iRotateThreadReadyQueue) +#endif + +#ifdef F_ReleaseWaitThread +SYSCALL(ReleaseWaitThread) +#endif + +#ifdef F_iReleaseWaitThread +SYSCALL(iReleaseWaitThread) +#endif + +#ifdef F_GetThreadId +SYSCALL(GetThreadId) +#endif + +#ifdef F__iGetThreadId +SYSCALL(_iGetThreadId) +#endif + +#ifdef F_ReferThreadStatus +SYSCALL(ReferThreadStatus) +#endif + +#ifdef F_iReferThreadStatus +SYSCALL(iReferThreadStatus) +#endif + +#ifdef F_SleepThread +SYSCALL(SleepThread) +#endif + +#ifdef F_WakeupThread +SYSCALL(WakeupThread) +#endif + +#ifdef F__iWakeupThread +SYSCALL(_iWakeupThread) +#endif + +#ifdef F_CancelWakeupThread +SYSCALL(CancelWakeupThread) +#endif + +#ifdef F_iCancelWakeupThread +SYSCALL(iCancelWakeupThread) +#endif + +#ifdef F_SuspendThread +SYSCALL(SuspendThread) +#endif + +#ifdef F__iSuspendThread +SYSCALL(_iSuspendThread) +#endif + +#ifdef F_ResumeThread +SYSCALL(ResumeThread) +#endif + +#ifdef F_iResumeThread +SYSCALL(iResumeThread) +#endif + +#ifdef F_RFU059 +SYSCALL(RFU059) +#endif + +#ifdef F_RFU060 +SYSCALL(RFU060) +#endif + +#ifdef F_SetupThread +SYSCALL(SetupThread) +#endif + +#ifdef F_RFU061 +SYSCALL(RFU061) +#endif + +#ifdef F_SetupHeap +SYSCALL(SetupHeap) +#endif + +#ifdef F_EndOfHeap +SYSCALL(EndOfHeap) +#endif + +#ifdef F_CreateSema +SYSCALL(CreateSema) +#endif + +#ifdef F_DeleteSema +SYSCALL(DeleteSema) +#endif + +#ifdef F_SignalSema +SYSCALL(SignalSema) +#endif + +#ifdef F_iSignalSema +SYSCALL(iSignalSema) +#endif + +#ifdef F_WaitSema +SYSCALL(WaitSema) +#endif + +#ifdef F_PollSema +SYSCALL(PollSema) +#endif + +#ifdef F_iPollSema +SYSCALL(iPollSema) +#endif + +#ifdef F_ReferSemaStatus +SYSCALL(ReferSemaStatus) +#endif + +#ifdef F_iReferSemaStatus +SYSCALL(iReferSemaStatus) +#endif + +#ifdef F_iDeleteSema +SYSCALL(iDeleteSema) +#endif + +#ifdef F_SetOsdConfigParam +SYSCALL(SetOsdConfigParam) +#endif + +#ifdef F_GetOsdConfigParam +SYSCALL(GetOsdConfigParam) +#endif + +#ifdef F_GetGsHParam +SYSCALL(GetGsHParam) +#endif + +#ifdef F_GetGsVParam +SYSCALL(GetGsVParam) +#endif + +#ifdef F_SetGsHParam +SYSCALL(SetGsHParam) +#endif + +#ifdef F_SetGsVParam +SYSCALL(SetGsVParam) +#endif + +#ifdef F_CreateEventFlag +SYSCALL(CreateEventFlag) +#endif + +#ifdef F_DeleteEventFlag +SYSCALL(DeleteEventFlag) +#endif + +#ifdef F_SetEventFlag +SYSCALL(SetEventFlag) +#endif + +#ifdef F_iSetEventFlag +SYSCALL(iSetEventFlag) +#endif + +#ifdef F_PutTLBEntry +SYSCALL(PutTLBEntry) +#endif + +#ifdef F_iPutTLBEntry +SYSCALL(iPutTLBEntry) +#endif + +#ifdef F__SetTLBEntry +SYSCALL(_SetTLBEntry) +#endif + +#ifdef F_iSetTLBEntry +SYSCALL(iSetTLBEntry) +#endif + +#ifdef F_GetTLBEntry +SYSCALL(GetTLBEntry) +#endif + +#ifdef F_iGetTLBEntry +SYSCALL(iGetTLBEntry) +#endif + +#ifdef F_ProbeTLBEntry +SYSCALL(ProbeTLBEntry) +#endif + +#ifdef F_iProbeTLBEntry +SYSCALL(iProbeTLBEntry) +#endif + +#ifdef F_ExpandScratchPad +SYSCALL(ExpandScratchPad) +#endif + +#ifdef F_EnableIntcHandler +SYSCALL(EnableIntcHandler) +#endif + +#ifdef F_iEnableIntcHandler +SYSCALL(iEnableIntcHandler) +#endif + +#ifdef F_DisableIntcHandler +SYSCALL(DisableIntcHandler) +#endif + +#ifdef F_iDisableIntcHandler +SYSCALL(iDisableIntcHandler) +#endif + +#ifdef F_EnableDmacHandler +SYSCALL(EnableDmacHandler) +#endif + +#ifdef F_iEnableDmacHandler +SYSCALL(iEnableDmacHandler) +#endif + +#ifdef F_DisableDmacHandler +SYSCALL(DisableDmacHandler) +#endif + +#ifdef F_iDisableDmacHandler +SYSCALL(iDisableDmacHandler) +#endif + +#ifdef F_KSeg0 +SYSCALL(KSeg0) +#endif + +#ifdef F_EnableCache +SYSCALL(EnableCache) +#endif + +#ifdef F_DisableCache +SYSCALL(DisableCache) +#endif + +#ifdef F_GetCop0 +SYSCALL(GetCop0) +#endif + +#ifdef F_FlushCache +SYSCALL(FlushCache) +#endif + +#ifdef F_CpuConfig +SYSCALL(CpuConfig) +#endif + +#ifdef F_iGetCop0 +SYSCALL(iGetCop0) +#endif + +#ifdef F_iFlushCache +SYSCALL(iFlushCache) +#endif + +#ifdef F_RFU105 +SYSCALL(RFU105) +#endif + +#ifdef F_iCpuConfig +SYSCALL(iCpuConfig) +#endif + +#ifdef F_sceSifStopDma +SYSCALL(sceSifStopDma) +#endif + +#ifdef F_SetCPUTimerHandler +SYSCALL(SetCPUTimerHandler) +#endif + +#ifdef F_SetCPUTimer +SYSCALL(SetCPUTimer) +#endif + +#ifdef F_SetOsdConfigParam2 +SYSCALL(SetOsdConfigParam2) +#endif + +#ifdef F_GetOsdConfigParam2 +SYSCALL(GetOsdConfigParam2) +#endif + +#ifdef F_GsGetIMR +SYSCALL(GsGetIMR) +#endif + +#ifdef F_iGsGetIMR +SYSCALL(iGsGetIMR) +#endif + +#ifdef F_GsPutIMR +SYSCALL(GsPutIMR) +#endif + +#ifdef F_iGsPutIMR +SYSCALL(iGsPutIMR) +#endif + +#ifdef F_SetPgifHandler +SYSCALL(SetPgifHandler) +#endif + +#ifdef F_SetVSyncFlag +SYSCALL(SetVSyncFlag) +#endif + +#ifdef F_SetSyscall +SYSCALL(SetSyscall) +#endif + +#ifdef F__print +SYSCALL(_print) +#endif + +#ifdef F_sceSifDmaStat +SYSCALL(sceSifDmaStat) +#endif + +#ifdef F_isceSifDmaStat +SYSCALL(isceSifDmaStat) +#endif + +#ifdef F_sceSifSetDma +SYSCALL(sceSifSetDma) +#endif + +#ifdef F_isceSifSetDma +SYSCALL(isceSifSetDma) +#endif + +#ifdef F_sceSifSetDChain +SYSCALL(sceSifSetDChain) +#endif + +#ifdef F_isceSifSetDChain +SYSCALL(isceSifSetDChain) +#endif + +#ifdef F_sceSifSetReg +SYSCALL(sceSifSetReg) +#endif + +#ifdef F_sceSifGetReg +SYSCALL(sceSifGetReg) +#endif + +#ifdef F__ExecOSD +SYSCALL(_ExecOSD) +#endif + +#ifdef F_Deci2Call +SYSCALL(Deci2Call) +#endif + +#ifdef F_PSMode +SYSCALL(PSMode) +#endif + +#ifdef F_MachineType +SYSCALL(MachineType) +#endif + +#ifdef F_GetMemorySize +SYSCALL(GetMemorySize) +#endif + +#ifdef F__GetGsDxDyOffset +SYSCALL(_GetGsDxDyOffset) +#endif + +#ifdef F__InitTLB +SYSCALL(_InitTLB) +#endif + +#ifdef F_SetMemoryMode +SYSCALL(SetMemoryMode) +#endif + +#ifdef F_GetMemoryMode +SYSCALL(GetMemoryMode) +#endif + +#ifdef F_GPfuncs +__asm__ +( + "\t" ".globl ChangeGP" "\n" + "\t" ".ent ChangeGP" "\n" + "\t" "ChangeGP:" "\n" + "\t" "\t" "move $v0, $gp" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "move $gp, $a0" "\n" + "\t" ".end ChangeGP" "\n" + + "\t" ".globl SetGP" "\n" + "\t" ".ent SetGP" "\n" + "\t" "SetGP:" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "move $gp, $a0" "\n" + "\t" ".end SetGP" "\n" + + "\t" ".globl GetGP" "\n" + "\t" ".ent GetGP" "\n" + "\t" "GetGP:" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "move $v0, $gp" "\n" + "\t" ".end GetGP" "\n" +); +#endif + +#ifdef F_sceSifWriteBackDCache +__asm__ +( + "\t" "\t" ".globl sceSifWriteBackDCache" "\n" + "\t" "\t" ".ent sceSifWriteBackDCache" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + + "\t" "sceSifWriteBackDCache:" "\n" /* DHWBIN: Data cache Hit WriteBack INvalidate. */ + + "\t" "\t" "lui $25, 0xffff" "\n" + "\t" "\t" "ori $25, $25, 0xffc0" "\n" + "\t" "\t" "blez $5, last" "\n" + "\t" "\t" "addu $10, $4, $5" "\n" + "\t" "\t" "and $8, $4, $25" "\n" + "\t" "\t" "addiu $10, $10, -1" "\n" + "\t" "\t" "and $9, $10, $25" "\n" + "\t" "\t" "subu $10, $9, $8" "\n" + "\t" "\t" "srl $11, $10, 0x6" "\n" + "\t" "\t" "addiu $11, $11, 1" "\n" + "\t" "\t" "andi $9, $11, 0x7" "\n" + "\t" "\t" "beqz $9, eight" "\n" + "\t" "\t" "srl $10, $11, 0x3" "\n" + "\t" "loop1:" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 0($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "addiu $9, $9, -1" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "bgtz $9, loop1" "\n" + "\t" "\t" "addiu $8, $8, 64" "\n" + + "\t" "eight:" "\n" + "\t" "\t" "beqz $10, last" "\n" + "\t" "loop8:" "\n" + "\t" "\t" "addiu $10, $10, -1" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 0($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 64($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 128($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 192($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 256($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 320($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 384($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cache 0x18, 448($8)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "bgtz $10, loop8" "\n" + "\t" "\t" "addiu $8, $8, 512" "\n" + "\t" "last:" "\n" + "\t" "\t" "jr $31" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" ".set pop" "\n" + "\t" "\t" ".end sceSifWriteBackDCache" "\n" +); +#endif + +#define DXWBIN 0x14 /* Data cache: indeX WriteBack INvalidate. */ +#define DXIN 0x16 /* Data cache: indeX INvalidate. */ + +#define opDCache(name, op) \ + __asm__ ( \ + "\t" "\t" ".set push;" "\n" \ + "\t" "\t" ".set noreorder;" "\n" \ + "\t" "\t" ".set nomacro;" "\n" \ + "\t" "\t" ".globl " STR(name) ";" "\n" \ + "\t" "\t" ".type " STR(name) ",@function;" "\n" \ + "\t" "\t" ".ent " STR(name) ", 0;" "\n" \ + "\t" "" STR(name) ": lui $7, 0xffff;" "\n" \ + "\t" "\t" "daddu $6, $0, $0;" "\n" \ + "\t" "\t" "ori $7, 0xf000;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "1: sync;" "\n" \ + "\t" "\t" "cache 0x10, 0($6);" "\n" \ + "\t" "\t" "sync;" "\n" \ + "\t" "\t" "mfc0 $2, $28;" "\n" \ + "\t" "\t" "and $2, $7;" "\n" \ + "\t" "\t" "addu $2, $6;" "\n" \ + "\t" "\t" "sltu $3, $5, $2;" "\n" \ + "\t" "\t" "sltu $2, $4;" "\n" \ + "\t" "\t" "bnez $2, 2f;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" "bnez $3, 2f;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" "sync;" "\n" \ + "\t" "\t" "cache " STR(op) ", 0($6);" "\n" \ + "\t" "\t" "sync;" "\n" \ + "\t" "2: sync;" "\n" \ + "\t" "\t" "cache 0x10, 1($6);" "\n" \ + "\t" "\t" "sync;" "\n" \ + "\t" "\t" "mfc0 $2, $28;" "\n" \ + "\t" "\t" "and $2, $7;" "\n" \ + "\t" "\t" "addu $2, $6;" "\n" \ + "\t" "\t" "sltu $3, $5, $2;" "\n" \ + "\t" "\t" "sltu $2, $4;" "\n" \ + "\t" "\t" "bnez $2, 3f;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" "bnez $3, 3f;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" "sync;" "\n" \ + "\t" "\t" "cache " STR(op) ", 1($6);" "\n" \ + "\t" "\t" "sync;" "\n" \ + "\t" "3: sync;" "\n" \ + "\t" "\t" "addiu $6, 64;" "\n" \ + "\t" "\t" "slti $2, $6, 4096;" "\n" \ + "\t" "\t" "bnez $2, 1b;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" "jr $31;" "\n" \ + "\t" "\t" "nop;" "\n" \ + "\t" "\t" ".end " STR(name) ";" "\n" \ + "\t" "\t" ".size " STR(name) ",.-" STR(name) ";" "\n" \ + "\t" "\t" ".set pop;" "\n" \ + ); + +#ifdef F__SyncDCache +opDCache(_SyncDCache, DXWBIN) +#endif + +#ifdef F__InvalidDCache +opDCache(_InvalidDCache, DXIN) +#endif + +#ifdef F___errno +/* This is needed in case we are linked against libm (the math library) but + not libc. */ +__asm__ +( + "\t" "\t" ".globl __errno" "\n" + "\t" "\t" ".ent __errno" "\n" + "\t" "\t" ".weak __errno" "\n" + + "\t" "__errno:" "\n" + "\t" "\t" "la $2, errno" "\n" + "\t" "\t" "jr $31" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" ".end __errno" "\n" +); +#endif + +#ifdef F_errno +/* New applications compiled against ps2lib that use errno will resolve to + this, while existing newlib applications will resolve to __errno. */ +__asm__ +( + "\t" "\t" ".globl errno" "\n" + "\t" "\t" ".weak errno" "\n" + + "\t" "\t" ".data" "\n" + "\t" "errno:" "\n" + "\t" "\t" ".space 4" "\n" +); +#endif + +#ifdef F_strlen +/* Assembler version of strlen that uses quadword instructions. + + Jeff Johnston, Cygnus Solutions, Feb 10/1999. + + ============================================================ + Copyright (C) 1999 by Cygnus Solutions. All rights reserved. + + Permission to use, copy, modify, and distribute this + software is freely granted, provided that this notice + is preserved. + ============================================================ */ + +__asm__ +( + "\t" "\t" ".globl strlen" "\n" + "\t" "\t" ".ent strlen" "\n" + "\t" "\t" ".weak strlen" "\n" + "\t" "strlen:" "\n" + "\t" "\t" ".frame $sp,0,$31" "\n" // vars= 0, regs= 0/0, args= 0, extra= 0 + "\t" "\t" ".mask 0x00000000,0" "\n" + "\t" "\t" ".fmask 0x00000000,0" "\n" + +#ifndef __OPTIMIZE_SIZE__ + + /* check if src is quadword aligned, doubleword aligned, or neither in which case + perform checking for null terminator one byte at a time. */ + + "\t" "\t" "andi $2,$4,0x7" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L15" "\n" + "\t" "\t" "move $7,$4" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "andi $3,$4,0xf" "\n" + "\t" "\t" "dli $2,0x0101010101010101" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $3,$0,$L12" "\n" + "\t" "\t" "move $5,$4" "\n" + "\t" "\t" ".set pop" "\n" + + /* src is quadword aligned. Load a quadword at a time and check for null terminator. + If null terminator is found, go and find exact position by looking at each byte + of the last quadword. Otherwise, continue to next quadword and keep searching. */ + + "\t" "\t" "lq $3,0($5)" "\n" + "\t" "\t" "pcpyld $8,$2,$2" "\n" + "\t" "\t" "dli $4,0x8080808080808080" "\n" + "\t" "\t" "psubb $2,$3,$8" "\n" + "\t" "\t" "pnor $3,$0,$3" "\n" + "\t" "\t" "pcpyld $9,$4,$4" "\n" + "\t" "\t" "pand $2,$2,$3" "\n" + "\t" "\t" "pand $2,$2,$9" "\n" + "\t" "\t" "pcpyud $3,$2,$8" "\n" + "\t" "\t" "or $6,$3,$2" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bnel $6,$0,$L15" "\n" + "\t" "\t" "move $4,$5" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "addu $5,$5,16" "\n" + "\t" "$L14:" "\n" + "\t" "\t" "lq $2,0($5)" "\n" + "\t" "\t" "#nop" "\n" + "\t" "\t" "pnor $3,$0,$2" "\n" + "\t" "\t" "psubb $2,$2,$8" "\n" + "\t" "\t" "pand $2,$2,$3" "\n" + "\t" "\t" "pand $4,$2,$9" "\n" + "\t" "\t" "pcpyud $3,$4,$6" "\n" + "\t" "\t" "or $3,$3,$4" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beql $3,$0,$L14" "\n" + "\t" "\t" "addu $5,$5,16" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "b $L15" "\n" + "\t" "\t" "move $4,$5" "\n" + "\t" "\t" ".set pop" "\n" + + /* src is doubleword aligned. Load a doubleword at a time and check for null terminator. + If null terminator is found, go and find exact position by looking at each byte + of the last doubleword. Otherwise, continue to next doubleword and keep searching. */ + + + "\t" "$L12:" "\n" + "\t" "\t" "ld $3,0($5)" "\n" + "\t" "\t" "dli $4,0x8080808080808080" "\n" + "\t" "\t" "dsubu $2,$3,$2" "\n" + "\t" "\t" "nor $3,$0,$3" "\n" + "\t" "\t" "and $2,$2,$3" "\n" + "\t" "\t" "and $2,$2,$4" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bnel $2,$0,$L15" "\n" + "\t" "\t" "move $4,$5" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "dli $6,0x0101010101010101" "\n" + "\t" "\t" "addu $5,$5,8" "\n" + "\t" "$L16:" "\n" + "\t" "\t" "ld $2,0($5)" "\n" + "\t" "\t" "#nop" "\n" + "\t" "\t" "nor $3,$0,$2" "\n" + "\t" "\t" "dsubu $2,$2,$6" "\n" + "\t" "\t" "and $2,$2,$3" "\n" + "\t" "\t" "and $2,$2,$4" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beql $2,$0,$L16" "\n" + "\t" "\t" "addu $5,$5,8" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "move $4,$5" "\n" + +#else /* __OPTIMIZE_SIZE__ */ + + "\t" "\t" "move $7,$4" "\n" + +#endif /* __OPTIMIZE_SIZE__ */ + + /* search a byte at a time for null terminator and then calculate length by subtracting + original string address from null terminator address. */ + + "\t" "$L9:" "\n" + "\t" "$L15:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + + "\t" "\t" "lb $2,0($4)" "\n" + "\t" "\t" "#nop" "\n" + "\t" "\t" "beq $2,$0,1f" "\n" + "\t" "\t" "addu $4,$4,1" "\n" + + "\t" "\t" "lb $2,0($4)" "\n" + "\t" "\t" "#nop" "\n" + "\t" "\t" "bne $2,$0,$L9" "\n" + "\t" "\t" "addu $4,$4,1" "\n" + "\t" "1:" "\n" + "\t" "\t" "subu $4,$4,1" "\n" + + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "j $31" "\n" + "\t" "\t" "subu $2,$4,$7" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".end strlen" "\n" +); +#endif + +#ifdef F_strncpy +/* Assembler version of strncpy using quadword instructions + + Jeff Johnston, Cygnus Solutions, Feb 10/1999. + + ============================================================ + Copyright (C) 1999 by Cygnus Solutions. All rights reserved. + + Permission to use, copy, modify, and distribute this + software is freely granted, provided that this notice + is preserved. + ============================================================ */ + +__asm__ +( + "\t" "\t" ".globl strncpy" "\n" + "\t" "\t" ".ent strncpy" "\n" + "\t" "\t" ".weak strncpy" "\n" + "\t" "strncpy:" "\n" + "\t" "\t" ".frame $sp,0,$31" "\n" // vars= 0, regs= 0/0, args= 0, extra= 0 + "\t" "\t" ".mask 0x00000000,0" "\n" + "\t" "\t" ".fmask 0x00000000,0" "\n" + + "\t" "\t" "move $8,$4" "\n" + +#ifndef __OPTIMIZE_SIZE__ + + /* check if src and dest are doubleword aligned, quadword aligned, or neither in which + case copy byte by byte */ + + "\t" "\t" "or $7,$5,$4" "\n" + "\t" "\t" "li $10,0x10" "\n" + "\t" "\t" "andi $2,$7,0x7" "\n" + "\t" "\t" "li $9,0x8" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L9" "\n" + "\t" "\t" "andi $2,$7,0xf" "\n" + "\t" "\t" ".set pop" "\n" + "\t" "\t" "movz $9,$10,$2" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L17" "\n" + "\t" "\t" "sltu $2,$6,$9" "\n" + "\t" "\t" ".set pop" "\n" + + /* src and dest are quadword aligned. Check a quadword at a time looking for a + null terminator or until the nth byte is reached. Otherwise, copy the + quadword to dest and continue looping checking quadwords. Once a null + terminator is found or n is < 16 go copy a byte at a time. */ + + "\t" "$L31:" "\n" + "\t" "\t" "bne $2,$0,$L9" "\n" + "\t" "\t" "dli $7,0x0101010101010101" "\n" + "\t" "\t" "lq $3,0($5)" "\n" + "\t" "\t" "pcpyld $9,$7,$7" "\n" + "\t" "\t" "pnor $3,$0,$3" "\n" + "\t" "\t" "dli $7,0x8080808080808080" "\n" + "\t" "\t" "psubb $2,$3,$9" "\n" + "\t" "\t" "pcpyld $10,$7,$7" "\n" + "\t" "\t" "pand $2,$2,$3" "\n" + "\t" "\t" "pand $2,$2,$10" "\n" + "\t" "\t" "pcpyud $3,$2,$4" "\n" + "\t" "\t" "or $3,$2,$3" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $3,$0,$L5" "\n" + "\t" "\t" "move $7,$8" "\n" + "\t" "\t" ".set pop" "\n" + "\t" "\t" "lq $3,0($5)" "\n" + "\t" "\t" ".p2align 3" "\n" + "\t" "$L39:" "\n" + "\t" "\t" "addu $6,$6,-16" "\n" + "\t" "\t" "addu $5,$5,16" "\n" + "\t" "\t" "sltu $2,$6,16" "\n" + "\t" "\t" "sq $3,0($7)" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L5" "\n" + "\t" "\t" "addu $7,$7,16" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "lq $2,0($5)" "\n" + "\t" "\t" "#nop" "\n" + "\t" "\t" "pnor $3,$0,$2" "\n" + "\t" "\t" "psubb $2,$2,$9" "\n" + "\t" "\t" "pand $2,$2,$3" "\n" + "\t" "\t" "pand $2,$2,$10" "\n" + "\t" "\t" "pcpyud $3,$2,$4" "\n" + "\t" "\t" "or $2,$2,$3" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beql $2,$0,$L19" "\n" + "\t" "\t" "lq $3,0($5)" "\n" + "\t" "\t" "b $L9" "\n" + "\t" "\t" "move $4,$7" "\n" + "\t" "\t" ".set pop" "\n" + + /* src and dest are quadword aligned. Check a quadword at a time looking for a + null terminator or until the nth byte is reached. Otherwise, copy the + quadword to dest and continue looping checking quadwords. Once a null + terminator is found or n is < 16 go copy a byte at a time. */ + + "\t" "$L17:" "\n" + "\t" "\t" "bne $2,$0,$L9" "\n" + "\t" "\t" "ld $3,0($5)" "\n" + "\t" "\t" "dli $9,0x0101010101010101" "\n" + "\t" "\t" "dli $10,0x8080808080808080" "\n" + "\t" "\t" "dsubu $2,$3,$9" "\n" + "\t" "\t" "nor $3,$0,$3" "\n" + "\t" "\t" "and $2,$2,$3" "\n" + "\t" "\t" "and $2,$2,$10" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L5" "\n" + "\t" "\t" "move $7,$8" "\n" + "\t" "\t" ".set pop" "\n" + "\t" "\t" "ld $3,0($5)" "\n" + "\t" "\t" ".p2align 3" "\n" + "\t" "$L19:" "\n" + "\t" "\t" "addu $6,$6,-8" "\n" + "\t" "\t" "addu $5,$5,8" "\n" + "\t" "\t" "sltu $2,$6,8" "\n" + "\t" "\t" "sd $3,0($7)" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L5" "\n" + "\t" "\t" "addu $7,$7,8" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "ld $2,0($5)" "\n" + "\t" "\t" "#nop" "\n" + "\t" "\t" "nor $3,$0,$2" "\n" + "\t" "\t" "dsubu $2,$2,$9" "\n" + "\t" "\t" "and $2,$2,$3" "\n" + "\t" "\t" "and $2,$2,$10" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beql $2,$0,$L19" "\n" + "\t" "\t" "ld $3,0($5)" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "$L5:" "\n" + "\t" "\t" "move $4,$7" "\n" + +#endif /* !__OPTIMIZE_SIZE__ */ + + /* check a byte at a time looking for either the null terminator or until n bytes are + copied. If the null terminator is found and n is not reached yet, copy null + bytes until n is reached. */ + + "\t" "\t" ".p2align 3" "\n" + "\t" "$L9:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beq $6,$0,$L18" "\n" + "\t" "\t" "move $2,$6" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "lbu $2,0($5)" "\n" + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "\t" "addu $5,$5,1" "\n" + "\t" "\t" "sb $2,0($4)" "\n" + "\t" "\t" "sll $2,$2,24" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L9" "\n" + "\t" "\t" "addu $4,$4,1" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "move $2,$6" "\n" + "\t" "$L20:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beq $2,$0,$L18" "\n" + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".p2align 3" "\n" + "\t" "$L16:" "\n" + "\t" "\t" "sb $0,0($4)" "\n" + "\t" "\t" "move $2,$6" "\n" + "\t" "\t" "addu $4,$4,1" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "bne $2,$0,$L16" "\n" + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "$L18:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "j $31" "\n" + "\t" "\t" "move $2,$8" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".end strncpy" "\n" +); +#endif + +#ifdef F_memcpy +/* Assembler version of memcpy using quadword instructions. + + Jeff Johnston, Cygnus Solutions, Feb 10/1999. + + ============================================================ + Copyright (C) 1999 by Cygnus Solutions. All rights reserved. + + Permission to use, copy, modify, and distribute this + software is freely granted, provided that this notice + is preserved. + ============================================================ */ + +__asm__ +( + "\t" "\t" ".globl memcpy" "\n" + "\t" "\t" ".ent memcpy" "\n" + "\t" "\t" ".weak memcpy" "\n" + "\t" "memcpy:" "\n" + "\t" "\t" ".frame $sp,0,$31" "\n" // vars= 0, regs= 0/0, args= 0, extra= 0 + "\t" "\t" ".mask 0x00000000,0" "\n" + "\t" "\t" ".fmask 0x00000000,0" "\n" + "\t" "\t" "move $8,$4" "\n" + +#ifndef __OPTIMIZE_SIZE__ + + /* if bytes to move are < 32 or src or dest are not quadword aligned, jump to + code that moves one byte at a time */ + + "\t" "\t" "sltu $2,$6,32" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L2" "\n" + "\t" "\t" "move $3,$8" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "or $2,$5,$8" "\n" + "\t" "\t" "andi $2,$2,0xF" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bnel $2,$0,$L20" "\n" + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "move $7,$8" "\n" + + /* while remainder to move is >= 32 bytes, use LQ/SQ quadword instructions + to move data */ + + "\t" "$L5:" "\n" + "\t" "\t" "lq $3,0($5)" "\n" + "\t" "\t" "addu $6,$6,-32" "\n" + "\t" "\t" "addu $5,$5,16" "\n" + "\t" "\t" "sltu $4,$6,32" "\n" + "\t" "\t" "sq $3,0($7)" "\n" + "\t" "\t" "addu $7,$7,16" "\n" + "\t" "\t" "lq $2,0($5)" "\n" + "\t" "\t" "addu $5,$5,16" "\n" + "\t" "\t" "sq $2,0($7)" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beq $4,$0,$L5" "\n" + "\t" "\t" "addu $7,$7,16" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "sltu $2,$6,8" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L2" "\n" + "\t" "\t" "move $3,$7" "\n" + "\t" "\t" ".set pop" "\n" + + /* while remainder to move is >= 8 bytes, use LD/SD doubleword instructions + to move data */ + + "\t" "$L9:" "\n" + "\t" "\t" "ld $3,0($5)" "\n" + "\t" "\t" "addu $6,$6,-8" "\n" + "\t" "\t" "addu $5,$5,8" "\n" + "\t" "\t" "sltu $2,$6,8" "\n" + "\t" "\t" "sd $3,0($7)" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beq $2,$0,$L9" "\n" + "\t" "\t" "addu $7,$7,8" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "move $3,$7" "\n" + +#else /* __OPTIMIZE_SIZE__ */ + + "\t" "\t" "move $3,$8" "\n" + +#endif /* !__OPTIMIZE_SIZE__ */ + + /* Move any remaining bytes one at a time */ + + "\t" "$L2:" "\n" + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "$L20:" "\n" + "\t" "\t" "li $2,-1" "\n" // 0xffffffffffffffff + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beq $6,$2,$L12" "\n" + "\t" "\t" "move $4,$2" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "$L13:" "\n" + "\t" "\t" "lbu $2,0($5)" "\n" + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "\t" "addu $5,$5,1" "\n" + "\t" "\t" "sb $2,0($3)" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "bne $6,$4,$L13" "\n" + "\t" "\t" "addu $3,$3,1" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "$L12:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "j $31" "\n" + "\t" "\t" "move $2,$8" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".end memcpy" "\n" +); +#endif + +#ifdef F_memset +/* Assembler version of memset using quadword instructions. + + Jeff Johnston, Cygnus Solutions, Feb 10/1999. + + ============================================================ + Copyright (C) 1999 by Cygnus Solutions. All rights reserved. + + Permission to use, copy, modify, and distribute this + software is freely granted, provided that this notice + is preserved. + ============================================================ */ + +__asm__ +( + "\t" "\t" ".globl memset" "\n" + "\t" "\t" ".ent memset" "\n" + "\t" "\t" ".weak memset" "\n" + "\t" "memset:" "\n" + "\t" "\t" ".frame $sp,0,$31" "\n" // vars= 0, regs= 0/0, args= 0, extra= 0 + "\t" "\t" ".mask 0x00000000,0" "\n" + "\t" "\t" ".fmask 0x00000000,0" "\n" + +#ifndef __OPTIMIZE_SIZE__ + + /* if not setting a double word or more, go and set one byte at a time */ + + "\t" "\t" "sltu $2,$6,8" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L2" "\n" + "\t" "\t" "move $3,$4" "\n" + "\t" "\t" ".set pop" "\n" + + /* if not aligned on a quadword boundary, set one byte at a time */ + + "\t" "\t" "andi $2,$4,0xf" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $2,$0,$L2" "\n" + "\t" "\t" "move $7,$4" "\n" + "\t" "\t" ".set pop" "\n" + + /* otherwise, build a double word containing the bytes to set */ + + "\t" "\t" "andi $9,$5,0xff" "\n" + "\t" "\t" "sltu $10,$6,32" "\n" + "\t" "\t" "move $8,$9" "\n" + "\t" "\t" "dsll $3,$8,8" "\n" + "\t" "\t" "or $8,$3,$9" "\n" + "\t" "\t" "pcpyh $3,$8" "\n" + + /* check if setting 32 bytes or more, otherwise set 8 bytes at a time */ + + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "bne $10,$0,$L31" "\n" + "\t" "\t" "sltu $2,$6,8" "\n" + "\t" "\t" ".set pop" "\n" + + /* take double word built from the byte to set and make a quadword */ + + "\t" "\t" "pcpyld $8,$3,$3" "\n" + + /* loop while bytes to set >=32 and use quadword stores */ + + "\t" "$L12:" "\n" + "\t" "\t" "sq $8,0($7)" "\n" + "\t" "\t" "addu $6,$6,-32" "\n" + "\t" "\t" "addu $7,$7,16" "\n" + "\t" "\t" "sltu $2,$6,32" "\n" + "\t" "\t" "sq $8,0($7)" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "beq $2,$0,$L12" "\n" + "\t" "\t" "addu $7,$7,16" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "b $L31" "\n" + "\t" "\t" "sltu $2,$6,8" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "$L16:" "\n" + "\t" "\t" "addu $6,$6,-8" "\n" + "\t" "\t" "addu $7,$7,8" "\n" + "\t" "\t" "sltu $2,$6,8" "\n" + "\t" "$L31:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "beql $2,$0,$L16" "\n" + "\t" "\t" "sd $3,0($7)" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" "move $3,$7" "\n" + +#else /* __OPTIMIZE_SIZE__ */ + + "\t" "\t" "move $3,$4" "\n" + +#endif /* __OPTIMIZE_SIZE__ */ + + /* loop while bytes left to set and set one byte at a time */ + + "\t" "$L2:" "\n" + "\t" "\t" "li $2,4294901760" "\n" // 0xffff0000 + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "\t" "ori $2,$2,0xffff" "\n" + "\t" "\t" "beq $6,$2,$L19" "\n" + "\t" "\t" "li $2,4294901760" "\n" // 0xffff0000 + "\t" "\t" "ori $2,$2,0xffff" "\n" + + "\t" "$L20:" "\n" + "\t" "\t" "sb $5,0($3)" "\n" + "\t" "\t" "addu $6,$6,-1" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "bne $6,$2,$L20" "\n" + "\t" "\t" "addu $3,$3,1" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "$L19:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set nomacro" "\n" + "\t" "\t" "j $31" "\n" + "\t" "\t" "move $2,$4" "\n" + "\t" "\t" ".set pop" "\n" + + "\t" "\t" ".end memset" "\n" +); +#endif + diff --git a/ee/kernel/src/setup_syscalls.S b/ee/kernel/src/setup_syscalls.S deleted file mode 100644 index a66893ec46d..00000000000 --- a/ee/kernel/src/setup_syscalls.S +++ /dev/null @@ -1,35 +0,0 @@ -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. - -.text - -.globl setup -.ent setup -setup: - li $v1, 0x74 - syscall - jr $ra - nop -.end setup - -.globl Copy -.ent Copy -Copy: - li $v1, 0x5A - syscall - jr $ra - nop -.end Copy - -.globl GetEntryAddress -.ent GetEntryAddress -GetEntryAddress: - li $v1, 0x5B - syscall - jr $ra - nop -.end GetEntryAddress diff --git a/ee/kernel/src/setup_syscalls.c b/ee/kernel/src/setup_syscalls.c new file mode 100644 index 00000000000..ca3f22c4e85 --- /dev/null +++ b/ee/kernel/src/setup_syscalls.c @@ -0,0 +1,57 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl setup" "\n" + "\t" ".ent setup" "\n" + "\t" "setup:" "\n" + "\t" "\t" "li $v1, 0x74" "\n" + "\t" "\t" "syscall" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end setup" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl Copy" "\n" + "\t" ".ent Copy" "\n" + "\t" "Copy:" "\n" + "\t" "\t" "li $v1, 0x5A" "\n" + "\t" "\t" "syscall" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end Copy" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl GetEntryAddress" "\n" + "\t" ".ent GetEntryAddress" "\n" + "\t" "GetEntryAddress:" "\n" + "\t" "\t" "li $v1, 0x5B" "\n" + "\t" "\t" "syscall" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end GetEntryAddress" "\n" +); diff --git a/ee/kernel/src/srcfile/src/dispatch.c b/ee/kernel/src/srcfile/src/dispatch.c new file mode 100644 index 00000000000..4b43a8a6401 --- /dev/null +++ b/ee/kernel/src/srcfile/src/dispatch.c @@ -0,0 +1,116 @@ + +#include + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl InvokeUserModeCallback" "\n" + "\t" ".ent InvokeUserModeCallback" "\n" + "\t" "InvokeUserModeCallback:" "\n" + // Also set status EXL=1 and KSU=01b (User Mode) + // COP0 registers: EPC ($14), status ($12) + "\t" "\t" "lui $k0, %hi(dispatch_ra)" "\n" + "\t" "\t" "sw $ra, %lo(dispatch_ra)($k0)" "\n" + "\t" "\t" "lui $k0, %hi(dispatch_sp)" "\n" + "\t" "\t" "sw $sp, %lo(dispatch_sp)($k0)" "\n" + "\t" "\t" "mtc0 $a0, $14" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "daddu $v1, $zero, $a1" "\n" + "\t" "\t" "daddu $a0, $zero, $a2" "\n" + "\t" "\t" "daddu $a1, $zero, $a3" "\n" + "\t" "\t" "daddu $a2, $zero, $a4" "\n" + "\t" "\t" "mfc0 $k0, $12" "\n" + "\t" "\t" "ori $k0, $k0, 0x12" "\n" + "\t" "\t" "mtc0 $k0, $12" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "eret" "\n" + "\t" ".end InvokeUserModeCallback" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl ResumeIntrDispatch" "\n" + "\t" ".ent ResumeIntrDispatch" "\n" + "\t" "ResumeIntrDispatch:" "\n" + // Clear IE and EXL, and set KSU=00b (Kernel Mode) + // COP0 registers: EPC ($14), status ($12) + "\t" "\t" "mfc0 $at, $12" "\n" + "\t" "\t" "addiu $k0, $zero, 0xFFE4" "\n" + "\t" "\t" "and $at, $at, $k0" "\n" + "\t" "\t" "mtc0 $at, $12" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "lui $k0, %hi(dispatch_ra)" "\n" + "\t" "\t" "lw $ra, %lo(dispatch_ra)($k0)" "\n" + "\t" "\t" "lui $k0, %hi(dispatch_sp)" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "lw $sp, %lo(dispatch_sp)($k0)" "\n" + "\t" ".end ResumeIntrDispatch" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl ChangeGP" "\n" + "\t" ".ent ChangeGP" "\n" + "\t" "ChangeGP:" "\n" + "\t" "\t" "move $v0, $gp" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "move $gp, $a0" "\n" + "\t" ".end ChangeGP" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl SetGP" "\n" + "\t" ".ent SetGP" "\n" + "\t" "SetGP:" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "move $gp, $a0" "\n" + "\t" ".end SetGP" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noat" "\n" + "\t" ".set noreorder" "\n" + + "\t" ".globl GetGP" "\n" + "\t" ".ent GetGP" "\n" + "\t" "GetGP:" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "move $v0, $gp" "\n" + "\t" ".end GetGP" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".pushsection .data" "\n" + "\t" "dispatch_ra: .quad 0" "\n" + "\t" "dispatch_sp: .quad 0" "\n" + "\t" ".popsection" "\n" +); diff --git a/ee/kernel/src/srcfile/src/dispatch.s b/ee/kernel/src/srcfile/src/dispatch.s deleted file mode 100644 index d2534879c82..00000000000 --- a/ee/kernel/src/srcfile/src/dispatch.s +++ /dev/null @@ -1,73 +0,0 @@ - -.set push -.set noat -.set noreorder - -.text - -.globl InvokeUserModeCallback -.ent InvokeUserModeCallback -InvokeUserModeCallback: - #Also set status EXL=1 and KSU=01b (User Mode) - #COP0 registers: EPC ($14), status ($12) - lui $k0, %hi(dispatch_ra) - sw $ra, %lo(dispatch_ra)($k0) - lui $k0, %hi(dispatch_sp) - sw $sp, %lo(dispatch_sp)($k0) - mtc0 $a0, $14 - sync.p - daddu $v1, $zero, $a1 - daddu $a0, $zero, $a2 - daddu $a1, $zero, $a3 - daddu $a2, $zero, $a4 - mfc0 $k0, $12 - ori $k0, $k0, 0x12 - mtc0 $k0, $12 - sync.p - eret -.end InvokeUserModeCallback - -.globl ResumeIntrDispatch -.ent ResumeIntrDispatch -ResumeIntrDispatch: - #Clear IE and EXL, and set KSU=00b (Kernel Mode) - #COP0 registers: EPC ($14), status ($12) - mfc0 $at, $12 - addiu $k0, $zero, 0xFFE4 - and $at, $at, $k0 - mtc0 $at, $12 - sync.p - lui $k0, %hi(dispatch_ra) - lw $ra, %lo(dispatch_ra)($k0) - lui $k0, %hi(dispatch_sp) - jr $ra - lw $sp, %lo(dispatch_sp)($k0) -.end ResumeIntrDispatch - -.globl ChangeGP -.ent ChangeGP -ChangeGP: - move $v0, $gp - jr $ra - move $gp, $a0 -.end ChangeGP - -.globl SetGP -.ent SetGP -SetGP: - jr $ra - move $gp, $a0 -.end SetGP - -.globl GetGP -.ent GetGP -GetGP: - jr $ra - move $v0, $gp -.end GetGP - -.set pop - -.data -dispatch_ra: .quad 0 -dispatch_sp: .quad 0 diff --git a/ee/libgs/src/ResetPath.c b/ee/libgs/src/ResetPath.c new file mode 100644 index 00000000000..abd99bccc31 --- /dev/null +++ b/ee/libgs/src/ResetPath.c @@ -0,0 +1,34 @@ + +unsigned int init_vif_regs_12[] = { + 0x10000404, 0x20000000, 0x00000000, 0x50000000, + 0x60000000, 0x30000000, 0x20000000, 0x40000000, +}; + +__asm__ +( + "\t" ".globl GsResetPath" "\n" + "\t" ".ent GsResetPath" "\n" + "\t" "GsResetPath:" "\n" + "\t" "\t" "li $a3, 1" "\n" + "\t" "\t" "la $v0, 0x10003C10" "\n" + "\t" "\t" "sw $a3, ($v0)" "\n" + "\t" "\t" "la $v1, 0x10003C20" "\n" + "\t" "\t" "li $v0, 2" "\n" + "\t" "\t" "move $a0, $zero" "\n" + "\t" "\t" "sw $v0, 0($v1)" "\n" + "\t" "\t" "sync" "\n" + "\t" "\t" "cfc2 $a0, $28" "\n" + "\t" "\t" "ori $a0, 0x200" "\n" + "\t" "\t" "ctc2 $a0, $28" "\n" + "\t" "\t" "sync.p" "\n" + "\t" "\t" "la $a1, init_vif_regs_12" "\n" + "\t" "\t" "la $a2, 0x10005000" "\n" + "\t" "\t" "lq $a0, ($a1)" "\n" + "\t" "\t" "la $v1, 0x10003000" "\n" + "\t" "\t" "sq $a0, ($a2)" "\n" + "\t" "\t" "lq $v0, 8($a1)" "\n" + "\t" "\t" "sq $v0, ($a2)" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "sw $a3, 0($v1)" "\n" + "\t" ".end GsResetPath" "\n" +); diff --git a/ee/libgs/src/ResetPath.s b/ee/libgs/src/ResetPath.s deleted file mode 100755 index 3c454796f28..00000000000 --- a/ee/libgs/src/ResetPath.s +++ /dev/null @@ -1,32 +0,0 @@ -.data - -init_vif_regs_12: .word 0x10000404, 0x20000000, 0x00000000, 0x50000000 - .word 0x60000000, 0x30000000, 0x20000000, 0x40000000 - -.text - -.globl GsResetPath -.ent GsResetPath -GsResetPath: - li $a3, 1 - la $v0, 0x10003C10 - sw $a3, ($v0) - la $v1, 0x10003C20 - li $v0, 2 - move $a0, $zero - sw $v0, 0($v1) - sync - cfc2 $a0, $28 - ori $a0, 0x200 - ctc2 $a0, $28 - sync.p - la $a1, init_vif_regs_12 - la $a2, 0x10005000 - lq $a0, ($a1) - la $v1, 0x10003000 - sq $a0, ($a2) - lq $v0, 8($a1) - sq $v0, ($a2) - jr $ra - sw $a3, 0($v1) -.end GsResetPath diff --git a/iop/debug/iopdebug/src/iop_dbg_low.S b/iop/debug/iopdebug/src/iop_dbg_low.S deleted file mode 100644 index bad5b878f85..00000000000 --- a/iop/debug/iopdebug/src/iop_dbg_low.S +++ /dev/null @@ -1,172 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2009, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - -/** - * @file - * IOPDEBUG - IOP debugging library. - * low-level IOP "debug" helper functions. - */ - -#include -#include "iopdebug_defs.h" -#include "as_reg_compat.h" - -.set push -.set noreorder -.set noat - -.global iop_dbg_get_dcic -.ent iop_dbg_get_dcic -iop_dbg_get_dcic: - mfc0 $v0, IOP_COP0_DCIC - nop - jr $ra - nop -.end iop_dbg_get_dcic - -.global iop_dbg_get_bpc -.ent iop_dbg_get_bpc -iop_dbg_get_bpc: - mtc0 $v0, IOP_COP0_BPC - nop - jr $ra - nop -.end iop_dbg_get_bpc - -.global iop_dbg_get_bpcm -.ent iop_dbg_get_bpcm -iop_dbg_get_bpcm: - mfc0 $v0, IOP_COP0_BPCM - nop - jr $ra - nop - -.end iop_dbg_get_bpcm - -.global iop_dbg_get_bda -.ent iop_dbg_get_bda -iop_dbg_get_bda: - mfc0 $v0, IOP_COP0_BDA - nop - jr $ra - nop -.end iop_dbg_get_bda - -.global iop_dbg_get_bdam -.ent iop_dbg_get_bdam -iop_dbg_get_bdam: - mfc0 $v0, IOP_COP0_BDAM - nop - jr $ra - nop -.end iop_dbg_get_bdam - -.global iop_dbg_set_dcic -.ent iop_dbg_set_dcic -iop_dbg_set_dcic: - mtc0 $a0, IOP_COP0_DCIC - nop - jr $ra - nop -.end iop_dbg_set_dcic - -.global iop_dbg_set_bpc -.ent iop_dbg_set_bpc -iop_dbg_set_bpc: - mtc0 $a0, IOP_COP0_BPC - nop - jr $ra - nop -.end iop_dbg_set_bpc - -.global iop_dbg_set_bpcm -.ent iop_dbg_set_bpcm -iop_dbg_set_bpcm: - mtc0 $a0, IOP_COP0_BPCM - nop - jr $ra - nop -.end iop_dbg_set_bpcm - - -.global iop_dbg_set_bda -.ent iop_dbg_set_bda -iop_dbg_set_bda: - mtc0 $a0, IOP_COP0_BDA - nop - jr $ra - nop -.end iop_dbg_set_bda - -.global iop_dbg_set_bdam -.ent iop_dbg_set_bdam -iop_dbg_set_bdam: - mtc0 $a0, IOP_COP0_BDAM - nop - jr $ra - nop -.end iop_dbg_set_bdam - -.global _iop_dbg_set_bpda -.ent _iop_dbg_set_bpda -_iop_dbg_set_bpda: - - mfc0 $t0, IOP_COP0_DCIC - nop - nop - mtc0 $zero, IOP_COP0_DCIC - nop - nop - - mtc0 $a0, IOP_COP0_BDA - mtc0 $a1, IOP_COP0_BDAM - - li $t1, ~(IOP_DCIC_DR | IOP_DCIC_DW) - and $t0, $t0, $t1 - - li $t1, (IOP_DCIC_TR | IOP_DCIC_DAE | IOP_DCIC_DE) - or $t0, $t0, $t1 - or $t0, $t0, $a2 - mtc0 $t0, IOP_COP0_DCIC - nop - jr $ra - nop - -.end _iop_dbg_set_bpda - -.global _iop_dbg_set_bpx -.ent _iop_dbg_set_bpx -_iop_dbg_set_bpx: - - mfc0 $t0, IOP_COP0_DCIC - nop - nop - mtc0 $zero, IOP_COP0_DCIC - nop - nop - - mtc0 $a0, IOP_COP0_BPC - mtc0 $a1, IOP_COP0_BPCM - nop - - li $t1, ~(IOP_DCIC_PC) - and $t0, $t0, $t1 - - li $t1, (IOP_DCIC_TR | IOP_DCIC_PCE | IOP_DCIC_DE) - or $t0, $t0, $t1 - or $t0, $t0, $a2 - mtc0 $t0, IOP_COP0_DCIC - nop - jr $ra - nop - -.end _iop_dbg_set_bpx - -.set pop diff --git a/iop/debug/iopdebug/src/iop_dbg_low.c b/iop/debug/iopdebug/src/iop_dbg_low.c new file mode 100644 index 00000000000..db1959a8e9e --- /dev/null +++ b/iop/debug/iopdebug/src/iop_dbg_low.c @@ -0,0 +1,275 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2009, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +/** + * @file + * IOPDEBUG - IOP debugging library. + * low-level IOP "debug" helper functions. + */ + +#include +#include "iopdebug_defs.h" + +#define STRINNER(x) #x +#define STR(x) STRINNER(x) + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_get_dcic" "\n" + "\t" ".ent iop_dbg_get_dcic" "\n" + "\t" "iop_dbg_get_dcic:" "\n" + "\t" "\t" "mfc0 $v0, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_get_dcic" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_get_bpc" "\n" + "\t" ".ent iop_dbg_get_bpc" "\n" + "\t" "iop_dbg_get_bpc:" "\n" + "\t" "\t" "mtc0 $v0, " STR(IOP_COP0_BPC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_get_bpc" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_get_bpcm" "\n" + "\t" ".ent iop_dbg_get_bpcm" "\n" + "\t" "iop_dbg_get_bpcm:" "\n" + "\t" "\t" "mfc0 $v0, " STR(IOP_COP0_BPCM) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end iop_dbg_get_bpcm" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_get_bda" "\n" + "\t" ".ent iop_dbg_get_bda" "\n" + "\t" "iop_dbg_get_bda:" "\n" + "\t" "\t" "mfc0 $v0, " STR(IOP_COP0_BDA) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_get_bda" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_get_bdam" "\n" + "\t" ".ent iop_dbg_get_bdam" "\n" + "\t" "iop_dbg_get_bdam:" "\n" + "\t" "\t" "mfc0 $v0, " STR(IOP_COP0_BDAM) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_get_bdam" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_set_dcic" "\n" + "\t" ".ent iop_dbg_set_dcic" "\n" + "\t" "iop_dbg_set_dcic:" "\n" + "\t" "\t" "mtc0 $a0, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_set_dcic" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_set_bpc" "\n" + "\t" ".ent iop_dbg_set_bpc" "\n" + "\t" "iop_dbg_set_bpc:" "\n" + "\t" "\t" "mtc0 $a0, " STR(IOP_COP0_BPC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_set_bpc" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_set_bpcm" "\n" + "\t" ".ent iop_dbg_set_bpcm" "\n" + "\t" "iop_dbg_set_bpcm:" "\n" + "\t" "\t" "mtc0 $a0, " STR(IOP_COP0_BPCM) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_set_bpcm" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_set_bda" "\n" + "\t" ".ent iop_dbg_set_bda" "\n" + "\t" "iop_dbg_set_bda:" "\n" + "\t" "\t" "mtc0 $a0, " STR(IOP_COP0_BDA) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_set_bda" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global iop_dbg_set_bdam" "\n" + "\t" ".ent iop_dbg_set_bdam" "\n" + "\t" "iop_dbg_set_bdam:" "\n" + "\t" "\t" "mtc0 $a0, " STR(IOP_COP0_BDAM) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end iop_dbg_set_bdam" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global _iop_dbg_set_bpda" "\n" + "\t" ".ent _iop_dbg_set_bpda" "\n" + "\t" "_iop_dbg_set_bpda:" "\n" + + "\t" "\t" "mfc0 $t0, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $zero, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "mtc0 $a0, " STR(IOP_COP0_BDA) "" "\n" + "\t" "\t" "mtc0 $a1, " STR(IOP_COP0_BDAM) "" "\n" + + "\t" "\t" "li $t1, ~(" STR(IOP_DCIC_DR) " | " STR(IOP_DCIC_DW) ")" "\n" + "\t" "\t" "and $t0, $t0, $t1" "\n" + + "\t" "\t" "li $t1, (" STR(IOP_DCIC_TR) " | " STR(IOP_DCIC_DAE) " | " STR(IOP_DCIC_DE) ")" "\n" + "\t" "\t" "or $t0, $t0, $t1" "\n" + "\t" "\t" "or $t0, $t0, $a2" "\n" + "\t" "\t" "mtc0 $t0, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end _iop_dbg_set_bpda" "\n" + + "\t" ".set pop" "\n" +); + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global _iop_dbg_set_bpx" "\n" + "\t" ".ent _iop_dbg_set_bpx" "\n" + "\t" "_iop_dbg_set_bpx:" "\n" + + "\t" "\t" "mfc0 $t0, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $zero, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "mtc0 $a0, " STR(IOP_COP0_BPC) "" "\n" + "\t" "\t" "mtc0 $a1, " STR(IOP_COP0_BPCM) "" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "li $t1, ~(" STR(IOP_DCIC_PC) ")" "\n" + "\t" "\t" "and $t0, $t0, $t1" "\n" + + "\t" "\t" "li $t1, (" STR(IOP_DCIC_TR) " | " STR(IOP_DCIC_PCE) " | " STR(IOP_DCIC_DE) ")" "\n" + "\t" "\t" "or $t0, $t0, $t1" "\n" + "\t" "\t" "or $t0, $t0, $a2" "\n" + "\t" "\t" "mtc0 $t0, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + + "\t" ".end _iop_dbg_set_bpx" "\n" + + "\t" ".set pop" "\n" +); diff --git a/iop/debug/iopdebug/src/iop_exceptions.S b/iop/debug/iopdebug/src/iop_exceptions.S deleted file mode 100644 index 3a134aa2539..00000000000 --- a/iop/debug/iopdebug/src/iop_exceptions.S +++ /dev/null @@ -1,288 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2009, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - -/** - * @file - * IOPDEBUG - IOP debugging library. - * low-level IOP exception-handler code. - */ - -#include -#include "iopdebug_defs.h" -#include "as_reg_compat.h" - -.set push -.set noreorder -.set noat - -.global _iop_save_frame -.ent _iop_save_frame -_iop_save_frame: - sw $zero, 0x000($s0) - - sw $at, 0x004($s0) - - sw $v0, 0x008($s0) - sw $v1, 0x00C($s0) - - sw $a0, 0x010($s0) - sw $a1, 0x014($s0) - sw $a2, 0x018($s0) - sw $a3, 0x01C($s0) - - sw $t0, 0x020($s0) - sw $t1, 0x024($s0) - sw $t2, 0x028($s0) - sw $t3, 0x02C($s0) - sw $t4, 0x030($s0) - sw $t5, 0x034($s0) - sw $t6, 0x038($s0) - sw $t7, 0x03C($s0) - -// sw $s0, 0x040($s0) - sw $s1, 0x044($s0) - sw $s2, 0x048($s0) - sw $s3, 0x04C($s0) - sw $s4, 0x050($s0) - sw $s5, 0x054($s0) - sw $s6, 0x058($s0) - sw $s7, 0x05C($s0) - - sw $t8, 0x060($s0) - sw $t9, 0x064($s0) - -// sw $k0, 0x068($s0) - sw $k1, 0x06C($s0) - - sw $gp, 0x070($s0) -// sw $sp, 0x074($s0) - sw $fp, 0x078($s0) -// sw $ra, 0x07C($s0) - - mfhi $t0 // hi - mflo $t1 // lo - nop // necessary?? - sw $t0, 0x080($s0) - sw $t1, 0x084($s0) - nop // necessary?? - - mfc0 $t0, $3 // IOP_COP0_BPC - mfc0 $t1, $5 // IOP_COP0_BDA - mfc0 $t2, $8 // IOP_COP0_BADVADDR - mfc0 $t3, $9 // IOP_COP0_BDAM - mfc0 $t4, $11 // IOP_COP0_BPCM - mfc0 $t5, $12 // SR - mfc0 $t6, $13 // Cause - mfc0 $t7, $14 // EPC - - sw $t0, 0x088($s0) - sw $t1, 0x08C($s0) - // gap for IOP_COP0_DCIC - sw $t2, 0x094($s0) - sw $t3, 0x098($s0) - sw $t4, 0x09C($s0) - sw $t5, 0x0A0($s0) - sw $t6, 0x0A4($s0) - sw $t7, 0x0A8($s0) - - jr $ra - nop -.end _iop_save_frame - -.global _iop_load_frame -.ent _iop_load_frame -_iop_load_frame: -// lw $zero, 0x000($s0) - - lw $at, 0x004($s0) - - lw $v0, 0x008($s0) - lw $v1, 0x00C($s0) - - lw $a0, 0x010($s0) - lw $a1, 0x014($s0) - lw $a2, 0x018($s0) - lw $a3, 0x01C($s0) - -// lw $s0, 0x040($s0) - lw $s1, 0x044($s0) - lw $s2, 0x048($s0) - lw $s3, 0x04C($s0) - lw $s4, 0x050($s0) - lw $s5, 0x054($s0) - lw $s6, 0x058($s0) - lw $s7, 0x05C($s0) - - lw $t8, 0x060($s0) - lw $t9, 0x064($s0) - -// lw $k0, 0x068($s0) - lw $k1, 0x06C($s0) - - lw $gp, 0x070($s0) -// lw $sp, 0x074($s0) - lw $fp, 0x078($s0) -// lw $ra, 0x07C($s0) - - lw $t0, 0x080($s0) - lw $t1, 0x084($s0) - mthi $t0 // hi - mtlo $t1 // lo - nop - nop - - lw $t0, 0x088($s0) - lw $t1, 0x08C($s0) - mtc0 $t0, $3 // IOP_COP0_BPC - mtc0 $t1, $5 // IOP_COP0_BDA - - // gap for IOP_COP0_DCIC - lw $t2, 0x094($s0) - lw $t3, 0x098($s0) - mtc0 $t2, $8 // IOP_COP0_BADVADDR - mtc0 $t3, $9 // IOP_COP0_BDAM - - lw $t4, 0x09C($s0) - lw $t5, 0x0A0($s0) - mtc0 $t4, $11 // IOP_COP0_BPCM - mtc0 $t5, $12 // SR - - lw $t6, 0x0A4($s0) - lw $t7, 0x0A8($s0) - mtc0 $t6, $13 // Cause - mtc0 $t7, $14 // EPC - - lw $t0, 0x020($s0) - lw $t1, 0x024($s0) - lw $t2, 0x028($s0) - lw $t3, 0x02c($s0) - lw $t4, 0x030($s0) - lw $t5, 0x034($s0) - lw $t6, 0x038($s0) - lw $t7, 0x03C($s0) - - jr $ra - nop -.end _iop_load_frame - -.global _iop_ex_cmn -.ent _iop_ex_cmn -_iop_ex_cmn: - addiu $sp, $sp, -0x10 - sw $ra, 0x00($sp) - nop - - jal _iop_save_frame - nop - - jal iop_exception_dispatcher - move $a0, $s0 - - jal _iop_load_frame - nop - - lw $ra, 0x00($sp) - nop - jr $ra - addiu $sp, $sp, 0x10 -.end _iop_ex_cmn - -.global _iop_ex_def_handler -.ent _iop_ex_def_handler -_iop_ex_def_handler: - nop - nop - -___iop_ex_def_handler_start: - la $k0, _iop_ex_def_frame - - sw $s0, 0x040($k0) // Save $s0 - sw $sp, 0x074($k0) // Save $sp - mfc0 $s0, IOP_COP0_DCIC - sw $ra, 0x07C($k0) // Save $ra - lw $sp, 0x410($zero) // k0 saved here by default exception prologue (at 0x80) - sw $s0, 0x090($k0) // Save IOP_COP0_DCIC - sw $sp, 0x068($k0) // Save $k0 - lw $at, 0x400($0) // at is saved here by default exception prologue (at 0x80) - la $sp, _iop_ex_def_stack + _EX_DEF_STACK_SIZE - - jal _iop_ex_cmn - move $s0, $k0 - - lw $k0, 0x068($s0) // restore k0 - lw $sp, 0x074($s0) // restore sp - lw $ra, 0x07C($s0) // restore ra - - lw $k1, 0x090($s0) // restore IOP_COP0_DCIC - nop - mtc0 $k1, IOP_COP0_DCIC - nop - - lw $k1, 0x0A8($s0) - nop - mtc0 $k1, $14 // EPC - lw $s0, 0x040($s0) // restore s0 - nop - jr $k1 - cop0 0x10 - nop - nop -.end _iop_ex_def_handler - -.global _iop_ex_break_handler -.ent _iop_ex_break_handler -_iop_ex_break_handler: - nop - nop - j ___iop_ex_def_handler_start - nop -.end _iop_ex_break_handler - -.global _iop_ex_dbg_handler -.ent _iop_ex_dbg_handler -_iop_ex_dbg_handler: - nop - nop - - la $k0, _iop_ex_dbg_frame - - sw $s0, 0x040($k0) // Save $s0 - sw $sp, 0x074($k0) // Save $sp - sw $ra, 0x07C($k0) // Save $ra - lw $sp, 0x420($zero) // k0 saved here by debug exception prologue (at 0x40) - lw $s0, 0x430($0) // IOP_COP0_DCIC is saved here by debug exception prologue (at 0x40) - sw $sp, 0x068($k0) // Save $k0 - sw $s0, 0x090($k0) // Save IOP_COP0_DCIC - la $sp, _iop_ex_dbg_stack + _EX_DBG_STACK_SIZE - - jal _iop_ex_cmn - move $s0, $k0 - - lw $k0, 0x068($s0) // restore k0 - lw $sp, 0x074($s0) // restore sp - lw $ra, 0x07C($s0) // restore ra - - lw $k1, 0x090($s0) // restore IOP_COP0_DCIC - nop - mtc0 $k1, IOP_COP0_DCIC - nop - - lw $k1, 0x0A8($s0) - nop - mtc0 $k1, $14 // EPC - lw $s0, 0x040($s0) // restore s0 - nop - jr $k1 - cop0 0x10 - nop - nop -.end _iop_ex_dbg_handler - -.set pop diff --git a/iop/debug/iopdebug/src/iop_exceptions.c b/iop/debug/iopdebug/src/iop_exceptions.c new file mode 100644 index 00000000000..4a7087da566 --- /dev/null +++ b/iop/debug/iopdebug/src/iop_exceptions.c @@ -0,0 +1,293 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2009, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +/** + * @file + * IOPDEBUG - IOP debugging library. + * low-level IOP exception-handler code. + */ + +#include +#include "iopdebug_defs.h" + +#define STRINNER(x) #x +#define STR(x) STRINNER(x) + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + "\t" ".set noat" "\n" + + "\t" ".global _iop_save_frame" "\n" + "\t" ".ent _iop_save_frame" "\n" + "\t" "_iop_save_frame:" "\n" + "\t" "\t" "sw $zero, 0x000($s0)" "\n" + + "\t" "\t" "sw $at, 0x004($s0)" "\n" + + "\t" "\t" "sw $v0, 0x008($s0)" "\n" + "\t" "\t" "sw $v1, 0x00C($s0)" "\n" + + "\t" "\t" "sw $a0, 0x010($s0)" "\n" + "\t" "\t" "sw $a1, 0x014($s0)" "\n" + "\t" "\t" "sw $a2, 0x018($s0)" "\n" + "\t" "\t" "sw $a3, 0x01C($s0)" "\n" + + "\t" "\t" "sw $t0, 0x020($s0)" "\n" + "\t" "\t" "sw $t1, 0x024($s0)" "\n" + "\t" "\t" "sw $t2, 0x028($s0)" "\n" + "\t" "\t" "sw $t3, 0x02C($s0)" "\n" + "\t" "\t" "sw $t4, 0x030($s0)" "\n" + "\t" "\t" "sw $t5, 0x034($s0)" "\n" + "\t" "\t" "sw $t6, 0x038($s0)" "\n" + "\t" "\t" "sw $t7, 0x03C($s0)" "\n" + + // "\t" "\t" "sw $s0, 0x040($s0)" "\n" + "\t" "\t" "sw $s1, 0x044($s0)" "\n" + "\t" "\t" "sw $s2, 0x048($s0)" "\n" + "\t" "\t" "sw $s3, 0x04C($s0)" "\n" + "\t" "\t" "sw $s4, 0x050($s0)" "\n" + "\t" "\t" "sw $s5, 0x054($s0)" "\n" + "\t" "\t" "sw $s6, 0x058($s0)" "\n" + "\t" "\t" "sw $s7, 0x05C($s0)" "\n" + + "\t" "\t" "sw $t8, 0x060($s0)" "\n" + "\t" "\t" "sw $t9, 0x064($s0)" "\n" + + // "\t" "\t" "sw $k0, 0x068($s0)" "\n" + "\t" "\t" "sw $k1, 0x06C($s0)" "\n" + + "\t" "\t" "sw $gp, 0x070($s0)" "\n" + // "\t" "\t" "sw $sp, 0x074($s0)" "\n" + "\t" "\t" "sw $fp, 0x078($s0)" "\n" + // "\t" "\t" "sw $ra, 0x07C($s0)" "\n" + + "\t" "\t" "mfhi $t0" "\n" // hi + "\t" "\t" "mflo $t1" "\n" // lo + "\t" "\t" "nop" "\n" // necessary?? + "\t" "\t" "sw $t0, 0x080($s0)" "\n" + "\t" "\t" "sw $t1, 0x084($s0)" "\n" + "\t" "\t" "nop" "\n" // necessary?? + + "\t" "\t" "mfc0 $t0, $3" "\n" // IOP_COP0_BPC + "\t" "\t" "mfc0 $t1, $5" "\n" // IOP_COP0_BDA + "\t" "\t" "mfc0 $t2, $8" "\n" // IOP_COP0_BADVADDR + "\t" "\t" "mfc0 $t3, $9" "\n" // IOP_COP0_BDAM + "\t" "\t" "mfc0 $t4, $11" "\n" // IOP_COP0_BPCM + "\t" "\t" "mfc0 $t5, $12" "\n" // SR + "\t" "\t" "mfc0 $t6, $13" "\n" // Cause + "\t" "\t" "mfc0 $t7, $14" "\n" // EPC + + "\t" "\t" "sw $t0, 0x088($s0)" "\n" + "\t" "\t" "sw $t1, 0x08C($s0)" "\n" + // gap for IOP_COP0_DCIC + "\t" "\t" "sw $t2, 0x094($s0)" "\n" + "\t" "\t" "sw $t3, 0x098($s0)" "\n" + "\t" "\t" "sw $t4, 0x09C($s0)" "\n" + "\t" "\t" "sw $t5, 0x0A0($s0)" "\n" + "\t" "\t" "sw $t6, 0x0A4($s0)" "\n" + "\t" "\t" "sw $t7, 0x0A8($s0)" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end _iop_save_frame" "\n" + + "\t" ".global _iop_load_frame" "\n" + "\t" ".ent _iop_load_frame" "\n" + "\t" "_iop_load_frame:" "\n" + // "\t" "\t" "lw $zero, 0x000($s0)" "\n" + + "\t" "\t" "lw $at, 0x004($s0)" "\n" + + "\t" "\t" "lw $v0, 0x008($s0)" "\n" + "\t" "\t" "lw $v1, 0x00C($s0)" "\n" + + "\t" "\t" "lw $a0, 0x010($s0)" "\n" + "\t" "\t" "lw $a1, 0x014($s0)" "\n" + "\t" "\t" "lw $a2, 0x018($s0)" "\n" + "\t" "\t" "lw $a3, 0x01C($s0)" "\n" + + // "\t" "\t" "lw $s0, 0x040($s0)" "\n" + "\t" "\t" "lw $s1, 0x044($s0)" "\n" + "\t" "\t" "lw $s2, 0x048($s0)" "\n" + "\t" "\t" "lw $s3, 0x04C($s0)" "\n" + "\t" "\t" "lw $s4, 0x050($s0)" "\n" + "\t" "\t" "lw $s5, 0x054($s0)" "\n" + "\t" "\t" "lw $s6, 0x058($s0)" "\n" + "\t" "\t" "lw $s7, 0x05C($s0)" "\n" + + "\t" "\t" "lw $t8, 0x060($s0)" "\n" + "\t" "\t" "lw $t9, 0x064($s0)" "\n" + + // "\t" "\t" "lw $k0, 0x068($s0)" "\n" + "\t" "\t" "lw $k1, 0x06C($s0)" "\n" + + "\t" "\t" "lw $gp, 0x070($s0)" "\n" + // "\t" "\t" "lw $sp, 0x074($s0)" "\n" + "\t" "\t" "lw $fp, 0x078($s0)" "\n" + // "\t" "\t" "lw $ra, 0x07C($s0)" "\n" + + "\t" "\t" "lw $t0, 0x080($s0)" "\n" + "\t" "\t" "lw $t1, 0x084($s0)" "\n" + "\t" "\t" "mthi $t0" "\n" // hi + "\t" "\t" "mtlo $t1" "\n" // lo + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "lw $t0, 0x088($s0)" "\n" + "\t" "\t" "lw $t1, 0x08C($s0)" "\n" + "\t" "\t" "mtc0 $t0, $3" "\n" // IOP_COP0_BPC + "\t" "\t" "mtc0 $t1, $5" "\n" // IOP_COP0_BDA + + // gap for IOP_COP0_DCIC + "\t" "\t" "lw $t2, 0x094($s0)" "\n" + "\t" "\t" "lw $t3, 0x098($s0)" "\n" + "\t" "\t" "mtc0 $t2, $8" "\n" // IOP_COP0_BADVADDR + "\t" "\t" "mtc0 $t3, $9" "\n" // IOP_COP0_BDAM + + "\t" "\t" "lw $t4, 0x09C($s0)" "\n" + "\t" "\t" "lw $t5, 0x0A0($s0)" "\n" + "\t" "\t" "mtc0 $t4, $11" "\n" // IOP_COP0_BPCM + "\t" "\t" "mtc0 $t5, $12" "\n" // SR + + "\t" "\t" "lw $t6, 0x0A4($s0)" "\n" + "\t" "\t" "lw $t7, 0x0A8($s0)" "\n" + "\t" "\t" "mtc0 $t6, $13" "\n" // Cause + "\t" "\t" "mtc0 $t7, $14" "\n" // EPC + + "\t" "\t" "lw $t0, 0x020($s0)" "\n" + "\t" "\t" "lw $t1, 0x024($s0)" "\n" + "\t" "\t" "lw $t2, 0x028($s0)" "\n" + "\t" "\t" "lw $t3, 0x02c($s0)" "\n" + "\t" "\t" "lw $t4, 0x030($s0)" "\n" + "\t" "\t" "lw $t5, 0x034($s0)" "\n" + "\t" "\t" "lw $t6, 0x038($s0)" "\n" + "\t" "\t" "lw $t7, 0x03C($s0)" "\n" + + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end _iop_load_frame" "\n" + + "\t" ".global _iop_ex_cmn" "\n" + "\t" ".ent _iop_ex_cmn" "\n" + "\t" "_iop_ex_cmn:" "\n" + "\t" "\t" "addiu $sp, $sp, -0x10" "\n" + "\t" "\t" "sw $ra, 0x00($sp)" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "jal _iop_save_frame" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "jal iop_exception_dispatcher" "\n" + "\t" "\t" "move $a0, $s0" "\n" + + "\t" "\t" "jal _iop_load_frame" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "lw $ra, 0x00($sp)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $ra" "\n" + "\t" "\t" "addiu $sp, $sp, 0x10" "\n" + "\t" ".end _iop_ex_cmn" "\n" + + "\t" ".global _iop_ex_def_handler" "\n" + "\t" ".ent _iop_ex_def_handler" "\n" + "\t" "_iop_ex_def_handler:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + + "\t" "___iop_ex_def_handler_start:" "\n" + "\t" "\t" "la $k0, _iop_ex_def_frame" "\n" + + "\t" "\t" "sw $s0, 0x040($k0)" "\n" // Save $s0 + "\t" "\t" "sw $sp, 0x074($k0)" "\n" // Save $sp + "\t" "\t" "mfc0 $s0, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "sw $ra, 0x07C($k0)" "\n" // Save $ra + "\t" "\t" "lw $sp, 0x410($zero)" "\n" // k0 saved here by default exception prologue (at 0x80) + "\t" "\t" "sw $s0, 0x090($k0)" "\n" // Save IOP_COP0_DCIC + "\t" "\t" "sw $sp, 0x068($k0)" "\n" // Save $k0 + "\t" "\t" "lw $at, 0x400($0)" "\n" // at is saved here by default exception prologue (at 0x80) + "\t" "\t" "la $sp, _iop_ex_def_stack + " STR(_EX_DEF_STACK_SIZE) "" "\n" + + "\t" "\t" "jal _iop_ex_cmn" "\n" + "\t" "\t" "move $s0, $k0" "\n" + + "\t" "\t" "lw $k0, 0x068($s0)" "\n" // restore k0 + "\t" "\t" "lw $sp, 0x074($s0)" "\n" // restore sp + "\t" "\t" "lw $ra, 0x07C($s0)" "\n" // restore ra + + "\t" "\t" "lw $k1, 0x090($s0)" "\n" // restore IOP_COP0_DCIC + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $k1, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "lw $k1, 0x0A8($s0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $k1, $14" "\n" // EPC + "\t" "\t" "lw $s0, 0x040($s0)" "\n" // restore s0 + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $k1" "\n" + "\t" "\t" "cop0 0x10" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end _iop_ex_def_handler" "\n" + + "\t" ".global _iop_ex_break_handler" "\n" + "\t" ".ent _iop_ex_break_handler" "\n" + "\t" "_iop_ex_break_handler:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "j ___iop_ex_def_handler_start" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end _iop_ex_break_handler" "\n" + + "\t" ".global _iop_ex_dbg_handler" "\n" + "\t" ".ent _iop_ex_dbg_handler" "\n" + "\t" "_iop_ex_dbg_handler:" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "la $k0, _iop_ex_dbg_frame" "\n" + + "\t" "\t" "sw $s0, 0x040($k0)" "\n" // Save $s0 + "\t" "\t" "sw $sp, 0x074($k0)" "\n" // Save $sp + "\t" "\t" "sw $ra, 0x07C($k0)" "\n" // Save $ra + "\t" "\t" "lw $sp, 0x420($zero)" "\n" // k0 saved here by debug exception prologue (at 0x40) + "\t" "\t" "lw $s0, 0x430($0)" "\n" // IOP_COP0_DCIC is saved here by debug exception prologue (at 0x40) + "\t" "\t" "sw $sp, 0x068($k0)" "\n" // Save $k0 + "\t" "\t" "sw $s0, 0x090($k0)" "\n" // Save IOP_COP0_DCIC + "\t" "\t" "la $sp, _iop_ex_dbg_stack + " STR(_EX_DBG_STACK_SIZE) "" "\n" + + "\t" "\t" "jal _iop_ex_cmn" "\n" + "\t" "\t" "move $s0, $k0" "\n" + + "\t" "\t" "lw $k0, 0x068($s0)" "\n" // restore k0 + "\t" "\t" "lw $sp, 0x074($s0)" "\n" // restore sp + "\t" "\t" "lw $ra, 0x07C($s0)" "\n" // restore ra + + "\t" "\t" "lw $k1, 0x090($s0)" "\n" // restore IOP_COP0_DCIC + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $k1, " STR(IOP_COP0_DCIC) "" "\n" + "\t" "\t" "nop" "\n" + + "\t" "\t" "lw $k1, 0x0A8($s0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $k1, $14" "\n" // EPC + "\t" "\t" "lw $s0, 0x040($s0)" "\n" // restore s0 + "\t" "\t" "nop" "\n" + "\t" "\t" "jr $k1" "\n" + "\t" "\t" "cop0 0x10" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "nop" "\n" + "\t" ".end _iop_ex_dbg_handler" "\n" + + "\t" ".set pop" "\n" +); diff --git a/iop/debug/ioptrap/src/handler.S b/iop/debug/ioptrap/src/handler.S deleted file mode 100644 index 6d8b6af49c6..00000000000 --- a/iop/debug/ioptrap/src/handler.S +++ /dev/null @@ -1,295 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - - -#include "as_reg_compat.h" - -#define GENERAL_ATSAVE 0x400 -#define GENERAL_SRSAVE - - .global def_exc_handler - .ent def_exc_handler -def_exc_handler: - .set push - .set noreorder - .set noat - .word 0 - .word 0 - la $k0, __trap_frame - sw $0, 0x10($k0) - - lw $1, 0x400($0) - nop - sw $1, 0x14($k0) - - sw $2, 0x18($k0) - sw $3, 0x1c($k0) - sw $4, 0x20($k0) - sw $5, 0x24($k0) - sw $6, 0x28($k0) - sw $7, 0x2c($k0) - sw $8, 0x30($k0) - sw $9, 0x34($k0) - sw $10, 0x38($k0) - sw $11, 0x3c($k0) - sw $12, 0x40($k0) - sw $13, 0x44($k0) - sw $14, 0x48($k0) - sw $15, 0x4c($k0) - sw $16, 0x50($k0) - sw $17, 0x54($k0) - sw $18, 0x58($k0) - sw $19, 0x5c($k0) - sw $20, 0x60($k0) - sw $21, 0x64($k0) - sw $22, 0x68($k0) - sw $23, 0x6c($k0) - sw $24, 0x70($k0) - sw $25, 0x74($k0) - sw $26, 0x78($k0) - sw $27, 0x7c($k0) - sw $28, 0x80($k0) - sw $29, 0x84($k0) - sw $30, 0x88($k0) - sw $31, 0x8c($k0) - mfhi $a0 - nop - sw $a0, 0x90($k0) - - mflo $a0 - nop - sw $a0, 0x94($k0) - - - # lw $a0, 0x404($0) # saved EPC - mfc0 $a0, $14 # EPC - nop - sw $a0, 0($k0) - - # lw $a0, 0x408($0) # saved SR - mfc0 $a0, $12 # SR - nop - sw $a0, 0xc($k0) - - mfc0 $a0, $8 # BadVaddr - nop - sw $a0, 0x8($k0) - - sw $0, 0x98($k0) - - - # lw $a0, 0x40c($0) # saved Cause - mfc0 $a0, $13 # Cause - nop - sw $a0, 4($k0) - - sll $a0, 25 - srl $a0, 27 - jal trap - or $a1, $k0, $0 - - la $k0, __trap_frame - - lw $a0, 0x94($k0) - nop - mtlo $a0 - - lw $a0, 0x90($k0) - nop - mthi $a0 - - # lw $0, 0x10($k0) - lw $1, 0x14($k0) - lw $2, 0x18($k0) - lw $3, 0x1c($k0) - lw $4, 0x20($k0) - lw $5, 0x24($k0) - lw $6, 0x28($k0) - lw $7, 0x2c($k0) - lw $8, 0x30($k0) - lw $9, 0x34($k0) - lw $10, 0x38($k0) - lw $11, 0x3c($k0) - lw $12, 0x40($k0) - lw $13, 0x44($k0) - lw $14, 0x48($k0) - lw $15, 0x4c($k0) - lw $16, 0x50($k0) - lw $17, 0x54($k0) - lw $18, 0x58($k0) - lw $19, 0x5c($k0) - lw $20, 0x60($k0) - lw $21, 0x64($k0) - lw $22, 0x68($k0) - lw $23, 0x6c($k0) - lw $24, 0x70($k0) - lw $25, 0x74($k0) - # lw $26, 0x78($k0) - # lw $27, 0x7c($k0) - lw $28, 0x80($k0) - lw $29, 0x84($k0) - lw $30, 0x88($k0) - lw $31, 0x8c($k0) - - lw $k1, 0xc($k0) - nop - srl $k1, 1 - sll $k1, 1 - mtc0 $k1, $12 # restore SR - - lw $k1, 0($k0) - lw $k0, 0x410($0) # k0 saved here by exception prologue (at 0x80) - jr $k1 - cop0 0x10 - nop - .set pop - .end def_exc_handler - - .global bp_exc_handler - .ent bp_exc_handler -bp_exc_handler: - .set push - .set noreorder - .set noat - .word 0 - .word 0 - la $k0, __trap_frame - sw $0, 0x10($k0) - sw $1, 0x14($k0) - sw $2, 0x18($k0) - sw $3, 0x1c($k0) - sw $4, 0x20($k0) - sw $5, 0x24($k0) - sw $6, 0x28($k0) - sw $7, 0x2c($k0) - sw $8, 0x30($k0) - sw $9, 0x34($k0) - sw $10, 0x38($k0) - sw $11, 0x3c($k0) - sw $12, 0x40($k0) - sw $13, 0x44($k0) - sw $14, 0x48($k0) - sw $15, 0x4c($k0) - sw $16, 0x50($k0) - sw $17, 0x54($k0) - sw $18, 0x58($k0) - sw $19, 0x5c($k0) - sw $20, 0x60($k0) - sw $21, 0x64($k0) - sw $22, 0x68($k0) - sw $23, 0x6c($k0) - sw $24, 0x70($k0) - sw $25, 0x74($k0) - sw $26, 0x78($k0) - sw $27, 0x7c($k0) - sw $28, 0x80($k0) - sw $29, 0x84($k0) - sw $30, 0x88($k0) - sw $31, 0x8c($k0) - mfhi $a0 - nop - sw $a0, 0x90($k0) - - mflo $a0 - nop - sw $a0, 0x94($k0) - - - # lw $a0, 0x424($0) # saved EPC - mfc0 $a0, $14 # EPC - nop - sw $a0, 0($k0) - - # lw $a0, 0x42c($0) # saved SR - mfc0 $a0, $12 # SR - nop - sw $a0, 0xc($k0) - - mfc0 $a0, $8 # BadVaddr - nop - sw $a0, 0x8($k0) - - lw $a0, 0x430($0) # saved DCIC - nop - sw $a0, 0x98($k0) - - - # lw $a0, 0x428($0) # saved Cause - mfc0 $a0, $13 # Cause - nop - sw $a0, 4($k0) - - sll $a0, 25 - srl $a0, 27 - jal trap - or $a1, $k0, $0 - - - la $k0, __trap_frame - - lw $a0, 0x94($k0) - nop - mtlo $a0 - - lw $a0, 0x90($k0) - nop - mthi $a0 - - lw $a0, 0x98($k0) - nop - mtc0 $a0, $7 - - # lw $0, 0x10($k0) - lw $1, 0x14($k0) - lw $2, 0x18($k0) - lw $3, 0x1c($k0) - lw $4, 0x20($k0) - lw $5, 0x24($k0) - lw $6, 0x28($k0) - lw $7, 0x2c($k0) - lw $8, 0x30($k0) - lw $9, 0x34($k0) - lw $10, 0x38($k0) - lw $11, 0x3c($k0) - lw $12, 0x40($k0) - lw $13, 0x44($k0) - lw $14, 0x48($k0) - lw $15, 0x4c($k0) - lw $16, 0x50($k0) - lw $17, 0x54($k0) - lw $18, 0x58($k0) - lw $19, 0x5c($k0) - lw $20, 0x60($k0) - lw $21, 0x64($k0) - lw $22, 0x68($k0) - lw $23, 0x6c($k0) - lw $24, 0x70($k0) - lw $25, 0x74($k0) - # lw $26, 0x78($k0) - # lw $27, 0x7c($k0) - lw $28, 0x80($k0) - lw $29, 0x84($k0) - lw $30, 0x88($k0) - lw $31, 0x8c($k0) - - lw $k1, 0xc($k0) - nop - srl $k1, 1 - sll $k1, 1 - mtc0 $k1, $12 # restore SR - - lw $k1, 0($k0) - lw $k0, 0x420($0) # k0 saved here by debug exception prologue (at 0x40) - jr $k1 - cop0 0x10 - nop - .set pop - .end bp_exc_handler - diff --git a/iop/debug/ioptrap/src/handler.c b/iop/debug/ioptrap/src/handler.c new file mode 100644 index 00000000000..52c7d036e37 --- /dev/null +++ b/iop/debug/ioptrap/src/handler.c @@ -0,0 +1,294 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +#define GENERAL_ATSAVE 0x400 +#define GENERAL_SRSAVE + +__asm__ +( + "\t" "\t" ".global def_exc_handler" "\n" + "\t" "\t" ".ent def_exc_handler" "\n" + "\t" "def_exc_handler:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + "\t" "\t" ".word 0" "\n" + "\t" "\t" ".word 0" "\n" + "\t" "\t" "la $k0, __trap_frame" "\n" + "\t" "\t" "sw $0, 0x10($k0)" "\n" + + "\t" "\t" "lw $1, 0x400($0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $1, 0x14($k0)" "\n" + + "\t" "\t" "sw $2, 0x18($k0)" "\n" + "\t" "\t" "sw $3, 0x1c($k0)" "\n" + "\t" "\t" "sw $4, 0x20($k0)" "\n" + "\t" "\t" "sw $5, 0x24($k0)" "\n" + "\t" "\t" "sw $6, 0x28($k0)" "\n" + "\t" "\t" "sw $7, 0x2c($k0)" "\n" + "\t" "\t" "sw $8, 0x30($k0)" "\n" + "\t" "\t" "sw $9, 0x34($k0)" "\n" + "\t" "\t" "sw $10, 0x38($k0)" "\n" + "\t" "\t" "sw $11, 0x3c($k0)" "\n" + "\t" "\t" "sw $12, 0x40($k0)" "\n" + "\t" "\t" "sw $13, 0x44($k0)" "\n" + "\t" "\t" "sw $14, 0x48($k0)" "\n" + "\t" "\t" "sw $15, 0x4c($k0)" "\n" + "\t" "\t" "sw $16, 0x50($k0)" "\n" + "\t" "\t" "sw $17, 0x54($k0)" "\n" + "\t" "\t" "sw $18, 0x58($k0)" "\n" + "\t" "\t" "sw $19, 0x5c($k0)" "\n" + "\t" "\t" "sw $20, 0x60($k0)" "\n" + "\t" "\t" "sw $21, 0x64($k0)" "\n" + "\t" "\t" "sw $22, 0x68($k0)" "\n" + "\t" "\t" "sw $23, 0x6c($k0)" "\n" + "\t" "\t" "sw $24, 0x70($k0)" "\n" + "\t" "\t" "sw $25, 0x74($k0)" "\n" + "\t" "\t" "sw $26, 0x78($k0)" "\n" + "\t" "\t" "sw $27, 0x7c($k0)" "\n" + "\t" "\t" "sw $28, 0x80($k0)" "\n" + "\t" "\t" "sw $29, 0x84($k0)" "\n" + "\t" "\t" "sw $30, 0x88($k0)" "\n" + "\t" "\t" "sw $31, 0x8c($k0)" "\n" + "\t" "\t" "mfhi $a0" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0x90($k0)" "\n" + + "\t" "\t" "mflo $a0" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0x94($k0)" "\n" + + + // "\t" "\t" "lw $a0, 0x404($0)" "\n" // saved EPC + "\t" "\t" "mfc0 $a0, $14" "\n" // EPC + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0($k0)" "\n" + + // "\t" "\t" "lw $a0, 0x408($0)" "\n" // saved SR + "\t" "\t" "mfc0 $a0, $12" "\n" // SR + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0xc($k0)" "\n" + + "\t" "\t" "mfc0 $a0, $8" "\n" // BadVaddr + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0x8($k0)" "\n" + + "\t" "\t" "sw $0, 0x98($k0)" "\n" + + + // "\t" "\t" "lw $a0, 0x40c($0)" "\n" // saved Cause + "\t" "\t" "mfc0 $a0, $13" "\n" // Cause + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 4($k0)" "\n" + + "\t" "\t" "sll $a0, 25" "\n" + "\t" "\t" "srl $a0, 27" "\n" + "\t" "\t" "jal trap" "\n" + "\t" "\t" "or $a1, $k0, $0" "\n" + + "\t" "\t" "la $k0, __trap_frame" "\n" + + "\t" "\t" "lw $a0, 0x94($k0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtlo $a0" "\n" + + "\t" "\t" "lw $a0, 0x90($k0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mthi $a0" "\n" + + // "\t" "\t" "lw $0, 0x10($k0)" "\n" + "\t" "\t" "lw $1, 0x14($k0)" "\n" + "\t" "\t" "lw $2, 0x18($k0)" "\n" + "\t" "\t" "lw $3, 0x1c($k0)" "\n" + "\t" "\t" "lw $4, 0x20($k0)" "\n" + "\t" "\t" "lw $5, 0x24($k0)" "\n" + "\t" "\t" "lw $6, 0x28($k0)" "\n" + "\t" "\t" "lw $7, 0x2c($k0)" "\n" + "\t" "\t" "lw $8, 0x30($k0)" "\n" + "\t" "\t" "lw $9, 0x34($k0)" "\n" + "\t" "\t" "lw $10, 0x38($k0)" "\n" + "\t" "\t" "lw $11, 0x3c($k0)" "\n" + "\t" "\t" "lw $12, 0x40($k0)" "\n" + "\t" "\t" "lw $13, 0x44($k0)" "\n" + "\t" "\t" "lw $14, 0x48($k0)" "\n" + "\t" "\t" "lw $15, 0x4c($k0)" "\n" + "\t" "\t" "lw $16, 0x50($k0)" "\n" + "\t" "\t" "lw $17, 0x54($k0)" "\n" + "\t" "\t" "lw $18, 0x58($k0)" "\n" + "\t" "\t" "lw $19, 0x5c($k0)" "\n" + "\t" "\t" "lw $20, 0x60($k0)" "\n" + "\t" "\t" "lw $21, 0x64($k0)" "\n" + "\t" "\t" "lw $22, 0x68($k0)" "\n" + "\t" "\t" "lw $23, 0x6c($k0)" "\n" + "\t" "\t" "lw $24, 0x70($k0)" "\n" + "\t" "\t" "lw $25, 0x74($k0)" "\n" + // "\t" "\t" "lw $26, 0x78($k0)" "\n" + // "\t" "\t" "lw $27, 0x7c($k0)" "\n" + "\t" "\t" "lw $28, 0x80($k0)" "\n" + "\t" "\t" "lw $29, 0x84($k0)" "\n" + "\t" "\t" "lw $30, 0x88($k0)" "\n" + "\t" "\t" "lw $31, 0x8c($k0)" "\n" + + "\t" "\t" "lw $k1, 0xc($k0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "srl $k1, 1" "\n" + "\t" "\t" "sll $k1, 1" "\n" + "\t" "\t" "mtc0 $k1, $12" "\n" // restore SR + + "\t" "\t" "lw $k1, 0($k0)" "\n" + "\t" "\t" "lw $k0, 0x410($0)" "\n" // k0 saved here by exception prologue (at 0x80) + "\t" "\t" "jr $k1" "\n" + "\t" "\t" "cop0 0x10" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" ".set pop" "\n" + "\t" "\t" ".end def_exc_handler" "\n" + + "\t" "\t" ".global bp_exc_handler" "\n" + "\t" "\t" ".ent bp_exc_handler" "\n" + "\t" "bp_exc_handler:" "\n" + "\t" "\t" ".set push" "\n" + "\t" "\t" ".set noreorder" "\n" + "\t" "\t" ".set noat" "\n" + "\t" "\t" ".word 0" "\n" + "\t" "\t" ".word 0" "\n" + "\t" "\t" "la $k0, __trap_frame" "\n" + "\t" "\t" "sw $0, 0x10($k0)" "\n" + "\t" "\t" "sw $1, 0x14($k0)" "\n" + "\t" "\t" "sw $2, 0x18($k0)" "\n" + "\t" "\t" "sw $3, 0x1c($k0)" "\n" + "\t" "\t" "sw $4, 0x20($k0)" "\n" + "\t" "\t" "sw $5, 0x24($k0)" "\n" + "\t" "\t" "sw $6, 0x28($k0)" "\n" + "\t" "\t" "sw $7, 0x2c($k0)" "\n" + "\t" "\t" "sw $8, 0x30($k0)" "\n" + "\t" "\t" "sw $9, 0x34($k0)" "\n" + "\t" "\t" "sw $10, 0x38($k0)" "\n" + "\t" "\t" "sw $11, 0x3c($k0)" "\n" + "\t" "\t" "sw $12, 0x40($k0)" "\n" + "\t" "\t" "sw $13, 0x44($k0)" "\n" + "\t" "\t" "sw $14, 0x48($k0)" "\n" + "\t" "\t" "sw $15, 0x4c($k0)" "\n" + "\t" "\t" "sw $16, 0x50($k0)" "\n" + "\t" "\t" "sw $17, 0x54($k0)" "\n" + "\t" "\t" "sw $18, 0x58($k0)" "\n" + "\t" "\t" "sw $19, 0x5c($k0)" "\n" + "\t" "\t" "sw $20, 0x60($k0)" "\n" + "\t" "\t" "sw $21, 0x64($k0)" "\n" + "\t" "\t" "sw $22, 0x68($k0)" "\n" + "\t" "\t" "sw $23, 0x6c($k0)" "\n" + "\t" "\t" "sw $24, 0x70($k0)" "\n" + "\t" "\t" "sw $25, 0x74($k0)" "\n" + "\t" "\t" "sw $26, 0x78($k0)" "\n" + "\t" "\t" "sw $27, 0x7c($k0)" "\n" + "\t" "\t" "sw $28, 0x80($k0)" "\n" + "\t" "\t" "sw $29, 0x84($k0)" "\n" + "\t" "\t" "sw $30, 0x88($k0)" "\n" + "\t" "\t" "sw $31, 0x8c($k0)" "\n" + "\t" "\t" "mfhi $a0" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0x90($k0)" "\n" + + "\t" "\t" "mflo $a0" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0x94($k0)" "\n" + + + // "\t" "\t" "lw $a0, 0x424($0)" "\n" // saved EPC + "\t" "\t" "mfc0 $a0, $14" "\n" // EPC + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0($k0)" "\n" + + // "\t" "\t" "lw $a0, 0x42c($0)" "\n" // saved SR + "\t" "\t" "mfc0 $a0, $12" "\n" // SR + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0xc($k0)" "\n" + + "\t" "\t" "mfc0 $a0, $8" "\n" // BadVaddr + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0x8($k0)" "\n" + + "\t" "\t" "lw $a0, 0x430($0)" "\n" // saved DCIC + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 0x98($k0)" "\n" + + + // "\t" "\t" "lw $a0, 0x428($0)" "\n" // saved Cause + "\t" "\t" "mfc0 $a0, $13" "\n" // Cause + "\t" "\t" "nop" "\n" + "\t" "\t" "sw $a0, 4($k0)" "\n" + + "\t" "\t" "sll $a0, 25" "\n" + "\t" "\t" "srl $a0, 27" "\n" + "\t" "\t" "jal trap" "\n" + "\t" "\t" "or $a1, $k0, $0" "\n" + + + "\t" "\t" "la $k0, __trap_frame" "\n" + + "\t" "\t" "lw $a0, 0x94($k0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtlo $a0" "\n" + + "\t" "\t" "lw $a0, 0x90($k0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mthi $a0" "\n" + + "\t" "\t" "lw $a0, 0x98($k0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "mtc0 $a0, $7" "\n" + + // "\t" "\t" "lw $0, 0x10($k0)" "\n" + "\t" "\t" "lw $1, 0x14($k0)" "\n" + "\t" "\t" "lw $2, 0x18($k0)" "\n" + "\t" "\t" "lw $3, 0x1c($k0)" "\n" + "\t" "\t" "lw $4, 0x20($k0)" "\n" + "\t" "\t" "lw $5, 0x24($k0)" "\n" + "\t" "\t" "lw $6, 0x28($k0)" "\n" + "\t" "\t" "lw $7, 0x2c($k0)" "\n" + "\t" "\t" "lw $8, 0x30($k0)" "\n" + "\t" "\t" "lw $9, 0x34($k0)" "\n" + "\t" "\t" "lw $10, 0x38($k0)" "\n" + "\t" "\t" "lw $11, 0x3c($k0)" "\n" + "\t" "\t" "lw $12, 0x40($k0)" "\n" + "\t" "\t" "lw $13, 0x44($k0)" "\n" + "\t" "\t" "lw $14, 0x48($k0)" "\n" + "\t" "\t" "lw $15, 0x4c($k0)" "\n" + "\t" "\t" "lw $16, 0x50($k0)" "\n" + "\t" "\t" "lw $17, 0x54($k0)" "\n" + "\t" "\t" "lw $18, 0x58($k0)" "\n" + "\t" "\t" "lw $19, 0x5c($k0)" "\n" + "\t" "\t" "lw $20, 0x60($k0)" "\n" + "\t" "\t" "lw $21, 0x64($k0)" "\n" + "\t" "\t" "lw $22, 0x68($k0)" "\n" + "\t" "\t" "lw $23, 0x6c($k0)" "\n" + "\t" "\t" "lw $24, 0x70($k0)" "\n" + "\t" "\t" "lw $25, 0x74($k0)" "\n" + // "\t" "\t" "lw $26, 0x78($k0)" "\n" + // "\t" "\t" "lw $27, 0x7c($k0)" "\n" + "\t" "\t" "lw $28, 0x80($k0)" "\n" + "\t" "\t" "lw $29, 0x84($k0)" "\n" + "\t" "\t" "lw $30, 0x88($k0)" "\n" + "\t" "\t" "lw $31, 0x8c($k0)" "\n" + + "\t" "\t" "lw $k1, 0xc($k0)" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" "srl $k1, 1" "\n" + "\t" "\t" "sll $k1, 1" "\n" + "\t" "\t" "mtc0 $k1, $12" "\n" // restore SR + + "\t" "\t" "lw $k1, 0($k0)" "\n" + "\t" "\t" "lw $k0, 0x420($0)" "\n" // k0 saved here by debug exception prologue (at 0x40) + "\t" "\t" "jr $k1" "\n" + "\t" "\t" "cop0 0x10" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" ".set pop" "\n" + "\t" "\t" ".end bp_exc_handler" "\n" +); diff --git a/iop/sound/ahx/src/hw.S b/iop/sound/ahx/src/hw.S deleted file mode 100755 index 07c4c5adcce..00000000000 --- a/iop/sound/ahx/src/hw.S +++ /dev/null @@ -1,36 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - - -.text -.set push -.set noreorder - - .globl wmemcpy - .ent wmemcpy -wmemcpy: - sra $6,$6,0x2 - addiu $6,$6,-1 - li $2,-1 - beq $6,$2,wmemcopy_end - move $3,$2 -wmemcopy_loop: - lw $2,0($5) - addiu $5,$5,4 - addiu $6,$6,-1 - sw $2,0($4) - bne $6,$3,wmemcopy_loop - addiu $4,$4,4 -wmemcopy_end: - jr $31 - nop - .end wmemcpy - -.set pop diff --git a/iop/sound/ahx/src/hw.c b/iop/sound/ahx/src/hw.c new file mode 100644 index 00000000000..058b5d97afd --- /dev/null +++ b/iop/sound/ahx/src/hw.c @@ -0,0 +1,37 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" "\t" ".globl wmemcpy" "\n" + "\t" "\t" ".ent wmemcpy" "\n" + "\t" "wmemcpy:" "\n" + "\t" "\t" "sra $6,$6,0x2" "\n" + "\t" "\t" "addiu $6,$6,-1" "\n" + "\t" "\t" "li $2,-1" "\n" + "\t" "\t" "beq $6,$2,wmemcopy_end" "\n" + "\t" "\t" "move $3,$2" "\n" + "\t" "wmemcopy_loop:" "\n" + "\t" "\t" "lw $2,0($5)" "\n" + "\t" "\t" "addiu $5,$5,4" "\n" + "\t" "\t" "addiu $6,$6,-1" "\n" + "\t" "\t" "sw $2,0($4)" "\n" + "\t" "\t" "bne $6,$3,wmemcopy_loop" "\n" + "\t" "\t" "addiu $4,$4,4" "\n" + "\t" "wmemcopy_end:" "\n" + "\t" "\t" "jr $31" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" ".end wmemcpy" "\n" + + "\t" ".set pop" "\n" +); diff --git a/iop/sound/audsrv/src/hw.S b/iop/sound/audsrv/src/hw.S deleted file mode 100755 index 07c4c5adcce..00000000000 --- a/iop/sound/audsrv/src/hw.S +++ /dev/null @@ -1,36 +0,0 @@ -/* -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004, ps2dev - http://www.ps2dev.org -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. -*/ - - -.text -.set push -.set noreorder - - .globl wmemcpy - .ent wmemcpy -wmemcpy: - sra $6,$6,0x2 - addiu $6,$6,-1 - li $2,-1 - beq $6,$2,wmemcopy_end - move $3,$2 -wmemcopy_loop: - lw $2,0($5) - addiu $5,$5,4 - addiu $6,$6,-1 - sw $2,0($4) - bne $6,$3,wmemcopy_loop - addiu $4,$4,4 -wmemcopy_end: - jr $31 - nop - .end wmemcpy - -.set pop diff --git a/iop/sound/audsrv/src/hw.c b/iop/sound/audsrv/src/hw.c new file mode 100644 index 00000000000..058b5d97afd --- /dev/null +++ b/iop/sound/audsrv/src/hw.c @@ -0,0 +1,37 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +__asm__ +( + "\t" ".set push" "\n" + "\t" ".set noreorder" "\n" + + "\t" "\t" ".globl wmemcpy" "\n" + "\t" "\t" ".ent wmemcpy" "\n" + "\t" "wmemcpy:" "\n" + "\t" "\t" "sra $6,$6,0x2" "\n" + "\t" "\t" "addiu $6,$6,-1" "\n" + "\t" "\t" "li $2,-1" "\n" + "\t" "\t" "beq $6,$2,wmemcopy_end" "\n" + "\t" "\t" "move $3,$2" "\n" + "\t" "wmemcopy_loop:" "\n" + "\t" "\t" "lw $2,0($5)" "\n" + "\t" "\t" "addiu $5,$5,4" "\n" + "\t" "\t" "addiu $6,$6,-1" "\n" + "\t" "\t" "sw $2,0($4)" "\n" + "\t" "\t" "bne $6,$3,wmemcopy_loop" "\n" + "\t" "\t" "addiu $4,$4,4" "\n" + "\t" "wmemcopy_end:" "\n" + "\t" "\t" "jr $31" "\n" + "\t" "\t" "nop" "\n" + "\t" "\t" ".end wmemcpy" "\n" + + "\t" ".set pop" "\n" +);