ReactOS  0.4.13-dev-92-gf251225
gdblib.c File Reference
#include "ppcmmu/mmu.h"
Include dependency graph for gdblib.c:

Go to the source code of this file.

Classes

struct  _BREAKPOINT
 

Macros

#define GDB_SAVE_SIZE   0x66
 
#define RCV   0
 
#define THR   0
 
#define BAUDLOW   0
 
#define BAUDHIGH   1
 
#define IER   1
 
#define FCR   2
 
#define ISR   2
 
#define LCR   3
 
#define MCR   4
 
#define LSR   5
 
#define MSR   6
 
#define SPR   7
 

Typedefs

typedef struct _BREAKPOINT BREAKPOINT
 
typedef struct _BREAKPOINTPBREAKPOINT
 

Functions

void send (char *serport, char c)
 
char recv (char *serport)
 
void setup (char *serport, int baud)
 
int isxdigit (int ch)
 
void sync ()
 
int rdy (char *serport)
 
int chr (char *serport)
 
void SerialSetUp (int deviceType, void *deviceAddr, int baud)
 
int SerialInterrupt (int signal, ppc_trap_frame_t *tf)
 
void IntEnable ()
 
void SerialWrite (int ch)
 
int SerialRead ()
 
int hex2int (int ch)
 
int PacketReadHexNumber (int dig)
 
void PacketWriteChar (int ch)
 
int PacketWriteHexNumber (int hnum, int dig)
 
void PacketStart ()
 
void PacketFinish ()
 
void PacketWriteString (char *str)
 
void PacketOk ()
 
void PacketEmpty ()
 
void PacketWriteSignal (int code)
 
void PacketWriteError (int code)
 
void marker ()
 
void GotPacket ()
 
int TakeException (int n, ppc_trap_frame_t *tf)
 

Variables

BREAKPOINT BreakPoints [64]
 
char DataOutBuffer [1024]
 
volatile int DataOutAddr
 
volatile int DataOutCsum
 
char DataInBuffer [128]
 
volatile int DataInAddr
 
volatile int ParseState = 0
 
volatile int ComputedCsum
 
volatile int ActualCsum
 
volatile int PacketSent = 0
 
volatile int SendSignal = 0
 
volatile int Continue = 0
 
volatile int Signal = 0
 
volatile ppc_trap_frame_t RegisterSaves
 
volatile ppc_trap_frame_tRegisterSaveArea = &RegisterSaves
 
charhex = "0123456789abcdef"
 
charserport = (char *)0x800003f8
 

Macro Definition Documentation

◆ BAUDHIGH

#define BAUDHIGH   1

Definition at line 109 of file gdblib.c.

◆ BAUDLOW

#define BAUDLOW   0

Definition at line 108 of file gdblib.c.

◆ FCR

#define FCR   2

Definition at line 111 of file gdblib.c.

◆ GDB_SAVE_SIZE

#define GDB_SAVE_SIZE   0x66

Definition at line 89 of file gdblib.c.

◆ IER

#define IER   1

Definition at line 110 of file gdblib.c.

◆ ISR

#define ISR   2

Definition at line 112 of file gdblib.c.

◆ LCR

#define LCR   3

Definition at line 113 of file gdblib.c.

◆ LSR

#define LSR   5

Definition at line 115 of file gdblib.c.

◆ MCR

#define MCR   4

Definition at line 114 of file gdblib.c.

◆ MSR

#define MSR   6

Definition at line 116 of file gdblib.c.

◆ RCV

#define RCV   0

Definition at line 106 of file gdblib.c.

◆ SPR

#define SPR   7

Definition at line 117 of file gdblib.c.

◆ THR

#define THR   0

Definition at line 107 of file gdblib.c.

Typedef Documentation

◆ BREAKPOINT

◆ PBREAKPOINT

Function Documentation

◆ chr()

◆ GotPacket()

void GotPacket ( )

Definition at line 309 of file gdblib.c.

