Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

comboot.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #ifndef COMBOOT_H
  2. #define COMBOOT_H
  3. /**
  4. * @file
  5. *
  6. * SYSLINUX COMBOOT
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <stdint.h>
  10. #include <setjmp.h>
  11. #include <ipxe/in.h>
  12. /** Descriptor in a 32-bit IDT */
  13. struct idt_descriptor {
  14. uint16_t offset_low;
  15. uint16_t selector;
  16. uint16_t flags;
  17. uint16_t offset_high;
  18. } __attribute__ (( packed ));
  19. /** Operand for the LIDT instruction */
  20. struct idt_register {
  21. uint16_t limit;
  22. uint32_t base;
  23. } __attribute__ (( packed ));
  24. /** Entry in the interrupt jump buffer */
  25. struct ijb_entry {
  26. uint8_t pusha_instruction;
  27. uint8_t mov_instruction;
  28. uint8_t mov_value;
  29. uint8_t jump_instruction;
  30. uint32_t jump_destination;
  31. } __attribute__ (( packed ));
  32. /** The x86 opcode for "pushal" */
  33. #define IJB_PUSHA 0x60
  34. /** The x86 opcode for "movb $imm8,%al" */
  35. #define IJB_MOV_AL_IMM8 0xB0
  36. /** The x86 opcode for "jmp rel32" */
  37. #define IJB_JMP_REL32 0xE9
  38. /** Flags that specify a 32-bit interrupt gate with DPL=0 */
  39. #define IDT_INTERRUPT_GATE_FLAGS 0x8E00
  40. /** Address of COM32 interrupt descriptor table */
  41. #define COM32_IDT 0x100000
  42. /** Number of entries in a fully populated IDT */
  43. #define COM32_NUM_IDT_ENTRIES 256
  44. /** Address of COM32 interrupt jump buffer */
  45. #define COM32_IJB 0x100800
  46. /** Segment used for COMBOOT PSP and image */
  47. #define COMBOOT_PSP_SEG 0x07C0
  48. /** Entry point address of COM32 images */
  49. #define COM32_START_PHYS 0x101000
  50. /** COM32 bounce buffer segment */
  51. #define COM32_BOUNCE_SEG 0x07C0
  52. /** Size of SYSLINUX file block in bytes */
  53. #define COMBOOT_FILE_BLOCKSZ 512
  54. /** COMBOOT feature flags (INT 22h AX=15h) */
  55. #define COMBOOT_FEATURE_LOCAL_BOOT (1 << 0)
  56. #define COMBOOT_FEATURE_IDLE_LOOP (1 << 1)
  57. /** Maximum number of shuffle descriptors for
  58. * shuffle and boot functions
  59. * (INT 22h AX=0012h, 001Ah, 001Bh)
  60. */
  61. #define COMBOOT_MAX_SHUFFLE_DESCRIPTORS 682
  62. typedef union {
  63. uint32_t l;
  64. uint16_t w[2];
  65. uint8_t b[4];
  66. } com32_reg32_t;
  67. typedef struct {
  68. uint16_t gs; /* Offset 0 */
  69. uint16_t fs; /* Offset 2 */
  70. uint16_t es; /* Offset 4 */
  71. uint16_t ds; /* Offset 6 */
  72. com32_reg32_t edi; /* Offset 8 */
  73. com32_reg32_t esi; /* Offset 12 */
  74. com32_reg32_t ebp; /* Offset 16 */
  75. com32_reg32_t _unused_esp; /* Offset 20 */
  76. com32_reg32_t ebx; /* Offset 24 */
  77. com32_reg32_t edx; /* Offset 28 */
  78. com32_reg32_t ecx; /* Offset 32 */
  79. com32_reg32_t eax; /* Offset 36 */
  80. com32_reg32_t eflags; /* Offset 40 */
  81. } com32sys_t;
  82. typedef struct {
  83. uint32_t eax; /* Offset 0 */
  84. uint32_t ecx; /* Offset 4 */
  85. uint32_t edx; /* Offset 8 */
  86. uint32_t ebx; /* Offset 12 */
  87. uint32_t esp; /* Offset 16 */
  88. uint32_t ebp; /* Offset 20 */
  89. uint32_t esi; /* Offset 24 */
  90. uint32_t edi; /* Offset 28 */
  91. uint32_t eip; /* Offset 32 */
  92. } syslinux_pm_regs;
  93. typedef struct {
  94. uint16_t es; /* Offset 0 */
  95. uint16_t _unused_cs; /* Offset 2 */
  96. uint16_t ds; /* Offset 4 */
  97. uint16_t ss; /* Offset 6 */
  98. uint16_t fs; /* Offset 8 */
  99. uint16_t gs; /* Offset 10 */
  100. uint32_t eax; /* Offset 12 */
  101. uint32_t ecx; /* Offset 16 */
  102. uint32_t edx; /* Offset 20 */
  103. uint32_t ebx; /* Offset 24 */
  104. uint32_t esp; /* Offset 28 */
  105. uint32_t ebp; /* Offset 32 */
  106. uint32_t esi; /* Offset 36 */
  107. uint32_t edi; /* Offset 40 */
  108. uint16_t ip; /* Offset 44 */
  109. uint16_t cs; /* Offset 46 */
  110. } syslinux_rm_regs;
  111. typedef struct {
  112. uint32_t dest;
  113. uint32_t src;
  114. uint32_t len;
  115. } comboot_shuffle_descriptor;
  116. extern void hook_comboot_interrupts ( );
  117. extern void unhook_comboot_interrupts ( );
  118. /* These are not the correct prototypes, but it doens't matter,
  119. * as we only ever get the address of these functions;
  120. * they are only called from COM32 code running in PHYS_CODE
  121. */
  122. extern void com32_intcall_wrapper ( );
  123. extern void com32_farcall_wrapper ( );
  124. extern void com32_cfarcall_wrapper ( );
  125. extern void com32_irq_wrapper ( );
  126. /* Resolve a hostname to an (IPv4) address */
  127. extern int comboot_resolv ( const char *name, struct in_addr *address );
  128. /* setjmp/longjmp context buffer used to return after loading an image */
  129. extern rmjmp_buf comboot_return;
  130. extern void *com32_external_esp;
  131. #define COMBOOT_EXIT 1
  132. #define COMBOOT_EXIT_RUN_KERNEL 2
  133. #define COMBOOT_EXIT_COMMAND 3
  134. extern void comboot_force_text_mode ( void );
  135. #define COMBOOT_VIDEO_GRAPHICS 0x01
  136. #define COMBOOT_VIDEO_NONSTANDARD 0x02
  137. #define COMBOOT_VIDEO_VESA 0x04
  138. #define COMBOOT_VIDEO_NOTEXT 0x08
  139. #endif