You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

realmode_asm.S 3.4KB

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