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
20eb3a51
authored
Sep 13, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make serial work more reliably
parent
47bb3424
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
25 deletions
src/asm.c
src/asm.h
src/kern.c
src/makefile
src/serial.c
src/asm.c
deleted
100644 → 0
View file @
47bb3424
/*
asm.c contains x86 specific functions for executing low level code
*/
#include "asm.h"
// Wrapper for outb
// Stolen from http://wiki.osdev.org/Inline_Assembly/Examples
static
inline
void
outb
(
uint16_t
port
,
uint8_t
val
)
{
asm
volatile
(
"outb %0, %1"
:
:
"a"
(
val
),
"Nd"
(
port
));
}
// Wrapper for inb
static
inline
uint8_t
inb
(
uint16_t
port
)
{
uint8_t
ret
;
asm
volatile
(
"inb %1, %0"
:
"=a"
(
ret
)
:
"Nd"
(
port
));
return
ret
;
}
src/asm.h
View file @
20eb3a51
/*
asm.h
exports archatecture specific functions for hardware interaction
asm.h
contains x86 specific functions for executing low level code
*/
#pragma once
#include <stdint.h>
// Functions for reading and writing to/from x86 IO ports
static
inline
void
outb
(
uint16_t
port
,
uint8_t
val
);
static
inline
uint8_t
inb
(
uint16_t
port
);
// Wrapper for outb
// Stolen from http://wiki.osdev.org/Inline_Assembly/Examples
inline
void
outb
(
uint16_t
port
,
uint8_t
val
)
{
asm
volatile
(
"outb %0, %1"
:
:
"a"
(
val
),
"Nd"
(
port
));
}
// Wrapper for inb
inline
uint8_t
inb
(
uint16_t
port
)
{
uint8_t
ret
;
asm
volatile
(
"inb %1, %0"
:
"=a"
(
ret
)
:
"Nd"
(
port
));
return
ret
;
}
src/kern.c
View file @
20eb3a51
...
...
@@ -110,7 +110,8 @@ void kernel_main() {
* yet, '\n' will produce some VGA specific character instead.
* This is normal.
*/
terminal_writestring
(
"Hello, kernel World!
\n
"
);
serial_init
();
serial_writestring
(
"Hello, kernel World!
\n
"
);
serial_writestring
(
"First Serial Test!
\n
"
);
terminal_writestring
(
"Hello, kernel World!
\n
"
);
serial_writestring
(
"Second Serial Test
\n
"
);
}
src/makefile
View file @
20eb3a51
...
...
@@ -6,3 +6,4 @@ all:
$C
-T
linker.ld
-o
myos.bin
-ffreestanding
-O2
-nostdlib
*
.o
-lgcc
clean
:
rm
*
.o
*
.bin
src/serial.c
View file @
20eb3a51
...
...
@@ -27,7 +27,7 @@ void serial_writechar(char a) {
}
void
serial_writestring
(
char
*
s
)
{
while
(
s
)
{
while
(
*
s
)
{
serial_writechar
(
*
s
);
s
++
;
}
...
...
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