What is the task of pmap_enter ?

Mario Hoerich lists at MHoerich.de
Mon Jan 10 09:15:33 PST 2005


# Romil Shah:
>    I am working on 2200S RAID controller and using aac driver from RELEGN4 ,
> aac_disk.c in the driver uses pmap_enter for coping the virtual pages to
> some physical location.

Not really copying (afaict) but rather assigning a physical address
to a virtual one. 

> In FreeBSD 4.10 pmap_kenter_temporary is used which
> return the address which is passed to the controller for dumping on kernel
> panic where as this is not happening with pmap_enter , can any one tell me
> the difference between pmap_enter and pmap_kenter_temporary  (both  this
> file are present in i386/pmap.c.

Caveat emptor: I'm no kernel hacker and thus not overly familiar
with the internal workings. So buy my explanation at your own risk.;)

pmap_kenter_temporary() *temporarily* maps a physical address
to a virtual one, which is then returned. No change in the
page table, no state-keeping whatsoever.

In contrast, pmap_enter() creates persistent mappings (or
alters existing ones) and changes the page table of the
process to include them. That's why it doesn't need
to return an address.

Quoting the daemon book [McKusick et al,1999]:
|    On the HP300, pmap_enter() takes the following actions:
|
|    1. If no page-table exists for the process, a 4-MByte range is
|    allocated in the kernel's address space to map the process's
|    address space.
|
|    2. If the process has no segment table of its own[...], a private
|    one is allocated
|
|    3. If a physical page has not yet been allocated to the process
|    page-table at the location required for the new mapping, that is
|    done now. Kernel page-table pages are acquired from the reserved
|    pool allocated at bootstrap time.[...]For either kernel or user
|    pagetable pages, the kernel mapping for the new page is flagged
|    as being a pagetable page, and the physical address of the page
|    is recorded in the segment table.

Afterwards, once existance of the entered mapping is ensured, it may
change either the protection or wiring attributes (iff the exact same
mapping already exists) or replace an older mapping referencing the
same virtual address (but a different physical one). In the latter
case, it creates a pv_table entry (iff physical address is in range
of the respective pmap module) and creates a page-table entry.

pmap_entry() has probably changed a little since 4.4BSD, but I
think the above steps have pretty much stayed the same (modulo
some architectural necessities). 

HTH,
Mario

[McKusick et al, 1999]: 
McKusick, Bostic, Karels, Quarterman
"The design and implementation of the 4.4BSD operating system",
Addison Wesley, ISBN 0-201-54979-4
-- 


More information about the freebsd-questions mailing list