iPXE
Macros | Functions | Variables
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)
 
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. More...
 
struct gdb_transport serial_gdb_transport __gdb_transport
 

Macro Definition Documentation

◆ GDBSERIAL_BAUD

#define GDBSERIAL_BAUD   COMSPEED

Definition at line 38 of file gdbserial.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ gdbserial_recv()

static size_t gdbserial_recv ( char *  buf,
size_t  len 
)
static

Definition at line 46 of file gdbserial.c.

46  {
47 
48  assert ( len > 0 );
49  while ( ! uart_data_ready ( gdbserial_uart ) ) {}
50  buf[0] = uart_receive ( gdbserial_uart );
51  return 1;
52 }
static struct uart * gdbserial_uart
GDB serial UART.
Definition: gdbserial.c:42
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231

References assert(), gdbserial_uart, and len.

◆ gdbserial_send()

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

Definition at line 54 of file gdbserial.c.

54  {
55 
56  while ( len-- > 0 ) {
57  uart_transmit ( gdbserial_uart, *buf++ );
58  }
59 }
static struct uart * gdbserial_uart
GDB serial UART.
Definition: gdbserial.c:42
ring len
Length.
Definition: dwmac.h:231

References gdbserial_uart, and len.

◆ gdbserial_init()

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

Definition at line 61 of file gdbserial.c.

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

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

◆ gdbserial_configure()

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

Definition at line 86 of file gdbserial.c.

87  {
88  int rc;
89 
90  uart_put ( gdbserial_uart );
92 
94  if ( ! gdbserial_uart )
95  return NULL;
96  uart_get ( gdbserial_uart );
97 
98  gdbserial_uart->baud = baud;
99 
100  if ( ( rc = uart_init ( gdbserial_uart ) ) != 0 )
101  return NULL;
102 
103  return &serial_gdb_transport;
104 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
static struct uart * gdbserial_uart
GDB serial UART.
Definition: gdbserial.c:42
unsigned int baud
Baud rate (if specified)
Definition: uart.h:26
struct uart * uart_find(const char *name)
Find named UART.
Definition: uart.c:130
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References uart::baud, 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 42 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:54
static int gdbserial_init(int argc, char **argv)
Definition: gdbserial.c:61
static size_t gdbserial_recv(char *buf, size_t len)
Definition: gdbserial.c:46

Definition at line 44 of file gdbserial.c.