summaryrefslogtreecommitdiffstats
path: root/src/arch/x86/interface/syslinux/comboot_call.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/interface/syslinux/comboot_call.c')
-rw-r--r--src/arch/x86/interface/syslinux/comboot_call.c90
1 files changed, 38 insertions, 52 deletions
diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c
index b75e8ef7c..c3e921075 100644
--- a/src/arch/x86/interface/syslinux/comboot_call.c
+++ b/src/arch/x86/interface/syslinux/comboot_call.c
@@ -37,6 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/posix_io.h>
#include <ipxe/process.h>
#include <ipxe/serial.h>
+#include <ipxe/ns16550.h>
#include <ipxe/init.h>
#include <ipxe/image.h>
#include <ipxe/version.h>
@@ -88,14 +89,9 @@ static uint16_t comboot_graphics_mode = 0;
* Print a string with a particular terminator
*/
static void print_user_string ( unsigned int segment, unsigned int offset, char terminator ) {
- int i = 0;
- char c;
- userptr_t str = real_to_user ( segment, offset );
- for ( ; ; ) {
- copy_from_user ( &c, str, i, 1 );
- if ( c == terminator ) break;
- putchar ( c );
- i++;
+ char *c;
+ for ( c = real_to_virt ( segment, offset ) ; *c != terminator ; c++ ) {
+ putchar ( *c );
}
}
@@ -109,26 +105,26 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig
unsigned int i;
/* Copy shuffle descriptor list so it doesn't get overwritten */
- copy_from_user ( shuf, real_to_user ( list_segment, list_offset ), 0,
- count * sizeof( comboot_shuffle_descriptor ) );
+ memcpy ( shuf, real_to_virt ( list_segment, list_offset ),
+ count * sizeof( comboot_shuffle_descriptor ) );
/* Do the copies */
for ( i = 0; i < count; i++ ) {
- userptr_t src_u = phys_to_user ( shuf[ i ].src );
- userptr_t dest_u = phys_to_user ( shuf[ i ].dest );
+ const void *src = phys_to_virt ( shuf[ i ].src );
+ void *dest = phys_to_virt ( shuf[ i ].dest );
if ( shuf[ i ].src == 0xFFFFFFFF ) {
/* Fill with 0 instead of copying */
- memset_user ( dest_u, 0, 0, shuf[ i ].len );
+ memset ( dest, 0, shuf[ i ].len );
} else if ( shuf[ i ].dest == 0xFFFFFFFF ) {
/* Copy new list of descriptors */
count = shuf[ i ].len / sizeof( comboot_shuffle_descriptor );
assert ( count <= COMBOOT_MAX_SHUFFLE_DESCRIPTORS );
- copy_from_user ( shuf, src_u, 0, shuf[ i ].len );
+ memcpy ( shuf, src, shuf[ i ].len );
i = -1;
} else {
/* Regular copy */
- memmove_user ( dest_u, 0, src_u, 0, shuf[ i ].len );
+ memmove ( dest, src, shuf[ i ].len );
}
}
}
@@ -164,7 +160,7 @@ void comboot_force_text_mode ( void ) {
/**
* Fetch kernel and optional initrd
*/
-static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
+static int comboot_fetch_kernel ( const char *kernel_file, char *cmdline ) {
struct image *kernel;
struct image *initrd;
char *initrd_file;
@@ -258,8 +254,8 @@ static __asmcall __used void int21 ( struct i386_all_regs *ix86 ) {
break;
case 0x04: /* Write Character to Serial Port */
- if ( serial_console.base ) {
- uart_transmit ( &serial_console, ix86->regs.dl );
+ if ( serial_console ) {
+ uart_transmit ( serial_console, ix86->regs.dl );
ix86->flags &= ~CF;
}
break;
@@ -346,10 +342,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
case 0x0003: /* Run command */
{
- userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx );
- int len = strlen_user ( cmd_u, 0 );
- char cmd[len + 1];
- copy_from_user ( cmd, cmd_u, 0, len + 1 );
+ const char *cmd = real_to_virt ( ix86->segs.es,
+ ix86->regs.bx );
DBG ( "COMBOOT: executing command '%s'\n", cmd );
system ( cmd );
DBG ( "COMBOOT: exiting after executing command...\n" );
@@ -370,11 +364,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
case 0x0006: /* Open file */
{
int fd;
- userptr_t file_u = real_to_user ( ix86->segs.es, ix86->regs.si );
- int len = strlen_user ( file_u, 0 );
- char file[len + 1];
-
- copy_from_user ( file, file_u, 0, len + 1 );
+ const char *file = real_to_virt ( ix86->segs.es,
+ ix86->regs.si );
if ( file[0] == '\0' ) {
DBG ( "COMBOOT: attempted open with empty file name\n" );
@@ -410,7 +401,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
int len = ix86->regs.cx * COMBOOT_FILE_BLOCKSZ;
int rc;
fd_set fds;
- userptr_t buf = real_to_user ( ix86->segs.es, ix86->regs.bx );
+ void *buf = real_to_virt ( ix86->segs.es,
+ ix86->regs.bx );
/* Wait for data ready to read */
FD_ZERO ( &fds );
@@ -418,7 +410,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
select ( &fds, 1 );
- rc = read_user ( fd, buf, 0, len );
+ rc = read ( fd, buf, len );
if ( rc < 0 ) {
DBG ( "COMBOOT: read failed\n" );
ix86->regs.si = 0;
@@ -454,9 +446,11 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
break;
case 0x000B: /* Get Serial Console Configuration */
- if ( serial_console.base ) {
- ix86->regs.dx = ( ( intptr_t ) serial_console.base );
- ix86->regs.cx = serial_console.divisor;
+ if ( serial_console ) {
+ struct ns16550_uart *comport = serial_console->priv;
+
+ ix86->regs.dx = ( ( intptr_t ) comport->base );
+ ix86->regs.cx = comport->divisor;
ix86->regs.bx = 0;
ix86->flags &= ~CF;
}
@@ -483,13 +477,10 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
case 0x0010: /* Resolve hostname */
{
- userptr_t hostname_u = real_to_user ( ix86->segs.es, ix86->regs.bx );
- int len = strlen_user ( hostname_u, 0 );
- char hostname[len];
+ const char *hostname = real_to_virt ( ix86->segs.es,
+ ix86->regs.bx );
struct in_addr addr;
- copy_from_user ( hostname, hostname_u, 0, len + 1 );
-
/* TODO:
* "If the hostname does not contain a dot (.), the
* local domain name is automatically appended."
@@ -526,8 +517,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
"lret\n\t"
)
:
- : "r" ( ix86->segs.ds ),
- "r" ( ix86->regs.ebp ),
+ : "R" ( ix86->segs.ds ),
+ "R" ( ix86->regs.ebp ),
"d" ( ix86->regs.ebx ),
"S" ( ix86->regs.esi ) );
@@ -549,15 +540,10 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
case 0x0016: /* Run kernel image */
{
- userptr_t file_u = real_to_user ( ix86->segs.ds, ix86->regs.si );
- userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx );
- int file_len = strlen_user ( file_u, 0 );
- int cmd_len = strlen_user ( cmd_u, 0 );
- char file[file_len + 1];
- char cmd[cmd_len + 1];
-
- copy_from_user ( file, file_u, 0, file_len + 1 );
- copy_from_user ( cmd, cmd_u, 0, cmd_len + 1 );
+ const char *file = real_to_virt ( ix86->segs.ds,
+ ix86->regs.si );
+ char *cmd = real_to_virt ( ix86->segs.es,
+ ix86->regs.bx );
DBG ( "COMBOOT: run kernel %s %s\n", file, cmd );
comboot_fetch_kernel ( file, cmd );
@@ -595,9 +581,9 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );
/* Copy initial register values to .text16 */
- memcpy_user ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ), 0,
- real_to_user ( ix86->segs.ds, ix86->regs.si ), 0,
- sizeof(syslinux_rm_regs) );
+ memcpy ( real_to_virt ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ),
+ real_to_virt ( ix86->segs.ds, ix86->regs.si ),
+ sizeof(syslinux_rm_regs) );
/* Load initial register values */
__asm__ __volatile__ (
@@ -702,4 +688,4 @@ void unhook_comboot_interrupts ( ) {
}
/* Avoid dragging in serial console support unconditionally */
-struct uart serial_console __attribute__ (( weak ));
+struct uart *serial_console __attribute__ (( weak ));