summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjake <jake@FreeBSD.org>2002-02-23 03:36:04 +0000
committerjake <jake@FreeBSD.org>2002-02-23 03:36:04 +0000
commit3088b53a9a745aca8d9a6e06ac6c7e7f879bd62c (patch)
treea36341e981f23ee93346efb557545ccfdafdc9ec
parentcd8694ee322192ad8cb60298a6a639d3c2ce60a4 (diff)
downloadFreeBSD-src-3088b53a9a745aca8d9a6e06ac6c7e7f879bd62c.zip
FreeBSD-src-3088b53a9a745aca8d9a6e06ac6c7e7f879bd62c.tar.gz
Add OF_claim_virt() and OF_release_phys().
Submitted by: tmm
-rw-r--r--sys/boot/ofw/libofw/openfirm.c70
-rw-r--r--sys/boot/ofw/libofw/openfirm.h2
2 files changed, 72 insertions, 0 deletions
diff --git a/sys/boot/ofw/libofw/openfirm.c b/sys/boot/ofw/libofw/openfirm.c
index 3970d95..bb2dd20 100644
--- a/sys/boot/ofw/libofw/openfirm.c
+++ b/sys/boot/ofw/libofw/openfirm.c
@@ -706,6 +706,45 @@ OF_claim(void *virt, u_int size, u_int align)
}
/* 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.
*/
diff --git a/sys/boot/ofw/libofw/openfirm.h b/sys/boot/ofw/libofw/openfirm.h
index 90e9d9e..86c39b0 100644
--- a/sys/boot/ofw/libofw/openfirm.h
+++ b/sys/boot/ofw/libofw/openfirm.h
@@ -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 *);
OpenPOWER on IntegriCloud