iPXE
Macros | Typedefs | Enumerations | Functions
gdbmach.h File Reference

Dummy GDB architecture specifics. More...

#include <stdint.h>

Go to the source code of this file.

Macros

#define GDBMACH_SIZEOF_REGS   ( GDBMACH_NREGS * sizeof ( gdbreg_t ) )
 

Typedefs

typedef unsigned long gdbreg_t
 

Enumerations

enum  { GDBMACH_NREGS }
 

Functions

static void gdbmach_set_pc (gdbreg_t *regs, gdbreg_t pc)
 
static void gdbmach_set_single_step (gdbreg_t *regs, int step)
 
static void gdbmach_breakpoint (void)
 
int gdbmach_set_breakpoint (int type, unsigned long addr, size_t len, int enable)
 Set hardware breakpoint. More...
 
void gdbmach_init (void)
 Initialise GDB. More...
 

Detailed Description

Dummy GDB architecture specifics.

This file is included only if the architecture does not provide its own version of this file.

Definition in file gdbmach.h.

Macro Definition Documentation

◆ GDBMACH_SIZEOF_REGS

#define GDBMACH_SIZEOF_REGS   ( GDBMACH_NREGS * sizeof ( gdbreg_t ) )

Definition at line 23 of file gdbmach.h.

Typedef Documentation

◆ gdbreg_t

typedef unsigned long gdbreg_t

Definition at line 15 of file gdbmach.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GDBMACH_NREGS 

Definition at line 18 of file gdbmach.h.

18  {
19  /* Not yet implemented */
21 };

Function Documentation

◆ gdbmach_set_pc()

static void gdbmach_set_pc ( gdbreg_t regs,
gdbreg_t  pc 
)
inlinestatic

Definition at line 25 of file gdbmach.h.

25  {
26  /* Not yet implemented */
27  ( void ) regs;
28  ( void ) pc;
29 }
struct i386_regs regs
Definition: registers.h:15

References regs.

◆ gdbmach_set_single_step()

static void gdbmach_set_single_step ( gdbreg_t regs,
int  step 
)
inlinestatic

Definition at line 31 of file gdbmach.h.

31  {
32  /* Not yet implemented */
33  ( void ) regs;
34  ( void ) step;
35 }
struct i386_regs regs
Definition: registers.h:15
void step(void)
Single-step a single process.
Definition: process.c:98

References regs, and step().

◆ gdbmach_breakpoint()

static void gdbmach_breakpoint ( void  )
inlinestatic

Definition at line 37 of file gdbmach.h.

37  {
38  /* Not yet implemented */
39 }

◆ gdbmach_set_breakpoint()

int gdbmach_set_breakpoint ( int  type,
unsigned long  addr,
size_t  len,
int  enable 
)

Set hardware breakpoint.

Parameters
typeGDB breakpoint type
addrVirtual address
lenLength
enableEnable (not disable) breakpoint
Return values
rcReturn status code

Definition at line 133 of file gdbmach.c.

