1 |
1181 |
sfurman |
/* This file is part of the program psim.
|
2 |
|
|
|
3 |
|
|
Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
|
4 |
|
|
|
5 |
|
|
This program is free software; you can redistribute it and/or modify
|
6 |
|
|
it under the terms of the GNU General Public License as published by
|
7 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
(at your option) any later version.
|
9 |
|
|
|
10 |
|
|
This program is distributed in the hope that it will be useful,
|
11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
GNU General Public License for more details.
|
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU General Public License
|
16 |
|
|
along with this program; if not, write to the Free Software
|
17 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
18 |
|
|
|
19 |
|
|
*/
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
#ifndef _EMUL_CHIRP_H_
|
23 |
|
|
#define _EMUL_CHIRP_H_
|
24 |
|
|
|
25 |
|
|
/* EMUL_CHIRP:
|
26 |
|
|
|
27 |
|
|
The emulation of the OpenBoot client interface (as defined in 1275)
|
28 |
|
|
illustrates how it is possible for PSIM to implement an interface
|
29 |
|
|
that is both running in virtual memory and is called using a
|
30 |
|
|
standard function call interface.
|
31 |
|
|
|
32 |
|
|
The OpenBoot client interface is implemented by using two
|
33 |
|
|
instructions:
|
34 |
|
|
|
35 |
|
|
client_interface:
|
36 |
|
|
<emul_call>
|
37 |
|
|
blr
|
38 |
|
|
|
39 |
|
|
A client program makes a function call to `client_interface' using
|
40 |
|
|
the `bl' instruction. The simulator will then execute the
|
41 |
|
|
<emul_call> instruction (which calls emul_chirp) and then the `blr'
|
42 |
|
|
which will return to the caller.
|
43 |
|
|
|
44 |
|
|
In addition to providing the `client_interface' entry point, while
|
45 |
|
|
a client request is being handled, emul_chirp patches (well it will
|
46 |
|
|
one day) the data access exception vector with a <emul_call>
|
47 |
|
|
instruction. By doing this, emul_chirp is able to catch and handle
|
48 |
|
|
any invalid data accesses it makes while emulating a client call.
|
49 |
|
|
|
50 |
|
|
When such an exception occures, emul_chirp is able to recover by
|
51 |
|
|
restoring the processor and then calling the clients callback
|
52 |
|
|
interface so that the client can recover from the data exception.
|
53 |
|
|
|
54 |
|
|
Handling this are the emul_chirp states:
|
55 |
|
|
|
56 |
|
|
serving---.
|
57 |
|
|
/ |
|
58 |
|
|
Emulation compleated ^ v Client makes call to
|
59 |
|
|
- restore int vectors | | emulated interface
|
60 |
|
|
^ v - patch exception vectors
|
61 |
|
|
| /
|
62 |
|
|
`-emulating-. emulating the request
|
63 |
|
|
/ |
|
64 |
|
|
| v Emulation encounters
|
65 |
|
|
Client callback recovers ^ | data access exception
|
66 |
|
|
from data exception and | v - re-enable vm
|
67 |
|
|
returns. ^ | - call client callback
|
68 |
|
|
- restart request | /
|
69 |
|
|
`--faulting
|
70 |
|
|
*/
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
extern const os_emul emul_chirp;
|
74 |
|
|
|
75 |
|
|
#endif
|