]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/m32r/devices.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / sim / m32r / devices.c
CommitLineData
ff8c385a
DE
1/* m32r device support
2 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
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,
35 SIM_CPU *cpu, sim_cia cia)
36{
37 SIM_DESC sd = CPU_STATE (cpu);
38
39 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
40 return nr_bytes;
41
42#ifdef HAVE_DV_SOCKSER
43 if (addr == UART_INCHAR_ADDR)
44 {
45 int c = dv_sockser_read (sd);
46 if (c == -1)
47 return 0;
48 *(char *) source = c;
49 return 1;
50 }
51 if (addr == UART_STATUS_ADDR)
52 {
53 int status = dv_sockser_status (sd);
54 unsigned char *p = source;
55 p[0] = 0;
56 p[1] = (((status & DV_SOCKSER_INPUT_EMPTY)
57#ifdef UART_INPUT_READY0
58 ? UART_INPUT_READY : 0)
59#else
60 ? 0 : UART_INPUT_READY)
61#endif
62 + ((status & DV_SOCKSER_OUTPUT_EMPTY) ? UART_OUTPUT_READY : 0));
63 return 2;
64 }
65#endif
66
67 return nr_bytes;
68}
69
70int
71device_io_write_buffer (device *me, const void *source, int space,
72 address_word addr, unsigned nr_bytes,
73 SIM_CPU *cpu, sim_cia cia)
74{
75 SIM_DESC sd = CPU_STATE (cpu);
76
77#if WITH_SCACHE
78 /* MSPR support is deprecated but is kept in for upward compatibility
79 with existing overlay support. */
80 if (addr == MSPR_ADDR)
81 {
82 if ((*(const char *) source & MSPR_PURGE) != 0)
83 scache_flush (sd);
84 return nr_bytes;
85 }
86 if (addr == MCCR_ADDR)
87 {
88 if ((*(const char *) source & MCCR_CP) != 0)
89 scache_flush (sd);
90 return nr_bytes;
91 }
92#endif
93
94 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
95 return nr_bytes;
96
97#if HAVE_DV_SOCKSER
98 if (addr == UART_OUTCHAR_ADDR)
99 {
100 int rc = dv_sockser_write (sd, *(char *) source);
101 return rc == 1;
102 }
103#endif
104
105 return nr_bytes;
106}
107
108void device_error () {}