Skip to content

Commit 849f337

Browse files
authored
Merge pull request #748 from Ziemas/deci2-tty
Implement DECI2 TTY functions
2 parents d5cfa0e + d1a988c commit 849f337

File tree

5 files changed

+430
-1
lines changed

5 files changed

+430
-1
lines changed

ee/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ KERNEL_OBJS = ResetEE.o SetGsCrt.o $(EXEC_SYSCALLS) \
225225
EE_OBJS = $(KERNEL_OBJS) $(SIFCMD_OBJS) $(SIFRPC_OBJS) $(FILEIO_OBJS) \
226226
$(LOADFILE_OBJS) $(IOPHEAP_OBJS) $(IOPCONTROL_OBJS) $(ROM0_OBJS) $(CONFIG_OBJS) \
227227
$(GLUE_OBJS) $(SIO_OBJS) $(TIMER_OBJS) $(TIMER_ALARM_OBJS) $(DELAYTHREAD_OBJS) $(GETKERNEL_OBJS) \
228-
$(INITSYS_OBJS) $(KERNEL_UTIL_OBJS) erl-support.o
228+
$(INITSYS_OBJS) $(KERNEL_UTIL_OBJS) deci2.o tty.o erl-support.o
229229

230230

231231
EE_OBJS += $(THREAD_OBJS) $(LIBOSD_OBJS) $(TLBFUNC_OBJS) $(ALARM_OBJS) $(EXIT_OBJS) $(SETUP_OBJS) setup_syscalls.o debug.o

ee/kernel/include/deci2.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Licenced under Academic Free License version 2.0
7+
# Review ps2sdk README & LICENSE files for further details.
8+
*/
9+
10+
/**
11+
* @file
12+
* DECI2 library functions
13+
*/
14+
15+
#ifndef DECI2_H_
16+
#define DECI2_H_
17+
18+
enum {
19+
DECI2_ERR_INVALID = -1,
20+
DECI2_ERR_INVALSOCK = -2,
21+
DECI2_ERR_ALREADYUSE = -3,
22+
DECI2_ERR_MFILE = -4,
23+
DECI2_ERR_INVALADDR = -5,
24+
DECI2_ERR_PKTSIZE = -6,
25+
DECI2_ERR_WOULDBLOCK = -7,
26+
DECI2_ERR_ALREADYLOCK = -8,
27+
DECI2_ERR_NOTLOCKED = -9,
28+
DECI2_ERR_NOROUTE = -10,
29+
DECI2_ERR_NOSPACE = -11,
30+
DECI2_ERR_INVALHEAD = -12,
31+
};
32+
33+
enum {
34+
DECI2_READ = 1,
35+
DECI2_READ_DONE = 2,
36+
DECI2_WRITE = 3,
37+
DECI2_WRITE_DONE = 4,
38+
DECI2_CHSTATUS = 5,
39+
DECI2_ERROR = 6,
40+
};
41+
42+
int sceDeci2Open(unsigned short protocol, void *opt, void (*handler)(int event, int param, void *opt));
43+
int sceDeci2Close(int s);
44+
int sceDeci2ReqSend(int s, char dest);
45+
void sceDeci2Poll(int s);
46+
int sceDeci2ExRecv(int s, void *buf, unsigned short len);
47+
int sceDeci2ExSend(int s, void *buf, unsigned short len);
48+
int sceDeci2ExReqSend(int s, char dest);
49+
int sceDeci2ExLock(int s);
50+
int sceDeci2ExUnLock(int s);
51+
int kputs(char *s);
52+
53+
#endif // DECI2_H_

ee/kernel/include/tty.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Licenced under Academic Free License version 2.0
7+
# Review ps2sdk README & LICENSE files for further details.
8+
*/
9+
10+
/**
11+
* @file
12+
* DECI2 TTY
13+
*/
14+
15+
#ifndef TTY_H_
16+
#define TTY_H_
17+
18+
extern int ttyinit;
19+
20+
int sceTtyInit();
21+
int sceTtyWrite(const char *buf, int len);
22+
int sceTtyRead(char *buf, int len);
23+
24+
#endif // TTY_H_

ee/kernel/src/deci2.c

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Licenced under Academic Free License version 2.0
7+
# Review ps2sdk README & LICENSE files for further details.
8+
*/
9+
10+
/**
11+
* @file
12+
* DECI2
13+
*/
14+
15+
#include "kernel.h"
16+
17+
// actual size?
18+
static char userarea[56];
19+
20+
int sceDeci2Open(unsigned short protocol, void *opt,
21+
void (*handler)(int event, int param, void *opt))
22+
{
23+
24+
u32 args[4];
25+
26+
args[0] = protocol & 0xffff;
27+
args[1] = (u32)opt;
28+
args[2] = (u32)handler;
29+
args[3] = (u32)UNCACHED_SEG(userarea);
30+
31+
return Deci2Call(1, args);
32+
}
33+
34+
int sceDeci2Close(int s)
35+
{
36+
u32 args[4];
37+
38+
args[0] = s;
39+
40+
return Deci2Call(2, args);
41+
}
42+
43+
int sceDeci2ReqSend(int s, char dest)
44+
{
45+
u32 args[4];
46+
47+
args[0] = s;
48+
args[1] = dest;
49+
50+
return Deci2Call(3, args);
51+
}
52+
53+
void sceDeci2Poll(int s)
54+
{
55+
u32 args[4];
56+
57+
args[0] = s;
58+
59+
Deci2Call(4, args);
60+
}
61+
62+
int sceDeci2ExRecv(int s, void *buf, unsigned short len)
63+
{
64+
u32 args[4];
65+
66+
args[0] = s;
67+
args[1] = (u32)buf;
68+
args[2] = len & 0xffff;
69+
70+
return Deci2Call(-5, args);
71+
}
72+
73+
int sceDeci2ExSend(int s, void *buf, unsigned short len)
74+
{
75+
u32 args[4];
76+
77+
args[0] = s;
78+
args[1] = (u32)buf;
79+
args[2] = len & 0xffff;
80+
81+
return Deci2Call(-6, args);
82+
}
83+
84+
int sceDeci2ExReqSend(int s, char dest)
85+
{
86+
u32 args[4];
87+
88+
args[0] = s;
89+
args[1] = dest;
90+
91+
return Deci2Call(-7, args);
92+
}
93+
94+
int sceDeci2ExLock(int s)
95+
{
96+
u32 args[4];
97+
98+
args[0] = s;
99+
100+
return Deci2Call(-8, args);
101+
}
102+
103+
int sceDeci2ExUnLock(int s)
104+
{
105+
u32 args[4];
106+
107+
args[0] = s;
108+
109+
return Deci2Call(-9, args);
110+
}
111+
112+
int kputs(char *s)
113+
{
114+
u32 args[4];
115+
116+
args[0] = (u32)s;
117+
118+
return Deci2Call(16, args);
119+
}

0 commit comments

Comments
 (0)