iPXE
gdbserial.c File Reference
#include <stddef.h>
#include <stdio.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.

Macros

#define GDBSERIAL_BAUD   COMSPEED

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (FORBIDDEN)
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 (const char *name, unsigned int baud)

Variables

static struct uartgdbserial_uart
 GDB serial UART.
struct gdb_transport serial_gdb_transport __gdb_transport

Macro Definition Documentation

◆ GDBSERIAL_BAUD

#define GDBSERIAL_BAUD   COMSPEED

Definition at line 39 of file gdbserial.c.

Referenced by gdbserial_init().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ gdbserial_recv()

size_t gdbserial_recv ( char * buf,
size_t len )
static

Definition at line 47 of file gdbserial.c.

47 {
48
49 assert ( len > 0 );
50 while ( ! uart_data_ready ( gdbserial_uart ) ) {}
51 buf[0] = uart_receive ( gdbserial_uart );
52 return 1;
53}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
ring len
Length.
Definition dwmac.h:226
static struct uart * gdbserial_uart
GDB serial UART.
Definition gdbserial.c:43

References assert, gdbserial_uart, and len.

◆ gdbserial_send()

void gdbserial_send ( const char * buf,
size_t len )
static

Definition at line 55 of file gdbserial.c.

55 {
56
57 while ( len-- > 0 ) {
58 uart_transmit ( gdbserial_uart, *buf++ );
59 }
60}

References gdbserial_uart, and len.

◆ gdbserial_init()

int gdbserial_init ( int argc,
char ** argv )
static

Definition at line 62 of file gdbserial.c.

62 {
63 const char *port;
64
65 if ( argc == 1 ) {
66 port = argv[0];
67 } else {
68 printf ( "serial: syntax <port>\n" );
69 return 1;
70 }
71
73 printf ( "serial: unable to configure\n" );
74 return 1;
75 }
76
77 return 0;
78}
u8 port
Port number.
Definition CIB_PRM.h:3
#define GDBSERIAL_BAUD
Definition gdbserial.c:39
struct gdb_transport * gdbserial_configure(const char *name, unsigned int baud)
Definition gdbserial.c:87
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References GDBSERIAL_BAUD, gdbserial_configure(), port, and printf().

◆ gdbserial_configure()

struct gdb_transport * gdbserial_configure ( const char * name,
unsigned int baud )

Definition at line 87 of file gdbserial.c.

88 {
89 int rc;
90
91 uart_put ( gdbserial_uart );
93
95 if ( ! gdbserial_uart )
96 return NULL;
97 uart_get ( gdbserial_uart );
98
99 gdbserial_uart->baud = baud;
100
101 if ( ( rc = uart_init ( gdbserial_uart ) ) != 0 )
102 return NULL;
103
104 return &serial_gdb_transport;
105}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
const char * name
Definition ath9k_hw.c:1986
struct uart * uart_find(const char *name)
Find named UART.
Definition uart.c:130

References gdbserial_uart, name, NULL, rc, and uart_find().

Referenced by gdbserial_init().

Variable Documentation

◆ gdbserial_uart

struct uart* gdbserial_uart
static

GDB serial UART.

Definition at line 43 of file gdbserial.c.

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

◆ __gdb_transport

struct gdb_transport serial_gdb_transport __gdb_transport
Initial value:
= {
.name = "serial",
.init = gdbserial_init,
.recv = gdbserial_recv,
.send = gdbserial_send,
}
static void gdbserial_send(const char *buf, size_t len)
Definition gdbserial.c:55
static int gdbserial_init(int argc, char **argv)
Definition gdbserial.c:62
static size_t gdbserial_recv(char *buf, size_t len)
Definition gdbserial.c:47

Definition at line 45 of file gdbserial.c.