Initial creation of sourceware repository
[deliverable/binutils-gdb.git] / sim / fr30 / devices.c
CommitLineData
c906108c
SS
1/* fr30 device support
2 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
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
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/* ??? All of this is just to get something going. wip! */
22
23#include "sim-main.h"
24
25#ifdef HAVE_DV_SOCKSER
26#include "dv-sockser.h"
27#endif
28
29device fr30_devices;
30
31int
32device_io_read_buffer (device *me, void *source, int space,
33 address_word addr, unsigned nr_bytes,
34 SIM_CPU *cpu, sim_cia cia)
35{
36 SIM_DESC sd = CPU_STATE (cpu);
37
38 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
39 return nr_bytes;
40
41#ifdef HAVE_DV_SOCKSER
42 if (addr == UART_INCHAR_ADDR)
43 {
44 int c = dv_sockser_read (sd);
45 if (c == -1)
46 return 0;
47 *(char *) source = c;
48 return 1;
49 }
50 if (addr == UART_STATUS_ADDR)
51 {
52 int status = dv_sockser_status (sd);
53 unsigned char *p = source;
54 p[0] = 0;
55 p[1] = (((status & DV_SOCKSER_INPUT_EMPTY)
56#ifdef UART_INPUT_READY0
57 ? UART_INPUT_READY : 0)
58#else
59 ? 0 : UART_INPUT_READY)
60#endif
61 + ((status & DV_SOCKSER_OUTPUT_EMPTY) ? UART_OUTPUT_READY : 0));
62 return 2;
63 }
64#endif
65
66 return nr_bytes;
67}
68
69int
70device_io_write_buffer (device *me, const void *source, int space,
71 address_word addr, unsigned nr_bytes,
72 SIM_CPU *cpu, sim_cia cia)
73{
74 SIM_DESC sd = CPU_STATE (cpu);
75
76#if WITH_SCACHE
77 if (addr == MCCR_ADDR)
78 {
79 if ((*(const char *) source & MCCR_CP) != 0)
80 scache_flush (sd);
81 return nr_bytes;
82 }
83#endif
84
85 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
86 return nr_bytes;
87
88#if HAVE_DV_SOCKSER
89 if (addr == UART_OUTCHAR_ADDR)
90 {
91 int rc = dv_sockser_write (sd, *(char *) source);
92 return rc == 1;
93 }
94#endif
95
96 return nr_bytes;
97}
98
99void device_error () {}
This page took 0.026762 seconds and 4 git commands to generate.