iPXE
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 ) )

Enumerations

enum  { GDBMACH_NREGS }

Functions

 FILE_SECBOOT (FORBIDDEN)
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.
void gdbmach_init (void)
 Initialise GDB.

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 25 of file gdbmach.h.

Referenced by gdbstub_read_regs(), and gdbstub_write_regs().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GDBMACH_NREGS 

Definition at line 20 of file gdbmach.h.

20 {
21 /* Not yet implemented */
23};
@ GDBMACH_NREGS
Definition gdbmach.h:38

Function Documentation

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ gdbmach_set_pc()

void gdbmach_set_pc ( gdbreg_t * regs,
gdbreg_t pc )
inlinestatic

Definition at line 27 of file gdbmach.h.

27 {
28 /* Not yet implemented */
29 ( void ) regs;
30 ( void ) pc;
31}
struct i386_regs regs
Definition registers.h:1

References regs.

◆ gdbmach_set_single_step()

void gdbmach_set_single_step ( gdbreg_t * regs,
int step )
inlinestatic

Definition at line 33 of file gdbmach.h.

33 {
34 /* Not yet implemented */
35 ( void ) regs;
36 ( void ) step;
37}
void step(void)
Single-step a single process.
Definition process.c:99

References regs, and step().

◆ gdbmach_breakpoint()

void gdbmach_breakpoint ( void )
inlinestatic

Definition at line 39 of file gdbmach.h.

39 {
40 /* Not yet implemented */
41}

◆ gdbmach_set_breakpoint()

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

Set hardware breakpoint.

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

Definition at line 134 of file gdbmach.c.

135 {
136 unsigned int rwlen;
137 unsigned long mask;
138 int bp;
139
140 /* Parse breakpoint type */
141 switch ( type ) {
142 case GDBMACH_WATCH:
143 rwlen = DR7_RWLEN_WRITE;
144 break;
145 case GDBMACH_AWATCH:
146 rwlen = DR7_RWLEN_ACCESS;
147 break;
148 default:
149 return -ENOTSUP;
150 }
151
152 /* Parse breakpoint length */
153 switch ( len ) {
154 case 1:
155 rwlen |= DR7_RWLEN_1;
156 break;
157 case 2:
158 rwlen |= DR7_RWLEN_2;
159 break;
160 case 4:
161 rwlen |= DR7_RWLEN_4;
162 break;
163 case 8:
164 rwlen |= DR7_RWLEN_8;
165 break;
166 default:
167 return -ENOTSUP;
168 }
169
170 /* Convert to linear address */
171 if ( sizeof ( physaddr_t ) <= sizeof ( uint32_t ) )
172 addr = virt_to_phys ( ( void * ) addr );
173
174 /* Find reusable or available hardware breakpoint */
175 bp = gdbmach_find ( addr, rwlen );
176 if ( bp < 0 )
177 return ( enable ? -ENOBUFS : 0 );
178
179 /* Configure this breakpoint */
180 DBGC ( &dr[0], "GDB bp %d at %p+%zx type %d (%sabled)\n",
181 bp, ( ( void * ) addr ), len, type, ( enable ? "en" : "dis" ) );
182 dr[bp] = addr;
183 mask = DR7_RWLEN_MASK ( bp );
184 dr7 = ( ( dr7 & ~mask ) | ( rwlen & mask ) );
185 mask = DR7_G ( bp );
186 dr7 &= ~mask;
187 if ( enable )
188 dr7 |= mask;
189
190 /* Update debug registers */
192
193 return 0;
194}
@ GDBMACH_WATCH
Definition gdbmach.h:46
@ GDBMACH_AWATCH
Definition gdbmach.h:48
unsigned int uint32_t
Definition stdint.h:12
unsigned long physaddr_t
Definition stdint.h:20
ring len
Length.
Definition dwmac.h:226
uint32_t addr
Buffer address.
Definition dwmac.h:9
uint32_t type
Operating system type.
Definition ena.h:1
static void gdbmach_update(void)
Update debug registers.
Definition gdbmach.c:82
#define DR7_RWLEN_2
Debug register 7: Two-byte length.
Definition gdbmach.c:61
static int gdbmach_find(unsigned long addr, unsigned int rwlen)
Find reusable or available hardware breakpoint.
Definition gdbmach.c:99
static unsigned long dr7
Active value of debug register 7.
Definition gdbmach.c:76
static unsigned long dr[NUM_HWBP]
Hardware breakpoint addresses (debug registers 0-3)
Definition gdbmach.c:73
#define DR7_RWLEN_4
Debug register 7: Four-byte length.
Definition gdbmach.c:64
#define DR7_RWLEN_1
Debug register 7: One-byte length.
Definition gdbmach.c:58
#define DR7_G(bp)
Debug register 7: Global breakpoint enable.
Definition gdbmach.c:46
#define DR7_RWLEN_8
Debug register 7: Eight-byte length.
Definition gdbmach.c:67
#define DR7_RWLEN_ACCESS
Debug register 7: Break on data access.
Definition gdbmach.c:55
#define DR7_RWLEN_MASK(bp)
Debug register 7: Breakpoint R/W and length mask.
Definition gdbmach.c:70
#define DR7_RWLEN_WRITE
Debug register 7: Break on data writes.
Definition gdbmach.c:52
#define DBGC(...)
Definition compiler.h:505
#define ENOTSUP
Operation not supported.
Definition errno.h:590
#define ENOBUFS
No buffer space available.
Definition errno.h:499
uint16_t bp
Definition registers.h:9

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, and type.

Referenced by gdbstub_breakpoint().

◆ gdbmach_init()

void gdbmach_init ( void )
extern

Initialise GDB.

Definition at line 242 of file gdbmach.c.

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

References gdbmach_vectors, and set_interrupt_vector().

Referenced by gdbstub_start().