310 {
311  int i, memaddr, memsize;
312 
313  Continue = 0;
314  switch (DataInBuffer[DataInAddr++])
315  {
316  case 'g':
317  PacketStart();
318  for (i = 0; i < GDB_SAVE_SIZE; i++)
319  {
321  }
322  PacketFinish();
323  break;
324 
325  case 'G':
326  for (i = 0; i < sizeof(*RegisterSaveArea) / sizeof(int); i++)
327  {
328  ((int *)RegisterSaveArea)[i] = PacketReadHexNumber(8);
329  }
330  PacketOk();
331  break;
332 
333  case 'm':
334  memaddr = PacketReadHexNumber(8);
335  DataInAddr++;
336  memsize = PacketReadHexNumber(8);
337  PacketStart();
338  while(memsize-- > 0)
339  {
340  PacketWriteHexNumber(*((char *)memaddr++), 2);
341  }
342  PacketFinish();
343  break;
344 
345  case 'M':
346  memaddr = PacketReadHexNumber(8);
347  DataInAddr++;
348  memsize = PacketReadHexNumber(8);
349  DataInAddr++;
350  while(memsize-- > 0)
351  {
352  *((char *)memaddr++) = PacketReadHexNumber(2);
353  }
354  PacketOk();
355  break;
356 
357  case '?':
359  break;
360 
361  case 'c':
362  PacketOk();
363  Continue = 1;
364  break;
365 
366  case 'S':
367  PacketOk();
368  Continue = 0;
369  break;
370 
371  case 's':
372  RegisterSaveArea->srr1 |= 0x400;
373  PacketOk();
374  Continue = 1;
375  marker();
376  break;
377 
378  case 'q':
379  switch (DataInBuffer[1])
380  {
381  case 'S': /*upported => nothing*/
382  PacketEmpty();
383  break;
384 
385  case 'O': /*ffsets*/
386  PacketEmpty();
387  break;
388  }
389  break;
390 
391  default:
392  PacketEmpty();
393  break;
394  }
395 }
void PacketFinish()
Definition: gdblib.c:248
volatile ppc_trap_frame_t * RegisterSaveArea
Definition: gdblib.c:103
void PacketEmpty()
Definition: gdblib.c:285
unsigned long srr1
Definition: mmu.h:115
void PacketOk()
Definition: gdblib.c:278
void PacketStart()
Definition: gdblib.c:242
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
volatile int DataInAddr
Definition: gdblib.c:100
int PacketReadHexNumber(int dig)
Definition: gdblib.c:212
void PacketWriteSignal(int code)
Definition: gdblib.c:291
#define GDB_SAVE_SIZE
Definition: gdblib.c:89
char DataInBuffer[128]
Definition: gdblib.c:99
volatile int Signal
Definition: gdblib.c:102
volatile int Continue
Definition: gdblib.c:102
int PacketWriteHexNumber(int hnum, int dig)
Definition: gdblib.c:230
void marker()
Definition: gdblib.c:307
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by SerialInterrupt().

◆ hex2int()

int hex2int ( int  ch)

Definition at line 205 of file gdblib.c.

206 {
207  if (ch >= 'a' && ch <= 'f') return ch + 10 - 'a';
208  else if (ch >= 'A' && ch <= 'F') return ch + 10 - 'A';
209  else return ch - '0';
210 }

Referenced by PacketReadHexNumber(), and SerialInterrupt().

◆ IntEnable()

void IntEnable ( )

Definition at line 190 of file gdblib.c.

191 {
193 }
int GetPhysByte(int Addr)
char * serport
Definition: gdblib.c:123
unsigned long paddr_t
Definition: mmu.h:89
#define IER
Definition: gdblib.c:110
void SetPhysByte(ULONG Addr, ULONG Data)

Referenced by OHCI_EnableInterrupts(), OHCI_InterruptNextSOF(), OHCI_InterruptService(), OHCI_ResetController(), and OHCI_TakeControlHC().

◆ isxdigit()

int isxdigit ( int  ch)

Definition at line 125 of file gdblib.c.

126 {
127  return
128  (ch >= 'A' && ch <= 'F') ||
129  (ch >= 'a' && ch <= 'f') ||
130  (ch >= '0' && ch <= '9');
131 }

Referenced by PacketReadHexNumber().

◆ marker()

void marker ( )

