OSDN Git Service

Add support for GDB monitor-style I/O.
authorjimb <jimb>
Mon, 10 Sep 2001 23:47:40 +0000 (23:47 +0000)
committerjimb <jimb>
Mon, 10 Sep 2001 23:47:40 +0000 (23:47 +0000)
* m68k/idp-outbyte.c (raw_outbyte): Renamed from outbyte; made
static.
(outbyte): Call raw_outbyte; if GDB_MONITOR_OUTPUT is #defined,
precede the byte with a ^O character.
* m68k/idpgdb.ld: New linker script.
* m68k/Makefile.in (IDPGDB_LDFLAGS, IDPGDB_BSP, IDPGDB_OBJS): New
variables.
(all): Add ${IDPGDB_BSP} to the list of things to build.
(${IDPGDB_BSP}, idp-gdb-outbyte.o, idpgdb-test.x,
idpgdb-test.srec, idpgdb-test.dis, idpgdb-test): New rules.
(install): Install the IDPGDB stuff, too.

libgloss/ChangeLog
libgloss/m68k/Makefile.in
libgloss/m68k/idp-outbyte.c
libgloss/m68k/idpgdb.ld [new file with mode: 0644]

index d7ace73..44790b2 100644 (file)
@@ -1,3 +1,18 @@
+2001-09-10  Jim Blandy  <jimb@redhat.com>
+
+       Add support for GDB monitor-style I/O.
+       * m68k/idp-outbyte.c (raw_outbyte): Renamed from outbyte; made
+       static.
+       (outbyte): Call raw_outbyte; if GDB_MONITOR_OUTPUT is #defined,
+       precede the byte with a ^O character.
+       * m68k/idpgdb.ld: New linker script.
+       * m68k/Makefile.in (IDPGDB_LDFLAGS, IDPGDB_BSP, IDPGDB_OBJS): New
+       variables.
+       (all): Add ${IDPGDB_BSP} to the list of things to build.
+       (${IDPGDB_BSP}, idp-gdb-outbyte.o, idpgdb-test.x,
+       idpgdb-test.srec, idpgdb-test.dis, idpgdb-test): New rules.
+       (install): Install the IDPGDB stuff, too.
+
 2001-03-30  Richard Henderson  <rth@redhat.com>
            Eric Christopher  <echristo@redhat.com>
 
index 626f029..5705b11 100644 (file)
@@ -110,6 +110,13 @@ IDP_BSP=   libidp.a
 IDP_OBJS=      leds.o idp-inbyte.o idp-outbyte.o mc68ec.o
 
 #
+# here's all the IDP GDB target stuff
+#
+IDPGDB_LDFLAGS=        -L${srcdir} -Tidpgdb.ld
+IDPGDB_BSP=    libidpgdb.a
+IDPGDB_OBJS=   leds.o idp-inbyte.o idp-gdb-outbyte.o mc68ec.o
+
+#
 # here's all the DBUG target stuff
 #
 DBUG_BSP=      libdbug.a
@@ -122,7 +129,7 @@ DBUG_OBJS=  dbug-exit.o dbug-inbyte.o dbug-outbyte.o
 # build a test program for each target board. Just trying to get
 # it to link is a good test, so we ignore all the errors for now.
 #
-all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP}
+all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${IDPGDB_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP}
 
 #
 # here's where we build the board support packages for each target
@@ -139,6 +146,10 @@ ${IDP_BSP}: $(OBJS) ${IDP_OBJS}
        ${AR} ${ARFLAGS} $@ $(OBJS) ${IDP_OBJS}
        ${RANLIB} $@
 
+${IDPGDB_BSP}: $(OBJS) ${IDPGDB_OBJS}
+       ${AR} ${ARFLAGS} $@ $(OBJS) ${IDPGDB_OBJS}
+       ${RANLIB} $@
+
 ${DBUG_BSP}: $(OBJS) ${DBUG_OBJS}
        ${AR} ${ARFLAGS} $@ $(OBJS) ${DBUG_OBJS}
        ${RANLIB} $@
@@ -160,6 +171,9 @@ idp-inbyte.o: ${srcdir}/idp-inbyte.c
 idp-outbyte.o: ${srcdir}/idp-outbyte.c
        $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
 
+idp-gdb-outbyte.o: ${srcdir}/idp-outbyte.c
+       $(CC) $(CFLAGS_FOR_TARGET) -DGDB_MONITOR_OUTPUT $(INCLUDES) -c $< -o $@
+
 mc68ec.o: ${srcdir}/mc68ec.c
        $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
 
