• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef COMBOOT_H
2 #define COMBOOT_H
3 
4 /**
5  * @file
6  *
7  * SYSLINUX COMBOOT
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER );
11 
12 #include <stdint.h>
13 #include <setjmp.h>
14 #include <gpxe/in.h>
15 
16 /** Segment used for COMBOOT PSP and image */
17 #define COMBOOT_PSP_SEG 0x07C0
18 
19 /** Entry point address of COM32 images */
20 #define COM32_START_PHYS 0x101000
21 
22 /** COM32 bounce buffer segment */
23 #define COM32_BOUNCE_SEG 0x07C0
24 
25 /** Size of SYSLINUX file block in bytes */
26 #define COMBOOT_FILE_BLOCKSZ 512
27 
28 /** COMBOOT feature flags (INT 22h AX=15h) */
29 #define COMBOOT_FEATURE_LOCAL_BOOT (1 << 0)
30 #define COMBOOT_FEATURE_IDLE_LOOP  (1 << 1)
31 
32 /** Maximum number of shuffle descriptors for
33  * shuffle and boot functions
34  * (INT 22h AX=0012h, 001Ah, 001Bh)
35  */
36 #define COMBOOT_MAX_SHUFFLE_DESCRIPTORS 682
37 
38 typedef union {
39 	uint32_t l;
40 	uint16_t w[2];
41 	uint8_t  b[4];
42 } com32_reg32_t;
43 
44 typedef struct {
45 	uint16_t gs;                /* Offset  0 */
46 	uint16_t fs;                /* Offset  2 */
47 	uint16_t es;                /* Offset  4 */
48 	uint16_t ds;                /* Offset  6 */
49 
50 	com32_reg32_t edi;          /* Offset  8 */
51 	com32_reg32_t esi;          /* Offset 12 */
52 	com32_reg32_t ebp;          /* Offset 16 */
53 	com32_reg32_t _unused_esp;  /* Offset 20 */
54 	com32_reg32_t ebx;          /* Offset 24 */
55 	com32_reg32_t edx;          /* Offset 28 */
56 	com32_reg32_t ecx;          /* Offset 32 */
57 	com32_reg32_t eax;          /* Offset 36 */
58 
59 	com32_reg32_t eflags;       /* Offset 40 */
60 } com32sys_t;
61 
62 typedef struct {
63 	uint32_t eax;               /* Offset  0 */
64 	uint32_t ecx;               /* Offset  4 */
65 	uint32_t edx;               /* Offset  8 */
66 	uint32_t ebx;               /* Offset 12 */
67 	uint32_t esp;               /* Offset 16 */
68 	uint32_t ebp;               /* Offset 20 */
69 	uint32_t esi;               /* Offset 24 */
70 	uint32_t edi;               /* Offset 28 */
71 
72 	uint32_t eip;               /* Offset 32 */
73 } syslinux_pm_regs;
74 
75 typedef struct {
76 	uint16_t es;                /* Offset  0 */
77 	uint16_t _unused_cs;        /* Offset  2 */
78 	uint16_t ds;                /* Offset  4 */
79 	uint16_t ss;                /* Offset  6 */
80 	uint16_t fs;                /* Offset  8 */
81 	uint16_t gs;                /* Offset 10 */
82 
83 	uint32_t eax;                /* Offset 12 */
84 	uint32_t ecx;                /* Offset 16 */
85 	uint32_t edx;                /* Offset 20 */
86 	uint32_t ebx;                /* Offset 24 */
87 	uint32_t esp;                /* Offset 28 */
88 	uint32_t ebp;                /* Offset 32 */
89 	uint32_t esi;                /* Offset 36 */
90 	uint32_t edi;                /* Offset 40 */
91 
92 	uint16_t ip;                /* Offset 44 */
93 	uint16_t cs;                /* Offset 46 */
94 } syslinux_rm_regs;
95 
96 typedef struct {
97 	uint32_t dest;
98 	uint32_t src;
99 	uint32_t len;
100 } comboot_shuffle_descriptor;
101 
102 extern void hook_comboot_interrupts ( );
103 extern void unhook_comboot_interrupts ( );
104 
105 /* These are not the correct prototypes, but it doens't matter,
106  * as we only ever get the address of these functions;
107  * they are only called from COM32 code running in PHYS_CODE
108  */
109 extern void com32_intcall_wrapper ( );
110 extern void com32_farcall_wrapper ( );
111 extern void com32_cfarcall_wrapper ( );
112 
113 /* Resolve a hostname to an (IPv4) address */
114 extern int comboot_resolv ( const char *name, struct in_addr *address );
115 
116 /* setjmp/longjmp context buffer used to return after loading an image */
117 extern rmjmp_buf comboot_return;
118 
119 /* Replacement image when exiting with COMBOOT_EXIT_RUN_KERNEL */
120 extern struct image *comboot_replacement_image;
121 
122 extern void *com32_external_esp;
123 
124 #define COMBOOT_EXIT 1
125 #define COMBOOT_EXIT_RUN_KERNEL 2
126 #define COMBOOT_EXIT_COMMAND 3
127 
128 extern void comboot_force_text_mode ( void );
129 
130 #define COMBOOT_VIDEO_GRAPHICS    0x01
131 #define COMBOOT_VIDEO_NONSTANDARD 0x02
132 #define COMBOOT_VIDEO_VESA        0x04
133 #define COMBOOT_VIDEO_NOTEXT      0x08
134 
135 #endif
136