Definition at line 307 of file gdblib.c.

307 { }

Referenced by GotPacket().

◆ PacketEmpty()

void PacketEmpty ( )

Definition at line 285 of file gdblib.c.

286 {
287  PacketStart();
288  PacketFinish();
289 }
void PacketFinish()
Definition: gdblib.c:248
void PacketStart()
Definition: gdblib.c:242

Referenced by GotPacket().

◆ PacketFinish()

void PacketFinish ( )

Definition at line 248 of file gdblib.c.

249 {
250  int i, ch, count = 0;
251 
252  PacketSent = 0;
253 
254  SerialWrite('$');
255  for (i = 0; i < DataOutAddr; i++)
256  {
258  }
259  SerialWrite('#');
260  SerialWrite(hex[(DataOutCsum >> 4) & 15]);
261  SerialWrite(hex[DataOutCsum & 15]);
262 
263  while(!chr(serport) && ((ch = SerialRead()) != '+') && (ch != '$'));
264  if (ch == '$')
265  {
266  ParseState = 0;
267  DataInAddr = 0;
268  ComputedCsum = 0;
269  }
270 }
char * serport
Definition: gdblib.c:123
GLuint GLuint GLsizei count
Definition: gl.h:1545
volatile int DataOutAddr
Definition: gdblib.c:98
char * hex
Definition: gdblib.c:104
void SerialWrite(int ch)
Definition: gdblib.c:195
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
volatile int DataOutCsum
Definition: gdblib.c:98
char DataOutBuffer[1024]
Definition: gdblib.c:97
volatile int DataInAddr
Definition: gdblib.c:100
volatile int ParseState
Definition: gdblib.c:100
volatile int ComputedCsum
Definition: gdblib.c:100
int chr(char *serport)
Definition: gdblib.c:152
volatile int PacketSent
Definition: gdblib.c:101
int SerialRead()
Definition: gdblib.c:200

Referenced by GotPacket(), PacketEmpty(), PacketOk(), PacketWriteError(), and PacketWriteSignal().

◆ PacketOk()

void PacketOk ( )

Definition at line 278 of file gdblib.c.

279 {
280  PacketStart();
281  PacketWriteString("OK");
282  PacketFinish();
283 }
void PacketFinish()
Definition: gdblib.c:248
void PacketWriteString(char *str)
Definition: gdblib.c:273
void PacketStart()
Definition: gdblib.c:242

Referenced by GotPacket().

◆ PacketReadHexNumber()

int PacketReadHexNumber ( int  dig)

Definition at line 212 of file gdblib.c.

213 {
214  int i;
215  int result = 0;
216  for (i = 0; i < dig && isxdigit(DataInBuffer[DataInAddr]); i++)
217  {
218  result <<= 4;
220  }
221  return result;
222 }
int isxdigit(int ch)
Definition: gdblib.c:125
int hex2int(int ch)
Definition: gdblib.c:205
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
volatile int DataInAddr
Definition: gdblib.c:100
char DataInBuffer[128]
Definition: gdblib.c:99
GLuint64EXT * result
Definition: glext.h:11304

Referenced by GotPacket().

◆ PacketStart()

void PacketStart ( )

Definition at line 242 of file gdblib.c.

243 {
244  DataOutCsum = 0;
245  DataOutAddr = 0;
246 }
volatile int DataOutAddr
Definition: gdblib.c:98
volatile int DataOutCsum
Definition: gdblib.c:98

Referenced by GotPacket(), PacketEmpty(), PacketOk(), PacketWriteError(), and PacketWriteSignal().

◆ PacketWriteChar()

void PacketWriteChar ( int  ch)

Definition at line 224 of file gdblib.c.

225 {
226  DataOutCsum += ch;
227  DataOutBuffer[DataOutAddr++] = ch;
228 }
volatile int DataOutAddr
Definition: gdblib.c:98
volatile int DataOutCsum
Definition: gdblib.c:98
char DataOutBuffer[1024]
Definition: gdblib.c:97

Referenced by PacketWriteError(), PacketWriteHexNumber(), PacketWriteSignal(), and PacketWriteString().

◆ PacketWriteError()

