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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [sim/] [ppc/] [hw_core.c] - Diff between revs 827 and 840

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 827 Rev 840
/*  This file is part of the program psim.
/*  This file is part of the program psim.
 
 
    Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
    Copyright (C) 1994-1996, 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 _HW_CORE_C_
#ifndef _HW_CORE_C_
#define _HW_CORE_C_
#define _HW_CORE_C_
 
 
#include "device_table.h"
#include "device_table.h"
 
 
#include "corefile.h"
#include "corefile.h"
 
 
 
 
/* DEVICE
/* DEVICE
 
 
   core - root of the device tree
   core - root of the device tree
 
 
   DESCRIPTION
   DESCRIPTION
 
 
   The core device positioned at the root of the device tree appears
   The core device positioned at the root of the device tree appears
   to its child devices as a normal device just like every other
   to its child devices as a normal device just like every other
   device in the tree.
   device in the tree.
 
 
   Internally it is implemented using a core object.  Requests to
   Internally it is implemented using a core object.  Requests to
   attach (or detach) address spaces are passed to that core object.
   attach (or detach) address spaces are passed to that core object.
   Requests to transfer (DMA) data are reflected back down the device
   Requests to transfer (DMA) data are reflected back down the device
   tree using the core_map data transfer methods.
   tree using the core_map data transfer methods.
 
 
   PROPERTIES
   PROPERTIES
 
 
   None.
   None.
 
 
   */
   */
 
 
 
 
static void
static void
hw_core_init_address_callback(device *me)
hw_core_init_address_callback(device *me)
{
{
  core *memory = (core*)device_data(me);
  core *memory = (core*)device_data(me);
  core_init(memory);
  core_init(memory);
}
}
 
 
 
 
static void
static void
hw_core_attach_address_callback(device *me,
hw_core_attach_address_callback(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*/
{
{
  core *memory = (core*)device_data(me);
  core *memory = (core*)device_data(me);
  if (space != 0)
  if (space != 0)
    error("core_attach_address_callback() invalid address space\n");
    error("core_attach_address_callback() invalid address space\n");
  core_attach(memory,
  core_attach(memory,
              attach,
              attach,
              space,
              space,
              access,
              access,
              addr,
              addr,
              nr_bytes,
              nr_bytes,
              client);
              client);
}
}
 
 
 
 
static unsigned
static unsigned
hw_core_dma_read_buffer_callback(device *me,
hw_core_dma_read_buffer_callback(device *me,
                                 void *dest,
                                 void *dest,
                                 int space,
                                 int space,
                                 unsigned_word addr,
                                 unsigned_word addr,
                                 unsigned nr_bytes)
                                 unsigned nr_bytes)
{
{
  core *memory = (core*)device_data(me);
  core *memory = (core*)device_data(me);
  return core_map_read_buffer(core_readable(memory),
  return core_map_read_buffer(core_readable(memory),
                              dest,
                              dest,
                              addr,
                              addr,
                              nr_bytes);
                              nr_bytes);
}
}
 
 
 
 
static unsigned
static unsigned
hw_core_dma_write_buffer_callback(device *me,
hw_core_dma_write_buffer_callback(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)
{
{
  core *memory = (core*)device_data(me);
  core *memory = (core*)device_data(me);
  core_map *map = (violate_read_only_section
  core_map *map = (violate_read_only_section
                   ? core_readable(memory)
                   ? core_readable(memory)
                   : core_writeable(memory));
                   : core_writeable(memory));
  return core_map_write_buffer(map,
  return core_map_write_buffer(map,
                               source,
                               source,
                               addr,
                               addr,
                               nr_bytes);
                               nr_bytes);
}
}
 
 
static device_callbacks const hw_core_callbacks = {
static device_callbacks const hw_core_callbacks = {
  { hw_core_init_address_callback, },
  { hw_core_init_address_callback, },
  { hw_core_attach_address_callback, },
  { hw_core_attach_address_callback, },
  { NULL, }, /* IO */
  { NULL, }, /* IO */
  { hw_core_dma_read_buffer_callback,
  { hw_core_dma_read_buffer_callback,
    hw_core_dma_write_buffer_callback, },
    hw_core_dma_write_buffer_callback, },
  { NULL, }, /* interrupt */
  { NULL, }, /* interrupt */
  { generic_device_unit_decode,
  { generic_device_unit_decode,
    generic_device_unit_encode,
    generic_device_unit_encode,
    generic_device_address_to_attach_address,
    generic_device_address_to_attach_address,
    generic_device_size_to_attach_size, },
    generic_device_size_to_attach_size, },
};
};
 
 
 
 
static void *
static void *
hw_core_create(const char *name,
hw_core_create(const char *name,
               const device_unit *unit_address,
               const device_unit *unit_address,
               const char *args)
               const char *args)
{
{
  core *memory = core_create();
  core *memory = core_create();
  return memory;
  return memory;
}
}
 
 
const device_descriptor hw_core_device_descriptor[] = {
const device_descriptor hw_core_device_descriptor[] = {
  { "core", hw_core_create, &hw_core_callbacks },
  { "core", hw_core_create, &hw_core_callbacks },
  { NULL },
  { NULL },
};
};
 
 
#endif /* _HW_CORE_C_ */
#endif /* _HW_CORE_C_ */
 
 

powered by: WebSVN 2.1.0

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