@@ -189,6 +203,16 @@ idp-test.dis: idp-test.x
        $(OBJDUMP) -d idp-test.x > $@
 idp-test: idp-test.srec idp-test.dis
 
+idpgdb-test.x: test.o ${CRT0} Makefile ${IDPGDB_BSP}
+       ${CC} $(CFLAGS_FOR_TARGET) -L${srcdir} -L${objdir} \
+       test.o -o $@ $(LDFLAGS_FOR_TARGET) -N -Wl,-Tidpgdb.ld
+idpgdb-test.srec: idpgdb-test.x
+       $(OBJCOPY) -O srec idpgdb-test.x $@
+idpgdb-test.dis: idpgdb-test.x
+       @rm -fr idpgdb-test.dis
+       $(OBJDUMP) -d idpgdb-test.x > $@
+idpgdb-test: idpgdb-test.srec idpgdb-test.dis
+
 mvme135-test.x: test.o ${CRT0} ${srcdir}/mvme135.ld Makefile  ${MVME135_BSP}
        ${CC} -L${srcdir} -L${objdir} test.o -o $@ $(LDFLAGS_FOR_TARGET) \
        -N -Wl,-Tmvme135.ld -nostdlib
@@ -245,6 +269,9 @@ install:
        # install IDP stuff
        $(INSTALL_PROGRAM) $(IDP_BSP) $(tooldir)/lib${MULTISUBDIR}/$(IDP_BSP)
        $(INSTALL_DATA) ${srcdir}/idp.ld $(tooldir)/lib${MULTISUBDIR}/idp.ld
+       # install IDPGDB stuff
+       $(INSTALL_PROGRAM) $(IDPGDB_BSP) $(tooldir)/lib${MULTISUBDIR}/$(IDPGDB_BSP)
+       $(INSTALL_DATA) ${srcdir}/idpgdb.ld $(tooldir)/lib${MULTISUBDIR}/idpgdb.ld
        # install MVME135 stuff
        $(INSTALL_PROGRAM) $(MVME135_BSP) $(tooldir)/lib${MULTISUBDIR}/$(MVME135_BSP)
        $(INSTALL_DATA) ${srcdir}/mvme135.ld $(tooldir)/lib${MULTISUBDIR}/mvme135.ld
index d09ae89..a95dc0c 100644 (file)
 #define WRITEREG(x, y) (*((char *) DUART_ADDR + (x * 4) + 3) = y)
 
 /*
- * outbyte -- send a byte to the DUART buffer. This only sends
+ * raw_outbyte -- send a byte to the DUART buffer. This only sends
  *           to channel A.
  */
