Ejemplo n.º 1
0
/* console_write --
 *     Write to the console device
 *
 * PARAMETERS:
 *     major - major device number for console devices
 *     minor - minor device number for console
 *     arg - device write argument
 *
 * RETURNS:
 *     RTEMS error code
 */
rtems_device_driver
console_write(rtems_device_major_number major,
        rtems_device_minor_number minor,
        void *arg)
{
    switch (console_mode)
    {
        case CONSOLE_MODE_POLL:
        case CONSOLE_MODE_INT:
                return rtems_termios_write (arg);
        case CONSOLE_MODE_RAW:
        {
            rtems_libio_rw_args_t *argp = arg;
            char cr = '\r';
            char *buf = argp->buffer;
            int count = argp->count;
            int i;

            for (i = 0; i < count; i++)
            {
                if (*buf == '\n')
                    sh4uart_poll_write(&sh4_uarts[minor], &cr, 1);
                sh4uart_poll_write(&sh4_uarts[minor], buf, 1);
                buf++;
            }
            argp->bytes_moved = count;
            return RTEMS_SUCCESSFUL;
        }
#ifdef SH4_WITH_IPL
        case CONSOLE_MODE_IPL:
        {
            rtems_libio_rw_args_t *argp = arg;
            char *buf = argp->buffer;
            int count = argp->count;
            ipl_console_poll_write(minor, buf, count);
            argp->bytes_moved = count;
            return RTEMS_SUCCESSFUL;
        }
#endif
        default: /* Unreachable */
            return RTEMS_NOT_DEFINED;
    }
}
Ejemplo n.º 2
0
/*
 * sh4uart_init --
 * This function verifies the input parameters and perform initialization
 *     of the SH-4 on-chip UART descriptor structure.
 *
 * PARAMETERS:
 *     uart - pointer to the UART channel descriptor structure
 *     tty - pointer to termios structure
 *     chn - channel number (SH4_SCI/SH4_SCIF -- 1/2)
 *     int_driven - interrupt-driven (1) or polled (0) I/O mode
 *
 * RETURNS:
 *     RTEMS_SUCCESSFUL if all parameters are valid, or error code
 */
rtems_status_code
sh4uart_init(sh4uart *uart, void *tty, int chn, int int_driven)
{
  if (uart == NULL)
    return RTEMS_INVALID_ADDRESS;

  if ((chn != SH4_SCI) && (chn != SH4_SCIF))
    return RTEMS_INVALID_NUMBER;

  uart->chn = chn;
  uart->tty = tty;
  uart->int_driven = int_driven;

#if 0
  sh4uart_poll_write(uart, "init", 4);
#endif
  return RTEMS_SUCCESSFUL;
}
Ejemplo n.º 3
0
/* console_poll_write --
 *     wrapper for polling mode write function
 *
 * PARAMETERS:
 *     minor - minor device number
 *     buf - output buffer
 *     len - output buffer length
 *
 * RETURNS:
 *     result code
 */
static ssize_t
console_poll_write(int minor, const char *buf, size_t len)
{
        return sh4uart_poll_write(&sh4_uarts[minor], buf, len);
}