Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
kgdb.c File Reference
#include <linux/string.h>
#include <linux/signal.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/linkage.h>
#include <linux/reboot.h>
#include <asm/setup.h>
#include <asm/ptrace.h>
#include <arch/svinto.h>
#include <asm/irq.h>

Go to the source code of this file.

Data Structures

struct  register_image
 

Macros

#define HEXCHARS_IN_THREAD_ID   16
 
#define USEDVAR(name)   { if (name) { ; } }
 
#define USEDFUN(name)   { void (*pf)(void) = (void *)name; USEDVAR(pf) }
 
#define BUFMAX   512
 
#define RUNLENMAX   64
 
#define INTERNAL_STACK_SIZE   1024
 

Typedefs

typedef struct register_image registers
 

Enumerations

enum  error_type {
  SUCCESS, E01, E02, E03,
  E04, E05, E06, E07,
  SUCCESS, E01, E02, E03,
  E04, E05, E06
}
 
enum  register_name {
  R0, R1, R2, R3,
  R4, R5, R6, R7,
  R8, R9, R10, R11,
  R12, R13, SP, PC,
  P0, VR, P2, P3,
  P4, CCR, P6, MOF,
  P8, IBR, IRP, SRP,
  BAR, DCCR, BRP, USP,
  R0, R1, R2, R3,
  R4, R5, R6, R7,
  R8, R9, R10, R11,
  R12, R13, SP, ACR,
  BZ, VR, PID, SRS,
  WZ, EXS, EDA, MOF,
  DZ, EBP, ERP, SRP,
  NRP, CCS, USP, SPC,
  PC, S0, S1, S2,
  S3, S4, S5, S6,
  S7, S8, S9, S10,
  S11, S12, S13, S14,
  S15
}
 

Functions

int getDebugChar (void)
 
void putDebugChar (int val)
 
void enableDebugIRQ (void)
 
void putDebugString (const unsigned char *str, int length)
 
void handle_breakpoint (void)
 
void handle_interrupt (void)
 
void breakpoint (void)
 
