選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

realmode_asm.S 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* Real-mode interface: assembly-language portions.
  2. *
  3. * Initial version by Michael Brown <mbrown@fensystems.co.uk>, January 2004.
  4. */
  5. #include "realmode.h"
  6. #include "callbacks.h"
  7. #if 1 /* CODE16 */
  8. #define BOCHSBP xchgw %bx,%bx
  9. #define NUM_PUSHA_REGS (8)
  10. #define NUM_SEG_REGS (6)
  11. .text
  12. .arch i386
  13. .section ".text16.nocompress", "ax", @progbits
  14. .code16
  15. .equ CR0_PE,1
  16. #ifdef GAS291
  17. #define DATA32 data32;
  18. #define ADDR32 addr32;
  19. #define LJMPI(x) ljmp x
  20. #else
  21. #define DATA32 data32
  22. #define ADDR32 addr32
  23. /* newer GAS295 require #define LJMPI(x) ljmp *x */
  24. #define LJMPI(x) ljmp x
  25. #endif
  26. #ifdef PXE_EXPORT
  27. /****************************************************************************
  28. * PXE CALLBACK INTERFACE
  29. *
  30. * Prepend this to rm_callback_interface to create a real-mode PXE
  31. * callback interface.
  32. ****************************************************************************
  33. */
  34. .section ".text16", "ax", @progbits
  35. .globl pxe_callback_interface
  36. .code16
  37. pxe_callback_interface:
  38. /* Macro to calculate offset of labels within code segment in
  39. * installed copy of code.
  40. */
  41. #define INSTALLED(x) ( (x) - pxe_callback_interface )
  42. /****************************************************************************
  43. * PXE entry points (!PXE and PXENV+ APIs)
  44. ****************************************************************************
  45. */
  46. /* in_call mechanism for !PXE API calls */
  47. .globl _pxe_in_call_far
  48. _pxe_in_call_far:
  49. /* Prepend "PXE API call" and "API version 0x201" to stack */
  50. pushl $0x201
  51. jmp 1f
  52. /* in_call mechanism for PXENV+ API calls */
  53. .globl _pxenv_in_call_far
  54. _pxenv_in_call_far:
  55. /* Prepend "PXE API call" and "API version 0x200" to stack */
  56. pushl $0x200
  57. 1: pushl $EB_OPCODE_PXE
  58. /* Perform real-mode in_call */
  59. call pxe_rm_in_call
  60. /* Return */
  61. addw $8, %sp
  62. lret
  63. /****************************************************************************
  64. * PXE installation check (INT 1A) code
  65. ****************************************************************************
  66. */
  67. .globl _pxe_intercept_int1a
  68. _pxe_intercept_int1a:
  69. pushfw
  70. cmpw $0x5650, %ax
  71. jne 2f
  72. 1: /* INT 1A,5650 - Intercept */
  73. popfw
  74. /* Set up return values according to PXE spec: */
  75. movw $0x564e, %ax /* AX := 564Eh (VN) */
  76. pushw %cs:INSTALLED(_pxe_pxenv_segment)
  77. popw %es /* ES:BX := &(PXENV+ structure) */
  78. movw %cs:INSTALLED(_pxe_pxenv_offset), %bx
  79. clc /* CF is cleared */
  80. lret $2 /* 'iret' without reloading flags */
  81. 2: /* INT 1A,other - Do not intercept */
  82. popfw
  83. ljmp %cs:*INSTALLED(_pxe_intercepted_int1a)
  84. .globl _pxe_intercepted_int1a
  85. _pxe_intercepted_int1a: .word 0,0
  86. .globl _pxe_pxenv_location
  87. _pxe_pxenv_location:
  88. _pxe_pxenv_offset: .word 0
  89. _pxe_pxenv_segment: .word 0
  90. pxe_rm_in_call:
  91. pxe_attach_rm:
  92. /* rm_callback_interface must be appended here */
  93. pxe_callback_interface_end:
  94. .globl _pxe_callback_interface_size
  95. .equ _pxe_callback_interface_size, pxe_callback_interface_end - pxe_callback_interface
  96. .globl pxe_callback_interface_size
  97. pxe_callback_interface_size:
  98. .word _pxe_callback_interface_size
  99. #else /* PXE_EXPORT */
  100. /* Define symbols used by the linker scripts, to prevent link errors */
  101. .globl _pxe_callback_interface_size
  102. .equ _pxe_callback_interface_size, 0
  103. #endif /* PXE_EXPORT */
  104. #else /* CODE16 */
  105. /* Define symbols used by the linker scripts, to prevent link errors */
  106. .globl _rm_callback_interface_size
  107. .equ _rm_callback_interface_size, 0
  108. .globl _pxe_callback_interface_size
  109. .equ _pxe_callback_interface_size, 0
  110. #endif /* CODE16 */