PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
tty.c
1#include "irx_imports.h"
2#include <errno.h>
3
4
5int acUartWrite(void *buf, int count);
6int acUartRead(void *buf, int count);
7
8static int acuart_read(iop_file_t *f, void *buffer, int size) {
9 (void)f;
10 return acUartRead(buffer, size);
11}
12static int acuart_write(iop_file_t *f, void *buffer, int size) {
13 (void)f;
14 return acUartWrite(buffer, size);
15}
16
17IOMAN_RETURN_VALUE_IMPL(0);
18IOMAN_RETURN_VALUE_IMPL(ENOTSUP);
19
20static iop_device_ops_t uart_ops = {
21 IOMAN_RETURN_VALUE(0), // init
22 IOMAN_RETURN_VALUE(0), // deinit
23 IOMAN_RETURN_VALUE(ENOTSUP), // format
24 IOMAN_RETURN_VALUE(ENOTSUP), // open
25 IOMAN_RETURN_VALUE(ENOTSUP), // close
26 &acuart_read, // read
27 &acuart_write, // write
28 IOMAN_RETURN_VALUE(ENOTSUP), // lseek
29 IOMAN_RETURN_VALUE(ENOTSUP), // ioctl
30 IOMAN_RETURN_VALUE(ENOTSUP), // remove
31 IOMAN_RETURN_VALUE(ENOTSUP), // mkdir
32 IOMAN_RETURN_VALUE(ENOTSUP), // rmdir
33 IOMAN_RETURN_VALUE(ENOTSUP), // dopen
34 IOMAN_RETURN_VALUE(ENOTSUP), // dclose
35 IOMAN_RETURN_VALUE(ENOTSUP), // dread
36 IOMAN_RETURN_VALUE(ENOTSUP), // getstat
37 IOMAN_RETURN_VALUE(ENOTSUP), // chstat
38};
39
40#define DEVNAME "tty"
41
42static iop_device_t uart_tty = {
43 DEVNAME,
44 IOP_DT_CHAR | IOP_DT_CONS,
45 1,
46 "TTY via arcade UART",
47 &uart_ops,
48};
49
50int CreateTTY() {
51 if(AddDrv(&uart_tty) != 0) return MODULE_NO_RESIDENT_END;
52
53 close(0);
54 open(DEVNAME "00:", 0x1000 | O_RDWR);
55
56 close(1);
57 open(DEVNAME "00:", O_WRONLY);
58
59 close(2);
60 open(DEVNAME "00:", O_WRONLY);
61 return MODULE_RESIDENT_END;
62}
#define ENOTSUP
Definition errno.h:259
u32 count
start sector of fragmented bd/file