?? porting.texi
字號:
@item general query @code{qXXXX}Request info about XXXX.@item general set @code{QXXXX=yyyy}Set value of @code{XXXX} to @code{yyyy}.@item query sect offs @code{qOffsets}Get section offsets. Reply is @code{Text=xxx;Data=yyy;Bss=zzz}@item console output OtextSend text to stdout. The text gets display from the target side of theserial connection.@end tableResponses can be run-length encoded to save space. A @code{*}means thatthe next character is an ASCII encoding giving a repeat count whichstands for that many repetitions of the character preceding the @code{*}.The encoding is n+29, yielding a printable character where n >=3 (which is where run length encoding starts to win). You can't use avalue of where n >126 because it's only a two byte value. An examplewould be a @code{0*03} means the same thing as @code{0000}.@node Exception handler, ROM monitors, GNU remote protocol, GDB@section A linked in exception handlerA @emph{GDB stub} consists of two parts, support for the exceptionhandler, and the exception handler itself. The exception handler needsto communicate to GDB on the host whenever there is a breakpointexception. When GDB starts a program running on the target, it's pollingthe serial port during execution looking for any debug packets. So whena breakpoint occurs, the exception handler needs to save state, and senda GDB remote protocol packet to GDB on the host. GDB takes any outputthat isn't a debug command packet and displays it in the command window.Support for the exception handler varies between processors, but theminimum supported functions are those needed by GDB. These are functionsto support the reading and writing of registers, the reading and writingof memory, start execution at an address, single step, and last signal.Sometimes other functions for adjusting the baud rate, or resetting thehardware are implemented. Once GDB gets the command packet from the breakpoint, it will read a fewregisters and memory locations an then wait for the user. When the usertypes @code{run} or @code{continue} a @code{continue} command is issuedto the backend, and control returns from the breakpoint routine to theapplication.@node ROM monitors, Other remote protocols, Exception handler, GDB@section Using a ROM monitor as a backendGDB also can mimic a human user and use a ROM monitors normal debugcommands as a backend. This consists mostly of sending and parsing@code{ASCII} strings. All the ROM monitor interfaces share a common setof routines in @code{gdb/monitor.c}. This supports adding new ROMmonitor interfaces by filling in a structure with the common commandsGDB needs. GDb already supports several command ROM monitors, includingMotorola's @code{Bug} monitor for their VME boards, and the Rom68kmonitor by Integrated Systems, Inc. for various m68k based boards. GDBalso supports the custom ROM monitors on the WinBond and Oki PA basedtargets. There is builtin support for loading files to ROM monitorsspecifically. GDB can convert a binary into an srecord and then load itas an ascii file, or using @code{xmodem}.@c FIXME: do I need trademark somethings here ? Is Integrated the right@c company? @node Other remote protocols, ,ROM monitors, GDB @section Adding support for new protocols@c FIXME: write something here @node Binutils, Code Listings, GDB, Top@node Code Listings, idp.ld, Binutils, Top@appendix Code Listings@menu* idp.ld:: A m68k linker script.* crt0.S:: Crt0.S for an m68k.* glue.c:: C based support for for Stdio functions.* mvme.S:: Rom monitor based I/O support in assembler.* io.c:: C based for memory mapped I/O.* leds.c:: C based LED routines.@end menu@node idp.ld, crt0.S, Code Listings, Code Listings@section Linker script for the IDP boardThis is the linker script script that is used on the Motorola IDP board.@exampleSTARTUP(crt0.o)OUTPUT_ARCH(m68k)INPUT(idp.o)SEARCH_DIR(.)__DYNAMIC = 0;/* * Setup the memory map of the MC68ec0x0 Board (IDP) * stack grows up towards high memory. This works for * both the rom68k and the mon68k monitors. */MEMORY@{ ram : ORIGIN = 0x10000, LENGTH = 2M@}/* * stick everything in ram (of course) */SECTIONS@{ .text : @{ CREATE_OBJECT_SYMBOLS *(.text) etext = .; __CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .; __DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .; *(.lit) *(.shdata) @} > ram .shbss SIZEOF(.text) + ADDR(.text) : @{ *(.shbss) @} .talias : @{ @} > ram .data : @{ *(.data) CONSTRUCTORS _edata = .; @} > ram .bss SIZEOF(.data) + ADDR(.data) : @{ __bss_start = ALIGN(0x8); *(.bss) *(COMMON) end = ALIGN(0x8); _end = ALIGN(0x8); __end = ALIGN(0x8); @} .mstack : @{ @} > ram .rstack : @{ @} > ram .stab . (NOLOAD) : @{ [ .stab ] @} .stabstr . (NOLOAD) : @{ [ .stabstr ] @}@}@end example@node crt0.S, glue.c, idp.ld, Code Listings@section crt0.S - The startup file@example/* * crt0.S -- startup file for m68k-coff * */ .title "crt0.S for m68k-coff"/* These are predefined by new versions of GNU cpp. */#ifndef __USER_LABEL_PREFIX__#define __USER_LABEL_PREFIX__ _#endif#ifndef __REGISTER_PREFIX__#define __REGISTER_PREFIX__#endif/* ANSI concatenation macros. */#define CONCAT1(a, b) CONCAT2(a, b)#define CONCAT2(a, b) a ## b/* Use the right prefix for global labels. */#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)/* Use the right prefix for registers. */#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)#define d0 REG (d0)#define d1 REG (d1)#define d2 REG (d2)#define d3 REG (d3)#define d4 REG (d4)#define d5 REG (d5)#define d6 REG (d6)#define d7 REG (d7)#define a0 REG (a0)#define a1 REG (a1)#define a2 REG (a2)#define a3 REG (a3)#define a4 REG (a4)#define a5 REG (a5)#define a6 REG (a6)#define fp REG (fp)#define sp REG (sp)/* * Set up some room for a stack. We just grab a chunk of memory. */ .set stack_size, 0x2000 .comm SYM (stack), stack_size/* * Define an empty environment. */ .data .align 2SYM (environ): .long 0 .align 2 .text .global SYM (stack) .global SYM (main) .global SYM (exit)/* * This really should be __bss_start, not SYM (__bss_start). */ .global __bss_start/* * start -- set things up so the application will run. */SYM (start): link a6, #-8 moveal #SYM (stack) + stack_size, sp/* * zerobss -- zero out the bss section */ moveal #__bss_start, a0 moveal #SYM (end), a11: movel #0, (a0) leal 4(a0), a0 cmpal a0, a1 bne 1b/* * Call the main routine from the application to get it going. * main (argc, argv, environ) * We pass argv as a pointer to NULL. */ pea 0 pea SYM (environ) pea sp@@(4) pea 0 jsr SYM (main) movel d0, sp@@-/* * _exit -- Exit from the application. Normally we cause a user trap * to return to the ROM monitor for another run. */SYM (exit): trap #0@end example@node glue.c, mvme.S, crt0.S, Code Listings@section C based "glue" code.@example/* * glue.c -- all the code to make GCC and the libraries run on * a bare target board. These should work with any * target if inbyte() and outbyte() exist. */#include <sys/types.h>#include <sys/stat.h>#include <errno.h>#ifndef NULL#define NULL 0#endif/* FIXME: this is a hack till libc builds */__main()@{ return;@}#undef errnoint errno;extern caddr_t _end; /* _end is set in the linker command file */extern int outbyte();extern unsigned char inbyte();extern int havebyte();/* just in case, most boards have at least some memory */#ifndef RAMSIZE# define RAMSIZE (caddr_t)0x100000#endif/* * read -- read bytes from the serial port. Ignore fd, since * we only have stdin. */intread(fd, buf, nbytes) int fd; char *buf; int nbytes;@{ int i = 0; for (i = 0; i < nbytes; i++) @{ *(buf + i) = inbyte(); if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) @{ (*(buf + i)) = 0; break; @} @} return (i);@}/* * write -- write bytes to the serial port. Ignore fd, since * stdout and stderr are the same. Since we have no filesystem, * open will only return an error. */intwrite(fd, buf, nbytes) int fd; char *buf; int nbytes;@{ int i; for (i = 0; i < nbytes; i++) @{ if (*(buf + i) == '\n') @{ outbyte ('\r'); @} outbyte (*(buf + i)); @} return (nbytes);@}/* * open -- open a file descriptor. We don't have a filesystem, so * we return an error. */intopen(buf, flags, mode) char *buf; int flags; int mode;@{ errno = EIO; return (-1);@}/* * close -- close a file descriptor. We don't need * to do anything, but pretend we did. */intclose(fd) int fd;@{ return (0);@}/* * sbrk -- changes heap size size. Get nbytes more * RAM. We just increment a pointer in what's * left of memory on the board. */caddr_tsbrk(nbytes) int nbytes;@{ static caddr_t heap_ptr = NULL; caddr_t base; if (heap_ptr == NULL) @{ heap_ptr = (caddr_t)&_end; @} if ((RAMSIZE - heap_ptr) >= 0) @{ base = heap_ptr; heap_ptr += nbytes; return (base); @} else @{ errno = ENOMEM; return ((caddr_t)-1); @}@}/* * isatty -- returns 1 if connected to a terminal device, * returns 0 if not. Since we're hooked up to a * serial port, we'll say yes and return a 1. */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -