mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-23 19:56:24 +08:00
FDT(4): Port to RTEMS
This commit is contained in:
parent
f0dd0c506a
commit
c1205ee81e
@ -18,6 +18,10 @@ GENERATED += $(LOCAL_INC)/usbdevs.h
|
||||
GENERATED += $(LOCAL_INC)/miibus_if.h
|
||||
GENERATED += $(LOCAL_SRC)/miibus_if.c
|
||||
GENERATED += $(LOCAL_INC)/miidevs.h
|
||||
GENERATED += $(LOCAL_INC)/ofw_if.h
|
||||
GENERATED += $(LOCAL_SRC)/ofw_if.c
|
||||
GENERATED += $(LOCAL_INC)/ofw_bus_if.h
|
||||
GENERATED += $(LOCAL_SRC)/ofw_bus_if.c
|
||||
GENERATED += $(LOCAL_INC)/pci_if.h
|
||||
GENERATED += $(LOCAL_SRC)/pci_if.c
|
||||
GENERATED += $(LOCAL_INC)/pcib_if.h
|
||||
@ -109,6 +113,22 @@ $(LOCAL_SRC)/mmcbr_if.c: $(FREEBSD_SRC)/sys/dev/mmc/mmcbr_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -c
|
||||
mv mmcbr_if.c $@
|
||||
|
||||
$(LOCAL_INC)/ofw_if.h: $(FREEBSD_SRC)/sys/dev/ofw/ofw_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -h
|
||||
mv ofw_if.h $@
|
||||
|
||||
$(LOCAL_SRC)/ofw_if.c: $(FREEBSD_SRC)/sys/dev/ofw/ofw_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -c
|
||||
mv ofw_if.c $@
|
||||
|
||||
$(LOCAL_INC)/ofw_bus_if.h: $(FREEBSD_SRC)/sys/dev/ofw/ofw_bus_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -h
|
||||
mv ofw_bus_if.h $@
|
||||
|
||||
$(LOCAL_SRC)/ofw_bus_if.c: $(FREEBSD_SRC)/sys/dev/ofw/ofw_bus_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -c
|
||||
mv ofw_bus_if.c $@
|
||||
|
||||
$(LOCAL_INC)/if_dwc_if.h: $(FREEBSD_SRC)/sys/dev/dwc/if_dwc_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -h
|
||||
mv if_dwc_if.h $@
|
||||
|
@ -97,12 +97,18 @@ static ofw_method_t ofw_fdt_methods[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
#ifndef __rtems__
|
||||
static ofw_def_t ofw_fdt = {
|
||||
#else /* __rtems__ */
|
||||
ofw_def_t ofw_fdt = {
|
||||
#endif /* __rtems__ */
|
||||
OFW_FDT,
|
||||
ofw_fdt_methods,
|
||||
0
|
||||
};
|
||||
#ifndef __rtems__
|
||||
OFW_DEF(ofw_fdt);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void *fdtp = NULL;
|
||||
|
||||
|
@ -80,6 +80,9 @@ struct ofw_kobj {
|
||||
|
||||
typedef struct ofw_kobj *ofw_t;
|
||||
typedef struct kobj_class ofw_def_t;
|
||||
#ifdef __rtems__
|
||||
extern ofw_def_t ofw_fdt;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define ofw_method_t kobj_method_t
|
||||
#define OFWMETHOD KOBJMETHOD
|
||||
|
@ -84,7 +84,11 @@ MALLOC_DEFINE(M_OFWPROP, "openfirm", "Open Firmware properties");
|
||||
|
||||
static ihandle_t stdout;
|
||||
|
||||
#ifndef __rtems__
|
||||
static ofw_def_t *ofw_def_impl = NULL;
|
||||
#else /* __rtems__ */
|
||||
#define ofw_def_impl (&ofw_fdt)
|
||||
#endif /* __rtems__ */
|
||||
static ofw_t ofw_obj;
|
||||
static struct ofw_kobj ofw_kernel_obj;
|
||||
static struct kobj_ops ofw_kernel_kops;
|
||||
@ -144,6 +148,10 @@ static void
|
||||
xrefinfo_init(void *unsed)
|
||||
{
|
||||
|
||||
#ifdef __rtems__
|
||||
if (OF_init(__DECONST(void *, bsp_fdt_get())) != 0)
|
||||
return (ENXIO);
|
||||
#endif /* __rtems__ */
|
||||
/*
|
||||
* There is no locking during this init because it runs much earlier
|
||||
* than any of the clients/consumers of the xref list data, but we do
|
||||
@ -198,6 +206,7 @@ SET_DECLARE(ofw_set, ofw_def_t);
|
||||
boolean_t
|
||||
OF_install(char *name, int prio)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
ofw_def_t *ofwp, **ofwpp;
|
||||
static int curr_prio = 0;
|
||||
|
||||
@ -217,6 +226,9 @@ OF_install(char *name, int prio)
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
#else /* __rtems__ */
|
||||
return (TRUE);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
/* Initializer */
|
||||
|
41
libbsd.py
41
libbsd.py
@ -51,6 +51,8 @@ def rtems(mm):
|
||||
'local/cryptodev_if.c',
|
||||
'local/device_if.c',
|
||||
'local/miibus_if.c',
|
||||
'local/ofw_bus_if.c',
|
||||
'local/ofw_if.c',
|
||||
'local/pcib_if.c',
|
||||
'local/pci_if.c',
|
||||
'local/usb_if.c',
|
||||
@ -395,6 +397,44 @@ def base(mm):
|
||||
)
|
||||
return mod
|
||||
|
||||
#
|
||||
# FDT
|
||||
#
|
||||
def fdt(mm):
|
||||
mod = builder.Module('fdt')
|
||||
mod.addKernelSpaceHeaderFiles(
|
||||
[
|
||||
'sys/sys/slicer.h',
|
||||
'sys/dev/fdt/fdt_common.h',
|
||||
'sys/dev/fdt/simplebus.h',
|
||||
'sys/dev/ofw/ofw_bus.h',
|
||||
'sys/dev/ofw/ofw_bus_subr.h',
|
||||
'sys/dev/ofw/ofw_subr.h',
|
||||
'sys/dev/ofw/ofw_pci.h',
|
||||
'sys/dev/ofw/ofwvar.h',
|
||||
'sys/dev/ofw/openfirm.h',
|
||||
]
|
||||
)
|
||||
mod.addKernelSpaceSourceFiles(
|
||||
[
|
||||
'sys/dev/fdt/simplebus.c',
|
||||
'sys/dev/fdt/fdt_common.c',
|
||||
'sys/dev/ofw/ofwbus.c',
|
||||
'sys/dev/ofw/openfirm.c',
|
||||
'sys/dev/ofw/ofw_fdt.c',
|
||||
'sys/dev/ofw/ofw_bus_subr.c',
|
||||
'sys/dev/ofw/ofw_subr.c',
|
||||
],
|
||||
mm.generator['source']()
|
||||
)
|
||||
mod.addRTEMSSourceFiles(
|
||||
[
|
||||
'rtems/ofw_machdep.c',
|
||||
],
|
||||
mm.generator['source']()
|
||||
)
|
||||
return mod
|
||||
|
||||
#
|
||||
# MMC
|
||||
#
|
||||
@ -3039,6 +3079,7 @@ def sources(mm):
|
||||
mm.addModule(rtems(mm))
|
||||
mm.addModule(base(mm))
|
||||
|
||||
mm.addModule(fdt(mm))
|
||||
mm.addModule(mmc(mm))
|
||||
|
||||
mm.addModule(dev_usb(mm))
|
||||
|
@ -773,6 +773,8 @@ def build(bld):
|
||||
'freebsd/sys/dev/e1000/if_em.c',
|
||||
'freebsd/sys/dev/e1000/if_igb.c',
|
||||
'freebsd/sys/dev/e1000/if_lem.c',
|
||||
'freebsd/sys/dev/fdt/fdt_common.c',
|
||||
'freebsd/sys/dev/fdt/simplebus.c',
|
||||
'freebsd/sys/dev/fxp/if_fxp.c',
|
||||
'freebsd/sys/dev/led/led.c',
|
||||
'freebsd/sys/dev/mii/brgphy.c',
|
||||
@ -787,6 +789,11 @@ def build(bld):
|
||||
'freebsd/sys/dev/mii/ukphy_subr.c',
|
||||
'freebsd/sys/dev/mmc/mmc.c',
|
||||
'freebsd/sys/dev/mmc/mmcsd.c',
|
||||
'freebsd/sys/dev/ofw/ofw_bus_subr.c',
|
||||
'freebsd/sys/dev/ofw/ofw_fdt.c',
|
||||
'freebsd/sys/dev/ofw/ofw_subr.c',
|
||||
'freebsd/sys/dev/ofw/ofwbus.c',
|
||||
'freebsd/sys/dev/ofw/openfirm.c',
|
||||
'freebsd/sys/dev/pci/pci.c',
|
||||
'freebsd/sys/dev/pci/pci_pci.c',
|
||||
'freebsd/sys/dev/pci/pci_user.c',
|
||||
@ -1229,6 +1236,8 @@ def build(bld):
|
||||
'rtemsbsd/local/miibus_if.c',
|
||||
'rtemsbsd/local/mmcbr_if.c',
|
||||
'rtemsbsd/local/mmcbus_if.c',
|
||||
'rtemsbsd/local/ofw_bus_if.c',
|
||||
'rtemsbsd/local/ofw_if.c',
|
||||
'rtemsbsd/local/pci_if.c',
|
||||
'rtemsbsd/local/pcib_if.c',
|
||||
'rtemsbsd/local/rtwn-rtl8192cfwT.c',
|
||||
@ -1257,6 +1266,7 @@ def build(bld):
|
||||
'rtemsbsd/pppd/upap.c',
|
||||
'rtemsbsd/pppd/utils.c',
|
||||
'rtemsbsd/rtems/ipsec_get_policylen.c',
|
||||
'rtemsbsd/rtems/ofw_machdep.c',
|
||||
'rtemsbsd/rtems/rtems-bsd-allocator-domain-size.c',
|
||||
'rtemsbsd/rtems/rtems-bsd-arp-processor.c',
|
||||
'rtemsbsd/rtems/rtems-bsd-get-allocator-domain-size.c',
|
||||
|
1
rtemsbsd/include/contrib/libfdt/libfdt.h
Normal file
1
rtemsbsd/include/contrib/libfdt/libfdt.h
Normal file
@ -0,0 +1 @@
|
||||
#include <libfdt.h>
|
1
rtemsbsd/include/contrib/libfdt/libfdt_env.h
Normal file
1
rtemsbsd/include/contrib/libfdt/libfdt_env.h
Normal file
@ -0,0 +1 @@
|
||||
#include <libfdt_env.h>
|
@ -32,6 +32,16 @@
|
||||
#ifndef _MACHINE_OFW_MACHDEP_H_
|
||||
#define _MACHINE_OFW_MACHDEP_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <vm/vm.h>
|
||||
|
||||
typedef uint32_t cell_t;
|
||||
|
||||
struct mem_region {
|
||||
uint64_t mr_start;
|
||||
uint64_t mr_size;
|
||||
};
|
||||
|
||||
#endif /* _MACHINE_OFW_MACHDEP_H_ */
|
||||
|
116
rtemsbsd/include/rtems/bsd/local/ofw_bus_if.h
Normal file
116
rtemsbsd/include/rtems/bsd/local/ofw_bus_if.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* This file is produced automatically.
|
||||
* Do not modify anything in here by hand.
|
||||
*
|
||||
* Created from source file
|
||||
* freebsd-org/sys/dev/ofw/ofw_bus_if.m
|
||||
* with
|
||||
* makeobjops.awk
|
||||
*
|
||||
* See the source file for legal information
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ofw_bus_if_h_
|
||||
#define _ofw_bus_if_h_
|
||||
|
||||
|
||||
struct ofw_bus_devinfo {
|
||||
phandle_t obd_node;
|
||||
char *obd_compat;
|
||||
char *obd_model;
|
||||
char *obd_name;
|
||||
char *obd_type;
|
||||
char *obd_status;
|
||||
};
|
||||
|
||||
/** @brief Unique descriptor for the OFW_BUS_GET_DEVINFO() method */
|
||||
extern struct kobjop_desc ofw_bus_get_devinfo_desc;
|
||||
/** @brief A function implementing the OFW_BUS_GET_DEVINFO() method */
|
||||
typedef const struct ofw_bus_devinfo * ofw_bus_get_devinfo_t(device_t bus,
|
||||
device_t dev);
|
||||
|
||||
static __inline const struct ofw_bus_devinfo * OFW_BUS_GET_DEVINFO(device_t bus,
|
||||
device_t dev)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)bus)->ops,ofw_bus_get_devinfo);
|
||||
return ((ofw_bus_get_devinfo_t *) _m)(bus, dev);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_BUS_GET_COMPAT() method */
|
||||
extern struct kobjop_desc ofw_bus_get_compat_desc;
|
||||
/** @brief A function implementing the OFW_BUS_GET_COMPAT() method */
|
||||
typedef const char * ofw_bus_get_compat_t(device_t bus, device_t dev);
|
||||
|
||||
static __inline const char * OFW_BUS_GET_COMPAT(device_t bus, device_t dev)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)bus)->ops,ofw_bus_get_compat);
|
||||
return ((ofw_bus_get_compat_t *) _m)(bus, dev);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_BUS_GET_MODEL() method */
|
||||
extern struct kobjop_desc ofw_bus_get_model_desc;
|
||||
/** @brief A function implementing the OFW_BUS_GET_MODEL() method */
|
||||
typedef const char * ofw_bus_get_model_t(device_t bus, device_t dev);
|
||||
|
||||
static __inline const char * OFW_BUS_GET_MODEL(device_t bus, device_t dev)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)bus)->ops,ofw_bus_get_model);
|
||||
return ((ofw_bus_get_model_t *) _m)(bus, dev);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_BUS_GET_NAME() method */
|
||||
extern struct kobjop_desc ofw_bus_get_name_desc;
|
||||
/** @brief A function implementing the OFW_BUS_GET_NAME() method */
|
||||
typedef const char * ofw_bus_get_name_t(device_t bus, device_t dev);
|
||||
|
||||
static __inline const char * OFW_BUS_GET_NAME(device_t bus, device_t dev)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)bus)->ops,ofw_bus_get_name);
|
||||
return ((ofw_bus_get_name_t *) _m)(bus, dev);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_BUS_GET_NODE() method */
|
||||
extern struct kobjop_desc ofw_bus_get_node_desc;
|
||||
/** @brief A function implementing the OFW_BUS_GET_NODE() method */
|
||||
typedef phandle_t ofw_bus_get_node_t(device_t bus, device_t dev);
|
||||
|
||||
static __inline phandle_t OFW_BUS_GET_NODE(device_t bus, device_t dev)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)bus)->ops,ofw_bus_get_node);
|
||||
return ((ofw_bus_get_node_t *) _m)(bus, dev);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_BUS_GET_TYPE() method */
|
||||
extern struct kobjop_desc ofw_bus_get_type_desc;
|
||||
/** @brief A function implementing the OFW_BUS_GET_TYPE() method */
|
||||
typedef const char * ofw_bus_get_type_t(device_t bus, device_t dev);
|
||||
|
||||
static __inline const char * OFW_BUS_GET_TYPE(device_t bus, device_t dev)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)bus)->ops,ofw_bus_get_type);
|
||||
return ((ofw_bus_get_type_t *) _m)(bus, dev);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_BUS_MAP_INTR() method */
|
||||
extern struct kobjop_desc ofw_bus_map_intr_desc;
|
||||
/** @brief A function implementing the OFW_BUS_MAP_INTR() method */
|
||||
typedef int ofw_bus_map_intr_t(device_t bus, device_t dev, phandle_t iparent,
|
||||
int icells, pcell_t *interrupt);
|
||||
|
||||
static __inline int OFW_BUS_MAP_INTR(device_t bus, device_t dev,
|
||||
phandle_t iparent, int icells,
|
||||
pcell_t *interrupt)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)bus)->ops,ofw_bus_map_intr);
|
||||
return ((ofw_bus_map_intr_t *) _m)(bus, dev, iparent, icells, interrupt);
|
||||
}
|
||||
|
||||
#endif /* _ofw_bus_if_h_ */
|
500
rtemsbsd/include/rtems/bsd/local/ofw_if.h
Normal file
500
rtemsbsd/include/rtems/bsd/local/ofw_if.h
Normal file
@ -0,0 +1,500 @@
|
||||
/*
|
||||
* This file is produced automatically.
|
||||
* Do not modify anything in here by hand.
|
||||
*
|
||||
* Created from source file
|
||||
* freebsd-org/sys/dev/ofw/ofw_if.m
|
||||
* with
|
||||
* makeobjops.awk
|
||||
*
|
||||
* See the source file for legal information
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup OFW ofw - KObj methods for Open Firmware RTAS implementations
|
||||
* @brief A set of methods to implement the Open Firmware client side interface.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _ofw_if_h_
|
||||
#define _ofw_if_h_
|
||||
|
||||
/** @brief Unique descriptor for the OFW_INIT() method */
|
||||
extern struct kobjop_desc ofw_init_desc;
|
||||
/** @brief A function implementing the OFW_INIT() method */
|
||||
typedef int ofw_init_t(ofw_t _ofw, void *_cookie);
|
||||
/**
|
||||
* @brief Initialize OFW client interface
|
||||
*
|
||||
* @param _cookie A handle to the client interface, generally the OF
|
||||
* callback routine.
|
||||
*/
|
||||
|
||||
static __inline int OFW_INIT(ofw_t _ofw, void *_cookie)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_init);
|
||||
return ((ofw_init_t *) _m)(_ofw, _cookie);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_PEER() method */
|
||||
extern struct kobjop_desc ofw_peer_desc;
|
||||
/** @brief A function implementing the OFW_PEER() method */
|
||||
typedef phandle_t ofw_peer_t(ofw_t _ofw, phandle_t _node);
|
||||
/**
|
||||
* @brief Return next sibling of node.
|
||||
*
|
||||
* @param _node Selected node
|
||||
*/
|
||||
|
||||
static __inline phandle_t OFW_PEER(ofw_t _ofw, phandle_t _node)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_peer);
|
||||
return ((ofw_peer_t *) _m)(_ofw, _node);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_PARENT() method */
|
||||
extern struct kobjop_desc ofw_parent_desc;
|
||||
/** @brief A function implementing the OFW_PARENT() method */
|
||||
typedef phandle_t ofw_parent_t(ofw_t _ofw, phandle_t _node);
|
||||
/**
|
||||
* @brief Return parent of node.
|
||||
*
|
||||
* @param _node Selected node
|
||||
*/
|
||||
|
||||
static __inline phandle_t OFW_PARENT(ofw_t _ofw, phandle_t _node)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_parent);
|
||||
return ((ofw_parent_t *) _m)(_ofw, _node);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_CHILD() method */
|
||||
extern struct kobjop_desc ofw_child_desc;
|
||||
/** @brief A function implementing the OFW_CHILD() method */
|
||||
typedef phandle_t ofw_child_t(ofw_t _ofw, phandle_t _node);
|
||||
/**
|
||||
* @brief Return first child of node.
|
||||
*
|
||||
* @param _node Selected node
|
||||
*/
|
||||
|
||||
static __inline phandle_t OFW_CHILD(ofw_t _ofw, phandle_t _node)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_child);
|
||||
return ((ofw_child_t *) _m)(_ofw, _node);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_INSTANCE_TO_PACKAGE() method */
|
||||
extern struct kobjop_desc ofw_instance_to_package_desc;
|
||||
/** @brief A function implementing the OFW_INSTANCE_TO_PACKAGE() method */
|
||||
typedef phandle_t ofw_instance_to_package_t(ofw_t _ofw, ihandle_t _handle);
|
||||
/**
|
||||
* @brief Return package corresponding to instance.
|
||||
*
|
||||
* @param _handle Selected instance
|
||||
*/
|
||||
|
||||
static __inline phandle_t OFW_INSTANCE_TO_PACKAGE(ofw_t _ofw, ihandle_t _handle)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_instance_to_package);
|
||||
return ((ofw_instance_to_package_t *) _m)(_ofw, _handle);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_GETPROPLEN() method */
|
||||
extern struct kobjop_desc ofw_getproplen_desc;
|
||||
/** @brief A function implementing the OFW_GETPROPLEN() method */
|
||||
typedef ssize_t ofw_getproplen_t(ofw_t _ofw, phandle_t _node,
|
||||
const char *_prop);
|
||||
/**
|
||||
* @brief Return length of node property.
|
||||
*
|
||||
* @param _node Selected node
|
||||
* @param _prop Property name
|
||||
*/
|
||||
|
||||
static __inline ssize_t OFW_GETPROPLEN(ofw_t _ofw, phandle_t _node,
|
||||
const char *_prop)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_getproplen);
|
||||
return ((ofw_getproplen_t *) _m)(_ofw, _node, _prop);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_GETPROP() method */
|
||||
extern struct kobjop_desc ofw_getprop_desc;
|
||||
/** @brief A function implementing the OFW_GETPROP() method */
|
||||
typedef ssize_t ofw_getprop_t(ofw_t _ofw, phandle_t _node, const char *_prop,
|
||||
void *_buf, size_t _size);
|
||||
/**
|
||||
* @brief Read node property.
|
||||
*
|
||||
* @param _node Selected node
|
||||
* @param _prop Property name
|
||||
* @param _buf Pointer to buffer
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline ssize_t OFW_GETPROP(ofw_t _ofw, phandle_t _node,
|
||||
const char *_prop, void *_buf, size_t _size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_getprop);
|
||||
return ((ofw_getprop_t *) _m)(_ofw, _node, _prop, _buf, _size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_NEXTPROP() method */
|
||||
extern struct kobjop_desc ofw_nextprop_desc;
|
||||
/** @brief A function implementing the OFW_NEXTPROP() method */
|
||||
typedef int ofw_nextprop_t(ofw_t _ofw, phandle_t _node, const char *_prop,
|
||||
char *_buf, size_t _size);
|
||||
/**
|
||||
* @brief Get next property name.
|
||||
*
|
||||
* @param _node Selected node
|
||||
* @param _prop Current property name
|
||||
* @param _buf Buffer for next property name
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline int OFW_NEXTPROP(ofw_t _ofw, phandle_t _node, const char *_prop,
|
||||
char *_buf, size_t _size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_nextprop);
|
||||
return ((ofw_nextprop_t *) _m)(_ofw, _node, _prop, _buf, _size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_SETPROP() method */
|
||||
extern struct kobjop_desc ofw_setprop_desc;
|
||||
/** @brief A function implementing the OFW_SETPROP() method */
|
||||
typedef int ofw_setprop_t(ofw_t _ofw, phandle_t _node, const char *_prop,
|
||||
const void *_buf, size_t _size);
|
||||
/**
|
||||
* @brief Set property.
|
||||
*
|
||||
* @param _node Selected node
|
||||
* @param _prop Property name
|
||||
* @param _buf Value to set
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline int OFW_SETPROP(ofw_t _ofw, phandle_t _node, const char *_prop,
|
||||
const void *_buf, size_t _size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_setprop);
|
||||
return ((ofw_setprop_t *) _m)(_ofw, _node, _prop, _buf, _size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_CANON() method */
|
||||
extern struct kobjop_desc ofw_canon_desc;
|
||||
/** @brief A function implementing the OFW_CANON() method */
|
||||
typedef ssize_t ofw_canon_t(ofw_t _ofw, const char *_path, char *_buf,
|
||||
size_t _size);
|
||||
/**
|
||||
* @brief Canonicalize path.
|
||||
*
|
||||
* @param _path Path to canonicalize
|
||||
* @param _buf Buffer for canonicalized path
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline ssize_t OFW_CANON(ofw_t _ofw, const char *_path, char *_buf,
|
||||
size_t _size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_canon);
|
||||
return ((ofw_canon_t *) _m)(_ofw, _path, _buf, _size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_FINDDEVICE() method */
|
||||
extern struct kobjop_desc ofw_finddevice_desc;
|
||||
/** @brief A function implementing the OFW_FINDDEVICE() method */
|
||||
typedef phandle_t ofw_finddevice_t(ofw_t _ofw, const char *_path);
|
||||
/**
|
||||
* @brief Return phandle for named device.
|
||||
*
|
||||
* @param _path Device path
|
||||
*/
|
||||
|
||||
static __inline phandle_t OFW_FINDDEVICE(ofw_t _ofw, const char *_path)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_finddevice);
|
||||
return ((ofw_finddevice_t *) _m)(_ofw, _path);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_INSTANCE_TO_PATH() method */
|
||||
extern struct kobjop_desc ofw_instance_to_path_desc;
|
||||
/** @brief A function implementing the OFW_INSTANCE_TO_PATH() method */
|
||||
typedef ssize_t ofw_instance_to_path_t(ofw_t _ofw, ihandle_t _handle,
|
||||
char *_path, size_t _size);
|
||||
/**
|
||||
* @brief Return path for node instance.
|
||||
*
|
||||
* @param _handle Instance handle
|
||||
* @param _path Buffer for path
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline ssize_t OFW_INSTANCE_TO_PATH(ofw_t _ofw, ihandle_t _handle,
|
||||
char *_path, size_t _size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_instance_to_path);
|
||||
return ((ofw_instance_to_path_t *) _m)(_ofw, _handle, _path, _size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_PACKAGE_TO_PATH() method */
|
||||
extern struct kobjop_desc ofw_package_to_path_desc;
|
||||
/** @brief A function implementing the OFW_PACKAGE_TO_PATH() method */
|
||||
typedef ssize_t ofw_package_to_path_t(ofw_t _ofw, phandle_t _node, char *_path,
|
||||
size_t _size);
|
||||
/**
|
||||
* @brief Return path for node.
|
||||
*
|
||||
* @param _node Package node
|
||||
* @param _path Buffer for path
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline ssize_t OFW_PACKAGE_TO_PATH(ofw_t _ofw, phandle_t _node,
|
||||
char *_path, size_t _size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_package_to_path);
|
||||
return ((ofw_package_to_path_t *) _m)(_ofw, _node, _path, _size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_TEST() method */
|
||||
extern struct kobjop_desc ofw_test_desc;
|
||||
/** @brief A function implementing the OFW_TEST() method */
|
||||
typedef int ofw_test_t(ofw_t _ofw, const char *_name);
|
||||
/**
|
||||
* @brief Test to see if a service exists.
|
||||
*
|
||||
* @param _name name of the service
|
||||
*/
|
||||
|
||||
static __inline int OFW_TEST(ofw_t _ofw, const char *_name)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_test);
|
||||
return ((ofw_test_t *) _m)(_ofw, _name);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_CALL_METHOD() method */
|
||||
extern struct kobjop_desc ofw_call_method_desc;
|
||||
/** @brief A function implementing the OFW_CALL_METHOD() method */
|
||||
typedef int ofw_call_method_t(ofw_t _ofw, ihandle_t _instance,
|
||||
const char *_method, int _nargs, int _nreturns,
|
||||
cell_t *_args_and_returns);
|
||||
/**
|
||||
* @brief Call method belonging to an instance handle.
|
||||
*
|
||||
* @param _instance Instance handle
|
||||
* @param _method Method name
|
||||
* @param _nargs Number of arguments
|
||||
* @param _nreturns Number of return values
|
||||
* @param _args_and_returns Values for arguments, followed by returns
|
||||
*/
|
||||
|
||||
static __inline int OFW_CALL_METHOD(ofw_t _ofw, ihandle_t _instance,
|
||||
const char *_method, int _nargs,
|
||||
int _nreturns, cell_t *_args_and_returns)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_call_method);
|
||||
return ((ofw_call_method_t *) _m)(_ofw, _instance, _method, _nargs, _nreturns, _args_and_returns);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_INTERPRET() method */
|
||||
extern struct kobjop_desc ofw_interpret_desc;
|
||||
/** @brief A function implementing the OFW_INTERPRET() method */
|
||||
typedef int ofw_interpret_t(ofw_t _ofw, const char *_cmd, int _nreturns,
|
||||
cell_t *_returns);
|
||||
/**
|
||||
* @brief Interpret a forth command.
|
||||
*
|
||||
* @param _cmd Command
|
||||
* @param _nreturns Number of return values
|
||||
* @param _returns Values for returns
|
||||
*/
|
||||
|
||||
static __inline int OFW_INTERPRET(ofw_t _ofw, const char *_cmd, int _nreturns,
|
||||
cell_t *_returns)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_interpret);
|
||||
return ((ofw_interpret_t *) _m)(_ofw, _cmd, _nreturns, _returns);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_OPEN() method */
|
||||
extern struct kobjop_desc ofw_open_desc;
|
||||
/** @brief A function implementing the OFW_OPEN() method */
|
||||
typedef ihandle_t ofw_open_t(ofw_t _ofw, const char *_path);
|
||||
/**
|
||||
* @brief Open node, returning instance handle.
|
||||
*
|
||||
* @param _path Path to node
|
||||
*/
|
||||
|
||||
static __inline ihandle_t OFW_OPEN(ofw_t _ofw, const char *_path)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_open);
|
||||
return ((ofw_open_t *) _m)(_ofw, _path);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_CLOSE() method */
|
||||
extern struct kobjop_desc ofw_close_desc;
|
||||
/** @brief A function implementing the OFW_CLOSE() method */
|
||||
typedef void ofw_close_t(ofw_t _ofw, ihandle_t _instance);
|
||||
/**
|
||||
* @brief Close node instance.
|
||||
*
|
||||
* @param _instance Instance to close
|
||||
*/
|
||||
|
||||
static __inline void OFW_CLOSE(ofw_t _ofw, ihandle_t _instance)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_close);
|
||||
((ofw_close_t *) _m)(_ofw, _instance);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_READ() method */
|
||||
extern struct kobjop_desc ofw_read_desc;
|
||||
/** @brief A function implementing the OFW_READ() method */
|
||||
typedef ssize_t ofw_read_t(ofw_t _ofw, ihandle_t _instance, void *_buf,
|
||||
size_t size);
|
||||
/**
|
||||
* @brief Read from device.
|
||||
*
|
||||
* @param _instance Device instance
|
||||
* @param _buf Buffer to read to
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline ssize_t OFW_READ(ofw_t _ofw, ihandle_t _instance, void *_buf,
|
||||
size_t size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_read);
|
||||
return ((ofw_read_t *) _m)(_ofw, _instance, _buf, size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_WRITE() method */
|
||||
extern struct kobjop_desc ofw_write_desc;
|
||||
/** @brief A function implementing the OFW_WRITE() method */
|
||||
typedef ssize_t ofw_write_t(ofw_t _ofw, ihandle_t _instance, const void *_buf,
|
||||
size_t size);
|
||||
/**
|
||||
* @brief Write to device.
|
||||
*
|
||||
* @param _instance Device instance
|
||||
* @param _buf Buffer to write from
|
||||
* @param _size Size of buffer
|
||||
*/
|
||||
|
||||
static __inline ssize_t OFW_WRITE(ofw_t _ofw, ihandle_t _instance,
|
||||
const void *_buf, size_t size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_write);
|
||||
return ((ofw_write_t *) _m)(_ofw, _instance, _buf, size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_SEEK() method */
|
||||
extern struct kobjop_desc ofw_seek_desc;
|
||||
/** @brief A function implementing the OFW_SEEK() method */
|
||||
typedef int ofw_seek_t(ofw_t _ofw, ihandle_t _instance, uint64_t _off);
|
||||
/**
|
||||
* @brief Seek device.
|
||||
*
|
||||
* @param _instance Device instance
|
||||
* @param _off Offset to which to seek
|
||||
*/
|
||||
|
||||
static __inline int OFW_SEEK(ofw_t _ofw, ihandle_t _instance, uint64_t _off)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_seek);
|
||||
return ((ofw_seek_t *) _m)(_ofw, _instance, _off);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_CLAIM() method */
|
||||
extern struct kobjop_desc ofw_claim_desc;
|
||||
/** @brief A function implementing the OFW_CLAIM() method */
|
||||
typedef caddr_t ofw_claim_t(ofw_t _ofw, void *_addr, size_t _size,
|
||||
u_int _align);
|
||||
/**
|
||||
* @brief Claim virtual memory.
|
||||
*
|
||||
* @param _addr Requested memory location (NULL for first available)
|
||||
* @param _size Requested size in bytes
|
||||
* @param _align Requested alignment
|
||||
*/
|
||||
|
||||
static __inline caddr_t OFW_CLAIM(ofw_t _ofw, void *_addr, size_t _size,
|
||||
u_int _align)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_claim);
|
||||
return ((ofw_claim_t *) _m)(_ofw, _addr, _size, _align);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_RELEASE() method */
|
||||
extern struct kobjop_desc ofw_release_desc;
|
||||
/** @brief A function implementing the OFW_RELEASE() method */
|
||||
typedef void ofw_release_t(ofw_t _ofw, void *_addr, size_t _size);
|
||||
/**
|
||||
* @brief Release virtual memory.
|
||||
*
|
||||
* @param _addr Memory location
|
||||
* @param _size Size in bytes
|
||||
*/
|
||||
|
||||
static __inline void OFW_RELEASE(ofw_t _ofw, void *_addr, size_t _size)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_release);
|
||||
((ofw_release_t *) _m)(_ofw, _addr, _size);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_ENTER() method */
|
||||
extern struct kobjop_desc ofw_enter_desc;
|
||||
/** @brief A function implementing the OFW_ENTER() method */
|
||||
typedef void ofw_enter_t(ofw_t _ofw);
|
||||
/**
|
||||
* @brief Temporarily return control to firmware.
|
||||
*/
|
||||
|
||||
static __inline void OFW_ENTER(ofw_t _ofw)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_enter);
|
||||
((ofw_enter_t *) _m)(_ofw);
|
||||
}
|
||||
|
||||
/** @brief Unique descriptor for the OFW_EXIT() method */
|
||||
extern struct kobjop_desc ofw_exit_desc;
|
||||
/** @brief A function implementing the OFW_EXIT() method */
|
||||
typedef void ofw_exit_t(ofw_t _ofw);
|
||||
/**
|
||||
* @brief Halt and return control to firmware.
|
||||
*/
|
||||
|
||||
static __inline void OFW_EXIT(ofw_t _ofw)
|
||||
{
|
||||
kobjop_t _m;
|
||||
KOBJOPLOOKUP(((kobj_t)_ofw)->ops,ofw_exit);
|
||||
((ofw_exit_t *) _m)(_ofw);
|
||||
}
|
||||
|
||||
#endif /* _ofw_if_h_ */
|
@ -0,0 +1,4 @@
|
||||
#include <bsp/fdt.h>
|
||||
#ifdef BSP_FDT_IS_SUPPORTED
|
||||
#define FDT 1
|
||||
#endif
|
114
rtemsbsd/local/ofw_bus_if.c
Normal file
114
rtemsbsd/local/ofw_bus_if.c
Normal file
@ -0,0 +1,114 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*
|
||||
* This file is produced automatically.
|
||||
* Do not modify anything in here by hand.
|
||||
*
|
||||
* Created from source file
|
||||
* freebsd-org/sys/dev/ofw/ofw_bus_if.m
|
||||
* with
|
||||
* makeobjops.awk
|
||||
*
|
||||
* See the source file for legal information
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kobj.h>
|
||||
#include <sys/bus.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <rtems/bsd/local/ofw_bus_if.h>
|
||||
|
||||
|
||||
static ofw_bus_get_devinfo_t ofw_bus_default_get_devinfo;
|
||||
static ofw_bus_get_compat_t ofw_bus_default_get_compat;
|
||||
static ofw_bus_get_model_t ofw_bus_default_get_model;
|
||||
static ofw_bus_get_name_t ofw_bus_default_get_name;
|
||||
static ofw_bus_get_node_t ofw_bus_default_get_node;
|
||||
static ofw_bus_get_type_t ofw_bus_default_get_type;
|
||||
static ofw_bus_map_intr_t ofw_bus_default_map_intr;
|
||||
|
||||
static const struct ofw_bus_devinfo *
|
||||
ofw_bus_default_get_devinfo(device_t bus, device_t dev)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
ofw_bus_default_get_compat(device_t bus, device_t dev)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
ofw_bus_default_get_model(device_t bus, device_t dev)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
ofw_bus_default_get_name(device_t bus, device_t dev)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static phandle_t
|
||||
ofw_bus_default_get_node(device_t bus, device_t dev)
|
||||
{
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static const char *
|
||||
ofw_bus_default_get_type(device_t bus, device_t dev)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
ofw_bus_default_map_intr(device_t bus, device_t dev, phandle_t iparent,
|
||||
int icells, pcell_t *interrupt)
|
||||
{
|
||||
/* Propagate up the bus hierarchy until someone handles it. */
|
||||
if (device_get_parent(bus) != NULL)
|
||||
return OFW_BUS_MAP_INTR(device_get_parent(bus), dev,
|
||||
iparent, icells, interrupt);
|
||||
|
||||
/* If that fails, then assume a one-domain system */
|
||||
return (interrupt[0]);
|
||||
}
|
||||
|
||||
struct kobjop_desc ofw_bus_get_devinfo_desc = {
|
||||
0, { &ofw_bus_get_devinfo_desc, (kobjop_t)ofw_bus_default_get_devinfo }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_bus_get_compat_desc = {
|
||||
0, { &ofw_bus_get_compat_desc, (kobjop_t)ofw_bus_default_get_compat }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_bus_get_model_desc = {
|
||||
0, { &ofw_bus_get_model_desc, (kobjop_t)ofw_bus_default_get_model }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_bus_get_name_desc = {
|
||||
0, { &ofw_bus_get_name_desc, (kobjop_t)ofw_bus_default_get_name }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_bus_get_node_desc = {
|
||||
0, { &ofw_bus_get_node_desc, (kobjop_t)ofw_bus_default_get_node }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_bus_get_type_desc = {
|
||||
0, { &ofw_bus_get_type_desc, (kobjop_t)ofw_bus_default_get_type }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_bus_map_intr_desc = {
|
||||
0, { &ofw_bus_map_intr_desc, (kobjop_t)ofw_bus_default_map_intr }
|
||||
};
|
||||
|
122
rtemsbsd/local/ofw_if.c
Normal file
122
rtemsbsd/local/ofw_if.c
Normal file
@ -0,0 +1,122 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*
|
||||
* This file is produced automatically.
|
||||
* Do not modify anything in here by hand.
|
||||
*
|
||||
* Created from source file
|
||||
* freebsd-org/sys/dev/ofw/ofw_if.m
|
||||
* with
|
||||
* makeobjops.awk
|
||||
*
|
||||
* See the source file for legal information
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kobj.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofwvar.h>
|
||||
#include <rtems/bsd/local/ofw_if.h>
|
||||
|
||||
struct kobjop_desc ofw_init_desc = {
|
||||
0, { &ofw_init_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_peer_desc = {
|
||||
0, { &ofw_peer_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_parent_desc = {
|
||||
0, { &ofw_parent_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_child_desc = {
|
||||
0, { &ofw_child_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_instance_to_package_desc = {
|
||||
0, { &ofw_instance_to_package_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_getproplen_desc = {
|
||||
0, { &ofw_getproplen_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_getprop_desc = {
|
||||
0, { &ofw_getprop_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_nextprop_desc = {
|
||||
0, { &ofw_nextprop_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_setprop_desc = {
|
||||
0, { &ofw_setprop_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_canon_desc = {
|
||||
0, { &ofw_canon_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_finddevice_desc = {
|
||||
0, { &ofw_finddevice_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_instance_to_path_desc = {
|
||||
0, { &ofw_instance_to_path_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_package_to_path_desc = {
|
||||
0, { &ofw_package_to_path_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_test_desc = {
|
||||
0, { &ofw_test_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_call_method_desc = {
|
||||
0, { &ofw_call_method_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_interpret_desc = {
|
||||
0, { &ofw_interpret_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_open_desc = {
|
||||
0, { &ofw_open_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_close_desc = {
|
||||
0, { &ofw_close_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_read_desc = {
|
||||
0, { &ofw_read_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_write_desc = {
|
||||
0, { &ofw_write_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_seek_desc = {
|
||||
0, { &ofw_seek_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_claim_desc = {
|
||||
0, { &ofw_claim_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_release_desc = {
|
||||
0, { &ofw_release_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_enter_desc = {
|
||||
0, { &ofw_enter_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
||||
struct kobjop_desc ofw_exit_desc = {
|
||||
0, { &ofw_exit_desc, (kobjop_t)kobj_error_method }
|
||||
};
|
||||
|
58
rtemsbsd/rtems/ofw_machdep.c
Normal file
58
rtemsbsd/rtems/ofw_machdep.c
Normal file
@ -0,0 +1,58 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2015 Ian Lepore <ian@freebsd.org>
|
||||
* 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 THE AUTHOR OR CONTRIBUTORS 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 <sys/param.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_subr.h>
|
||||
|
||||
int
|
||||
OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
|
||||
bus_space_handle_t *handle, bus_size_t *sz)
|
||||
{
|
||||
bus_addr_t addr;
|
||||
bus_size_t size;
|
||||
int err;
|
||||
|
||||
err = ofw_reg_to_paddr(dev, regno, &addr, &size, NULL);
|
||||
if (err != 0)
|
||||
return (err);
|
||||
|
||||
*tag = 0;
|
||||
|
||||
if (sz != NULL)
|
||||
*sz = size;
|
||||
|
||||
return (bus_space_map(*tag, addr, size, 0, handle));
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2009, 2017 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@ -50,11 +50,21 @@
|
||||
#include <sys/malloc.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <rtems/bsd/local/opt_platform.h>
|
||||
|
||||
#ifdef FDT
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#endif
|
||||
|
||||
#include <rtems/bsd/bsd.h>
|
||||
#include <rtems/irq-extension.h>
|
||||
|
||||
/* #define DISABLE_INTERRUPT_EXTENSION */
|
||||
|
||||
#if defined(__i386__) || defined(FDT)
|
||||
#define ENABLE_RESOURCE_ACTIVATE_DEACTIVATE
|
||||
#endif
|
||||
|
||||
RTEMS_BSD_DECLARE_SET(nexus, rtems_bsd_device);
|
||||
|
||||
RTEMS_BSD_DEFINE_SET(nexus, rtems_bsd_device);
|
||||
@ -205,17 +215,24 @@ nexus_release_resource(device_t bus, device_t child, int type, int rid,
|
||||
return (rman_release_resource(res));
|
||||
}
|
||||
|
||||
#ifdef __i386__
|
||||
#ifdef ENABLE_RESOURCE_ACTIVATE_DEACTIVATE
|
||||
static int
|
||||
nexus_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
struct resource *res)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
#ifdef __i386__
|
||||
case SYS_RES_IOPORT:
|
||||
rman_set_bustag(res, X86_BUS_SPACE_IO);
|
||||
break;
|
||||
#endif
|
||||
case SYS_RES_MEMORY:
|
||||
#ifdef __i386__
|
||||
rman_set_bustag(res, X86_BUS_SPACE_MEM);
|
||||
#else
|
||||
rman_set_bushandle(res, rman_get_start(res));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return (rman_activate_resource(res));
|
||||
@ -330,6 +347,16 @@ nexus_teardown_intr(device_t dev, device_t child, struct resource *res,
|
||||
return (err);
|
||||
}
|
||||
|
||||
#ifdef FDT
|
||||
static int
|
||||
nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells,
|
||||
pcell_t *intr)
|
||||
{
|
||||
|
||||
return ((int)bsp_fdt_map_intr(intr[0]));
|
||||
}
|
||||
#endif /* FDT */
|
||||
|
||||
static device_method_t nexus_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, nexus_probe),
|
||||
@ -344,13 +371,18 @@ static device_method_t nexus_methods[] = {
|
||||
DEVMETHOD(bus_add_child, bus_generic_add_child),
|
||||
DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
|
||||
DEVMETHOD(bus_release_resource, nexus_release_resource),
|
||||
#ifdef __i386__
|
||||
#ifdef ENABLE_RESOURCE_ACTIVATE_DEACTIVATE
|
||||
DEVMETHOD(bus_activate_resource, nexus_activate_resource),
|
||||
DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
|
||||
#endif
|
||||
DEVMETHOD(bus_setup_intr, nexus_setup_intr),
|
||||
DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
|
||||
|
||||
#ifdef FDT
|
||||
/* OFW interface */
|
||||
DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr),
|
||||
#endif
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user