OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [sim/] [ppc/] [device.h] - Diff between revs 157 and 223

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

Rev 157 Rev 223
/*  This file is part of the program psim.
/*  This file is part of the program psim.
 
 
    Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
    Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
 
 
    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 2 of the License, or
    the Free Software Foundation; either version 2 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, write to the Free Software
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
    */
    */
 
 
 
 
#ifndef _DEVICE_H_
#ifndef _DEVICE_H_
#define _DEVICE_H_
#define _DEVICE_H_
 
 
#ifndef INLINE_DEVICE
#ifndef INLINE_DEVICE
#define INLINE_DEVICE
#define INLINE_DEVICE
#endif
#endif
 
 
/* declared in basics.h, this object is used everywhere */
/* declared in 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 interrupts lie at the heart of PSIM's device model.
   property and interrupts 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.  Details of this object can be found in the
   supports are given.  Details of this object can be found in the
   files <<device.h>> and <<device.c>>.
   files <<device.h>> and <<device.c>>.
 
 
   */
   */
 
 
 
 
/* Device creation: */
/* Device creation: */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device *) device_create
(device *) device_create
(device *parent,
(device *parent,
 const char *base,
 const char *base,
 const char *name,
 const char *name,
 const char *unit_address,
 const char *unit_address,
 const char *args);
 const char *args);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_usage
(void) device_usage
(int verbose);
(int verbose);
 
 
 
 
/* Device initialization: */
/* Device initialization: */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_clean
(void) device_clean
(device *root,
(device *root,
 void *data);
 void *data);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_init_static_properties
(void) device_init_static_properties
(device *me,
(device *me,
 void *data);
 void *data);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_init_address
(void) device_init_address
(device *me,
(device *me,
 void *data);
 void *data);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_init_runtime_properties
(void) device_init_runtime_properties
(device *me,
(device *me,
 void *data);
 void *data);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_init_data
(void) device_init_data
(device *me,
(device *me,
 void *data);
 void *data);
 
 
 
 
/* 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).
 
 
   */
   */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device *) device_parent
(device *) device_parent
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device *) device_root
(device *) device_root
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device *) device_sibling
(device *) device_sibling
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device *) device_child
(device *) device_child
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const char *) device_name
(const char *) device_name
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const char *) device_base
(const char *) device_base
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const char *) device_path
(const char *) device_path
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void *) device_data
(void *) device_data
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(psim *) device_system
(psim *) device_system
(device *me);
(device *me);
 
 
typedef struct _device_unit {
typedef struct _device_unit {
  int nr_cells;
  int nr_cells;
  unsigned_cell cells[4]; /* unused cells are zero */
  unsigned_cell cells[4]; /* unused cells are zero */
} device_unit;
} device_unit;
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const device_unit *) device_unit_address
(const device_unit *) device_unit_address
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_decode_unit
(int) device_decode_unit
(device *bus,
(device *bus,
 const char *unit,
 const char *unit,
 device_unit *address);
 device_unit *address);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_encode_unit
(int) device_encode_unit
(device *bus,
(device *bus,
 const device_unit *unit_address,
 const device_unit *unit_address,
 char *buf,
 char *buf,
 int sizeof_buf);
 int sizeof_buf);
 
 
 
 
/* Convert an Open Firmware size into a form suitable for attach
/* Convert an Open Firmware size into a form suitable for attach
   address calls.
   address calls.
 
 
   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 */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_address_to_attach_address
(int) device_address_to_attach_address
(device *me,
(device *me,
 const device_unit *address,
 const device_unit *address,
 int *attach_space,
 int *attach_space,
 unsigned_word *attach_address,
 unsigned_word *attach_address,
 device *client);
 device *client);
 
 
 
 
/* Convert an Open Firmware size into a form suitable for attach
/* Convert an Open Firmware size into a form suitable for attach
   address calls
   address calls
 
 
   Return a zero result if the address should be ignored */
   Return a zero result if the address should be ignored */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_size_to_attach_size
(int) device_size_to_attach_size
(device *me,
(device *me,
 const device_unit *size,
 const device_unit *size,
 unsigned *nr_bytes,
 unsigned *nr_bytes,
 device *client);
 device *client);
 
 
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned) device_nr_address_cells
(unsigned) device_nr_address_cells
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned) device_nr_size_cells
(unsigned) device_nr_size_cells
(device *me);
(device *me);
 
 
 
 
/* Properties:
/* Properties:
 
 
   Attached to a device are a number of properties.  Each property has
   Attached to a device are a number of properties.  Each property has
   a size and type (both of which can be queried).  A device is able
   a size and type (both of which can be queried).  A device is able
   to iterate over or query and set a properties value.
   to iterate over or query and set a properties value.
 
 
   */
   */
 
 
/* The following are valid property types.  The property `array' is
/* The following are valid property types.  The property `array' is
   for generic untyped data. */
   for generic untyped data. */
 
 
typedef enum {
typedef enum {
  array_property,
  array_property,
  boolean_property,
  boolean_property,
  ihandle_property, /*runtime*/
  ihandle_property, /*runtime*/
  integer_property,
  integer_property,
  range_array_property,
  range_array_property,
  reg_array_property,
  reg_array_property,
  string_property,
  string_property,
  string_array_property,
  string_array_property,
} device_property_type;
} device_property_type;
 
 
typedef struct _device_property device_property;
typedef struct _device_property device_property;
struct _device_property {
struct _device_property {
  device *owner;
  device *owner;
  const char *name;
  const char *name;
  device_property_type type;
  device_property_type type;
  unsigned sizeof_array;
  unsigned sizeof_array;
  const void *array;
  const void *array;
  const device_property *original;
  const device_property *original;
  object_disposition disposition;
  object_disposition disposition;
};
};
 
 
 
 
/* iterate through the properties attached to a device */
/* iterate through the properties attached to a device */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const device_property *) device_next_property
(const device_property *) device_next_property
(const device_property *previous);
(const device_property *previous);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const device_property *) device_find_property
(const device_property *) device_find_property
(device *me,
(device *me,
 const char *property); /* NULL for first property */
 const char *property); /* NULL for first property */
 
 
 
 
/* Manipulate the properties belonging to a given device.
/* Manipulate the properties belonging to a given device.
 
 
   SET on the other hand will force the properties value.  The
   SET on the other hand will force the properties value.  The
   simulation is aborted if the property was present but of a
   simulation is aborted if the property was present but of a
   conflicting type.
   conflicting type.
 
 
   FIND returns the specified properties value, aborting the
   FIND returns the specified properties value, aborting the
   simulation if the property is missing.  Code locating a property
   simulation if the property is missing.  Code locating a property
   should first check its type (using device_find_property above) and
   should first check its type (using device_find_property above) and
   then obtain its value using the below.
   then obtain its value using the below.
 
 
   void device_add_<type>_property(device *, const char *, <type>)
   void device_add_<type>_property(device *, const char *, <type>)
   void device_add_*_array_property(device *, const char *, const <type>*, int)
   void device_add_*_array_property(device *, const char *, const <type>*, int)
   void device_set_*_property(device *, const char *, <type>)
   void device_set_*_property(device *, const char *, <type>)
   void device_set_*_array_property(device *, const char *, const <type>*, int)
   void device_set_*_array_property(device *, const char *, const <type>*, int)
   <type> device_find_*_property(device *, const char *)
   <type> device_find_*_property(device *, const char *)
   int device_find_*_array_property(device *, const char *, int, <type>*)
   int device_find_*_array_property(device *, const char *, int, <type>*)
 
 
   */
   */
 
 
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_array_property
(void) device_add_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const void *array,
 const void *array,
 int sizeof_array);
 int sizeof_array);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_set_array_property
(void) device_set_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const void *array,
 const void *array,
 int sizeof_array);
 int sizeof_array);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const device_property *) device_find_array_property
(const device_property *) device_find_array_property
(device *me,
(device *me,
 const char *property);
 const char *property);
 
 
 
 
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_boolean_property
(void) device_add_boolean_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 int bool);
 int bool);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_find_boolean_property
(int) device_find_boolean_property
(device *me,
(device *me,
 const char *property);
 const char *property);
 
 
 
 
 
 
typedef struct _ihandle_runtime_property_spec {
typedef struct _ihandle_runtime_property_spec {
  const char *full_path;
  const char *full_path;
} ihandle_runtime_property_spec;
} ihandle_runtime_property_spec;
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_ihandle_runtime_property
(void) device_add_ihandle_runtime_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const ihandle_runtime_property_spec *ihandle);
 const ihandle_runtime_property_spec *ihandle);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_find_ihandle_runtime_property
(void) device_find_ihandle_runtime_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 ihandle_runtime_property_spec *ihandle);
 ihandle_runtime_property_spec *ihandle);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_set_ihandle_property
(void) device_set_ihandle_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 device_instance *ihandle);
 device_instance *ihandle);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device_instance *) device_find_ihandle_property
(device_instance *) device_find_ihandle_property
(device *me,
(device *me,
 const char *property);
 const char *property);
 
 
 
 
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_integer_property
(void) device_add_integer_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 signed_cell integer);
 signed_cell integer);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(signed_cell) device_find_integer_property
(signed_cell) device_find_integer_property
(device *me,
(device *me,
 const char *property);
 const char *property);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_find_integer_array_property
(int) device_find_integer_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 unsigned index,
 unsigned index,
 signed_cell *integer);
 signed_cell *integer);
 
 
 
 
 
 
typedef struct _range_property_spec {
typedef struct _range_property_spec {
  device_unit child_address;
  device_unit child_address;
  device_unit parent_address;
  device_unit parent_address;
  device_unit size;
  device_unit size;
} range_property_spec;
} range_property_spec;
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_range_array_property
(void) device_add_range_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const range_property_spec *ranges,
 const range_property_spec *ranges,
 unsigned nr_ranges);
 unsigned nr_ranges);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_find_range_array_property
(int) device_find_range_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 unsigned index,
 unsigned index,
 range_property_spec *range);
 range_property_spec *range);
 
 
 
 
 
 
typedef struct _reg_property_spec {
typedef struct _reg_property_spec {
  device_unit address;
  device_unit address;
  device_unit size;
  device_unit size;
} reg_property_spec;
} reg_property_spec;
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_reg_array_property
(void) device_add_reg_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const reg_property_spec *reg,
 const reg_property_spec *reg,
 unsigned nr_regs);
 unsigned nr_regs);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_find_reg_array_property
(int) device_find_reg_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 unsigned index,
 unsigned index,
 reg_property_spec *reg);
 reg_property_spec *reg);
 
 
 
 
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_string_property
(void) device_add_string_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const char *string);
 const char *string);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const char *) device_find_string_property
(const char *) device_find_string_property
(device *me,
(device *me,
 const char *property);
 const char *property);
 
 
 
 
 
 
typedef const char *string_property_spec;
typedef const char *string_property_spec;
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_string_array_property
(void) device_add_string_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const string_property_spec *strings,
 const string_property_spec *strings,
 unsigned nr_strings);
 unsigned nr_strings);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_find_string_array_property
(int) device_find_string_array_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 unsigned index,
 unsigned index,
 string_property_spec *string);
 string_property_spec *string);
 
 
 
 
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_add_duplicate_property
(void) device_add_duplicate_property
(device *me,
(device *me,
 const char *property,
 const char *property,
 const device_property *original);
 const device_property *original);
 
 
 
 
 
 
/* Instances:
/* Instances:
 
 
   As with IEEE1275, a device can be opened, creating an instance.
   As with IEEE1275, a device can be opened, creating an instance.
   Instances provide more abstract interfaces to the underlying
   Instances provide more abstract interfaces to the underlying
   hardware.  For example, the instance methods for a disk may include
   hardware.  For example, the instance methods for a disk may include
   code that is able to interpret file systems found on disks.  Such
   code that is able to interpret file systems found on disks.  Such
   methods would there for allow the manipulation of files on the
   methods would there for allow the manipulation of files on the
   disks file system.  The operations would be implemented using the
   disks file system.  The operations would be implemented using the
   basic block I/O model provided by the disk.
   basic block I/O model provided by the disk.
 
 
   This model includes methods that faciliate the creation of device
   This model includes methods that faciliate the creation of device
   instance and (should a given device support it) standard operations
   instance and (should a given device support it) standard operations
   on those instances.
   on those instances.
 
 
   */
   */
 
 
typedef struct _device_instance_callbacks device_instance_callbacks;
typedef struct _device_instance_callbacks device_instance_callbacks;
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device_instance *) device_create_instance_from
(device_instance *) device_create_instance_from
(device *me, /*OR*/ device_instance *parent,
(device *me, /*OR*/ device_instance *parent,
 void *data,
 void *data,
 const char *path,
 const char *path,
 const char *args,
 const char *args,
 const device_instance_callbacks *callbacks);
 const device_instance_callbacks *callbacks);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device_instance *) device_create_instance
(device_instance *) device_create_instance
(device *me,
(device *me,
 const char *full_path,
 const char *full_path,
 const char *args);
 const char *args);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_instance_delete