void kgdb_handle_breakpoint (void)
 
 asm (" .global kgdb_handle_breakpoint kgdb_handle_breakpoint: ;; ;; Response to the break-instruction ;; ;; Create a register image of the caller ;; move $dccr,[reg+0x5E] ; Save the flags in DCCR before disable interrupts di ; Disable interrupts move.d $r0,[reg] ; Save R0 move.d $r1,[reg+0x04] ; Save R1 move.d $r2,[reg+0x08] ; Save R2 move.d $r3,[reg+0x0C] ; Save R3 move.d $r4,[reg+0x10] ; Save R4 move.d $r5,[reg+0x14] ; Save R5 move.d $r6,[reg+0x18] ; Save R6 move.d $r7,[reg+0x1C] ; Save R7 move.d $r8,[reg+0x20] ; Save R8 move.d $r9,[reg+0x24] ; Save R9 move.d $r10,[reg+0x28] ; Save R10 move.d $r11,[reg+0x2C] ; Save R11 move.d $r12,[reg+0x30] ; Save R12 move.d $r13,[reg+0x34] ; Save R13 move.d $sp,[reg+0x38] ; Save SP (R14) ;; Due to the old assembler-versions BRP might not be recognized .word 0xE670 ; move brp,$r0 subq 2,$r0 ; Set to address of previous instruction. move.d $r0,[reg+0x3c] ; Save the address in PC (R15) clear.b [reg+0x40] ; Clear P0 move $vr,[reg+0x41] ; Save special register P1 clear.w [reg+0x42] ; Clear P4 move $ccr,[reg+0x44] ; Save special register CCR move $mof,[reg+0x46] ; P7 clear.d [reg+0x4A] ; Clear P8 move $ibr,[reg+0x4E] ; P9, move $irp,[reg+0x52] ; P10, move $srp,[reg+0x56] ; P11, move $dtp0,[reg+0x5A] ; P12, register BAR, assembler might not know BAR ; P13, register DCCR already saved ;; Due to the old assembler-versions BRP might not be recognized .word 0xE670 ; move brp,r0 ;; Static (compiled) breakpoints must return to the next instruction in order ;; to avoid infinite loops. Dynamic (gdb-invoked) must restore the instruction ;; in order to execute it when execution is continued. test.b [is_dyn_brkp] ; Is this a dynamic breakpoint? beq is_static ; No, a static breakpoint nop subq 2,$r0 ; rerun the instruction the break replaced is_static: moveq 1,$r1 move.b $r1,[is_dyn_brkp] ; Set the state variable to dynamic breakpoint move.d $r0,[reg+0x62] ; Save the return address in BRP move $usp,[reg+0x66] ; USP ;; ;; Handle the communication ;; move.d internal_stack+1020,$sp ; Use the internal stack which grows upward moveq 5,$r10 ; SIGTRAP jsr handle_exception ; Interactive routine ;; ;; Return to the caller ;; move.d [reg],$r0 ; Restore R0 move.d [reg+0x04],$r1 ; Restore R1 move.d [reg+0x08],$r2 ; Restore R2 move.d [reg+0x0C],$r3 ; Restore R3 move.d [reg+0x10],$r4 ; Restore R4 move.d [reg+0x14],$r5 ; Restore R5 move.d [reg+0x18],$r6 ; Restore R6 move.d [reg+0x1C],$r7 ; Restore R7 move.d [reg+0x20],$r8 ; Restore R8 move.d [reg+0x24],$r9 ; Restore R9 move.d [reg+0x28],$r10 ; Restore R10 move.d [reg+0x2C],$r11 ; Restore R11 move.d [reg+0x30],$r12 ; Restore R12 move.d [reg+0x34],$r13 ; Restore R13 ;; ;; FIXME: Which registers should be restored? ;; move.d [reg+0x38],$sp ; Restore SP (R14) move [reg+0x56],$srp ; Restore the subroutine return pointer. move [reg+0x5E],$dccr ; Restore DCCR move [reg+0x66],$usp ; Restore USP jump [reg+0x62] ; A jump to the content in register BRP works. nop ; ")
 
void kgdb_handle_serial (void)
 
 asm (" .global kgdb_handle_serial kgdb_handle_serial: ;; ;; Response to a serial interrupt ;; move $dccr,[reg+0x5E] ; Save the flags in DCCR di ; Disable interrupts move.d $r0,[reg] ; Save R0 move.d $r1,[reg+0x04] ; Save R1 move.d $r2,[reg+0x08] ; Save R2 move.d $r3,[reg+0x0C] ; Save R3 move.d $r4,[reg+0x10] ; Save R4 move.d $r5,[reg+0x14] ; Save R5 move.d $r6,[reg+0x18] ; Save R6 move.d $r7,[reg+0x1C] ; Save R7 move.d $r8,[reg+0x20] ; Save R8 move.d $r9,[reg+0x24] ; Save R9 move.d $r10,[reg+0x28] ; Save R10 move.d $r11,[reg+0x2C] ; Save R11 move.d $r12,[reg+0x30] ; Save R12 move.d $r13,[reg+0x34] ; Save R13 move.d $sp,[reg+0x38] ; Save SP (R14) move $irp,[reg+0x3c] ; Save the address in PC (R15) clear.b [reg+0x40] ; Clear P0 move $vr,[reg+0x41] ; Save special register P1, clear.w [reg+0x42] ; Clear P4 move $ccr,[reg+0x44] ; Save special register CCR move $mof,[reg+0x46] ; P7 clear.d [reg+0x4A] ; Clear P8 move $ibr,[reg+0x4E] ; P9, move $irp,[reg+0x52] ; P10, move $srp,[reg+0x56] ; P11, move $dtp0,[reg+0x5A] ; P12, register BAR, assembler might not know BAR ; P13, register DCCR already saved ;; Due to the old assembler-versions BRP might not be recognized .word 0xE670 ; move brp,r0 move.d $r0,[reg+0x62] ; Save the return address in BRP move $usp,[reg+0x66] ; USP ;; get the serial character (from debugport.c) and check if it is a ctrl-c jsr getDebugChar cmp.b 3, $r10 bne goback nop move.d [reg+0x5E], $r10 ; Get DCCR btstq 8, $r10 ; Test the U-flag. bmi goback nop ;; ;; Handle the communication ;; move.d internal_stack+1020,$sp ; Use the internal stack moveq 2,$r10 ; SIGINT jsr handle_exception ; Interactive routine goback: ;; ;; Return to the caller ;; move.d [reg],$r0 ; Restore R0 move.d [reg+0x04],$r1 ; Restore R1 move.d [reg+0x08],$r2 ; Restore R2 move.d [reg+0x0C],$r3 ; Restore R3 move.d [reg+0x10],$r4 ; Restore R4 move.d [reg+0x14],$r5 ; Restore R5 move.d [reg+0x18],$r6 ; Restore R6 move.d [reg+0x1C],$r7 ; Restore R7 move.d [reg+0x20],$r8 ; Restore R8 move.d [reg+0x24],$r9 ; Restore R9 move.d [reg+0x28],$r10 ; Restore R10 move.d [reg+0x2C],$r11 ; Restore R11 move.d [reg+0x30],$r12 ; Restore R12 move.d [reg+0x34],$r13 ; Restore R13 ;; ;; FIXME: Which registers should be restored? ;; move.d [reg+0x38],$sp ; Restore SP (R14) move [reg+0x56],$srp ; Restore the subroutine return pointer. move [reg+0x5E],$dccr ; Restore DCCR move [reg+0x66],$usp ; Restore USP reti ; Return from the interrupt routine nop ")
 
void kgdb_init (void)
 

Variables

unsigned char executing_task
 

Macro Definition Documentation

#define BUFMAX   512

Definition at line 346 of file kgdb.c.

#define HEXCHARS_IN_THREAD_ID   16

Definition at line 337 of file kgdb.c.

#define INTERNAL_STACK_SIZE   1024

Definition at line 434 of file kgdb.c.

#define RUNLENMAX   64

Definition at line 349 of file kgdb.c.

#define USEDFUN (   name)    { void (*pf)(void) = (void *)name; USEDVAR(pf) }

Definition at line 341 of file kgdb.c.

#define USEDVAR (   name)    { if (name) { ; } }

Definition at line 340 of file kgdb.c.

Typedef Documentation

Enumeration Type Documentation

enum error_type
Enumerator:
SUCCESS 
E01 
E02 
E03 
E04 
E05 
E06 
E07 
SUCCESS 
E01 
E02 
E03 
E04 
E05 
E06 

Definition at line 356 of file kgdb.c.

Enumerator:
R0 
R1 
R2 
R3 
R4 
R5 
R6 
R7 
R8 
R9 
R10 
R11 
R12 
R13 
SP 
PC 
P0 
VR 
P2 
P3 
P4 
CCR 
P6 
MOF 
P8 
IBR 
IRP 
SRP 
BAR 
DCCR 
BRP 
USP 
R0 
R1 
R2 
R3 
R4 
R5 
R6 
R7 
R8 
R9 
R10 
R11 
R12 
R13 
SP 
ACR 
BZ 
VR 
PID 
SRS 
WZ 
EXS 
EDA 
MOF 
DZ 
EBP 
ERP 
SRP 
NRP 
CCS 
USP 
SPC 
PC 
S0 
S1 
S2 
S3 
S4 
S5 
S6 
S7 
S8 
S9 
S10 
S11 
S12 
S13 
S14 
S15 

Definition at line 380 of file kgdb.c.

Function Documentation

