<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 20, 2016 at 2:20 AM, Chris Johns <span dir="ltr"><<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Move the gdb stub from the i386 UART code to use the libchip drivers.<br>
<br>
Use any ports discovered during the probes.<br>
<br>
Add gdb control to the boot command line.<br>
<br>
Change the device naming to the full device path, not a partial path.<br>
For example /dev/com1.<br>
---<br>
c/src/lib/libbsp/i386/pc386/Makefile.am | 5 +-<br>
c/src/lib/libbsp/i386/pc386/README | 23 ++-<br>
c/src/lib/libbsp/i386/pc386/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 6 +<br>
c/src/lib/libbsp/i386/pc386/console/conscfg.c | 88 ++++++----<br>
.../libbsp/i386/pc386/console/console_control.c | 39 +++--<br>
.../lib/libbsp/i386/pc386/console/console_select.c | 106 +++--------<br>
c/src/lib/libbsp/i386/pc386/console/gdb_select.c | 169 ++++++++++++++++++<br>
c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c | 135 +++++++-------<br>
c/src/lib/libbsp/i386/pc386/include/bsp.h | 3 +-<br>
c/src/lib/libbsp/i386/pc386/include/bspimpl.h | 12 +-<br>
c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 29 ++-<br>
c/src/lib/libbsp/i386/pc386/startup/ldsegs.S | 2 +-<br>
c/src/lib/libbsp/i386/shared/comm/GDB.HOWTO | 134 +++++++-------<br>
c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c | 195 ++++++++++++++-------<br>
c/src/lib/libbsp/i386/shared/comm/i386-stub.c | 179 +++++++++++--------<br>
c/src/lib/libbsp/shared/console.c | 43 ++++-<br>
c/src/lib/libbsp/shared/console_private.h | 13 ++<br>
17 files changed, 754 insertions(+), 427 deletions(-)<br>
create mode 100644 c/src/lib/libbsp/i386/pc386/console/gdb_select.c<br>
<br>
diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am b/c/src/lib/libbsp/i386/pc386/Makefile.am<br>
index d9af7dd..22d4bf1 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am<br>
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am<br>
@@ -132,6 +132,7 @@ libbsp_a_SOURCES += console/printk_support.c<br>
libbsp_a_SOURCES += console/exar17d15x.c<br>
libbsp_a_SOURCES += console/rtd316.c<br>
libbsp_a_SOURCES += console/uart_bus_pci.c<br>
+libbsp_a_SOURCES += console/gdb_select.c<br>
<br>
# gdb<br>
libbsp_a_SOURCES += ../../i386/shared/comm/i386-stub.c<br>
@@ -181,8 +182,8 @@ libbsp_a_SOURCES += ide/idecfg.c<br>
endif<br>
<br>
if HAS_SMP<br>
-libbsp_a_SOURCES += ../../i386/shared/smp/getcpuid.c<br>
-libbsp_a_SOURCES += ../../i386/shared/smp/smp-imps.c<br>
+libbsp_a_SOURCES += ../../i386/shared/smp/getcpuid.c<br>
+libbsp_a_SOURCES += ../../i386/shared/smp/smp-imps.c<br>
<br>
project_lib_DATA += appstart.$(OBJEXT)<br>
appcpustart.$(OBJEXT): start/start16.S<br>
diff --git a/c/src/lib/libbsp/i386/pc386/README b/c/src/lib/libbsp/i386/pc386/README<br>
index bfebf19..4ed8829 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/README<br>
+++ b/c/src/lib/libbsp/i386/pc386/README<br>
@@ -7,7 +7,7 @@ a Pentium or above, the TSC register is used for timing calibration<br>
purposes rather than relying entirely on the i8254.<br>
<br>
Partial support is implemented for more modern PCs which do not have<br>
-a complete complement of legacy peripherals.<br>
+a complete complement of legacy peripherals.<br>
<br>
Console/Printk Device Selection<br>
===============================<br>
@@ -19,9 +19,9 @@ in the following order of priority:<br>
+ VGA and keyboard<br>
+ COM1 through COM4aaa<br>
<br></blockquote><div><br></div><div>What is the aaa?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-+ Any COM devices on the PCI bus<br>
++ Any COM devices on the PCI bus including IO and memory mapped.<br>
<br>
-Beyond the dynamic probing for device presence, a combination of<br>
+Beyond the dynamic probing for device presence, a combination of<br>
configure and boot time options are available. By default, all devices<br>
are enabled. The configure time options are:<br>
<br>
@@ -45,7 +45,7 @@ specify the console and kernel debug IO device. The --printk<br>
is then interpreted to specify the debug kernel IO device.<br>
For example,<br>
<br>
---console=com1 --printk=vgacons<br>
+--console=/dev/com1 --printk=/dev/vgacons<br>
<br>
specifies that com1 is to be used for stdin, stdout, and stderr<br>
while the VGA console is to be used for kernel debug IO.<br>
@@ -55,8 +55,21 @@ the RTEMS device /dev/com1.<br>
The device name may be followed by a baud rate. The following<br>
example illustrates this:<br>
<br>
---console=com1,19200 --printk=vgacons<br>
+--console=/dev/com1,19200 --printk=/dev/vgacons<br>
<br>
If the specified device is not present, then a suitable fallback<br>
device is selected. The fallback order is based upon the probe<br>
order listed earlier.<br>
+<br>
+PCI UART devices are /dev/pcicom1 etc as they are probed and found.<br>
+<br>
+GDB<br>
+===<br>
+<br>
+GDB can be support using:<br>
+<br>
+ --gdb=/dev/com1,115200 : where the device and baudrate are selectable.<br>
+ --gdb-break : halt at a break point in the BSP and wait for GDB.<br>
+ --gdb-remote-debug : Output the GDB remote protocol data to printk<br>
+<br>
+The GDB stub details and in shared/comm/GDB.HOWTO.<br>
diff --git a/c/src/lib/libbsp/i386/pc386/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/c/src/lib/libbsp/i386/pc386/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index 17b7d02..d62a9b3 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/c/src/lib/libbsp/i386/pc386/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -142,6 +142,12 @@ RTEMS_BSPOPTS_HELP([BSP_HAS_SMP],<br>
[Always defined when on a pc386 to enable the pc386 support for<br>
determining the CPU core number in an SMP configuration.])<br>
<br>
+RTEMS_BSPOPTS_SET([BSP_GDB_STUB],[*],[1])<br>
+RTEMS_BSPOPTS_HELP([BSP_GDB_STUB],<br>
+[Defined by default. Enables use of the GDB stub for debugging via a<br>
+ serial port.])<br>
+AM_CONDITIONAL(BSP_GDB_STUB, test "$BSP_GDB_STUB" = "1")<br>
+<br>
## if this is an i386, does gas have good code16 support?<br>
RTEMS_I386_GAS_CODE16<br>
AM_CONDITIONAL(RTEMS_GAS_CODE16,[test "$RTEMS_GAS_CODE16" = "yes"])<br>
diff --git a/c/src/lib/libbsp/i386/pc386/console/conscfg.c b/c/src/lib/libbsp/i386/pc386/console/conscfg.c<br>
index 5b7ebc5..82d3cf9 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/console/conscfg.c<br>
+++ b/c/src/lib/libbsp/i386/pc386/console/conscfg.c<br>
@@ -16,13 +16,14 @@<br>
*/<br>
<br>
#include <bsp.h><br>
+#include <bsp/bspimpl.h><br>
#include <libchip/serial.h><br>
#include <libchip/ns16550.h><br>
#if BSP_ENABLE_VGA<br>
#include "vgacons.h"<br>
#endif<br>
#include <bsp/irq.h><br>
-#include <rtems/pci.h><br>
+#include "../../../shared/console_private.h"<br>
<br>
#if BSP_ENABLE_VGA<br>
#define VGA_CONSOLE_FUNCTIONS &vgacons_fns<br>
@@ -43,7 +44,7 @@<br>
#define COM3_BASE_IO 0x2F8<br>
#define COM4_BASE_IO 0x2E8<br>
<br>
- #define CLOCK_RATE (115200 * 16)<br>
+ #define CLOCK_RATE (115200 * 16)<br>
<br>
static uint8_t com_get_register(uint32_t addr, uint8_t i)<br>
{<br>
@@ -57,21 +58,26 @@<br>
{<br>
outport_byte( (addr + i), val );<br>
}<br>
-<br>
- extern bool pc386_com1_com4_enabled(int);<br>
#endif<br>
<br>
#if (BSP_IS_EDISON == 1 )<br>
extern const console_fns edison_fns;<br>
#endif<br>
<br>
-console_tbl Console_Configuration_Ports[] = {<br>
-#if (BSP_IS_EDISON == 1)<br>
+/*<br>
+ * Default to the PC VGA console if present and configured.<br>
+ */<br>
+console_tbl Console_Configuration_Ports[] = {<br>
+#if BSP_ENABLE_VGA<br>
+ /*<br>
+ * If present the VGA console must always be minor 0.<br>
+ * See console_control.<br>
+ */<br>
{<br>
- "/dev/com1", /* sDeviceName */<br>
- -1, /* deviceType */<br>
- &edison_fns, /* pDeviceFns */<br>
- NULL, /* deviceProbe */<br>
+ "/dev/vgacons", /* sDeviceName */<br>
+ VGA_CONSOLE, /* deviceType */<br>
+ VGA_CONSOLE_FUNCTIONS, /* pDeviceFns */<br>
+ vgacons_probe, /* deviceProbe */<br>
NULL, /* pDeviceFlow */<br>
16, /* ulMargin */<br>
8, /* ulHysteresis */<br>
@@ -83,16 +89,22 @@ console_tbl Console_Configuration_Ports[] = {<br>
NULL, /* setRegister */<br>
NULL,/* unused */ /* getData */<br>
NULL,/* unused */ /* setData */<br>
- 0X0, /* ulClock */<br>
- 0x0 /* ulIntVector -- base for port */<br>
+ 0x0, /* ulClock */<br>
+ 0x0 /* ulIntVector -- base for port */<br>
},<br>
#endif<br>
-#if BSP_ENABLE_VGA<br>
+};<br>
+<br>
+unsigned long Console_Configuration_Count =<br>
+ (sizeof(Console_Configuration_Ports)/sizeof(console_tbl));<br>
+<br>
+static console_tbl Legacy_Ports[] = {<br>
+#if (BSP_IS_EDISON == 1)<br>
{<br>
- "/dev/vgacons", /* sDeviceName */<br>
- VGA_CONSOLE, /* deviceType */<br>
- VGA_CONSOLE_FUNCTIONS, /* pDeviceFns */<br>
- vgacons_probe, /* deviceProbe */<br>
+ "/dev/com1", /* sDeviceName */<br>
+ -1, /* deviceType */<br>
+ &edison_fns, /* pDeviceFns */<br>
+ NULL, /* deviceProbe */<br>
NULL, /* pDeviceFlow */<br>
16, /* ulMargin */<br>
8, /* ulHysteresis */<br>
@@ -104,8 +116,8 @@ console_tbl Console_Configuration_Ports[] = {<br>
NULL, /* setRegister */<br>
NULL,/* unused */ /* getData */<br>
NULL,/* unused */ /* setData */<br>
- 0X0, /* ulClock */<br>
- 0x0 /* ulIntVector -- base for port */<br>
+ 0x0, /* ulClock */<br>
+ 0x0 /* ulIntVector -- base for port */<br>
},<br>
#endif<br>
#if BSP_ENABLE_COM1_COM4<br>
@@ -113,7 +125,7 @@ console_tbl Console_Configuration_Ports[] = {<br>
"/dev/com1", /* sDeviceName */<br>
SERIAL_NS16550, /* deviceType */<br>
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */<br>
- pc386_com1_com4_enabled, /* deviceProbe */<br>
+ NULL, /* deviceProbe */<br>
NULL, /* pDeviceFlow */<br>
16, /* ulMargin */<br>
8, /* ulHysteresis */<br>
@@ -132,7 +144,7 @@ console_tbl Console_Configuration_Ports[] = {<br>
"/dev/com2", /* sDeviceName */<br>
SERIAL_NS16550, /* deviceType */<br>
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */<br>
- pc386_com1_com4_enabled, /* deviceProbe */<br>
+ NULL, /* deviceProbe */<br>
NULL, /* pDeviceFlow */<br>
16, /* ulMargin */<br>
8, /* ulHysteresis */<br>
@@ -147,12 +159,11 @@ console_tbl Console_Configuration_Ports[] = {<br>
CLOCK_RATE, /* ulClock */<br>
BSP_UART_COM2_IRQ /* ulIntVector -- base for port */<br>
},<br>
-<br>
{<br>
"/dev/com3", /* sDeviceName */<br>
SERIAL_NS16550, /* deviceType */<br>
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */<br>
- pc386_com1_com4_enabled, /* deviceProbe */<br>
+ NULL, /* deviceProbe */<br>
NULL, /* pDeviceFlow */<br>
16, /* ulMargin */<br>
8, /* ulHysteresis */<br>
@@ -167,12 +178,11 @@ console_tbl Console_Configuration_Ports[] = {<br>
CLOCK_RATE, /* ulClock */<br>
BSP_UART_COM3_IRQ /* ulIntVector -- base for port */<br>
},<br>
-<br>
{<br>
"/dev/com4", /* sDeviceName */<br>
SERIAL_NS16550, /* deviceType */<br>
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */<br>
- pc386_com1_com4_enabled, /* deviceProbe */<br>
+ NULL, /* deviceProbe */<br>
NULL, /* pDeviceFlow */<br>
16, /* ulMargin */<br>
8, /* ulHysteresis */<br>
@@ -188,12 +198,26 @@ console_tbl Console_Configuration_Ports[] = {<br>
BSP_UART_COM4_IRQ /* ulIntVector -- base for port */<br>
},<br>
#endif<br>
-<br>
};<br>
<br>
-/*<br>
- * Define a variable that contains the number of statically configured<br>
- * console devices.<br>
- */<br>
-unsigned long Console_Configuration_Count = \<br>
- (sizeof(Console_Configuration_Ports)/sizeof(console_tbl));<br>
+#define Legacy_Port_Count \<br>
+ (sizeof(Legacy_Ports)/sizeof(console_tbl))<br>
+<br>
+void legacy_uart_probe(void)<br>
+{<br>
+#if BSP_ENABLE_COM1_COM4<br>
+ const char *opt;<br>
+ /*<br>
+ * Check the command line to see if com1-com4 are disabled.<br>
+ */<br>
+ opt = bsp_cmdline_arg("--disable-com1-com4");<br>
+ if ( opt ) {<br>
+ printk( "COM1-COM4: disabled\n" );<br>
+ } else {<br>
+ if (Legacy_Port_Count) {<br>
+ printk("Legacy UART Ports: COM1-COM4\n");<br>
+ console_register_devices( Legacy_Ports, Legacy_Port_Count );<br>
+ }<br>
+ }<br>
+#endif<br>
+}<br>
diff --git a/c/src/lib/libbsp/i386/pc386/console/console_control.c b/c/src/lib/libbsp/i386/pc386/console/console_control.c<br>
index a0b9220..3a454d9 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/console/console_control.c<br>
+++ b/c/src/lib/libbsp/i386/pc386/console/console_control.c<br>
@@ -1,5 +1,5 @@<br>
/*<br>
- * This file is an extension of the generic console driver<br>
+ * This file is an extension of the generic console driver<br>
* shell used by all console drivers using libchip, it contains<br>
* the console_control routine, This bsp needs its own version<br>
* of this method to handle the keyboard and mouse as a single<br>
@@ -44,27 +44,28 @@ rtems_device_driver console_control(<br>
)<br>
{<br>
#if BSP_ENABLE_VGA<br>
- rtems_libio_ioctl_args_t *args = arg;<br>
+ if (minor == 0) {<br>
+ rtems_libio_ioctl_args_t *args = arg;<br>
<br>
- switch (args->command) {<br>
- default:<br>
- if( vt_ioctl( args->command, (unsigned long)args->buffer ) != 0 )<br>
- return rtems_termios_ioctl (arg);<br>
- break;<br>
+ switch (args->command) {<br>
+ default:<br>
+ if( vt_ioctl( args->command, (unsigned long)args->buffer ) != 0 )<br>
+ return rtems_termios_ioctl (arg);<br>
+ break;<br>
<br>
- case MW_UID_REGISTER_DEVICE:<br>
- printk( "SerialMouse: reg=%s\n", args->buffer );<br>
- register_kbd_msg_queue( args->buffer, 0 );<br>
- break;<br>
+ case MW_UID_REGISTER_DEVICE:<br>
+ printk( "SerialMouse: reg=%s\n", args->buffer );<br>
+ register_kbd_msg_queue( args->buffer, 0 );<br>
+ break;<br>
<br>
- case MW_UID_UNREGISTER_DEVICE:<br>
- unregister_kbd_msg_queue( 0 );<br>
- break;<br>
+ case MW_UID_UNREGISTER_DEVICE:<br>
+ unregister_kbd_msg_queue( 0 );<br>
+ break;<br>
+ }<br>
+<br>
+ args->ioctl_return = 0;<br>
+ return RTEMS_SUCCESSFUL;<br>
}<br>
-<br>
- args->ioctl_return = 0;<br>
- return RTEMS_SUCCESSFUL;<br>
-#else<br>
- return rtems_termios_ioctl (arg);<br>
#endif<br>
+ return rtems_termios_ioctl (arg);<br>
}<br>
diff --git a/c/src/lib/libbsp/i386/pc386/console/console_select.c b/c/src/lib/libbsp/i386/pc386/console/console_select.c<br>
index 6a91a96..f7e6bbc 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/console/console_select.c<br>
+++ b/c/src/lib/libbsp/i386/pc386/console/console_select.c<br>
@@ -3,7 +3,7 @@<br>
*<br>
* @ingroup Console<br>
*<br>
- * @brief pc397 console select<br>
+ * @brief pc386 console select<br>
*<br>
* This file contains a routine to select the console based upon a number<br>
* of criteria.<br>
@@ -33,24 +33,6 @@<br>
#include <crt.h><br>
#endif<br>
<br>
-#include <bsp/bspimpl.h><br>
-<br>
-/*<br>
- * Forward prototype<br>
- */<br>
-extern bool pc386_com1_com4_enabled(int);<br>
-<br>
-/*<br>
- * This method is used to determine if COM1-COM4 are enabled based upon<br>
- * boot command line arguments.<br>
- */<br>
-static bool are_com1_com4_enabled;<br>
-<br>
-bool pc386_com1_com4_enabled(int minor)<br>
-{<br>
- return are_com1_com4_enabled;<br>
-}<br>
-<br>
/*<br>
* Method to return true if the device associated with the<br>
* minor number probs available.<br>
@@ -97,48 +79,6 @@ static rtems_device_minor_number bsp_First_Available_Device( void )<br>
rtems_fatal_error_occurred(RTEMS_IO_ERROR);<br>
}<br>
<br>
-static bool bsp_find_console_entry(<br>
- const char *match,<br>
- size_t length,<br>
- rtems_device_minor_number *match_minor<br>
-)<br>
-{<br>
- rtems_device_minor_number minor;<br>
- const char *name;<br>
-<br>
- for (minor=0; minor < Console_Port_Count ; minor++) {<br>
- console_tbl *cptr = Console_Port_Tbl[minor];<br>
-<br>
- /*<br>
- * Console table entries include /dev/ prefix, device names passed<br>
- * in on command line do not.<br>
- */<br>
- name = cptr->sDeviceName + sizeof("/dev");<br>
- if ( !strncmp( name, match, length ) ) {<br>
- *match_minor = minor;<br>
- return true;<br>
- }<br>
- }<br>
-<br>
- return false;<br>
-}<br>
-<br>
-static void parse_com1_com4_enable(void)<br>
-{<br>
- static const char *opt;<br>
-<br>
- /*<br>
- * Check the command line to see if com1-com4 are disabled.<br>
- */<br>
- opt = bsp_cmdline_arg("--disable-com1-com4");<br>
- if ( opt ) {<br>
- printk( "Disable COM1-COM4 per boot argument\n" );<br>
- are_com1_com4_enabled = false;<br>
- } else {<br>
- are_com1_com4_enabled = true;<br>
- }<br>
-}<br>
-<br>
static bool parse_printk_or_console(<br>
const char *param,<br>
rtems_device_minor_number *minor_out<br>
@@ -150,6 +90,7 @@ static bool parse_printk_or_console(<br>
size_t length;<br>
size_t index;<br>
rtems_device_minor_number minor;<br>
+ console_tbl *conscfg;<br>
<br>
/*<br>
* Check the command line for the type of mode the console is.<br>
@@ -198,16 +139,14 @@ static bool parse_printk_or_console(<br>
<br>
length = &opt[index] - option;<br>
<br>
- if ( !bsp_find_console_entry( option, length, &minor ) ) {<br>
+ conscfg = console_find_console_entry( option, length, &minor );<br>
+ if ( conscfg == NULL ) {<br>
return false;<br>
}<br>
<br>
*minor_out = minor;<br>
if (comma) {<br>
- console_tbl *conscfg = &Console_Configuration_Ports[minor];<br>
-<br>
option = comma + 1;<br>
-<br>
if (strncmp (option, "115200", sizeof ("115200") - 1) == 0)<br>
conscfg->pDeviceParams = (void *)115200;<br>
else if (strncmp (option, "57600", sizeof ("57600") - 1) == 0)<br>
@@ -241,39 +180,34 @@ static inline const char *get_name(<br>
*/<br>
void pc386_parse_console_arguments(void)<br>
{<br>
- rtems_device_minor_number minor;<br>
-<br>
- /*<br>
- * The console device driver must have its data structures initialized<br>
- * before we can iterate the table of devices for names.<br>
- */<br>
- console_initialize_data();<br>
-<br>
- /*<br>
- * Determine if COM1-COM4 were disabled.<br>
- */<br>
- parse_com1_com4_enable();<br>
+ rtems_device_minor_number minor;<br>
+ rtems_device_minor_number minor_console = 0;<br>
+ rtems_device_minor_number minor_printk = 0;<br>
<br>
/*<br>
* Assume that if only --console is specified, that printk() should<br>
* follow that selection by default.<br>
*/<br>
if ( parse_printk_or_console( "--console=", &minor ) ) {<br>
- Console_Port_Minor = minor;<br>
- BSPPrintkPort = minor;<br>
+ minor_console = minor;<br>
+ minor_printk = minor;<br>
}<br>
<br>
/*<br>
* But if explicitly specified, attempt to honor it.<br>
*/<br>
if ( parse_printk_or_console( "--printk=", &minor ) ) {<br>
- BSPPrintkPort = minor;<br>
+ minor_printk = minor;<br>
}<br>
<br>
-#if 0<br>
- printk( "Console device: %s\n", get_name(Console_Port_Minor) );<br>
- printk( "printk device: %s\n", get_name(BSPPrintkPort) );<br>
-#endif<br>
+ printk( "Console: %s printk: %s\n",<br>
+ get_name(minor_console),get_name(minor_printk) );<br>
+<br>
+ /*<br>
+ * Any output after this can cause problems until termios is initialised.<br>
+ */<br>
+ Console_Port_Minor = minor_console;<br>
+ BSPPrintkPort = minor_printk;<br>
}<br>
<br>
/*<br>
@@ -283,6 +217,10 @@ void pc386_parse_console_arguments(void)<br>
void bsp_console_select(void)<br>
{<br>
#ifdef RTEMS_RUNTIME_CONSOLE_SELECT<br>
+ /*<br>
+ * WARNING: This code is really needed any more and should be removed.<br>
+ * references to COM1 and COM2 like they are wrong.<br>
+ */<br>
if ( BSP_runtime_console_select )<br>
BSP_runtime_console_select(&BSPPrintkPort, &Console_Port_Minor);<br>
<br>
diff --git a/c/src/lib/libbsp/i386/pc386/console/gdb_select.c b/c/src/lib/libbsp/i386/pc386/console/gdb_select.c<br>
new file mode 100644<br>
index 0000000..8e64658<br>
--- /dev/null<br>
+++ b/c/src/lib/libbsp/i386/pc386/console/gdb_select.c<br>
@@ -0,0 +1,169 @@<br>
+/**<br>
+ * @file<br>
+ *<br>
+ * @ingroup GDB<br>
+ *<br>
+ * @brief pc386 gdb select<br>
+ *<br>
+ * This file contains a routine to enable and select the UART the gdb stub<br>
+ * connects too. Currently limited to COM1 and COM2. See<br>
+ * shared/comm/i386-stub-glue.c file.<br>
+ */<br>
+<br>
+/*<br>
+ * COPYRIGHT (c) 2016.<br>
+ * Chris Johns <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>><br>
+ *<br>
+ * The license and distribution terms for this file may be<br>
+ * found in the file LICENSE in this distribution or at<br>
+ * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
+ */<br>
+<br>
+#include <stdlib.h><br>
+<br>
+#include <bsp.h><br>
+#include <rtems/libio.h><br>
+#include <rtems/console.h><br>
+#include <rtems/termiostypes.h><br>
+#include <libchip/serial.h><br>
+#include <libchip/ns16550.h><br>
+#include <bsp/bspimpl.h><br>
+<br>
+#include "../../../shared/console_private.h"<br>
+<br>
+/*<br>
+ * Used in the stub to print output.<br>
+ */<br>
+int remote_debug;<br>
+/*<br>
+ * Defined in the stub, used here.<br>
+ */<br>
+void set_debug_traps(void);<br>
+<br>
+/*<br>
+ * Added here to get a valid baudrate. Needs to go once we<br>
+ * move to the standard UART driver.<br>
+ */<br>
+int BSPBaseBaud;<br>
+<br>
+static bool gdb_port_probe(int minor)<br>
+{<br>
+ /* Return false as GDB has claimed the port */<br>
+ return false;<br>
+}<br>
+<br>
+void pc386_parse_gdb_arguments(void)<br>
+{<br>
+ static const char *opt;<br>
+<br>
+ /*<br>
+ * Check the command line to see if com1-com4 are disabled.<br>
+ */<br>
+ opt = bsp_cmdline_arg("--gdb=");<br>
+ if ( opt ) {<br>
+ const char *option;<br>
+ const char *comma;<br>
+ size_t length;<br>
+ size_t index;<br>
+ rtems_device_minor_number minor;<br>
+ uint32_t baudrate = 115200;<br>
+ bool halt = false;<br>
+ console_tbl *port;<br>
+<br>
+ /*<br>
+ * Fine the length, there can be more command line visible.<br>
+ */<br>
+ length = 0;<br>
+ while ((opt[length] != ' ') && (opt[length] != '\0')) {<br>
+ ++length;<br>
+ if (length > NAME_MAX) {<br>
+ printk("invalid option (--gdb): too long\n");<br>
+ return;<br>
+ }<br>
+ }<br>
+<br>
+ /*<br>
+ * Only match up to a comma or NULL<br>
+ */<br>
+ index = 0;<br>
+ while ((opt[index] != '=') && (index < length)) {<br>
+ ++index;<br>
+ }<br>
+<br>
+ if (opt[index] != '=') {<br>
+ printk("invalid option (--gdb): no equals\n");<br>
+ return;<br>
+ }<br>
+<br>
+ ++index;<br>
+ option = &opt[index];<br>
+<br>
+ while ((opt[index] != ',') && (index < length)) {<br>
+ ++index;<br>
+ }<br>
+<br>
+ if (opt[index] == ',')<br>
+ comma = &opt[index];<br>
+ else<br>
+ comma = NULL;<br>
+<br>
+ length = &opt[index] - option;<br>
+<br>
+ port = console_find_console_entry( option, length, &minor );<br>
+<br>
+ if ( port == NULL ) {<br>
+ printk("invalid option (--gdb): port not found\n");<br>
+ return;<br>
+ }<br>
+<br>
+ if (comma) {<br>
+ option = comma + 1;<br>
+ baudrate = strtoul(option, 0, 10);<br>
+ switch (baudrate) {<br>
+ case 115200:<br>
+ case 57600:<br>
+ case 38400:<br>
+ case 19200:<br>
+ case 9600:<br>
+ case 4800:<br>
+ port->pDeviceParams = (void*) baudrate;<br>
+ BSPBaseBaud = baudrate; /* REMOVE ME */<br>
+ break;<br>
+ default:<br>
+ printk("invalid option (--gdb): bad baudrate\n");<br>
+ return;<br>
+ }<br>
+ }<br></blockquote><div><br></div><div>Is there anyway the code parsing this option can be shared with that</div><div>for the com ports?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ /*<br>
+ * Provide a probe that fails so the device is not part of termios. All<br>
+ * functions are polling.<br>
+ */<br>
+ port->deviceProbe = gdb_port_probe;<br>
+ port->pDeviceFns = &ns16550_fns_polled;<br>
+<br>
+ opt = bsp_cmdline_arg("--gdb-remote-debug");<br>
+ if ( opt ) {<br>
+ remote_debug = 1;<br>
+ }<br>
+<br>
+ opt = bsp_cmdline_arg("--gdb-break");<br>
+ if ( opt ) {<br>
+ halt = true;<br>
+ }<br>
+<br>
+ printk("GDB stub: enable %s%s%s\n",<br>
+ port->sDeviceName,<br>
+ remote_debug ? ", remote-debug" : "",<br>
+ halt ? ", halting" : "");<br>
+<br>
+ i386_stub_glue_init(minor);<br>
+ set_debug_traps();<br>
+ i386_stub_glue_init_breakin();<br>
+<br>
+ if ( halt ) {<br>
+ printk("GDB stub: waiting for remote connection..\n");<br>
+ breakpoint();<br>
+ }<br>
+ }<br>
+}<br>
diff --git a/c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c b/c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c<br>
index 36afb73..60d35e8 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c<br>
+++ b/c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c<br>
@@ -314,85 +314,88 @@ void pci_uart_probe(void)<br>
&fun<br>
);<br>
if ( status == PCIB_ERR_SUCCESS ) {<br>
+ uint8_t irq;<br>
+ uint32_t base;<br>
+<br>
boards++;<br>
conf[instance].found = true;<br>
conf[instance].clock = pci_ns8250_ids[i].rclk;<br>
conf[instance].ports = 1;<br>
total_ports += conf[instance].ports;<br>
- break;<br>
- }<br>
- }<br>
-<br>
- if ( status != PCIB_ERR_SUCCESS )<br>
- continue;<br>
<br>
- uint8_t irq;<br>
- uint32_t base;<br>
+ pci_read_config_byte( bus, dev, fun, PCI_INTERRUPT_LINE, &irq );<br>
+ pci_read_config_dword( bus, dev, fun, PCI_BASE_ADDRESS_0, &base );<br>
<br>
- pci_read_config_byte( bus, dev, fun, PCI_INTERRUPT_LINE, &irq );<br>
- pci_read_config_dword( bus, dev, fun, PCI_BASE_ADDRESS_0, &base );<br>
+ conf[instance].irq = irq;<br>
+ conf[instance].base = base;<br>
<br>
- conf[instance].irq = irq;<br>
- conf[instance].base = base;<br>
-<br>
- printk(<br>
- "Found %s #%d at 0x%08x IRQ %d with %d clock\n",<br>
- pci_ns8250_ids[i].desc,<br>
- instance,<br>
- conf[instance].base,<br>
- conf[instance].irq,<br>
- conf[instance].clock<br>
- );<br>
+ printk(<br>
+ "Found %s #%d at 0x%08x IRQ %d with %d clock\n",<br>
+ pci_ns8250_ids[i].desc,<br>
+ instance,<br>
+ conf[instance].base,<br>
+ conf[instance].irq,<br>
+ conf[instance].clock<br>
+ );<br>
+ }<br>
+ }<br>
}<br>
<br>
/*<br>
* Now allocate array of device structures and fill them in<br>
*/<br>
- int device_instance;<br>
- ports = calloc( total_ports, sizeof( console_tbl ) );<br>
- port_p = ports;<br>
- device_instance = 1;<br>
- for ( b=0 ; b<MAX_BOARDS ; b++ ) {<br>
- if ( conf[b].found == false )<br>
- continue;<br>
- char name[32];<br>
-<br>
- sprintf( name, "/dev/pcicom%d", device_instance++ );<br>
- port_p->sDeviceName = strdup( name );<br>
- port_p->deviceType = SERIAL_NS16550;<br>
- if ( conf[b].irq <= 15 ) {<br>
- port_p->pDeviceFns = &ns16550_fns;<br>
- } else {<br>
- printk(<br>
- "%s IRQ=%d >= 16 requires APIC support, using polling\n",<br>
- name,<br>
- conf[b].irq <= 15<br>
- );<br>
- port_p->pDeviceFns = &ns16550_fns_polled;<br>
- }<br>
-<br>
- port_p->deviceProbe = NULL;<br>
- port_p->pDeviceFlow = NULL;<br>
- port_p->ulMargin = 16;<br>
- port_p->ulHysteresis = 8;<br>
- port_p->pDeviceParams = (void *) 9600;<br>
- port_p->ulCtrlPort1 = conf[b].base;<br>
- port_p->ulCtrlPort2 = 0; /* NA */<br>
- port_p->ulDataPort = 0; /* NA */<br>
- port_p->getRegister = pci_ns16550_get_register;<br>
- port_p->setRegister = pci_ns16550_set_register;<br>
- port_p->getData = NULL; /* NA */<br>
- port_p->setData = NULL; /* NA */<br>
- port_p->ulClock = conf[b].clock;<br>
- port_p->ulIntVector = conf[b].irq;<br>
-<br>
- port_p++;<br>
- } /* end boards */<br>
+ if (boards) {<br>
+ int device_instance;<br>
+<br>
+ ports = calloc( total_ports, sizeof( console_tbl ) );<br>
+ if (ports != NULL) {<br>
+ port_p = ports;<br>
+ device_instance = 1;<br>
+ for (b = 0; b < MAX_BOARDS; b++) {<br>
+ char name[32];<br>
+ if ( conf[b].found == false )<br>
+ continue;<br>
+ sprintf( name, "/dev/pcicom%d", device_instance++ );<br>
+ port_p->sDeviceName = strdup( name );<br>
+ port_p->deviceType = SERIAL_NS16550;<br>
+ if ( conf[b].irq <= 15 ) {<br>
+ port_p->pDeviceFns = &ns16550_fns;<br>
+ } else {<br>
+ printk(<br>
+ "%s IRQ=%d >= 16 requires APIC support, using polling\n",<br>
+ name,<br>
+ conf[b].irq<br>
+ );<br>
+ port_p->pDeviceFns = &ns16550_fns_polled;<br>
+ }<br>
<br>
- /*<br>
- * Register the devices<br>
- */<br>
- if ( boards )<br>
- console_register_devices( ports, total_ports );<br>
+ port_p->deviceProbe = NULL;<br>
+ port_p->pDeviceFlow = NULL;<br>
+ port_p->ulMargin = 16;<br>
+ port_p->ulHysteresis = 8;<br>
+ port_p->pDeviceParams = (void *) 9600;<br>
+ port_p->ulCtrlPort1 = conf[b].base;<br>
+ port_p->ulCtrlPort2 = 0; /* NA */<br>
+ port_p->ulDataPort = 0; /* NA */<br>
+ port_p->getRegister = pci_ns16550_get_register;<br>
+ port_p->setRegister = pci_ns16550_set_register;<br>
+ port_p->getData = NULL; /* NA */<br>
+ port_p->setData = NULL; /* NA */<br>
+ port_p->ulClock = conf[b].clock;<br>
+ port_p->ulIntVector = conf[b].irq;<br>
+<br>
+ port_p++;<br>
+ } /* end boards */<br>
+<br>
+ /*<br>
+ * Register the devices<br>
+ */<br>
+ console_register_devices( ports, total_ports );<br>
+<br>
+ /*<br>
+ * Do not free the ports memory, the console hold this memory for-ever.<br>
+ */<br>
+ }<br>
+ }<br>
}<br>
#endif<br>
diff --git a/c/src/lib/libbsp/i386/pc386/include/bsp.h b/c/src/lib/libbsp/i386/pc386/include/bsp.h<br>
index 34516f0..cdfbce6 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/include/bsp.h<br>
+++ b/c/src/lib/libbsp/i386/pc386/include/bsp.h<br>
@@ -197,7 +197,7 @@ void rtems_irq_mngt_init(void); /* from 'irq_init.c' */<br>
*/<br>
void *clock_driver_sim_idle_body(uintptr_t);<br>
#define BSP_IDLE_TASK_BODY clock_driver_sim_idle_body<br>
- /*<br>
+ /*<br>
* hack to kill some time. Hopefully hitting a hardware register is slower<br>
* than an empty loop.<br>
*/<br>
@@ -255,6 +255,7 @@ void bsp_ide_cmdline_init(void);<br>
void init_remote_gdb( void );<br>
void i386_stub_glue_init(int uart);<br>
void i386_stub_glue_init_breakin(void);<br>
+int i386_stub_glue_uart(void);<br>
void breakpoint(void);<br>
<br>
#define BSP_MAXIMUM_DEVICES 6<br>
diff --git a/c/src/lib/libbsp/i386/pc386/include/bspimpl.h b/c/src/lib/libbsp/i386/pc386/include/bspimpl.h<br>
index 6503e0a..314fb91 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/include/bspimpl.h<br>
+++ b/c/src/lib/libbsp/i386/pc386/include/bspimpl.h<br>
@@ -1,7 +1,7 @@<br>
/**<br>
* @file<br>
*<br>
- * BSP specific helpers<br>
+ * BSP specific helpers<br>
*/<br>
<br>
/*<br>
@@ -30,6 +30,16 @@ const pci_config_access_functions *pci_io_initialize(void);<br>
void pc386_parse_console_arguments(void);<br>
<br>
/*<br>
+ * Helper to parse boot command line arguments related to gdb<br>
+ */<br>
+void pc386_parse_gdb_arguments(void);<br>
+<br>
+/*<br>
+ * Dynamically probe for Legacy UARTS<br>
+ */<br>
+void legacy_uart_probe(void);<br>
+<br>
+/*<br>
* Dynamically probe for PCI UARTS<br>
*/<br>
void pci_uart_probe(void);<br>
diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c<br>
index 41f858b..0559fbe 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c<br>
+++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c<br>
@@ -10,6 +10,9 @@<br>
* It was subsequently adapted as part of the pc386 BSP by developers from<br>
* the NavIST Group in 1997.<br>
*<br>
+ * Copyright (c) 2016.<br>
+ * Chris Johns <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>><br>
+ *<br>
* COPYRIGHT (c) 1989-2008, 2016.<br>
* On-Line Applications Research Corporation (OAR).<br>
*<br>
@@ -107,16 +110,29 @@ static void bsp_start_default( void )<br>
bsp_pci_initialize_helper();<br>
<br>
/*<br>
- * Probe for UARTs on PCI. One of these may end up as the console.<br>
+ * Probe for legacy UARTs.<br>
+ */<br>
+ legacy_uart_probe();<br>
+<br>
+ /*<br>
+ * Probe for UARTs on PCI.<br>
*/<br>
pci_uart_probe();<br>
<br>
/*<br>
- * Figure out where printk() and console IO is to be directed.<br>
- * Do this after the PCI bus is initialized so we have a chance<br>
- * for those devices to be added to the set in the console driver.<br>
- * In general, Do it as early as possible so printk() has a chance<br>
- * to work early on devices found via PCI probe.<br>
+ * Parse the GDB arguments and flag a serial port as not valid. This stops<br>
+ * the console from claming the port.<br>
+ */<br>
+#if BSP_GDB_STUB<br>
+ pc386_parse_gdb_arguments();<br>
+#endif<br>
+<br>
+ /*<br>
+ * Figure out where printk() and console IO is to be directed. Do this after<br>
+ * the legacy and PCI bus probes so we have a chance for those devices to be<br>
+ * added to the set in the console driver. In general, do it as early as<br>
+ * possible so printk() has a chance to work early on devices found via PCI<br>
+ * probe.<br>
*/<br>
pc386_parse_console_arguments();<br>
<br>
@@ -127,7 +143,6 @@ static void bsp_start_default( void )<br>
#if BSP_ENABLE_IDE<br>
bsp_ide_cmdline_init();<br>
#endif<br>
-<br>
} /* bsp_start_default */<br>
<br>
/*<br>
diff --git a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S<br>
index 82ff982..ea41874 100644<br>
--- a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S<br>
+++ b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S<br>
@@ -110,7 +110,6 @@ next_step:<br>
movw ax, fs<br>
movw ax, gs<br>
<br>
-#if (BSP_IS_EDISON == 0)<br>
/*---------------------------------------------------------------------+<br>
| Now we have to reprogram the interrupts :-(. We put them right after<br>
| the intel-reserved hardware interrupts, at int 0x20-0x2F. There they<br>
@@ -121,6 +120,7 @@ next_step:<br>
| it isn't fun.<br>
+---------------------------------------------------------------------*/<br>
<br>
+#if (BSP_IS_EDISON == 0)<br>
movb $0x11, al /* initialization sequence */<br>
outb al, $0x20 /* send it to 8259A-1 */<br>
call SYM(pc386_delay)<br>
diff --git a/c/src/lib/libbsp/i386/shared/comm/GDB.HOWTO b/c/src/lib/libbsp/i386/shared/comm/GDB.HOWTO<br>
index c57f5a5..d5e0326 100644<br>
--- a/c/src/lib/libbsp/i386/shared/comm/GDB.HOWTO<br>
+++ b/c/src/lib/libbsp/i386/shared/comm/GDB.HOWTO<br>
@@ -1,30 +1,31 @@<br>
-1. Add GDB initilization to your target's code:<br>
+i386/pc386 GDB Stub<br>
<br>
-a) include file:<br>
+The i386 GDB stub has been updated to use the libchip drivers for the<br>
+NS16550. Make sure you have detect the device and you have added a console<br>
+entry. On the PC the legacy and PCI boards are supported.<br>
<br>
-#include <uart.h><br>
+This GDB stub glue code is specific to the UART protocol defined in libbchip.<br>
<br>
-b) declare this variable:<br>
+The pc386 BSP has boot command line options to manage GDB support.<br>
<br>
-extern int BSPConsolePort;<br>
+a) Find the minor number of the console device:<br>
<br>
-c) To start-up GDB, run this:<br>
+ #include <console_private.h><br>
<br>
- /* Init GDB glue */<br>
+ rtems_device_minor_number minor = 0;<br>
<br>
- if(BSPConsolePort != BSP_UART_COM2)<br>
- {<br>
- /*<br>
- * If com2 is not used as console use it for<br>
- * debugging<br>
- */<br>
- i386_stub_glue_init(BSP_UART_COM2);<br>
- }<br>
- else<br>
- {<br>
- /* Otherwise use com1 */<br>
- i386_stub_glue_init(BSP_UART_COM1);<br>
- }<br>
+ if (console_find_console_entry("/dev/com1",<br>
+ strlen("/dev/com1") - 1, &minor) == NULL)<br>
+ error("driver not found\n");<br>
+<br>
+Note, this call is part of the private console API and may change.<br>
+<br>
+b) To start GDB stub, run this:<br>
+<br>
+ #include <bsp.h><br>
+<br>
+ /* Init GDB glue */<br>
+ i386_stub_glue_init(minor);<br>
<br>
/* Init GDB stub itself */<br>
set_debug_traps();<br>
@@ -39,54 +40,45 @@ c) To start-up GDB, run this:<br>
/* Put breakpoint in */<br>
breakpoint();<br>
<br>
-d) This is all you need to do for the target.<br>
-<br>
-2. Edit cmds: specify path to current directory and device used for debugging<br>
- example of cmds is attached below. Make sure your paths are correct.<br>
-3. type 'make'<br>
-4. Boot o-pc386/<test>.exe on target computer, where <test> has the code from step 1. ( I modified and recompiled base_sp as the <test> )<br>
-5. run 'i396-rtems-gdb --nx --command=./cmds o-pc386/<test>.coff<br>
-<br>
-=========================== example cmds ==============================<br>
-/usr1/rtems/work/rtems/cpukit/ada<br>
-/usr1/rtems/work/rtems/cpukit/libblock/src<br>
-/usr1/rtems/work/rtems/cpukit/libcsupport/src<br>
-/usr1/rtems/work/rtems/cpukit/libfs/src/dosfs<br>
-/usr1/rtems/work/rtems/cpukit/libfs/src/imfs<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/capture<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/cpuuse<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/devnull<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/dummy<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/dumpbuf<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/monitor<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/mw-fb<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/rtmonuse<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/serdbg<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/shell<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/stackchk<br>
-/usr1/rtems/work/rtems/cpukit/libmisc/untar<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/arpa<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/kern<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/lib<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/libc<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/machine<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/net<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/netinet<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/nfs<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/rtems<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/sys<br>
-/usr1/rtems/work/rtems/cpukit/libnetworking/vm<br>
-/usr1/rtems/work/rtems/cpukit/librpc/src/rpc<br>
-/usr1/rtems/work/rtems/cpukit/librpc/src/xdr<br>
-/usr1/rtems/work/rtems/cpukit/posix/src<br>
-/usr1/rtems/work/rtems/cpukit/posix/inline/rtems/posix<br>
-/usr1/rtems/work/rtems/cpukit/rtems/inline/rtems/rtems<br>
-/usr1/rtems/work/rtems/cpukit/rtems/src<br>
-/usr1/rtems/work/rtems/cpukit/sapi/inline/rtems<br>
-/usr1/rtems/work/rtems/cpukit/sapi/src<br>
-/usr1/rtems/work/rtems/cpukit/score/cpu/i386<br>
-/usr1/rtems/work/rtems/cpukit/score/cpu/i386/rtems/score<br>
-/usr1/rtems/work/rtems/cpukit/score/src<br>
-/usr1/rtems/work/rtems/cpukit/score/inline/rtems/score<br>
-set remotebaud 38400<br>
-target remote /dev/ttyS1<br>
+c) To run use GDB:<br>
+<br>
+ $ i386-rtems4.12-gdb hello.exe<br>
+ GNU gdb (GDB) 7.11<br>
+ Copyright (C) 2016 Free Software Foundation, Inc.<br>
+ License GPLv3+: GNU GPL version 3 or later <<a href="http://gnu.org/licenses/gpl.html" rel="noreferrer" target="_blank">http://gnu.org/licenses/gpl.html</a>><br>
+ This is free software: you are free to change and redistribute it.<br>
+ There is NO WARRANTY, to the extent permitted by law. Type "show copying"<br>
+ and "show warranty" for details.<br>
+ This GDB was configured as "--host=x86_64-freebsd10.1 --target=i386-rtems4.12".<br>
+ Type "show configuration" for configuration details.<br>
+ For bug reporting instructions, please see:<br>
+ <<a href="http://www.gnu.org/software/gdb/bugs/" rel="noreferrer" target="_blank">http://www.gnu.org/software/gdb/bugs/</a>>.<br>
+ Find the GDB manual and other documentation resources online at:<br>
+ <<a href="http://www.gnu.org/software/gdb/documentation/" rel="noreferrer" target="_blank">http://www.gnu.org/software/gdb/documentation/</a>>.<br>
+ For help, type "help".<br>
+ Type "apropos word" to search for commands related to "word"...<br>
+ Reading symbols from hello.exe...done.<br>
+ (gdb) target remote /dev/cuaU5<br>
+ Remote debugging using /dev/cuaU5<br>
+ 0x00103fda in breakpoint () at i386-stub.c:1004<br>
+ 1004 BREAKPOINT ();<br>
+ (gdb) b Init<br>
+ Breakpoint 1 at 0x1001e0: file init.c, line 29.<br>
+ (gdb) c<br>
+ Continuing.<br>
+<br>
+ Breakpoint 1, Init (ignored=1269800) at init.c:29<br>
+ 29 {<br>
+ (gdb)<br>
+<br>
+Pressing ^C works and if running the board should halt when GDB connects.<br>
+<br>
+e) Use ser2net to provide reomve access over a network to a board. Install the<br>
+ser2net package and add a configuration for the port GDB connects to. For<br>
+example:<br>
+<br>
+ 0005:raw:0:/dev/cuaU5:115200<br>
+<br>
+Start ser2net running then connect GDB using:<br>
+<br>
+ (gdb) target remote myhost:30005<br>
diff --git a/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c b/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c<br>
index 121eef1..25a153f 100644<br>
--- a/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c<br>
+++ b/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c<br>
@@ -1,23 +1,102 @@<br>
/*<br>
+ * Copyright (c) 2016.<br>
+ * Chris Johns <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>><br>
+ *<br>
* This software is Copyright (C) 1998 by T.sqware - all rights limited<br>
* It is provided in to the public domain "as is", can be freely modified<br>
* as far as this copyight notice is kept unchanged, but does not imply<br>
* an endorsement by T.sqware of the product in which it is included.<br>
*/<br>
<br>
-#include <rtems/system.h><br>
-#include <rtems/score/cpu.h><br>
#include <bsp.h><br>
#include <bsp/irq.h><br>
-#include <uart.h><br>
-#include <assert.h><br>
+#include <libchip/serial.h><br>
+<br>
+#include "../../../shared/console_private.h"<br>
<br>
int putDebugChar(int ch); /* write a single character */<br>
int getDebugChar(void); /* read and return a single char */<br>
<br>
+/* Check is any characters received are a ^C */<br>
+int i386_gdb_uart_ctrl_c_check(void);<br>
+<br>
+/* Raw interrupt handler. */<br>
+void i386_gdb_uart_isr(void);<br>
+<br>
/* assign an exception handler */<br>
void exceptionHandler(int, void (*handler)(void));<br>
<br>
+/* User supplied remote debug option. */<br>
+extern int remote_debug;<br>
+<br>
+/* Current uart and port used by the gdb stub */<br>
+static int uart_current;<br>
+static console_tbl* port_current;<br>
+<br>
+/*<br>
+ * Interrupt service routine for all, it does it check whether ^C is received<br>
+ * if yes it will flip TF bit before returning.<br>
+ *<br>
+ * Note: it should be installed as raw interrupt handler.<br>
+ *<br>
+ * Warning: I do not like the use of the global data, I am not<br>
+ * sure if this is SMP safe.<br>
+ */<br>
+int i386_gdb_uart_isr_regsav[4] RTEMS_UNUSED;<br>
+__asm__ (".p2align 4");<br>
+__asm__ (".text");<br>
+__asm__ (".globl i386_gdb_uart_isr");<br>
+__asm__ ("i386_gdb_uart_isr:");<br>
+__asm__ (" pusha"); /* Push all */<br>
+__asm__ (" call i386_gdb_uart_ctrl_c_check"); /* Look for ^C */<br>
+__asm__ (" movl %eax, i386_gdb_uart_isr_regsav"); /* Save eax */<br>
+__asm__ (" popa"); /* Pop all */<br>
+__asm__ (" xchgl %eax, i386_gdb_uart_isr_regsav"); /* Exchange eax */<br>
+__asm__ (" cmpl $0, %eax"); /* 1 == ^C */<br>
+__asm__ (" je i386_gdb_uart_isr_1"); /* branch if 0 */<br>
+__asm__ (" movl %ebx, i386_gdb_uart_isr_regsav + 4"); /* Save ebx */<br>
+__asm__ (" movl %edx, i386_gdb_uart_isr_regsav + 8"); /* Save edx */<br>
+__asm__ (" popl %ebx"); /* Pop eip */<br>
+__asm__ (" popl %edx"); /* Pop cs */<br>
+__asm__ (" popl %eax"); /* Pop flags */<br>
+__asm__ (" orl $0x100, %eax"); /* Modify it */<br>
+__asm__ (" pushl %eax"); /* Push it back */<br>
+__asm__ (" pushl %edx"); /* Push cs */<br>
+__asm__ (" pushl %ebx"); /* Push eip */<br>
+__asm__ (" movl i386_gdb_uart_isr_regsav + 4, %ebx"); /* Restore ebx */<br>
+__asm__ (" movl i386_gdb_uart_isr_regsav + 8, %edx"); /* Restore edx */<br>
+__asm__ ("i386_gdb_uart_isr_1:");<br>
+__asm__ (" movb $0x20, %al");<br>
+__asm__ (" outb %al, $0x20");<br>
+__asm__ (" movl i386_gdb_uart_isr_regsav, %eax"); /* Restore eax */<br>
+__asm__ (" iret"); /* Done */<br>
+<br>
+static int gdb_hello_index;<br>
+static const char const* gdb_hello = "+";<br>
+<br>
+int i386_gdb_uart_ctrl_c_check(void)<br>
+{<br>
+ if (port_current) {<br>
+ int c = 0;<br>
+ while (c >= 0) {<br>
+ c = port_current->pDeviceFns->deviceRead(uart_current);<br>
+ if (c == 3) {<br>
+ gdb_hello_index = 0;<br>
+ return 1;<br>
+ } else if (gdb_hello[gdb_hello_index] == (char) c) {<br>
+ ++gdb_hello_index;<br>
+ if (gdb_hello[gdb_hello_index] == '\0') {<br>
+ gdb_hello_index = 0;<br>
+ return 1;<br>
+ }<br>
+ } else {<br>
+ gdb_hello_index = 0;<br>
+ }<br>
+ }<br>
+ }<br>
+ return 0;<br>
+}<br>
+<br>
static void<br>
nop(const rtems_raw_irq_connect_data* notused)<br>
{<br>
@@ -29,10 +108,12 @@ isOn(const rtems_raw_irq_connect_data* notused)<br>
return 1;<br>
}<br>
<br>
-void BSP_loop(int uart);<br>
-<br>
-/* Current uart used by gdb stub */<br>
-static int uart_current = 0;<br>
+int i386_stub_glue_uart(void)<br>
+{<br>
+ if (port_current == NULL)<br>
+ return -1;<br>
+ return uart_current;<br>
+}<br>
<br>
/*<br>
* Initialize glue code linking i386-stub with the rest of<br>
@@ -41,12 +122,19 @@ static int uart_current = 0;<br>
void<br>
i386_stub_glue_init(int uart)<br>
{<br>
- assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);<br>
+ rtems_device_minor_number minor = (rtems_device_minor_number) uart;<br>
+<br>
+ port_current = console_find_console_entry(NULL, 0, &minor);<br>
+<br>
+ if (port_current == NULL) {<br>
+ printk("GDB: invalid minor number for UART\n");<br>
+ return;<br>
+ }<br>
<br>
uart_current = uart;<br>
<br>
- /* BSP_uart_init(uart, 38400, CHR_8_BITS, 0, 0, 0);*/<br>
- BSP_uart_init(uart, 115200, CHR_8_BITS, 0, 0, 0);<br>
+ /* Intialise the UART, assuming polled drivers */<br>
+ port_current->pDeviceFns->deviceInitialize(uart);<br>
}<br>
<br>
static void BSP_uart_on(const rtems_raw_irq_connect_data* used)<br>
@@ -72,76 +160,65 @@ void i386_stub_glue_init_breakin(void)<br>
{<br>
rtems_raw_irq_connect_data uart_raw_irq_data;<br>
<br>
- assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);<br>
+ if (port_current == NULL) {<br>
+ printk("GDB: no port initialised\n");<br>
+ return;<br>
+ }<br>
<br>
- if(uart_current == BSP_UART_COM1)<br>
- {<br>
- uart_raw_irq_data.idtIndex = BSP_UART_COM1_IRQ + BSP_IRQ_VECTOR_BASE;<br>
- }<br>
- else<br>
- {<br>
- uart_raw_irq_data.idtIndex = BSP_UART_COM2_IRQ + BSP_IRQ_VECTOR_BASE;<br>
- }<br>
+ if ((port_current->ulIntVector == 0) || (port_current->ulIntVector > 16)) {<br>
+ printk("GDB: no UART interrupt support\n");<br>
+ }<br>
+ else {<br>
+ uart_raw_irq_data.idtIndex = port_current->ulIntVector + BSP_IRQ_VECTOR_BASE;<br>
<br>
- if(!i386_get_current_idt_entry(&uart_raw_irq_data))<br>
- {<br>
- printk("cannot get idt entry\n");<br>
+ if (!i386_get_current_idt_entry(&uart_raw_irq_data)) {<br>
+ printk("GBD: cannot get idt entry\n");<br>
rtems_fatal_error_occurred(1);<br>
}<br>
<br>
- if(!i386_delete_idt_entry(&uart_raw_irq_data))<br>
- {<br>
- printk("cannot delete idt entry\n");<br>
+ if (!i386_delete_idt_entry(&uart_raw_irq_data)) {<br>
+ printk("GDB: cannot delete idt entry\n");<br>
rtems_fatal_error_occurred(1);<br>
}<br>
<br>
- uart_raw_irq_data.on = BSP_uart_on;<br>
- uart_raw_irq_data.off = BSP_uart_off;<br>
- uart_raw_irq_data.isOn= BSP_uart_isOn;<br>
+ uart_raw_irq_data.on = BSP_uart_on;<br>
+ uart_raw_irq_data.off = BSP_uart_off;<br>
+ uart_raw_irq_data.isOn= BSP_uart_isOn;<br>
<br>
- /* Install ISR */<br>
- if(uart_current == BSP_UART_COM1)<br>
- {<br>
- uart_raw_irq_data.idtIndex = BSP_UART_COM1_IRQ + BSP_IRQ_VECTOR_BASE;<br>
- uart_raw_irq_data.hdl = BSP_uart_dbgisr_com1;<br>
- }<br>
- else<br>
- {<br>
- uart_raw_irq_data.idtIndex = BSP_UART_COM2_IRQ + BSP_IRQ_VECTOR_BASE;<br>
- uart_raw_irq_data.hdl = BSP_uart_dbgisr_com2;<br>
- }<br>
+ /* Install ISR */<br>
+ uart_raw_irq_data.idtIndex = port_current->ulIntVector + BSP_IRQ_VECTOR_BASE;<br>
+ uart_raw_irq_data.hdl = i386_gdb_uart_isr;<br>
<br>
- if (!i386_set_idt_entry (&uart_raw_irq_data))<br>
- {<br>
- printk("raw exception handler connection failed\n");<br>
+ if (!i386_set_idt_entry (&uart_raw_irq_data)) {<br>
+ printk("GDB: raw exception handler connection failed\n");<br>
rtems_fatal_error_occurred(1);<br>
}<br>
<br>
- /* Enable interrupts */<br>
- BSP_uart_intr_ctrl(uart_current, BSP_UART_INTR_CTRL_GDB);<br>
-<br>
- return;<br>
+ /* Enable interrupts, this is a bit of a hack because we<br>
+ * have to know the device but there is no other call. */<br>
+ (*port_current->setRegister)(port_current->ulCtrlPort1, 1, 0x01);<br>
+ }<br>
}<br>
<br>
int<br>
putDebugChar(int ch)<br>
{<br>
- assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);<br>
-<br>
- BSP_uart_polled_write(uart_current, ch);<br>
-<br>
+ if (port_current != NULL) {<br>
+ port_current->pDeviceFns->deviceWritePolled(uart_current, ch);<br>
+ }<br>
return 1;<br>
}<br>
<br>
int getDebugChar(void)<br>
{<br>
- int val;<br>
-<br>
- assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);<br>
+ int c = -1;<br>
<br>
- val = BSP_uart_polled_read(uart_current);<br>
+ if (port_current != NULL) {<br>
+ while (c < 0)<br>
+ c = port_current->pDeviceFns->deviceRead(uart_current);<br>
+ }<br>
<br>
- return val;<br>
+ return c;<br>
}<br>
<br>
void exceptionHandler(int vector, void (*handler)(void))<br>
@@ -152,13 +229,13 @@ void exceptionHandler(int vector, void (*handler)(void))<br>
<br>
if(!i386_get_current_idt_entry(&excep_raw_irq_data))<br>
{<br>
- printk("cannot get idt entry\n");<br>
+ printk("GDB: cannot get idt entry\n");<br>
rtems_fatal_error_occurred(1);<br>
}<br>
<br>
if(!i386_delete_idt_entry(&excep_raw_irq_data))<br>
{<br>
- printk("cannot delete idt entry\n");<br>
+ printk("GDB: cannot delete idt entry\n");<br>
rtems_fatal_error_occurred(1);<br>
}<br>
<br>
@@ -168,7 +245,7 @@ void exceptionHandler(int vector, void (*handler)(void))<br>
excep_raw_irq_data.hdl = handler;<br>
<br>
if (!i386_set_idt_entry (&excep_raw_irq_data)) {<br>
- printk("raw exception handler connection failed\n");<br>
+ printk("GDB: raw exception handler connection failed\n");<br>
rtems_fatal_error_occurred(1);<br>
}<br>
return;<br>
diff --git a/c/src/lib/libbsp/i386/shared/comm/i386-stub.c b/c/src/lib/libbsp/i386/shared/comm/i386-stub.c<br>
index bc72396..b3630ee 100644<br>
--- a/c/src/lib/libbsp/i386/shared/comm/i386-stub.c<br>
+++ b/c/src/lib/libbsp/i386/shared/comm/i386-stub.c<br>
@@ -99,6 +99,8 @@<br>
#include <string.h><br>
#include <stdbool.h><br>
<br>
+#include <bsp.h><br>
+<br>
/*<br>
* Prototypes we need to avoid warnings but not going into public space.<br>
*/<br>
@@ -150,11 +152,15 @@ enum regnames<br>
/*<br>
* these should not be static cuz they can be used outside this module<br>
*/<br>
-int registers[NUMREGS];<br>
+<br>
+int i386_gdb_registers[NUMREGS];<br>
<br>
#define STACKSIZE 10000<br>
-int remcomStack[STACKSIZE / sizeof (int)];<br>
-static int *stackPtr = &remcomStack[STACKSIZE / sizeof (int) - 1];<br>
+int i386_gdb_remcomStack[STACKSIZE / sizeof (int)];<br>
+int *i386_gdb_stackPtr = &i386_gdb_remcomStack[STACKSIZE / sizeof (int) - 1];<br>
+<br>
+<br>
+static int gdb_connected;<br>
<br>
/*************************** ASSEMBLY CODE MACROS *************************/<br>
/* */<br>
@@ -168,25 +174,25 @@ extern void<br>
__asm__ (".text");<br>
__asm__ (".globl return_to_prog");<br>
__asm__ ("return_to_prog:");<br>
-__asm__ (" movw registers+44, %ss");<br>
-__asm__ (" movl registers+16, %esp");<br>
-__asm__ (" movl registers+4, %ecx");<br>
-__asm__ (" movl registers+8, %edx");<br>
-__asm__ (" movl registers+12, %ebx");<br>
-__asm__ (" movl registers+20, %ebp");<br>
-__asm__ (" movl registers+24, %esi");<br>
-__asm__ (" movl registers+28, %edi");<br>
-__asm__ (" movw registers+48, %ds");<br>
-__asm__ (" movw registers+52, %es");<br>
-__asm__ (" movw registers+56, %fs");<br>
-__asm__ (" movw registers+60, %gs");<br>
-__asm__ (" movl registers+36, %eax");<br>
+__asm__ (" movw i386_gdb_registers+44, %ss");<br>
+__asm__ (" movl i386_gdb_registers+16, %esp");<br>
+__asm__ (" movl i386_gdb_registers+4, %ecx");<br>
+__asm__ (" movl i386_gdb_registers+8, %edx");<br>
+__asm__ (" movl i386_gdb_registers+12, %ebx");<br>
+__asm__ (" movl i386_gdb_registers+20, %ebp");<br>
+__asm__ (" movl i386_gdb_registers+24, %esi");<br>
+__asm__ (" movl i386_gdb_registers+28, %edi");<br>
+__asm__ (" movw i386_gdb_registers+48, %ds");<br>
+__asm__ (" movw i386_gdb_registers+52, %es");<br>
+__asm__ (" movw i386_gdb_registers+56, %fs");<br>
+__asm__ (" movw i386_gdb_registers+60, %gs");<br>
+__asm__ (" movl i386_gdb_registers+36, %eax");<br>
__asm__ (" pushl %eax"); /* saved eflags */<br>
-__asm__ (" movl registers+40, %eax");<br>
+__asm__ (" movl i386_gdb_registers+40, %eax");<br>
__asm__ (" pushl %eax"); /* saved cs */<br>
-__asm__ (" movl registers+32, %eax");<br>
+__asm__ (" movl i386_gdb_registers+32, %eax");<br>
__asm__ (" pushl %eax"); /* saved eip */<br>
-__asm__ (" movl registers, %eax");<br>
+__asm__ (" movl i386_gdb_registers, %eax");<br>
/* use iret to restore pc and flags together so<br>
that trace flag works right. */<br>
__asm__ (" iret");<br>
@@ -202,37 +208,37 @@ int gdb_i386vector = -1;<br>
/* GDB stores segment registers in 32-bit words (that's just the way<br>
m-i386v.h is written). So zero the appropriate areas in registers. */<br>
#define SAVE_REGISTERS1() \<br>
- __asm__ ("movl %eax, registers"); \<br>
- __asm__ ("movl %ecx, registers+4"); \<br>
- __asm__ ("movl %edx, registers+8"); \<br>
- __asm__ ("movl %ebx, registers+12"); \<br>
- __asm__ ("movl %ebp, registers+20"); \<br>
- __asm__ ("movl %esi, registers+24"); \<br>
- __asm__ ("movl %edi, registers+28"); \<br>
- __asm__ ("movw $0, %ax"); \<br>
- __asm__ ("movw %ds, registers+48"); \<br>
- __asm__ ("movw %ax, registers+50"); \<br>
- __asm__ ("movw %es, registers+52"); \<br>
- __asm__ ("movw %ax, registers+54"); \<br>
- __asm__ ("movw %fs, registers+56"); \<br>
- __asm__ ("movw %ax, registers+58"); \<br>
- __asm__ ("movw %gs, registers+60"); \<br>
- __asm__ ("movw %ax, registers+62");<br>
+ __asm__ ("movl %eax, i386_gdb_registers"); \<br>
+ __asm__ ("movl %ecx, i386_gdb_registers+4"); \<br>
+ __asm__ ("movl %edx, i386_gdb_registers+8"); \<br>
+ __asm__ ("movl %ebx, i386_gdb_registers+12"); \<br>
+ __asm__ ("movl %ebp, i386_gdb_registers+20"); \<br>
+ __asm__ ("movl %esi, i386_gdb_registers+24"); \<br>
+ __asm__ ("movl %edi, i386_gdb_registers+28"); \<br>
+ __asm__ ("movw $0, %ax"); \<br>
+ __asm__ ("movw %ds, i386_gdb_registers+48"); \<br>
+ __asm__ ("movw %ax, i386_gdb_registers+50"); \<br>
+ __asm__ ("movw %es, i386_gdb_registers+52"); \<br>
+ __asm__ ("movw %ax, i386_gdb_registers+54"); \<br>
+ __asm__ ("movw %fs, i386_gdb_registers+56"); \<br>
+ __asm__ ("movw %ax, i386_gdb_registers+58"); \<br>
+ __asm__ ("movw %gs, i386_gdb_registers+60"); \<br>
+ __asm__ ("movw %ax, i386_gdb_registers+62");<br>
#define SAVE_ERRCODE() \<br>
- __asm__ ("popl %ebx"); \<br>
+ __asm__ ("popl %ebx"); \<br>
__asm__ ("movl %ebx, gdb_i386errcode");<br>
#define SAVE_REGISTERS2() \<br>
- __asm__ ("popl %ebx"); /* old eip */ \<br>
- __asm__ ("movl %ebx, registers+32"); \<br>
- __asm__ ("popl %ebx"); /* old cs */ \<br>
- __asm__ ("movl %ebx, registers+40"); \<br>
- __asm__ ("movw %ax, registers+42"); \<br>
- __asm__ ("popl %ebx"); /* old eflags */ \<br>
- __asm__ ("movl %ebx, registers+36"); \<br>
- /* Now that we've done the pops, we can save the stack pointer."); */ \<br>
- __asm__ ("movw %ss, registers+44"); \<br>
- __asm__ ("movw %ax, registers+46"); \<br>
- __asm__ ("movl %esp, registers+16");<br>
+ __asm__ ("popl %ebx"); /* old eip */ \<br>
+ __asm__ ("movl %ebx, i386_gdb_registers+32"); \<br>
+ __asm__ ("popl %ebx"); /* old cs */ \<br>
+ __asm__ ("movl %ebx, i386_gdb_registers+40"); \<br>
+ __asm__ ("movw %ax, i386_gdb_registers+42"); \<br>
+ __asm__ ("popl %ebx"); /* old eflags */ \<br>
+ __asm__ ("movl %ebx, i386_gdb_registers+36"); \<br>
+ /* Now that we've done the pops, we can save the stack pointer."); */ \<br>
+ __asm__ ("movw %ss, i386_gdb_registers+44"); \<br>
+ __asm__ ("movw %ax, i386_gdb_registers+46"); \<br>
+ __asm__ ("movl %esp, i386_gdb_registers+16");<br>
<br>
/* See if mem_fault_routine is set, if so just IRET to that address. */<br>
#define CHECK_FAULT() \<br>
@@ -449,7 +455,7 @@ extern void remcomHandler (void);<br>
__asm__ ("_remcomHandler:");<br>
__asm__ (" popl %eax"); /* pop off return address */<br>
__asm__ (" popl %eax"); /* get the exception number */<br>
-__asm__ (" movl stackPtr, %esp"); /* move to remcom stack area */<br>
+__asm__ (" movl i386_gdb_stackPtr, %esp"); /* move to remcom stack area */<br>
__asm__ (" pushl %eax"); /* push exception onto stack */<br>
__asm__ (" call handle_exception"); /* this never returns */<br>
<br>
@@ -508,10 +514,15 @@ getpacket (char *buffer)<br>
xmitcsum += hex (getDebugChar () & 0x7f);<br>
if ((remote_debug) && (checksum != xmitcsum))<br>
{<br>
- fprintf (stderr, "bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n",<br>
- checksum, xmitcsum, buffer);<br>
+ printk ("bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n",<br>
+ checksum, xmitcsum, buffer);<br>
}<br>
<br>
+ if (remote_debug) {<br>
+ printk("GETP: $%s...%s\n", buffer,<br>
+ checksum == xmitcsum ? "Ack" : "Nack");<br>
+ }<br>
+<br>
if (checksum != xmitcsum)<br>
putDebugChar ('-'); /* failed checksum */<br>
else<br>
@@ -539,13 +550,16 @@ getpacket (char *buffer)<br>
static void<br>
putpacket (char *buffer)<br>
{<br>
- unsigned char checksum;<br>
- int count;<br>
- char ch;<br>
-<br>
/* $<packet info>#<checksum>. */<br>
- do<br>
+ while (true)<br>
{<br>
+ unsigned char checksum;<br>
+ int count;<br>
+ char ch;<br>
+<br>
+ if (remote_debug)<br>
+ printk("PUTP: $%s", buffer);<br>
+<br>
putDebugChar ('$');<br>
checksum = 0;<br>
count = 0;<br>
@@ -562,9 +576,18 @@ putpacket (char *buffer)<br>
putDebugChar (hexchars[checksum >> 4]);<br>
putDebugChar (hexchars[checksum % 16]);<br>
<br>
- }<br>
- while ((getDebugChar () & 0x7f) != '+');<br>
+ if (remote_debug)<br>
+ printk("#%c%c...", hexchars[checksum >> 4], hexchars[checksum % 16]);<br>
<br>
+ ch = getDebugChar () & 0x7f;<br>
+ if (ch == '+') {<br>
+ if (remote_debug)<br>
+ printk("Ack\n");<br>
+ break;<br>
+ }<br>
+ if (remote_debug)<br>
+ printk("Nack(%c)\n", ch);<br>
+ }<br>
}<br>
<br>
char remcomInBuffer[BUFMAX];<br>
@@ -578,7 +601,7 @@ debug_error (<br>
)<br>
{<br>
if (remote_debug)<br>
- fprintf (stderr, format, parm);<br>
+ printk (format, parm);<br>
}<br>
<br>
/* Address of a routine to RTE to if we get a memory fault. */<br>
@@ -764,10 +787,10 @@ handle_exception (int exceptionVector)<br>
gdb_i386vector = exceptionVector;<br>
<br>
if (remote_debug)<br>
- printf ("vector=%d, sr=0x%x, pc=0x%x\n",<br>
+ printk ("GDB: EXECPTION: vector=%d, sr=0x%x, pc=0x%x\n",<br>
exceptionVector,<br>
- registers[PS],<br>
- registers[PC]);<br>
+ i386_gdb_registers[PS],<br>
+ i386_gdb_registers[PC]);<br>
<br>
/* Reply to host that an exception has occurred. Always return the<br>
PC, SP, and FP, since gdb always wants them. */<br>
@@ -779,31 +802,33 @@ handle_exception (int exceptionVector)<br>
<br>
*ptr++ = hexchars[ESP];<br>
*ptr++ = ':';<br>
- mem2hex ((char *) ®isters[ESP], ptr, REGBYTES, 0);<br>
+ mem2hex ((char *) &i386_gdb_registers[ESP], ptr, REGBYTES, 0);<br>
ptr += REGBYTES * 2;<br>
*ptr++ = ';';<br>
<br>
*ptr++ = hexchars[EBP];<br>
*ptr++ = ':';<br>
- mem2hex ((char *) ®isters[EBP], ptr, REGBYTES, 0);<br>
+ mem2hex ((char *) &i386_gdb_registers[EBP], ptr, REGBYTES, 0);<br>
ptr += REGBYTES * 2;<br>
*ptr++ = ';';<br>
<br>
*ptr++ = hexchars[PC];<br>
*ptr++ = ':';<br>
- mem2hex ((char *) ®isters[PC], ptr, REGBYTES, 0);<br>
+ mem2hex ((char *) &i386_gdb_registers[PC], ptr, REGBYTES, 0);<br>
ptr += REGBYTES * 2;<br>
*ptr++ = ';';<br>
<br>
*ptr = '\0';<br>
<br>
- putpacket (remcomOutBuffer);<br>
+ if (gdb_connected)<br>
+ putpacket (remcomOutBuffer);<br>
<br>
while (1 == 1)<br>
{<br>
error = 0;<br>
remcomOutBuffer[0] = 0;<br>
getpacket (remcomInBuffer);<br>
+ gdb_connected = 1;<br>
switch (remcomInBuffer[0])<br>
{<br>
case '?':<br>
@@ -812,14 +837,14 @@ handle_exception (int exceptionVector)<br>
remcomOutBuffer[2] = hexchars[sigval % 16];<br>
remcomOutBuffer[3] = 0;<br>
break;<br>
- case 'd':<br>
+ case 'd': /* remove */<br>
remote_debug = !(remote_debug); /* toggle debug flag */<br>
break;<br>
case 'g': /* return the value of the CPU registers */<br>
- mem2hex ((char *) registers, remcomOutBuffer, NUMREGBYTES, 0);<br>
+ mem2hex ((char *) i386_gdb_registers, remcomOutBuffer, NUMREGBYTES, 0);<br>
break;<br>
case 'G': /* set the value of the CPU registers - return OK */<br>
- hex2mem (&remcomInBuffer[1], (char *) registers, NUMREGBYTES, 0);<br>
+ hex2mem (&remcomInBuffer[1], (char *) i386_gdb_registers, NUMREGBYTES, 0);<br>
strcpy (remcomOutBuffer, "OK");<br>
break;<br>
<br>
@@ -828,7 +853,7 @@ handle_exception (int exceptionVector)<br>
if (hexToInt (&ptr, ®)<br>
&& *ptr++ == '=')<br>
{<br>
- hex2mem (ptr, (char *) ®isters[reg], REGBYTES, 0);<br>
+ hex2mem (ptr, (char *) &i386_gdb_registers[reg], REGBYTES, 0);<br>
strcpy (remcomOutBuffer, "OK");<br>
}<br>
else<br>
@@ -902,29 +927,31 @@ handle_exception (int exceptionVector)<br>
/* try to read optional parameter, pc unchanged if no parm */<br>
ptr = &remcomInBuffer[1];<br>
if (hexToInt (&ptr, &addr))<br>
- registers[PC] = addr;<br>
+ i386_gdb_registers[PC] = addr;<br>
<br>
/* clear the trace bit */<br>
- registers[PS] &= 0xfffffeff;<br>
+ i386_gdb_registers[PS] &= 0xfffffeff;<br>
<br>
/* set the trace bit if we're stepping */<br>
if (remcomInBuffer[0] == 's')<br>
- registers[PS] |= 0x100;<br>
+ i386_gdb_registers[PS] |= 0x100;<br>
<br>
_returnFromException (); /* this is a jump */<br>
-<br>
break;<br>
<br>
/* Detach. */<br>
case 'D':<br>
putpacket (remcomOutBuffer);<br>
- registers[PS] &= 0xfffffeff;<br>
+ i386_gdb_registers[PS] &= 0xfffffeff;<br>
_returnFromException (); /* this is a jump */<br>
-<br>
break;<br>
<br>
/* kill the program */<br>
case 'k': /* do nothing */<br>
+ bsp_reset();<br>
+ continue;<br>
+<br>
+ default:<br>
break;<br>
} /* switch */<br>
<br>
@@ -938,7 +965,7 @@ handle_exception (int exceptionVector)<br>
void<br>
set_debug_traps (void)<br>
{<br>
- stackPtr = &remcomStack[STACKSIZE / sizeof (int) - 1];<br>
+ i386_gdb_stackPtr = &i386_gdb_remcomStack[STACKSIZE / sizeof (int) - 1];<br>
<br>
exceptionHandler (0, _catchException0);<br>
exceptionHandler (1, _catchException1);<br>
diff --git a/c/src/lib/libbsp/shared/console.c b/c/src/lib/libbsp/shared/console.c<br>
index d226172..b4af1b3 100644<br>
--- a/c/src/lib/libbsp/shared/console.c<br>
+++ b/c/src/lib/libbsp/shared/console.c<br>
@@ -34,6 +34,45 @@ rtems_device_minor_number Console_Port_Minor = 0;<br>
static bool console_initialized = false;<br>
<br>
/*<br>
+ * console_find_console_entry<br>
+ *<br>
+ * This method is used to search the console entries for a<br>
+ * specific device entry.<br>
+ */<br>
+console_tbl* console_find_console_entry(<br>
+ const char *match,<br>
+ size_t length,<br>
+ rtems_device_minor_number *match_minor<br>
+)<br>
+{<br>
+ rtems_device_minor_number minor;<br>
+<br>
+ /*<br>
+ * The the match name is NULL get the minor number entry.<br>
+ */<br>
+ if (match == NULL) {<br>
+ if (*match_minor < Console_Port_Count)<br>
+ return Console_Port_Tbl[*match_minor];<br>
+ return NULL;<br>
+ }<br>
+<br>
+ for (minor=0; minor < Console_Port_Count ; minor++) {<br>
+ console_tbl *cptr = Console_Port_Tbl[minor];<br>
+<br>
+ /*<br>
+ * Console table entries include /dev/ prefix, device names passed<br>
+ * in on command line do not.<br>
+ */<br>
+ if ( !strncmp( cptr->sDeviceName, match, length ) ) {<br>
+ *match_minor = minor;<br>
+ return cptr;<br>
+ }<br>
+ }<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+/*<br>
* console_initialize_data<br>
*<br>
* This method is used to initialize the table of pointers to the<br>
@@ -278,9 +317,7 @@ rtems_device_driver console_initialize(<br>
* must still initialize pointers for Console_Port_Tbl and<br>
* Console_Port_Data.<br>
*/<br>
- if ( !Console_Port_Tbl ) {<br>
- console_initialize_data();<br>
- }<br>
+ console_initialize_data();<br>
<br>
/*<br>
* console_initialize has been invoked so it is now too late to<br>
diff --git a/c/src/lib/libbsp/shared/console_private.h b/c/src/lib/libbsp/shared/console_private.h<br>
index 42a8ee9..3855e83 100644<br>
--- a/c/src/lib/libbsp/shared/console_private.h<br>
+++ b/c/src/lib/libbsp/shared/console_private.h<br>
@@ -41,6 +41,19 @@ int vt_ioctl(<br>
);<br>
<br>
/**<br>
+ * @brief console_find_console_entry<br>
+ *<br>
+ * This method is used to search the console entries for a<br>
+ * specific device entry and return it. If match is NULL the<br>
+ * minor number provided is matched.<br>
+ */<br>
+console_tbl* console_find_console_entry(<br>
+ const char *match,<br>
+ size_t length,<br>
+ rtems_device_minor_number *match_minor<br>
+);<br>
+<br>
+/**<br>
* @brief console_initialize_data<br>
*<br>
* This must be called before dynamic registration of devices can occur.<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.4.6<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</font></span></blockquote></div><br></div></div>