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

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