2
0

op_helper.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include <assert.h>
  2. #include "cpu.h"
  3. #include "helper.h"
  4. #include "qemu/host-utils.h"
  5. #include "hw/lm32_pic.h"
  6. #include "hw/lm32_juart.h"
  7. #if !defined(CONFIG_USER_ONLY)
  8. #define MMUSUFFIX _mmu
  9. #define SHIFT 0
  10. #include "exec/softmmu_template.h"
  11. #define SHIFT 1
  12. #include "exec/softmmu_template.h"
  13. #define SHIFT 2
  14. #include "exec/softmmu_template.h"
  15. #define SHIFT 3
  16. #include "exec/softmmu_template.h"
  17. void helper_raise_exception(CPULM32State *env, uint32_t index)
  18. {
  19. env->exception_index = index;
  20. cpu_loop_exit(env);
  21. }
  22. void helper_hlt(CPULM32State *env)
  23. {
  24. env->halted = 1;
  25. env->exception_index = EXCP_HLT;
  26. cpu_loop_exit(env);
  27. }
  28. void helper_wcsr_im(CPULM32State *env, uint32_t im)
  29. {
  30. lm32_pic_set_im(env->pic_state, im);
  31. }
  32. void helper_wcsr_ip(CPULM32State *env, uint32_t im)
  33. {
  34. lm32_pic_set_ip(env->pic_state, im);
  35. }
  36. void helper_wcsr_jtx(CPULM32State *env, uint32_t jtx)
  37. {
  38. lm32_juart_set_jtx(env->juart_state, jtx);
  39. }
  40. void helper_wcsr_jrx(CPULM32State *env, uint32_t jrx)
  41. {
  42. lm32_juart_set_jrx(env->juart_state, jrx);
  43. }
  44. uint32_t helper_rcsr_im(CPULM32State *env)
  45. {
  46. return lm32_pic_get_im(env->pic_state);
  47. }
  48. uint32_t helper_rcsr_ip(CPULM32State *env)
  49. {
  50. return lm32_pic_get_ip(env->pic_state);
  51. }
  52. uint32_t helper_rcsr_jtx(CPULM32State *env)
  53. {
  54. return lm32_juart_get_jtx(env->juart_state);
  55. }
  56. uint32_t helper_rcsr_jrx(CPULM32State *env)
  57. {
  58. return lm32_juart_get_jrx(env->juart_state);
  59. }
  60. /* Try to fill the TLB and return an exception if error. If retaddr is
  61. NULL, it means that the function was called in C code (i.e. not
  62. from generated code or from helper.c) */
  63. void tlb_fill(CPULM32State *env, target_ulong addr, int is_write, int mmu_idx,
  64. uintptr_t retaddr)
  65. {
  66. int ret;
  67. ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx);
  68. if (unlikely(ret)) {
  69. if (retaddr) {
  70. /* now we have a real cpu fault */
  71. cpu_restore_state(env, retaddr);
  72. }
  73. cpu_loop_exit(env);
  74. }
  75. }
  76. #endif