OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / gloss / angel.h
1 // angel.h - A limited emulation component for the Angel ROM monitor
2 // that features onthe ARM PID7T development board.  -*- C++ -*-
3
4 // Copyright (C) 1999, 2000 Red Hat.
5 // This file is part of SID and is licensed under the GPL.
6 // See the file COPYING.SID for conditions for redistribution.
7
8 // Details of the Angel ROM monitor and, specifically, the system call
9 // interface, can be found in Chapter 8 of the ARM Software
10 // Development Toolkit Reference Guide (ARM part no. DUI 0041B).
11
12 #ifndef ANGEL_H
13 #define ANGEL_H
14
15 // FIXME: Move to common area.
16 extern "C" {
17 #ifdef HAVE_SYS_TYPES_H
18 #include <sys/types.h>
19 #endif
20 #ifdef HAVE_SYS_TIME_H
21 #include <sys/time.h>
22 #endif
23 #ifdef HAVE_TIME_H
24 #include <time.h>
25 #endif
26 }
27
28 #include "gloss.h"
29
30 using sidutil::make_attribute;
31 using sidutil::parse_attribute;
32
33 class arm_angel: public gloss32
34 {
35 public:
36
37   arm_angel();
38
39 private:
40
41   enum syscalls
42   {
43     syscall_open = 1,
44     syscall_close,
45     syscall_writec,
46     syscall_write0,
47     syscall_write,
48     syscall_readc,
49     syscall_read,
50     syscall_iserror,
51     syscall_istty,
52     syscall_seek = 0xA,
53     syscall_flen = 0xC,
54     syscall_tmpnam,
55     syscall_remove,
56     syscall_rename,
57     syscall_clock,
58     syscall_time,
59     syscall_system,
60     syscall_errno,
61     syscall_get_cmdline = 0x15,
62     syscall_heapinfo,
63     syscall_report_exception = 0x18
64   };
65
66   enum exceptions {
67     exception_rte = 0x20022,  // Runtime error.
68     exception_exit = 0x20026
69   };
70
71   int32 errnum;
72   uint32 heapBase, heapLimit;
73   uint32 stackBase, stackLimit;
74
75   clock_t startupTime;
76
77   // We need to do some extra processing at reset time.
78   void reset();
79
80   // ABI-specifics, for getting syscall arguments and setting results.
81   // ??? Class by itself.
82   // ??? Perhaps this shouldn't be here at all as it's really an
83   // implementation detail (but lots of implementations will probably use it).
84   bool get_int_argument(unsigned index, int32& value);
85   bool set_int_result(int32 value);
86   bool set_error_result(int32 value);
87
88   // Return boolean indicating if cpu is requesting something we're to handle.
89   bool syscall_trap_p();
90   // Perform a system call trap.
91   void syscall_trap();
92
93   // Convert host errno to target errno.
94   int host_to_target_errno (int errno_);
95   // Cover fn for set_error_result (host_to_target_errno (errcode)).
96   bool set_host_error_result (int32 errcode);
97
98   // Methods to handle the individual system calls.
99   void do_clock();
100   void do_close();
101   void do_flen();
102   void do_get_cmdline();
103   void do_heapinfo();
104   void do_iserror();
105   void do_istty();
106   void do_open();
107   void do_read();
108   void do_readc();
109   void do_remove();
110   void do_rename();
111   void do_report_exception();
112   void do_seek();
113   void do_system();
114   void do_tmpnam();
115   void do_write();
116   void do_write0();
117   void do_writec();
118 };
119
120 #endif // ANGEL_H