OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [sim/] [common/] [hw-device.h] - Diff between revs 827 and 840

Only display areas with differences | Details | Blame | View Log

Rev 827 Rev 840
/* The common simulator framework for GDB, the GNU Debugger.
/* The common simulator framework for GDB, the GNU Debugger.
 
 
   Copyright 2002, 2007, 2008 Free Software Foundation, Inc.
   Copyright 2002, 2007, 2008 Free Software Foundation, Inc.
 
 
   Contributed by Andrew Cagney and Red Hat.
   Contributed by Andrew Cagney and Red Hat.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 
 
#ifndef HW_DEVICE_H
#ifndef HW_DEVICE_H
#define HW_DEVICE_H
#define HW_DEVICE_H
 
 
/* declared in sim-basics.h, this object is used everywhere */
/* declared in sim-basics.h, this object is used everywhere */
/* typedef struct _device device; */
/* typedef struct _device device; */
 
 
 
 
/* Introduction:
/* Introduction:
 
 
   As explained in earlier sections, the device, device instance,
   As explained in earlier sections, the device, device instance,
   property and ports lie at the heart of PSIM's device model.
   property and ports lie at the heart of PSIM's device model.
 
 
   In the below a synopsis of the device object and the operations it
   In the below a synopsis of the device object and the operations it
   supports are given.
   supports are given.
   */
   */
 
 
 
 
/* Creation:
/* Creation:
 
 
   The devices are created using a sequence of steps.  In particular:
   The devices are created using a sequence of steps.  In particular:
 
 
        o       A tree framework is created.
        o       A tree framework is created.
 
 
                At this point, properties can be modified and extra
                At this point, properties can be modified and extra
                devices inserted (or removed?).
                devices inserted (or removed?).
 
 
#if LATER
#if LATER
 
 
                Any properties that have a run-time value (eg ihandle
                Any properties that have a run-time value (eg ihandle
                or device instance pointer properties) are entered
                or device instance pointer properties) are entered
                into the device tree using a named reference to the
                into the device tree using a named reference to the
                corresponding runtime object that is to be created.
                corresponding runtime object that is to be created.
 
 
#endif
#endif
 
 
        o       Real devices are created for all the dummy devices.
        o       Real devices are created for all the dummy devices.
 
 
                A device can assume that all of its parents have been
                A device can assume that all of its parents have been
                initialized.
                initialized.
 
 
                A device can assume that all non run-time properties
                A device can assume that all non run-time properties
                have been initialized.
                have been initialized.
 
 
                As part of being created, the device normally attaches
                As part of being created, the device normally attaches
                itself to its parent bus.
                itself to its parent bus.
 
 
#if LATER
#if LATER
 
 
                Device instance data is initialized.
                Device instance data is initialized.
 
 
#endif
#endif
 
 
#if LATER
#if LATER
 
 
        o       Any run-time properties are created.
        o       Any run-time properties are created.
 
 
#endif
#endif
 
 
#if MUCH_MUCH_LATER
#if MUCH_MUCH_LATER
 
 
        o       Some devices, as part of their initialization
        o       Some devices, as part of their initialization
                might want to refer to ihandle properties
                might want to refer to ihandle properties
                in the device tree.
                in the device tree.
 
 
#endif
#endif
 
 
   NOTES:
   NOTES:
 
 
        o       It is important to separate the creation
        o       It is important to separate the creation
                of an actual device from the creation
                of an actual device from the creation
                of the tree.  The alternative creating
                of the tree.  The alternative creating
                the device in two stages: As a separate
                the device in two stages: As a separate
                entity and then as a part of the tree.
                entity and then as a part of the tree.
 
 
#if LATER
#if LATER
        o       Run-time properties can not be created
        o       Run-time properties can not be created
                until after the devices in the tree
                until after the devices in the tree
                have been created.  Hence an extra pass
                have been created.  Hence an extra pass
                for handling them.
                for handling them.
#endif
#endif
 
 
   */
   */
 
 
/* Relationships:
/* Relationships:
 
 
   A device is able to determine its relationship to other devices
   A device is able to determine its relationship to other devices
   within the tree.  Operations include querying for a devices parent,
   within the tree.  Operations include querying for a devices parent,
   sibling, child, name, and path (from the root).
   sibling, child, name, and path (from the root).
 
 
   */
   */
 
 
 
 
