Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
gte-timing.c File Reference
#include <stdint.h>
#include "common/hardware/cop2.h"
#include "common/syscalls/syscalls.h"
Include dependency graph for gte-timing.c:

Classes

struct  command
 

Macros

#define T2_VALUE   (*(volatile uint32_t *)0xbf801120)
 
#define T2_MODE   (*(volatile uint32_t *)0xbf801124)
 
#define BLOCK(name, reps, opcode, body)
 
#define GAPLIST(M, a, b)
 
#define GAPBLOCK(tag, opcode, N)    BLOCK(tag##_gap##N, 8, opcode, "cop2 %[op]\n.rept " #N "\nnop\n.endr\nmfc2 %[d], $9")
 
#define GAPBASE(tag, opcode, N)   BLOCK(gapBase##N, 8, 0, "nop\n.rept " #N "\nnop\n.endr\nmfc2 %[d], $9")
 
#define GAPREF(tag, opcode, N)   tag##_gap##N,
 
#define GAPREFB(tag, opcode, N)   gapBase##N,
 
#define GAPNUM(tag, opcode, N)   N,
 
#define NGAP   (sizeof(s_gapN) / sizeof(s_gapN[0]))
 
#define WHO(X, tag, opcode)
 
#define WHOBLOCK(tag, opcode, suffix, label, insn)    BLOCK(tag##_w##suffix, 8, opcode, "cop2 %[op]\n" insn "\n.rept 64\nnop\n.endr")
 
#define WHOREF(tag, opcode, suffix, label, insn)   tag##_w##suffix,
 
#define WHONAME(tag, opcode, suffix, label, insn)   label,
 
#define NWHO   9
 
#define COMMANDS(X)
 
#define DEFINE_BLOCKS(tag, opcode)
 
#define DEFINE_ENTRY(tag, opcode)    {#tag, tag##_cmd, tag##_wBase, {WHO(WHOREF, tag, opcode)}, {GAPLIST(GAPREF, tag, opcode)}},
 
#define NCOMMANDS   (sizeof(s_commands) / sizeof(s_commands[0]))
 
#define W(i)   __asm__ volatile("mtc2 %0, $" #i "; nop; nop" : : "r"(data[i]));
 
#define C(i)   __asm__ volatile("ctc2 %0, $" #i "; nop; nop" : : "r"(ctrl[i]));
 

Typedefs

typedef uint32_t(* blockFn) (void)
 

Functions

int main (void)
 

Macro Definition Documentation

◆ BLOCK

#define BLOCK (   name,
  reps,
  opcode,
  body 
)
Value:
static __attribute__((noinline)) uint32_t name(void) { \
uint32_t t0, t1, d = 0; \
__asm__ volatile(".set push\n.set noreorder\n" \
"lw %[t0], 0(%[t])\n" \
".rept " #reps "\n" body "\n.endr\n" \
"lw %[t1], 0(%[t])\n" \
".set pop\n" \
: [t0] "=&r"(t0), [t1] "=&r"(t1), [d] "+r"(d) \
: [t] "r"(&T2_VALUE), [m] "r"(s_scratch), [op] "i"(opcode) \
: "memory"); \
return (t1 - t0) & 0xffff; \
}
__attribute__((weak))
Definition clz.c:56
uint32_t t
Definition cop0.c:79
#define T2_VALUE
Definition gte-timing.c:50
__asm__(" .section .text.monitorSlotEntry, \"ax\", @progbits\n" " .align 2\n" " .global monitorSlotEntry\n" " .type monitorSlotEntry, @function\n" " .set push\n" " .set noreorder\n" " .set noat\n" "monitorSlotEntry:\n" " mfc0 $v0, $13\n" " nop\n" " andi $v0, $v0, 0x7c\n" " beqz $v0, 1f\n" " srl $v0, $v0, 2\n" " li $v1, " MON_STR(MON_SLOT_EXCMASK) "\n" " srlv $v1, $v1, $v0\n" " andi $v1, $v1, 1\n" " bnez $v1, 2f\n" " nop\n" " jr $ra\n" " nop\n" "1:\n" MON_SLOT_RX_TEST " jr $ra\n" " nop\n" "2:\n" " sw $a0, 0x10($k0)\n" " sw $a1, 0x14($k0)\n" " sw $a2, 0x18($k0)\n" " sw $a3, 0x1c($k0)\n" " mfc0 $a0, $12\n" " nop\n" " sw $a0, 0x8c($k0)\n" " mfc0 $a1, $13\n" " nop\n" " sw $a1, 0x90($k0)\n" " sw $k1, 0x6c($k0)\n" " sw $s0, 0x40($k0)\n" " sw $s1, 0x44($k0)\n" " sw $s2, 0x48($k0)\n" " sw $s3, 0x4c($k0)\n" " sw $s4, 0x50($k0)\n" " sw $s5, 0x54($k0)\n" " sw $s6, 0x58($k0)\n" " sw $s7, 0x5c($k0)\n" " sw $t0, 0x20($k0)\n" " sw $t1, 0x24($k0)\n" " sw $t2, 0x28($k0)\n" " sw $t3, 0x2c($k0)\n" " sw $t4, 0x30($k0)\n" " sw $t5, 0x34($k0)\n" " sw $t6, 0x38($k0)\n" " sw $t7, 0x3c($k0)\n" " sw $t8, 0x60($k0)\n" " sw $t9, 0x64($k0)\n" " sw $gp, 0x70($k0)\n" " sw $sp, 0x74($k0)\n" " sw $fp, 0x78($k0)\n" " mfhi $a0\n" " nop\n" " sw $a0, 0x84($k0)\n" " mflo $a0\n" " nop\n" " sw $a0, 0x88($k0)\n" " move $s0, $ra\n" " la $sp, monitorSlotStack + " MON_STR(MONITOR_SLOT_STACK_WORDS) " * 4 - 16\n" " jal monitorSlotDispatch\n" " nop\n" " lw $k0, 0x108($zero)\n" " move $ra, $s0\n" " lw $k0, 0($k0)\n" " nop\n" " addiu $k0, $k0, 8\n" " lw $a0, 0x84($k0)\n" " lw $a1, 0x88($k0)\n" " mthi $a0\n" " mtlo $a1\n" " lw $a0, 0x10($k0)\n" " lw $a1, 0x14($k0)\n" " lw $a2, 0x18($k0)\n" " lw $a3, 0x1c($k0)\n" " lw $t0, 0x20($k0)\n" " lw $t1, 0x24($k0)\n" " lw $t2, 0x28($k0)\n" " lw $t3, 0x2c($k0)\n" " lw $t4, 0x30($k0)\n" " lw $t5, 0x34($k0)\n" " lw $t6, 0x38($k0)\n" " lw $t7, 0x3c($k0)\n" " lw $t8, 0x60($k0)\n" " lw $t9, 0x64($k0)\n" " lw $s0, 0x40($k0)\n" " lw $sp, 0x74($k0)\n" " jr $ra\n" " nop\n" " .set pop\n" " .size monitorSlotEntry, . - monitorSlotEntry\n" " .previous\n")
void uint32_t(classId, spec)

