aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gdt.h2
-rw-r--r--src/core/int.S3
-rw-r--r--src/core/paging.c5
-rw-r--r--src/core/paging.h15
-rw-r--r--src/core/scheduler.c20
-rw-r--r--src/core/scheduler.h4
6 files changed, 44 insertions, 5 deletions
diff --git a/src/core/gdt.h b/src/core/gdt.h
index 246ddbe..c0c9e05 100644
--- a/src/core/gdt.h
+++ b/src/core/gdt.h
@@ -62,6 +62,8 @@ typedef struct GDT_TSS {
u16 t_reserved, io_map;
} __attribute__((packed)) GDT_TSS;
+extern GDT_TSS TSS;
+
/**
* Copy GDT in memory
*/
diff --git a/src/core/int.S b/src/core/int.S
index 8ca8b7a..115f37c 100644
--- a/src/core/int.S
+++ b/src/core/int.S
@@ -63,8 +63,7 @@ INT_SYSCALL:
.globl INT_PAGE_FAULT
INT_PAGE_FAULT:
SAVE_REGS
- call page_fault
- hlt
+ call paging_page_fault
movb $0x20, %al
outb %al, $0x20
RESTORE_REGS
diff --git a/src/core/paging.c b/src/core/paging.c
index c32a3bc..8f12866 100644
--- a/src/core/paging.c
+++ b/src/core/paging.c
@@ -106,4 +106,9 @@ char *paging_allocate(int p){
print("Jean\n");
}
print("end");
+}
+
+void paging_page_fault(){
+ print("Page fault!");
+ asm("hlt");
} \ No newline at end of file
diff --git a/src/core/paging.h b/src/core/paging.h
index ad3671e..1526101 100644
--- a/src/core/paging.h
+++ b/src/core/paging.h
@@ -3,19 +3,24 @@
#define PAGING_CR0_BIT 0x80000000
#define PAGING_PAGE_SIZE 4096
-#define PAGING_MAX_PAGES 2048
+#define PAGING_MAX_PAGES 2048 // At least 1024 for the kernel
#if PAGING_MAX_PAGES%1024>0
#define PAGING_MAX_DIR_ENTRY PAGING_MAX_PAGES/1024+1
#else
#define PAGING_MAX_DIR_ENTRY PAGING_MAX_PAGES/1024
#endif
-/*
+/**
* Configure and enable paging
*/
void paging_enable();
-
+/**
+ * Allocate a new page and return its address
+ */
char* paging_allocate_next_page();
+/**
+ * Set usage status of a page
+ */
void paging_set_usage(int addr,char state);
/**
* Create a new page directory containing
@@ -23,4 +28,8 @@ void paging_set_usage(int addr,char state);
*/
char *paging_allocate(int p);
void paging_dump(int min,int max);
+/**
+ * Handler of page fault
+ */
+void paging_page_fault();
#endif \ No newline at end of file
diff --git a/src/core/scheduler.c b/src/core/scheduler.c
index e69de29..0f2b724 100644
--- a/src/core/scheduler.c
+++ b/src/core/scheduler.c
@@ -0,0 +1,20 @@
+#include "libc/stdio.h"
+
+char show_tics=0;
+
+void schedule(){
+
+}
+
+void clock(){
+ static int tic=0;
+ static int sec=0;
+ tic++;
+ if(tic>=20){
+ tic=0;
+ sec++;
+ if(show_tics)
+ putchar('.');
+ }
+ schedule();
+} \ No newline at end of file
diff --git a/src/core/scheduler.h b/src/core/scheduler.h
index f15168b..ec0caf1 100644
--- a/src/core/scheduler.h
+++ b/src/core/scheduler.h
@@ -1,5 +1,9 @@
#ifndef SCHEDULER_H
#define SCHEDULER_H
+extern char show_tics;
+
+void clock();
+void schedule();
#endif \ No newline at end of file