#define hw_parent(hw) ((hw)->parent_of_hw + 0)
#define hw_parent(hw) ((hw)->parent_of_hw + 0)
 
 
#define hw_sibling(hw) ((hw)->sibling_of_hw + 0)
#define hw_sibling(hw) ((hw)->sibling_of_hw + 0)
 
 
#define hw_child(hw) ((hw)->child_of_hw + 0)
#define hw_child(hw) ((hw)->child_of_hw + 0)
 
 
 
 
 
 
/* Herritage:
/* Herritage:
 
 
 */
 */
 
 
#define hw_family(hw) ((hw)->family_of_hw + 0)
#define hw_family(hw) ((hw)->family_of_hw + 0)
 
 
#define hw_name(hw) ((hw)->name_of_hw + 0)
#define hw_name(hw) ((hw)->name_of_hw + 0)
 
 
#define hw_args(hw) ((hw)->args_of_hw + 0)
#define hw_args(hw) ((hw)->args_of_hw + 0)
 
 
#define hw_path(hw) ((hw)->path_of_hw + 0)
#define hw_path(hw) ((hw)->path_of_hw + 0)
 
 
 
 
 
 
/* Short cut to the root node of the tree */
/* Short cut to the root node of the tree */
 
 
#define hw_root(hw) ((hw)->root_of_hw + 0)
#define hw_root(hw) ((hw)->root_of_hw + 0)
 
 
/* Short cut back to the simulator object */
/* Short cut back to the simulator object */
 
 
#define hw_system(hw) ((hw)->system_of_hw)
#define hw_system(hw) ((hw)->system_of_hw)
 
 
/* For requests initiated by a CPU the cpu that initiated the request */
/* For requests initiated by a CPU the cpu that initiated the request */
 
 
struct _sim_cpu *hw_system_cpu (struct hw *hw);
struct _sim_cpu *hw_system_cpu (struct hw *hw);
 
 
 
 
/* Device private data */
/* Device private data */
 
 
#define hw_data(hw) ((hw)->data_of_hw)
#define hw_data(hw) ((hw)->data_of_hw)
 
 
#define set_hw_data(hw, value) \
#define set_hw_data(hw, value) \
((hw)->data_of_hw = (value))
((hw)->data_of_hw = (value))
 
 
 
 


/* Perform a soft reset of the device */
/* Perform a soft reset of the device */
 
 
typedef unsigned (hw_reset_method)
typedef unsigned (hw_reset_method)
     (struct hw *me);
     (struct hw *me);
 
 
#define hw_reset(hw) ((hw)->to_reset (hw))
#define hw_reset(hw) ((hw)->to_reset (hw))
 
 
#define set_hw_reset(hw, method) \
#define set_hw_reset(hw, method) \
((hw)->to_reset = method)
((hw)->to_reset = method)
 
 


/* Hardware operations:
/* Hardware operations:
 
 
   Connecting a parent to its children is a common bus. The parent
   Connecting a parent to its children is a common bus. The parent
   node is described as the bus owner and is responisble for
   node is described as the bus owner and is responisble for
   co-ordinating bus operations. On the bus, a SPACE:ADDR pair is used
   co-ordinating bus operations. On the bus, a SPACE:ADDR pair is used
   to specify an address.  A device that is both a bus owner (parent)
   to specify an address.  A device that is both a bus owner (parent)
   and bus client (child) are referred to as a bridging device.
   and bus client (child) are referred to as a bridging device.
 
 
   A child performing a data (DMA) transfer will pass its request to
   A child performing a data (DMA) transfer will pass its request to
   the bus owner (the devices parent).  The bus owner will then either
   the bus owner (the devices parent).  The bus owner will then either
   reflect the request to one of the other devices attached to the bus
   reflect the request to one of the other devices attached to the bus
   (a child of the bus owner) or bridge the request up the tree to the
   (a child of the bus owner) or bridge the request up the tree to the
   next bus. */
   next bus. */
 
 
 
 
/* Children attached to a bus can register (attach) themselves to
/* Children attached to a bus can register (attach) themselves to
   specific addresses on their attached bus.
   specific addresses on their attached bus.
 
 
   (A device may also be implicitly attached to certain bus
   (A device may also be implicitly attached to certain bus
   addresses).
   addresses).
 
 
   The SPACE:ADDR pair specify an address on the common bus that
   The SPACE:ADDR pair specify an address on the common bus that
   connects the parent and child devices. */
   connects the parent and child devices. */
 
 
typedef void (hw_attach_address_method)
typedef void (hw_attach_address_method)
     (struct hw *me,
     (struct hw *me,
      int level,
      int level,
      int space,
      int space,
      address_word addr,
      address_word addr,
      address_word nr_bytes,
      address_word nr_bytes,
      struct hw *client); /*callback/default*/
      struct hw *client); /*callback/default*/
 
 
#define hw_attach_address(me, level, space, addr, nr_bytes, client) \
#define hw_attach_address(me, level, space, addr, nr_bytes, client) \
((me)->to_attach_address (me, level, space, addr, nr_bytes, client))
((me)->to_attach_address (me, level, space, addr, nr_bytes, client))
 
 
#define set_hw_attach_address(hw, method) \
#define set_hw_attach_address(hw, method) \
((hw)->to_attach_address = (method))
((hw)->to_attach_address = (method))
 
 
typedef void (hw_detach_address_method)
typedef void (hw_detach_address_method)
     (struct hw *me,
     (struct hw *me,
      int level,
      int level,
      int space,
      int space,
      address_word addr,
      address_word addr,
      address_word nr_bytes,
      address_word nr_bytes,
      struct hw *client); /*callback/default*/
      struct hw *client); /*callback/default*/
 
 
#define hw_detach_address(me, level, space, addr, nr_bytes, client) \
#define hw_detach_address(me, level, space, addr, nr_bytes, client) \
((me)->to_detach_address (me, level, space, addr, nr_bytes, client))
((me)->to_detach_address (me, level, space, addr, nr_bytes, client))
 
 
#define set_hw_detach_address(hw, method) \
#define set_hw_detach_address(hw, method) \
((hw)->to_detach_address = (method))
((hw)->to_detach_address = (method))
 
 
 
 
/* An IO operation from a parent to a child via the conecting bus.
/* An IO operation from a parent to a child via the conecting bus.
 
 
   The SPACE:ADDR pair specify an address on the bus shared between
   The SPACE:ADDR pair specify an address on the bus shared between
   the parent and child devices. */
   the parent and child devices. */
 
 
typedef unsigned (hw_io_read_buffer_method)
typedef unsigned (hw_io_read_buffer_method)
     (struct hw *me,
     (struct hw *me,
      void *dest,
      void *dest,
      int space,
      int space,
      unsigned_word addr,
      unsigned_word addr,
      unsigned nr_bytes);
      unsigned nr_bytes);
 
 
#define hw_io_read_buffer(hw, dest, space, addr, nr_bytes) \
#define hw_io_read_buffer(hw, dest, space, addr, nr_bytes) \
((hw)->to_io_read_buffer (hw, dest, space, addr, nr_bytes))
((hw)->to_io_read_buffer (hw, dest, space, addr, nr_bytes))
 
 
#define set_hw_io_read_buffer(hw, method) \
#define set_hw_io_read_buffer(hw, method) \
((hw)->to_io_read_buffer = (method))
((hw)->to_io_read_buffer = (method))
 
 
typedef unsigned (hw_io_write_buffer_method)
typedef unsigned (hw_io_write_buffer_method)
     (struct hw *me,
     (struct hw *me,
      const void *source,
      const void *source,
      int space,
      int space,
      unsigned_word addr,
      unsigned_word addr,
      unsigned nr_bytes);
      unsigned nr_bytes);
 
 
#define hw_io_write_buffer(hw, src, space, addr, nr_bytes) \
#define hw_io_write_buffer(hw, src, space, addr, nr_bytes) \
((hw)->to_io_write_buffer (hw, src, space, addr, nr_bytes))
((hw)->to_io_write_buffer (hw, src, space, addr, nr_bytes))
 
 
#define set_hw_io_write_buffer(hw, method) \
#define set_hw_io_write_buffer(hw, method) \
((hw)->to_io_write_buffer = (method))
((hw)->to_io_write_buffer = (method))
 
 
 
 
/* Conversly, the device pci1000,1@1 may need to perform a dma transfer
/* Conversly, the device pci1000,1@1 may need to perform a dma transfer
   into the cpu/memory core.  Just as I/O moves towards the leaves,
   into the cpu/memory core.  Just as I/O moves towards the leaves,
   dma transfers move towards the core via the initiating devices
   dma transfers move towards the core via the initiating devices
   parent nodes.  The root device (special) converts the DMA transfer
   parent nodes.  The root device (special) converts the DMA transfer
   into reads/writes to memory.
   into reads/writes to memory.
 
 
   The SPACE:ADDR pair specify an address on the common bus connecting
   The SPACE:ADDR pair specify an address on the common bus connecting
   the parent and child devices. */
   the parent and child devices. */
 
 
