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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. */
  20. FILE_LICENCE ( GPL2_OR_LATER )
  21. .arch i386
  22. /****************************************************************************
  23. * !PXE structure
  24. ****************************************************************************
  25. */
  26. .section ".text16.data", "aw", @progbits
  27. .globl ppxe
  28. .align 16
  29. ppxe:
  30. .ascii "!PXE" /* Signature */
  31. .byte pxe_length /* StructLength */
  32. .byte 0 /* StructCksum */
  33. .byte 0 /* StructRev */
  34. .byte 0 /* reserved_1 */
  35. .word undiheader, 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_memsz /* Stack */
  45. .word 0, 0, 0, _data16_memsz /* UNDIData */
  46. .word 0, 0, 0, _text16_memsz /* UNDICode */
  47. .word 0, 0, 0, _text16_memsz /* 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, . - ppxe
  53. .size ppxe, . - ppxe
  54. /* Define undiheader=0 as a weak symbol for non-ROM builds */
  55. .section ".weak", "a", @nobits
  56. .weak undiheader
  57. undiheader:
  58. /****************************************************************************
  59. * PXENV+ structure
  60. ****************************************************************************
  61. */
  62. .section ".text16.data", "aw", @progbits
  63. .globl pxenv
  64. .align 16
  65. pxenv:
  66. .ascii "PXENV+" /* Signature */
  67. .word 0x0201 /* Version */
  68. .byte pxenv_length /* Length */
  69. .byte 0 /* Checksum */
  70. .word pxenv_entry, 0 /* RMEntry */
  71. .long 0 /* PMEntry */
  72. .word 0 /* PMSelector */
  73. .word 0 /* StackSeg */
  74. .word _data16_memsz /* StackSize */
  75. .word 0 /* BC_CodeSeg */
  76. .word 0 /* BC_CodeSize */
  77. .word 0 /* BC_DataSeg */
  78. .word 0 /* BC_DataSize */
  79. .word 0 /* UNDIDataSeg */
  80. .word _data16_memsz /* UNDIDataSize */
  81. .word 0 /* UNDICodeSeg */
  82. .word _text16_memsz /* UNDICodeSize */
  83. .word ppxe, 0 /* PXEPtr */
  84. .equ pxenv_length, . - pxenv
  85. .size pxenv, . - pxenv
  86. /****************************************************************************
  87. * pxenv_entry (16-bit far call)
  88. *
  89. * PXE API call PXENV+ entry point
  90. *
  91. * Parameters:
  92. * %es:di : Far pointer to PXE parameter structure
  93. * %bx : PXE API call
  94. * Returns:
  95. * %ax : PXE exit status
  96. * Corrupts:
  97. * none
  98. ****************************************************************************
  99. */
  100. /* Wyse Streaming Manager server (WLDRM13.BIN) assumes that
  101. * the PXENV+ entry point is at UNDI_CS:0000; apparently,
  102. * somebody at Wyse has difficulty distinguishing between the
  103. * words "may" and "must"...
  104. */
  105. .section ".text16.null", "ax", @progbits
  106. .code16
  107. pxenv_null_entry:
  108. jmp pxenv_entry
  109. .section ".text16", "ax", @progbits
  110. .code16
  111. pxenv_entry:
  112. pushl $pxe_api_call
  113. pushw %cs
  114. call prot_call
  115. addl $4, %esp
  116. lret
  117. .size pxenv_entry, . - pxenv_entry
  118. /****************************************************************************
  119. * pxe_entry
  120. *
  121. * PXE API call !PXE entry point
  122. *
  123. * Parameters:
  124. * stack : Far pointer to PXE parameter structure
  125. * stack : PXE API call
  126. * Returns:
  127. * %ax : PXE exit status
  128. * Corrupts:
  129. * none
  130. ****************************************************************************
  131. */
  132. .section ".text16", "ax", @progbits
  133. .code16
  134. pxe_entry:
  135. pxe_entry_sp:
  136. /* Preserve original %esp */
  137. pushl %esp
  138. /* Zero high word of %esp to allow use of common code */
  139. movzwl %sp, %esp
  140. jmp pxe_entry_common
  141. pxe_entry_esp:
  142. /* Preserve %esp to match behaviour of pxe_entry_sp */
  143. pushl %esp
  144. pxe_entry_common:
  145. /* Save PXENV+ API call registers */
  146. pushw %es
  147. pushw %di
  148. pushw %bx
  149. /* Load !PXE parameters from stack into PXENV+ registers */
  150. addr32 movw 18(%esp), %bx
  151. movw %bx, %es
  152. addr32 movw 16(%esp), %di
  153. addr32 movw 14(%esp), %bx
  154. /* Make call as for PXENV+ */
  155. pushw %cs
  156. call pxenv_entry
  157. /* Restore PXENV+ registers */
  158. popw %bx
  159. popw %di
  160. popw %es
  161. /* Restore original %esp and return */
  162. popl %esp
  163. lret
  164. .size pxe_entry, . - pxe_entry
  165. /****************************************************************************
  166. * pxe_int_1a
  167. *
  168. * PXE INT 1A handler
  169. *
  170. * Parameters:
  171. * %ax : 0x5650
  172. * Returns:
  173. * %ax : 0x564e
  174. * %es:bx : Far pointer to the PXENV+ structure
  175. * %edx : Physical address of the PXENV+ structure
  176. * CF cleared
  177. * Corrupts:
  178. * none
  179. ****************************************************************************
  180. */
  181. .section ".text16", "ax", @progbits
  182. .code16
  183. .globl pxe_int_1a
  184. pxe_int_1a:
  185. pushfw
  186. cmpw $0x5650, %ax
  187. jne 1f
  188. /* INT 1A,5650 - PXE installation check */
  189. xorl %edx, %edx
  190. movw %cs, %dx
  191. movw %dx, %es
  192. movw $pxenv, %bx
  193. shll $4, %edx
  194. addl $pxenv, %edx
  195. movw $0x564e, %ax
  196. pushw %bp
  197. movw %sp, %bp
  198. andb $~0x01, 8(%bp) /* Clear CF on return */
  199. popw %bp
  200. popfw
  201. iret
  202. 1: /* INT 1A,other - pass through */
  203. popfw
  204. ljmp *%cs:pxe_int_1a_vector
  205. .section ".text16.data", "aw", @progbits
  206. .globl pxe_int_1a_vector
  207. pxe_int_1a_vector: .long 0