summaryrefslogtreecommitdiffstats
path: root/sys/dev/ofw
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2009-06-14 00:05:38 +0000
committermarius <marius@FreeBSD.org>2009-06-14 00:05:38 +0000
commit3961775a2db6be3ae2d269fb4fd4bb0465075f50 (patch)
tree6d55f50ca451267249e8300f0d3fcfa3987f7bd7 /sys/dev/ofw
parent58b8ea457a3c19c4d56dab1375a71b926f674a2a (diff)
downloadFreeBSD-src-3961775a2db6be3ae2d269fb4fd4bb0465075f50.zip
FreeBSD-src-3961775a2db6be3ae2d269fb4fd4bb0465075f50.tar.gz
Fix style.
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r--sys/dev/ofw/ofw_bus_subr.c46
-rw-r--r--sys/dev/ofw/ofw_bus_subr.h20
-rw-r--r--sys/dev/ofw/ofw_disk.c94
-rw-r--r--sys/dev/ofw/ofw_if.m83
-rw-r--r--sys/dev/ofw/ofw_iicbus.c25
-rw-r--r--sys/dev/ofw/ofw_standard.c17
-rw-r--r--sys/dev/ofw/ofwvar.h20
-rw-r--r--sys/dev/ofw/openfirm.c44
-rw-r--r--sys/dev/ofw/openfirm.h18
-rw-r--r--sys/dev/ofw/openfirmio.c9
10 files changed, 193 insertions, 183 deletions
diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c
index 1cc5207..05ce13c 100644
--- a/sys/dev/ofw/ofw_bus_subr.c
+++ b/sys/dev/ofw/ofw_bus_subr.c
@@ -74,10 +74,11 @@ ofw_bus_gen_destroy_devinfo(struct ofw_bus_devinfo *obd)
free(obd->obd_type, M_OFWPROP);
}
-int
+int
ofw_bus_gen_child_pnpinfo_str(device_t cbdev, device_t child, char *buf,
size_t buflen)
{
+
if (ofw_bus_get_name(child) != NULL) {
strlcat(buf, "name=", buflen);
strlcat(buf, ofw_bus_get_name(child), buflen);
@@ -87,7 +88,6 @@ ofw_bus_gen_child_pnpinfo_str(device_t cbdev, device_t child, char *buf,
strlcat(buf, " compat=", buflen);
strlcat(buf, ofw_bus_get_compat(child), buflen);
}
-
return (0);
};
@@ -95,19 +95,19 @@ const char *
ofw_bus_gen_get_compat(device_t bus, device_t dev)
{
const struct ofw_bus_devinfo *obd;
-
- obd = OFW_BUS_GET_DEVINFO(bus, dev);
+
+ obd = OFW_BUS_GET_DEVINFO(bus, dev);
if (obd == NULL)
return (NULL);
return (obd->obd_compat);
}
-
+
const char *
ofw_bus_gen_get_model(device_t bus, device_t dev)
{
const struct ofw_bus_devinfo *obd;
- obd = OFW_BUS_GET_DEVINFO(bus, dev);
+ obd = OFW_BUS_GET_DEVINFO(bus, dev);
if (obd == NULL)
return (NULL);
return (obd->obd_model);
@@ -118,7 +118,7 @@ ofw_bus_gen_get_name(device_t bus, device_t dev)
{
const struct ofw_bus_devinfo *obd;
- obd = OFW_BUS_GET_DEVINFO(bus, dev);
+ obd = OFW_BUS_GET_DEVINFO(bus, dev);
if (obd == NULL)
return (NULL);
return (obd->obd_name);
@@ -129,7 +129,7 @@ ofw_bus_gen_get_node(device_t bus, device_t dev)
{
const struct ofw_bus_devinfo *obd;
- obd = OFW_BUS_GET_DEVINFO(bus, dev);
+ obd = OFW_BUS_GET_DEVINFO(bus, dev);
if (obd == NULL)
return (0);
return (obd->obd_node);
@@ -140,7 +140,7 @@ ofw_bus_gen_get_type(device_t bus, device_t dev)
{
const struct ofw_bus_devinfo *obd;
- obd = OFW_BUS_GET_DEVINFO(bus, dev);
+ obd = OFW_BUS_GET_DEVINFO(bus, dev);
if (obd == NULL)
return (NULL);
return (obd->obd_type);
@@ -162,15 +162,13 @@ ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz)
msksz = OF_getprop_alloc(node, "interrupt-map-mask", 1,
(void **)&ii->opi_imapmsk);
/*
- * Failure to get the mask is ignored; a full mask is used then.
- * Barf on bad mask sizes, however.
+ * Failure to get the mask is ignored; a full mask is used
+ * then. We barf on bad mask sizes, however.
*/
- if (msksz != -1 && msksz != ii->opi_addrc + intrsz) {
+ if (msksz != -1 && msksz != ii->opi_addrc + intrsz)
panic("ofw_bus_setup_iinfo: bad interrupt-map-mask "
"property!");
- }
}
-
}
int
@@ -197,10 +195,10 @@ ofw_bus_lookup_imap(phandle_t node, struct ofw_bus_iinfo *ii, void *reg,
* Map an interrupt using the firmware reg, interrupt-map and
* interrupt-map-mask properties.
* The interrupt property to be mapped must be of size intrsz, and pointed to
- * by intr. The regs property of the node for which the mapping is done must
+ * by intr. The regs property of the node for which the mapping is done must
* be passed as regs. This property is an array of register specifications;
* the size of the address part of such a specification must be passed as
- * physsz. Only the first element of the property is used.
+ * physsz. Only the first element of the property is used.
* imap and imapsz hold the interrupt mask and it's size.
* imapmsk is a pointer to the interrupt-map-mask property, which must have
* a size of physsz + intrsz; it may be NULL, in which case a full mask is
@@ -216,11 +214,11 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
int rintrsz)
{
phandle_t parent;
- u_int8_t *ref = maskbuf;
- u_int8_t *uiintr = intr;
- u_int8_t *uiregs = regs;
- u_int8_t *uiimapmsk = imapmsk;
- u_int8_t *mptr;
+ uint8_t *ref = maskbuf;
+ uint8_t *uiintr = intr;
+ uint8_t *uiregs = regs;
+ uint8_t *uiimapmsk = imapmsk;
+ uint8_t *mptr;
pcell_t pintrsz;
int i, rsz, tsz;
@@ -244,13 +242,13 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
pintrsz = 1; /* default */
pintrsz *= sizeof(pcell_t);
- /* Compute the map stride size */
+ /* Compute the map stride size. */
tsz = physsz + intrsz + sizeof(phandle_t) + pintrsz;
KASSERT(i >= tsz, ("ofw_bus_search_intrmap: truncated map"));
-
+
/*
* XXX: Apple hardware uses a second cell to set information
- * on the interrupt trigger type. This information should
+ * on the interrupt trigger type. This information should
* be used somewhere to program the PIC.
*/
diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h
index 58dd587..14bcbc9 100644
--- a/sys/dev/ofw/ofw_bus_subr.h
+++ b/sys/dev/ofw/ofw_bus_subr.h
@@ -41,30 +41,30 @@
#define ORIR_NOTFOUND 0xffffffff
struct ofw_bus_iinfo {
- u_int8_t *opi_imap;
- u_int8_t *opi_imapmsk;
+ uint8_t *opi_imap;
+ uint8_t *opi_imapmsk;
int opi_imapsz;
pcell_t opi_addrc;
};
+/* Generic implementation of ofw_bus_if.m methods and helper routines */
int ofw_bus_gen_setup_devinfo(struct ofw_bus_devinfo *, phandle_t);
void ofw_bus_gen_destroy_devinfo(struct ofw_bus_devinfo *);
+ofw_bus_get_compat_t ofw_bus_gen_get_compat;
+ofw_bus_get_model_t ofw_bus_gen_get_model;
+ofw_bus_get_name_t ofw_bus_gen_get_name;
+ofw_bus_get_node_t ofw_bus_gen_get_node;
+ofw_bus_get_type_t ofw_bus_gen_get_type;
+
/* Helper method to report interesting OF properties in pnpinfo */
-int ofw_bus_gen_child_pnpinfo_str(device_t, device_t, char *, size_t);
+bus_child_pnpinfo_str_t ofw_bus_gen_child_pnpinfo_str;
/* Routines for processing firmware interrupt maps */
-
void ofw_bus_setup_iinfo(phandle_t, struct ofw_bus_iinfo *, int);
int ofw_bus_lookup_imap(phandle_t, struct ofw_bus_iinfo *, void *, int,
void *, int, void *, int, void *);
int ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *,
void *, void *, int);
-ofw_bus_get_compat_t ofw_bus_gen_get_compat;
-ofw_bus_get_model_t ofw_bus_gen_get_model;
-ofw_bus_get_name_t ofw_bus_gen_get_name;
-ofw_bus_get_node_t ofw_bus_gen_get_node;
-ofw_bus_get_type_t ofw_bus_gen_get_type;
-
#endif /* !_DEV_OFW_OFW_BUS_SUBR_H_ */
diff --git a/sys/dev/ofw/ofw_disk.c b/sys/dev/ofw/ofw_disk.c
index d20cbc3..66155d3 100644
--- a/sys/dev/ofw/ofw_disk.c
+++ b/sys/dev/ofw/ofw_disk.c
@@ -47,16 +47,16 @@ __FBSDID("$FreeBSD$");
struct ofwd_softc
{
- struct bio_queue_head ofwd_bio_queue;
- struct mtx ofwd_queue_mtx;
+ struct bio_queue_head ofwd_bio_queue;
+ struct mtx ofwd_queue_mtx;
ihandle_t ofwd_instance;
off_t ofwd_mediasize;
- unsigned ofwd_sectorsize;
- unsigned ofwd_fwheads;
- unsigned ofwd_fwsectors;
- struct proc *ofwd_procp;
- struct g_geom *ofwd_gp;
- struct g_provider *ofwd_pp;
+ unsigned ofwd_sectorsize;
+ unsigned ofwd_fwheads;
+ unsigned ofwd_fwsectors;
+ struct proc *ofwd_procp;
+ struct g_geom *ofwd_gp;
+ struct g_provider *ofwd_pp;
} ofwd_softc;
static g_init_t g_ofwd_init;
@@ -83,21 +83,21 @@ ofwd_startio(struct ofwd_softc *sc, struct bio *bp)
r = OF_seek(sc->ofwd_instance, bp->bio_offset);
- switch (bp->bio_cmd) {
- case BIO_READ:
+ switch (bp->bio_cmd) {
+ case BIO_READ:
r = OF_read(sc->ofwd_instance, (void *)bp->bio_data,
- bp->bio_length);
- break;
- case BIO_WRITE:
+ bp->bio_length);
+ break;
+ case BIO_WRITE:
r = OF_write(sc->ofwd_instance, (void *)bp->bio_data,
- bp->bio_length);
- break;
- }
+ bp->bio_length);
+ break;
+ }
if (r != bp->bio_length)
panic("ofwd: incorrect i/o count");
- bp->bio_resid = 0;
- return (0);
+ bp->bio_resid = 0;
+ return (0);
}
static void
@@ -107,41 +107,41 @@ ofwd_kthread(void *arg)
struct bio *bp;
int error;
- sc = arg;
- curthread->td_base_pri = PRIBIO;
+ sc = arg;
+ curthread->td_base_pri = PRIBIO;
- for (;;) {
+ for (;;) {
mtx_lock(&sc->ofwd_queue_mtx);
bp = bioq_takefirst(&sc->ofwd_bio_queue);
if (!bp) {
msleep(sc, &sc->ofwd_queue_mtx, PRIBIO | PDROP,
"ofwdwait", 0);
- continue;
+ continue;
}
- mtx_unlock(&sc->ofwd_queue_mtx);
- if (bp->bio_cmd == BIO_GETATTR) {
+ mtx_unlock(&sc->ofwd_queue_mtx);
+ if (bp->bio_cmd == BIO_GETATTR) {
error = EOPNOTSUPP;
- } else
+ } else
error = ofwd_startio(sc, bp);
if (error != -1) {
- bp->bio_completed = bp->bio_length;
- g_io_deliver(bp, error);
- }
+ bp->bio_completed = bp->bio_length;
+ g_io_deliver(bp, error);
+ }
}
}
static void
g_ofwd_init(struct g_class *mp __unused)
{
- struct ofwd_softc *sc;
- struct g_geom *gp;
- struct g_provider *pp;
- char path[128];
- char fname[32];
+ char path[128];
+ char fname[32];
phandle_t ofd;
+ struct ofwd_softc *sc;
+ struct g_geom *gp;
+ struct g_provider *pp;
ihandle_t ifd;
- int error;
+ int error;
if (ofwd_enable == 0)
return;
@@ -161,19 +161,19 @@ g_ofwd_init(struct g_class *mp __unused)
}
sc = (struct ofwd_softc *)malloc(sizeof *sc, M_DEVBUF,
- M_WAITOK|M_ZERO);
+ M_WAITOK|M_ZERO);
bioq_init(&sc->ofwd_bio_queue);
- mtx_init(&sc->ofwd_queue_mtx, "ofwd bio queue", NULL, MTX_DEF);
+ mtx_init(&sc->ofwd_queue_mtx, "ofwd bio queue", NULL, MTX_DEF);
sc->ofwd_instance = ifd;
- sc->ofwd_mediasize = (off_t)2*33554432;
+ sc->ofwd_mediasize = (off_t)2 * 33554432;
sc->ofwd_sectorsize = OFWD_BLOCKSIZE;
sc->ofwd_fwsectors = 0;
sc->ofwd_fwheads = 0;
error = kproc_create(ofwd_kthread, sc, &sc->ofwd_procp, 0, 0,
- "ofwd0");
- if (error != 0) {
+ "ofwd0");
+ if (error != 0) {
free(sc, M_DEVBUF);
- return;
+ return;
}
gp = g_new_geomf(&g_ofwd_class, "ofwd0");
@@ -189,13 +189,13 @@ g_ofwd_init(struct g_class *mp __unused)
static void
g_ofwd_start(struct bio *bp)
{
- struct ofwd_softc *sc;
+ struct ofwd_softc *sc;
- sc = bp->bio_to->geom->softc;
- mtx_lock(&sc->ofwd_queue_mtx);
- bioq_disksort(&sc->ofwd_bio_queue, bp);
- mtx_unlock(&sc->ofwd_queue_mtx);
- wakeup(sc);
+ sc = bp->bio_to->geom->softc;
+ mtx_lock(&sc->ofwd_queue_mtx);
+ bioq_disksort(&sc->ofwd_bio_queue, bp);
+ mtx_unlock(&sc->ofwd_queue_mtx);
+ wakeup(sc);
}
static int
@@ -204,5 +204,5 @@ g_ofwd_access(struct g_provider *pp, int r, int w, int e)
if (pp->geom->softc == NULL)
return (ENXIO);
- return (0);
+ return (0);
}
diff --git a/sys/dev/ofw/ofw_if.m b/sys/dev/ofw/ofw_if.m
index 431ac91..902f071 100644
--- a/sys/dev/ofw/ofw_if.m
+++ b/sys/dev/ofw/ofw_if.m
@@ -32,7 +32,7 @@
/**
* @defgroup OFW ofw - KObj methods for Open Firmware RTAS implementations
* @brief A set of methods to implement the Open Firmware client side interface.
- *@{
+ * @{
*/
INTERFACE ofw;
@@ -49,59 +49,59 @@ METHOD void init {
};
/**
- * @brief Return next sibling of node
+ * @brief Return next sibling of node.
*
* @param _node Selected node
*/
METHOD phandle_t peer {
ofw_t _ofw;
- phandle_t _node;
+ phandle_t _node;
};
/**
- * @brief Return parent of node
+ * @brief Return parent of node.
*
* @param _node Selected node
*/
METHOD phandle_t parent {
ofw_t _ofw;
- phandle_t _node;
+ phandle_t _node;
};
/**
- * @brief Return first child of node
+ * @brief Return first child of node.
*
* @param _node Selected node
*/
METHOD phandle_t child {
ofw_t _ofw;
- phandle_t _node;
+ phandle_t _node;
};
/**
- * @brief Return package corresponding to instance
+ * @brief Return package corresponding to instance.
*
* @param _handle Selected instance
*/
METHOD phandle_t instance_to_package {
ofw_t _ofw;
- ihandle_t _handle;
+ ihandle_t _handle;
};
/**
- * @brief Return length of node property
+ * @brief Return length of node property.
*
* @param _node Selected node
* @param _prop Property name
*/
METHOD ssize_t getproplen {
ofw_t _ofw;
- phandle_t _node;
- const char *_prop;
+ phandle_t _node;
+ const char *_prop;
};
/**
- * @brief Read node property
+ * @brief Read node property.
*
* @param _node Selected node
* @param _prop Property name
@@ -110,14 +110,14 @@ METHOD ssize_t getproplen {
*/
METHOD ssize_t getprop {
ofw_t _ofw;
- phandle_t _node;
+ phandle_t _node;
const char *_prop;
void *_buf;
size_t _size;
};
/**
- * @brief Get next property name
+ * @brief Get next property name.
*
* @param _node Selected node
* @param _prop Current property name
@@ -126,14 +126,14 @@ METHOD ssize_t getprop {
*/
METHOD int nextprop {
ofw_t _ofw;
- phandle_t _node;
+ phandle_t _node;
const char *_prop;
- char *_buf;
+ char *_buf;
size_t _size;
};
/**
- * @brief Set property
+ * @brief Set property.
*
* @param _node Selected node
* @param _prop Property name
@@ -142,14 +142,14 @@ METHOD int nextprop {
*/
METHOD int setprop {
ofw_t _ofw;
- phandle_t _node;
- const char *_prop;
+ phandle_t _node;
+ const char *_prop;
const void *_buf;
size_t _size;
};
/**
- * @brief Canonicalize path
+ * @brief Canonicalize path.
*
* @param _path Path to canonicalize
* @param _buf Buffer for canonicalized path
@@ -163,17 +163,17 @@ METHOD ssize_t canon {
};
/**
- * @brief Return phandle for named device
+ * @brief Return phandle for named device.
*
* @param _path Device path
*/
METHOD phandle_t finddevice {
ofw_t _ofw;
- const char *_path;
+ const char *_path;
};
/**
- * @brief Return path for node instance
+ * @brief Return path for node instance.
*
* @param _handle Instance handle
* @param _path Buffer for path
@@ -182,12 +182,12 @@ METHOD phandle_t finddevice {
METHOD ssize_t instance_to_path {
ofw_t _ofw;
ihandle_t _handle;
- char *_path;
+ char *_path;
size_t _size;
};
/**
- * @brief Return path for node
+ * @brief Return path for node.
*
* @param _node Package node
* @param _path Buffer for path
@@ -196,11 +196,10 @@ METHOD ssize_t instance_to_path {
METHOD ssize_t package_to_path {
ofw_t _ofw;
phandle_t _node;
- char *_path;
+ char *_path;
size_t _size;
};
-
# Methods for OF method calls (optional)
/**
@@ -214,7 +213,7 @@ METHOD int test {
};
/**
- * @brief Call method belonging to an instance handle
+ * @brief Call method belonging to an instance handle.
*
* @param _instance Instance handle
* @param _method Method name
@@ -228,13 +227,13 @@ METHOD int call_method {
ihandle_t _instance;
const char *_method;
int _nargs;
- int _nreturns;
+ int _nreturns;
unsigned long *_args_and_returns;
};
/**
- * @brief Interpret a forth command
+ * @brief Interpret a forth command.
*
* @param _cmd Command
* @param _nreturns Number of return values
@@ -244,14 +243,14 @@ METHOD int call_method {
METHOD int interpret {
ofw_t _ofw;
const char *_cmd;
- int _nreturns;
+ int _nreturns;
unsigned long *_returns;
};
# Device I/O Functions (optional)
/**
- * @brief Open node, returning instance handle
+ * @brief Open node, returning instance handle.
*
* @param _path Path to node
*/
@@ -261,7 +260,7 @@ METHOD ihandle_t open {
}
/**
- * @brief Close node instance
+ * @brief Close node instance.
*
* @param _instance Instance to close
*/
@@ -271,7 +270,7 @@ METHOD void close {
}
/**
- * @brief Read from device
+ * @brief Read from device.
*
* @param _instance Device instance
* @param _buf Buffer to read to
@@ -285,7 +284,7 @@ METHOD ssize_t read {
}
/**
- * @brief Write to device
+ * @brief Write to device.
*
* @param _instance Device instance
* @param _buf Buffer to write from
@@ -299,7 +298,7 @@ METHOD ssize_t write {
}
/**
- * @brief Seek device
+ * @brief Seek device.
*
* @param _instance Device instance
* @param _off Offset to which to seek
@@ -313,7 +312,7 @@ METHOD int seek {
# Open Firmware memory management
/**
- * @brief Claim virtual memory
+ * @brief Claim virtual memory.
*
* @param _addr Requested memory location (NULL for first available)
* @param _size Requested size in bytes
@@ -327,7 +326,7 @@ METHOD caddr_t claim {
}
/**
- * @brief Release virtual memory
+ * @brief Release virtual memory.
*
* @param _addr Memory location
* @param _size Size in bytes
@@ -341,17 +340,15 @@ METHOD void release {
# Commands for returning control to the firmware
/**
- * @brief Temporarily return control to firmware
+ * @brief Temporarily return control to firmware.
*/
METHOD void enter {
ofw_t _ofw;
};
/**
- * @brief Halt and return control to firmware
+ * @brief Halt and return control to firmware.
*/
METHOD void exit {
ofw_t _ofw;
};
-
-
diff --git a/sys/dev/ofw/ofw_iicbus.c b/sys/dev/ofw/ofw_iicbus.c
index e8effca..2ee9a72 100644
--- a/sys/dev/ofw/ofw_iicbus.c
+++ b/sys/dev/ofw/ofw_iicbus.c
@@ -68,7 +68,7 @@ static device_method_t ofw_iicbus_methods[] = {
DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
- { 0, 0 }
+ KOBJMETHOD_END
};
struct ofw_iicbus_devinfo {
@@ -100,7 +100,7 @@ ofw_iicbus_attach(device_t dev)
{
struct iicbus_softc *sc = IICBUS_SOFTC(dev);
struct ofw_iicbus_devinfo *dinfo;
- phandle_t node, child;
+ phandle_t child;
device_t childdev;
uint32_t addr;
@@ -114,16 +114,13 @@ ofw_iicbus_attach(device_t dev)
/*
* Attach those children represented in the device tree.
*/
-
- node = ofw_bus_get_node(dev);
-
- for (child = OF_child(node); child != 0; child = OF_peer(child)) {
+ for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
+ child = OF_peer(child)) {
/*
* Try to get the I2C address first from the i2c-address
- * property, then try the reg property. It moves around
+ * property, then try the reg property. It moves around
* on different systems.
*/
-
if (OF_getprop(child, "i2c-address", &addr, sizeof(addr)) == -1)
if (OF_getprop(child, "reg", &addr, sizeof(addr)) == -1)
continue;
@@ -132,7 +129,6 @@ ofw_iicbus_attach(device_t dev)
* Now set up the I2C and OFW bus layer devinfo and add it
* to the bus.
*/
-
dinfo = malloc(sizeof(struct ofw_iicbus_devinfo), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (dinfo == NULL)
@@ -159,15 +155,17 @@ ofw_iicbus_add_child(device_t dev, int order, const char *name, int unit)
child = device_add_child_ordered(dev, order, name, unit);
if (child == NULL)
return (child);
- devi = malloc(sizeof(struct ofw_iicbus_devinfo), M_DEVBUF,
+ devi = malloc(sizeof(struct ofw_iicbus_devinfo), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (devi == NULL) {
device_delete_child(dev, child);
return (0);
}
- /* NULL all the OFW-related parts of the ivars for non-OFW children */
-
+ /*
+ * NULL all the OFW-related parts of the ivars for non-OFW
+ * children.
+ */
devi->opd_obdinfo.obd_node = -1;
devi->opd_obdinfo.obd_name = NULL;
devi->opd_obdinfo.obd_compat = NULL;
@@ -175,7 +173,7 @@ ofw_iicbus_add_child(device_t dev, int order, const char *name, int unit)
devi->opd_obdinfo.obd_model = NULL;
device_set_ivars(child, devi);
-
+
return (child);
}
@@ -187,4 +185,3 @@ ofw_iicbus_get_devinfo(device_t bus, device_t dev)
dinfo = device_get_ivars(dev);
return (&dinfo->opd_obdinfo);
}
-
diff --git a/sys/dev/ofw/ofw_standard.c b/sys/dev/ofw/ofw_standard.c
index addca71..de18a9e 100644
--- a/sys/dev/ofw/ofw_standard.c
+++ b/sys/dev/ofw/ofw_standard.c
@@ -65,8 +65,9 @@ __FBSDID("$FreeBSD$");
#include <machine/stdarg.h>
-#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofwvar.h>
+#include <dev/ofw/openfirm.h>
+
#include "ofw_if.h"
static void ofw_std_init(ofw_t ofw, void *openfirm);
@@ -101,7 +102,7 @@ static ssize_t ofw_std_read(ofw_t ofw, ihandle_t instance, void *addr,
size_t len);
static ssize_t ofw_std_write(ofw_t ofw, ihandle_t instance, const void *addr,
size_t len);
-static int ofw_std_seek(ofw_t ofw, ihandle_t instance, u_int64_t pos);
+static int ofw_std_seek(ofw_t ofw, ihandle_t instance, uint64_t pos);
static caddr_t ofw_std_claim(ofw_t ofw, void *virt, size_t size, u_int align);
static void ofw_std_release(ofw_t ofw, void *virt, size_t size);
static void ofw_std_enter(ofw_t ofw);
@@ -147,11 +148,12 @@ OFW_DEF(ofw_std);
static int (*openfirmware)(void *);
-/* Initialiser */
+/* Initializer */
static void
ofw_std_init(ofw_t ofw, void *openfirm)
{
+
openfirmware = (int (*)(void *))openfirm;
}
@@ -199,9 +201,8 @@ ofw_std_interpret(ofw_t ofw, const char *cmd, int nreturns,
args.nreturns = ++nreturns;
args.slot[i++] = (cell_t)cmd;
- if (openfirmware(&args) == -1) {
+ if (openfirmware(&args) == -1)
return (-1);
- }
status = args.slot[i++];
while (i < 1 + nreturns)
returns[j++] = args.slot[i++];
@@ -571,9 +572,8 @@ ofw_std_open(ofw_t ofw, const char *device)
};
args.device = (cell_t)device;
- if (openfirmware(&args) == -1 || args.instance == 0) {
+ if (openfirmware(&args) == -1 || args.instance == 0)
return (-1);
- }
return (args.instance);
}
@@ -650,7 +650,7 @@ ofw_std_write(ofw_t ofw, ihandle_t instance, const void *addr, size_t len)
/* Seek to a position. */
static int
-ofw_std_seek(ofw_t ofw, ihandle_t instance, u_int64_t pos)
+ofw_std_seek(ofw_t ofw, ihandle_t instance, uint64_t pos)
{
static struct {
cell_t name;
@@ -760,4 +760,3 @@ ofw_std_exit(ofw_t ofw)
for (;;) /* just in case */
;
}
-
diff --git a/sys/dev/ofw/ofwvar.h b/sys/dev/ofw/ofwvar.h
index 950dded..ddaa3db 100644
--- a/sys/dev/ofw/ofwvar.h
+++ b/sys/dev/ofw/ofwvar.h
@@ -27,8 +27,8 @@
* $FreeBSD$
*/
-#ifndef _OFW_OFWVAR_H_
-#define _OFW_OFWVAR_H_
+#ifndef _DEV_OFW_OFWVAR_H_
+#define _DEV_OFW_OFWVAR_H_
/*
* An Open Firmware client implementation is declared with a kernel object and
@@ -45,7 +45,7 @@
* };
*
* static ofw_def_t ofw_fdt = {
- * "ofw_fdt",
+ * "ofw_fdt",
* fdt_methods,
* sizeof(fdt_softc), // or 0 if no softc
* };
@@ -69,21 +69,21 @@ struct ofw_kobj {
/*
* Opaque data that can be overlaid with an instance-private
- * structure. OFW code can test that this is large enough at
- * compile time with a sizeof() test againt it's softc. There
+ * structure. OFW code can test that this is large enough at
+ * compile time with a sizeof() test againt it's softc. There
* is also a run-time test when the MMU kernel object is
* registered.
*/
-#define OFW_OPAQUESZ 64
+#define OFW_OPAQUESZ 64
u_int ofw_opaque[OFW_OPAQUESZ];
};
typedef struct ofw_kobj *ofw_t;
typedef struct kobj_class ofw_def_t;
-#define ofw_method_t kobj_method_t
-#define OFWMETHOD KOBJMETHOD
+#define ofw_method_t kobj_method_t
+#define OFWMETHOD KOBJMETHOD
-#define OFW_DEF(name) DATA_SET(ofw_set, name)
+#define OFW_DEF(name) DATA_SET(ofw_set, name)
-#endif /* _OFW_OFWVAR_H_ */
+#endif /* _DEV_OFW_OFWVAR_H_ */
diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c
index 06b58d0..17cda68 100644
--- a/sys/dev/ofw/openfirm.c
+++ b/sys/dev/ofw/openfirm.c
@@ -65,8 +65,8 @@ __FBSDID("$FreeBSD$");
#include <machine/stdarg.h>
-#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofwvar.h>
+#include <dev/ofw/openfirm.h>
#include "ofw_if.h"
@@ -88,12 +88,12 @@ SET_DECLARE(ofw_set, ofw_def_t);
boolean_t
OF_install(char *name, int prio)
{
- ofw_def_t **ofwpp, *ofwp;
+ ofw_def_t *ofwp, **ofwpp;
static int curr_prio = 0;
/*
- * Try and locate the OFW kobj corresponding to the name
- */
+ * Try and locate the OFW kobj corresponding to the name.
+ */
SET_FOREACH(ofwpp, ofw_set) {
ofwp = *ofwpp;
@@ -109,8 +109,7 @@ OF_install(char *name, int prio)
return (FALSE);
}
-/* Initialiser */
-
+/* Initializer */
void
OF_init(void *cookie)
{
@@ -119,7 +118,7 @@ OF_init(void *cookie)
ofw_obj = &ofw_kernel_obj;
/*
* Take care of compiling the selected class, and
- * then statically initialize the OFW object
+ * then statically initialize the OFW object.
*/
kobj_class_compile_static(ofw_def_impl, &ofw_kernel_kops);
kobj_init((kobj_t)ofw_obj, ofw_def_impl);
@@ -152,6 +151,7 @@ OF_printf(const char *fmt, ...)
int
OF_test(const char *name)
{
+
return (OFW_TEST(ofw_obj, name));
}
@@ -183,6 +183,7 @@ OF_interpret(const char *cmd, int nreturns, ...)
phandle_t
OF_peer(phandle_t node)
{
+
return (OFW_PEER(ofw_obj, node));
}
@@ -190,6 +191,7 @@ OF_peer(phandle_t node)
phandle_t
OF_child(phandle_t node)
{
+
return (OFW_CHILD(ofw_obj, node));
}
@@ -197,6 +199,7 @@ OF_child(phandle_t node)
phandle_t
OF_parent(phandle_t node)
{
+
return (OFW_PARENT(ofw_obj, node));
}
@@ -204,6 +207,7 @@ OF_parent(phandle_t node)
phandle_t
OF_instance_to_package(ihandle_t instance)
{
+
return (OFW_INSTANCE_TO_PACKAGE(ofw_obj, instance));
}
@@ -211,6 +215,7 @@ OF_instance_to_package(ihandle_t instance)
ssize_t
OF_getproplen(phandle_t package, const char *propname)
{
+
return (OFW_GETPROPLEN(ofw_obj, package, propname));
}
@@ -218,6 +223,7 @@ OF_getproplen(phandle_t package, const char *propname)
ssize_t
OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
{
+
return (OFW_GETPROP(ofw_obj, package, propname, buf, buflen));
}
@@ -227,20 +233,19 @@ OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
* first match.
*/
ssize_t
-OF_searchprop(phandle_t node, char *propname, void *buf, size_t len)
+OF_searchprop(phandle_t node, const char *propname, void *buf, size_t len)
{
ssize_t rv;
- for (; node != 0; node = OF_parent(node)) {
+ for (; node != 0; node = OF_parent(node))
if ((rv = OF_getprop(node, propname, buf, len)) != -1)
return (rv);
- }
return (-1);
}
/*
* Store the value of a property of a package into newly allocated memory
- * (using the M_OFWPROP malloc pool and M_WAITOK). elsz is the size of a
+ * (using the M_OFWPROP malloc pool and M_WAITOK). elsz is the size of a
* single element, the number of elements is return in number.
*/
ssize_t
@@ -266,6 +271,7 @@ OF_getprop_alloc(phandle_t package, const char *propname, int elsz, void **buf)
int
OF_nextprop(phandle_t package, const char *previous, char *buf, size_t size)
{
+
return (OFW_NEXTPROP(ofw_obj, package, previous, buf, size));
}
@@ -273,6 +279,7 @@ OF_nextprop(phandle_t package, const char *previous, char *buf, size_t size)
int
OF_setprop(phandle_t package, const char *propname, const void *buf, size_t len)
{
+
return (OFW_SETPROP(ofw_obj, package, propname, buf,len));
}
@@ -280,6 +287,7 @@ OF_setprop(phandle_t package, const char *propname, const void *buf, size_t len)
ssize_t
OF_canon(const char *device, char *buf, size_t len)
{
+
return (OFW_CANON(ofw_obj, device, buf, len));
}
@@ -287,6 +295,7 @@ OF_canon(const char *device, char *buf, size_t len)
phandle_t
OF_finddevice(const char *device)
{
+
return (OFW_FINDDEVICE(ofw_obj, device));
}
@@ -294,6 +303,7 @@ OF_finddevice(const char *device)
ssize_t
OF_instance_to_path(ihandle_t instance, char *buf, size_t len)
{
+
return (OFW_INSTANCE_TO_PATH(ofw_obj, instance, buf, len));
}
@@ -301,6 +311,7 @@ OF_instance_to_path(ihandle_t instance, char *buf, size_t len)
ssize_t
OF_package_to_path(phandle_t package, char *buf, size_t len)
{
+
return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len));
}
@@ -321,7 +332,6 @@ OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
status = OFW_CALL_METHOD(ofw_obj, instance, method, nargs, nreturns,
args_n_results);
-
if (status != 0)
return (status);
@@ -339,6 +349,7 @@ OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
ihandle_t
OF_open(const char *device)
{
+
return (OFW_OPEN(ofw_obj, device));
}
@@ -346,6 +357,7 @@ OF_open(const char *device)
void
OF_close(ihandle_t instance)
{
+
OFW_CLOSE(ofw_obj, instance);
}
@@ -353,6 +365,7 @@ OF_close(ihandle_t instance)
ssize_t
OF_read(ihandle_t instance, void *addr, size_t len)
{
+
return (OFW_READ(ofw_obj, instance, addr, len));
}
@@ -360,6 +373,7 @@ OF_read(ihandle_t instance, void *addr, size_t len)
ssize_t
OF_write(ihandle_t instance, const void *addr, size_t len)
{
+
return (OFW_WRITE(ofw_obj, instance, addr, len));
}
@@ -367,6 +381,7 @@ OF_write(ihandle_t instance, const void *addr, size_t len)
int
OF_seek(ihandle_t instance, uint64_t pos)
{
+
return (OFW_SEEK(ofw_obj, instance, pos));
}
@@ -378,6 +393,7 @@ OF_seek(ihandle_t instance, uint64_t pos)
void *
OF_claim(void *virt, size_t size, u_int align)
{
+
return (OFW_CLAIM(ofw_obj, virt, size, align));
}
@@ -385,6 +401,7 @@ OF_claim(void *virt, size_t size, u_int align)
void
OF_release(void *virt, size_t size)
{
+
OFW_RELEASE(ofw_obj, virt, size);
}
@@ -396,6 +413,7 @@ OF_release(void *virt, size_t size)
void
OF_enter()
{
+
OFW_ENTER(ofw_obj);
}
@@ -403,10 +421,10 @@ OF_enter()
void
OF_exit()
{
+
/* Should not return */
OFW_EXIT(ofw_obj);
for (;;) /* just in case */
;
}
-
diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h
index 614c4b2..10e8aad 100644
--- a/sys/dev/ofw/openfirm.h
+++ b/sys/dev/ofw/openfirm.h
@@ -57,8 +57,8 @@
* $FreeBSD$
*/
-#ifndef _OPENFIRM_H_
-#define _OPENFIRM_H_
+#ifndef _DEV_OPENFIRM_H_
+#define _DEV_OPENFIRM_H_
#include <sys/types.h>
@@ -66,7 +66,7 @@
* Prototypes for Open Firmware Interface Routines
*/
-typedef uint32_t ihandle_t;
+typedef uint32_t ihandle_t;
typedef uint32_t phandle_t;
typedef uint32_t pcell_t;
@@ -78,7 +78,7 @@ typedef uint32_t pcell_t;
MALLOC_DECLARE(M_OFWPROP);
/*
- * Open Firmware interface initialization. OF_install installs the named
+ * Open Firmware interface initialization. OF_install installs the named
* interface as the Open Firmware access mechanism, OF_init initializes it.
*/
@@ -94,8 +94,8 @@ void OF_init(void *cookie);
#define OFW_FDT "ofw_fdt" /* Flattened Device Tree */
/* Generic functions */
-int OF_test(const char *);
-void OF_printf(const char *, ...);
+int OF_test(const char *name);
+void OF_printf(const char *fmt, ...);
/* Device tree functions */
phandle_t OF_peer(phandle_t node);
@@ -104,7 +104,7 @@ phandle_t OF_parent(phandle_t node);
ssize_t OF_getproplen(phandle_t node, const char *propname);
ssize_t OF_getprop(phandle_t node, const char *propname, void *buf,
size_t len);
-ssize_t OF_searchprop(phandle_t node, char *propname, void *buf,
+ssize_t OF_searchprop(phandle_t node, const char *propname, void *buf,
size_t len);
ssize_t OF_getprop_alloc(phandle_t node, const char *propname,
int elsz, void **buf);
@@ -129,7 +129,7 @@ int OF_call_method(const char *method, ihandle_t instance,
int nargs, int nreturns, ...);
/* Memory functions */
-void *OF_claim(void *virtrequest, size_t size, u_int align);
+void *OF_claim(void *virtrequest, size_t size, u_int align);
void OF_release(void *virt, size_t size);
/* Control transfer functions */
@@ -140,4 +140,4 @@ void OF_exit(void) __attribute__((noreturn));
int OF_interpret(const char *cmd, int nreturns, ...);
#endif /* _KERNEL */
-#endif /* _OPENFIRM_H_ */
+#endif /* _DEV_OPENFIRM_H_ */
diff --git a/sys/dev/ofw/openfirmio.c b/sys/dev/ofw/openfirmio.c
index d042f02..5803ec1 100644
--- a/sys/dev/ofw/openfirmio.c
+++ b/sys/dev/ofw/openfirmio.c
@@ -95,7 +95,7 @@ openfirm_getstr(int len, const char *user, char **cpp)
int error;
char *cp;
- /* Reject obvious bogus requests */
+ /* Reject obvious bogus requests. */
if ((u_int)len > OFIOCMAXNAME)
return (ENAMETOOLONG);
@@ -141,7 +141,7 @@ openfirm_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
}
if (node != 0 && node != lastnode) {
- /* Not an easy one, must search for it */
+ /* Not an easy one, we must search for it. */
ok = openfirm_checkid(OF_peer(0), node);
if (!ok)
return (EINVAL);
@@ -169,7 +169,7 @@ openfirm_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
break;
}
of->of_buflen = len;
- /* -1 means no entry; 0 means no value */
+ /* -1 means no entry; 0 means no value. */
if (len <= 0)
break;
value = malloc(len, M_TEMP, M_WAITOK);
@@ -185,7 +185,7 @@ openfirm_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
/*
* Note: Text string values for at least the /options node
* have to be null-terminated and the length parameter must
- * include this terminating null. However, like OF_getprop(),
+ * include this terminating null. However, like OF_getprop(),
* OF_setprop() will return the actual length of the text
* string, i.e. omitting the terminating null.
*/
@@ -274,6 +274,7 @@ openfirm_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
static int
openfirm_modevent(module_t mod, int type, void *data)
{
+
switch(type) {
case MOD_LOAD:
if (bootverbose)
OpenPOWER on IntegriCloud