typedef unsigned (hw_dma_read_buffer_method)
typedef unsigned (hw_dma_read_buffer_method)
     (struct hw *bus,
     (struct hw *bus,
      void *dest,
      void *dest,
      int space,
      int space,
      unsigned_word addr,
      unsigned_word addr,
      unsigned nr_bytes);
      unsigned nr_bytes);
 
 
#define hw_dma_read_buffer(bus, dest, space, addr, nr_bytes) \
#define hw_dma_read_buffer(bus, dest, space, addr, nr_bytes) \
((bus)->to_dma_read_buffer (bus, dest, space, addr, nr_bytes))
((bus)->to_dma_read_buffer (bus, dest, space, addr, nr_bytes))
 
 
#define set_hw_dma_read_buffer(me, method) \
#define set_hw_dma_read_buffer(me, method) \
((me)->to_dma_read_buffer = (method))
((me)->to_dma_read_buffer = (method))
 
 
typedef unsigned (hw_dma_write_buffer_method)
typedef unsigned (hw_dma_write_buffer_method)
     (struct hw *bus,
     (struct hw *bus,
      const void *source,
      const void *source,
      int space,
      int space,
      unsigned_word addr,
      unsigned_word addr,
      unsigned nr_bytes,
      unsigned nr_bytes,
      int violate_read_only_section);
      int violate_read_only_section);
 
 
#define hw_dma_write_buffer(bus, src, space, addr, nr_bytes, violate_ro) \
#define hw_dma_write_buffer(bus, src, space, addr, nr_bytes, violate_ro) \
((bus)->to_dma_write_buffer (bus, src, space, addr, nr_bytes, violate_ro))
((bus)->to_dma_write_buffer (bus, src, space, addr, nr_bytes, violate_ro))
 
 
#define set_hw_dma_write_buffer(me, method) \
#define set_hw_dma_write_buffer(me, method) \
((me)->to_dma_write_buffer = (method))
((me)->to_dma_write_buffer = (method))


/* Address/size specs for devices are encoded following a convention
/* Address/size specs for devices are encoded following a convention
   similar to that used by OpenFirmware.  In particular, an
   similar to that used by OpenFirmware.  In particular, an
   address/size is packed into a sequence of up to four cell words.
   address/size is packed into a sequence of up to four cell words.
   The number of words determined by the number of {address,size}
   The number of words determined by the number of {address,size}
   cells attributes of the device. */
   cells attributes of the device. */
 
 
typedef struct _hw_unit {
typedef struct _hw_unit {
  int nr_cells;
  int nr_cells;
  unsigned_cell cells[4]; /* unused cells are zero */
  unsigned_cell cells[4]; /* unused cells are zero */
} hw_unit;
} hw_unit;
 
 
 
 
/* For the given bus, the number of address and size cells used in a
/* For the given bus, the number of address and size cells used in a
   hw_unit. */
   hw_unit. */
 
 
#define hw_unit_nr_address_cells(bus) ((bus)->nr_address_cells_of_hw_unit + 0)
#define hw_unit_nr_address_cells(bus) ((bus)->nr_address_cells_of_hw_unit + 0)
 
 
#define hw_unit_nr_size_cells(bus) ((bus)->nr_size_cells_of_hw_unit + 0)
#define hw_unit_nr_size_cells(bus) ((bus)->nr_size_cells_of_hw_unit + 0)
 
 
 
 
/* For the given device, its identifying hw_unit address.
/* For the given device, its identifying hw_unit address.
 
 
   Each device has an identifying hw_unit address.  That address is
   Each device has an identifying hw_unit address.  That address is
   used when identifying one of a number of identical devices on a
   used when identifying one of a number of identical devices on a
   common controller bus. ex fd0&fd1. */
   common controller bus. ex fd0&fd1. */
 
 
