]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/frv/devices.c
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / sim / frv / devices.c
CommitLineData
b34f6357 1/* frv device support
32d0add0 2 Copyright (C) 1998-2015 Free Software Foundation, Inc.
b34f6357
DB
3 Contributed by Red Hat.
4
5This file is part of the GNU simulators.
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.
b34f6357
DB
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/>. */
b34f6357
DB
19
20/* ??? All of this is just to get something going. wip! */
21
22#include "sim-main.h"
23
24#ifdef HAVE_DV_SOCKSER
25#include "dv-sockser.h"
26#endif
27
28device frv_devices;
29
30int
31device_io_read_buffer (device *me, void *source, int space,
32 address_word addr, unsigned nr_bytes,
33 SIM_DESC sd, SIM_CPU *cpu, sim_cia cia)
34{
35 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
36 return nr_bytes;
37
38#ifdef HAVE_DV_SOCKSER
39 if (addr == UART_INCHAR_ADDR)
40 {
41 int c = dv_sockser_read (sd);
42 if (c == -1)
43 return 0;
44 *(char *) source = c;
45 return 1;
46 }
47 if (addr == UART_STATUS_ADDR)
48 {
49 int status = dv_sockser_status (sd);
50 unsigned char *p = source;
51 p[0] = 0;
52 p[1] = (((status & DV_SOCKSER_INPUT_EMPTY)
53#ifdef UART_INPUT_READY0
54 ? UART_INPUT_READY : 0)
55#else
56 ? 0 : UART_INPUT_READY)
57#endif
58 + ((status & DV_SOCKSER_OUTPUT_EMPTY) ? UART_OUTPUT_READY : 0));
59 return 2;
60 }
61#endif
62
63 return nr_bytes;
64}
65
66int
67device_io_write_buffer (device *me, const void *source, int space,
68 address_word addr, unsigned nr_bytes,
69 SIM_DESC sd, SIM_CPU *cpu, sim_cia cia)
70{
71
72#if WITH_SCACHE
73 if (addr == MCCR_ADDR)
74 {
75 if ((*(const char *) source & MCCR_CP) != 0)
76 scache_flush (sd);
77 return nr_bytes;
78 }
79#endif
80
81 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
82 return nr_bytes;
83
84#if HAVE_DV_SOCKSER
85 if (addr == UART_OUTCHAR_ADDR)
86 {
87 int rc = dv_sockser_write (sd, *(char *) source);
88 return rc == 1;
89 }
90#endif
91
92 return nr_bytes;
93}
94
fb0cc53e 95void device_error (device *me, const char *message, ...) {}