◆ C

#define C (   i)    __asm__ volatile("ctc2 %0, $" #i "; nop; nop" : : "r"(ctrl[i]));

◆ COMMANDS

#define COMMANDS (   X)
Value:
X(RTPS, COP2_RTPS(1, 0)) \
X(RTPT, COP2_RTPT(1, 0)) \
X(NCLIP, COP2_NCLIP) \
X(OP, COP2_OP_CP(1, 0)) \
X(DPCS, COP2_DPCS(1, 0)) \
X(DPCT, COP2_DPCT(1, 0)) \
X(DCPL, COP2_DCPL(1, 0)) \
X(INTPL, COP2_INTPL(1, 0)) \
X(MVMVA_RT, COP2_MVMVA(1, COP2_MX_RT, COP2_V_V0, COP2_CV_TR, 0)) \
X(MVMVA_BAD, COP2_MVMVA(1, COP2_MX_BAD, COP2_V_IR, COP2_CV_FC, 1)) \
X(NCS, COP2_NCS(1, 1)) \
X(NCT, COP2_NCT(1, 1)) \
X(NCCS, COP2_NCCS(1, 1)) \
X(NCCT, COP2_NCCT(1, 1)) \
X(NCDS, COP2_NCDS(1, 1)) \
X(NCDT, COP2_NCDT(1, 1)) \
X(CC, COP2_CC(1, 1)) \
X(CDP, COP2_CDP(1, 1)) \
X(SQR, COP2_SQR(1, 0)) \
X(AVSZ3, COP2_AVSZ3) \
X(AVSZ4, COP2_AVSZ4) \
X(GPF, COP2_GPF(1, 0)) \
X(GPL, COP2_GPL(1, 0))
#define COP2_INTPL(sf, lm)
Definition cop2.h:142
#define COP2_OP_CP(sf, lm)
Definition cop2.h:136
#define COP2_GPL(sf, lm)
Definition cop2.h:169
#define COP2_V_V0
Definition cop2.h:70
#define COP2_NCS(sf, lm)
Definition cop2.h:149
#define COP2_NCCS(sf, lm)
Definition cop2.h:151
#define COP2_DPCT(sf, lm)
Definition cop2.h:140
#define COP2_CV_FC
Definition cop2.h:78
#define COP2_SQR(sf, lm)
Definition cop2.h:161
#define COP2_NCDS(sf, lm)
Definition cop2.h:153
#define COP2_NCCT(sf, lm)
Definition cop2.h:152
#define COP2_RTPT(sf, lm)
Definition cop2.h:130
#define COP2_MX_RT
Definition cop2.h:64
#define COP2_CDP(sf, lm)
Definition cop2.h:158
#define COP2_V_IR
Definition cop2.h:73
#define COP2_GPF(sf, lm)
Definition cop2.h:168
#define COP2_NCLIP
Definition cop2.h:133
#define COP2_RTPS(sf, lm)
Definition cop2.h:129
#define COP2_NCT(sf, lm)
Definition cop2.h:150
#define COP2_AVSZ3
Definition cop2.h:164
#define COP2_DPCS(sf, lm)
Definition cop2.h:139
#define COP2_MVMVA(sf, mx, v, cv, lm)
Definition cop2.h:145
#define COP2_DCPL(sf, lm)
Definition cop2.h:141
#define COP2_AVSZ4
Definition cop2.h:165
#define COP2_MX_BAD
Definition cop2.h:67
#define COP2_CC(sf, lm)
Definition cop2.h:157
#define COP2_CV_TR
Definition cop2.h:76
#define COP2_NCDT(sf, lm)
Definition cop2.h:154

◆ DEFINE_BLOCKS

#define DEFINE_BLOCKS (   tag,
  opcode 
)
Value:
BLOCK(tag##_cmd, 64, opcode, "cop2 %[op]\nmfc2 %[d], $9") \
BLOCK(tag##_wBase, 8, opcode, "cop2 %[op]\nnop\n.rept 64\nnop\n.endr") \
WHO(WHOBLOCK, tag, opcode) \
GAPLIST(GAPBLOCK, tag, opcode)
#define GAPBLOCK(tag, opcode, N)
Definition gte-timing.c:100
#define BLOCK(name, reps, opcode, body)
Definition gte-timing.c:67
#define WHOBLOCK(tag, opcode, suffix, label, insn)
Definition gte-timing.c:122

◆ DEFINE_ENTRY

#define DEFINE_ENTRY (   tag,
  opcode 
)     {#tag, tag##_cmd, tag##_wBase, {WHO(WHOREF, tag, opcode)}, {GAPLIST(GAPREF, tag, opcode)}},

◆ GAPBASE

#define GAPBASE (   tag,
  opcode,
  N 
)    BLOCK(gapBase##N, 8, 0, "nop\n.rept " #N "\nnop\n.endr\nmfc2 %[d], $9")

◆ GAPBLOCK

#define GAPBLOCK (   tag,
  opcode,
  N 
)     BLOCK(tag##_gap##N, 8, opcode, "cop2 %[op]\n.rept " #N "\nnop\n.endr\nmfc2 %[d], $9")

◆ GAPLIST

#define GAPLIST (   M,
  a,
  b 
)
Value:
M(a, b, 0) M(a, b, 1) M(a, b, 2) M(a, b, 3) M(a, b, 4) M(a, b, 6) M(a, b, 8) M(a, b, 12) M(a, b, 16) \
M(a, b, 20) M(a, b, 24) M(a, b, 32) M(a, b, 40) M(a, b, 48)
uint8_t b
Definition gte-depthcue.c:39

◆ GAPNUM

#define GAPNUM (   tag,
  opcode,
  N 
)    N,

◆ GAPREF

#define GAPREF (   tag,
  opcode,
  N 
)    tag##_gap##N,

◆ GAPREFB

#define GAPREFB (   tag,
  opcode,
  N 
)    gapBase##N,

◆ NCOMMANDS

#define NCOMMANDS   (sizeof(s_commands) / sizeof(s_commands[0]))

◆ NGAP

#define NGAP   (sizeof(s_gapN) / sizeof(s_gapN[0]))

◆ NWHO

#define NWHO   9

◆ T2_MODE

#define T2_MODE   (*(volatile uint32_t *)0xbf801124)

◆ T2_VALUE

#define T2_VALUE   (*(volatile uint32_t *)0xbf801120)

◆ W

#define W (   i)    __asm__ volatile("mtc2 %0, $" #i "; nop; nop" : : "r"(data[i]));

◆ WHO

#define WHO (   X,
  tag,
  opcode 
)
Value:
X(tag, opcode, MfcRes, "mfc2 IR1", "mfc2 %[d], $9") \
X(tag, opcode, MfcIn, "mfc2 VXY0", "mfc2 %[d], $0") \
X(tag, opcode, CfcFlag, "cfc2 FLAG", "cfc2 %[d], $31") \
X(tag, opcode, CfcMat, "cfc2 R11R12", "cfc2 %[d], $0") \
X(tag, opcode, Swc2, "swc2 IR1", "swc2 $9, 0(%[m])") \
X(tag, opcode, Lwc2, "lwc2 VXY0", "lwc2 $0, 4(%[m])") \
X(tag, opcode, Mtc2, "mtc2 VXY0", "mtc2 %[d], $0") \
X(tag, opcode, Ctc2, "ctc2 ZSF3", "ctc2 %[d], $29") \
X(tag, opcode, Cop2, "cop2 NCLIP", "cop2 0x1400006")

◆ WHOBLOCK

#define WHOBLOCK (   tag,
  opcode,
  suffix,
  label,
  insn 
)     BLOCK(tag##_w##suffix, 8, opcode, "cop2 %[op]\n" insn "\n.rept 64\nnop\n.endr")

◆ WHONAME

#define WHONAME (   tag,
  opcode,
  suffix,
  label,
  insn 
)    label,

◆ WHOREF

#define WHOREF (   tag,
  opcode,
  suffix,
  label,
  insn 
)    tag##_w##suffix,

Typedef Documentation

◆ blockFn

typedef uint32_t(* blockFn) (void)

Function Documentation

◆ main()

int main ( void  )