iPXE
Defines | Functions | Variables
gdbserial.c File Reference
#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>

Go to the source code of this file.

Defines

#define GDBSERIAL_PORT   COMCONSOLE
#define GDBSERIAL_BAUD   COMSPEED
#define GDBSERIAL_LCR   UART_LCR_WPS ( COMDATA, COMPARITY, COMSTOP )

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static size_t gdbserial_recv (char *buf, size_t len)
static void gdbserial_send (const char *buf, size_t len)
static int gdbserial_init (int argc, char **argv)
struct gdb_transportgdbserial_configure (unsigned int port, unsigned int baud, uint8_t lcr)

Variables

static struct uart gdbserial_uart
 GDB serial UART.
struct gdb_transport
serial_gdb_transport 
__gdb_transport

Define Documentation

#define GDBSERIAL_PORT   COMCONSOLE

Definition at line 37 of file gdbserial.c.

Referenced by gdbserial_init().

#define GDBSERIAL_BAUD   COMSPEED

Definition at line 46 of file gdbserial.c.

Referenced by gdbserial_init().

Definition at line 53 of file gdbserial.c.

Referenced by gdbserial_init().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static size_t gdbserial_recv ( char *  buf,
size_t  len 
) [static]

Definition at line 61 of file gdbserial.c.

References assert, gdbserial_uart, uart_data_ready(), and uart_receive().

                                                       {

        assert ( len > 0 );
        while ( ! uart_data_ready ( &gdbserial_uart ) ) {}
        buf[0] = uart_receive ( &gdbserial_uart );
        return 1;
}
static void gdbserial_send ( const char *  buf,
size_t  len 
) [static]

Definition at line 69 of file gdbserial.c.

References gdbserial_uart, and uart_transmit().

                                                           {

        while ( len-- > 0 ) {
                uart_transmit ( &gdbserial_uart, *buf++ );
        }
}
static int gdbserial_init ( int  argc,
char **  argv 
) [static]

Definition at line 76 of file gdbserial.c.

References GDBSERIAL_BAUD, gdbserial_configure(), GDBSERIAL_LCR, GDBSERIAL_PORT, port, printf(), and strtoul().

                                                    {
        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;
                }
        } else {
                printf ( "serial: syntax <port>\n" );
                return 1;
        }

        if ( ! gdbserial_configure ( port, GDBSERIAL_BAUD, GDBSERIAL_LCR ) ) {
                printf ( "serial: unable to configure\n" );
                return 1;
        }

        return 0;
}
struct gdb_transport* gdbserial_configure ( unsigned int  port,
unsigned int  baud,
uint8_t  lcr 
) [read]

Definition at line 108 of file gdbserial.c.

References gdbserial_uart, NULL, rc, uart_init(), and uart_select().

Referenced by gdbserial_init().

                                                                              {
        int rc;

        if ( ( rc = uart_select ( &gdbserial_uart, port ) ) != 0 )
                return NULL;

        if ( ( rc = uart_init ( &gdbserial_uart, baud, lcr ) ) != 0 )
                return NULL;

        return &serial_gdb_transport;
}

Variable Documentation

struct uart gdbserial_uart [static]

GDB serial UART.

Definition at line 57 of file gdbserial.c.

Referenced by gdbserial_configure(), gdbserial_recv(), and gdbserial_send().

struct gdb_transport serial_gdb_transport __gdb_transport
Initial value:
 {
        .name = "serial",
        .init = gdbserial_init,
        .recv = gdbserial_recv,
        .send = gdbserial_send,
}

Definition at line 59 of file gdbserial.c.