示例#1
0
/*
 * Initialize glue code linking i386-stub with the rest of
 * the system
 */
void
i386_stub_glue_init(int uart)
{
  rtems_device_minor_number minor = (rtems_device_minor_number) uart;

  port_current = console_find_console_entry(NULL, 0, &minor);

  if (port_current == NULL) {
    printk("GDB: invalid minor number for UART\n");
    return;
  }

  uart_current = uart;

  /* Intialise the UART, assuming polled drivers */
  port_current->pDeviceFns->deviceInitialize(uart);
}
示例#2
0
static bool parse_printk_or_console(
  const char                *param,
  rtems_device_minor_number *minor_out
)
{
  static const char         *opt;
  const char                *option;
  const char                *comma;
  size_t                     length;
  size_t                     index;
  rtems_device_minor_number  minor;
  console_tbl               *conscfg;

  /*
   * Check the command line for the type of mode the console is.
   */
  opt = bsp_cmdline_arg(param);
  if ( !opt ) {
    return false;
  }

  /*
   * Fine the length, there can be more command line visible.
   */
  length = 0;
  while ((opt[length] != ' ') && (opt[length] != '\0')) {
    ++length;
    if (length > NAME_MAX) {
      printk("invalid option (%s): too long\n", param);
      return false;
    }
  }

  /*
   * Only match up to a comma or NULL
   */
  index = 0;
  while ((opt[index] != '=') && (index < length)) {
    ++index;
  }

  if (opt[index] != '=') {
    printk("invalid option (%s): no equals\n", param);
    return false;
  }

  ++index;
  option = &opt[index];

  while ((opt[index] != ',') && (index < length)) {
    ++index;
  }

  if (opt[index] == ',')
    comma = &opt[index];
  else
    comma = NULL;

  length = &opt[index] - option;

  conscfg = console_find_console_entry( option, length, &minor );
  if ( conscfg == NULL ) {
    return false;
  }

  *minor_out = minor;
  if (comma) {
    option = comma + 1;
    if (strncmp (option, "115200", sizeof ("115200") - 1) == 0)
      conscfg->pDeviceParams = (void *)115200;
    else if (strncmp (option, "57600", sizeof ("57600") - 1) == 0)
      conscfg->pDeviceParams = (void *)57600;
    else if (strncmp (option, "38400", sizeof ("38400") - 1) == 0)
      conscfg->pDeviceParams = (void *)38400;
    else if (strncmp (option, "19200", sizeof ("19200") - 1) == 0)
      conscfg->pDeviceParams = (void *)19200;
    else if (strncmp (option, "9600", sizeof ("9600") - 1) == 0)
      conscfg->pDeviceParams = (void *)9600;
    else if (strncmp (option, "4800", sizeof ("4800") - 1) == 0)
      conscfg->pDeviceParams = (void *)4800;
  }

  return true;
}
示例#3
0
文件: gdb_select.c 项目: AoLaD/rtems
void pc386_parse_gdb_arguments(void)
{
  static const char *opt;

  /*
   * Check the command line to see if com1-com4 are disabled.
   */
  opt = bsp_cmdline_arg("--gdb=");
  if ( opt ) {
    const char                *option;
    const char                *comma;
    size_t                     length;
    size_t                     index;
    rtems_device_minor_number  minor;
    uint32_t                   baudrate = 115200;
    bool                       halt = false;
    console_tbl               *port;

    /*
     * Fine the length, there can be more command line visible.
     */
    length = 0;
    while ((opt[length] != ' ') && (opt[length] != '\0')) {
      ++length;
      if (length > NAME_MAX) {
        printk("invalid option (--gdb): too long\n");
        return;
      }
    }

    /*
     * Only match up to a comma or NULL
     */
    index = 0;
    while ((opt[index] != '=') && (index < length)) {
      ++index;
    }

    if (opt[index] != '=') {
      printk("invalid option (--gdb): no equals\n");
      return;
    }

    ++index;
    option = &opt[index];

    while ((opt[index] != ',') && (index < length)) {
      ++index;
    }

    if (opt[index] == ',')
      comma = &opt[index];
    else
      comma = NULL;

    length = &opt[index] - option;

    port = console_find_console_entry( option, length, &minor );

    if ( port == NULL ) {
      printk("invalid option (--gdb): port not found\n");
      return;
    }

    if (comma) {
      option = comma + 1;
      baudrate = strtoul(option, 0, 10);
      switch (baudrate) {
        case 115200:
        case 57600:
        case 38400:
        case 19200:
        case 9600:
        case 4800:
          port->pDeviceParams = (void*) baudrate;
          BSPBaseBaud = baudrate; /* REMOVE ME */
          break;
        default:
          printk("invalid option (--gdb): bad baudrate\n");
          return;
      }
    }

    /*
     * Provide a probe that fails so the device is not part of termios. All
     * functions are polling.
     */
    port->deviceProbe = gdb_port_probe;
    port->pDeviceFns = &ns16550_fns_polled;

    opt = bsp_cmdline_arg("--gdb-remote-debug");
    if ( opt ) {
      remote_debug = 1;
    }

    opt = bsp_cmdline_arg("--gdb-break");
    if ( opt ) {
      halt = true;
    }

    printk("GDB stub: enable %s%s%s\n",
           port->sDeviceName,
           remote_debug ? ", remote-debug" : "",
           halt ? ", halting" : "");

    i386_stub_glue_init(minor);
    set_debug_traps();
    i386_stub_glue_init_breakin();

    if ( halt ) {
      printk("GDB stub: waiting for remote connection..\n");
      breakpoint();
    }
  }
}