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
09b732fe
authored
Oct 13, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move tests to their own file
parent
155b2238
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
3 deletions
src/kern.c
src/mem.c
src/test.c
src/test.h
src/kern.c
View file @
09b732fe
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "mem.h"
#include "mem.h"
#include "gdt.h"
#include "gdt.h"
#include "idt.h"
#include "idt.h"
#include "test.h"
#if defined(__cplusplus)
#if defined(__cplusplus)
extern
"C"
/* Use C linkage for kernel_main. */
extern
"C"
/* Use C linkage for kernel_main. */
...
@@ -37,10 +38,9 @@ void kernel_main()
...
@@ -37,10 +38,9 @@ void kernel_main()
enablePaging
();
enablePaging
();
serial_writestring
(
"Finished Initilizing memory
\n
"
);
serial_writestring
(
"Finished Initilizing memory
\n
"
);
asm
(
"int $0x80"
);
asm
(
"int $0x90"
);
int
o
=
0
;
int
o
=
0
;
int
j
=
5
/
o
;
int
j
=
5
/
o
;
serial_hexword
(
j
);
serial_hexword
(
j
);
asm
(
"hlt"
);
test_mem
();
test_idt
();
}
}
src/mem.c
View file @
09b732fe
...
@@ -28,6 +28,10 @@ page_directory_entry* initiate_directory()
...
@@ -28,6 +28,10 @@ page_directory_entry* initiate_directory()
page_directory
[
i
]
|=
PAGE_WRITABLE
;
page_directory
[
i
]
|=
PAGE_WRITABLE
;
}
}
// Set last directory entry to point back
page_directory
[
1023
]
=
(
uint32_t
)
page_directory
;
page_directory
[
1023
]
|=
PAGE_WRITABLE
|
PAGE_PRESENT
;
return
page_directory
;
return
page_directory
;
}
}
...
...
src/test.c
0 → 100644
View file @
09b732fe
/*
test.c implements functions used for testing
*/
#include "test.h"
void
test_idt
()
{
asm
(
"int $0x80"
);
asm
(
"int $0x90"
);
asm
(
"hlt"
);
}
void
test_mem
()
{
// try writing a bunch of bytes starting at 0
int
i
=
0x0
;
for
(
i
=
0
;
i
<
0x4000
;
i
++
)
{
*
(
int
*
)(
i
<<
2
)
=
i
;
serial_writestring
(
"wrote 0x"
);
serial_hexstring
(
&
i
,
4
);
serial_writestring
(
"
\n
"
);
}
// read it back in and make sure its all stored
for
(
i
=
0
;
i
<
0x4000
;
i
++
)
{
if
(
*
(
int
*
)(
i
<<
2
)
!=
i
)
{
serial_writestring
(
"Memory error
\n
"
);
}
}
serial_writestring
(
"Wrote a bunch of memory
\n
"
);
}
src/test.h
0 → 100644
View file @
09b732fe
/*
test.h defines functions used for testing
*/
#ifndef INC_TEST
#define INC_TEST
#include "serial.h"
// test_idt calls a couple of interrupts. Should be done after kernel
// has been set up
void
test_idt
();
// test_mem writes some stuff to moem
void
test_mem
();
#endif
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