const hw_unit *hw_unit_address
const hw_unit *hw_unit_address
(struct hw *me);
(struct hw *me);
 
 
 
 
/* Convert between a textual and the internal representation of a
/* Convert between a textual and the internal representation of a
   hw_unit address/size.
   hw_unit address/size.
 
 
   NOTE: A device asks its parent to translate between a hw_unit and
   NOTE: A device asks its parent to translate between a hw_unit and
   textual representation.  This is because the textual address of a
   textual representation.  This is because the textual address of a
   device is specified using the parent busses notation. */
   device is specified using the parent busses notation. */
 
 
typedef int (hw_unit_decode_method)
typedef int (hw_unit_decode_method)
     (struct hw *bus,
     (struct hw *bus,
      const char *encoded,
      const char *encoded,
      hw_unit *unit);
      hw_unit *unit);
 
 
#define hw_unit_decode(bus, encoded, unit) \
#define hw_unit_decode(bus, encoded, unit) \
((bus)->to_unit_decode (bus, encoded, unit))
((bus)->to_unit_decode (bus, encoded, unit))
 
 
#define set_hw_unit_decode(hw, method) \
#define set_hw_unit_decode(hw, method) \
((hw)->to_unit_decode = (method))
((hw)->to_unit_decode = (method))
 
 
typedef int (hw_unit_encode_method)
typedef int (hw_unit_encode_method)
     (struct hw *bus,
     (struct hw *bus,
      const hw_unit *unit,
      const hw_unit *unit,
      char *encoded,
      char *encoded,
      int sizeof_buf);
      int sizeof_buf);
 
 
#define hw_unit_encode(bus, unit, encoded, sizeof_encoded) \
#define hw_unit_encode(bus, unit, encoded, sizeof_encoded) \
((bus)->to_unit_encode (bus, unit, encoded, sizeof_encoded))
((bus)->to_unit_encode (bus, unit, encoded, sizeof_encoded))
 
 
#define set_hw_unit_encode(hw, method) \
#define set_hw_unit_encode(hw, method) \
((hw)->to_unit_encode = (method))
((hw)->to_unit_encode = (method))
 
 
 
 
/* As the bus that the device is attached too, to translate a devices
/* As the bus that the device is attached too, to translate a devices
   hw_unit address/size into a form suitable for an attach address
   hw_unit address/size into a form suitable for an attach address
   call.
   call.
 
 
   Return a zero result if the address should be ignored when looking
   Return a zero result if the address should be ignored when looking
   for attach addresses. */
   for attach addresses. */
 
 
typedef int (hw_unit_address_to_attach_address_method)
typedef int (hw_unit_address_to_attach_address_method)
     (struct hw *bus,
     (struct hw *bus,
      const hw_unit *unit_addr,
      const hw_unit *unit_addr,
      int *attach_space,
      int *attach_space,
      unsigned_word *attach_addr,
      unsigned_word *attach_addr,
      struct hw *client);
      struct hw *client);
 
 
#define hw_unit_address_to_attach_address(bus, unit_addr, attach_space, attach_addr, client) \
#define hw_unit_address_to_attach_address(bus, unit_addr, attach_space, attach_addr, client) \
((bus)->to_unit_address_to_attach_address (bus, unit_addr, attach_space, attach_addr, client))
((bus)->to_unit_address_to_attach_address (bus, unit_addr, attach_space, attach_addr, client))
 
 
#define set_hw_unit_address_to_attach_address(hw, method) \
#define set_hw_unit_address_to_attach_address(hw, method) \
((hw)->to_unit_address_to_attach_address = (method))
((hw)->to_unit_address_to_attach_address = (method))
 
 
typedef int (hw_unit_size_to_attach_size_method)
typedef int (hw_unit_size_to_attach_size_method)
     (struct hw *bus,
     (struct hw *bus,
      const hw_unit *unit_size,
      const hw_unit *unit_size,
      unsigned *attach_size,
      unsigned *attach_size,
      struct hw *client);
      struct hw *client);
 
 
#define hw_unit_size_to_attach_size(bus, unit_size, attach_size, client) \
#define hw_unit_size_to_attach_size(bus, unit_size, attach_size, client) \
((bus)->to_unit_size_to_attach_size (bus, unit_size, attach_size, client))
((bus)->to_unit_size_to_attach_size (bus, unit_size, attach_size, client))
 
 
#define set_hw_unit_size_to_attach_size(hw, method) \
#define set_hw_unit_size_to_attach_size(hw, method) \
((hw)->to_unit_size_to_attach_size = (method))
((hw)->to_unit_size_to_attach_size = (method))
 
 


