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.

comprefix.S 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* We need a real mode stack that won't be stomped on by Etherboot
  2. which starts at 0x20000. Choose something that's sufficiently high,
  3. but not in DOC territory. Note that we couldn't do this in a real
  4. .com program since stack variables are in the same segment as the
  5. code and data, but this isn't really a .com program, it just looks
  6. like one to make DOS load it into memory. It still has the 64kB
  7. limitation of .com files though. */
  8. #define STACK_SEG 0x7000
  9. #define STACK_SIZE 0x4000
  10. .text
  11. .code16
  12. .arch i386
  13. .section ".prefix", "ax", @progbits
  14. /* Cheat a little with the relocations: .COM files are loaded at 0x100 */
  15. _prefix:
  16. /* Set up temporary stack */
  17. movw $STACK_SEG, %ax
  18. movw %ax, %ss
  19. movw $STACK_SIZE, %sp
  20. pushl $0 /* No parameters to preserve for exit path */
  21. pushw $0 /* Dummy return address - use prefix_exit */
  22. /* Calculate segment address of image start */
  23. pushw %cs
  24. popw %ax
  25. addw $(0x100/16), %ax
  26. pushw %ax
  27. pushw $_start
  28. /* Calculated lcall to _start with %cs:0000 = image start */
  29. lret
  30. .section ".text16", "ax", @progbits
  31. prefix_exit:
  32. movw $0x4c00,%ax /* return to DOS */
  33. int $0x21 /* reach this on Quit */
  34. prefix_exit_end:
  35. .previous
  36. /* The body of etherboot is attached here at build time.
  37. * Force 16 byte alignment
  38. */
  39. .align 16,0
  40. _body: