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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [sim/] [ppc/] [hw_core.c] - Blame information for rev 481

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/*  This file is part of the program psim.
2
 
3
    Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
4
 
5
    This program is free software; you can redistribute it and/or modify
6
    it under the terms of the GNU General Public License as published by
7
    the Free Software Foundation; either version 2 of the License, or
8
    (at your option) any later version.
9
 
10
    This program is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    GNU General Public License for more details.
14
 
15
    You should have received a copy of the GNU General Public License
16
    along with this program; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 
19
    */
20
 
21
 
22
#ifndef _HW_CORE_C_
23
#define _HW_CORE_C_
24
 
25
#include "device_table.h"
26
 
27
#include "corefile.h"
28
 
29
 
30
/* DEVICE
31
 
32
   core - root of the device tree
33
 
34
   DESCRIPTION
35
 
36
   The core device positioned at the root of the device tree appears
37
   to its child devices as a normal device just like every other
38
   device in the tree.
39
 
40
   Internally it is implemented using a core object.  Requests to
41
   attach (or detach) address spaces are passed to that core object.
42
   Requests to transfer (DMA) data are reflected back down the device
43
   tree using the core_map data transfer methods.
44
 
45
   PROPERTIES
46
 
47
   None.
48
 
49
   */
50
 
51
 
52
static void
53
hw_core_init_address_callback(device *me)
54
{
55
  core *memory = (core*)device_data(me);
56
  core_init(memory);
57
}
58
 
59
 
60
static void
61
hw_core_attach_address_callback(device *me,
62
                                attach_type attach,
63
                                int space,
64
                                unsigned_word addr,
65
                                unsigned nr_bytes,
66
                                access_type access,
67
                                device *client) /*callback/default*/
68
{
69
  core *memory = (core*)device_data(me);
70
  if (space != 0)
71
    error("core_attach_address_callback() invalid address space\n");
72
  core_attach(memory,
73
              attach,
74
              space,
75
              access,
76
              addr,
77
              nr_bytes,
78
              client);
79
}
80
 
81
 
82
static unsigned
83
hw_core_dma_read_buffer_callback(device *me,
84
                                 void *dest,
85
                                 int space,
86
                                 unsigned_word addr,
87
                                 unsigned nr_bytes)
88
{
89
  core *memory = (core*)device_data(me);
90
  return core_map_read_buffer(core_readable(memory),
91
                              dest,
92
                              addr,
93
                              nr_bytes);
94
}
95
 
96
 
97
static unsigned
98
hw_core_dma_write_buffer_callback(device *me,
99
                                  const void *source,
100
                                  int space,
101
                                  unsigned_word addr,
102
                                  unsigned nr_bytes,
103
                                  int violate_read_only_section)
104
{
105
  core *memory = (core*)device_data(me);
106
  core_map *map = (violate_read_only_section
107
                   ? core_readable(memory)
108
                   : core_writeable(memory));
109
  return core_map_write_buffer(map,
110
                               source,
111
                               addr,
112
                               nr_bytes);
113
}
114
 
115
static device_callbacks const hw_core_callbacks = {
116
  { hw_core_init_address_callback, },
117
  { hw_core_attach_address_callback, },
118
  { NULL, }, /* IO */
119
  { hw_core_dma_read_buffer_callback,
120
    hw_core_dma_write_buffer_callback, },
121
  { NULL, }, /* interrupt */
122
  { generic_device_unit_decode,
123
    generic_device_unit_encode,
124
    generic_device_address_to_attach_address,
125
    generic_device_size_to_attach_size, },
126
};
127
 
128
 
129
static void *
130
hw_core_create(const char *name,
131
               const device_unit *unit_address,
132
               const char *args)
133
{
134
  core *memory = core_create();
135
  return memory;
136
}
137
 
138
const device_descriptor hw_core_device_descriptor[] = {
139
  { "core", hw_core_create, &hw_core_callbacks },
140
  { NULL },
141
};
142
 
143
#endif /* _HW_CORE_C_ */

powered by: WebSVN 2.1.0

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