#include <errno.h>#include <realmode.h>#include <biosint.h>#include <console.h>#include <stdlib.h>#include <comboot.h>#include <bzimage.h>#include <pxe_call.h>#include <setjmp.h>#include <string.h>#include <gpxe/posix_io.h>#include <gpxe/process.h>#include <gpxe/serial.h>#include <gpxe/init.h>#include <gpxe/image.h>#include <usr/imgmgmt.h>#include "config/console.h"#include "config/serial.h"Go to the source code of this file.
Data Structures | |
| union | syslinux_regs |
Defines | |
| #define | syslinux_version __use_data16 ( syslinux_version ) |
| #define | syslinux_copyright __use_data16 ( syslinux_copyright ) |
| #define | syslinux_configuration_file __use_data16 ( syslinux_configuration_file ) |
| #define | comboot_feature_flags __use_data16 ( comboot_feature_flags ) |
| #define | comboot_initial_regs __use_text16 ( comboot_initial_regs ) |
| #define | int20_vector __use_text16 ( int20_vector ) |
| #define | int21_vector __use_text16 ( int21_vector ) |
| #define | int22_vector __use_text16 ( int22_vector ) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static char | __data16_array (syslinux_version,[]) |
| The "SYSLINUX" version string. | |
| static char | __data16_array (syslinux_copyright,[]) |
| The "SYSLINUX" copyright string. | |
| static char | __data16_array (syslinux_configuration_file,[]) |
| static uint8_t | __data16 (comboot_feature_flags) |
| Feature flags. | |
| static syslinux_regs | __text16 (comboot_initial_regs) |
| Initial register values for INT 22h AX=1Ah and 1Bh. | |
| static struct segoff | __text16 (int20_vector) |
| static struct segoff | __text16 (int21_vector) |
| static struct segoff | __text16 (int22_vector) |
| void | int20_wrapper (void) |
| void | int21_wrapper (void) |
| void | int22_wrapper (void) |
| static void | print_user_string (unsigned int segment, unsigned int offset, char terminator) |
| Print a string with a particular terminator. | |
| 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. | |
| void | comboot_force_text_mode (void) |
| Set default text mode. | |
| static int | comboot_fetch_kernel (char *kernel_file, char *cmdline) |
| Fetch kernel and optional initrd. | |
| static __asmcall void | int20 (struct i386_all_regs *ix86 __unused) |
| Terminate program interrupt handler. | |
| static __asmcall void | int21 (struct i386_all_regs *ix86) |
| DOS-compatible API. | |
| static __asmcall void | int22 (struct i386_all_regs *ix86) |
| SYSLINUX API. | |
| void | hook_comboot_interrupts () |
| Hook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h). | |
| void | unhook_comboot_interrupts () |
| Unhook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h). | |
Variables | |
| rmjmp_buf | comboot_return |
| struct image * | comboot_replacement_image |
| static uint16_t | comboot_graphics_mode = 0 |
| #define syslinux_version __use_data16 ( syslinux_version ) |
| #define syslinux_copyright __use_data16 ( syslinux_copyright ) |
| #define syslinux_configuration_file __use_data16 ( syslinux_configuration_file ) |
| #define comboot_feature_flags __use_data16 ( comboot_feature_flags ) |
| #define comboot_initial_regs __use_text16 ( comboot_initial_regs ) |
| #define int20_vector __use_text16 ( int20_vector ) |
Definition at line 69 of file comboot_call.c.
Referenced by hook_comboot_interrupts(), and unhook_comboot_interrupts().
| #define int21_vector __use_text16 ( int21_vector ) |
Definition at line 72 of file comboot_call.c.
Referenced by hook_comboot_interrupts(), and unhook_comboot_interrupts().
| #define int22_vector __use_text16 ( int22_vector ) |
Definition at line 75 of file comboot_call.c.
Referenced by hook_comboot_interrupts(), and unhook_comboot_interrupts().
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static char __data16_array | ( | syslinux_version | ) | [static] |
The "SYSLINUX" version string.
| static char __data16_array | ( | syslinux_copyright | ) | [static] |
The "SYSLINUX" copyright string.
| static char __data16_array | ( | syslinux_configuration_file | ) | [static] |
| static uint8_t __data16 | ( | comboot_feature_flags | ) | [static] |
Feature flags.
| static syslinux_regs __text16 | ( | comboot_initial_regs | ) | [static] |
Initial register values for INT 22h AX=1Ah and 1Bh.
| static struct segoff __text16 | ( | int20_vector | ) | [static, read] |
| static struct segoff __text16 | ( | int21_vector | ) | [static, read] |
| static struct segoff __text16 | ( | int22_vector | ) | [static, read] |
| void int20_wrapper | ( | void | ) |
Referenced by hook_comboot_interrupts(), and unhook_comboot_interrupts().
| void int21_wrapper | ( | void | ) |
Referenced by hook_comboot_interrupts(), and unhook_comboot_interrupts().
| void int22_wrapper | ( | void | ) |
Referenced by hook_comboot_interrupts(), and unhook_comboot_interrupts().
| static void print_user_string | ( | unsigned int | segment, | |
| unsigned int | offset, | |||
| char | terminator | |||
| ) | [static] |
Print a string with a particular terminator.
Definition at line 94 of file comboot_call.c.
References copy_from_user(), putchar(), and real_to_user().
Referenced by int21(), and int22().
00094 { 00095 int i = 0; 00096 char c; 00097 userptr_t str = real_to_user ( segment, offset ); 00098 for ( ; ; ) { 00099 copy_from_user ( &c, str, i, 1 ); 00100 if ( c == terminator ) break; 00101 putchar ( c ); 00102 i++; 00103 } 00104 }
| static void shuffle | ( | unsigned int | list_segment, | |
| unsigned int | list_offset, | |||
| unsigned int | count | |||
| ) | [static] |
Perform a series of memory copies from a list in low memory.
Definition at line 110 of file comboot_call.c.
References assert, COMBOOT_MAX_SHUFFLE_DESCRIPTORS, copy_from_user(), dest, comboot_shuffle_descriptor::len, image::len, memmove_user(), memset_user(), phys_to_user(), real_to_user(), and src.
Referenced by int22().
00111 { 00112 comboot_shuffle_descriptor shuf[COMBOOT_MAX_SHUFFLE_DESCRIPTORS]; 00113 unsigned int i; 00114 00115 /* Copy shuffle descriptor list so it doesn't get overwritten */ 00116 copy_from_user ( shuf, real_to_user ( list_segment, list_offset ), 0, 00117 count * sizeof( comboot_shuffle_descriptor ) ); 00118 00119 /* Do the copies */ 00120 for ( i = 0; i < count; i++ ) { 00121 userptr_t src_u = phys_to_user ( shuf[ i ].src ); 00122 userptr_t dest_u = phys_to_user ( shuf[ i ].dest ); 00123 00124 if ( shuf[ i ].src == 0xFFFFFFFF ) { 00125 /* Fill with 0 instead of copying */ 00126 memset_user ( dest_u, 0, 0, shuf[ i ].len ); 00127 } else if ( shuf[ i ].dest == 0xFFFFFFFF ) { 00128 /* Copy new list of descriptors */ 00129 count = shuf[ i ].len / sizeof( comboot_shuffle_descriptor ); 00130 assert ( count <= COMBOOT_MAX_SHUFFLE_DESCRIPTORS ); 00131 copy_from_user ( shuf, src_u, 0, shuf[ i ].len ); 00132 i = -1; 00133 } else { 00134 /* Regular copy */ 00135 memmove_user ( dest_u, 0, src_u, 0, shuf[ i ].len ); 00136 } 00137 } 00138 }
| void comboot_force_text_mode | ( | void | ) |
Set default text mode.
Definition at line 144 of file comboot_call.c.
References __asm__(), comboot_graphics_mode, COMBOOT_VIDEO_GRAPHICS, COMBOOT_VIDEO_VESA, and REAL_CODE.
Referenced by com32_exec(), comboot_exec(), and int22().
00144 { 00145 if ( comboot_graphics_mode & COMBOOT_VIDEO_VESA ) { 00146 /* Set VGA mode 3 via VESA VBE mode set */ 00147 __asm__ __volatile__ ( 00148 REAL_CODE ( 00149 "mov $0x4F02, %%ax\n\t" 00150 "mov $0x03, %%bx\n\t" 00151 "int $0x10\n\t" 00152 ) 00153 : : ); 00154 } else if ( comboot_graphics_mode & COMBOOT_VIDEO_GRAPHICS ) { 00155 /* Set VGA mode 3 via standard VGA mode set */ 00156 __asm__ __volatile__ ( 00157 REAL_CODE ( 00158 "mov $0x03, %%ax\n\t" 00159 "int $0x10\n\t" 00160 ) 00161 : : ); 00162 } 00163 00164 comboot_graphics_mode = 0; 00165 }
| static int comboot_fetch_kernel | ( | char * | kernel_file, | |
| char * | cmdline | |||
| ) | [static] |
Fetch kernel and optional initrd.
Definition at line 171 of file comboot_call.c.
References alloc_image(), assert, DBG, ENOMEM, image_get(), image_put(), image_set_cmdline(), imgfetch(), NULL, register_image(), strchr(), strerror(), and strstr().
Referenced by int22().
00171 { 00172 struct image *kernel = NULL; 00173 struct image *initrd = NULL; 00174 char *initrd_file; 00175 int rc; 00176 00177 /* Find initrd= parameter, if any */ 00178 if ( ( initrd_file = strstr ( cmdline, "initrd=" ) ) != NULL ) { 00179 char *initrd_end; 00180 00181 /* skip "initrd=" */ 00182 initrd_file += 7; 00183 00184 /* Find terminating space, if any, and replace with NUL */ 00185 initrd_end = strchr ( initrd_file, ' ' ); 00186 if ( initrd_end ) 00187 *initrd_end = '\0'; 00188 00189 DBG ( "COMBOOT: fetching initrd '%s'\n", initrd_file ); 00190 00191 /* Allocate and fetch initrd */ 00192 initrd = alloc_image(); 00193 if ( ! initrd ) { 00194 DBG ( "COMBOOT: could not allocate initrd\n" ); 00195 rc = -ENOMEM; 00196 goto out; 00197 } 00198 if ( ( rc = imgfetch ( initrd, initrd_file, 00199 register_image ) ) != 0 ) { 00200 DBG ( "COMBOOT: could not fetch initrd: %s\n", 00201 strerror ( rc ) ); 00202 goto out; 00203 } 00204 00205 /* Restore space after initrd name, if applicable */ 00206 if ( initrd_end ) 00207 *initrd_end = ' '; 00208 } 00209 00210 DBG ( "COMBOOT: fetching kernel '%s'\n", kernel_file ); 00211 00212 /* Allocate and fetch kernel */ 00213 kernel = alloc_image(); 00214 if ( ! kernel ) { 00215 DBG ( "COMBOOT: could not allocate kernel\n" ); 00216 rc = -ENOMEM; 00217 goto out; 00218 } 00219 if ( ( rc = imgfetch ( kernel, kernel_file, 00220 register_image ) ) != 0 ) { 00221 DBG ( "COMBOOT: could not fetch kernel: %s\n", 00222 strerror ( rc ) ); 00223 goto out; 00224 } 00225 if ( ( rc = image_set_cmdline ( kernel, cmdline ) ) != 0 ) { 00226 DBG ( "COMBOOT: could not set kernel command line: %s\n", 00227 strerror ( rc ) ); 00228 goto out; 00229 } 00230 00231 /* Store kernel as replacement image */ 00232 assert ( comboot_replacement_image == NULL ); 00233 comboot_replacement_image = image_get ( kernel ); 00234 00235 out: 00236 /* Drop image references unconditionally; either we want to 00237 * discard them, or they have been registered and we should 00238 * drop out local reference. 00239 */ 00240 image_put ( kernel ); 00241 image_put ( initrd ); 00242 return rc; 00243 }
| static __asmcall void int20 | ( | struct i386_all_regs *ix86 | __unused | ) | [static] |
Terminate program interrupt handler.
Definition at line 249 of file comboot_call.c.
References COMBOOT_EXIT, and rmlongjmp.
Referenced by hook_comboot_interrupts().
00249 { 00250 rmlongjmp ( comboot_return, COMBOOT_EXIT ); 00251 }
| static __asmcall void int21 | ( | struct i386_all_regs * | ix86 | ) | [static] |
DOS-compatible API.
Definition at line 257 of file comboot_call.c.
References i386_regs::ah, i386_regs::al, CF, COMBOOT_EXIT, DBG, i386_regs::dl, i386_seg_regs::ds, i386_regs::dx, i386_regs::eax, i386_regs::ebx, i386_regs::ecx, i386_regs::edx, i386_all_regs::flags, getchar(), iskey(), print_user_string(), putchar(), i386_all_regs::regs, rmlongjmp, i386_all_regs::segs, and serial_putc().
Referenced by hook_comboot_interrupts().
00257 { 00258 ix86->flags |= CF; 00259 00260 switch ( ix86->regs.ah ) { 00261 case 0x00: 00262 case 0x4C: /* Terminate program */ 00263 rmlongjmp ( comboot_return, COMBOOT_EXIT ); 00264 break; 00265 00266 case 0x01: /* Get Key with Echo */ 00267 case 0x08: /* Get Key without Echo */ 00268 /* TODO: handle extended characters? */ 00269 ix86->regs.al = getchar( ); 00270 00271 /* Enter */ 00272 if ( ix86->regs.al == 0x0A ) 00273 ix86->regs.al = 0x0D; 00274 00275 if ( ix86->regs.ah == 0x01 ) 00276 putchar ( ix86->regs.al ); 00277 00278 ix86->flags &= ~CF; 00279 break; 00280 00281 case 0x02: /* Write Character */ 00282 putchar ( ix86->regs.dl ); 00283 ix86->flags &= ~CF; 00284 break; 00285 00286 case 0x04: /* Write Character to Serial Port */ 00287 serial_putc ( ix86->regs.dl ); 00288 ix86->flags &= ~CF; 00289 break; 00290 00291 case 0x09: /* Write DOS String to Console */ 00292 print_user_string ( ix86->segs.ds, ix86->regs.dx, '$' ); 00293 ix86->flags &= ~CF; 00294 break; 00295 00296 case 0x0B: /* Check Keyboard */ 00297 if ( iskey() ) 00298 ix86->regs.al = 0xFF; 00299 else 00300 ix86->regs.al = 0x00; 00301 00302 ix86->flags &= ~CF; 00303 break; 00304 00305 case 0x30: /* Check DOS Version */ 00306 /* Bottom halves all 0; top halves spell "SYSLINUX" */ 00307 ix86->regs.eax = 0x59530000; 00308 ix86->regs.ebx = 0x4C530000; 00309 ix86->regs.ecx = 0x4E490000; 00310 ix86->regs.edx = 0x58550000; 00311 ix86->flags &= ~CF; 00312 break; 00313 00314 default: 00315 DBG ( "COMBOOT unknown int21 function %02x\n", ix86->regs.ah ); 00316 break; 00317 } 00318 }
| static __asmcall void int22 | ( | struct i386_all_regs * | ix86 | ) | [static] |
SYSLINUX API.
Definition at line 324 of file comboot_call.c.
References __asm__(), __from_data16, __from_text16, i386_regs::al, assert, i386_regs::ax, i386_regs::bx, BZI_LOADER_TYPE_GPXE, CF, i386_regs::ch, i386_regs::cl, close(), COMBOOT_EXIT_COMMAND, COMBOOT_EXIT_RUN_KERNEL, comboot_feature_flags, comboot_fetch_kernel(), COMBOOT_FILE_BLOCKSZ, comboot_force_text_mode(), comboot_graphics_mode, comboot_initial_regs, COMBOOT_MAX_SHUFFLE_DESCRIPTORS, comboot_resolv(), COMCONSOLE, COMSPEED, copy_from_user(), i386_regs::cx, DBG, i386_regs::di, i386_regs::dl, i386_seg_regs::ds, i386_regs::dx, i386_regs::eax, i386_regs::ebp, i386_regs::ebx, i386_regs::ecx, i386_seg_regs::es, i386_regs::esi, i386_all_regs::flags, fsize(), image::len, memcpy_user(), open(), print_user_string(), pxe_api_call_weak(), read_user(), REAL_CODE, real_to_user(), i386_all_regs::regs, rm_cs, rm_ds, rmlongjmp, in_addr::s_addr, i386_all_regs::segs, select(), shuffle(), shutdown(), SHUTDOWN_BOOT, i386_regs::si, step(), strlen_user(), syslinux_configuration_file, syslinux_copyright, syslinux_version, and system().
Referenced by hook_comboot_interrupts().
00324 { 00325 ix86->flags |= CF; 00326 00327 switch ( ix86->regs.ax ) { 00328 case 0x0001: /* Get Version */ 00329 00330 /* Number of INT 22h API functions available */ 00331 ix86->regs.ax = 0x001D; 00332 00333 /* SYSLINUX version number */ 00334 ix86->regs.ch = 0; /* major */ 00335 ix86->regs.cl = 0; /* minor */ 00336 00337 /* SYSLINUX derivative ID */ 00338 ix86->regs.dl = BZI_LOADER_TYPE_GPXE; 00339 00340 /* SYSLINUX version and copyright strings */ 00341 ix86->segs.es = rm_ds; 00342 ix86->regs.si = ( ( unsigned ) __from_data16 ( syslinux_version ) ); 00343 ix86->regs.di = ( ( unsigned ) __from_data16 ( syslinux_copyright ) ); 00344 00345 ix86->flags &= ~CF; 00346 break; 00347 00348 case 0x0002: /* Write String */ 00349 print_user_string ( ix86->segs.es, ix86->regs.bx, '\0' ); 00350 ix86->flags &= ~CF; 00351 break; 00352 00353 case 0x0003: /* Run command */ 00354 { 00355 userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); 00356 int len = strlen_user ( cmd_u, 0 ); 00357 char cmd[len + 1]; 00358 copy_from_user ( cmd, cmd_u, 0, len + 1 ); 00359 DBG ( "COMBOOT: executing command '%s'\n", cmd ); 00360 system ( cmd ); 00361 DBG ( "COMBOOT: exiting after executing command...\n" ); 00362 rmlongjmp ( comboot_return, COMBOOT_EXIT_COMMAND ); 00363 } 00364 break; 00365 00366 case 0x0004: /* Run default command */ 00367 /* FIXME: just exit for now */ 00368 rmlongjmp ( comboot_return, COMBOOT_EXIT_COMMAND ); 00369 break; 00370 00371 case 0x0005: /* Force text mode */ 00372 comboot_force_text_mode ( ); 00373 ix86->flags &= ~CF; 00374 break; 00375 00376 case 0x0006: /* Open file */ 00377 { 00378 int fd; 00379 userptr_t file_u = real_to_user ( ix86->segs.es, ix86->regs.si ); 00380 int len = strlen_user ( file_u, 0 ); 00381 char file[len + 1]; 00382 00383 copy_from_user ( file, file_u, 0, len + 1 ); 00384 00385 if ( file[0] == '\0' ) { 00386 DBG ( "COMBOOT: attempted open with empty file name\n" ); 00387 break; 00388 } 00389 00390 DBG ( "COMBOOT: opening file '%s'\n", file ); 00391 00392 fd = open ( file ); 00393 00394 if ( fd < 0 ) { 00395 DBG ( "COMBOOT: error opening file %s\n", file ); 00396 break; 00397 } 00398 00399 /* This relies on the fact that a gPXE POSIX fd will 00400 * always fit in 16 bits. 00401 */ 00402 #if (POSIX_FD_MAX > 65535) 00403 #error POSIX_FD_MAX too large 00404 #endif 00405 ix86->regs.si = (uint16_t) fd; 00406 00407 ix86->regs.cx = COMBOOT_FILE_BLOCKSZ; 00408 ix86->regs.eax = fsize ( fd ); 00409 ix86->flags &= ~CF; 00410 } 00411 break; 00412 00413 case 0x0007: /* Read file */ 00414 { 00415 int fd = ix86->regs.si; 00416 int len = ix86->regs.cx * COMBOOT_FILE_BLOCKSZ; 00417 int rc; 00418 fd_set fds; 00419 userptr_t buf = real_to_user ( ix86->segs.es, ix86->regs.bx ); 00420 00421 /* Wait for data ready to read */ 00422 FD_ZERO ( &fds ); 00423 FD_SET ( fd, &fds ); 00424 00425 select ( &fds, 1 ); 00426 00427 rc = read_user ( fd, buf, 0, len ); 00428 if ( rc < 0 ) { 00429 DBG ( "COMBOOT: read failed\n" ); 00430 ix86->regs.si = 0; 00431 break; 00432 } 00433 00434 ix86->regs.ecx = rc; 00435 ix86->flags &= ~CF; 00436 } 00437 break; 00438 00439 case 0x0008: /* Close file */ 00440 { 00441 int fd = ix86->regs.si; 00442 close ( fd ); 00443 ix86->flags &= ~CF; 00444 } 00445 break; 00446 00447 case 0x0009: /* Call PXE Stack */ 00448 if ( pxe_api_call_weak ( ix86 ) != 0 ) 00449 ix86->flags |= CF; 00450 else 00451 ix86->flags &= ~CF; 00452 break; 00453 00454 case 0x000A: /* Get Derivative-Specific Information */ 00455 00456 /* gPXE has its own derivative ID, so there is no defined 00457 * output here; just return AL for now */ 00458 ix86->regs.al = BZI_LOADER_TYPE_GPXE; 00459 ix86->flags &= ~CF; 00460 break; 00461 00462 case 0x000B: /* Get Serial Console Configuration */ 00463 #if defined(CONSOLE_SERIAL) && !defined(COMPRESERVE) 00464 ix86->regs.dx = COMCONSOLE; 00465 ix86->regs.cx = 115200 / COMSPEED; 00466 ix86->regs.bx = 0; 00467 #else 00468 ix86->regs.dx = 0; 00469 #endif 00470 00471 ix86->flags &= ~CF; 00472 break; 00473 00474 case 0x000E: /* Get configuration file name */ 00475 /* FIXME: stub */ 00476 ix86->segs.es = rm_ds; 00477 ix86->regs.bx = ( ( unsigned ) __from_data16 ( syslinux_configuration_file ) ); 00478 ix86->flags &= ~CF; 00479 break; 00480 00481 case 0x000F: /* Get IPAPPEND strings */ 00482 /* FIXME: stub */ 00483 ix86->regs.cx = 0; 00484 ix86->segs.es = 0; 00485 ix86->regs.bx = 0; 00486 ix86->flags &= ~CF; 00487 break; 00488 00489 case 0x0010: /* Resolve hostname */ 00490 { 00491 userptr_t hostname_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); 00492 int len = strlen_user ( hostname_u, 0 ); 00493 char hostname[len]; 00494 struct in_addr addr; 00495 00496 copy_from_user ( hostname, hostname_u, 0, len + 1 ); 00497 00498 /* TODO: 00499 * "If the hostname does not contain a dot (.), the 00500 * local domain name is automatically appended." 00501 */ 00502 00503 comboot_resolv ( hostname, &addr ); 00504 00505 ix86->regs.eax = addr.s_addr; 00506 ix86->flags &= ~CF; 00507 } 00508 break; 00509 00510 case 0x0011: /* Maximum number of shuffle descriptors */ 00511 ix86->regs.cx = COMBOOT_MAX_SHUFFLE_DESCRIPTORS; 00512 ix86->flags &= ~CF; 00513 break; 00514 00515 case 0x0012: /* Cleanup, shuffle and boot */ 00516 if ( ix86->regs.cx > COMBOOT_MAX_SHUFFLE_DESCRIPTORS ) 00517 break; 00518 00519 /* Perform final cleanup */ 00520 shutdown ( SHUTDOWN_BOOT ); 00521 00522 /* Perform sequence of copies */ 00523 shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx ); 00524 00525 /* Jump to real-mode entry point */ 00526 __asm__ __volatile__ ( 00527 REAL_CODE ( 00528 "pushw %0\n\t" 00529 "popw %%ds\n\t" 00530 "pushl %1\n\t" 00531 "lret\n\t" 00532 ) 00533 : 00534 : "r" ( ix86->segs.ds ), 00535 "r" ( ix86->regs.ebp ), 00536 "d" ( ix86->regs.ebx ), 00537 "S" ( ix86->regs.esi ) ); 00538 00539 assert ( 0 ); /* Execution should never reach this point */ 00540 00541 break; 00542 00543 case 0x0013: /* Idle loop call */ 00544 step ( ); 00545 ix86->flags &= ~CF; 00546 break; 00547 00548 case 0x0015: /* Get feature flags */ 00549 ix86->segs.es = rm_ds; 00550 ix86->regs.bx = ( ( unsigned ) __from_data16 ( &comboot_feature_flags ) ); 00551 ix86->regs.cx = 1; /* Number of feature flag bytes */ 00552 ix86->flags &= ~CF; 00553 break; 00554 00555 case 0x0016: /* Run kernel image */ 00556 { 00557 userptr_t file_u = real_to_user ( ix86->segs.ds, ix86->regs.si ); 00558 userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); 00559 int file_len = strlen_user ( file_u, 0 ); 00560 int cmd_len = strlen_user ( cmd_u, 0 ); 00561 char file[file_len + 1]; 00562 char cmd[cmd_len + 1]; 00563 00564 copy_from_user ( file, file_u, 0, file_len + 1 ); 00565 copy_from_user ( cmd, cmd_u, 0, cmd_len + 1 ); 00566 00567 DBG ( "COMBOOT: run kernel %s %s\n", file, cmd ); 00568 comboot_fetch_kernel ( file, cmd ); 00569 /* Technically, we should return if we 00570 * couldn't load the kernel, but it's not safe 00571 * to do that since we have just overwritten 00572 * part of the COMBOOT program's memory space. 00573 */ 00574 DBG ( "COMBOOT: exiting to run kernel...\n" ); 00575 rmlongjmp ( comboot_return, COMBOOT_EXIT_RUN_KERNEL ); 00576 } 00577 break; 00578 00579 case 0x0017: /* Report video mode change */ 00580 comboot_graphics_mode = ix86->regs.bx; 00581 ix86->flags &= ~CF; 00582 break; 00583 00584 case 0x0018: /* Query custom font */ 00585 /* FIXME: stub */ 00586 ix86->regs.al = 0; 00587 ix86->segs.es = 0; 00588 ix86->regs.bx = 0; 00589 ix86->flags &= ~CF; 00590 break; 00591 00592 case 0x001B: /* Cleanup, shuffle and boot to real mode */ 00593 if ( ix86->regs.cx > COMBOOT_MAX_SHUFFLE_DESCRIPTORS ) 00594 break; 00595 00596 /* Perform final cleanup */ 00597 shutdown ( SHUTDOWN_BOOT ); 00598 00599 /* Perform sequence of copies */ 00600 shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx ); 00601 00602 /* Copy initial register values to .text16 */ 00603 memcpy_user ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ), 0, 00604 real_to_user ( ix86->segs.ds, ix86->regs.si ), 0, 00605 sizeof(syslinux_rm_regs) ); 00606 00607 /* Load initial register values */ 00608 __asm__ __volatile__ ( 00609 REAL_CODE ( 00610 /* Point SS:SP at the register value structure */ 00611 "pushw %%cs\n\t" 00612 "popw %%ss\n\t" 00613 "movw $comboot_initial_regs, %%sp\n\t" 00614 00615 /* Segment registers */ 00616 "popw %%es\n\t" 00617 "popw %%ax\n\t" /* Skip CS */ 00618 "popw %%ds\n\t" 00619 "popw %%ax\n\t" /* Skip SS for now */ 00620 "popw %%fs\n\t" 00621 "popw %%gs\n\t" 00622 00623 /* GP registers */ 00624 "popl %%eax\n\t" 00625 "popl %%ecx\n\t" 00626 "popl %%edx\n\t" 00627 "popl %%ebx\n\t" 00628 "popl %%ebp\n\t" /* Skip ESP for now */ 00629 "popl %%ebp\n\t" 00630 "popl %%esi\n\t" 00631 "popl %%edi\n\t" 00632 00633 /* Load correct SS:ESP */ 00634 "movw $(comboot_initial_regs + 6), %%sp\n\t" 00635 "popw %%ss\n\t" 00636 "movl %%cs:(comboot_initial_regs + 28), %%esp\n\t" 00637 00638 "ljmp *%%cs:(comboot_initial_regs + 44)\n\t" 00639 ) 00640 : : ); 00641 00642 break; 00643 00644 case 0x001C: /* Get pointer to auxilliary data vector */ 00645 /* FIXME: stub */ 00646 ix86->regs.cx = 0; /* Size of the ADV */ 00647 ix86->flags &= ~CF; 00648 break; 00649 00650 case 0x001D: /* Write auxilliary data vector */ 00651 /* FIXME: stub */ 00652 ix86->flags &= ~CF; 00653 break; 00654 00655 default: 00656 DBG ( "COMBOOT unknown int22 function %04x\n", ix86->regs.ax ); 00657 break; 00658 } 00659 }
| void hook_comboot_interrupts | ( | ) |
Hook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h).
Definition at line 664 of file comboot_call.c.
References __asm__(), hook_bios_interrupt(), int20(), int20_vector, int20_wrapper(), int21(), int21_vector, int21_wrapper(), int22(), int22_vector, int22_wrapper(), and TEXT16_CODE.
Referenced by com32_exec(), and comboot_exec().
00664 { 00665 00666 __asm__ __volatile__ ( 00667 TEXT16_CODE ( "\nint20_wrapper:\n\t" 00668 "pushl %0\n\t" 00669 "pushw %%cs\n\t" 00670 "call prot_call\n\t" 00671 "addw $4, %%sp\n\t" 00672 "iret\n\t" ) 00673 : : "i" ( int20 ) ); 00674 00675 hook_bios_interrupt ( 0x20, ( unsigned int ) int20_wrapper, 00676 &int20_vector ); 00677 00678 __asm__ __volatile__ ( 00679 TEXT16_CODE ( "\nint21_wrapper:\n\t" 00680 "pushl %0\n\t" 00681 "pushw %%cs\n\t" 00682 "call prot_call\n\t" 00683 "addw $4, %%sp\n\t" 00684 "iret\n\t" ) 00685 : : "i" ( int21 ) ); 00686 00687 hook_bios_interrupt ( 0x21, ( unsigned int ) int21_wrapper, 00688 &int21_vector ); 00689 00690 __asm__ __volatile__ ( 00691 TEXT16_CODE ( "\nint22_wrapper:\n\t" 00692 "pushl %0\n\t" 00693 "pushw %%cs\n\t" 00694 "call prot_call\n\t" 00695 "addw $4, %%sp\n\t" 00696 "iret\n\t" ) 00697 : : "i" ( int22) ); 00698 00699 hook_bios_interrupt ( 0x22, ( unsigned int ) int22_wrapper, 00700 &int22_vector ); 00701 }
| void unhook_comboot_interrupts | ( | ) |
Unhook BIOS interrupts related to COMBOOT API (INT 20h, 21h, 22h).
Definition at line 706 of file comboot_call.c.
References int20_vector, int20_wrapper(), int21_vector, int21_wrapper(), int22_vector, int22_wrapper(), and unhook_bios_interrupt().
Referenced by com32_exec(), and comboot_exec().
00706 { 00707 00708 unhook_bios_interrupt ( 0x20, ( unsigned int ) int20_wrapper, 00709 &int20_vector ); 00710 00711 unhook_bios_interrupt ( 0x21, ( unsigned int ) int21_wrapper, 00712 &int21_vector ); 00713 00714 unhook_bios_interrupt ( 0x22, ( unsigned int ) int22_wrapper, 00715 &int22_vector ); 00716 }
| struct image* comboot_replacement_image |
uint16_t comboot_graphics_mode = 0 [static] |
1.5.7.1