Subversion Repositories HelenOS

Rev

Rev 2323 | Rev 2349 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2323 Rev 2339
Line 45... Line 45...
45
 *  @param pte    Section entry to initialize.
45
 *  @param pte    Section entry to initialize.
46
 *  @param frame  First frame in the section (frame number).
46
 *  @param frame  First frame in the section (frame number).
47
 *
47
 *
48
 *  @note         If #frame is not 1MB aligned, first lower 1MB aligned frame will be used.
48
 *  @note         If #frame is not 1MB aligned, first lower 1MB aligned frame will be used.
49
 */  
49
 */  
50
static void init_pte_level0_section(pte_level0_section_t* pte, unsigned frame)
50
static void init_pte_level0_section(pte_level0_section_t* pte, unsigned int frame)
51
{
51
{
52
    pte->descriptor_type   = PTE_DESCRIPTOR_SECTION;
52
    pte->descriptor_type   = PTE_DESCRIPTOR_SECTION;
53
    pte->bufferable        = 0;
53
    pte->bufferable        = 0;
54
    pte->cacheable         = 0;
54
    pte->cacheable         = 0;
55
    pte->impl_specific     = 0;
55
    pte->impl_specific     = 0;
56
    pte->domain            = 0;
56
    pte->domain            = 0;
57
    pte->should_be_zero_1  = 0;
57
    pte->should_be_zero_1  = 0;
58
    pte->access_permission = PTE_AP_USER_NO_KERNEL_RW; 
58
    pte->access_permission = PTE_AP_USER_NO_KERNEL_RW; 
59
    pte->should_be_zero_2  = 0;
59
    pte->should_be_zero_2  = 0;
60
    pte->section_base_addr = (frame << FRAME_WIDTH) >> 20;
60
    pte->section_base_addr = frame;
61
}
61
}
62
 
62
 
63
 
63
 
64
/** Initializes page table used while booting the kernel. */
64
/** Initializes page table used while booting the kernel. */
65
static void init_page_table(void)
65
static void init_page_table(void)
66
{
66
{
67
    int i;
67
    int i;
68
    const unsigned int first_kernel_section = ADDR2PFN(PA2KA(0)) / FRAMES_PER_SECTION;
68
    const unsigned int first_kernel_page = ADDR2PFN(PA2KA(0));
69
 
69
 
70
    // create 1:1 virtual-physical mapping (in lower 2GB)
70
    // create 1:1 virtual-physical mapping (in lower 2GB)
71
    for (i = 0; i < first_kernel_section; i++) {
71
    for (i = 0; i < first_kernel_page; i++) {
72
        init_pte_level0_section(&page_table[i], i * FRAMES_PER_SECTION);
72
        init_pte_level0_section(&page_table[i], i);
73
    }
73
    }
74
 
74
 
75
    // create 1:1 virtual-physical mapping in kernel space (upper 2GB),
75
    // create 1:1 virtual-physical mapping in kernel space (upper 2GB),
76
    // physical addresses start from 0
76
    // physical addresses start from 0
77
    for (i = first_kernel_section; i < PTL0_ENTRIES; i++) {
77
    for (i = first_kernel_page; i < PTL0_ENTRIES; i++) {
78
        init_pte_level0_section(&page_table[i], (i - first_kernel_section) * FRAMES_PER_SECTION);
78
        init_pte_level0_section(&page_table[i], i - first_kernel_page);
79
    }
79
    }
80
}
80
}
81
 
81
 
82
 
82
 
83
/** Starts the MMU - initializes page table and enables paging.
83
/** Starts the MMU - initializes page table and enables paging.