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
a3051ccb
authored
Oct 17, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix bug in serial_hexword
parent
dd9209b7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
src/serial.c
src/serial.c
View file @
a3051ccb
...
...
@@ -6,7 +6,7 @@
#define SERIAL_IO_PORT 0x3f8 // COM1
void
serial_init
()
void
serial_init
()
{
outb
(
SERIAL_IO_PORT
+
1
,
0x00
);
// Disable all interrupts
outb
(
SERIAL_IO_PORT
+
3
,
0x80
);
// Enable DLAB (set baud rate divisor)
...
...
@@ -17,21 +17,21 @@ void serial_init()
outb
(
SERIAL_IO_PORT
+
4
,
0x0B
);
// IRQs enabled, RTS/DSR set
}
int
is_transmit_empty
()
int
is_transmit_empty
()
{
return
inb
(
SERIAL_IO_PORT
+
5
)
&
0x20
;
}
void
serial_writechar
(
char
a
)
void
serial_writechar
(
char
a
)
{
while
(
is_transmit_empty
()
==
0
);
outb
(
SERIAL_IO_PORT
,
a
);
}
void
serial_writestring
(
char
*
s
)
void
serial_writestring
(
char
*
s
)
{
while
(
*
s
)
while
(
*
s
)
{
serial_writechar
(
*
s
);
s
++
;
...
...
@@ -39,9 +39,9 @@ void serial_writestring(char* s)
}
const
char
*
hexchars
=
"0123456789abcdef"
;
void
serial_hexword
(
uint32_t
x
)
void
serial_hexword
(
uint32_t
x
)
{
for
(
int
i
=
8
;
i
!=
0
;
i
--
)
for
(
int
i
=
7
;
i
>=
0
;
i
--
)
{
serial_writechar
(
hexchars
[
x
>>
i
*
4
&
0xf
]);
}
...
...
@@ -49,7 +49,7 @@ void serial_hexword(uint32_t x)
void
serial_hexstring
(
void
*
s
,
uint32_t
n
)
{
char
*
d
=
(
char
*
)
s
;
for
(
uint32_t
i
=
0
;
i
<
n
;
i
++
)
for
(
uint32_t
i
=
0
;
i
<
n
;
i
++
)
{
serial_writechar
(
hexchars
[(
d
[
i
]
>>
4
)
&
0xf
]);
serial_writechar
(
hexchars
[
d
[
i
]
&
0xf
]);
...
...
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