diff options
| author | Simon Rettberg | 2026-01-28 12:53:53 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2026-01-28 12:53:53 +0100 |
| commit | 8e82785c584dc13e20f9229decb95bd17bbe9cd1 (patch) | |
| tree | a8b359e59196be5b2e3862bed189107f4bc9975f /src/core/gdbserial.c | |
| parent | Merge branch 'master' into openslx (diff) | |
| parent | [prefix] Make unlzma.S compatible with 386 class CPUs (diff) | |
| download | ipxe-openslx.tar.gz ipxe-openslx.tar.xz ipxe-openslx.zip | |
Merge branch 'master' into openslxopenslx
Diffstat (limited to 'src/core/gdbserial.c')
| -rw-r--r-- | src/core/gdbserial.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/src/core/gdbserial.c b/src/core/gdbserial.c index 0983f2557..61add5d47 100644 --- a/src/core/gdbserial.c +++ b/src/core/gdbserial.c @@ -25,20 +25,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <stddef.h> #include <stdio.h> -#include <stdlib.h> #include <assert.h> #include <ipxe/uart.h> #include <ipxe/gdbstub.h> #include <ipxe/gdbserial.h> #include <config/serial.h> -/* UART port number */ -#ifdef COMCONSOLE -#define GDBSERIAL_PORT COMCONSOLE -#else -#define GDBSERIAL_PORT 0 -#endif - /* UART baud rate */ #ifdef COMPRESERVE #define GDBSERIAL_BAUD 0 @@ -46,51 +38,37 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define GDBSERIAL_BAUD COMSPEED #endif -/* UART line control register value */ -#ifdef COMPRESERVE -#define GDBSERIAL_LCR 0 -#else -#define GDBSERIAL_LCR UART_LCR_WPS ( COMDATA, COMPARITY, COMSTOP ) -#endif - /** GDB serial UART */ -static struct uart gdbserial_uart; +static struct uart *gdbserial_uart; struct gdb_transport serial_gdb_transport __gdb_transport; static size_t gdbserial_recv ( char *buf, size_t len ) { assert ( len > 0 ); - while ( ! uart_data_ready ( &gdbserial_uart ) ) {} - buf[0] = uart_receive ( &gdbserial_uart ); + while ( ! uart_data_ready ( gdbserial_uart ) ) {} + buf[0] = uart_receive ( gdbserial_uart ); return 1; } static void gdbserial_send ( const char *buf, size_t len ) { while ( len-- > 0 ) { - uart_transmit ( &gdbserial_uart, *buf++ ); + uart_transmit ( gdbserial_uart, *buf++ ); } } static int gdbserial_init ( int argc, char **argv ) { - unsigned int port; - char *endp; - - if ( argc == 0 ) { - port = GDBSERIAL_PORT; - } else if ( argc == 1 ) { - port = strtoul ( argv[0], &endp, 10 ); - if ( *endp ) { - printf ( "serial: invalid port\n" ); - return 1; - } + const char *port; + + if ( argc == 1 ) { + port = argv[0]; } else { printf ( "serial: syntax <port>\n" ); return 1; } - if ( ! gdbserial_configure ( port, GDBSERIAL_BAUD, GDBSERIAL_LCR ) ) { + if ( ! gdbserial_configure ( port, GDBSERIAL_BAUD ) ) { printf ( "serial: unable to configure\n" ); return 1; } @@ -105,14 +83,21 @@ struct gdb_transport serial_gdb_transport __gdb_transport = { .send = gdbserial_send, }; -struct gdb_transport * gdbserial_configure ( unsigned int port, - unsigned int baud, uint8_t lcr ) { +struct gdb_transport * gdbserial_configure ( const char *name, + unsigned int baud ) { int rc; - if ( ( rc = uart_select ( &gdbserial_uart, port ) ) != 0 ) + uart_put ( gdbserial_uart ); + gdbserial_uart = NULL; + + gdbserial_uart = uart_find ( name ); + if ( ! gdbserial_uart ) return NULL; + uart_get ( gdbserial_uart ); + + gdbserial_uart->baud = baud; - if ( ( rc = uart_init ( &gdbserial_uart, baud, lcr ) ) != 0 ) + if ( ( rc = uart_init ( gdbserial_uart ) ) != 0 ) return NULL; return &serial_gdb_transport; |
