iPXE
comboot_call.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Daniel Verkamp <daniel@drv.nu>.
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 
20 /**
21  * @file SYSLINUX COMBOOT API
22  *
23  */
24 
25 FILE_LICENCE ( GPL2_OR_LATER );
26 
27 #include <errno.h>
28 #include <realmode.h>
29 #include <biosint.h>
30 #include <ipxe/console.h>
31 #include <stdlib.h>
32 #include <comboot.h>
33 #include <bzimage.h>
34 #include <pxe_call.h>
35 #include <rmsetjmp.h>
36 #include <string.h>
37 #include <ipxe/posix_io.h>
38 #include <ipxe/process.h>
39 #include <ipxe/serial.h>
40 #include <ipxe/ns16550.h>
41 #include <ipxe/init.h>
42 #include <ipxe/image.h>
43 #include <ipxe/version.h>
44 #include <usr/imgmgmt.h>
45 
46 /** The "SYSLINUX" version string */
47 static char __bss16_array ( syslinux_version, [32] );
48 #define syslinux_version __use_data16 ( syslinux_version )
49 
50 /** The "SYSLINUX" copyright string */
51 static char __data16_array ( syslinux_copyright, [] ) = " https://ipxe.org";
52 #define syslinux_copyright __use_data16 ( syslinux_copyright )
53 
54 static char __data16_array ( syslinux_configuration_file, [] ) = "";
55 #define syslinux_configuration_file __use_data16 ( syslinux_configuration_file )
56 
57 /** Feature flags */
59 #define comboot_feature_flags __use_data16 ( comboot_feature_flags )
60 
61 typedef union {
64 
65 /** Initial register values for INT 22h AX=1Ah and 1Bh */
67 #define comboot_initial_regs __use_text16 ( comboot_initial_regs )
68 
69 static struct segoff __text16 ( int20_vector );
70 #define int20_vector __use_text16 ( int20_vector )
71 
72 static struct segoff __text16 ( int21_vector );
73 #define int21_vector __use_text16 ( int21_vector )
74 
75 static struct segoff __text16 ( int22_vector );
76 #define int22_vector __use_text16 ( int22_vector )
77 
78 extern void int20_wrapper ( void );
79 extern void int21_wrapper ( void );
80 extern void int22_wrapper ( void );
81 
82 /* setjmp/longjmp context buffer used to return after loading an image */
84 
85 /* Mode flags set by INT 22h AX=0017h */
87 
88 /**
89  * Print a string with a particular terminator
90  */
91 static void print_user_string ( unsigned int segment, unsigned int offset, char terminator ) {
92  char *c;
93  for ( c = real_to_virt ( segment, offset ) ; *c != terminator ; c++ ) {
94  putchar ( *c );
95  }
96 }
97 
98 
99 /**
100  * Perform a series of memory copies from a list in low memory
101  */
102 static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsigned int count )
103 {
105  unsigned int i;
106 
107  /* Copy shuffle descriptor list so it doesn't get overwritten */
108  memcpy ( shuf, real_to_virt ( list_segment, list_offset ),
109  count * sizeof( comboot_shuffle_descriptor ) );
110 
111  /* Do the copies */
112  for ( i = 0; i < count; i++ ) {
113  const void *src = phys_to_virt ( shuf[ i ].src );
114  void *dest = phys_to_virt ( shuf[ i ].dest );
115 
116  if ( shuf[ i ].src == 0xFFFFFFFF ) {
117  /* Fill with 0 instead of copying */
118  memset ( dest, 0, shuf[ i ].len );
119  } else if ( shuf[ i ].dest == 0xFFFFFFFF ) {
120  /* Copy new list of descriptors */
121  count = shuf[ i ].len / sizeof( comboot_shuffle_descriptor );
123  memcpy ( shuf, src, shuf[ i ].len );
124  i = -1;
125  } else {
126  /* Regular copy */
127  memmove ( dest, src, shuf[ i ].len );
128  }
129  }
130 }
131 
132 
133 /**
134  * Set default text mode
135  */
136 void comboot_force_text_mode ( void ) {
138  /* Set VGA mode 3 via VESA VBE mode set */
140  REAL_CODE (
141  "mov $0x4F02, %%ax\n\t"
142  "mov $0x03, %%bx\n\t"
143  "int $0x10\n\t"
144  )
145  : : );
147  /* Set VGA mode 3 via standard VGA mode set */
149  REAL_CODE (
150  "mov $0x03, %%ax\n\t"
151  "int $0x10\n\t"
152  )
153  : : );
154  }
155 
157 }
158 
159 
160 /**
161  * Fetch kernel and optional initrd
162  */
163 static int comboot_fetch_kernel ( const char *kernel_file, char *cmdline ) {
164  struct image *kernel;
165  struct image *initrd;
166  char *initrd_file;
167  int rc;
168 
169  /* Find initrd= parameter, if any */
170  if ( ( initrd_file = strstr ( cmdline, "initrd=" ) ) != NULL ) {
171  char *initrd_end;
172 
173  /* skip "initrd=" */
174  initrd_file += 7;
175 
176  /* Find terminating space, if any, and replace with NUL */
177  initrd_end = strchr ( initrd_file, ' ' );
178  if ( initrd_end )
179  *initrd_end = '\0';
180 
181  DBG ( "COMBOOT: fetching initrd '%s'\n", initrd_file );
182 
183  /* Fetch initrd */
184  if ( ( rc = imgdownload_string ( initrd_file, 0,
185  &initrd ) ) != 0 ) {
186  DBG ( "COMBOOT: could not fetch initrd: %s\n",
187  strerror ( rc ) );
188  return rc;
189  }
190 
191  /* Restore space after initrd name, if applicable */
192  if ( initrd_end )
193  *initrd_end = ' ';
194  }
195 
196  DBG ( "COMBOOT: fetching kernel '%s'\n", kernel_file );
197 
198  /* Fetch kernel */
199  if ( ( rc = imgdownload_string ( kernel_file, 0, &kernel ) ) != 0 ) {
200  DBG ( "COMBOOT: could not fetch kernel: %s\n",
201  strerror ( rc ) );
202  return rc;
203  }
204 
205  /* Replace comboot image with kernel */
206  if ( ( rc = image_replace ( kernel ) ) != 0 ) {
207  DBG ( "COMBOOT: could not replace with kernel: %s\n",
208  strerror ( rc ) );
209  return rc;
210  }
211 
212  return 0;
213 }
214 
215 
216 /**
217  * Terminate program interrupt handler
218  */
219 static __asmcall __used void int20 ( struct i386_all_regs *ix86 __unused ) {
221 }
222 
223 
224 /**
225  * DOS-compatible API
226  */
227 static __asmcall __used void int21 ( struct i386_all_regs *ix86 ) {
228  ix86->flags |= CF;
229 
230  switch ( ix86->regs.ah ) {
231  case 0x00:
232  case 0x4C: /* Terminate program */
234  break;
235 
236  case 0x01: /* Get Key with Echo */
237  case 0x08: /* Get Key without Echo */
238  /* TODO: handle extended characters? */
239  ix86->regs.al = getchar( );
240 
241  /* Enter */
242  if ( ix86->regs.al == 0x0A )
243  ix86->regs.al = 0x0D;
244 
245  if ( ix86->regs.ah == 0x01 )
246  putchar ( ix86->regs.al );
247 
248  ix86->flags &= ~CF;
249  break;
250 
251  case 0x02: /* Write Character */
252  putchar ( ix86->regs.dl );
253  ix86->flags &= ~CF;
254  break;
255 
256  case 0x04: /* Write Character to Serial Port */
257  if ( serial_console ) {
258  uart_transmit ( serial_console, ix86->regs.dl );
259  ix86->flags &= ~CF;
260  }
261  break;
262 
263  case 0x09: /* Write DOS String to Console */
264  print_user_string ( ix86->segs.ds, ix86->regs.dx, '$' );
265  ix86->flags &= ~CF;
266  break;
267 
268  case 0x0B: /* Check Keyboard */
269  if ( iskey() )
270  ix86->regs.al = 0xFF;
271  else
272  ix86->regs.al = 0x00;
273 
274  ix86->flags &= ~CF;
275  break;
276 
277  case 0x30: /* Check DOS Version */
278  /* Bottom halves all 0; top halves spell "SYSLINUX" */
279  ix86->regs.eax = 0x59530000;
280  ix86->regs.ebx = 0x4C530000;
281  ix86->regs.ecx = 0x4E490000;
282  ix86->regs.edx = 0x58550000;
283  ix86->flags &= ~CF;
284  break;
285 
286  default:
287  DBG ( "COMBOOT unknown int21 function %02x\n", ix86->regs.ah );
288  break;
289  }
290 }
291 
292 
293 /**
294  * Dispatch PXE API call weakly
295  *
296  * @v ix86 Registers for PXE call
297  * @ret present Zero if the PXE stack is present, nonzero if not
298  *
299  * A successful return only indicates that the PXE stack was available
300  * for dispatching the call; it says nothing about the success of
301  * whatever the call asked for.
302  */
304  return -1;
305 }
306 
307 /**
308  * SYSLINUX API
309  */
310 static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
311  ix86->flags |= CF;
312 
313  switch ( ix86->regs.ax ) {
314  case 0x0001: /* Get Version */
315 
316  /* Number of INT 22h API functions available */
317  ix86->regs.ax = 0x001D;
318 
319  /* SYSLINUX version number */
320  ix86->regs.ch = 0; /* major */
321  ix86->regs.cl = 0; /* minor */
322 
323  /* SYSLINUX derivative ID */
324  ix86->regs.dl = BZI_LOADER_TYPE_IPXE;
325 
326  /* SYSLINUX version */
328  "\r\niPXE %s", product_version );
329 
330  /* SYSLINUX version and copyright strings */
331  ix86->segs.es = rm_ds;
332  ix86->regs.si = ( ( unsigned ) __from_data16 ( syslinux_version ) );
333  ix86->regs.di = ( ( unsigned ) __from_data16 ( syslinux_copyright ) );
334 
335  ix86->flags &= ~CF;
336  break;
337 
338  case 0x0002: /* Write String */
339  print_user_string ( ix86->segs.es, ix86->regs.bx, '\0' );
340  ix86->flags &= ~CF;
341  break;
342 
343  case 0x0003: /* Run command */
344  {
345  const char *cmd = real_to_virt ( ix86->segs.es,
346  ix86->regs.bx );
347  DBG ( "COMBOOT: executing command '%s'\n", cmd );
348  system ( cmd );
349  DBG ( "COMBOOT: exiting after executing command...\n" );
351  }
352  break;
353 
354  case 0x0004: /* Run default command */
355  /* FIXME: just exit for now */
357  break;
358 
359  case 0x0005: /* Force text mode */
361  ix86->flags &= ~CF;
362  break;
363 
364  case 0x0006: /* Open file */
365  {
366  int fd;
367  const char *file = real_to_virt ( ix86->segs.es,
368  ix86->regs.si );
369 
370  if ( file[0] == '\0' ) {
371  DBG ( "COMBOOT: attempted open with empty file name\n" );
372  break;
373  }
374 
375  DBG ( "COMBOOT: opening file '%s'\n", file );
376 
377  fd = open ( file );
378 
379  if ( fd < 0 ) {
380  DBG ( "COMBOOT: error opening file %s\n", file );
381  break;
382  }
383 
384  /* This relies on the fact that a iPXE POSIX fd will
385  * always fit in 16 bits.
386  */
387 #if (POSIX_FD_MAX > 65535)
388 #error POSIX_FD_MAX too large
389 #endif
390  ix86->regs.si = (uint16_t) fd;
391 
392  ix86->regs.cx = COMBOOT_FILE_BLOCKSZ;
393  ix86->regs.eax = fsize ( fd );
394  ix86->flags &= ~CF;
395  }
396  break;
397 
398  case 0x0007: /* Read file */
399  {
400  int fd = ix86->regs.si;
401  int len = ix86->regs.cx * COMBOOT_FILE_BLOCKSZ;
402  int rc;
403  fd_set fds;
404  void *buf = real_to_virt ( ix86->segs.es,
405  ix86->regs.bx );
406 
407  /* Wait for data ready to read */
408  FD_ZERO ( &fds );
409  FD_SET ( fd, &fds );
410 
411  select ( &fds, 1 );
412 
413  rc = read ( fd, buf, len );
414  if ( rc < 0 ) {
415  DBG ( "COMBOOT: read failed\n" );
416  ix86->regs.si = 0;
417  break;
418  }
419 
420  ix86->regs.ecx = rc;
421  ix86->flags &= ~CF;
422  }
423  break;
424 
425  case 0x0008: /* Close file */
426  {
427  int fd = ix86->regs.si;
428  close ( fd );
429  ix86->flags &= ~CF;
430  }
431  break;
432 
433  case 0x0009: /* Call PXE Stack */
434  if ( pxe_api_call_weak ( ix86 ) != 0 )
435  ix86->flags |= CF;
436  else
437  ix86->flags &= ~CF;
438  break;
439 
440  case 0x000A: /* Get Derivative-Specific Information */
441 
442  /* iPXE has its own derivative ID, so there is no defined
443  * output here; just return AL for now */
444  ix86->regs.al = BZI_LOADER_TYPE_IPXE;
445  ix86->flags &= ~CF;
446  break;
447 
448  case 0x000B: /* Get Serial Console Configuration */
449  if ( serial_console ) {
450  struct ns16550_uart *comport = serial_console->priv;
451 
452  ix86->regs.dx = ( ( intptr_t ) comport->base );
453  ix86->regs.cx = comport->divisor;
454  ix86->regs.bx = 0;
455  ix86->flags &= ~CF;
456  }
457  break;
458 
459  case 0x000C: /* Perform final cleanup */
460  shutdown_boot();
461  break;
462 
463  case 0x000E: /* Get configuration file name */
464  /* FIXME: stub */
465  ix86->segs.es = rm_ds;
466  ix86->regs.bx = ( ( unsigned ) __from_data16 ( syslinux_configuration_file ) );
467  ix86->flags &= ~CF;
468  break;
469 
470  case 0x000F: /* Get IPAPPEND strings */
471  /* FIXME: stub */
472  ix86->regs.cx = 0;
473  ix86->segs.es = 0;
474  ix86->regs.bx = 0;
475  ix86->flags &= ~CF;
476  break;
477 
478  case 0x0010: /* Resolve hostname */
479  {
480  const char *hostname = real_to_virt ( ix86->segs.es,
481  ix86->regs.bx );
482  struct in_addr addr;
483 
484  /* TODO:
485  * "If the hostname does not contain a dot (.), the
486  * local domain name is automatically appended."
487  */
488 
489  comboot_resolv ( hostname, &addr );
490 
491  ix86->regs.eax = addr.s_addr;
492  ix86->flags &= ~CF;
493  }
494  break;
495 
496  case 0x0011: /* Maximum number of shuffle descriptors */
498  ix86->flags &= ~CF;
499  break;
500 
501  case 0x0012: /* Cleanup, shuffle and boot */
503  break;
504 
505  /* Perform final cleanup */
506  shutdown_boot();
507 
508  /* Perform sequence of copies */
509  shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );
510 
511  /* Jump to real-mode entry point */
513  REAL_CODE (
514  "pushw %0\n\t"
515  "popw %%ds\n\t"
516  "pushl %1\n\t"
517  "lret\n\t"
518  )
519  :
520  : "R" ( ix86->segs.ds ),
521  "R" ( ix86->regs.ebp ),
522  "d" ( ix86->regs.ebx ),
523  "S" ( ix86->regs.esi ) );
524 
525  assert ( 0 ); /* Execution should never reach this point */
526 
527  break;
528 
529  case 0x0013: /* Idle loop call */
530  step ( );
531  ix86->flags &= ~CF;
532  break;
533 
534  case 0x0015: /* Get feature flags */
535  ix86->segs.es = rm_ds;
536  ix86->regs.bx = ( ( unsigned ) __from_data16 ( &comboot_feature_flags ) );
537  ix86->regs.cx = 1; /* Number of feature flag bytes */
538  ix86->flags &= ~CF;
539  break;
540 
541  case 0x0016: /* Run kernel image */
542  {
543  const char *file = real_to_virt ( ix86->segs.ds,
544  ix86->regs.si );
545  char *cmd = real_to_virt ( ix86->segs.es,
546  ix86->regs.bx );
547 
548  DBG ( "COMBOOT: run kernel %s %s\n", file, cmd );
549  comboot_fetch_kernel ( file, cmd );
550  /* Technically, we should return if we
551  * couldn't load the kernel, but it's not safe
552  * to do that since we have just overwritten
553  * part of the COMBOOT program's memory space.
554  */
555  DBG ( "COMBOOT: exiting to run kernel...\n" );
557  }
558  break;
559 
560  case 0x0017: /* Report video mode change */
561  comboot_graphics_mode = ix86->regs.bx;
562  ix86->flags &= ~CF;
563  break;
564 
565  case 0x0018: /* Query custom font */
566  /* FIXME: stub */
567  ix86->regs.al = 0;
568  ix86->segs.es = 0;
569  ix86->regs.bx = 0;
570  ix86->flags &= ~CF;
571  break;
572 
573  case 0x001B: /* Cleanup, shuffle and boot to real mode */
575  break;
576 
577  /* Perform final cleanup */
578  shutdown_boot();
579 
580  /* Perform sequence of copies */
581  shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );
582 
583  /* Copy initial register values to .text16 */
585  real_to_virt ( ix86->segs.ds, ix86->regs.si ),
586  sizeof(syslinux_rm_regs) );
587 
588  /* Load initial register values */
590  REAL_CODE (
591  /* Point SS:SP at the register value structure */
592  "pushw %%cs\n\t"
593  "popw %%ss\n\t"
594  "movw $comboot_initial_regs, %%sp\n\t"
595 
596  /* Segment registers */
597  "popw %%es\n\t"
598  "popw %%ax\n\t" /* Skip CS */
599  "popw %%ds\n\t"
600  "popw %%ax\n\t" /* Skip SS for now */
601  "popw %%fs\n\t"
602  "popw %%gs\n\t"
603 
604  /* GP registers */
605  "popl %%eax\n\t"
606  "popl %%ecx\n\t"
607  "popl %%edx\n\t"
608  "popl %%ebx\n\t"
609  "popl %%ebp\n\t" /* Skip ESP for now */
610  "popl %%ebp\n\t"
611  "popl %%esi\n\t"
612  "popl %%edi\n\t"
613 
614  /* Load correct SS:ESP */
615  "movw $(comboot_initial_regs + 6), %%sp\n\t"
616  "popw %%ss\n\t"
617  "movl %%cs:(comboot_initial_regs + 28), %%esp\n\t"
618 
619  "ljmp *%%cs:(comboot_initial_regs + 44)\n\t"
620  )
621  : : );
622 
623  break;
624 
625  case 0x001C: /* Get pointer to auxilliary data vector */
626  /* FIXME: stub */
627  ix86->regs.cx = 0; /* Size of the ADV */
628  ix86->flags &= ~CF;
629  break;
630 
631  case 0x001D: /* Write auxilliary data vector */
632  /* FIXME: stub */
633  ix86->flags &= ~CF;
634  break;
635 
636  default:
637  DBG ( "COMBOOT unknown int22 function %04x\n", ix86->regs.ax );
638  break;
639  }
640 }
641 
642 /**
643  * Hook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h)
644  */
646 
648  TEXT16_CODE ( "\nint20_wrapper:\n\t"
649  VIRT_CALL ( int20 )
650  "clc\n\t"
651  "call patch_cf\n\t"
652  "iret\n\t" ) : );
653 
655 
657  TEXT16_CODE ( "\nint21_wrapper:\n\t"
658  VIRT_CALL ( int21 )
659  "clc\n\t"
660  "call patch_cf\n\t"
661  "iret\n\t" ) : );
662 
664 
666  TEXT16_CODE ( "\nint22_wrapper:\n\t"
667  VIRT_CALL ( int22 )
668  "clc\n\t"
669  "call patch_cf\n\t"
670  "iret\n\t" ) : );
671 
673 }
674 
675 /**
676  * Unhook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h)
677  */
679 
681  &int20_vector );
682 
684  &int21_vector );
685 
687  &int22_vector );
688 }
689 
690 /* Avoid dragging in serial console support unconditionally */
691 struct uart *serial_console __attribute__ (( weak ));
#define syslinux_configuration_file
Definition: comboot_call.c:55
static void print_user_string(unsigned int segment, unsigned int offset, char terminator)
Print a string with a particular terminator.
Definition: comboot_call.c:91
#define __attribute__(x)
Definition: compiler.h:10
struct option_descriptor read[1]
Definition: nvo_cmd.c:115
uint16_t segment
Code segment.
Definition: librm.h:138
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
#define CF
Definition: registers.h:181
static uint8_t __data16(comboot_feature_flags)
Feature flags.
struct i386_seg_regs segs
Definition: registers.h:175
uint32_t ebp
Definition: registers.h:73
#define syslinux_copyright
Definition: comboot_call.c:52
#define VIRT_CALL(function)
Call C function from real-mode code.
Definition: librm.h:72
uint16_t es
Definition: registers.h:142
Error codes.
A generic UART.
Definition: uart.h:17
void * base
Register base address.
Definition: ns16550.h:82
#define __from_text16(pointer)
Definition: libkir.h:23
static syslinux_regs __text16(comboot_initial_regs)
Initial register values for INT 22h AX=1Ah and 1Bh.
uint32_t flags
Definition: registers.h:177
SYSLINUX COMBOOT.
#define COMBOOT_VIDEO_VESA
Definition: comboot.h:127
#define COMBOOT_FEATURE_IDLE_LOOP
Definition: comboot.h:30
PXE API entry point.
An executable image.
Definition: image.h:23
Serial console.
static physaddr_t initrd_end
End of reshuffle region.
Definition: initrd.c:42
uint32_t eax
Definition: registers.h:109
#define rm_ds
Definition: libkir.h:39
unsigned long intptr_t
Definition: stdint.h:21
16550-compatible UART
A full register dump.
Definition: registers.h:174
__weak int pxe_api_call_weak(struct i386_all_regs *ix86 __unused)
Dispatch PXE API call weakly.
Definition: comboot_call.c:303
static __always_inline void * real_to_virt(unsigned int segment, unsigned int offset)
Convert segment:offset address to virtual address.
Definition: realmode.h:77
void hook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Hook INT vector.
Definition: biosint.c:25
int unhook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Unhook INT vector.
Definition: biosint.c:70
ssize_t fsize(int fd)
Determine file size.
Definition: posix_io.c:310
char * strstr(const char *haystack, const char *needle)
Find substring.
Definition: string.c:309
struct uart * serial_console
Active serial console UART.
Definition: comboot_call.c:691
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define __asmcall
Declare a function with standard calling conventions.
Definition: compiler.h:15
#define COMBOOT_EXIT
Definition: comboot.h:119
#define __used
Declare a function as used.
Definition: compiler.h:605
uint32_t esi
Definition: registers.h:69
void int22_wrapper(void)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
rmjmp_buf comboot_return
Definition: comboot_call.c:83
struct i386_regs regs
Definition: registers.h:176
static const void * src
Definition: string.h:47
Executable images.
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
ring len
Length.
Definition: dwmac.h:231
syslinux_rm_regs rm
Definition: comboot_call.c:62
void comboot_force_text_mode(void)
Set default text mode.
Definition: comboot_call.c:136
uint16_t cx
Definition: registers.h:100
static unsigned int count
Number of entries.
Definition: dwmac.h:225
#define BZI_LOADER_TYPE_IPXE
bzImage boot loader identifier for iPXE
Definition: bzimage.h:93
uint16_t divisor
Baud rate divisor.
Definition: ns16550.h:88
uint16_t dx
Definition: registers.h:92
uint32_t kernel
Kernel version (numeric)
Definition: ena.h:20
static uint16_t comboot_graphics_mode
Definition: comboot_call.c:86
User interaction.
uint16_t bx
Definition: registers.h:84
uint32_t fd_set
File descriptor set as used for select()
Definition: posix_io.h:21
int getchar(void)
Read a single character from any console.
Definition: console.c:85
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int comboot_fetch_kernel(const char *kernel_file, char *cmdline)
Fetch kernel and optional initrd.
Definition: comboot_call.c:163
static char __bss16_array(syslinux_version, [32])
The "SYSLINUX" version string.
void unhook_comboot_interrupts()
Unhook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h)
Definition: comboot_call.c:678
static char __data16_array(syslinux_copyright, [])
The "SYSLINUX" copyright string.
IP address structure.
Definition: in.h:41
uint8_t ah
Definition: registers.h:106
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:271
void * priv
Driver-private data.
Definition: uart.h:31
int image_replace(struct image *replacement)
Set replacement image.
Definition: image.c:528
A 16550-compatible UART.
Definition: ns16550.h:80
uint32_t addr
Buffer address.
Definition: dwmac.h:20
#define comboot_feature_flags
Definition: comboot_call.c:59
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
uint16_t ds
Definition: registers.h:141
Processes.
const char product_version[]
Product version string.
Definition: version.c:70
unsigned char uint8_t
Definition: stdint.h:10
int select(fd_set *readfds, int wait)
Check file descriptors for readiness.
Definition: posix_io.c:229
#define int21_vector
Definition: comboot_call.c:73
Version number.
void int21_wrapper(void)
void * memmove(void *dest, const void *src, size_t len) __nonnull
uint32_t ecx
Definition: registers.h:101
static void shuffle(unsigned int list_segment, unsigned int list_offset, unsigned int count)
Perform a series of memory copies from a list in low memory.
Definition: comboot_call.c:102
#define COMBOOT_EXIT_RUN_KERNEL
Definition: comboot.h:120
int comboot_resolv(const char *name, struct in_addr *address)
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
void hook_comboot_interrupts()
Hook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h)
Definition: comboot_call.c:645
#define int20_vector
Definition: comboot_call.c:70
uint8_t cl
Definition: registers.h:97
uint16_t di
Definition: registers.h:64
Image management.
uint32_t ebx
Definition: registers.h:85
#define __from_data16(pointer)
Definition: libkir.h:22
int imgdownload_string(const char *uri_string, unsigned long timeout, struct image **image)
Download a new image.
Definition: imgmgmt.c:120
uint16_t ax
Definition: registers.h:108
#define COMBOOT_EXIT_COMMAND
Definition: comboot.h:121
void step(void)
Single-step a single process.
Definition: process.c:98
#define syslinux_version
Definition: comboot_call.c:48
static __asmcall __used void int22(struct i386_all_regs *ix86)
SYSLINUX API.
Definition: comboot_call.c:310
FILE_LICENCE(GPL2_OR_LATER)
int open(const char *uri_string)
Open file.
Definition: posix_io.c:176
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150
#define rm_cs
Definition: libkir.h:38
#define __weak
Declare a function as weak (use before the definition)
Definition: compiler.h:219
#define COMBOOT_MAX_SHUFFLE_DESCRIPTORS
Maximum number of shuffle descriptors for shuffle and boot functions (INT 22h AX=0012h,...
Definition: comboot.h:36
void int20_wrapper(void)
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
uint32_t edx
Definition: registers.h:93
static struct evtchn_close * close
Definition: xenevent.h:23
static __asmcall __used void int20(struct i386_all_regs *ix86 __unused)
Terminate program interrupt handler.
Definition: comboot_call.c:219
static __asmcall __used void int21(struct i386_all_regs *ix86)
DOS-compatible API.
Definition: comboot_call.c:227
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
uint16_t si
Definition: registers.h:68
uint8_t al
Definition: registers.h:105
POSIX-like I/O.
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define rmlongjmp(_env, _val)
Definition: rmsetjmp.h:22
uint32_t cmdline
Definition: multiboot.h:16
struct eth_slow_terminator_tlv terminator
Terminator.
Definition: eth_slow.h:20
#define comboot_initial_regs
Definition: comboot_call.c:67
static void shutdown_boot(void)
Shut down system for OS boot.
Definition: init.h:77
#define int22_vector
Definition: comboot_call.c:76
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
int putchar(int character)
Write a single character to each console device.
Definition: console.c:28
#define COMBOOT_VIDEO_GRAPHICS
Definition: comboot.h:125
String functions.
uint8_t ch
Definition: registers.h:98
int iskey(void)
Check for available input on any console.
Definition: console.c:130
A real-mode-extended jump buffer.
Definition: rmsetjmp.h:10
#define COMBOOT_FILE_BLOCKSZ
Size of SYSLINUX file block in bytes.
Definition: comboot.h:26
#define TEXT16_CODE(asm_code_str)
Definition: libkir.h:217
uint8_t system[ETH_ALEN]
System identifier.
Definition: eth_slow.h:24
uint8_t dl
Definition: registers.h:89
void * memset(void *dest, int character, size_t len) __nonnull