emul_chirp.h 2.8 KB

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