Repository navigation
Expand file tree
/
Copy pathstdtty.cc
More file actions
112 lines (86 loc) · 1.7 KB
/
Copy pathstdtty.cc
File metadata and controls
112 lines (86 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <os.h>
#include <stdtty.h>
File* console_mknod(char* name,u32 flag,File* dev){
Console* cons=new Console(name,flag);
return cons;
}
module("module.stdio",MODULE_DEVICE,Console,console_mknod)
Console::~Console(){
if (iotty!=&io)
delete iotty;
}
Console::Console(char* n,u32 flag) : Device(n)
{
if (flag==0)
iotty=new Io(flag);
else
iotty=&io;
}
void Console::reset_info(){
//static info
strncpy(sinfo.name,name,TTY_NAME_LEN);
sinfo.state=TTY_STATE_RUN;
sinfo.type=TTY_TYPE_IOSTD;
sinfo.flags=0;
//moving info
minfo.x=iotty->getX();
minfo.y=iotty->getY();
minfo.attrf=White;
minfo.attrb=Black;
}
void Console::scan(){
}
u32 Console::open(u32 flag){
return RETURN_OK;
}
u32 Console::close(){
return RETURN_OK;
}
u32 Console::read(u32 pos,u8* buffer,u32 sizee){
return iotty->read((char*)buffer,sizee);
}
u32 Console::write(u32 pos,u8* buffer,u32 size){
int i;
for (i=0;i<size;i++){
iotty->putc(*buffer);
buffer++;
}
return size;
}
u32 Console::ioctl(u32 id,u8* buffer){
u32 ret=0;
reset_info();
switch (id){
case DEV_GET_TYPE:
ret=DEV_TYPE_TTY;
break;
case DEV_GET_STATE:
ret=DEV_STATE_OK;
break;
case DEV_GET_FORMAT:
ret=DEV_FORMAT_CHAR;
break;
case API_TTY_SWITCH_SCREEN:
iotty->switchtty();
break;
case API_TTY_CLEAR_SCREEN:
iotty->clear();
break;
case API_TTY_GET_SINFO:
memcpy((char*)buffer,(char*)&sinfo,sizeof(tty_info_static));
break;
case API_TTY_GET_MINFO:
memcpy((char*)buffer,(char*)&minfo,sizeof(tty_info_moving));
break;
case API_TTY_SET_MINFO:
break;
default:
ret=NOT_DEFINED;
break;
}
return ret;
}
u32 Console::remove(){
delete this;
return RETURN_OK;
}