Changeset ff9f858 in mainline for arch/ia32/src/mm/page.c


Ignore:
Timestamp:
2005-06-30T23:27:02Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a03f9
Parents:
992bbb97
Message:

Generic 4-level page tables interface & implementation (review & test).
Implement more architecture dependant macros on IA-32.
Provide fake implementation on IA-64 and MIPS.
Convert map_page_to_frame() to use the new interface.
Move adjusted map_page_to_frame() from IA-32's arch/mm/page.c to the generic mm/page.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/mm/page.c

    r992bbb97 rff9f858  
    8787        paging_on();
    8888}
    89 
    90 /*
    91  * Besides mapping pages to frames, this function also sets the present bit of
    92  * the page's specifier in both page directory and respective page table. If
    93  * the page table for this page has not been allocated so far, it will take
    94  * care of it and allocate the necessary frame.
    95  *
    96  * PAGE_CACHEABLE flag: when set, it turns caches for that page on
    97  * PAGE_NOT_PRESENT flag: when set, it marks the page not present
    98  * PAGE_USER flag: when set, the page is accessible from userspace
    99  *
    100  * When the root parameter is non-zero, it is used as the page directory address.
    101  * Otherwise, the page directory address is read from CPU.
    102  */
    103 void map_page_to_frame(__address page, __address frame, int flags, __address root)
    104 {
    105         struct page_specifier *pd, *pt;
    106         __address dba, newpt;
    107         int pde, pte;
    108 
    109         if (root) dba = root;
    110         else dba = read_cr3();
    111 
    112         pde = page >> 22;               /* page directory entry */
    113         pte = (page >> 12) & 0x3ff;     /* page table entry */
    114        
    115         pd = (struct page_specifier *) PA2KA(dba);
    116        
    117         if (!pd[pde].present) {
    118                 /*
    119                  * There is currently no page table for this address. Allocate
    120                  * frame for the page table and clean it.
    121                  */
    122                 newpt = frame_alloc(FRAME_KA);
    123                 pd[pde].frame_address = KA2PA(newpt) >> 12;
    124                 memsetb(newpt, PAGE_SIZE, 0);
    125                 pd[pde].present = 1;
    126                 pd[pde].uaccessible = 1;
    127         }
    128        
    129         pt = (struct page_specifier *) PA2KA((pd[pde].frame_address << 12));
    130 
    131         pt[pte].frame_address = frame >> 12;
    132         pt[pte].present = !(flags & PAGE_NOT_PRESENT);
    133         pt[pte].page_cache_disable = !(flags & PAGE_CACHEABLE);
    134         pt[pte].uaccessible = (flags & PAGE_USER) != 0;
    135         pt[pte].writeable = (flags & PAGE_WRITE) != 0; 
    136 }
Note: See TracChangeset for help on using the changeset viewer.