Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e54b5743
authored
Nov 09, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added some command functionality
parent
e61fb400
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
3 deletions
src/io.c
src/io.c
View file @
e54b5743
...
@@ -2,15 +2,62 @@
...
@@ -2,15 +2,62 @@
#include "pic.h"
#include "pic.h"
#include "serial.h"
#include "serial.h"
#include "idt.h"
#include "idt.h"
#include "string.h"
#include "term.h"
char
scan_map
[
256
]
=
{
' '
,
'E'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'0'
,
'-'
,
'='
,
'\b'
,
'\t'
,
'q'
,
'w'
,
'e'
,
'r'
,
't'
,
'y'
,
'u'
,
'i'
,
'o'
,
'p'
,
char
scan_map
[
256
]
=
{
' '
,
'E'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'0'
,
'-'
,
'='
,
'\b'
,
'\t'
,
'q'
,
'w'
,
'e'
,
'r'
,
't'
,
'y'
,
'u'
,
'i'
,
'o'
,
'p'
,
'['
,
']'
,
'\n'
,
'^'
,
'a'
,
's'
,
'd'
,
'f'
,
'g'
,
'h'
,
'j'
,
'k'
,
'l'
,
';'
,
'\''
,
'`'
,
'S'
,
'\\'
,
'z'
,
'x'
,
'c'
,
'v'
,
'b'
,
'n'
,
'm'
,
'['
,
']'
,
'\n'
,
'^'
,
'a'
,
's'
,
'd'
,
'f'
,
'g'
,
'h'
,
'j'
,
'k'
,
'l'
,
';'
,
'\''
,
'`'
,
'S'
,
'\\'
,
'z'
,
'x'
,
'c'
,
'v'
,
'b'
,
'n'
,
'm'
,
','
,
'.'
,
'/'
,
'S'
,
'O'
,
'A'
,
' '
,
'C'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'L'
,
'L'
,};
','
,
'.'
,
'/'
,
'S'
,
'O'
,
'A'
,
' '
,
'C'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'F'
,
'L'
,
'L'
,};
char
kb_buf
[
256
];
int
kb_buf_size
;
int
cstack
[
128
];
int
cstack_size
;
void
io_process
(
char
*
s
)
{
terminal_putchar
(
'\n'
);
if
(
strncmp
(
s
,
"echo "
,
5
)
==
0
)
{
terminal_writestring
(
s
+
5
);
terminal_putchar
(
'\n'
);
}
else
if
(
strncmp
(
s
,
"serial "
,
7
)
==
0
)
{
serial_writestring
(
"
\n
"
);
serial_writestring
(
s
+
7
);
serial_writestring
(
"
\n
"
);
}
else
if
(
strncmp
(
s
,
"hex "
,
4
)
==
0
)
{
terminal_hexstring
(
s
+
4
,
16
);
terminal_putchar
(
'\n'
);
}
else
if
(
strncmp
(
s
,
"push "
,
5
)
==
0
)
{
int
n
=
stoi
(
s
+
5
);
cstack
[
cstack_size
]
=
n
;
cstack_size
++
;
//terminal_writestring("pushed\n");
}
else
if
(
strncmp
(
s
,
"pop"
,
3
)
==
0
)
{
if
(
cstack_size
==
0
)
{
terminal_writestring
(
"stack empty
\n
"
);
}
else
{
terminal_putchar
(
cstack
[
cstack_size
-
1
]
+
48
);
cstack_size
--
;
terminal_putchar
(
'\n'
);
}
}
}
void
kbd_irq
()
void
kbd_irq
()
{
{
int
a
=
inb
(
0x60
);
int
a
=
inb
(
0x60
);
serial_hexword
(
a
);
//
serial_hexword(a);
if
(
a
==
0x4b
)
if
(
a
==
0x4b
)
terminal_adjustcursor
(
-
1
,
0
);
terminal_adjustcursor
(
-
1
,
0
);
else
if
(
a
==
0x4d
)
else
if
(
a
==
0x4d
)
...
@@ -20,10 +67,33 @@ void kbd_irq()
...
@@ -20,10 +67,33 @@ void kbd_irq()
else
if
(
a
==
0x50
)
else
if
(
a
==
0x50
)
terminal_adjustcursor
(
0
,
1
);
terminal_adjustcursor
(
0
,
1
);
else
if
(
a
<
0x80
)
else
if
(
a
<
0x80
)
terminal_putchar
(
scan_map
[
a
]);
{
char
in
=
scan_map
[
a
];
if
(
in
==
'\n'
)
//enter pressed
{
io_process
(
kb_buf
);
for
(
int
i
=
0
;
i
<
kb_buf_size
;
i
++
)
{
kb_buf
[
i
]
=
'\0'
;
}
kb_buf_size
=
0
;
}
else
if
(
in
==
'\b'
)
{
kb_buf_size
--
;
kb_buf
[
kb_buf_size
]
=
'\0'
;
terminal_putchar
(
in
);
}
else
{
kb_buf
[
kb_buf_size
]
=
in
;
kb_buf_size
++
;
terminal_putchar
(
in
);
}
}
//else
//else
//terminal_putchar(scan_map[a-0x80]);
//terminal_putchar(scan_map[a-0x80]);
serial_writestring
(
"
\n
"
);
//
serial_writestring("\n");
pic_command
(
0
,
PIC_OCW2_EOI
);
pic_command
(
0
,
PIC_OCW2_EOI
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment