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.

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