Ignore:
Timestamp:
Jun 30, 2017, 5:18:13 PM (7 years ago)
Author:
max@…
Message:

complete hal_ppm_init, to take into account the reserved areas

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/hal_gpt.c

    r114 r116  
    7171void hal_gpt_bootstrap_reset()
    7272{
    73 //      XXX: will be revisited later
    74 //      size_t npages = (va_avail - (CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE)) / PAGE_SIZE;
    75 //      hal_gpt_leave_range(CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE, npages);
    76 //      va_avail = CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE;
     73        size_t npages = (va_avail - (CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE)) / PAGE_SIZE;
     74        hal_gpt_leave_range(CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE, npages);
     75        va_avail = CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE;
     76}
     77
     78/*
     79 * Uniformize the PA and VA offsets, and return the value. After this function,
     80 * we are guaranteed to have [VA = PA + constant_offset]. And therefore we can
     81 * only call hal_gpt_bootstrap_valloc, without entering it in a PA.
     82 */
     83size_t hal_gpt_bootstrap_uniformize()
     84{
     85        size_t pa_offset = pa_avail - 0;
     86        size_t va_offset = va_avail - CLUSTER_MIN_VA(0);
     87
     88        if (pa_offset < va_offset)
     89                pa_avail += (va_offset - pa_offset);
     90        else if (pa_offset > va_offset)
     91                va_avail += (pa_offset - va_offset);
     92
     93        return MAX(pa_offset, va_offset);
    7794}
    7895
     
    8198        XASSERT(va % PAGE_SIZE == 0);
    8299        XASSERT(pa % PAGE_SIZE == 0);
    83         XASSERT(va == tmpva || PTE_BASE[pl1_i(va)] == 0);
     100        //XASSERT(va == tmpva || PTE_BASE[pl1_i(va)] == 0);
    84101        PTE_BASE[pl1_i(va)] = (pa & PG_FRAME) | flags;
    85102        invlpg(va);
     
    223240
    224241        /* Manually enter cluster0's heap */
    225 /*
    226242        hal_gpt_enter_range(CLUSTER_MIN_VA(0) + kimg_size, kimg_max_pa,
    227243            (CLUSTER_VA_SIZE - kimg_size) / PAGE_SIZE);
    228 */
    229244}
    230245
Note: See TracChangeset for help on using the changeset viewer.