extern char *hw_strdup (struct hw *me, const char *str);
extern char *hw_strdup (struct hw *me, const char *str);
 
 


/* Utilities:
/* Utilities:
 
 
   */
   */
 
 
/* IOCTL::
/* IOCTL::
 
 
   Often devices require `out of band' operations to be performed.
   Often devices require `out of band' operations to be performed.
   For instance a pal device may need to notify a PCI bridge device
   For instance a pal device may need to notify a PCI bridge device
   that an interrupt ack cycle needs to be performed on the PCI bus.
   that an interrupt ack cycle needs to be performed on the PCI bus.
   Within PSIM such operations are performed by using the generic
   Within PSIM such operations are performed by using the generic
   ioctl call <<hw_ioctl()>>.
   ioctl call <<hw_ioctl()>>.
 
 
   */
   */
 
 
typedef enum {
typedef enum {
  hw_ioctl_break, /* unsigned_word requested_break */
  hw_ioctl_break, /* unsigned_word requested_break */
  hw_ioctl_set_trace, /* void */
  hw_ioctl_set_trace, /* void */
  hw_ioctl_create_stack, /* unsigned_word *sp, char **argv, char **envp */
  hw_ioctl_create_stack, /* unsigned_word *sp, char **argv, char **envp */
  hw_ioctl_change_media, /* const char *new_image (possibly NULL) */
  hw_ioctl_change_media, /* const char *new_image (possibly NULL) */
  nr_hw_ioctl_requests,
  nr_hw_ioctl_requests,
} hw_ioctl_request;
} hw_ioctl_request;
 
 
typedef int (hw_ioctl_method)
typedef int (hw_ioctl_method)
     (struct hw *me,
     (struct hw *me,
      hw_ioctl_request request,
      hw_ioctl_request request,
      va_list ap);
      va_list ap);
 
 
int hw_ioctl
int hw_ioctl
(struct hw *me,
(struct hw *me,
 hw_ioctl_request request,
 hw_ioctl_request request,
 ...);
 ...);
 
 
 
 
/* Error reporting::
/* Error reporting::
 
 
   So that errors originating from devices appear in a consistent
   So that errors originating from devices appear in a consistent
   format, the <<hw_abort()>> function can be used.  Formats and
   format, the <<hw_abort()>> function can be used.  Formats and
   outputs the error message before aborting the simulation
   outputs the error message before aborting the simulation
 
 
   Devices should use this function to abort the simulation except
   Devices should use this function to abort the simulation except
   when the abort reason leaves the simulation in a hazardous
   when the abort reason leaves the simulation in a hazardous
   condition (for instance a failed malloc).
   condition (for instance a failed malloc).
 
 
   */
   */
 
 
void hw_abort
void hw_abort
(struct hw *me,
(struct hw *me,
 const char *fmt,
 const char *fmt,
 ...) __attribute__ ((format (printf, 2, 3)));
 ...) __attribute__ ((format (printf, 2, 3)));
 
 
void hw_vabort
void hw_vabort
(struct hw *me,
(struct hw *me,
 const char *fmt,
 const char *fmt,
 va_list ap);
 va_list ap);
 
 
void hw_halt
void hw_halt
(struct hw *me,
(struct hw *me,
 int reason,
 int reason,
 int status);
 int status);
 
 
 
 
#define hw_trace_p(hw) ((hw)->trace_of_hw_p + 0)
#define hw_trace_p(hw) ((hw)->trace_of_hw_p + 0)
 
 
void hw_trace
void hw_trace
(struct hw *me,
(struct hw *me,
 const char *fmt,
 const char *fmt,
 ...) __attribute__ ((format (printf, 2, 3)));
 ...) __attribute__ ((format (printf, 2, 3)));
 
 
