summaryrefslogtreecommitdiffstats
path: root/sys/boot/ofw
diff options
context:
space:
mode:
Diffstat (limited to 'sys/boot/ofw')
-rw-r--r--sys/boot/ofw/common/main.c12
-rw-r--r--sys/boot/ofw/libofw/Makefile2
-rw-r--r--sys/boot/ofw/libofw/ofw_console.c5
-rw-r--r--sys/boot/ofw/libofw/ofw_net.c3
-rw-r--r--sys/boot/ofw/libofw/openfirm.c123
-rw-r--r--sys/boot/ofw/libofw/openfirm.h11
-rw-r--r--sys/boot/ofw/libofw/openfirm_mmu.c143
7 files changed, 18 insertions, 281 deletions
diff --git a/sys/boot/ofw/common/main.c b/sys/boot/ofw/common/main.c
index 2a6dd1c..1a03e9b 100644
--- a/sys/boot/ofw/common/main.c
+++ b/sys/boot/ofw/common/main.c
@@ -41,7 +41,6 @@ extern char bootprog_rev[];
extern char bootprog_date[];
extern char bootprog_maker[];
-phandle_t chosen;
u_int32_t acells;
static char bootargs[128];
@@ -64,24 +63,22 @@ init_heap(void)
uint64_t
memsize(void)
{
- ihandle_t meminstance;
- phandle_t memory;
+ phandle_t memoryp;
struct ofw_reg reg[4];
struct ofw_reg2 reg2[8];
int i;
u_int64_t sz, memsz;
- OF_getprop(chosen, "memory", &meminstance, sizeof(meminstance));
- memory = OF_instance_to_package(meminstance);
+ memoryp = OF_instance_to_package(memory);
if (acells == 1) {
- sz = OF_getprop(memory, "reg", &reg, sizeof(reg));
+ sz = OF_getprop(memoryp, "reg", &reg, sizeof(reg));
sz /= sizeof(struct ofw_reg);
for (i = 0, memsz = 0; i < sz; i++)
memsz += reg[i].size;
} else if (acells == 2) {
- sz = OF_getprop(memory, "reg", &reg2, sizeof(reg2));
+ sz = OF_getprop(memoryp, "reg", &reg2, sizeof(reg2));
sz /= sizeof(struct ofw_reg2);
for (i = 0, memsz = 0; i < sz; i++)
@@ -107,7 +104,6 @@ main(int (*openfirm)(void *))
OF_init(openfirm);
root = OF_finddevice("/");
- chosen = OF_finddevice("/chosen");
acells = 1;
OF_getprop(root, "#address-cells", &acells, sizeof(acells));
diff --git a/sys/boot/ofw/libofw/Makefile b/sys/boot/ofw/libofw/Makefile
index 493a1cb..8a56a77 100644
--- a/sys/boot/ofw/libofw/Makefile
+++ b/sys/boot/ofw/libofw/Makefile
@@ -5,7 +5,7 @@ INTERNALLIB=
SRCS= devicename.c elf_freebsd.c ofw_console.c ofw_copy.c ofw_disk.c \
ofw_memory.c ofw_module.c ofw_net.c ofw_reboot.c \
- ofw_time.c openfirm.c openfirm_mmu.c
+ ofw_time.c openfirm.c
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
diff --git a/sys/boot/ofw/libofw/ofw_console.c b/sys/boot/ofw/libofw/ofw_console.c
index 6cb8b03..796ac97 100644
--- a/sys/boot/ofw/libofw/ofw_console.c
+++ b/sys/boot/ofw/libofw/ofw_console.c
@@ -34,8 +34,6 @@ __FBSDID("$FreeBSD$");
#include "bootstrap.h"
#include "openfirm.h"
-int console;
-
static void ofw_cons_probe(struct console *cp);
static int ofw_cons_init(int);
void ofw_cons_putchar(int);
@@ -59,10 +57,7 @@ struct console ofwconsole = {
static void
ofw_cons_probe(struct console *cp)
{
- phandle_t chosen;
- if ((chosen = OF_finddevice("/chosen")) == -1)
- OF_exit();
OF_getprop(chosen, "stdin", &stdin, sizeof(stdin));
OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
diff --git a/sys/boot/ofw/libofw/ofw_net.c b/sys/boot/ofw/libofw/ofw_net.c
index 5149df9..17e1125 100644
--- a/sys/boot/ofw/libofw/ofw_net.c
+++ b/sys/boot/ofw/libofw/ofw_net.c
@@ -179,12 +179,11 @@ extern char *strchr();
static void
ofwn_init(struct iodesc *desc, void *machdep_hint)
{
- phandle_t chosen, netdev;
+ phandle_t netdev;
char path[64];
char *ch;
int pathlen;
- chosen = OF_finddevice("/chosen");
pathlen = OF_getprop(chosen, "bootpath", path, 64);
if ((ch = index(path, ':')) != NULL)
*ch = '\0';
diff --git a/sys/boot/ofw/libofw/openfirm.c b/sys/boot/ofw/libofw/openfirm.c
index 97477dd..8786d5d 100644
--- a/sys/boot/ofw/libofw/openfirm.c
+++ b/sys/boot/ofw/libofw/openfirm.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
int (*openfirmware)(void *);
+phandle_t chosen;
ihandle_t mmu;
ihandle_t memory;
@@ -74,30 +75,15 @@ ihandle_t memory;
void
OF_init(int (*openfirm)(void *))
{
- phandle_t chosen;
openfirmware = openfirm;
- chosen = OF_finddevice("/chosen");
- OF_getprop(chosen, "memory", &memory, sizeof(memory));
- if (memory == 0)
- panic("failed to get memory ihandle");
- OF_getprop(chosen, "mmu", &mmu, sizeof(mmu));
- if (mmu == 0)
- panic("failed to get mmu ihandle");
-}
-
-phandle_t
-OF_chosennode(void)
-{
- static phandle_t chosen;
-
- if (chosen)
- return (chosen);
-
if ((chosen = OF_finddevice("/chosen")) == -1)
OF_exit();
- return (chosen);
+ if (OF_getprop(chosen, "memory", &memory, sizeof(memory)) == -1)
+ OF_exit();
+ if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1)
+ OF_exit();
}
/*
@@ -461,7 +447,8 @@ OF_call_method(char *method, ihandle_t instance, int nargs, int nreturns, ...)
2,
1,
};
- int *ip, n;
+ cell_t *cp;
+ int n;
if (nargs > 6)
return (-1);
@@ -470,15 +457,15 @@ OF_call_method(char *method, ihandle_t instance, int nargs, int nreturns, ...)
args.method = (cell_t)method;
args.instance = instance;
va_start(ap, nreturns);
- for (ip = (int *)(args.args_n_results + (n = nargs)); --n >= 0;)
- *--ip = va_arg(ap, int);
+ for (cp = (cell_t *)(args.args_n_results + (n = nargs)); --n >= 0;)
+ *--cp = va_arg(ap, cell_t);
if (openfirmware(&args) == -1)
return (-1);
if (args.args_n_results[nargs])
return (args.args_n_results[nargs]);
- for (ip = (int *)(args.args_n_results + nargs + (n = args.nreturns));
+ for (cp = (cell_t *)(args.args_n_results + nargs + (n = args.nreturns));
--n > 0;)
- *va_arg(ap, int *) = *--ip;
+ *va_arg(ap, cell_t *) = *--cp;
va_end(ap);
return (0);
}
@@ -648,67 +635,6 @@ 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",
- };
-
- args.ihandle = mmu;
- args.align = align;
- args.size = size;
- args.virt = (cell_t)virt;
- if (openfirmware(&args) == -1)
- return (-1);
- return (args.ret);
-}
-
-/* Allocate an area of physical memory */
-void *
-OF_alloc_phys(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 status;
- cell_t phys_hi;
- cell_t phys_low;
- } args = {
- (cell_t)"call-method",
- 4,
- 3,
- (cell_t)"claim",
- };
-
- args.ihandle = memory;
- args.size = size;
- args.align = align;
- if (openfirmware(&args) == -1)
- return ((void *)-1);
- return ((void *)(args.phys_hi << 32 | args.phys_low));
-}
-
/* Release an area of memory. */
void
OF_release(void *virt, u_int size)
@@ -729,33 +655,6 @@ 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",
- };
-
- args.ihandle = memory;
- args.phys_hi = phys >> 32;
- args.phys_lo = 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 a0e9c65..6c7ffb2 100644
--- a/sys/boot/ofw/libofw/openfirm.h
+++ b/sys/boot/ofw/libofw/openfirm.h
@@ -106,10 +106,7 @@ 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 *);
@@ -117,13 +114,7 @@ void OF_enter(void);
void OF_exit(void) __attribute__((noreturn));
void OF_chain(void *, u_int, void (*)(), void *, u_int);
-#if 0
-/* User interface functions */
-/* OF_interpret */
-void *OF_set_callback(void *);
-void OF_set_symbol_lookup(void *, void *);
-#endif
-
/* Time function */
int OF_milliseconds(void);
+
#endif /* _OPENFIRM_H_ */
diff --git a/sys/boot/ofw/libofw/openfirm_mmu.c b/sys/boot/ofw/libofw/openfirm_mmu.c
deleted file mode 100644
index c92baa0..0000000
--- a/sys/boot/ofw/libofw/openfirm_mmu.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2006 Kip Macy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <machine/stdarg.h>
-#include <stand.h>
-
-#include "openfirm.h"
-
-static ihandle_t
-OF_mmu_ihandle(void)
-{
- static ihandle_t immu;
-
- if (immu != (ihandle_t)0)
- return (immu);
-
- if (OF_getproplen(OF_chosennode(), "mmu") != sizeof (ihandle_t))
- return (immu = (ihandle_t)-1);
-
- (void) OF_getprop(OF_chosennode(), "mmu", (caddr_t)(&immu), sizeof immu);
- return (immu);
-}
-
-
-int
-OF_translate_virt(vm_offset_t va, int *valid, vm_paddr_t *physaddr, int *mode)
-{
- int rv;
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t method;
- cell_t immu;
- cell_t va;
- cell_t result;
- cell_t valid;
- cell_t mode;
- cell_t phys_hi;
- cell_t phys_lo;
- } args = {
- (cell_t)"call-method",
- 3,
- 5,
- (cell_t)"translate",
- };
-
- args.immu = (cell_t) OF_mmu_ihandle();
- args.result = 0;
- args.valid = 0;
- args.mode = 0;
- rv = openfirmware(&args);
- if (rv == -1)
- return (-1);
- if (args.result != 0)
- return (-1);
-
- *valid = args.valid;
- *mode = args.mode;
- *physaddr = (vm_paddr_t)(args.phys_hi << 32 | args.phys_lo);
-
- return (0);
-}
-
-vm_paddr_t
-OF_vtophys(vm_offset_t va)
-{
- int mode, valid, error;
- vm_paddr_t physaddr;
-
- error = OF_translate_virt(va, &valid, &physaddr, &mode);
-
- if (error == 0 && valid == -1)
- return physaddr;
-
- return (0);
-}
-
-int
-OF_map_phys(int mode, size_t size, vm_offset_t va, uint64_t pa)
-{
- int rv;
-
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t method;
- cell_t immu;
- cell_t mode;
- cell_t size;
- cell_t va;
- cell_t pa_hi;
- cell_t pa_lo;
- cell_t result;
- } args = {
- (cell_t)"call-method",
- 7,
- 1,
- (cell_t)"map",
- };
- args.immu = (cell_t)OF_mmu_ihandle();
- args.mode = (cell_t)mode;
- args.size = (cell_t)size;
- args.va = (cell_t)va;
- args.pa_hi = (cell_t)(pa >> 32);
- args.pa_lo = (cell_t)((uint32_t)pa);
-
- rv = openfirmware(&args);
- if (rv == -1)
- return (-1);
- if (args.result != 0)
- return (-1);
-
- return (0);
-}
OpenPOWER on IntegriCloud