Import backup from 2003-10-16

This commit is contained in:
Josh Holtrop 2003-10-16 22:00:00 -04:00
parent 5da602b162
commit 8bf6e65a95
7 changed files with 38 additions and 3 deletions

View File

@ -71,6 +71,14 @@ inline void restart()
} }
} }
inline void halt()
{
asm("cli");
asm("hlt");
while (1)
;
}
inline void eoi() inline void eoi()
{ {
outportb(0x20, 0x20); //EOI outportb(0x20, 0x20); //EOI

View File

@ -10,6 +10,7 @@ inline byte inportb(unsigned short port);
void enable_ints(); void enable_ints();
void disable_ints(); void disable_ints();
inline void restart(); inline void restart();
inline void halt();
void remap_pics(int pic1, int pic2); void remap_pics(int pic1, int pic2);
inline void pic1_mask(byte mask); inline void pic1_mask(byte mask);
inline void pic2_mask(byte mask); inline void pic2_mask(byte mask);

View File

@ -29,8 +29,11 @@
#define BRWHITE_TXT 0x0F #define BRWHITE_TXT 0x0F
#define FREERAM_START 0x268000 #define FREERAM_START 0x268000
#define MAX_RAM 0x40000000 //1gb maximum RAM supported
#define KERNEL_PID 0x02 #define PID_KERNEL 0x02
#define PID_VMM 0x03
#define PID_USER 0x10000
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned short word; typedef unsigned short word;

View File

@ -13,6 +13,7 @@
#include "functions.h" #include "functions.h"
#include "video.h" #include "video.h"
#include "mm.h" #include "mm.h"
#include "vmm.h"
#include "keyboard.h" #include "keyboard.h"
#include "mouse.h" #include "mouse.h"
@ -22,6 +23,7 @@ void k_init();
#include "mouse.c" #include "mouse.c"
#include "keyboard.c" #include "keyboard.c"
#include "mm.c" #include "mm.c"
#include "vmm.c"
#include "functions.c" #include "functions.c"
#include "video.c" #include "video.c"
@ -68,6 +70,7 @@ void k_init()
} }
mm_init(); mm_init();
vmm_init();
mouse_init(); mouse_init();
enable_ints(); enable_ints();
printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem); printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem);

5
mm.c
View File

@ -6,6 +6,7 @@
pageblock *first_pageblock = (pageblock *) 0; pageblock *first_pageblock = (pageblock *) 0;
dword mm_totalmem = 0x100000; //start counting from 1mb dword mm_totalmem = 0x100000; //start counting from 1mb
dword mm_highestAddress = 0;
void mm_init() void mm_init()
{ {
@ -17,6 +18,8 @@ void mm_init()
if (maps[a].attributes == 1) // (1) mem free to OS if (maps[a].attributes == 1) // (1) mem free to OS
{ {
mm_totalmem += maps[a].limit.lowdword; mm_totalmem += maps[a].limit.lowdword;
if (mm_highestAddress < (maps[a].base.lowdword + maps[a].limit.lowdword))
mm_highestAddress = maps[a].base.lowdword + maps[a].limit.lowdword;
if ((maps[a].base.lowdword + maps[a].limit.lowdword) > (FREERAM_START+8192)) //goes past where we start freeram if ((maps[a].base.lowdword + maps[a].limit.lowdword) > (FREERAM_START+8192)) //goes past where we start freeram
{ {
if (maps[a].base.lowdword < FREERAM_START) if (maps[a].base.lowdword < FREERAM_START)
@ -82,7 +85,7 @@ void mm_init_pageblockpage(pageblock *pbp)
void *mm_palloc(dword numpages, dword proc_pid) void *mm_palloc(dword numpages, dword proc_pid)
{ {
if (proc_pid < KERNEL_PID) if (proc_pid < PID_KERNEL)
return 0; return 0;
pageblock *pb = first_pageblock; pageblock *pb = first_pageblock;
if (mm_freeentries() < 2) if (mm_freeentries() < 2)

17
vmm.c
View File

@ -3,6 +3,21 @@
// Author: Josh Holtrop // Author: Josh Holtrop
// Date: 09/30/03 // Date: 09/30/03
void *vmm_PDBR;
void vmm_init()
{
if(!(vmm_PDBR = mm_palloc(1, PID_KERNEL)))
{
printf("ERROR! COULD NOT ALLOCATE PAGE FOR INITIAL PAGE DIRECTORY!!");
halt();
}
}
void *malloc(dword bytes) void *malloc(dword bytes)
{ {
@ -12,7 +27,7 @@ void *malloc(dword bytes)
int free(void *ptr); int free(void *ptr)
{ {

2
vmm.h
View File

@ -4,6 +4,7 @@
// Date: 09/30/03 // Date: 09/30/03
void vmm_init();
void *malloc(dword bytes); void *malloc(dword bytes);
int free(void *ptr); int free(void *ptr);
@ -11,3 +12,4 @@ int free(void *ptr);