cpu.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * cpu.h
  3. *
  4. * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __MONOLITHIUM_CPU_H__
  20. #define __MONOLITHIUM_CPU_H__
  21. #define CPU_MAX_FPU_DATA_SIZE 512
  22. #define CPU_STATUS_FLAG_CF (1 << 0)
  23. #define CPU_STATUS_FLAG_PF (1 << 2)
  24. #define CPU_STATUS_FLAG_AF (1 << 4)
  25. #define CPU_STATUS_FLAG_ZF (1 << 6)
  26. #define CPU_STATUS_FLAG_SF (1 << 7)
  27. #define CPU_STATUS_FLAG_TF (1 << 8)
  28. #define CPU_STATUS_FLAG_IF (1 << 9)
  29. #define CPU_STATUS_FLAG_DF (1 << 10)
  30. #define CPU_STATUS_FLAG_OF (1 << 11)
  31. #define CPU_STATUS_FLAG_NT (1 << 14)
  32. #define CPU_STATUS_FLAG_RF (1 << 16)
  33. #define CPU_STATUS_FLAG_VM (1 << 17)
  34. #define CPU_STATUS_FLAG_AC (1 << 18)
  35. #define CPU_STATUS_FLAG_VIF (1 << 19)
  36. #define CPU_STATUS_FLAG_VIP (1 << 20)
  37. #define CPU_STATUS_FLAG_ID (1 << 21)
  38. typedef struct
  39. {
  40. dword_t data_selector;
  41. dword_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
  42. dword_t error_code;
  43. dword_t eip, cs, eflags;
  44. } registers_t;
  45. typedef struct
  46. {
  47. dword_t data_selector;
  48. dword_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
  49. dword_t error_code;
  50. dword_t eip, cs, eflags, esp3, ss;
  51. } registers_ext_t;
  52. typedef struct
  53. {
  54. dword_t data_selector;
  55. dword_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
  56. dword_t error_code;
  57. dword_t eip, cs, eflags, esp3, ss, es, ds, fs, gs;
  58. } registers_ext_vm86_t;
  59. typedef enum
  60. {
  61. CPU_EXCEPTION_DE = 0x00,
  62. CPU_EXCEPTION_DB = 0x01,
  63. CPU_EXCEPTION_NMI = 0x02,
  64. CPU_EXCEPTION_BP = 0x03,
  65. CPU_EXCEPTION_OF = 0x04,
  66. CPU_EXCEPTION_BR = 0x05,
  67. CPU_EXCEPTION_UD = 0x06,
  68. CPU_EXCEPTION_NM = 0x07,
  69. CPU_EXCEPTION_DF = 0x08,
  70. CPU_EXCEPTION_TS = 0x0A,
  71. CPU_EXCEPTION_NP = 0x0B,
  72. CPU_EXCEPTION_SS = 0x0C,
  73. CPU_EXCEPTION_GP = 0x0D,
  74. CPU_EXCEPTION_PF = 0x0E,
  75. CPU_EXCEPTION_MF = 0x10,
  76. CPU_EXCEPTION_AC = 0x11,
  77. CPU_EXCEPTION_MC = 0x12,
  78. CPU_EXCEPTION_XM = 0x13,
  79. CPU_EXCEPTION_VE = 0x14,
  80. CPU_EXCEPTION_SX = 0x1E,
  81. CPU_EXCEPTION_MAX
  82. } cpu_exception_t;
  83. #endif