#define HW_TRACE(ARGS) \
#define HW_TRACE(ARGS) \
do { \
do { \
  if (hw_trace_p (me)) \
  if (hw_trace_p (me)) \
    { \
    { \
      hw_trace ARGS; \
      hw_trace ARGS; \
    } \
    } \
} while (0)
} while (0)
 
 
 
 
/* Some of the related functions require specific types */
/* Some of the related functions require specific types */
 
 
struct hw_property_data;
struct hw_property_data;
struct hw_port_data;
struct hw_port_data;
struct hw_base_data;
struct hw_base_data;
struct hw_alloc_data;
struct hw_alloc_data;
struct hw_event_data;
struct hw_event_data;
struct hw_handle_data;
struct hw_handle_data;
struct hw_instance_data;
struct hw_instance_data;
 
 
/* Finally the hardware device - keep your grubby little mits off of
/* Finally the hardware device - keep your grubby little mits off of
   these internals! :-) */
   these internals! :-) */
 
 
struct hw {
struct hw {
 
 
  /* our relatives */
  /* our relatives */
  struct hw *parent_of_hw;
  struct hw *parent_of_hw;
  struct hw *sibling_of_hw;
  struct hw *sibling_of_hw;
  struct hw *child_of_hw;
  struct hw *child_of_hw;
 
 
  /* our identity */
  /* our identity */
  const char *name_of_hw;
  const char *name_of_hw;
  const char *family_of_hw;
  const char *family_of_hw;
  const char *args_of_hw;
  const char *args_of_hw;
  const char *path_of_hw;
  const char *path_of_hw;
 
 
  /* our data */
  /* our data */
  void *data_of_hw;
  void *data_of_hw;
 
 
  /* hot links */
  /* hot links */
  struct hw *root_of_hw;
  struct hw *root_of_hw;
  struct sim_state *system_of_hw;
  struct sim_state *system_of_hw;
 
 
  /* identifying data */
  /* identifying data */
  hw_unit unit_address_of_hw;
  hw_unit unit_address_of_hw;
  int nr_address_cells_of_hw_unit;
  int nr_address_cells_of_hw_unit;
  int nr_size_cells_of_hw_unit;
  int nr_size_cells_of_hw_unit;
 
 
  /* Soft reset */
  /* Soft reset */
  hw_reset_method *to_reset;
  hw_reset_method *to_reset;
 
 
  /* Basic callbacks */
  /* Basic callbacks */
  hw_io_read_buffer_method *to_io_read_buffer;
  hw_io_read_buffer_method *to_io_read_buffer;
  hw_io_write_buffer_method *to_io_write_buffer;
  hw_io_write_buffer_method *to_io_write_buffer;
  hw_dma_read_buffer_method *to_dma_read_buffer;
  hw_dma_read_buffer_method *to_dma_read_buffer;
  hw_dma_write_buffer_method *to_dma_write_buffer;
  hw_dma_write_buffer_method *to_dma_write_buffer;
  hw_attach_address_method *to_attach_address;
  hw_attach_address_method *to_attach_address;
  hw_detach_address_method *to_detach_address;
  hw_detach_address_method *to_detach_address;
 
 
  /* More complicated callbacks */
  /* More complicated callbacks */
  hw_ioctl_method *to_ioctl;
  hw_ioctl_method *to_ioctl;
  int trace_of_hw_p;
  int trace_of_hw_p;
 
 
  /* address callbacks */
  /* address callbacks */
  hw_unit_decode_method *to_unit_decode;
  hw_unit_decode_method *to_unit_decode;
  hw_unit_encode_method *to_unit_encode;
  hw_unit_encode_method *to_unit_encode;
  hw_unit_address_to_attach_address_method *to_unit_address_to_attach_address;
  hw_unit_address_to_attach_address_method *to_unit_address_to_attach_address;
  hw_unit_size_to_attach_size_method *to_unit_size_to_attach_size;
  hw_unit_size_to_attach_size_method *to_unit_size_to_attach_size;
 
 
  /* related data */
  /* related data */
  struct hw_property_data *properties_of_hw;
  struct hw_property_data *properties_of_hw;
  struct hw_port_data *ports_of_hw;
  struct hw_port_data *ports_of_hw;
  struct hw_base_data *base_of_hw;
  struct hw_base_data *base_of_hw;
  struct hw_alloc_data *alloc_of_hw;
  struct hw_alloc_data *alloc_of_hw;
  struct hw_event_data *events_of_hw;
  struct hw_event_data *events_of_hw;
  struct hw_handle_data *handles_of_hw;
  struct hw_handle_data *handles_of_hw;
  struct hw_instance_data *instances_of_hw;
  struct hw_instance_data *instances_of_hw;
 
 
};
};
 
 
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.