sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
mx4sio.h
Go to the documentation of this file.
1
5#ifndef MX4SIO_H
6#define MX4SIO_H
7
8#include <stdint.h>
9
10/*
11 * Clock divider for 48MHz clock:
12 * 1 = 48 MHz - Invalid setting
13 * 2 = 24 MHz - Fastest usable speed
14 * 3 = 16 MHz
15 * 4 = 12 MHz
16 * 5 = 9.6MHz
17 * 6 = 6 MHz
18 * ...
19 * 0x78 = 400KHz - Initialization speed
20 */
21
22/* baud dividers */
23#define SIO2_BAUD_DIV_SLOW 0x78
24#define SIO2_BAUD_DIV_FAST 0x2
25
26/* SIO2 can only transfer 256 bytes at a time */
27#define SIO2_MAX_TRANSFER_SIZE 256
28
29/* interrupt event flags */
30#define EF_SIO2_INTR_REVERSE 0x00000100
31#define EF_SIO2_INTR_COMPLETE 0x00000200
32
33/* interrupt types */
34#define INTR_NONE 0x0
35#define INTR_RX 0x1
36#define INTR_TX 0x2
37
38/* mem slot 2 */
39#define PORT_NR 3
40
41// #define CONFIG_USE_CRC16
42
43typedef struct dma_command_t
44{
45 uint8_t *buffer;
46 uint16_t sector_count;
47 volatile uint16_t sectors_transferred;
48 uint16_t sectors_reversed;
49#ifdef CONFIG_USE_CRC16
50 uint16_t crc[512]; /*FIXME*/
51#endif
52 uint8_t response;
53 volatile uint8_t abort;
55
56/* globals */
57extern dma_command_t cmd;
58extern int sio2_event_flag;
59extern const uint8_t reverse_byte_LUT8[256];
60
61/* MX SIO2 functions */
62extern void mx_sio2_lock(uint8_t intr_type);
63extern void mx_sio2_unlock(uint8_t intr_type);
64extern void mx_sio2_set_baud(uint8_t baud);
65
66extern uint8_t mx_sio2_write_byte(uint8_t byte);
67extern uint8_t mx_sio2_write_dummy(void);
68
69extern void mx_sio2_rx_pio(uint8_t *buffer, uint32_t size); /* PIO only used for sending commands */
70extern void mx_sio2_tx_pio(uint8_t *buffer, uint32_t size);
71
72extern void mx_sio2_start_rx_dma(uint8_t *buffer); /* DMA used for all other transfers */
73extern void mx_sio2_start_tx_dma(uint8_t *buffer);
74
75extern uint8_t mx_sio2_wait_equal(uint8_t value, uint32_t count);
76extern uint8_t mx_sio2_wait_not_equal(uint8_t value, uint32_t count);
77extern uint8_t mx_sio2_wait_equal_masked(uint8_t value, uint8_t mask, uint32_t count);
78
79/* misc */
80extern void reverse_buffer(uint32_t *buffer, uint32_t count);
81
82#endif
u32 count
start sector of fragmented bd/file