134  {
135  unsigned int rwlen;
136  unsigned long mask;
137  int bp;
138 
139  /* Parse breakpoint type */
140  switch ( type ) {
141  case GDBMACH_WATCH:
142  rwlen = DR7_RWLEN_WRITE;
143  break;
144  case GDBMACH_AWATCH:
145  rwlen = DR7_RWLEN_ACCESS;
146  break;
147  default:
148  return -ENOTSUP;
149  }
150 
151  /* Parse breakpoint length */
152  switch ( len ) {
153  case 1:
154  rwlen |= DR7_RWLEN_1;
155  break;
156  case 2:
157  rwlen |= DR7_RWLEN_2;
158  break;
159  case 4:
160  rwlen |= DR7_RWLEN_4;
161  break;
162  case 8:
163  rwlen |= DR7_RWLEN_8;
164  break;
165  default:
166  return -ENOTSUP;
167  }
168 
169  /* Convert to linear address */
170  if ( sizeof ( physaddr_t ) <= sizeof ( uint32_t ) )
171  addr = virt_to_phys ( ( void * ) addr );
172 
173  /* Find reusable or available hardware breakpoint */
174  bp = gdbmach_find ( addr, rwlen );
175  if ( bp < 0 )
176  return ( enable ? -ENOBUFS : 0 );
177 
178  /* Configure this breakpoint */
179  DBGC ( &dr[0], "GDB bp %d at %p+%zx type %d (%sabled)\n",
180  bp, ( ( void * ) addr ), len, type, ( enable ? "en" : "dis" ) );
181  dr[bp] = addr;
182  mask = DR7_RWLEN_MASK ( bp );
183  dr7 = ( ( dr7 & ~mask ) | ( rwlen & mask ) );
184  mask = DR7_G ( bp );
185  dr7 &= ~mask;
186  if ( enable )
187  dr7 |= mask;
188 
189  /* Update debug registers */
190  gdbmach_update();
191 
192  return 0;
193 }
#define DR7_RWLEN_MASK(bp)
Debug register 7: Breakpoint R/W and length mask.
Definition: gdbmach.c:69
uint32_t type
Operating system type.
Definition: ena.h:12
#define DBGC(...)
Definition: compiler.h:505
uint16_t bp
Definition: registers.h:23
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
#define DR7_RWLEN_1
Debug register 7: One-byte length.
Definition: gdbmach.c:57
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static int gdbmach_find(unsigned long addr, unsigned int rwlen)
Find reusable or available hardware breakpoint.
Definition: gdbmach.c:98
#define DR7_RWLEN_ACCESS
Debug register 7: Break on data access.
Definition: gdbmach.c:54
static unsigned long dr[NUM_HWBP]
Hardware breakpoint addresses (debug registers 0-3)
Definition: gdbmach.c:72
unsigned int uint32_t
Definition: stdint.h:12
unsigned long physaddr_t
Definition: stdint.h:20
#define DR7_RWLEN_2
Debug register 7: Two-byte length.
Definition: gdbmach.c:60
#define DR7_G(bp)
Debug register 7: Global breakpoint enable.
Definition: gdbmach.c:45
static void gdbmach_update(void)
Update debug registers.
Definition: gdbmach.c:81
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
u32 addr
Definition: sky2.h:8
static unsigned long dr7
Active value of debug register 7.
Definition: gdbmach.c:75
#define DR7_RWLEN_8
Debug register 7: Eight-byte length.
Definition: gdbmach.c:66
uint32_t len
Length.
Definition: ena.h:14
#define DR7_RWLEN_WRITE
Debug register 7: Break on data writes.
Definition: gdbmach.c:51
#define DR7_RWLEN_4
Debug register 7: Four-byte length.
Definition: gdbmach.c:63

References addr, bp, DBGC, dr, dr7, DR7_G, DR7_RWLEN_1, DR7_RWLEN_2, DR7_RWLEN_4, DR7_RWLEN_8, DR7_RWLEN_ACCESS, DR7_RWLEN_MASK, DR7_RWLEN_WRITE, ENOBUFS, ENOTSUP, GDBMACH_AWATCH, gdbmach_find(), gdbmach_update(), GDBMACH_WATCH, len, type, and virt_to_phys().

Referenced by gdbstub_breakpoint().

◆ gdbmach_init()

void gdbmach_init ( void  )

Initialise GDB.

Definition at line 241 of file gdbmach.c.

241  {
242  unsigned int i;
243 
244  /* Hook CPU exception vectors */
245  for ( i = 0 ; i < ( sizeof ( gdbmach_vectors ) /
246  sizeof ( gdbmach_vectors[0] ) ) ; i++ ) {
247  if ( gdbmach_vectors[i] )
249  }
250 }
static void * gdbmach_vectors[]
CPU exception vectors.
Definition: gdbmach.c:228
void set_interrupt_vector(unsigned int intr, void *vector)
Set interrupt vector.
Definition: librm_mgmt.c:97

References gdbmach_vectors, and set_interrupt_vector().

Referenced by gdbstub_start().