source: rtems/c/src/lib/libbsp/arm/armulator/startup/syscalls.c @ caf88699

4.104.114.84.95
Last change on this file since caf88699 was caf88699, checked in by Joel Sherrill <joel.sherrill@…>, on 07/31/00 at 18:29:37

New bsp for simulator in gdb. Does not work yet.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/* Support files for newlib/GDB simulator.
2 *  $Id$
3 */
4
5#include <_ansi.h>
6#include <sys/types.h>
7#include <sys/stat.h>
8#include <sys/fcntl.h>
9#include <stdio.h>
10#include <time.h>
11#include <sys/time.h>
12#include <sys/times.h>
13#include <errno.h>
14#include <reent.h>
15#include "swi.h"
16
17int armulator_stdin;
18int armulator_stdout;
19int armulator_stderr;
20
21#ifdef ARM_RDI_MONITOR
22
23static inline int
24do_AngelSWI (int reason, void * arg)
25{
26  int value;
27  asm volatile ("mov r0, %1; mov r1, %2; swi %a3; mov %0, r0"
28       : "=r" (value) /* Outputs */
29       : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
30       : "r0", "r1", "lr"
31                /* Clobbers r0 and r1, and lr if in supervisor mode */);
32  return value;
33}
34#endif /* ARM_RDI_MONITOR */
35
36void
37initialize_monitor_handles (void)
38{
39  int i;
40 
41#ifdef ARM_RDI_MONITOR
42  int volatile block[3];
43 
44  block[0] = (int) ":tt";
45  block[2] = 3;     /* length of filename */
46  block[1] = 0;     /* mode "r" */
47  armulator_stdin = do_AngelSWI (AngelSWI_Reason_Open, block);
48
49  block[0] = (int) ":tt";
50  block[2] = 3;     /* length of filename */
51  block[1] = 4;     /* mode "w" */
52  armulator_stdout = armulator_stderr = do_AngelSWI (AngelSWI_Reason_Open, block);
53#else
54  int fh;
55  const char * name;
56
57  name = ":tt";
58  asm ("mov r0,%2; mov r1, #0; swi %a1; mov %0, r0"
59       : "=r"(fh)
60       : "i" (SWI_Open),"r"(name)
61       : "r0","r1");
62  armulator_stdin = fh;
63
64  name = ":tt";
65  asm ("mov r0,%2; mov r1, #4; swi %a1; mov %0, r0"
66       : "=r"(fh)
67       : "i" (SWI_Open),"r"(name)
68       : "r0","r1");
69  armulator_stdout = armulator_stderr = fh;
70#endif
71}
72
73/* Returns # chars not! read */
74
75int
76_swiread (int file,
77          char * ptr,
78          int len)
79{
80  int fh = file;
81#ifdef ARM_RDI_MONITOR
82  int block[3];
83 
84  block[0] = fh;
85  block[1] = (int) ptr;
86  block[2] = len;
87 
88  return do_AngelSWI (AngelSWI_Reason_Read, block);
89#else
90  asm ("mov r0, %1; mov r1, %2;mov r2, %3; swi %a0"
91       : /* No outputs */
92       : "i"(SWI_Read), "r"(fh), "r"(ptr), "r"(len)
93       : "r0","r1","r2");
94#endif
95}
96
97/* Returns #chars not! written */
98int
99_swiwrite (
100           int    file,
101           char * ptr,
102           int    len)
103{
104  int fh = file;
105#ifdef ARM_RDI_MONITOR
106  int block[3];
107 
108  block[0] = fh;
109  block[1] = (int) ptr;
110  block[2] = len;
111 
112  return do_AngelSWI (AngelSWI_Reason_Write, block);
113#else
114  asm ("mov r0, %1; mov r1, %2;mov r2, %3; swi %a0"
115       : /* No outputs */
116       : "i"(SWI_Write), "r"(fh), "r"(ptr), "r"(len)
117       : "r0","r1","r2");
118#endif
119}
120
121/*
122 *  Move me
123 */
124
125void
126bsp_cleanup (void )
127{
128  /* FIXME: return code is thrown away */
129 
130#ifdef ARM_RDI_MONITOR
131  do_AngelSWI (AngelSWI_Reason_ReportException,
132              (void *) ADP_Stopped_ApplicationExit);
133#else
134  asm ("swi %a0" :: "i" (SWI_Exit));
135#endif
136}
137
138/*
139 *  Technically could use this as guts of a "real-time clock driver"
140 */
141
142#if 0
143int
144_gettimeofday (struct timeval * tp, struct timezone * tzp)
145{
146
147  if (tp)
148    {
149    /* Ask the host for the seconds since the Unix epoch */
150#ifdef ARM_RDI_MONITOR
151      tp->tv_sec = do_AngelSWI (AngelSWI_Reason_Time,NULL);
152#else
153      {
154        int value;
155        asm ("swi %a1; mov %0, r0" : "=r" (value): "i" (SWI_Time) : "r0");
156        tp->tv_sec = value;
157      }
158#endif
159      tp->tv_usec = 0;
160    }
161
162  /* Return fixed data for the timezone */
163  if (tzp)
164    {
165      tzp->tz_minuteswest = 0;
166      tzp->tz_dsttime = 0;
167    }
168
169  return 0;
170}
171#endif
172
Note: See TracBrowser for help on using the repository browser.