(void) device_instance_delete
(device_instance *instance);
(device_instance *instance);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_instance_read
(int) device_instance_read
(device_instance *instance,
(device_instance *instance,
 void *addr,
 void *addr,
 unsigned_word len);
 unsigned_word len);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_instance_write
(int) device_instance_write
(device_instance *instance,
(device_instance *instance,
 const void *addr,
 const void *addr,
 unsigned_word len);
 unsigned_word len);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_instance_seek
(int) device_instance_seek
(device_instance *instance,
(device_instance *instance,
 unsigned_word pos_hi,
 unsigned_word pos_hi,
 unsigned_word pos_lo);
 unsigned_word pos_lo);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_instance_call_method
(int) device_instance_call_method
(device_instance *instance,
(device_instance *instance,
 const char *method,
 const char *method,
 int n_stack_args,
 int n_stack_args,
 unsigned_cell stack_args[/*n_stack_args*/],
 unsigned_cell stack_args[/*n_stack_args*/],
 int n_stack_returns,
 int n_stack_returns,
 unsigned_cell stack_returns[/*n_stack_returns*/]);
 unsigned_cell stack_returns[/*n_stack_returns*/]);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device *) device_instance_device
(device *) device_instance_device
(device_instance *instance);
(device_instance *instance);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(const char *) device_instance_path
(const char *) device_instance_path
(device_instance *instance);
(device_instance *instance);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void *) device_instance_data
(void *) device_instance_data
(device_instance *instance);
(device_instance *instance);
 
 
 
 
/* Interrupts:
/* Interrupts:
 
 
   */
   */
 
 
/* Interrupt Source
/* Interrupt Source
 
 
   A device drives its interrupt line using the call
   A device drives its interrupt line using the call
 
 
   */
   */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_interrupt_event
(void) device_interrupt_event
(device *me,
(device *me,
 int my_port,
 int my_port,
 int value,
 int value,
 cpu *processor,
 cpu *processor,
 unsigned_word cia);
 unsigned_word cia);
 
 
/* This interrupt event will then be propogated to any attached
/* This interrupt event will then be propogated to any attached
   interrupt destinations.
   interrupt destinations.
 
 
   Any interpretation of PORT and VALUE is model dependant.  However
   Any interpretation of PORT and VALUE is model dependant.  However
   as guidelines the following are recommended: PCI interrupts a-d
   as guidelines the following are recommended: PCI interrupts a-d
   correspond to lines 0-3; level sensative interrupts be requested
   correspond to lines 0-3; level sensative interrupts be requested
   with a value of one and withdrawn with a value of 0; edge sensative
   with a value of one and withdrawn with a value of 0; edge sensative
   interrupts always have a value of 1, the event its self is treated
   interrupts always have a value of 1, the event its self is treated
   as the interrupt.
   as the interrupt.
 
 
 
 
   Interrupt Destinations
   Interrupt Destinations
 
 
   Attached to each interrupt line of a device can be zero or more
   Attached to each interrupt line of a device can be zero or more
   desitinations.  These destinations consist of a device/port pair.
   desitinations.  These destinations consist of a device/port pair.
   A destination is attached/detached to a device line using the
   A destination is attached/detached to a device line using the
   attach and detach calls. */
   attach and detach calls. */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_interrupt_attach
(void) device_interrupt_attach
(device *me,
(device *me,
 int my_port,
 int my_port,
 device *dest,
 device *dest,
 int dest_port,
 int dest_port,
 object_disposition disposition);
 object_disposition disposition);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_interrupt_detach
(void) device_interrupt_detach
(device *me,
(device *me,
 int my_port,
 int my_port,
 device *dest,
 device *dest,
 int dest_port);
 int dest_port);
 
 
typedef void (device_interrupt_traverse_function)
typedef void (device_interrupt_traverse_function)
     (device *me,
     (device *me,
      int my_port,
      int my_port,
      device *dest,
      device *dest,
      int my_dest,
      int my_dest,
      void *data);
      void *data);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_interrupt_traverse
(void) device_interrupt_traverse
(device *me,
(device *me,
 device_interrupt_traverse_function *handler,
 device_interrupt_traverse_function *handler,
 void *data);
 void *data);
 
 
 
 
