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.

pxe_entry.S 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. */
  19. .arch i386
  20. .section ".text16", "awx", @progbits
  21. .section ".text16.data", "aw", @progbits
  22. .section ".data16", "aw", @progbits
  23. /****************************************************************************
  24. * !PXE structure
  25. ****************************************************************************
  26. */
  27. .section ".text16.data"
  28. .globl pxe
  29. pxe:
  30. .ascii "!PXE" /* Signature */
  31. .byte pxe_length /* StructLength */
  32. .byte 0 /* StructCksum */
  33. .byte 0 /* StructRev */
  34. .byte 0 /* reserved_1 */
  35. .word 0, 0 /* UNDIROMID */
  36. .word 0, 0 /* BaseROMID */
  37. .word pxe_entry_sp, 0 /* EntryPointSP */
  38. .word pxe_entry_esp, 0 /* EntryPointESP */
  39. .word -1, -1 /* StatusCallout */
  40. .byte 0 /* reserved_2 */
  41. .byte SegDescCnt /* SegDescCnt */
  42. .word 0 /* FirstSelector */
  43. pxe_segments:
  44. .word 0, 0, 0, _data16_size /* Stack */
  45. .word 0, 0, 0, _data16_size /* UNDIData */
  46. .word 0, 0, 0, _text16_size /* UNDICode */
  47. .word 0, 0, 0, _text16_size /* UNDICodeWrite */
  48. .word 0, 0, 0, 0 /* BC_Data */
  49. .word 0, 0, 0, 0 /* BC_Code */
  50. .word 0, 0, 0, 0 /* BC_CodeWrite */
  51. .equ SegDescCnt, ( ( . - pxe_segments ) / 8 )
  52. .equ pxe_length, . - pxe
  53. .size pxe, . - pxe
  54. /****************************************************************************
  55. * PXENV+ structure
  56. ****************************************************************************
  57. */
  58. .section ".text16.data"
  59. .globl pxenv
  60. pxenv:
  61. .ascii "PXENV+" /* Signature */
  62. .word 0x0201 /* Version */
  63. .byte pxenv_length /* Length */
  64. .byte 0 /* Checksum */
  65. .word pxenv_entry, 0 /* RMEntry */
  66. .long 0 /* PMEntry */
  67. .word 0 /* PMSelector */
  68. .word 0 /* StackSeg */
  69. .word _data16_size /* StackSize */
  70. .word 0 /* BC_CodeSeg */
  71. .word 0 /* BC_CodeSize */
  72. .word 0 /* BC_DataSeg */
  73. .word 0 /* BC_DataSize */
  74. .word 0 /* UNDIDataSeg */
  75. .word _data16_size /* UNDIDataSize */
  76. .word 0 /* UNDICodeSeg */
  77. .word _text16_size /* UNDICodeSize */
  78. .word pxe, 0 /* PXEPtr */
  79. .equ pxenv_length, . - pxenv
  80. .size pxenv, . - pxenv
  81. /****************************************************************************
  82. * pxenv_entry (16-bit far call)
  83. *
  84. * PXE API call PXENV+ entry point
  85. *
  86. * Parameters:
  87. * %es:di : Far pointer to PXE parameter structure
  88. * %bx : PXE API call
  89. * Returns:
  90. * %ax : PXE exit status
  91. * Corrupts:
  92. * none
  93. ****************************************************************************
  94. */
  95. .section ".text16"
  96. .code16
  97. pxenv_entry:
  98. pushl $pxe_api_call
  99. pushw %cs
  100. call prot_call
  101. addl $4, %esp
  102. lret
  103. .size pxenv_entry, . - pxenv_entry
  104. /****************************************************************************
  105. * pxe_entry
  106. *
  107. * PXE API call !PXE entry point
  108. *
  109. * Parameters:
  110. * stack : Far pointer to PXE parameter structure
  111. * stack : PXE API call
  112. * Returns:
  113. * %ax : PXE exit status
  114. * Corrupts:
  115. * none
  116. ****************************************************************************
  117. */
  118. .section ".text16"
  119. .code16
  120. pxe_entry:
  121. pxe_entry_sp:
  122. /* Preserve original %esp */
  123. pushl %esp
  124. /* Zero high word of %esp to allow use of common code */
  125. movzwl %sp, %esp
  126. jmp pxe_entry_common
  127. pxe_entry_esp:
  128. /* Preserve %esp to match behaviour of pxe_entry_sp */
  129. pushl %esp
  130. pxe_entry_common:
  131. /* Save PXENV+ API call registers */
  132. pushw %es
  133. pushw %di
  134. pushw %bx
  135. /* Load !PXE parameters from stack into PXENV+ registers */
  136. movw 18(%esp), %bx
  137. movw %bx, %es
  138. movw 16(%esp), %di
  139. movw 14(%esp), %bx
  140. /* Make call as for PXENV+ */
  141. pushw %cs
  142. call pxenv_entry
  143. /* Restore PXENV+ registers */
  144. popw %bx
  145. popw %di
  146. popw %es
  147. /* Restore original %esp and return */
  148. popl %esp
  149. lret
  150. .size pxe_entry, . - pxe_entry
  151. /****************************************************************************
  152. * pxe_int_1a
  153. *
  154. * PXE INT 1A handler
  155. *
  156. * Parameters:
  157. * %ax : 0x5650
  158. * Returns:
  159. * %ax : 0x564e
  160. * %es:bx : Far pointer to the PXENV+ structure
  161. * CF cleared
  162. * Corrupts:
  163. * none
  164. ****************************************************************************
  165. */
  166. .section ".text16"
  167. .code16
  168. .globl pxe_int_1a
  169. pxe_int_1a:
  170. pushfw
  171. cmpw $0x5650, %ax
  172. jne 1f
  173. /* INT 1A,5650 - PXE installation check */
  174. pushw %cs
  175. popw %es
  176. movw $pxenv, %bx
  177. movw $0x564e, %ax
  178. popfw
  179. clc
  180. lret $2
  181. 1: /* INT 1A,other - pass through */
  182. popfw
  183. ljmp *%cs:pxe_int_1a_vector
  184. .section ".text16.data"
  185. .globl pxe_int_1a_vector
  186. pxe_int_1a_vector: .long 0