-
Notifications
You must be signed in to change notification settings - Fork 0
/
ps2.c
83 lines (69 loc) · 1.38 KB
/
ps2.c
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
// Inspiration PS/2 Functions Library
void enablemouse()
{
io_wait_ps2_w();
out(0x64,0xAD); // Disable Keyboard
io_wait_ps2_w();
out(0x64,0xA8); // Enable 2nd PS/2 Port
io_wait_ps2_w();
out(0x64,0xD4); // Send next byte to 2nd PS/2 Device
io_wait_ps2_w();
out(0x60,0xF4); // Tell Mouse to Enable Data Reporting
io_wait_ps2_w();
out(0x64,0xAE); // Enable Keyboard
}
void set_scancode_1()
{
io_wait_ps2_w();
out(0x60,0xF0);
io_wait_ps2_w();
out(0x60,0x00);
}
void setLEDs(int scrolllock,int numlock,int capslock)
{
unsigned char data_byte=0;
if(scrolllock==1)
{
data_byte=data_byte|1;
}
if(numlock==1)
{
data_byte=data_byte|2;
}
if(capslock==1)
{
data_byte=data_byte|4;
}
io_wait_ps2_w();
out(0x60,0xED);
io_wait_ps2_w();
out(0x60,data_byte);
}
void io_wait_ps2_w()
{
unsigned char inv;
for(;;)
{
inv=in(0x64);
inv=inv<<6;
inv=inv>>7;
if(inv==0)
{
break;
}
}
}
void io_wait_ps2_r()
{
unsigned char inv;
for(;;)
{
inv=in(0x64);
inv=inv<<7;
inv=inv>>7;
if(inv==1)
{
break;
}
}
}