/* DESTINATION is attached (detached) to LINE of the device ME
/* DESTINATION is attached (detached) to LINE of the device ME
 
 
 
 
   Interrupt conversion
   Interrupt conversion
 
 
   Users refer to interrupt port numbers symbolically.  For instance a
   Users refer to interrupt port numbers symbolically.  For instance a
   device may refer to its `INT' signal which is internally
   device may refer to its `INT' signal which is internally
   represented by port 3.
   represented by port 3.
 
 
   To convert to/from the symbolic and internal representation of a
   To convert to/from the symbolic and internal representation of a
   port name/number.  The following functions are available. */
   port name/number.  The following functions are available. */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_interrupt_decode
(int) device_interrupt_decode
(device *me,
(device *me,
 const char *symbolic_name,
 const char *symbolic_name,
 port_direction direction);
 port_direction direction);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_interrupt_encode
(int) device_interrupt_encode
(device *me,
(device *me,
 int port_number,
 int port_number,
 char *buf,
 char *buf,
 int sizeof_buf,
 int sizeof_buf,
 port_direction direction);
 port_direction direction);
 
 
 
 
/* Hardware operations:
/* Hardware operations:
 
 
   */
   */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned) device_io_read_buffer
(unsigned) device_io_read_buffer
(device *me,
(device *me,
 void *dest,
 void *dest,
 int space,
 int space,
 unsigned_word addr,
 unsigned_word addr,
 unsigned nr_bytes,
 unsigned nr_bytes,
 cpu *processor,
 cpu *processor,
 unsigned_word cia);
 unsigned_word cia);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned) device_io_write_buffer
(unsigned) device_io_write_buffer
(device *me,
(device *me,
 const void *source,
 const void *source,
 int space,
 int space,
 unsigned_word addr,
 unsigned_word addr,
 unsigned nr_bytes,
 unsigned nr_bytes,
 cpu *processor,
 cpu *processor,
 unsigned_word cia);
 unsigned_word cia);
 
 
 
 
/* Conversly, the device pci1000,1@1 my need to perform a dma transfer
/* Conversly, the device pci1000,1@1 my 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 */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned) device_dma_read_buffer
(unsigned) device_dma_read_buffer
(device *me,
(device *me,
 void *dest,
 void *dest,
 int space,
 int space,
 unsigned_word addr,
 unsigned_word addr,
 unsigned nr_bytes);
 unsigned nr_bytes);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned) device_dma_write_buffer
