Skip to content

Commit 4e42a6b

Browse files
Move OpenBIOS SIO to a seperate header and add enums
1 parent a50434c commit 4e42a6b

File tree

4 files changed

+72
-13
lines changed

4 files changed

+72
-13
lines changed

src/mips/common/hardware/hwregs.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ SOFTWARE.
3030

3131
#include "common/hardware/counters.h"
3232

33-
struct SIO {
34-
uint8_t fifo;
35-
uint8_t preview[3];
36-
uint16_t stat;
37-
uint16_t padding;
38-
uint16_t mode;
39-
uint16_t ctrl;
40-
uint16_t reserved;
41-
uint16_t baudRate;
42-
};
43-
4433
#define HW_U8(x) (*(volatile uint8_t *)(x))
4534
#define HW_U16(x) (*(volatile uint16_t *)(x))
4635
#define HW_U32(x) (*(volatile uint32_t *)(x))
@@ -52,8 +41,6 @@ struct SIO {
5241
#define SBUS_DEV5_CTRL HW_U32(0x1f801018)
5342
#define SBUS_COM_CTRL HW_U32(0x1f801020)
5443

55-
#define SIOS ((volatile struct SIO *)0x1f801040)
56-
5744
#define RAM_SIZE HW_U32(0x1f801060)
5845

5946
#define IREG HW_U32(0xbf801070)

src/mips/common/hardware/sio.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
3+
MIT License
4+
5+
Copyright (c) 2020 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+
struct SIOPort {
32+
uint8_t fifo;
33+
uint8_t preview[3];
34+
uint16_t stat;
35+
uint16_t padding;
36+
uint16_t mode;
37+
uint16_t ctrl;
38+
uint16_t reserved;
39+
uint16_t baudRate;
40+
};
41+
42+
#define SIOS ((volatile struct SIOPort *)0x1f801040)
43+
44+
enum {
45+
SIO_CTRL_TXEN = (1 << 0), // Transmit Enable
46+
SIO_CTRL_DTR = (1 << 1), // Data Terminal Ready, aka Select (output)
47+
SIO_CTRL_RXE = (1 << 2), // Receive Enable
48+
SIO_CTRL_SBRK = (1 << 3), // Send Break character
49+
SIO_CTRL_ERRRES = (1 << 4), // Error Reset
50+
SIO_CTRL_RTS = (1 << 5), // Request to Send (output)
51+
SIO_CTRL_IR = (1 << 6), // Internal Reset, resets most SIO registers
52+
SIO_CTRL_RXIRQMODE = (1 << 8), // Receive IRQ Mode (0..3 = IRQ when RX FIFO contains 1,2,4,8 bytes)
53+
SIO_CTRL_TXIRQEN = (1 << 10), // Transmit IRQ Enable
54+
SIO_CTRL_RXIRQEN = (1 << 11), // Receive IRQ Enable
55+
SIO_CTRL_ACKIRQEN = (1 << 12), // Acknowledge IRQ Enable
56+
SIO_CTRL_PORTSEL = (1 << 13), // Port Select
57+
};
58+
59+
enum {
60+
SIO_STAT_TXRDY = (1 << 0), // TX buffer is empty
61+
SIO_STAT_RXRDY = (1 << 1), // RX buffer has data
62+
SIO_STAT_TXEMPTY = (1 << 2), // No data in TX buffer
63+
SIO_STAT_PE = (1 << 3), // Parity Error
64+
SIO_STAT_OE = (1 << 4), // Overrun Error
65+
SIO_STAT_FE = (1 << 5), // Framing Error
66+
SIO_STAT_SYNDET = (1 << 6), // Sync Detect
67+
SIO_STAT_ACK = (1 << 7), // ACK signal level (input)
68+
SIO_STAT_CTS = (1 << 8), // Clear to Send (output), unused on SIO0
69+
SIO_STAT_IRQ = (1 << 9), // Interrupt Request
70+
};

src/mips/openbios/sio0/card.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SOFTWARE.
3030

3131
#include "common/hardware/hwregs.h"
3232
#include "common/hardware/irq.h"
33+
#include "common/hardware/sio.h"
3334
#include "common/kernel/events.h"
3435
#include "common/syscalls/syscalls.h"
3536
#include "openbios/kernel/events.h"

src/mips/openbios/sio0/driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ SOFTWARE.
2626

2727
#include "common/hardware/hwregs.h"
2828
#include "common/hardware/irq.h"
29+
#include "common/hardware/sio.h"
2930
#include "common/kernel/events.h"
3031
#include "common/psxlibc/string.h"
3132
#include "common/syscalls/syscalls.h"

0 commit comments

Comments
 (0)