Ignore:
Timestamp:
Jun 23, 2017, 11:55:08 AM (7 years ago)
Author:
max@…
Message:

Add some code for LAPIC; far from complete, but a good start.

File:
1 edited

Legend:

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

    r44 r45  
    6565}
    6666
     67/*
     68 * Reset the bootstrap VA we've used in cluster0 so far. After this
     69 * function, cluster0's heap is empty.
     70 */
     71void hal_gpt_bootstrap_reset()
     72{
     73        size_t npages = (va_avail - CLUSTER_HEAP_MIN_VA(0)) / PAGE_SIZE;
     74        hal_gpt_leave_range(CLUSTER_HEAP_MIN_VA(0), npages);
     75}
     76
     77
    6778void hal_gpt_enter(vaddr_t va, paddr_t pa)
    6879{
    69         XASSERT((va % PAGE_SIZE == 0));
    70         XASSERT((pa % PAGE_SIZE == 0));
     80        XASSERT(va % PAGE_SIZE == 0);
     81        XASSERT(pa % PAGE_SIZE == 0);
     82        XASSERT(va == tmpva || PTE_BASE[pl1_i(va)] == 0);
    7183        PTE_BASE[pl1_i(va)] = (pa & PG_FRAME) | PG_V | PG_KW | PG_NX;
    7284}
     
    7789        for (i = 0; i < n; i++) {
    7890                hal_gpt_enter(va + i * PAGE_SIZE, pa + i * PAGE_SIZE);
     91                invlpg(va + i * PAGE_SIZE);
     92        }
     93}
     94
     95void hal_gpt_leave(vaddr_t va)
     96{
     97        XASSERT(va % PAGE_SIZE == 0);
     98        XASSERT(PTE_BASE[pl1_i(va)] != 0);
     99        PTE_BASE[pl1_i(va)] = 0;
     100}
     101
     102void hal_gpt_leave_range(vaddr_t va, size_t n)
     103{
     104        size_t i;
     105        for (i = 0; i < n; i++) {
     106                hal_gpt_leave(va + i * PAGE_SIZE);
    79107                invlpg(va + i * PAGE_SIZE);
    80108        }
Note: See TracChangeset for help on using the changeset viewer.