Changeset 014292a1 in rtems


Ignore:
Timestamp:
Apr 8, 2016, 8:39:38 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
03ad2a5a
Parents:
f57f513d
git-author:
Chris Johns <chrisj@…> (04/08/16 08:39:38)
git-committer:
Chris Johns <chrisj@…> (05/11/16 01:45:01)
Message:

i386/pc386: Add support for the gdb stub to use available console drivers.

Move the gdb stub from the i386 UART code to use the libchip drivers.

Use any ports discovered during the probes.

Add gdb control to the boot command line.

Change the device naming to the full device path, not a partial path.
For example /dev/com1.

Location:
c/src/lib/libbsp
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/Makefile.am

    rf57f513d r014292a1  
    133133libbsp_a_SOURCES += console/rtd316.c
    134134libbsp_a_SOURCES += console/uart_bus_pci.c
     135libbsp_a_SOURCES += console/gdb_select.c
    135136
    136137# gdb
     
    182183
    183184if HAS_SMP
    184 libbsp_a_SOURCES += ../../i386/shared/smp/getcpuid.c 
    185 libbsp_a_SOURCES += ../../i386/shared/smp/smp-imps.c 
     185libbsp_a_SOURCES += ../../i386/shared/smp/getcpuid.c
     186libbsp_a_SOURCES += ../../i386/shared/smp/smp-imps.c
    186187
    187188project_lib_DATA += appstart.$(OBJEXT)
  • c/src/lib/libbsp/i386/pc386/README

    rf57f513d r014292a1  
    88
    99Partial support is implemented for more modern PCs which do not have
    10 a complete complement of legacy peripherals. 
     10a complete complement of legacy peripherals.
    1111
    1212Console/Printk Device Selection
     
    2020+ COM1 through COM4aaa
    2121
    22 + Any COM devices on the PCI bus
     22+ Any COM devices on the PCI bus including IO and memory mapped.
    2323
    24 Beyond the dynamic probing for device presence, a combination of 
     24Beyond the dynamic probing for device presence, a combination of
    2525configure and boot time options are available. By default, all devices
    2626are enabled. The configure time options are:
     
    4646For example,
    4747
    48 --console=com1 --printk=vgacons
     48--console=/dev/com1 --printk=/dev/vgacons
    4949
    5050specifies that com1 is to be used for stdin, stdout, and stderr
     
    5656example illustrates this:
    5757
    58 --console=com1,19200 --printk=vgacons
     58--console=/dev/com1,19200 --printk=/dev/vgacons
    5959
    6060If the specified device is not present, then a suitable fallback
    6161device is selected. The fallback order is based upon the probe
    6262order listed earlier.
     63
     64PCI UART devices are /dev/pcicom1 etc as they are probed and found.
     65
     66GDB
     67===
     68
     69GDB can be support using:
     70
     71 --gdb=/dev/com1,115200  : where the device and baudrate are selectable.
     72 --gdb-break             : halt at a break point in the BSP and wait for GDB.
     73 --gdb-remote-debug      : Output the GDB remote protocol data to printk
     74
     75The GDB stub details and in shared/comm/GDB.HOWTO.
  • c/src/lib/libbsp/i386/pc386/configure.ac

    rf57f513d r014292a1  
    143143 determining the CPU core number in an SMP configuration.])
    144144
     145RTEMS_BSPOPTS_SET([BSP_GDB_STUB],[*],[1])
     146RTEMS_BSPOPTS_HELP([BSP_GDB_STUB],
     147[Defined by default. Enables use of the GDB stub for debugging via a
     148 serial port.])
     149AM_CONDITIONAL(BSP_GDB_STUB, test "$BSP_GDB_STUB" = "1")
     150
    145151## if this is an i386, does gas have good code16 support?
    146152RTEMS_I386_GAS_CODE16
  • c/src/lib/libbsp/i386/pc386/console/conscfg.c

    rf57f513d r014292a1  
    1717
    1818#include <bsp.h>
     19#include <bsp/bspimpl.h>
    1920#include <libchip/serial.h>
    2021#include <libchip/ns16550.h>
     
    2324#endif
    2425#include <bsp/irq.h>
    25 #include <rtems/pci.h>
     26#include "../../../shared/console_private.h"
    2627
    2728#if BSP_ENABLE_VGA
     
    4445  #define COM4_BASE_IO  0x2E8
    4546
    46   #define CLOCK_RATE     (115200 * 16)
     47  #define CLOCK_RATE    (115200 * 16)
    4748
    4849  static uint8_t com_get_register(uint32_t addr, uint8_t i)
     
    5859    outport_byte( (addr + i), val );
    5960  }
    60 
    61   extern bool pc386_com1_com4_enabled(int);
    6261#endif
    6362
     
    6665#endif
    6766
    68 console_tbl     Console_Configuration_Ports[] = {
    69 #if (BSP_IS_EDISON == 1)
    70   {
    71     "/dev/com1",                           /* sDeviceName */
    72     -1,                                    /* deviceType */
    73     &edison_fns,                           /* pDeviceFns */
    74     NULL,                                  /* deviceProbe */
    75     NULL,                                  /* pDeviceFlow */
    76     16,                                    /* ulMargin */
    77     8,                                     /* ulHysteresis */
    78     (void *) NULL,              /* NULL */ /* pDeviceParams */
    79     0x00000000,                            /* ulCtrlPort1 */
    80     0x00000000,                            /* ulCtrlPort2 */
    81     0x00000000,                            /* ulDataPort */
    82     NULL,                                  /* getRegister */
    83     NULL,                                  /* setRegister */
    84     NULL,/* unused */                      /* getData */
    85     NULL,/* unused */                      /* setData */
    86     0X0,                                   /* ulClock */
    87     0x0                                     /* ulIntVector -- base for port */
    88   },
    89 #endif
     67/*
     68 * Default to the PC VGA console if present and configured.
     69 */
     70console_tbl Console_Configuration_Ports[] = {
    9071#if BSP_ENABLE_VGA
     72  /*
     73   * If present the VGA console must always be minor 0.
     74   * See console_control.
     75   */
    9176  {
    9277    "/dev/vgacons",                        /* sDeviceName */
     
    10590    NULL,/* unused */                      /* getData */
    10691    NULL,/* unused */                      /* setData */
    107     0X0,                                   /* ulClock */
    108     0x0                                     /* ulIntVector -- base for port */
     92    0x0,                                   /* ulClock */
     93    0x0                                    /* ulIntVector -- base for port */
     94  },
     95#endif
     96};
     97
     98unsigned long Console_Configuration_Count =
     99    (sizeof(Console_Configuration_Ports)/sizeof(console_tbl));
     100
     101static console_tbl Legacy_Ports[] = {
     102#if (BSP_IS_EDISON == 1)
     103  {
     104    "/dev/com1",                           /* sDeviceName */
     105    -1,                                    /* deviceType */
     106    &edison_fns,                           /* pDeviceFns */
     107    NULL,                                  /* deviceProbe */
     108    NULL,                                  /* pDeviceFlow */
     109    16,                                    /* ulMargin */
     110    8,                                     /* ulHysteresis */
     111    (void *) NULL,              /* NULL */ /* pDeviceParams */
     112    0x00000000,                            /* ulCtrlPort1 */
     113    0x00000000,                            /* ulCtrlPort2 */
     114    0x00000000,                            /* ulDataPort */
     115    NULL,                                  /* getRegister */
     116    NULL,                                  /* setRegister */
     117    NULL,/* unused */                      /* getData */
     118    NULL,/* unused */                      /* setData */
     119    0x0,                                   /* ulClock */
     120    0x0                                    /* ulIntVector -- base for port */
    109121  },
    110122#endif
     
    114126    SERIAL_NS16550,                        /* deviceType */
    115127    COM_CONSOLE_FUNCTIONS,                 /* pDeviceFns */
    116     pc386_com1_com4_enabled,               /* deviceProbe */
     128    NULL,                                  /* deviceProbe */
    117129    NULL,                                  /* pDeviceFlow */
    118130    16,                                    /* ulMargin */
     
    133145    SERIAL_NS16550,                        /* deviceType */
    134146    COM_CONSOLE_FUNCTIONS,                 /* pDeviceFns */
    135     pc386_com1_com4_enabled,               /* deviceProbe */
     147    NULL,                                  /* deviceProbe */
    136148    NULL,                                  /* pDeviceFlow */
    137149    16,                                    /* ulMargin */
     
    148160    BSP_UART_COM2_IRQ                      /* ulIntVector -- base for port */
    149161  },
    150 
    151162  {
    152163    "/dev/com3",                           /* sDeviceName */
    153164    SERIAL_NS16550,                        /* deviceType */
    154165    COM_CONSOLE_FUNCTIONS,                 /* pDeviceFns */
    155     pc386_com1_com4_enabled,               /* deviceProbe */
     166    NULL,                                  /* deviceProbe */
    156167    NULL,                                  /* pDeviceFlow */
    157168    16,                                    /* ulMargin */
     
    168179    BSP_UART_COM3_IRQ                      /* ulIntVector -- base for port */
    169180  },
    170 
    171181  {
    172182    "/dev/com4",                           /* sDeviceName */
    173183    SERIAL_NS16550,                        /* deviceType */
    174184    COM_CONSOLE_FUNCTIONS,                 /* pDeviceFns */
    175     pc386_com1_com4_enabled,               /* deviceProbe */
     185    NULL,                                  /* deviceProbe */
    176186    NULL,                                  /* pDeviceFlow */
    177187    16,                                    /* ulMargin */
     
    189199  },
    190200#endif
    191 
    192201};
    193202
    194 /*
    195  *  Define a variable that contains the number of statically configured
    196  *  console devices.
    197  */
    198 unsigned long  Console_Configuration_Count = \
    199     (sizeof(Console_Configuration_Ports)/sizeof(console_tbl));
     203#define Legacy_Port_Count \
     204    (sizeof(Legacy_Ports)/sizeof(console_tbl))
     205
     206void legacy_uart_probe(void)
     207{
     208#if BSP_ENABLE_COM1_COM4
     209  const char *opt;
     210  /*
     211   * Check the command line to see if com1-com4 are disabled.
     212   */
     213  opt = bsp_cmdline_arg("--disable-com1-com4");
     214  if ( opt ) {
     215    printk( "COM1-COM4: disabled\n" );
     216  } else {
     217    if (Legacy_Port_Count) {
     218      printk("Legacy UART Ports: COM1-COM4\n");
     219      console_register_devices( Legacy_Ports, Legacy_Port_Count );
     220    }
     221  }
     222#endif
     223}
  • c/src/lib/libbsp/i386/pc386/console/console_control.c

    rf57f513d r014292a1  
    11/*
    2  *  This file is an extension of the generic console driver 
     2 *  This file is an extension of the generic console driver
    33 *  shell used by all console drivers using libchip, it contains
    44 *  the console_control routine,  This bsp needs its own version
     
    4545{
    4646#if BSP_ENABLE_VGA
    47   rtems_libio_ioctl_args_t *args = arg;
     47  if (minor == 0) {
     48    rtems_libio_ioctl_args_t *args = arg;
    4849
    49   switch (args->command) {
    50     default:
    51       if( vt_ioctl( args->command, (unsigned long)args->buffer ) != 0 )
    52         return rtems_termios_ioctl (arg);
    53       break;
     50    switch (args->command) {
     51      default:
     52        if( vt_ioctl( args->command, (unsigned long)args->buffer ) != 0 )
     53          return rtems_termios_ioctl (arg);
     54        break;
    5455
    55     case MW_UID_REGISTER_DEVICE:
    56       printk( "SerialMouse: reg=%s\n", args->buffer );
    57       register_kbd_msg_queue( args->buffer, 0 );
    58       break;
     56      case MW_UID_REGISTER_DEVICE:
     57        printk( "SerialMouse: reg=%s\n", args->buffer );
     58        register_kbd_msg_queue( args->buffer, 0 );
     59        break;
    5960
    60     case MW_UID_UNREGISTER_DEVICE:
    61       unregister_kbd_msg_queue( 0 );
    62       break;
     61      case MW_UID_UNREGISTER_DEVICE:
     62        unregister_kbd_msg_queue( 0 );
     63        break;
     64    }
     65
     66    args->ioctl_return = 0;
     67    return RTEMS_SUCCESSFUL;
    6368  }
    64  
    65   args->ioctl_return = 0;
    66   return RTEMS_SUCCESSFUL;
    67 #else
     69#endif
    6870  return rtems_termios_ioctl (arg);
    69 #endif
    7071}
  • c/src/lib/libbsp/i386/pc386/console/console_select.c

    rf57f513d r014292a1  
    44 * @ingroup Console
    55 *
    6  * @brief pc397 console select
     6 * @brief pc386 console select
    77 *
    88 * This file contains a routine to select the console based upon a number
     
    3434#endif
    3535
    36 #include <bsp/bspimpl.h>
    37 
    38 /*
    39  * Forward prototype
    40  */
    41 extern bool pc386_com1_com4_enabled(int);
    42 
    43 /*
    44  * This method is used to determine if COM1-COM4 are enabled based upon
    45  * boot command line arguments.
    46  */
    47 static bool are_com1_com4_enabled;
    48 
    49 bool pc386_com1_com4_enabled(int minor)
    50 {
    51   return are_com1_com4_enabled;
    52 }
    53 
    5436/*
    5537 * Method to return true if the device associated with the
     
    9678   */
    9779  rtems_fatal_error_occurred(RTEMS_IO_ERROR);
    98 }
    99 
    100 static bool bsp_find_console_entry(
    101   const char                *match,
    102   size_t                     length,
    103   rtems_device_minor_number *match_minor
    104 )
    105 {
    106   rtems_device_minor_number  minor;
    107   const char                *name;
    108 
    109   for (minor=0; minor < Console_Port_Count ; minor++) {
    110     console_tbl  *cptr = Console_Port_Tbl[minor];
    111 
    112     /*
    113      * Console table entries include /dev/ prefix, device names passed
    114      * in on command line do not.
    115      */
    116     name = cptr->sDeviceName  + sizeof("/dev");
    117     if ( !strncmp( name, match, length ) ) {
    118       *match_minor = minor;
    119       return true;
    120     }
    121   }
    122 
    123   return false;
    124 }
    125 
    126 static void parse_com1_com4_enable(void)
    127 {
    128   static const char *opt;
    129 
    130   /*
    131    * Check the command line to see if com1-com4 are disabled.
    132    */
    133   opt = bsp_cmdline_arg("--disable-com1-com4");
    134   if ( opt ) {
    135     printk( "Disable COM1-COM4 per boot argument\n" );
    136     are_com1_com4_enabled = false;
    137   } else {
    138     are_com1_com4_enabled = true;
    139   }
    14080}
    14181
     
    15191  size_t                     index;
    15292  rtems_device_minor_number  minor;
     93  console_tbl               *conscfg;
    15394
    15495  /*
     
    199140  length = &opt[index] - option;
    200141
    201   if ( !bsp_find_console_entry( option, length, &minor ) ) {
     142  conscfg = console_find_console_entry( option, length, &minor );
     143  if ( conscfg == NULL ) {
    202144    return false;
    203145  }
     
    205147  *minor_out = minor;
    206148  if (comma) {
    207     console_tbl *conscfg = &Console_Configuration_Ports[minor];
    208 
    209149    option = comma + 1;
    210 
    211150    if (strncmp (option, "115200", sizeof ("115200") - 1) == 0)
    212151      conscfg->pDeviceParams = (void *)115200;
     
    242181void pc386_parse_console_arguments(void)
    243182{
    244   rtems_device_minor_number  minor;
    245 
    246   /*
    247    * The console device driver must have its data structures initialized
    248    * before we can iterate the table of devices for names.
    249    */
    250   console_initialize_data();
    251 
    252   /*
    253    * Determine if COM1-COM4 were disabled.
    254    */
    255   parse_com1_com4_enable();
     183  rtems_device_minor_number minor;
     184  rtems_device_minor_number minor_console = 0;
     185  rtems_device_minor_number minor_printk = 0;
    256186
    257187  /*
     
    260190   */
    261191  if ( parse_printk_or_console( "--console=", &minor ) ) {
    262     Console_Port_Minor = minor;
    263     BSPPrintkPort = minor;
     192    minor_console = minor;
     193    minor_printk = minor;
    264194  }
    265195
     
    268198   */
    269199  if ( parse_printk_or_console( "--printk=",  &minor ) ) {
    270     BSPPrintkPort = minor;
    271   }
    272 
    273 #if 0
    274   printk( "Console device: %s\n", get_name(Console_Port_Minor) );
    275   printk( "printk device:  %s\n", get_name(BSPPrintkPort) );
    276 #endif
     200    minor_printk = minor;
     201  }
     202
     203  printk( "Console: %s printk: %s\n",
     204          get_name(minor_console),get_name(minor_printk) );
     205
     206  /*
     207   * Any output after this can cause problems until termios is initialised.
     208   */
     209  Console_Port_Minor = minor_console;
     210  BSPPrintkPort = minor_printk;
    277211}
    278212
     
    284218{
    285219  #ifdef RTEMS_RUNTIME_CONSOLE_SELECT
     220    /*
     221     * WARNING: This code is really needed any more and should be removed.
     222     *          references to COM1 and COM2 like they are wrong.
     223     */
    286224    if ( BSP_runtime_console_select )
    287225      BSP_runtime_console_select(&BSPPrintkPort, &Console_Port_Minor);
  • c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c

    rf57f513d r014292a1  
    315315      );
    316316      if ( status == PCIB_ERR_SUCCESS ) {
     317        uint8_t  irq;
     318        uint32_t base;
     319
    317320        boards++;
    318321        conf[instance].found = true;
     
    320323        conf[instance].ports = 1;
    321324        total_ports += conf[instance].ports;
    322         break;
     325
     326        pci_read_config_byte( bus, dev, fun, PCI_INTERRUPT_LINE, &irq );
     327        pci_read_config_dword( bus, dev, fun, PCI_BASE_ADDRESS_0, &base );
     328
     329        conf[instance].irq  = irq;
     330        conf[instance].base = base;
     331
     332        printk(
     333          "Found %s #%d at 0x%08x IRQ %d with %d clock\n",
     334          pci_ns8250_ids[i].desc,
     335          instance,
     336          conf[instance].base,
     337          conf[instance].irq,
     338          conf[instance].clock
     339        );
    323340      }
    324341    }
    325 
    326     if ( status != PCIB_ERR_SUCCESS )
    327       continue;
    328 
    329     uint8_t  irq;
    330     uint32_t base;
    331 
    332     pci_read_config_byte( bus, dev, fun, PCI_INTERRUPT_LINE, &irq );
    333     pci_read_config_dword( bus, dev, fun, PCI_BASE_ADDRESS_0, &base );
    334 
    335     conf[instance].irq  = irq;
    336     conf[instance].base = base;
    337 
    338     printk(
    339       "Found %s #%d at 0x%08x IRQ %d with %d clock\n",
    340       pci_ns8250_ids[i].desc,
    341       instance,
    342       conf[instance].base,
    343       conf[instance].irq,
    344       conf[instance].clock
    345     );
    346342  }
    347343
     
    349345   *  Now allocate array of device structures and fill them in
    350346   */
    351   int device_instance;
    352   ports = calloc( total_ports, sizeof( console_tbl ) );
    353   port_p = ports;
    354   device_instance = 1;
    355   for ( b=0 ; b<MAX_BOARDS ; b++ ) {
    356     if ( conf[b].found == false )
    357       continue;
    358     char name[32];
    359 
    360     sprintf( name, "/dev/pcicom%d", device_instance++ );
    361     port_p->sDeviceName   = strdup( name );
    362     port_p->deviceType    = SERIAL_NS16550;
    363     if ( conf[b].irq <= 15 ) {
    364       port_p->pDeviceFns    = &ns16550_fns;
    365     } else {
    366       printk(
    367         "%s IRQ=%d >= 16 requires APIC support, using polling\n",
    368         name,
    369         conf[b].irq <= 15
    370       );
    371       port_p->pDeviceFns    = &ns16550_fns_polled;
     347  if (boards) {
     348    int device_instance;
     349
     350    ports = calloc( total_ports, sizeof( console_tbl ) );
     351    if (ports != NULL) {
     352      port_p = ports;
     353      device_instance = 1;
     354      for (b = 0; b < MAX_BOARDS; b++) {
     355        char name[32];
     356        if ( conf[b].found == false )
     357          continue;
     358        sprintf( name, "/dev/pcicom%d", device_instance++ );
     359        port_p->sDeviceName   = strdup( name );
     360        port_p->deviceType    = SERIAL_NS16550;
     361        if ( conf[b].irq <= 15 ) {
     362          port_p->pDeviceFns    = &ns16550_fns;
     363        } else {
     364          printk(
     365            "%s IRQ=%d >= 16 requires APIC support, using polling\n",
     366            name,
     367            conf[b].irq
     368          );
     369          port_p->pDeviceFns    = &ns16550_fns_polled;
     370        }
     371
     372        port_p->deviceProbe   = NULL;
     373        port_p->pDeviceFlow   = NULL;
     374        port_p->ulMargin      = 16;
     375        port_p->ulHysteresis  = 8;
     376        port_p->pDeviceParams = (void *) 9600;
     377        port_p->ulCtrlPort1   = conf[b].base;
     378        port_p->ulCtrlPort2   = 0;                   /* NA */
     379        port_p->ulDataPort    = 0;                   /* NA */
     380        port_p->getRegister   = pci_ns16550_get_register;
     381        port_p->setRegister   = pci_ns16550_set_register;
     382        port_p->getData       = NULL;                /* NA */
     383        port_p->setData       = NULL;                /* NA */
     384        port_p->ulClock       = conf[b].clock;
     385        port_p->ulIntVector   = conf[b].irq;
     386
     387        port_p++;
     388      }    /* end boards */
     389
     390      /*
     391       *  Register the devices
     392       */
     393      console_register_devices( ports, total_ports );
     394
     395      /*
     396       *  Do not free the ports memory, the console hold this memory for-ever.
     397       */
    372398    }
    373 
    374     port_p->deviceProbe   = NULL;
    375     port_p->pDeviceFlow   = NULL;
    376     port_p->ulMargin      = 16;
    377     port_p->ulHysteresis  = 8;
    378     port_p->pDeviceParams = (void *) 9600;
    379     port_p->ulCtrlPort1   = conf[b].base;
    380     port_p->ulCtrlPort2   = 0;                   /* NA */
    381     port_p->ulDataPort    = 0;                   /* NA */
    382     port_p->getRegister   = pci_ns16550_get_register;
    383     port_p->setRegister   = pci_ns16550_set_register;
    384     port_p->getData       = NULL;                /* NA */
    385     port_p->setData       = NULL;                /* NA */
    386     port_p->ulClock       = conf[b].clock;
    387     port_p->ulIntVector   = conf[b].irq;
    388 
    389     port_p++;
    390   }    /* end boards */
    391 
    392   /*
    393    *  Register the devices
    394    */
    395   if ( boards )
    396     console_register_devices( ports, total_ports );
     399  }
    397400}
    398401#endif
  • c/src/lib/libbsp/i386/pc386/include/bsp.h

    rf57f513d r014292a1  
    198198   void *clock_driver_sim_idle_body(uintptr_t);
    199199   #define BSP_IDLE_TASK_BODY clock_driver_sim_idle_body
    200   /* 
     200  /*
    201201   * hack to kill some time. Hopefully hitting a hardware register is slower
    202202   * than an empty loop.
     
    256256void i386_stub_glue_init(int uart);
    257257void i386_stub_glue_init_breakin(void);
     258int i386_stub_glue_uart(void);
    258259void breakpoint(void);
    259260
  • c/src/lib/libbsp/i386/pc386/include/bspimpl.h

    rf57f513d r014292a1  
    22 * @file
    33 *
    4  * BSP specific helpers 
     4 * BSP specific helpers
    55 */
    66
     
    3131
    3232/*
     33 * Helper to parse boot command line arguments related to gdb
     34 */
     35void pc386_parse_gdb_arguments(void);
     36
     37/*
     38 * Dynamically probe for Legacy UARTS
     39 */
     40void legacy_uart_probe(void);
     41
     42/*
    3343 * Dynamically probe for PCI UARTS
    3444 */
  • c/src/lib/libbsp/i386/pc386/startup/bspstart.c

    rf57f513d r014292a1  
    1010 * It was subsequently adapted as part of the pc386 BSP by developers from
    1111 * the NavIST Group in 1997.
     12 *
     13 * Copyright (c) 2016.
     14 * Chris Johns <chrisj@rtems.org>
    1215 *
    1316 * COPYRIGHT (c) 1989-2008, 2016.
     
    108111
    109112  /*
    110    * Probe for UARTs on PCI. One of these may end up as the console.
     113   * Probe for legacy UARTs.
     114   */
     115  legacy_uart_probe();
     116
     117  /*
     118   * Probe for UARTs on PCI.
    111119   */
    112120  pci_uart_probe();
    113121
    114122  /*
    115    * Figure out where printk() and console IO is to be directed.
    116    * Do this after the PCI bus is initialized so we have a chance
    117    * for those devices to be added to the set in the console driver.
    118    * In general, Do it as early as possible so printk() has a chance
    119    * to work early on devices found via PCI probe.
     123   * Parse the GDB arguments and flag a serial port as not valid. This stops
     124   * the console from claming the port.
     125   */
     126#if BSP_GDB_STUB
     127  pc386_parse_gdb_arguments();
     128#endif
     129
     130  /*
     131   * Figure out where printk() and console IO is to be directed.  Do this after
     132   * the legacy and PCI bus probes so we have a chance for those devices to be
     133   * added to the set in the console driver.  In general, do it as early as
     134   * possible so printk() has a chance to work early on devices found via PCI
     135   * probe.
    120136   */
    121137  pc386_parse_console_arguments();
     
    128144  bsp_ide_cmdline_init();
    129145#endif
    130 
    131146} /* bsp_start_default */
    132147
  • c/src/lib/libbsp/i386/pc386/startup/ldsegs.S

    rf57f513d r014292a1  
    111111        movw ax, gs
    112112
    113 #if (BSP_IS_EDISON == 0)
    114113/*---------------------------------------------------------------------+
    115114| Now we have to reprogram the interrupts :-(. We put them right after
     
    122121+---------------------------------------------------------------------*/
    123122
     123#if (BSP_IS_EDISON == 0)
    124124        movb    $0x11, al               /* initialization sequence          */
    125125        outb    al, $0x20               /* send it to 8259A-1               */
  • c/src/lib/libbsp/i386/shared/comm/GDB.HOWTO

    rf57f513d r014292a1  
    1 1. Add GDB initilization to your target's code:
     1i386/pc386 GDB Stub
    22
    3 a) include file:
     3The i386 GDB stub has been updated to use the libchip drivers for the
     4NS16550. Make sure you have detect the device and you have added a console
     5entry. On the PC the legacy and PCI boards are supported.
    46
    5 #include <uart.h>
     7This GDB stub glue code is specific to the UART protocol defined in libbchip.
    68
    7 b) declare this variable:   
     9The pc386 BSP has boot command line options to manage GDB support.
    810
    9 extern int BSPConsolePort;
     11a) Find the minor number of the console device:
    1012
    11 c) To start-up GDB, run this:
     13  #include <console_private.h>
    1214
    13  /* Init GDB glue  */
     15  rtems_device_minor_number minor = 0;
    1416
    15   if(BSPConsolePort != BSP_UART_COM2)
    16     {
    17       /*
    18        * If com2 is not used as console use it for
    19        * debugging
    20        */
    21       i386_stub_glue_init(BSP_UART_COM2);
    22     }
    23   else
    24     {
    25       /* Otherwise use com1 */
    26       i386_stub_glue_init(BSP_UART_COM1);
    27     }
     17  if (console_find_console_entry("/dev/com1",
     18                                 strlen("/dev/com1") - 1, &minor) == NULL)
     19    error("driver not found\n");
     20
     21Note, this call is part of the private console API and may change.
     22
     23b) To start GDB stub, run this:
     24
     25  #include <bsp.h>
     26
     27  /* Init GDB glue  */
     28  i386_stub_glue_init(minor);
    2829
    2930  /* Init GDB stub itself */
     
    4041  breakpoint();
    4142
    42 d) This is all you need to do for the target.
     43c) To run use GDB:
    4344
    44 2. Edit cmds: specify path to current directory and device used for debugging
    45    example of cmds is attached below.  Make sure your paths are correct.
    46 3. type 'make'
    47 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> )
    48 5. run 'i396-rtems-gdb --nx --command=./cmds o-pc386/<test>.coff
     45  $ i386-rtems4.12-gdb hello.exe
     46  GNU gdb (GDB) 7.11
     47  Copyright (C) 2016 Free Software Foundation, Inc.
     48  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
     49  This is free software: you are free to change and redistribute it.
     50  There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
     51  and "show warranty" for details.
     52  This GDB was configured as "--host=x86_64-freebsd10.1 --target=i386-rtems4.12".
     53  Type "show configuration" for configuration details.
     54  For bug reporting instructions, please see:
     55  <http://www.gnu.org/software/gdb/bugs/>.
     56  Find the GDB manual and other documentation resources online at:
     57  <http://www.gnu.org/software/gdb/documentation/>.
     58  For help, type "help".
     59  Type "apropos word" to search for commands related to "word"...
     60  Reading symbols from hello.exe...done.
     61  (gdb) target remote /dev/cuaU5
     62  Remote debugging using /dev/cuaU5
     63  0x00103fda in breakpoint () at i386-stub.c:1004
     64  1004          BREAKPOINT ();
     65  (gdb) b Init
     66  Breakpoint 1 at 0x1001e0: file init.c, line 29.
     67  (gdb) c
     68  Continuing.
    4969
    50 =========================== example cmds ==============================
    51 /usr1/rtems/work/rtems/cpukit/ada
    52 /usr1/rtems/work/rtems/cpukit/libblock/src
    53 /usr1/rtems/work/rtems/cpukit/libcsupport/src
    54 /usr1/rtems/work/rtems/cpukit/libfs/src/dosfs
    55 /usr1/rtems/work/rtems/cpukit/libfs/src/imfs
    56 /usr1/rtems/work/rtems/cpukit/libmisc/capture
    57 /usr1/rtems/work/rtems/cpukit/libmisc/cpuuse
    58 /usr1/rtems/work/rtems/cpukit/libmisc/devnull
    59 /usr1/rtems/work/rtems/cpukit/libmisc/dummy
    60 /usr1/rtems/work/rtems/cpukit/libmisc/dumpbuf
    61 /usr1/rtems/work/rtems/cpukit/libmisc/monitor
    62 /usr1/rtems/work/rtems/cpukit/libmisc/mw-fb
    63 /usr1/rtems/work/rtems/cpukit/libmisc/rtmonuse
    64 /usr1/rtems/work/rtems/cpukit/libmisc/serdbg
    65 /usr1/rtems/work/rtems/cpukit/libmisc/shell
    66 /usr1/rtems/work/rtems/cpukit/libmisc/stackchk
    67 /usr1/rtems/work/rtems/cpukit/libmisc/untar
    68 /usr1/rtems/work/rtems/cpukit/libnetworking/arpa
    69 /usr1/rtems/work/rtems/cpukit/libnetworking/kern
    70 /usr1/rtems/work/rtems/cpukit/libnetworking/lib
    71 /usr1/rtems/work/rtems/cpukit/libnetworking/libc
    72 /usr1/rtems/work/rtems/cpukit/libnetworking/machine
    73 /usr1/rtems/work/rtems/cpukit/libnetworking/net
    74 /usr1/rtems/work/rtems/cpukit/libnetworking/netinet
    75 /usr1/rtems/work/rtems/cpukit/libnetworking/nfs
    76 /usr1/rtems/work/rtems/cpukit/libnetworking/rtems
    77 /usr1/rtems/work/rtems/cpukit/libnetworking/sys
    78 /usr1/rtems/work/rtems/cpukit/libnetworking/vm
    79 /usr1/rtems/work/rtems/cpukit/librpc/src/rpc
    80 /usr1/rtems/work/rtems/cpukit/librpc/src/xdr
    81 /usr1/rtems/work/rtems/cpukit/posix/src
    82 /usr1/rtems/work/rtems/cpukit/posix/inline/rtems/posix
    83 /usr1/rtems/work/rtems/cpukit/rtems/inline/rtems/rtems
    84 /usr1/rtems/work/rtems/cpukit/rtems/src
    85 /usr1/rtems/work/rtems/cpukit/sapi/inline/rtems
    86 /usr1/rtems/work/rtems/cpukit/sapi/src
    87 /usr1/rtems/work/rtems/cpukit/score/cpu/i386
    88 /usr1/rtems/work/rtems/cpukit/score/cpu/i386/rtems/score
    89 /usr1/rtems/work/rtems/cpukit/score/src
    90 /usr1/rtems/work/rtems/cpukit/score/inline/rtems/score
    91 set remotebaud 38400
    92 target remote /dev/ttyS1
     70  Breakpoint 1, Init (ignored=1269800) at init.c:29
     71  29      {
     72  (gdb)
     73
     74Pressing ^C works and if running the board should halt when GDB connects.
     75
     76e) Use ser2net to provide reomve access over a network to a board. Install the
     77ser2net package and add a configuration for the port GDB connects to. For
     78example:
     79
     80 0005:raw:0:/dev/cuaU5:115200
     81
     82Start ser2net running then connect GDB using:
     83
     84 (gdb) target remote myhost:30005
  • c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c

    rf57f513d r014292a1  
    11/*
     2 * Copyright (c) 2016.
     3 * Chris Johns <chrisj@rtems.org>
     4 *
    25 * This software is Copyright (C) 1998 by T.sqware - all rights limited
    36 * It is provided in to the public domain "as is", can be freely modified
     
    69 */
    710
    8 #include <rtems/system.h>
    9 #include <rtems/score/cpu.h>
    1011#include <bsp.h>
    1112#include <bsp/irq.h>
    12 #include <uart.h>
    13 #include <assert.h>
     13#include <libchip/serial.h>
     14
     15#include "../../../shared/console_private.h"
    1416
    1517int  putDebugChar(int ch);     /* write a single character      */
    1618int  getDebugChar(void);       /* read and return a single char */
    1719
     20/* Check is any characters received are a ^C */
     21int i386_gdb_uart_ctrl_c_check(void);
     22
     23/* Raw interrupt handler. */
     24void i386_gdb_uart_isr(void);
     25
    1826/* assign an exception handler */
    1927void exceptionHandler(int, void (*handler)(void));
    2028
     29/* User supplied remote debug option. */
     30extern int remote_debug;
     31
     32/* Current uart and port used by the gdb stub */
     33static int          uart_current;
     34static console_tbl* port_current;
     35
     36/*
     37 * Interrupt service routine for all, it does it check whether ^C is received
     38 * if yes it will flip TF bit before returning.
     39 *
     40 * Note: it should be installed as raw interrupt handler.
     41 *
     42 * Warning: I do not like the use of the global data, I am not
     43 *          sure if this is SMP safe.
     44 */
     45int i386_gdb_uart_isr_regsav[4] RTEMS_UNUSED;
     46__asm__ (".p2align 4");
     47__asm__ (".text");
     48__asm__ (".globl i386_gdb_uart_isr");
     49__asm__ ("i386_gdb_uart_isr:");
     50__asm__ ("    pusha");                                       /* Push all */
     51__asm__ ("    call  i386_gdb_uart_ctrl_c_check");            /* Look for ^C */
     52__asm__ ("    movl  %eax, i386_gdb_uart_isr_regsav");        /* Save eax */
     53__asm__ ("    popa");                                        /* Pop all */
     54__asm__ ("    xchgl %eax, i386_gdb_uart_isr_regsav");        /* Exchange eax */
     55__asm__ ("    cmpl  $0, %eax");                              /* 1 == ^C */
     56__asm__ ("    je    i386_gdb_uart_isr_1");                   /* branch if 0 */
     57__asm__ ("    movl  %ebx, i386_gdb_uart_isr_regsav + 4");    /* Save ebx */
     58__asm__ ("    movl  %edx, i386_gdb_uart_isr_regsav + 8");    /* Save edx */
     59__asm__ ("    popl  %ebx");                                  /* Pop eip */
     60__asm__ ("    popl  %edx");                                  /* Pop cs */
     61__asm__ ("    popl  %eax");                                  /* Pop flags */
     62__asm__ ("    orl   $0x100, %eax");                          /* Modify it */
     63__asm__ ("    pushl %eax");                                  /* Push it back */
     64__asm__ ("    pushl %edx");                                  /* Push cs */
     65__asm__ ("    pushl %ebx");                                  /* Push eip */
     66__asm__ ("    movl  i386_gdb_uart_isr_regsav + 4, %ebx");    /* Restore ebx */
     67__asm__ ("    movl  i386_gdb_uart_isr_regsav + 8, %edx");    /* Restore edx */
     68__asm__ ("i386_gdb_uart_isr_1:");
     69__asm__ ("    movb  $0x20, %al");
     70__asm__ ("    outb  %al, $0x20");
     71__asm__ ("    movl  i386_gdb_uart_isr_regsav, %eax");        /* Restore eax */
     72__asm__ ("    iret");                                        /* Done */
     73
     74static int gdb_hello_index;
     75static const char const* gdb_hello = "+";
     76
     77int i386_gdb_uart_ctrl_c_check(void)
     78{
     79  if (port_current) {
     80    int c = 0;
     81    while (c >= 0) {
     82      c = port_current->pDeviceFns->deviceRead(uart_current);
     83      if (c == 3) {
     84        gdb_hello_index = 0;
     85        return 1;
     86      } else if (gdb_hello[gdb_hello_index] == (char) c) {
     87        ++gdb_hello_index;
     88        if (gdb_hello[gdb_hello_index] == '\0') {
     89          gdb_hello_index = 0;
     90          return 1;
     91        }
     92      } else {
     93        gdb_hello_index = 0;
     94      }
     95    }
     96  }
     97  return 0;
     98}
     99
    21100static void
    22101nop(const rtems_raw_irq_connect_data* notused)
     
    30109}
    31110
    32 void BSP_loop(int uart);
    33 
    34 /* Current uart used by gdb stub */
    35 static int uart_current = 0;
     111int i386_stub_glue_uart(void)
     112{
     113  if (port_current == NULL)
     114    return -1;
     115  return uart_current;
     116}
    36117
    37118/*
     
    42123i386_stub_glue_init(int uart)
    43124{
    44   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     125  rtems_device_minor_number minor = (rtems_device_minor_number) uart;
     126
     127  port_current = console_find_console_entry(NULL, 0, &minor);
     128
     129  if (port_current == NULL) {
     130    printk("GDB: invalid minor number for UART\n");
     131    return;
     132  }
    45133
    46134  uart_current = uart;
    47135
    48   /* BSP_uart_init(uart, 38400, CHR_8_BITS, 0, 0, 0);*/
    49   BSP_uart_init(uart, 115200, CHR_8_BITS, 0, 0, 0);
     136  /* Intialise the UART, assuming polled drivers */
     137  port_current->pDeviceFns->deviceInitialize(uart);
    50138}
    51139
     
    73161  rtems_raw_irq_connect_data uart_raw_irq_data;
    74162
    75   assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);
    76 
    77   if(uart_current == BSP_UART_COM1)
    78     {
    79       uart_raw_irq_data.idtIndex = BSP_UART_COM1_IRQ + BSP_IRQ_VECTOR_BASE;
    80     }
    81   else
    82     {
    83       uart_raw_irq_data.idtIndex = BSP_UART_COM2_IRQ + BSP_IRQ_VECTOR_BASE;
    84     }
    85 
    86   if(!i386_get_current_idt_entry(&uart_raw_irq_data))
    87     {
    88       printk("cannot get idt entry\n");
    89       rtems_fatal_error_occurred(1);
    90     }
    91 
    92   if(!i386_delete_idt_entry(&uart_raw_irq_data))
    93     {
    94       printk("cannot delete idt entry\n");
    95       rtems_fatal_error_occurred(1);
    96     }
    97 
    98   uart_raw_irq_data.on  = BSP_uart_on;
    99   uart_raw_irq_data.off = BSP_uart_off;
    100   uart_raw_irq_data.isOn= BSP_uart_isOn;
    101 
    102   /* Install ISR  */
    103   if(uart_current == BSP_UART_COM1)
    104     {
    105       uart_raw_irq_data.idtIndex = BSP_UART_COM1_IRQ + BSP_IRQ_VECTOR_BASE;
    106       uart_raw_irq_data.hdl = BSP_uart_dbgisr_com1;
    107     }
    108   else
    109     {
    110       uart_raw_irq_data.idtIndex = BSP_UART_COM2_IRQ + BSP_IRQ_VECTOR_BASE;
    111       uart_raw_irq_data.hdl = BSP_uart_dbgisr_com2;
    112     }
    113 
    114   if (!i386_set_idt_entry (&uart_raw_irq_data))
    115     {
    116       printk("raw exception handler connection failed\n");
    117       rtems_fatal_error_occurred(1);
    118     }
    119 
    120   /* Enable interrupts */
    121   BSP_uart_intr_ctrl(uart_current, BSP_UART_INTR_CTRL_GDB);
    122 
    123   return;
     163  if (port_current == NULL) {
     164    printk("GDB: no port initialised\n");
     165    return;
     166  }
     167
     168  if ((port_current->ulIntVector == 0) || (port_current->ulIntVector > 16)) {
     169    printk("GDB: no UART interrupt support\n");
     170  }
     171  else {
     172    uart_raw_irq_data.idtIndex = port_current->ulIntVector + BSP_IRQ_VECTOR_BASE;
     173
     174    if (!i386_get_current_idt_entry(&uart_raw_irq_data)) {
     175      printk("GBD: cannot get idt entry\n");
     176      rtems_fatal_error_occurred(1);
     177    }
     178
     179    if (!i386_delete_idt_entry(&uart_raw_irq_data)) {
     180      printk("GDB: cannot delete idt entry\n");
     181      rtems_fatal_error_occurred(1);
     182    }
     183
     184    uart_raw_irq_data.on  = BSP_uart_on;
     185    uart_raw_irq_data.off = BSP_uart_off;
     186    uart_raw_irq_data.isOn= BSP_uart_isOn;
     187
     188    /* Install ISR  */
     189    uart_raw_irq_data.idtIndex = port_current->ulIntVector + BSP_IRQ_VECTOR_BASE;
     190    uart_raw_irq_data.hdl = i386_gdb_uart_isr;
     191
     192    if (!i386_set_idt_entry (&uart_raw_irq_data)) {
     193      printk("GDB: raw exception handler connection failed\n");
     194      rtems_fatal_error_occurred(1);
     195    }
     196
     197    /* Enable interrupts, this is a bit of a hack because we
     198     * have to know the device but there is no other call. */
     199    (*port_current->setRegister)(port_current->ulCtrlPort1, 1, 0x01);
     200  }
    124201}
    125202
     
    127204putDebugChar(int ch)
    128205{
    129   assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);
    130 
    131   BSP_uart_polled_write(uart_current, ch);
    132 
     206  if (port_current != NULL) {
     207    port_current->pDeviceFns->deviceWritePolled(uart_current, ch);
     208  }
    133209  return 1;
    134210}
     
    136212int getDebugChar(void)
    137213{
    138   int val;
    139 
    140   assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);
    141 
    142   val = BSP_uart_polled_read(uart_current);
    143 
    144   return val;
     214  int c = -1;
     215
     216  if (port_current != NULL) {
     217    while (c < 0)
     218      c = port_current->pDeviceFns->deviceRead(uart_current);
     219  }
     220
     221  return c;
    145222}
    146223
     
    153230  if(!i386_get_current_idt_entry(&excep_raw_irq_data))
    154231    {
    155       printk("cannot get idt entry\n");
     232      printk("GDB: cannot get idt entry\n");
    156233      rtems_fatal_error_occurred(1);
    157234    }
     
    159236  if(!i386_delete_idt_entry(&excep_raw_irq_data))
    160237    {
    161       printk("cannot delete idt entry\n");
     238      printk("GDB: cannot delete idt entry\n");
    162239      rtems_fatal_error_occurred(1);
    163240    }
     
    169246
    170247  if (!i386_set_idt_entry (&excep_raw_irq_data)) {
    171       printk("raw exception handler connection failed\n");
     248      printk("GDB: raw exception handler connection failed\n");
    172249      rtems_fatal_error_occurred(1);
    173250    }
  • c/src/lib/libbsp/i386/shared/comm/i386-stub.c

    rf57f513d r014292a1  
    9999#include <string.h>
    100100#include <stdbool.h>
     101
     102#include <bsp.h>
    101103
    102104/*
     
    151153 * these should not be static cuz they can be used outside this module
    152154 */
    153 int registers[NUMREGS];
     155
     156int i386_gdb_registers[NUMREGS];
    154157
    155158#define STACKSIZE 10000
    156 int remcomStack[STACKSIZE / sizeof (int)];
    157 static int *stackPtr = &remcomStack[STACKSIZE / sizeof (int) - 1];
     159int i386_gdb_remcomStack[STACKSIZE / sizeof (int)];
     160int *i386_gdb_stackPtr = &i386_gdb_remcomStack[STACKSIZE / sizeof (int) - 1];
     161
     162
     163static int gdb_connected;
    158164
    159165/***************************  ASSEMBLY CODE MACROS *************************/
     
    169175__asm__ (".globl return_to_prog");
    170176__asm__ ("return_to_prog:");
    171 __asm__ ("        movw registers+44, %ss");
    172 __asm__ ("        movl registers+16, %esp");
    173 __asm__ ("        movl registers+4, %ecx");
    174 __asm__ ("        movl registers+8, %edx");
    175 __asm__ ("        movl registers+12, %ebx");
    176 __asm__ ("        movl registers+20, %ebp");
    177 __asm__ ("        movl registers+24, %esi");
    178 __asm__ ("        movl registers+28, %edi");
    179 __asm__ ("        movw registers+48, %ds");
    180 __asm__ ("        movw registers+52, %es");
    181 __asm__ ("        movw registers+56, %fs");
    182 __asm__ ("        movw registers+60, %gs");
    183 __asm__ ("        movl registers+36, %eax");
     177__asm__ ("        movw i386_gdb_registers+44, %ss");
     178__asm__ ("        movl i386_gdb_registers+16, %esp");
     179__asm__ ("        movl i386_gdb_registers+4, %ecx");
     180__asm__ ("        movl i386_gdb_registers+8, %edx");
     181__asm__ ("        movl i386_gdb_registers+12, %ebx");
     182__asm__ ("        movl i386_gdb_registers+20, %ebp");
     183__asm__ ("        movl i386_gdb_registers+24, %esi");
     184__asm__ ("        movl i386_gdb_registers+28, %edi");
     185__asm__ ("        movw i386_gdb_registers+48, %ds");
     186__asm__ ("        movw i386_gdb_registers+52, %es");
     187__asm__ ("        movw i386_gdb_registers+56, %fs");
     188__asm__ ("        movw i386_gdb_registers+60, %gs");
     189__asm__ ("        movl i386_gdb_registers+36, %eax");
    184190__asm__ ("        pushl %eax"); /* saved eflags */
    185 __asm__ ("        movl registers+40, %eax");
     191__asm__ ("        movl i386_gdb_registers+40, %eax");
    186192__asm__ ("        pushl %eax"); /* saved cs */
    187 __asm__ ("        movl registers+32, %eax");
     193__asm__ ("        movl i386_gdb_registers+32, %eax");
    188194__asm__ ("        pushl %eax"); /* saved eip */
    189 __asm__ ("        movl registers, %eax");
     195__asm__ ("        movl i386_gdb_registers, %eax");
    190196/* use iret to restore pc and flags together so
    191197   that trace flag works right.  */
     
    203209   m-i386v.h is written).  So zero the appropriate areas in registers.  */
    204210#define SAVE_REGISTERS1() \
    205   __asm__ ("movl %eax, registers");                                       \
    206   __asm__ ("movl %ecx, registers+4");                                        \
    207   __asm__ ("movl %edx, registers+8");                                        \
    208   __asm__ ("movl %ebx, registers+12");                                       \
    209   __asm__ ("movl %ebp, registers+20");                                       \
    210   __asm__ ("movl %esi, registers+24");                                       \
    211   __asm__ ("movl %edi, registers+28");                                       \
    212   __asm__ ("movw $0, %ax");                                                          \
    213   __asm__ ("movw %ds, registers+48");                                        \
    214   __asm__ ("movw %ax, registers+50");                                        \
    215   __asm__ ("movw %es, registers+52");                                        \
    216   __asm__ ("movw %ax, registers+54");                                        \
    217   __asm__ ("movw %fs, registers+56");                                        \
    218   __asm__ ("movw %ax, registers+58");                                        \
    219   __asm__ ("movw %gs, registers+60");                                        \
    220   __asm__ ("movw %ax, registers+62");
     211  __asm__ ("movl %eax, i386_gdb_registers");                            \
     212  __asm__ ("movl %ecx, i386_gdb_registers+4");                          \
     213  __asm__ ("movl %edx, i386_gdb_registers+8");                          \
     214  __asm__ ("movl %ebx, i386_gdb_registers+12");                         \
     215  __asm__ ("movl %ebp, i386_gdb_registers+20");                         \
     216  __asm__ ("movl %esi, i386_gdb_registers+24");                         \
     217  __asm__ ("movl %edi, i386_gdb_registers+28");                         \
     218  __asm__ ("movw $0, %ax");                                             \
     219  __asm__ ("movw %ds, i386_gdb_registers+48");                          \
     220  __asm__ ("movw %ax, i386_gdb_registers+50");                          \
     221  __asm__ ("movw %es, i386_gdb_registers+52");                          \
     222  __asm__ ("movw %ax, i386_gdb_registers+54");                          \
     223  __asm__ ("movw %fs, i386_gdb_registers+56");                          \
     224  __asm__ ("movw %ax, i386_gdb_registers+58");                          \
     225  __asm__ ("movw %gs, i386_gdb_registers+60");                          \
     226  __asm__ ("movw %ax, i386_gdb_registers+62");
    221227#define SAVE_ERRCODE() \
    222   __asm__ ("popl %ebx");                                  \
     228  __asm__ ("popl %ebx");                        \
    223229  __asm__ ("movl %ebx, gdb_i386errcode");
    224230#define SAVE_REGISTERS2() \
    225   __asm__ ("popl %ebx"); /* old eip */                                       \
    226   __asm__ ("movl %ebx, registers+32");                                       \
    227   __asm__ ("popl %ebx");         /* old cs */                                        \
    228   __asm__ ("movl %ebx, registers+40");                                       \
    229   __asm__ ("movw %ax, registers+42");                                           \
    230   __asm__ ("popl %ebx");         /* old eflags */                                    \
    231   __asm__ ("movl %ebx, registers+36");                                       \
    232   /* Now that we've done the pops, we can save the stack pointer.");  */   \
    233   __asm__ ("movw %ss, registers+44");                                        \
    234   __asm__ ("movw %ax, registers+46");                                                \
    235   __asm__ ("movl %esp, registers+16");
     231  __asm__ ("popl %ebx"); /* old eip */                                  \
     232  __asm__ ("movl %ebx, i386_gdb_registers+32");                         \
     233  __asm__ ("popl %ebx");         /* old cs */                           \
     234  __asm__ ("movl %ebx, i386_gdb_registers+40");                         \
     235  __asm__ ("movw %ax, i386_gdb_registers+42");                          \
     236  __asm__ ("popl %ebx");         /* old eflags */                       \
     237  __asm__ ("movl %ebx, i386_gdb_registers+36");                         \
     238  /* Now that we've done the pops, we can save the stack pointer.");  */ \
     239  __asm__ ("movw %ss, i386_gdb_registers+44");                          \
     240  __asm__ ("movw %ax, i386_gdb_registers+46");                          \
     241  __asm__ ("movl %esp, i386_gdb_registers+16");
    236242
    237243/* See if mem_fault_routine is set, if so just IRET to that address.  */
     
    450456__asm__ ("           popl %eax");       /* pop off return address     */
    451457__asm__ ("           popl %eax");       /* get the exception number   */
    452 __asm__ ("              movl stackPtr, %esp");  /* move to remcom stack area */
     458__asm__ ("              movl i386_gdb_stackPtr, %esp"); /* move to remcom stack area */
    453459__asm__ ("              pushl %eax");   /* push exception onto stack  */
    454460__asm__ ("              call  handle_exception");       /* this never returns */
     
    509515          if ((remote_debug) && (checksum != xmitcsum))
    510516            {
    511               fprintf (stderr, "bad checksum.  My count = 0x%x, sent=0x%x. buf=%s\n",
    512                        checksum, xmitcsum, buffer);
     517              printk ("bad checksum.  My count = 0x%x, sent=0x%x. buf=%s\n",
     518                      checksum, xmitcsum, buffer);
    513519            }
     520
     521          if (remote_debug) {
     522            printk("GETP: $%s...%s\n", buffer,
     523                   checksum == xmitcsum ? "Ack" : "Nack");
     524          }
    514525
    515526          if (checksum != xmitcsum)
     
    540551putpacket (char *buffer)
    541552{
    542   unsigned char checksum;
    543   int count;
    544   char ch;
    545 
    546553  /*  $<packet info>#<checksum>. */
    547   do
     554  while (true)
    548555    {
     556      unsigned char checksum;
     557      int count;
     558      char ch;
     559
     560      if (remote_debug)
     561        printk("PUTP: $%s", buffer);
     562
    549563      putDebugChar ('$');
    550564      checksum = 0;
     
    563577      putDebugChar (hexchars[checksum % 16]);
    564578
     579      if (remote_debug)
     580        printk("#%c%c...", hexchars[checksum >> 4], hexchars[checksum % 16]);
     581
     582      ch = getDebugChar () & 0x7f;
     583      if (ch == '+') {
     584        if (remote_debug)
     585          printk("Ack\n");
     586        break;
     587      }
     588      if (remote_debug)
     589        printk("Nack(%c)\n", ch);
    565590    }
    566   while ((getDebugChar () & 0x7f) != '+');
    567 
    568591}
    569592
     
    579602{
    580603  if (remote_debug)
    581     fprintf (stderr, format, parm);
     604    printk (format, parm);
    582605}
    583606
     
    765788
    766789  if (remote_debug)
    767     printf ("vector=%d, sr=0x%x, pc=0x%x\n",
     790    printk ("GDB: EXECPTION: vector=%d, sr=0x%x, pc=0x%x\n",
    768791            exceptionVector,
    769             registers[PS],
    770             registers[PC]);
     792            i386_gdb_registers[PS],
     793            i386_gdb_registers[PC]);
    771794
    772795  /* Reply to host that an exception has occurred.  Always return the
     
    780803  *ptr++ = hexchars[ESP];
    781804  *ptr++ = ':';
    782   mem2hex ((char *) &registers[ESP], ptr, REGBYTES, 0);
     805  mem2hex ((char *) &i386_gdb_registers[ESP], ptr, REGBYTES, 0);
    783806  ptr += REGBYTES * 2;
    784807  *ptr++ = ';';
     
    786809  *ptr++ = hexchars[EBP];
    787810  *ptr++ = ':';
    788   mem2hex ((char *) &registers[EBP], ptr, REGBYTES, 0);
     811  mem2hex ((char *) &i386_gdb_registers[EBP], ptr, REGBYTES, 0);
    789812  ptr += REGBYTES * 2;
    790813  *ptr++ = ';';
     
    792815  *ptr++ = hexchars[PC];
    793816  *ptr++ = ':';
    794   mem2hex ((char *) &registers[PC], ptr, REGBYTES, 0);
     817  mem2hex ((char *) &i386_gdb_registers[PC], ptr, REGBYTES, 0);
    795818  ptr += REGBYTES * 2;
    796819  *ptr++ = ';';
     
    798821  *ptr = '\0';
    799822
    800   putpacket (remcomOutBuffer);
     823  if (gdb_connected)
     824    putpacket (remcomOutBuffer);
    801825
    802826  while (1 == 1)
     
    805829      remcomOutBuffer[0] = 0;
    806830      getpacket (remcomInBuffer);
     831      gdb_connected = 1;
    807832      switch (remcomInBuffer[0])
    808833        {
     
    813838          remcomOutBuffer[3] = 0;
    814839          break;
    815         case 'd':
     840        case 'd': /* remove */
    816841          remote_debug = !(remote_debug);       /* toggle debug flag */
    817842          break;
    818843        case 'g':               /* return the value of the CPU registers */
    819           mem2hex ((char *) registers, remcomOutBuffer, NUMREGBYTES, 0);
     844          mem2hex ((char *) i386_gdb_registers, remcomOutBuffer, NUMREGBYTES, 0);
    820845          break;
    821846        case 'G':               /* set the value of the CPU registers - return OK */
    822           hex2mem (&remcomInBuffer[1], (char *) registers, NUMREGBYTES, 0);
     847          hex2mem (&remcomInBuffer[1], (char *) i386_gdb_registers, NUMREGBYTES, 0);
    823848          strcpy (remcomOutBuffer, "OK");
    824849          break;
     
    829854              && *ptr++ == '=')
    830855            {
    831               hex2mem (ptr, (char *) &registers[reg], REGBYTES, 0);
     856              hex2mem (ptr, (char *) &i386_gdb_registers[reg], REGBYTES, 0);
    832857              strcpy (remcomOutBuffer, "OK");
    833858            }
     
    903928          ptr = &remcomInBuffer[1];
    904929          if (hexToInt (&ptr, &addr))
    905             registers[PC] = addr;
     930            i386_gdb_registers[PC] = addr;
    906931
    907932          /* clear the trace bit */
    908           registers[PS] &= 0xfffffeff;
     933          i386_gdb_registers[PS] &= 0xfffffeff;
    909934
    910935          /* set the trace bit if we're stepping */
    911936          if (remcomInBuffer[0] == 's')
    912             registers[PS] |= 0x100;
     937            i386_gdb_registers[PS] |= 0x100;
    913938
    914939          _returnFromException ();      /* this is a jump */
    915 
    916940          break;
    917941
     
    919943        case 'D':
    920944          putpacket (remcomOutBuffer);
    921           registers[PS] &= 0xfffffeff;
     945          i386_gdb_registers[PS] &= 0xfffffeff;
    922946          _returnFromException ();      /* this is a jump */
    923 
    924947          break;
    925948
    926949          /* kill the program */
    927950        case 'k':               /* do nothing */
     951          bsp_reset();
     952          continue;
     953
     954        default:
    928955          break;
    929956        }                       /* switch */
     
    939966set_debug_traps (void)
    940967{
    941   stackPtr = &remcomStack[STACKSIZE / sizeof (int) - 1];
     968  i386_gdb_stackPtr = &i386_gdb_remcomStack[STACKSIZE / sizeof (int) - 1];
    942969
    943970  exceptionHandler (0, _catchException0);
  • c/src/lib/libbsp/shared/console.c

    rf57f513d r014292a1  
    3333rtems_device_minor_number   Console_Port_Minor  = 0;
    3434static bool                 console_initialized = false;
     35
     36/*
     37 *  console_find_console_entry
     38 *
     39 *  This method is used to search the console entries for a
     40 *  specific device entry.
     41 */
     42console_tbl* console_find_console_entry(
     43  const char                *match,
     44  size_t                     length,
     45  rtems_device_minor_number *match_minor
     46)
     47{
     48  rtems_device_minor_number  minor;
     49
     50  /*
     51   * The the match name is NULL get the minor number entry.
     52   */
     53  if (match == NULL) {
     54    if (*match_minor < Console_Port_Count)
     55      return Console_Port_Tbl[*match_minor];
     56    return NULL;
     57  }
     58
     59  for (minor=0; minor < Console_Port_Count ; minor++) {
     60    console_tbl  *cptr = Console_Port_Tbl[minor];
     61
     62    /*
     63     * Console table entries include /dev/ prefix, device names passed
     64     * in on command line do not.
     65     */
     66    if ( !strncmp( cptr->sDeviceName, match, length ) ) {
     67      *match_minor = minor;
     68      return cptr;
     69    }
     70  }
     71
     72  return NULL;
     73}
    3574
    3675/*
     
    279318   * Console_Port_Data.
    280319   */
    281   if ( !Console_Port_Tbl ) {
    282     console_initialize_data();
    283   }
     320  console_initialize_data();
    284321
    285322  /*
  • c/src/lib/libbsp/shared/console_private.h

    rf57f513d r014292a1  
    4242
    4343/**
     44 *  @brief console_find_console_entry
     45 *
     46 *  This method is used to search the console entries for a
     47 *  specific device entry and return it. If match is NULL the
     48 *  minor number provided is matched.
     49 */
     50console_tbl* console_find_console_entry(
     51  const char                *match,
     52  size_t                     length,
     53  rtems_device_minor_number *match_minor
     54);
     55
     56/**
    4457 *  @brief console_initialize_data
    4558 *
Note: See TracChangeset for help on using the changeset viewer.