(unsigned) device_dma_write_buffer
(device *me,
(device *me,
 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);
 
 
/* To avoid the need for an intermediate (bridging) node to ask each
/* To avoid the need for an intermediate (bridging) node to ask each
   of its child devices in turn if an IO access is intended for them,
   of its child devices in turn if an IO access is intended for them,
   parent nodes maintain a table mapping addresses directly to
   parent nodes maintain a table mapping addresses directly to
   specific devices.  When a device is `connected' to its bus it
   specific devices.  When a device is `connected' to its bus it
   attaches its self to its parent. */
   attaches its self to its parent. */
 
 
/* Address access attributes */
/* Address access attributes */
typedef enum _access_type {
typedef enum _access_type {
  access_invalid = 0,
  access_invalid = 0,
  access_read = 1,
  access_read = 1,
  access_write = 2,
  access_write = 2,
  access_read_write = 3,
  access_read_write = 3,
  access_exec = 4,
  access_exec = 4,
  access_read_exec = 5,
  access_read_exec = 5,
  access_write_exec = 6,
  access_write_exec = 6,
  access_read_write_exec = 7,
  access_read_write_exec = 7,
} access_type;
} access_type;
 
 
/* Address attachement types */
/* Address attachement types */
typedef enum _attach_type {
typedef enum _attach_type {
  attach_invalid,
  attach_invalid,
  attach_raw_memory,
  attach_raw_memory,
  attach_callback,
  attach_callback,
  /* ... */
  /* ... */
} attach_type;
} attach_type;
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_attach_address
(void) device_attach_address
(device *me,
(device *me,
 attach_type attach,
 attach_type attach,
 int space,
 int space,
 unsigned_word addr,
 unsigned_word addr,
 unsigned nr_bytes,
 unsigned nr_bytes,
 access_type access,
 access_type access,
 device *client); /*callback/default*/
 device *client); /*callback/default*/
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(void) device_detach_address
(void) device_detach_address
(device *me,
(device *me,
 attach_type attach,
 attach_type attach,
 int space,
 int space,
 unsigned_word addr,
 unsigned_word addr,
 unsigned nr_bytes,
 unsigned nr_bytes,
 access_type access,
 access_type access,
 device *client); /*callback/default*/
 device *client); /*callback/default*/
 
 
/* 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 <<device_ioctl()>>.
   ioctl call <<device_ioctl()>>.
 
 
   */
   */
 
 
typedef enum {
typedef enum {
  device_ioctl_break, /* unsigned_word requested_break */
  device_ioctl_break, /* unsigned_word requested_break */
  device_ioctl_set_trace, /* void */
  device_ioctl_set_trace, /* void */
  device_ioctl_create_stack, /* unsigned_word *sp, char **argv, char **envp */
  device_ioctl_create_stack, /* unsigned_word *sp, char **argv, char **envp */
  device_ioctl_change_media, /* const char *new_image (possibly NULL) */
  device_ioctl_change_media, /* const char *new_image (possibly NULL) */
  nr_device_ioctl_requests,
  nr_device_ioctl_requests,
} device_ioctl_request;
} device_ioctl_request;
 
 
EXTERN_DEVICE\
EXTERN_DEVICE\
(int) device_ioctl
(int) device_ioctl
(device *me,
(device *me,
 cpu *processor,
 cpu *processor,
 unsigned_word cia,
 unsigned_word cia,
 device_ioctl_request request,
 device_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 <<device_error()>> function can be used.  Formats and
   format, the <<device_error()>> 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).
 
 
   */
   */
 
 
EXTERN_DEVICE\
EXTERN_DEVICE\
(void volatile) device_error
(void volatile) device_error
(device *me,
(device *me,
 const char *fmt,
 const char *fmt,
 ...) __attribute__ ((format (printf, 2, 3)));
 ...) __attribute__ ((format (printf, 2, 3)));
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(int) device_trace
(int) device_trace
(device *me);
(device *me);
 
 
 
 
 
 
/* External representation:
/* External representation:
 
 
   Both device nodes and device instances, in OpenBoot firmware have
   Both device nodes and device instances, in OpenBoot firmware have
   an external representation (phandles and ihandles) and these values
   an external representation (phandles and ihandles) and these values
   are both stored in the device tree in property nodes and passed
   are both stored in the device tree in property nodes and passed
   between the client program and the simulator during emulation
   between the client program and the simulator during emulation
   calls.
   calls.
 
 
   To limit the potential risk associated with trusing `data' from the
   To limit the potential risk associated with trusing `data' from the
   client program, the following mapping operators `safely' convert
   client program, the following mapping operators `safely' convert
   between the two representations
   between the two representations
 
 
   */
   */
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device *) external_to_device
(device *) external_to_device
(device *tree_member,
(device *tree_member,
 unsigned_cell phandle);
 unsigned_cell phandle);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned_cell) device_to_external
(unsigned_cell) device_to_external
(device *me);
(device *me);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(device_instance *) external_to_device_instance
(device_instance *) external_to_device_instance
(device *tree_member,
(device *tree_member,
 unsigned_cell ihandle);
 unsigned_cell ihandle);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(unsigned_cell) device_instance_to_external
(unsigned_cell) device_instance_to_external
(device_instance *me);
(device_instance *me);
 
 
 
 
/* Event queue:
/* Event queue:
 
 
   The device inherets certain event queue operations from the main
   The device inherets certain event queue operations from the main
   simulation. */
   simulation. */
 
 
typedef void device_event_handler(void *data);
typedef void device_event_handler(void *data);
 
 
INLINE_DEVICE\
INLINE_DEVICE\
(event_entry_tag) device_event_queue_schedule
(event_entry_tag) device_event_queue_schedule
(device *me,
(device *me,
 signed64 delta_time,
 signed64 delta_time,
 device_event_handler *handler,
 device_event_handler *handler,
 void *data);
 void *data);
 
 
INLINE_EVENTS\
INLINE_EVENTS\
(void) device_event_queue_deschedule
(void) device_event_queue_deschedule
(device *me,
(device *me,
 event_entry_tag event_to_remove);
 event_entry_tag event_to_remove);
 
 
INLINE_EVENTS\
INLINE_EVENTS\
(signed64) device_event_queue_time
(signed64) device_event_queue_time
(device *me);
(device *me);
 
 
#endif /* _DEVICE_H_ */
#endif /* _DEVICE_H_ */
 
 

powered by: WebSVN 2.1.0

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