Subject: Re: Is uvm_km_valloc() in cpu_setup() possible?
To: Alexander Funcke <funcke@daemon.se>
From: Gregory McGarry <g.mcgarry@ieee.org>
List: tech-kern
Date: 04/24/2002 10:02:58
Alexander Funcke wrote:
> In the cpu_setup for the CPU (National Geode SCx200) want to map a few Kb at
> 0x4000000 in physical memory till virtual kernel memory.
>
> How shall go about?
>
> I tried to alloc kernel memory adresses through uvm_km_valloc() but I only get
> pagefaults.
This snippet is from the sommerfeld_i386mp_1 branch:
/*
* Map a chunk of memory read-only and return an appropraitely
* const'ed pointer.
*/
static const void *
mpbios_map (pa, len, handle)
paddr_t pa;
int len;
struct mp_map *handle;
{
paddr_t pgpa = i386_trunc_page(pa);
paddr_t endpa = i386_round_page(pa + len);
vaddr_t va = uvm_km_valloc(kernel_map, endpa - pgpa);
vaddr_t retva = va + (pa & PGOFSET);
handle->pa = pa;
handle->pg = pgpa;
handle->psize = len;
handle->baseva = va;
handle->vsize = endpa-pgpa;
do {
pmap_kenter_pa (va, pgpa, VM_PROT_READ);
va += NBPG;
pgpa += NBPG;
} while (pgpa < endpa);
return (const void *)retva;
}
inline static void
mpbios_unmap (handle)
struct mp_map *handle;
{
pmap_kremove (handle->baseva, handle->vsize);
uvm_km_free (kernel_map, handle->baseva, handle->vsize);
}
-- Gregory McGarry <g.mcgarry@ieee.org>