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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [ppc/] [hw_register.c] - Blame information for rev 868

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

Line No. Rev Author Line
1 227 jeremybenn
/*  This file is part of the program psim.
2
 
3
    Copyright 1994, 1995, 1996, 2003 Andrew Cagney
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_REGISTER_C_
23
#define _HW_REGISTER_C_
24
 
25
#include "device_table.h"
26
#include <stdlib.h>
27
#include "psim.h"
28
 
29
/* DEVICE
30
 
31
 
32
   register - dummy device to initialize processor registers
33
 
34
 
35
   DESCRIPTION
36
 
37
   The properties of this device are used, during initialization, to
38
   specify the initial value of various processor registers.  The
39
   property name specifying the register to be initialized with the
40
   special form <cpu-nr>.<register> being used to initialize a
41
   specific processor's register (eg 0.pc).
42
 
43
   Because, when the device tree is created, overriding properties are
44
   entered into the tree before any default values, this device must
45
   initialize registers in newest (default) to oldest (overriding)
46
   property order.
47
 
48
   The actual registers (for a given target) are defined in the file
49
   registers.c.
50
 
51
   This device is normally a child of the /openprom/init node.
52
 
53
 
54
   EXAMPLES
55
 
56
 
57
   Given a device tree containing the entry:
58
 
59
   |    /openprom/init/register/pc 0xfff00cf0
60
 
61
   then specifying the command line option:
62
 
63
   |    -o '/openprom/init/register/pc 0x0'
64
 
65
   would override the initial value of processor zero's program
66
   counter.  The resultant device tree tree containing:
67
 
68
   |    /openprom/init/register/0.pc 0x0
69
   |    /openprom/init/register/pc 0xfff00cf0
70
 
71
   and would be processed last to first resulting in the sequence: set
72
   all program counters to 0xfff00cf0; set processor zero's program
73
   counter to zero.
74
 
75
   */
76
 
77
static void
78
do_register_init(device *me,
79
                 const device_property *prop)
80
{
81
  psim *system = device_system(me);
82
  if (prop != NULL) {
83
    const char *name = prop->name;
84
    unsigned32 value = device_find_integer_property(me, name);
85
    int processor;
86
 
87
    do_register_init(me, device_next_property(prop));
88
 
89
    if (strchr(name, '.') == NULL) {
90
      processor = -1;
91
      DTRACE(register, ("%s=0x%lx\n", name, (unsigned long)value));
92
    }
93
    else {
94
      char *end;
95
      processor = strtoul(name, &end, 0);
96
      ASSERT(end[0] == '.');
97
      name = end+1;
98
      DTRACE(register, ("%d.%s=0x%lx\n", processor, name,
99
                        (unsigned long)value));
100
    }
101
    if (psim_write_register(system, processor, /* all processors */
102
                            &value,
103
                            name,
104
                            cooked_transfer) <= 0)
105
      error("Invalid register name %s\n", name);
106
  }
107
}
108
 
109
 
110
static void
111
register_init_data_callback(device *me)
112
{
113
  const device_property *prop = device_find_property(me, NULL);
114
  do_register_init(me, prop);
115
}
116
 
117
 
118
static device_callbacks const register_callbacks = {
119
  { NULL, register_init_data_callback, },
120
  { NULL, }, /* address */
121
  { NULL, }, /* IO */
122
  { NULL, }, /* DMA */
123
  { NULL, }, /* interrupt */
124
  { NULL, }, /* unit */
125
};
126
 
127
const device_descriptor hw_register_device_descriptor[] = {
128
  { "register", NULL, &register_callbacks },
129
  { NULL },
130
};
131
 
132
#endif /* _HW_REGISTER_C_ */

powered by: WebSVN 2.1.0

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