void PacketWriteError ( int  code)

Definition at line 299 of file gdblib.c.

300 {
301  PacketStart();
302  PacketWriteChar('E');
304  PacketFinish();
305 }
void PacketFinish()
Definition: gdblib.c:248
void PacketWriteChar(int ch)
Definition: gdblib.c:224
void PacketStart()
Definition: gdblib.c:242
int PacketWriteHexNumber(int hnum, int dig)
Definition: gdblib.c:230

◆ PacketWriteHexNumber()

int PacketWriteHexNumber ( int  hnum,
int  dig 
)

Definition at line 230 of file gdblib.c.

231 {
232  int i;
233  hnum <<= (8 - dig) * 4;
234  for (i = 0; i < dig; i++)
235  {
236  PacketWriteChar(hex[(hnum >> 28) & 15]);
237  hnum <<= 4;
238  }
239  return i;
240 }
void PacketWriteChar(int ch)
Definition: gdblib.c:224
char * hex
Definition: gdblib.c:104
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by GotPacket(), PacketWriteError(), and PacketWriteSignal().

◆ PacketWriteSignal()

void PacketWriteSignal ( int  code)

Definition at line 291 of file gdblib.c.

292 {
293  PacketStart();
294  PacketWriteChar('S');
296  PacketFinish();
297 }
void PacketFinish()
Definition: gdblib.c:248
void PacketWriteChar(int ch)
Definition: gdblib.c:224
void PacketStart()
Definition: gdblib.c:242
int PacketWriteHexNumber(int hnum, int dig)
Definition: gdblib.c:230

Referenced by GotPacket(), SerialInterrupt(), and TakeException().

◆ PacketWriteString()

void PacketWriteString ( char str)

Definition at line 273 of file gdblib.c.

274 {
275  while(*str) PacketWriteChar(*str++);
276 }
void PacketWriteChar(int ch)
Definition: gdblib.c:224
const WCHAR * str

Referenced by PacketOk().

◆ rdy()

int rdy ( char serport)
inline

Definition at line 146 of file gdblib.c.

147 {
148  sync();
149  return (GetPhysByte((paddr_t)serport+LSR) & 0x20);
150 }
int GetPhysByte(int Addr)
char * serport
Definition: gdblib.c:123
unsigned long paddr_t
Definition: mmu.h:89
#define LSR
Definition: gdblib.c:115
void sync()
Definition: gdblib.c:133

◆ recv()

char recv ( char serport)
inline

Definition at line 158 of file gdblib.c.

158  {
159  char c;
160 
161  while( !chr(serport) ) sync();
162 
164  sync();
165 
166  return c;
167 }
int GetPhysByte(int Addr)
char * serport
Definition: gdblib.c:123
unsigned long paddr_t
Definition: mmu.h:89
void sync()
Definition: gdblib.c:133
#define RCV
Definition: gdblib.c:106
const GLubyte * c
Definition: glext.h:8905
int chr(char *serport)
Definition: gdblib.c:152
#define c
Definition: ke_i.h:80

Referenced by SerialRead().

◆ send()

void send ( char serport,
char  c 
)
inline

Definition at line 138 of file gdblib.c.

138  {
139  /* Wait for Clear to Send */
140  while( !(GetPhysByte((paddr_t)serport+LSR) & 0x20) ) sync();
141 
143  sync();
144 }
int GetPhysByte(int Addr)
char * serport
Definition: gdblib.c:123
unsigned long paddr_t
Definition: mmu.h:89
#define LSR
Definition: gdblib.c:115
void sync()
Definition: gdblib.c:133
const GLubyte * c
Definition: glext.h:8905
#define THR
Definition: gdblib.c:107
void SetPhysByte(ULONG Addr, ULONG Data)

Referenced by SerialWrite().

◆ SerialInterrupt()

int SerialInterrupt ( int  signal,
ppc_trap_frame_t tf 
)

Definition at line 397 of file gdblib.c.

