diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-14 14:13:44 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-14 14:13:44 +0200 |
| commit | 2fc03e597e97d2139490a303b95e5ad807ee4239 (patch) | |
| tree | fc496c88a2ba06743527d15b39888c9e23475052 /src/core/paging.c | |
| parent | e1e75aa387b1bc2b80df1895131fa9d446bba9ac (diff) | |
Improve task loading
Diffstat (limited to 'src/core/paging.c')
| -rw-r--r-- | src/core/paging.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/core/paging.c b/src/core/paging.c index 8f12866..0fab46a 100644 --- a/src/core/paging.c +++ b/src/core/paging.c @@ -88,24 +88,30 @@ char* paging_allocate_next_page(){ asm("hlt"); } - -char *paging_allocate(int p){ +// TODO: Take p into account +int *paging_allocate(int p){ + // ----- Allow kernel access during interruption int *page_dir=(int*)paging_allocate_next_page(); - int *page_table; - int current_page_entry=0; - int current_dir_entry=0; - while(current_page_entry<p){ - if(current_page_entry%1024 == 0){ - current_dir_entry++; - page_table=(int*)paging_allocate_next_page(); - page_dir[current_dir_entry]=(int)page_table; - } - int entry=current_page_entry%1024; - page_table[current_page_entry]=(int)paging_allocate_next_page(); - current_page_entry++; - print("Jean\n"); + int *k_page_table=(int*)paging_allocate_next_page(); + // Init page directory + page_dir[0]=(int)k_page_table|3; + // Init page table 0 + int addr_offset=0; + for(int i=0;i<1024;i++){ + k_page_table[i]=addr_offset; + k_page_table[i]|=3; // Permission + addr_offset+=PAGING_PAGE_SIZE; // 4Ko pages } - print("end"); + + // ----- Task table + int *u_page_table=(int*)paging_allocate_next_page(); + page_dir[1]=(int)u_page_table|7; // 1024*1024*4096/4 + u_page_table[0]=(int)page_dir|7; + u_page_table[1]=(int)k_page_table|7; + u_page_table[2]=(int)u_page_table|7; + u_page_table[3]=(int)paging_allocate_next_page()|7; + + return page_dir; } void paging_page_fault(){ |
