Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
monitor
monitor.h
Go to the documentation of this file.
1
/*
2
3
MIT License
4
5
Copyright (c) 2026 PCSX-Redux authors
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy
8
of this software and associated documentation files (the "Software"), to deal
9
in the Software without restriction, including without limitation the rights
10
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the Software is
12
furnished to do so, subject to the following conditions:
13
14
The above copyright notice and this permission notice shall be included in all
15
copies or substantial portions of the Software.
16
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
SOFTWARE.
24
25
*/
26
27
#pragma once
28
29
#include <stdint.h>
30
31
/* Resident debug monitor. Opcodes, error codes, and event reasons follow
32
the monitor protocol design (sections 3, 6, 9). The high nibble of a TYPE
33
encodes direction: 0x0_/0x2_ host-originated, 0x4_ PS1 response, 0x8_ PS1
34
async event. */
35
36
/* Host -> PS1 commands */
37
#define MON_PING 0x01
38
#define MON_READ_MEM 0x02
39
#define MON_WRITE_MEM 0x03
40
#define MON_GET_REGS 0x04
41
#define MON_SET_REG 0x05
42
#define MON_SET_BP 0x06
43
#define MON_CLR_BP 0x07
44
#define MON_LOAD 0x08
45
#define MON_RUN 0x09
46
#define MON_CONT 0x0A
47
#define MON_STOP 0x0B
48
#define MON_STEP 0x0C
/* reserved / deferred */
49
#define MON_SET_BAUD 0x0D
/* SIO1 line rate, design section 2a */
50
51
/* Bit 15 on WRITE_MEM or LOAD: the payload is an LZ4 stream (monitor/lz4stream.h). */
52
#define MON_LZ4 0x8000
53
54
/* Capability bits, in HELLO and PONG. */
55
#define MON_CAP_LZ4 0x0001
56
/* STOP while RUNNING is read: the target stops with STOPPED INTERRUPT at its
57
next interrupt after the frame arrives (byte links only). */
58
#define MON_CAP_STOP 0x0002
59
/* The monitor is entered from the kernel exception handler's fourth patch
60
slot, ahead of the handler chains, so a program that resets the chains
61
does not lose it. Without it the monitor rides the priority-0 chain only. */
62
#define MON_CAP_SLOT 0x0004
63
64
/* LZ4 WRITE_MEM/LOAD on SIO1 by default: the wire is slow enough that decoding
65
hides under it. Elsewhere decoding would cost more than it saves. */
66
#if defined(MONITOR_LINK_SIO1) && !defined(MONITOR_NO_LZ4) && !defined(MONITOR_LZ4)
67
#define MONITOR_LZ4 1
68
#endif
69
70
/* PS1 -> host responses / events */
71
#define MON_ACK 0x40
72
#define MON_DATA 0x41
73
#define MON_REGS 0x42
74
#define MON_PONG 0x43
75
#define MON_ERROR 0x4F
76
#define MON_HELLO 0x80
77
#define MON_STOPPED 0x81
78
79
/* ERROR payload codes (section 9) */
80
#define MON_EBADCMD 0x01
81
#define MON_EBADSTATE 0x02
82
#define MON_EBADADDR 0x03
83
#define MON_EBADREG 0x04
84
#define MON_EBADLEN 0x05
85
#define MON_ECKSUM 0x06
86
#define MON_ENOFD 0x07
87
#define MON_EDECODE 0x08
88
89
/* STOPPED reason codes (section 6) */
90
#define MON_STOP_BREAKPOINT 0x01
91
#define MON_STOP_INTERRUPT 0x02
92
#define MON_STOP_DATA_WATCH 0x03
93
#define MON_STOP_FAULT 0x04
94
95
#define MON_PROTO_VER 0x0002
96
97
/* Monitor entry. Never returns: it takes over from boot()'s terminal path,
98
brings up the transport, announces HELLO, and runs the command loop. */
99
void
monitorMain
(
void
)
__attribute__
((noreturn));
__attribute__
__attribute__((weak))
Definition
clz.c:56
monitorMain
void monitorMain(void) __attribute__((noreturn))
Definition
monitor.c:686
Generated by
1.9.8