Debug paging
This commit is contained in:
parent
1e397041c2
commit
dcadede2d4
3 changed files with 14 additions and 22 deletions
|
@ -8,7 +8,7 @@
|
||||||
extern void interrupt_enable();
|
extern void interrupt_enable();
|
||||||
|
|
||||||
void utask(){
|
void utask(){
|
||||||
char *msg=(char*)4206592+300;
|
char *msg=(char*)PAGING_ENTRY_POINT_VIRT+300;
|
||||||
msg[0]='A';
|
msg[0]='A';
|
||||||
msg[1]='\0';
|
msg[1]='\0';
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -20,7 +20,7 @@ void utask(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void utask2(){
|
void utask2(){
|
||||||
char *msg=(char*)4206592+300;
|
char *msg=(char*)PAGING_ENTRY_POINT_VIRT+300;
|
||||||
msg[0]='B';
|
msg[0]='B';
|
||||||
msg[1]='\0';
|
msg[1]='\0';
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -53,8 +53,6 @@ void bringelle(){
|
||||||
|
|
||||||
int* page_dir=paging_allocate(2);
|
int* page_dir=paging_allocate(2);
|
||||||
task_create(page_dir, utask,100, 0xFF);
|
task_create(page_dir, utask,100, 0xFF);
|
||||||
|
|
||||||
|
|
||||||
int* page_dir2=paging_allocate(2);
|
int* page_dir2=paging_allocate(2);
|
||||||
task_create(page_dir2, utask2,100,0xFF);
|
task_create(page_dir2, utask2,100,0xFF);
|
||||||
|
|
||||||
|
|
|
@ -89,42 +89,36 @@ char* paging_allocate_next_page(){
|
||||||
asm("hlt");
|
asm("hlt");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Take p into account
|
|
||||||
int *paging_allocate(int p){
|
int *paging_allocate(int p){
|
||||||
// ----- Allow kernel access during interruption
|
// ----- Populate kernel adresses (to be able to execute interrupts codes)
|
||||||
int *page_dir=(int*)paging_allocate_next_page();
|
int *page_dir=(int*)paging_allocate_next_page();
|
||||||
int *k_page_table=(int*)paging_allocate_next_page();
|
int *k_page_table=(int*)paging_allocate_next_page();
|
||||||
// Init page directory
|
// Kernel is located in the first 4Mb (page dir entry 0)
|
||||||
page_dir[0]=(int)k_page_table|3;
|
page_dir[0]=(int)k_page_table|3;
|
||||||
// Init page table 0
|
|
||||||
int addr_offset=0;
|
int addr_offset=0;
|
||||||
for(int i=0;i<1024;i++){
|
for(int i=0;i<1024;i++){
|
||||||
k_page_table[i]=addr_offset;
|
k_page_table[i]=addr_offset;
|
||||||
k_page_table[i]|=3; // Permission
|
k_page_table[i]|=3; // Permissions
|
||||||
addr_offset+=PAGING_PAGE_SIZE; // 4Ko pages
|
addr_offset+=PAGING_PAGE_SIZE; // 4Ko pages
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- Task table
|
// ----- Populate task adresses
|
||||||
int *u_page_table=(int*)paging_allocate_next_page();
|
int *u_page_table=(int)paging_allocate_next_page();
|
||||||
page_dir[1]=(int)u_page_table|7;
|
page_dir[1]=(int)u_page_table|7;
|
||||||
u_page_table[0]=(int)page_dir|7; // Virtual address is 1024*4096/4
|
int dir_entry=1; // Entry point is at 1024*4096=4194304 (page dir entry 1 and page table entry 0)
|
||||||
u_page_table[1]=(int)k_page_table|7;
|
int pt_entry=0;
|
||||||
u_page_table[2]=(int)u_page_table|7;
|
|
||||||
|
|
||||||
int dir_entry=1;
|
|
||||||
int pt_entry=3;
|
|
||||||
int p_current=max(1,p); // Allocate at least 1 page
|
int p_current=max(1,p); // Allocate at least 1 page
|
||||||
while(p_current!=0){
|
while(p_current!=0){
|
||||||
|
u_page_table[pt_entry]=(int)paging_allocate_next_page()|7;
|
||||||
|
p_current--;
|
||||||
|
pt_entry++;
|
||||||
if(pt_entry%1024==0){
|
if(pt_entry%1024==0){
|
||||||
dir_entry++;
|
dir_entry++;
|
||||||
pt_entry=0;
|
pt_entry=0;
|
||||||
u_page_table=(int*)paging_allocate_next_page();
|
u_page_table=(int*)paging_allocate_next_page();
|
||||||
page_dir[dir_entry]=(int)u_page_table|7;
|
page_dir[dir_entry]=(int)u_page_table|7;
|
||||||
}
|
}
|
||||||
u_page_table[pt_entry]=(int)paging_allocate_next_page()|7;
|
|
||||||
p_current--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_dir;
|
return page_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
#define PAGING_MAX_DIR_ENTRY PAGING_MAX_PAGES/1024
|
#define PAGING_MAX_DIR_ENTRY PAGING_MAX_PAGES/1024
|
||||||
#endif
|
#endif
|
||||||
#define PAGING_PADDR(entry) ((int*)(((u32)entry)&0xFFFFF000))
|
#define PAGING_PADDR(entry) ((int*)(((u32)entry)&0xFFFFF000))
|
||||||
#define PAGING_ENTRY_POINT_VIRT (1024*PAGING_PAGE_SIZE+3*PAGING_PAGE_SIZE)
|
#define PAGING_ENTRY_POINT_VIRT (1024*PAGING_PAGE_SIZE)
|
||||||
#define PAGING_ENTRY_POINT_PHY(page_dir) ((int*)(((int*)((((int*)page_dir)[1])&0xFFFFF000))[3]&0xFFFFF000))
|
#define PAGING_ENTRY_POINT_PHY(page_dir) ((int*)(((int*)((((int*)page_dir)[1])&0xFFFFF000))[0]&0xFFFFF000))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure and enable paging
|
* Configure and enable paging
|
||||||
|
|
Loading…
Add table
Reference in a new issue