Changeset 8f00329 in mainline


Ignore:
Timestamp:
2006-02-09T21:59:31Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a3eeceb6
Parents:
bfb87df
Message:

Add page_mapping_remove().

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • genarch/src/mm/page_ht.c

    rbfb87df r8f00329  
    4848
    4949static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags);
     50static void ht_mapping_remove(as_t *as, __address page);
    5051static pte_t *ht_mapping_find(as_t *as, __address page);
    5152
     
    7172page_mapping_operations_t ht_mapping_operations = {
    7273        .mapping_insert = ht_mapping_insert,
     74        .mapping_remove = ht_mapping_remove,
    7375        .mapping_find = ht_mapping_find
    7476};
     
    163165{
    164166        pte_t *t;
    165         ipl_t ipl;
    166167        __native key[2] = { (__address) as, page };
    167168       
    168         ipl = interrupts_disable();
    169169        spinlock_lock(&page_ht_lock);
    170170
     
    177177       
    178178        spinlock_unlock(&page_ht_lock);
    179         interrupts_restore(ipl);
    180 }
     179}
     180
     181/** Remove mapping of page from page hash table.
     182 *
     183 * Remove any mapping of 'page' within address space 'as'.
     184 * TLB shootdown should follow in order to make effects of
     185 * this call visible.
     186 *
     187 * The address space must be locked and interrupts must be disabled.
     188 *
     189 * @param as Address space to wich page belongs.
     190 * @param page Virtual address of the page to be demapped.
     191 */
     192void ht_mapping_remove(as_t *as, __address page)
     193{
     194        __native key[2] = { (__address) as, page };
     195       
     196        spinlock_lock(&page_ht_lock);
     197
     198        /*
     199         * Note that removed PTE's will be freed
     200         * by remove_callback().
     201         */
     202        hash_table_remove(&page_ht, key, 2);
     203
     204        spinlock_unlock(&page_ht_lock);
     205}
     206
    181207
    182208/** Find mapping for virtual page in page hash table.
  • genarch/src/mm/page_pt.c

    rbfb87df r8f00329  
    3939
    4040static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags);
     41static void pt_mapping_remove(as_t *as, __address page);
    4142static pte_t *pt_mapping_find(as_t *as, __address page);
    4243
    4344page_mapping_operations_t pt_mapping_operations = {
    4445        .mapping_insert = pt_mapping_insert,
     46        .mapping_remove = pt_mapping_remove,
    4547        .mapping_find = pt_mapping_find
    4648};
     
    9698}
    9799
     100/** Remove mapping of page from hierarchical page tables.
     101 *
     102 * Remove any mapping of 'page' within address space 'as'.
     103 * TLB shootdown should follow in order to make effects of
     104 * this call visible.
     105 *
     106 * The address space must be locked and interrupts must be disabled.
     107 *
     108 * @param as Address space to wich page belongs.
     109 * @param page Virtual address of the page to be demapped.
     110 */
     111void pt_mapping_remove(as_t *as, __address page)
     112{
     113        pte_t *ptl0, *ptl1, *ptl2, *ptl3;
     114
     115        ptl0 = (pte_t *) PA2KA((__address) as->page_table);
     116
     117        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
     118                return;
     119
     120        ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
     121
     122        if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
     123                return;
     124
     125        ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
     126
     127        if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
     128                return;
     129
     130        ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
     131
     132        /* Destroy the mapping. Setting to PAGE_NOT_PRESENT is not sufficient. */
     133        memsetb((__address) &ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0);
     134}
     135
    98136/** Find mapping for virtual page in hierarchical page tables.
    99137 *
  • generic/include/mm/page.h

    rbfb87df r8f00329  
    6363struct page_mapping_operations {
    6464        void (* mapping_insert)(as_t *as, __address page, __address frame, int flags);
     65        void (* mapping_remove)(as_t *as, __address page);
    6566        pte_t *(* mapping_find)(as_t *as, __address page);
    6667};
     
    7172extern void page_init(void);
    7273extern void page_mapping_insert(as_t *as, __address page, __address frame, int flags);
     74extern void page_mapping_remove(as_t *as, __address page);
    7375extern pte_t *page_mapping_find(as_t *as, __address page);
    7476extern pte_t *page_table_create(int flags);
  • generic/src/mm/page.c

    rbfb87df r8f00329  
    7272}
    7373
    74 /** Map page to frame
     74/** Insert mapping of page to frame.
    7575 *
    7676 * Map virtual address 'page' to physical address 'frame'
     
    7979 * The address space must be locked and interrupts must be disabled.
    8080 *
    81  * @param as Address space to wich page belongs..
     81 * @param as Address space to wich page belongs.
    8282 * @param page Virtual address of the page to be mapped.
    8383 * @param frame Physical address of memory frame to which the mapping is done.
     
    9090       
    9191        page_mapping_operations->mapping_insert(as, page, frame, flags);
     92}
     93
     94/** Remove mapping of page.
     95 *
     96 * Remove any mapping of 'page' within address space 'as'.
     97 * TLB shootdown should follow in order to make effects of
     98 * this call visible.
     99 *
     100 * The address space must be locked and interrupts must be disabled.
     101 *
     102 * @param as Address space to wich page belongs.
     103 * @param page Virtual address of the page to be demapped.
     104 */
     105void page_mapping_remove(as_t *as, __address page)
     106{
     107        ASSERT(page_mapping_operations);
     108        ASSERT(page_mapping_operations->mapping_remove);
     109       
     110        page_mapping_operations->mapping_remove(as, page);
    92111}
    93112
Note: See TracChangeset for help on using the changeset viewer.