398 {
399  int ch;
400 
401  if (!chr(serport)) return 0;
402 
403  Signal = signal;
405 
406  do
407  {
408  ch = SerialRead();
409 
410  if (ch == 3) /* Break in - tehe */
411  {
412  Continue = 0;
414  }
415  else if (ch == '+')
416  {
417  /* Nothing */
418  }
419  else if (ch == '$')
420  {
421  DataInAddr = 0;
422  ParseState = 0;
423  ComputedCsum = 0;
424  ActualCsum = 0;
425  }
426  else if (ch == '#' && ParseState == 0)
427  {
428  ParseState = 2;
429  }
430  else if (ParseState == 0)
431  {
432  ComputedCsum += ch;
433  DataInBuffer[DataInAddr++] = ch;
434  }
435  else if (ParseState == 2)
436  {
437  ActualCsum = ch;
438  ParseState++;
439  }
440  else if (ParseState == 3)
441  {
442  ActualCsum = hex2int(ch) | (hex2int(ActualCsum) << 4);
443  ComputedCsum &= 255;
444  ParseState = -1;
445  if (ComputedCsum == ActualCsum)
446  {
447  ComputedCsum = 0;
449  DataInAddr = 0;
450  Continue = 0;
451  SerialWrite('+');
452  GotPacket();
453  }
454  else
455  SerialWrite('-');
456  }
457  else if (ParseState == -1)
458  SerialWrite('-');
459  }
460  while (!Continue);
461  return 1;
462 }
volatile ppc_trap_frame_t * RegisterSaveArea
Definition: gdblib.c:103
char * serport
Definition: gdblib.c:123
HFONT tf
Definition: icontest.c:17
void GotPacket()
Definition: gdblib.c:309
int hex2int(int ch)
Definition: gdblib.c:205
void SerialWrite(int ch)
Definition: gdblib.c:195
volatile int DataInAddr
Definition: gdblib.c:100
volatile int ParseState
Definition: gdblib.c:100
void PacketWriteSignal(int code)
Definition: gdblib.c:291
volatile int ActualCsum
Definition: gdblib.c:100
volatile int ComputedCsum
Definition: gdblib.c:100
char DataInBuffer[128]
Definition: gdblib.c:99
volatile int Signal
Definition: gdblib.c:102
volatile int Continue
Definition: gdblib.c:102
int signal
Definition: xcptfil.c:12
int chr(char *serport)
Definition: gdblib.c:152
int SerialRead()
Definition: gdblib.c:200

Referenced by _mmumain(), and TakeException().

◆ SerialRead()

int SerialRead ( )

Definition at line 200 of file gdblib.c.

201 {
202  return recv(serport);
203 }
char * serport
Definition: gdblib.c:123
char recv(char *serport)
Definition: gdblib.c:158

Referenced by PacketFinish(), and SerialInterrupt().

◆ SerialSetUp()

void SerialSetUp ( int  deviceType,
void deviceAddr,
int  baud 
)

Definition at line 181 of file gdblib.c.

182 {
183  int i;
184  serport = deviceAddr;
185  setup(serport, baud);
186 }
char * serport
Definition: gdblib.c:123
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void setup(char *serport, int baud)
Definition: gdblib.c:169

Referenced by _mmumain().

◆ SerialWrite()

void SerialWrite ( int  ch)

Definition at line 195 of file gdblib.c.

196 {
197  send(serport, ch);
198 }
char * serport
Definition: gdblib.c:123
void send(char *serport, char c)
Definition: gdblib.c:138

Referenced by PacketFinish(), and SerialInterrupt().

◆ setup()

void setup ( char serport,
int  baud 
)

Definition at line 169 of file gdblib.c.

169  {
170  int x = 115200 / baud;
172  sync();
174  sync();
176  sync();
178  sync();
179 }
char * serport
Definition: gdblib.c:123
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned long paddr_t
Definition: mmu.h:89
void sync()
Definition: gdblib.c:133
#define BAUDHIGH
Definition: gdblib.c:109
#define BAUDLOW
Definition: gdblib.c:108
void SetPhysByte(ULONG Addr, ULONG Data)
#define LCR
Definition: gdblib.c:113

