]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/m32r/devices.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / sim / m32r / devices.c
CommitLineData
c906108c 1/* m32r device support
6aba47ca 2 Copyright (C) 1997, 1998, 2007 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
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
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
17You should have received a copy of the GNU General Public License along
18with this program; if not, write to the Free Software Foundation, Inc.,
1959 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21#include "sim-main.h"
22
23#ifdef HAVE_DV_SOCKSER
24#include "dv-sockser.h"
25#endif
26
27/* Handling the MSPR register is done by creating a device in the core
28 mapping that winds up here. */
29
30device m32r_devices;
31
32int
33device_io_read_buffer (device *me, void *source, int space,
34 address_word addr, unsigned nr_bytes,
7a292a7a 35 SIM_DESC sd, SIM_CPU *cpu, sim_cia cia)
c906108c 36{
c906108c
SS
37 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
38 return nr_bytes;
39
40#ifdef HAVE_DV_SOCKSER
41 if (addr == UART_INCHAR_ADDR)
42 {
43 int c = dv_sockser_read (sd);
44 if (c == -1)
45 return 0;
46 *(char *) source = c;
47 return 1;
48 }
49 if (addr == UART_STATUS_ADDR)
50 {
51 int status = dv_sockser_status (sd);
52 unsigned char *p = source;
53 p[0] = 0;
54 p[1] = (((status & DV_SOCKSER_INPUT_EMPTY)
55#ifdef UART_INPUT_READY0
56 ? UART_INPUT_READY : 0)
57#else
58 ? 0 : UART_INPUT_READY)
59#endif
60 + ((status & DV_SOCKSER_OUTPUT_EMPTY) ? UART_OUTPUT_READY : 0));
61 return 2;
62 }
63#endif
64
65 return nr_bytes;
66}
67
68int
69device_io_write_buffer (device *me, const void *source, int space,
70 address_word addr, unsigned nr_bytes,
7a292a7a 71 SIM_DESC sd, SIM_CPU *cpu, sim_cia cia)
c906108c 72{
c906108c
SS
73#if WITH_SCACHE
74 /* MSPR support is deprecated but is kept in for upward compatibility
75 with existing overlay support. */
76 if (addr == MSPR_ADDR)
77 {
78 if ((*(const char *) source & MSPR_PURGE) != 0)
79 scache_flush (sd);
80 return nr_bytes;
81 }
82 if (addr == MCCR_ADDR)
83 {
84 if ((*(const char *) source & MCCR_CP) != 0)
85 scache_flush (sd);
86 return nr_bytes;
87 }
88#endif
89
90 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
91 return nr_bytes;
92
93#ifdef HAVE_DV_SOCKSER
94 if (addr == UART_OUTCHAR_ADDR)
95 {
96 int rc = dv_sockser_write (sd, *(char *) source);
97 return rc == 1;
98 }
99#endif
100
101 return nr_bytes;
102}
103
7a292a7a
SS
104void
105device_error (device *me, char *message, ...)
106{
107}