asm ( " .global kgdb_handle_breakpointkgdb_handle_breakpoint:;;;; Response to the break-instruction;;;; Create a register image of the caller;; move  $dccr,
[reg+0x5E] ;Save the flags in DCCR before disable interrupts di;Disable interrupts move.d  $r0,
[reg] ;Save R0 move.d  $r1,
[reg+0x04] ;Save R1 move.d  $r2,
[reg+0x08] ;Save R2 move.d  $r3,
[reg+0x0C] ;Save R3 move.d  $r4,
[reg+0x10] ;Save R4 move.d  $r5,
[reg+0x14] ;Save R5 move.d  $r6,
[reg+0x18] ;Save R6 move.d  $r7,
[reg+0x1C] ;Save R7 move.d  $r8,
[reg+0x20] ;Save R8 move.d  $r9,
[reg+0x24] ;Save R9 move.d  $r10,
[reg+0x28] ;Save R10 move.d  $r11,
[reg+0x2C] ;Save R11 move.d  $r12,
[reg+0x30] ;Save R12 move.d  $r13,
[reg+0x34] ;Save R13 move.d  $sp,
[reg+0x38] ;Save SP(R14);;Due to the old assembler-versions BRP might not be recognized.word 0xE670;move  brp,
  $r0 subq,
  $r0;Set to address of previous instruction.move.d,
[reg+0x3c] ;Save the address in PC(R15) clear.b;Clear P0 move  $vr[reg+0x40],
[reg+0x41] ;Save special register P1 clear.w;Clear P4 move  $ccr[reg+0x42],
[reg+0x44] ;Save special register CCR move  $mof,
[reg+0x46] ;P7 clear.d;Clear P8 move  $ibr[reg+0x4A],
[reg+0x4E] ;  P9,
move  $irp,
[reg+0x52] ;  P10,
move  $srp,
[reg+0x56] ;  P11,
move  $dtp0,
[reg+0x5A] ;  P12,
register  BAR,
assembler might not know BAR P13,
register DCCR already saved;;Due to the old assembler-versions BRP might not be recognized.word 0xE670;move  brp,
r0;;Static(compiled) breakpoints must return to the next instruction in order;;to avoid infinite loops.Dynamic(gdb-invoked) must restore the instruction;;in order to execute it when execution is continued.test.b;Is this a dynamic breakpoint?beq is_static;  No[is_dyn_brkp],
a static breakpoint nop subq  2,
  $r0;rerun the instruction the break replacedis_static:moveq,
  $r1 move.b,
[is_dyn_brkp] ;Set the state variable to dynamic breakpoint move.d  $r0,
[reg+0x62] ;Save the return address in BRP move  $usp,
[reg+0x66] ;USP;;;;Handle the communication;;move.d internal_stack 1020,
  $sp;Use the internal stack which grows upward moveq,
  $r10;SIGTRAP jsr handle_exception;Interactive routine;;;;Return to the caller;;move.[reg],
  $r0;Restore R0 move.[reg+0x04],
  $r1;Restore R1 move.[reg+0x08],
  $r2;Restore R2 move.[reg+0x0C],
  $r3;Restore R3 move.[reg+0x10],
  $r4;Restore R4 move.[reg+0x14],
  $r5;Restore R5 move.[reg+0x18],
  $r6;Restore R6 move.[reg+0x1C],
  $r7;Restore R7 move.[reg+0x20],
  $r8;Restore R8 move.[reg+0x24],
  $r9;Restore R9 move.[reg+0x28],
  $r10;Restore R10 move.[reg+0x2C],
  $r11;Restore R11 move.[reg+0x30],
  $r12;Restore R12 move.[reg+0x34],
  $r13;Restore R13;;;;FIXME:Which registers should be restored?;;move.[reg+0x38],
  $sp;Restore SP(R14)[reg+0x56],
  $srp;Restore the subroutine return pointer.[reg+0x5E],
  $dccr;Restore DCCR[reg+0x66],
  $usp;Restore USP jump;A jump to the content in register BRP works.nop;"[reg+0x62] 
)
asm ( " .global kgdb_handle_serialkgdb_handle_serial:;;;; Response to a serial interrupt;; move  $dccr,
[reg+0x5E] ;Save the flags in DCCR di;Disable interrupts move.d  $r0,
[reg] ;Save R0 move.d  $r1,
[reg+0x04] ;Save R1 move.d  $r2,
[reg+0x08] ;Save R2 move.d  $r3,
[reg+0x0C] ;Save R3 move.d  $r4,
[reg+0x10] ;Save R4 move.d  $r5,
[reg+0x14] ;Save R5 move.d  $r6,
[reg+0x18] ;Save R6 move.d  $r7,
[reg+0x1C] ;Save R7 move.d  $r8,
[reg+0x20] ;Save R8 move.d  $r9,
[reg+0x24] ;Save R9 move.d  $r10,
[reg+0x28] ;Save R10 move.d  $r11,
[reg+0x2C] ;Save R11 move.d  $r12,
[reg+0x30] ;Save R12 move.d  $r13,
[reg+0x34] ;Save R13 move.d  $sp,
[reg+0x38] ;Save SP(R14) move  $irp,
[reg+0x3c] ;Save the address in PC(R15) clear.b;Clear P0 move  $vr[reg+0x40],
[reg+0x41] ;Save special register  P1,
clear.w;Clear P4 move  $ccr[reg+0x42],
[reg+0x44] ;Save special register CCR move  $mof,
[reg+0x46] ;P7 clear.d;Clear P8 move  $ibr[reg+0x4A],
[reg+0x4E] ;  P9,
move  $irp,
[reg+0x52] ;  P10,
move  $srp,
[reg+0x56] ;  P11,
move  $dtp0,
[reg+0x5A] ;  P12,
register  BAR,
assembler might not know BAR P13,
register DCCR already saved;;Due to the old assembler-versions BRP might not be recognized.word 0xE670;move  brp,
r0 move.d  $r0,
[reg+0x62] ;Save the return address in BRP move  $usp,
[reg+0x66] ;USP;;get the serial character(from debugport.c) and check if it is a ctrl-c jsr getDebugChar cmp.b  3,
  $r10 bne goback nop move.[reg+0x5E],
  $r10;Get DCCR btstq,
  $r10;Test the U-flag.bmi goback nop;;;;Handle the communication;;move.d internal_stack+,
  $sp;Use the internal stack moveq,
  $r10;SIGINT jsr handle_exception;Interactive routinegoback:;;;;Return to the caller;;move.[reg],
  $r0;Restore R0 move.[reg+0x04],
  $r1;Restore R1 move.[reg+0x08],
  $r2;Restore R2 move.[reg+0x0C],
  $r3;Restore R3 move.[reg+0x10],
  $r4;Restore R4 move.[reg+0x14],
  $r5;Restore R5 move.[reg+0x18],
  $r6;Restore R6 move.[reg+0x1C],
  $r7;Restore R7 move.[reg+0x20],
  $r8;Restore R8 move.[reg+0x24],
  $r9;Restore R9 move.[reg+0x28],
  $r10;Restore R10 move.[reg+0x2C],
  $r11;Restore R11 move.[reg+0x30],
  $r12;Restore R12 move.[reg+0x34],
  $r13;Restore R13;;;;FIXME:Which registers should be restored?;;move.[reg+0x38],
  $sp;Restore SP(R14)[reg+0x56],
  $srp;Restore the subroutine return pointer.[reg+0x5E],
  $dccr;Restore DCCR[reg+0x66],
  $usp;Restore USP reti;Return from the interrupt routine nop" 
)
void breakpoint ( void  )

Definition at line 1462 of file kgdb.c.

void enableDebugIRQ ( void  )

Definition at line 371 of file debugport.c.

int getDebugChar ( void  )

Definition at line 341 of file debugport.c.

void handle_breakpoint ( void  )
void handle_interrupt ( void  )
void kgdb_handle_breakpoint ( void  )
void kgdb_handle_serial ( void  )
void kgdb_init ( void  )

Definition at line 1472 of file kgdb.c.

void putDebugChar ( int  val)

Definition at line 358 of file debugport.c.

void putDebugString ( const unsigned char str,
int  length 
)

Definition at line 841 of file kgdb.c.

Variable Documentation

unsigned char executing_task