a few cleanups

This commit is contained in:
Steffen Vogel 2014-12-04 20:33:28 +01:00
parent 370997f516
commit 67b8ca111a
2 changed files with 14 additions and 17 deletions

View file

@ -153,10 +153,10 @@ flush2:
; 5: Out of Bounds Exception
; 6: Invalid Opcode Exception
; 7: Coprocessor Not Available Exception
%assign i 0
%assign i 0
%rep 8
isrstub_pseudo_error i
%assign i i+1
%assign i i+1
%endrep
; 8: Double Fault Exception (With Error Code!)
@ -336,7 +336,7 @@ boot_pgd:
boot_pgt:
%assign i 0
%rep 1024 ; PAGE_MAP_ENTRIES
DD i | 0x203 ; PG_BOOT | PG_RW | PG_PRESENT
DD i | 0x203 ; PG_PRESENT | PG_BOOT | PG_RW
%assign i i + 4096 ; PAGE_SIZE
%endrep

View file

@ -28,6 +28,8 @@
* This is a 32/64 bit portable paging implementation for the x86 architecture
* using self-referenced page tables.
* See http://www.noteblok.net/2014/06/14/bachelor/ for a detailed description.
*
* @author Steffen Vogel <steffen.vogel@rwth-aachen.de>
*/
#include <eduos/stdio.h>
@ -38,7 +40,6 @@
#include <asm/irq.h>
#include <asm/page.h>
#include <asm/io.h>
#include <asm/multiboot.h>
/* Note that linker symbols are not variables, they have no memory
@ -64,10 +65,6 @@ static size_t * other[PAGE_LEVELS] = {
(size_t *) 0xFFFFE000
};
/* Addresses of child/parent tables */
#define CHILD(map, lvl, vpn) &map[lvl-1][vpn<<PAGE_MAP_BITS]
#define PARENT(map, lvl, vpn) &map[lvl+1][vpn>>PAGE_MAP_BITS]
size_t page_virt_to_phys(size_t addr)
{
size_t vpn = addr >> PAGE_BITS; // virtual page number
@ -110,7 +107,7 @@ int page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits)
self[lvl][vpn] = phyaddr | bits;
/* Fill new table with zeros */
memset(CHILD(self, lvl, vpn), 0, PAGE_SIZE);
memset(&self[lvl-1][vpn<<PAGE_MAP_BITS], 0, PAGE_SIZE);
}
}
else { /* PGT */
@ -176,7 +173,7 @@ int page_map_drop()
traverse(PAGE_LEVELS-1, 0);
spinlock_irqsave_unlock(&current_task->page_lock);
return 0;
}
@ -223,7 +220,7 @@ void page_fault_handler(struct state *s)
{
size_t viraddr = read_cr2();
kprintf("Page Fault Exception (%d) at cs:ip = %#x:%#lx, task = %u, addr = %#lx, error = %#x [ %s %s %s %s %s ]\n",
kprintf("Page Fault Exception (%d) at cs:ip = %#x:%#lx, task = %u, addr = %#lx, error = %#x [ %s %s %s %s %s ]\n",
s->int_no, s->cs, s->eip, current_task->id, viraddr, s->error,
(s->error & 0x4) ? "user" : "supervisor",
(s->error & 0x10) ? "instruction" : "data",
@ -246,7 +243,7 @@ int page_init()
/* Map kernel */
addr = (size_t) &kernel_start;
npages = PAGE_FLOOR((size_t) &kernel_end - (size_t) &kernel_start) >> PAGE_BITS;
page_map(addr, addr, npages, PG_PRESENT | PG_RW | PG_GLOBAL);
page_map(addr, addr, npages, PG_PRESENT | PG_RW | /* PG_USER | */ PG_GLOBAL);
#ifdef CONFIG_VGA
/* Map video memory */
@ -274,12 +271,12 @@ int page_init()
}
/* Unmap bootstrap identity paging (see entry.asm, PG_BOOT) */
for (i=0; i<PAGE_MAP_ENTRIES; i++) {
if (self[0][i] & PG_BOOT) {
for (i=0; i<PAGE_MAP_ENTRIES; i++)
if (self[0][i] & PG_BOOT)
self[0][i] = 0;
tlb_flush_one_page(i << PAGE_BITS);
}
}
/* Flush TLB to adopt changes above */
flush_tlb();
return 0;
}