]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/m32r/devices.c
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / sim / m32r / devices.c
CommitLineData
c906108c 1/* m32r device support
8acc9f48 2 Copyright (C) 1997-2013 Free Software Foundation, Inc.
c906108c
SS
3 Contributed by Cygnus Solutions.
4
5This file is part of GDB, the GNU debugger.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
4744ac1b
JB
9the Free Software Foundation; either version 3 of the License, or
10(at your option) any later version.
c906108c
SS
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
4744ac1b
JB
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20#include "sim-main.h"
21
22#ifdef HAVE_DV_SOCKSER
23#include "dv-sockser.h"
24#endif
25
26/* Handling the MSPR register is done by creating a device in the core
27 mapping that winds up here. */
28
29device m32r_devices;
30
31int
32device_io_read_buffer (device *me, void *source, int space,
33 address_word addr, unsigned nr_bytes,
7a292a7a 34 SIM_DESC sd, SIM_CPU *cpu, sim_cia cia)
c906108c 35{
c906108c
SS
36 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
37 return nr_bytes;
38
39#ifdef HAVE_DV_SOCKSER
40 if (addr == UART_INCHAR_ADDR)
41 {
42 int c = dv_sockser_read (sd);
43 if (c == -1)
44 return 0;
45 *(char *) source = c;
46 return 1;
47 }
48 if (addr == UART_STATUS_ADDR)
49 {
50 int status = dv_sockser_status (sd);
51 unsigned char *p = source;
52 p[0] = 0;
53 p[1] = (((status & DV_SOCKSER_INPUT_EMPTY)
54#ifdef UART_INPUT_READY0
55 ? UART_INPUT_READY : 0)
56#else
57 ? 0 : UART_INPUT_READY)
58#endif
59 + ((status & DV_SOCKSER_OUTPUT_EMPTY) ? UART_OUTPUT_READY : 0));
60 return 2;
61 }
62#endif
63
64 return nr_bytes;
65}
66
67int
68device_io_write_buffer (device *me, const void *source, int space,
69 address_word addr, unsigned nr_bytes,
7a292a7a 70 SIM_DESC sd, SIM_CPU *cpu, sim_cia cia)
c906108c 71{
c906108c
SS
72#if WITH_SCACHE
73 /* MSPR support is deprecated but is kept in for upward compatibility
74 with existing overlay support. */
75 if (addr == MSPR_ADDR)
76 {
77 if ((*(const char *) source & MSPR_PURGE) != 0)
78 scache_flush (sd);
79 return nr_bytes;
80 }
81 if (addr == MCCR_ADDR)
82 {
83 if ((*(const char *) source & MCCR_CP) != 0)
84 scache_flush (sd);
85 return nr_bytes;
86 }
87#endif
88
89 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
90 return nr_bytes;
91
92#ifdef HAVE_DV_SOCKSER
93 if (addr == UART_OUTCHAR_ADDR)
94 {
95 int rc = dv_sockser_write (sd, *(char *) source);
96 return rc == 1;
97 }
98#endif
99
100 return nr_bytes;
101}
102
7a292a7a 103void
fb0cc53e 104device_error (device *me, const char *message, ...)
7a292a7a
SS
105{
106}