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.

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