Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (C) 2011 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. /* Initial temporary stack size */
  27. #define EXE_STACK_SIZE 0x400
  28. /* Temporary decompression area (avoid DOS high memory area) */
  29. #define EXE_DECOMPRESS_ADDRESS 0x110000
  30. /* Fields within the Program Segment Prefix */
  31. #define PSP_CMDLINE_LEN 0x80
  32. #define PSP_CMDLINE_START 0x81
  33. .text
  34. .arch i386
  35. .org 0
  36. .code16
  37. .section ".prefix", "awx", @progbits
  38. signature:
  39. /* "MZ" signature */
  40. .ascii "MZ"
  41. last_block:
  42. /* Number of bytes in last block that are really used */
  43. .word 0
  44. blocks:
  45. /* Number of 512-byte blocks */
  46. .word 0
  47. .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
  48. .ascii "ADDW"
  49. .long blocks
  50. .long 512
  51. .long 0
  52. .previous
  53. num_reloc:
  54. /* Number of relocation entries stored after the header */
  55. .word 0
  56. header_pgh:
  57. /* Number of paragraphs in the header */
  58. .word ( ( _exe_start - signature ) / 16 )
  59. min_bss_pgh:
  60. /* Minimum number of paragraphs of additional (BSS) memory */
  61. .word ( EXE_STACK_SIZE / 16 )
  62. max_bss_pgh:
  63. /* Maximum number of paragraphs of additional (BSS) memory */
  64. .word ( EXE_STACK_SIZE / 16 )
  65. init_ss:
  66. /* Initial stack segment (relative to start of executable) */
  67. .word -( ( _exe_start - signature ) / 16 )
  68. .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
  69. .ascii "ADDW"
  70. .long init_ss
  71. .long 16
  72. .long 0
  73. .previous
  74. init_sp:
  75. /* Initial stack pointer */
  76. .word EXE_STACK_SIZE
  77. checksum:
  78. /* Checksum (ignored) */
  79. .word 0
  80. init_ip:
  81. /* Initial instruction pointer */
  82. .word _exe_start
  83. init_cs:
  84. /* Initial code segment (relative to start of executable) */
  85. .word -( ( _exe_start - signature ) / 16 )
  86. reloc_table:
  87. /* Relocation table offset */
  88. .word 0
  89. overlay:
  90. /* Overlay number */
  91. .word 0
  92. .align 16, 0
  93. .globl _exe_start
  94. _exe_start:
  95. /* Install iPXE. Use a fixed temporary decompression area to
  96. * avoid trashing the DOS high memory area.
  97. */
  98. call alloc_basemem
  99. xorl %esi, %esi
  100. movl $EXE_DECOMPRESS_ADDRESS, %edi
  101. orl $0xffffffff, %ebp /* Allow arbitrary relocation */
  102. call install_prealloc
  103. /* Set up real-mode stack */
  104. movw %bx, %ss
  105. movw $_estack16, %sp
  106. /* Jump to .text16 segment */
  107. pushw %ax
  108. pushw $1f
  109. lret
  110. .section ".text16", "awx", @progbits
  111. 1:
  112. /* Terminate command line with a NUL */
  113. movzbw PSP_CMDLINE_LEN, %si
  114. movb $0, PSP_CMDLINE_START(%si)
  115. /* Calculate command line physical address */
  116. xorl %esi, %esi
  117. movw %ds, %si
  118. shll $4, %esi
  119. addl $PSP_CMDLINE_START, %esi
  120. /* Set up %ds for access to .data16 */
  121. movw %bx, %ds
  122. /* Record command line address */
  123. movl %esi, cmdline_phys
  124. /* Run iPXE */
  125. virtcall main
  126. /* Uninstall iPXE */
  127. call uninstall
  128. /* Exit back to DOS. This is very unlikely to work */
  129. movw $0x4c00, %ax
  130. int $0x21