Referenced by create_suite(), DoInfInstall(), DoInfInstallW(), SerialSetUp(), set_script_mode(), SetPerUserSecValuesW(), test_CreateTrigger(), Test_InitializeLpkHooks(), test_SetAccountInformation_GetAccountInformation(), test_SetApplicationName_GetApplicationName(), test_SetComment_GetComment(), test_SetMaxRunTime_GetMaxRunTime(), test_SetParameters_GetParameters(), test_SetTrigger_GetTrigger(), UserInstStubWrapperW(), and via82c_timing().

◆ sync()

void sync ( void  )
inline

Definition at line 133 of file gdblib.c.

133  {
134  __asm__("eieio\n\t"
135  "sync");
136 }
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")

Referenced by chr(), rdy(), recv(), send(), and setup().

◆ TakeException()

int TakeException ( int  n,
ppc_trap_frame_t tf 
)

Definition at line 464 of file gdblib.c.

465 {
466  Signal = n;
469  SendSignal = 0;
470  Continue = 0;
471  while(!Continue) SerialInterrupt(n, tf);
472  return 1;
473 }
volatile ppc_trap_frame_t * RegisterSaveArea
Definition: gdblib.c:103
GLdouble n
Definition: glext.h:7729
HFONT tf
Definition: icontest.c:17
void PacketWriteSignal(int code)
Definition: gdblib.c:291
volatile int SendSignal
Definition: gdblib.c:101
volatile int Signal
Definition: gdblib.c:102
volatile int Continue
Definition: gdblib.c:102
int SerialInterrupt(int signal, ppc_trap_frame_t *tf)
Definition: gdblib.c:397

Referenced by _mmumain(), and initme().

Variable Documentation

◆ ActualCsum

volatile int ActualCsum

Definition at line 100 of file gdblib.c.

Referenced by SerialInterrupt().

◆ BreakPoints

BREAKPOINT BreakPoints[64]

Definition at line 96 of file gdblib.c.

◆ ComputedCsum

volatile int ComputedCsum

Definition at line 100 of file gdblib.c.

Referenced by PacketFinish(), and SerialInterrupt().

◆ Continue

◆ DataInAddr

volatile int DataInAddr

Definition at line 100 of file gdblib.c.

Referenced by GotPacket(), PacketFinish(), PacketReadHexNumber(), and SerialInterrupt().

◆ DataInBuffer

char DataInBuffer[128]

Definition at line 99 of file gdblib.c.

Referenced by GotPacket(), PacketReadHexNumber(), and SerialInterrupt().

◆ DataOutAddr

volatile int DataOutAddr

Definition at line 98 of file gdblib.c.

Referenced by PacketFinish(), PacketStart(), and PacketWriteChar().

◆ DataOutBuffer

char DataOutBuffer[1024]

Definition at line 97 of file gdblib.c.

Referenced by PacketFinish(), and PacketWriteChar().

◆ DataOutCsum

volatile int DataOutCsum

Definition at line 98 of file gdblib.c.

Referenced by PacketFinish(), PacketStart(), and PacketWriteChar().

◆ hex

const ios_base::fmtflags ios_base::hex = "0123456789abcdef"

Definition at line 104 of file gdblib.c.

Referenced by PacketFinish(), and PacketWriteHexNumber().

◆ PacketSent

volatile int PacketSent = 0

Definition at line 101 of file gdblib.c.

Referenced by PacketFinish().

◆ ParseState

volatile int ParseState = 0

Definition at line 100 of file gdblib.c.

Referenced by PacketFinish(), and SerialInterrupt().

◆ RegisterSaveArea

volatile ppc_trap_frame_t * RegisterSaveArea = &RegisterSaves

Definition at line 103 of file gdblib.c.

Referenced by GotPacket(), SerialInterrupt(), and TakeException().

◆ RegisterSaves

volatile ppc_trap_frame_t RegisterSaves

Definition at line 103 of file gdblib.c.

◆ SendSignal

volatile int SendSignal = 0

Definition at line 101 of file gdblib.c.

Referenced by TakeException().

◆ serport

char* serport = (char *)0x800003f8

◆ Signal

volatile int Signal = 0

Definition at line 102 of file gdblib.c.

Referenced by GotPacket(), SerialInterrupt(), TakeException(), and TestEventConcurrent().