Commit 09b732fe by triazo

Move tests to their own file

parent 155b2238
......@@ -8,6 +8,7 @@
#include "mem.h"
#include "gdt.h"
#include "idt.h"
#include "test.h"
#if defined(__cplusplus)
extern "C" /* Use C linkage for kernel_main. */
......@@ -37,10 +38,9 @@ void kernel_main()
enablePaging();
serial_writestring("Finished Initilizing memory\n");
asm ("int $0x80");
asm ("int $0x90");
int o=0;
int j=5/o;
serial_hexword(j);
asm ("hlt");
test_mem();
test_idt();
}
......@@ -28,6 +28,10 @@ page_directory_entry* initiate_directory()
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;
}
......
/*
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");
}
/*
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment