22#include "irx_imports.h"
23IRX_ID(
"sioremote_driver", 1, 1);
29static char tbuf[2048];
31void sio_init(u32 baudrate, u8 lcr_ueps, u8 lcr_upen, u8 lcr_usbl, u8 lcr_umode) {
33 i->baudrate = baudrate;
34 i->lcr_ueps = lcr_ueps;
35 i->lcr_upen = lcr_upen;
36 i->lcr_usbl = lcr_usbl;
37 i->lcr_umode = lcr_umode;
38 SifCallRpc(&cd0, SIOR_INIT, 0, &buffer,
sizeof(
struct siorInitArgs), NULL, 0, NULL, NULL);
43 SifCallRpc(&cd0, SIOR_PUTC, 0, &buffer,
sizeof(
int), &buffer,
sizeof(
int), NULL, NULL);
48 SifCallRpc(&cd0, SIOR_GETC, 0, 0, 0, &buffer,
sizeof(
int), NULL, NULL);
53 SifCallRpc(&cd0, SIOR_GETCBLOCK, 0, 0, 0, &buffer,
sizeof(
int), NULL, NULL);
57size_t sio_write(
const char *buf,
size_t size) {
58 buffer.write.buf = buf;
59 buffer.write.len = size;
60 SifCallRpc(&cd0, SIOR_WRITE, 0, &buffer, 8, &buffer, 4, NULL, NULL);
64size_t sio_read(
char *buf,
size_t size) {
65 buffer.read.buf = buf;
66 buffer.read.len = size;
67 SifCallRpc(&cd0, SIOR_READ, 0, &buffer, 8, &buffer, 4, NULL, NULL);
71int sio_puts(
const char * str) {
73 SifCallRpc(&cd0, SIOR_PUTS, 0, &buffer, 4, &buffer, 4, NULL, NULL);
77int sio_putsn(
const char * str) {
79 SifCallRpc(&cd0, SIOR_PUTSN, 0, &buffer, 4, &buffer, 4, NULL, NULL);
85 SifCallRpc(&cd0, SIOR_GETS, 0, &buffer, 4, &buffer, 4, NULL, NULL);
90 SifCallRpc(&cd0, SIOR_FLUSH, 0, NULL, 0, NULL, 0, NULL, NULL);
93int sio_vprintf(
const char * str, va_list args) {
96 res = vsnprintf(tbuf,
sizeof(tbuf), str, args);
103int sio_printf(
const char * str, ...) {
108 res = sio_vprintf(str, args);
114int _start(
int argc,
char *argv[])
121 memset(&cd0, 0,
sizeof(cd0));
123 for (retries = 0; retries < 15; retries++) {
124 printf(
"Binding RPC.\n");
125 if (SifBindRpc(&cd0, SIOR_IRX, 0) < 0) {
127 return MODULE_NO_RESIDENT_END;
129 if (cd0.server != 0) {
130 printf(
"Registering library.\n");
131 if (RegisterLibraryEntries(&_exp_sior)) {
132 printf(
"Couldn't register.\n");
133 return MODULE_NO_RESIDENT_END;
135 return MODULE_RESIDENT_END;
137 printf(
"Huh, not available, retrying... ?\n");
141 printf(
"Giving up.\n");
143 return MODULE_NO_RESIDENT_END;
size_t sio_read(void *buf, size_t size)
char * sio_gets(char *str)
size_t sio_write(void *buf, size_t size)