-void
-_DEFUN (outbyte, (byte),
+static void
+_DEFUN (raw_outbyte, (byte),
        char byte)
 {
+  /* First, wait for the UART to finish clocking out the last
+     character we sent, if any.  Then, give it the next character to
+     work on.  By waiting first, then handing off a new character, we
+     allow the UART to work while the processor (perhaps) does other
+     things; if we waited after sending each character, there'd be no
+     opportunity for parallelism.  */
   while ((READREG (DUART_SRA) & 0x04) == 0x00)
     ;
 
   WRITEREG (DUART_TBA, byte);          /* write the byte */
 }
+
+
+/*
+ * outbyte -- send BYTE out the DUART's channel A, for display to
+ *      the user.
+ *
+ *      Normally, this is identical to raw_outbyte, but if
+ *      GDB_MONITOR_OUTPUT is #defined, we prefix each byte we send
+ *      with a ^O character (ASCII 15).  This is a signal to GDB's
+ *      `rom68k' target to pass the character directly on to the user;
+ *      it allows programs to do console output under GDB.
+ *
+ *      We compile this file twice: once with GDB_MONITOR_OUTPUT
+ *      #defined, and once without.  The former .o file we put in
+ *      libidpgdb.a, which is included in the link by idpgdb.ld; the
+ *      latter we put in libidp.a, which is selected by idp.ld.
+ */
+void
+_DEFUN (outbyte, (byte),
+        char byte)
+{
+#ifdef GDB_MONITOR_OUTPUT
+  raw_outbyte (0x0f);
+#endif
+  raw_outbyte (byte);
+}
diff --git a/libgloss/m68k/idpgdb.ld b/libgloss/m68k/idpgdb.ld
new file mode 100644 (file)
index 0000000..9d24e28
--- /dev/null
@@ -0,0 +1,146 @@
+STARTUP(crt0.o)
+OUTPUT_ARCH(m68k)
+/* Uncomment this if you want srecords. This is needed for a.out
+ * if you plan to use GDB.
+OUTPUT_FORMAT(srec)
+ */
+
+SEARCH_DIR(.)
+GROUP(-lidpgdb -lc -lgcc)
+__DYNAMIC  =  0;
+
+/*
+ * Setup the memory map of the MC68ec0x0 Board (IDP)
+ * stack grows down from high memory. This works for
+ * both the rom68k and the mon68k monitors.
+ *
+ * The memory map look like this:
+ * +--------------------+ <- low memory
+ * | .text              |
+ * |        _etext      |
+ * |        ctor list   | the ctor and dtor lists are for
+ * |        dtor list   | C++ support
+ * +--------------------+
+ * | .data              | initialized data goes here
+ * |        _edata      |
+ * +--------------------+
+ * | .bss               |
+ * |        __bss_start | start of bss, cleared by crt0
+ * |        _end        | start of heap, used by sbrk()
+ * +--------------------+
+ * .                    .
+ * .                    .
+ * .                    .
+ * |        __stack     | top of stack
+ * +--------------------+
+ */
+
+/*
+ * When the IDP is not remapped (see rom68k's MP command in the
+ * "M68EC0x0IDP Users Manual", the first 64K bytes are reserved;
+ * Otherwise the first 256K bytes are reserved.
+ *
+ * The following memory map describes a unmapped IDP w/2MB RAM.
+ */
+
+MEMORY
+{
+  ram (rwx) : ORIGIN = 0x00010000, LENGTH = 2M-64K
+  rom0     : ORIGIN = 0x00800000, LENGTH = 1M
+  rom1     : ORIGIN = 0x00900000, LENGTH = 1M
+}
+
+/*
+ * allocate the stack to be at the top of memory, since the stack
+ * grows down
+ */
+
+PROVIDE (__stack = 2M - 8);
+
+/*
+ * Initalize some symbols to be zero so we can reference them in the
+ * crt0 without core dumping. These functions are all optional, but
+ * we do this so we can have our crt0 always use them if they exist. 
+ * This is so BSPs work better when using the crt0 installed with gcc.
+ * We have to initalize them twice, so we cover a.out (which prepends
+ * an underscore) and coff object file formats.
+ */
+PROVIDE (hardware_init_hook = 0);
+PROVIDE (_hardware_init_hook = 0);
+PROVIDE (software_init_hook = 0);
+PROVIDE (_software_init_hook = 0);
+/*
+ * stick everything in ram (of course)
+ */
+SECTIONS
+{
+  .text :
+  {
+    CREATE_OBJECT_SYMBOLS
+    *(.text)
+
+    . = ALIGN(0x4);
+    /* These are for running static constructors and destructors under ELF.  */
+    KEEP (*crtbegin.o(.ctors))
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+    KEEP (*crtbegin.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+
+    *(.rodata)
+
+    . = ALIGN(0x4);
+    *(.gcc_except_table) 
+
+    . = ALIGN(0x4);
+    *(.eh_frame)
+
+    . = ALIGN(0x4);
+    __INIT_SECTION__ = . ;
+    LONG (0x4e560000)  /* linkw %fp,#0 */
+    *(.init)
+    SHORT (0x4e5e)     /* unlk %fp */
+    SHORT (0x4e75)     /* rts */
+
+    . = ALIGN(0x4);
+    __FINI_SECTION__ = . ;
+    LONG (0x4e560000)  /* linkw %fp,#0 */
+    *(.fini)
+    SHORT (0x4e5e)     /* unlk %fp */
+    SHORT (0x4e75)     /* rts */
+
+    _etext = .;
+    *(.lit)
+  } > ram
+
+  .data :
+  {
+    *(.shdata)
+    *(.data)
+    _edata = .;
+  } > ram
+
+  .bss :
+  {
+    . = ALIGN(0x4);
+    __bss_start = . ;
+    *(.shbss)
+    *(.bss)
+    *(COMMON)
+    _end =  ALIGN (0x8);
+    __end = _end;
+  } > ram
+
+  .stab 0 (NOLOAD) :
+  {
+    *(.stab)
+  }
+
+  .stabstr 0 (NOLOAD) :
+  {
+    *(.stabstr)
+  }
+}