Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
Macros | Functions | Variables
monitor.c File Reference
#include "monitor/monitor.h"
#include <stddef.h>
#include "common/psxlibc/handlers.h"
#include "common/syscalls/syscalls.h"
#include "monitor/cop0dbg.h"
#include "monitor/install.h"
#include "monitor/kernel.h"
#include "common/kernel/threads.h"
#include "monitor/link.h"
#include "monitor/transport.h"
Include dependency graph for monitor.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MON_CAPS_LZ4   0
 
#define MON_CAPS_STOP   0
 
#define MON_CAPS   (MON_CAPS_LZ4 | MON_CAPS_STOP)
 
#define MON_CHUNK_BYTES   8192
 
#define MON_CMD_WORDS   16
 
#define MON_RUN_SR   0x40000404u
 
#define MON_REPLIED   (-1)
 
#define MONITOR_SLOT_STACK_WORDS   256
 
#define MON_SLOT_EXCMASK   0x1ef0
 
#define MON_STR_(x)   #x
 
#define MON_STR(x)   MON_STR_(x)
 
#define MON_SLOT_RX_TEST
 

Functions

uint32_t monitorSlotStack[MONITOR_SLOT_STACK_WORDS] __attribute__ ((used, aligned(8)))
 
void __attribute__ ((used, noinline))
 
 __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 monitorMain (void)
 

Variables

uint32_t s_biosChecksum
 
uint32_t * s_monitorSlot
 
struct HandlerInfo s_monitorHandler
 

Macro Definition Documentation

◆ MON_CAPS

#define MON_CAPS   (MON_CAPS_LZ4 | MON_CAPS_STOP)

◆ MON_CAPS_LZ4

#define MON_CAPS_LZ4   0

◆ MON_CAPS_STOP

#define MON_CAPS_STOP   0

◆ MON_CHUNK_BYTES

#define MON_CHUNK_BYTES   8192

◆ MON_CMD_WORDS

#define MON_CMD_WORDS   16

◆ MON_REPLIED

#define MON_REPLIED   (-1)

◆ MON_RUN_SR

#define MON_RUN_SR   0x40000404u

◆ MON_SLOT_EXCMASK

#define MON_SLOT_EXCMASK   0x1ef0

◆ MON_SLOT_RX_TEST

#define MON_SLOT_RX_TEST

◆ MON_STR

#define MON_STR (   x)    MON_STR_(x)

◆ MON_STR_

#define MON_STR_ (   x)    #x

◆ MONITOR_SLOT_STACK_WORDS

#define MONITOR_SLOT_STACK_WORDS   256

Function Documentation

◆ __asm__()

__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,
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,
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,
0x8c($k0)\n" " mfc0  $a1,
  $13\n" " nop\n" " sw,
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,
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,
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"   
)

◆ __attribute__() [1/2]

uint32_t monitorSlotStack[MONITOR_SLOT_STACK_WORDS] __attribute__ ( (used, aligned(8))  )

◆ __attribute__() [2/2]

void __attribute__ ( (used, noinline)  )

◆ monitorMain()

void monitorMain ( void  )

Variable Documentation

◆ badVaddr

uint32_t badVaddr

◆ cmd

uint32_t cmd = 0xe1000555

◆ ctx

struct Registers* ctx

◆ dcic

uint32_t dcic

◆ memWritten

int memWritten

◆ running

int running

◆ s_biosChecksum

uint32_t s_biosChecksum

◆ s_monitorHandler

struct HandlerInfo s_monitorHandler
Initial value:
= {
.next = 0,
.handler = 0,
.verifier = monitorVerifier,
.padding = 0,
}

◆ s_monitorSlot

uint32_t* s_monitorSlot

◆ watchAddr

uint32_t watchAddr