Subversion Repositories HelenOS-historic

Rev

Rev 1705 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1705 Rev 1780
Line 49... Line 49...
49
#include <print.h>
49
#include <print.h>
50
#include <interrupt.h>
50
#include <interrupt.h>
51
 
51
 
52
void page_arch_init(void)
52
void page_arch_init(void)
53
{
53
{
54
    __address cur;
54
    uintptr_t cur;
55
    int flags;
55
    int flags;
56
 
56
 
57
    if (config.cpu_active == 1) {
57
    if (config.cpu_active == 1) {
58
        page_mapping_operations = &pt_mapping_operations;
58
        page_mapping_operations = &pt_mapping_operations;
59
   
59
   
Line 66... Line 66...
66
                flags |= PAGE_GLOBAL;
66
                flags |= PAGE_GLOBAL;
67
            page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
67
            page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
68
        }
68
        }
69
 
69
 
70
        exc_register(14, "page_fault", (iroutine) page_fault);
70
        exc_register(14, "page_fault", (iroutine) page_fault);
71
        write_cr3((__address) AS_KERNEL->page_table);
71
        write_cr3((uintptr_t) AS_KERNEL->page_table);
72
    }
72
    }
73
    else {
73
    else {
74
        write_cr3((__address) AS_KERNEL->page_table);
74
        write_cr3((uintptr_t) AS_KERNEL->page_table);
75
    }
75
    }
76
 
76
 
77
    paging_on();
77
    paging_on();
78
}
78
}
79
 
79
 
80
 
80
 
81
__address hw_map(__address physaddr, size_t size)
81
uintptr_t hw_map(uintptr_t physaddr, size_t size)
82
{
82
{
83
    if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
83
    if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
84
        panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
84
        panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
85
   
85
   
86
    __address virtaddr = PA2KA(last_frame);
86
    uintptr_t virtaddr = PA2KA(last_frame);
87
    pfn_t i;
87
    pfn_t i;
88
    for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
88
    for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
89
        page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE);
89
        page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE);
90
   
90
   
91
    last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
91
    last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
Line 93... Line 93...
93
    return virtaddr;
93
    return virtaddr;
94
}
94
}
95
 
95
 
96
void page_fault(int n, istate_t *istate)
96
void page_fault(int n, istate_t *istate)
97
{
97
{
98
        __address page;
98
        uintptr_t page;
99
    pf_access_t access;
99
    pf_access_t access;
100
   
100
   
101
        page = read_cr2();
101
        page = read_cr2();
102
       
102
       
103
        if (istate->error_word & PFERR_CODE_RSVD)
103
        if (istate->error_word & PFERR_CODE_RSVD)