Cleaning code
This commit is contained in:
parent
5a9a57177f
commit
e1e75aa387
9 changed files with 66 additions and 25 deletions
|
@ -3,10 +3,8 @@
|
|||
#include "core/mem.h"
|
||||
#include "core/gdt.h"
|
||||
#include "core/paging.h"
|
||||
#include "core/scheduler.h"
|
||||
|
||||
char show_tics=0;
|
||||
|
||||
extern GDT_TSS TSS;
|
||||
extern void interrupt_enable();
|
||||
|
||||
void utask(){
|
||||
|
@ -60,19 +58,3 @@ void bringelle(){
|
|||
}
|
||||
|
||||
|
||||
void clock(){
|
||||
static int tic=0;
|
||||
static int sec=0;
|
||||
tic++;
|
||||
if(tic>=20){
|
||||
tic=0;
|
||||
sec++;
|
||||
if(show_tics)
|
||||
putchar('.');
|
||||
}
|
||||
}
|
||||
|
||||
void page_fault(){
|
||||
print("Page fault!");
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -106,4 +106,9 @@ char *paging_allocate(int p){
|
|||
print("Jean\n");
|
||||
}
|
||||
print("end");
|
||||
}
|
||||
|
||||
void paging_page_fault(){
|
||||
print("Page fault!");
|
||||
asm("hlt");
|
||||
}
|
|
@ -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
|
|
@ -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();
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
#ifndef SCHEDULER_H
|
||||
#define SCHEDULER_H
|
||||
|
||||
extern char show_tics;
|
||||
|
||||
void clock();
|
||||
void schedule();
|
||||
|
||||
#endif
|
|
@ -11,4 +11,22 @@ int pow(int x,int n){
|
|||
for(int i=0;i<(n-1);i++)
|
||||
ret*=x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int max(int x,int y){
|
||||
if(x>y)
|
||||
return x;
|
||||
return y;
|
||||
}
|
||||
|
||||
int min(int x,int y){
|
||||
if(x<y)
|
||||
return x;
|
||||
return y;
|
||||
}
|
||||
|
||||
int abs(int x){
|
||||
if(x<0)
|
||||
return -x;
|
||||
return x;
|
||||
}
|
|
@ -2,5 +2,7 @@
|
|||
#define MATH_H
|
||||
|
||||
int pow(int x,int n);
|
||||
|
||||
int max(int x,int y);
|
||||
int min(int x,int y);
|
||||
int abs(int x);
|
||||
#endif
|
Loading…
Add table
Reference in a new issue