Add OF_claim_virt() and OF_release_phys().

Submitted by:	tmm
This commit is contained in:
Jake Burkholder 2002-02-23 03:36:04 +00:00
parent 4f265afbc1
commit acfdfd647b
2 changed files with 72 additions and 0 deletions

View File

@ -705,6 +705,45 @@ OF_claim(void *virt, u_int size, u_int align)
return (void *)args.baseaddr;
}
/* Allocate an area of physical memory */
vm_offset_t
OF_claim_virt(vm_offset_t virt, size_t size, int align)
{
static struct {
cell_t name;
cell_t nargs;
cell_t nret;
cell_t method;
cell_t ihandle;
cell_t align;
cell_t size;
cell_t virt;
cell_t status;
cell_t ret;
} args = {
(cell_t)"call-method",
5,
2,
(cell_t)"claim",
0,
0,
0,
0,
0, /* ret */
0,
};
args.ihandle = mmu;
args.align = align;
args.size = size;
args.virt = virt;
if (openfirmware(&args) == -1)
return (vm_offset_t)-1;
return (vm_offset_t)args.ret;
}
/* Allocate an area of physical memory */
void *
OF_alloc_phys(size_t size, int align)
@ -766,6 +805,37 @@ OF_release(void *virt, u_int size)
openfirmware(&args);
}
/* Release an area of physical memory. */
void
OF_release_phys(vm_offset_t phys, u_int size)
{
static struct {
cell_t name;
cell_t nargs;
cell_t nret;
cell_t method;
cell_t ihandle;
cell_t size;
cell_t phys_hi;
cell_t phys_lo;
} args = {
(cell_t)"call-method",
5,
0,
(cell_t)"release",
0,
0,
0,
0
};
args.ihandle = memory;
args.phys_hi = (u_int32_t)(phys >> 32);
args.phys_lo = (u_int32_t)phys;
args.size = size;
openfirmware(&args);
}
/*
* Control transfer functions.
*/

View File

@ -105,8 +105,10 @@ int OF_seek(ihandle_t, u_quad_t);
/* Memory functions */
void *OF_claim(void *, u_int, u_int);
vm_offset_t OF_claim_virt(vm_offset_t, size_t, int);
void *OF_alloc_phys(size_t, int);
void OF_release(void *, u_int);
void OF_release_phys(vm_offset_t, u_int);
/* Control transfer functions */
void OF_boot(char *);