Beispiel #1
0
/*
 * Open the device
 */
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void *arg
)
{
#if UARTS_IO_MODE == 1  /* RTEMS interrupt-driven I/O with termios */
  /* Used to track termios private data for callbacks */
  extern struct rtems_termios_tty *ttyp[];
  rtems_libio_open_close_args_t *args = arg;

  static const rtems_termios_callbacks intrCallbacks = {
    NULL,                       	/* firstOpen */
    NULL,                       	/* lastClose */
    NULL,                         /* pollRead */
    m8xx_uart_write,       	      /* write */
    m8xx_uart_setAttributes,    	/* setAttributes */
    NULL,                       	/* stopRemoteTx */
    NULL,                       	/* startRemoteTx */
    1                           	/* outputUsesInterrupts */
  };
#else
#if (UARTS_USE_TERMIOS == 1) && (UARTS_IO_MODE != 1)
  static const rtems_termios_callbacks pollCallbacks = {
    NULL,                       	/* firstOpen */
    NULL,                       	/* lastClose */
    m8xx_uart_pollRead,        	  /* pollRead */
    m8xx_uart_pollWrite,       	  /* write */
    m8xx_uart_setAttributes,      /* setAttributes */
    NULL,                       	/* stopRemoteTx */
    NULL,                       	/* startRemoteTx */
    0                           	/* outputUsesInterrupts */
  };
#endif

#endif

  rtems_status_code sc;

  if ( minor > NUM_PORTS-1 )
    return RTEMS_INVALID_NUMBER;

#if UARTS_USE_TERMIOS == 1

#if UARTS_IO_MODE == 1  /* RTEMS interrupt-driven I/O with termios */
  sc = rtems_termios_open( major, minor, arg, &intrCallbacks );
  ttyp[minor] = args->iop->data1;        /* Keep cookie returned by termios_open */
#else                     /* RTEMS polled I/O with termios */
  sc = rtems_termios_open( major, minor, arg, &pollCallbacks );
#endif

#else /* UARTS_USE_TERMIOS != 1 */
  /* no termios -- default to polled I/O */
  sc = RTEMS_SUCCESSFUL;
#endif /* UARTS_USE_TERMIOS != 1 */

  return sc;

}
Beispiel #2
0
/******************************************************
  Name: console_open
  Input parameters: channel #, arg
  Output parameters: -
  Description: open the device
 *****************************************************/
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
 rtems_status_code sc = 0;

 static const rtems_termios_callbacks intrCallbacks = {
		NULL,			/* firstOpen */
		NULL,			/* lastClose */
		NULL,			/* pollRead */
		InterruptWrite,		/* write */
		SetAttributes,		/* setAttributes */
		NULL,			/* stopRemoteTx */
		NULL,			/* startRemoteTx */
		1			/* outputUsesInterrupts */
 };

 static const rtems_termios_callbacks pollCallbacks = {
		NULL,			/* firstOpen */
		NULL,			/* lastClose */
		dbugRead,		/* pollRead */
		dbugWrite,		/* write */
		SetAttributes,		/* setAttributes */
		NULL,			/* stopRemoteTx */
		NULL,			/* startRemoteTx */
		0			/* outputUsesInterrupts */
 };

 if (minor==UART_CHANNEL_A) {
	if (USE_INTERRUPTS_A) {
		rtems_libio_open_close_args_t *args = arg;

		sc |= rtems_termios_open (major, minor, arg, &intrCallbacks);
		ttypA = args->iop->data1;
	}
	else {
		sc |= rtems_termios_open (major, minor, arg, &pollCallbacks);
	}
 }

 else if (minor==UART_CHANNEL_B) {
	if (USE_INTERRUPTS_B) {
		rtems_libio_open_close_args_t *args = arg;

		sc |= rtems_termios_open (major, minor, arg, &intrCallbacks);
		ttypB = args->iop->data1;
	}
	else {
		sc |= rtems_termios_open (major, minor, arg, &pollCallbacks);
	}
 }

 else return RTEMS_INVALID_NUMBER;

 return sc;
}
Beispiel #3
0
/* PAGE
 *
 *  console_open
 *
 *  open a port as a termios console.
 *
 */
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  int               port = minor;
#if (CONSOLE_USE_INTERRUPTS)
  rtems_libio_open_close_args_t *args = arg;
  static const rtems_termios_callbacks intrCallbacks = {
    NULL,                       /* firstOpen */
    NULL,                       /* lastClose */
    NULL,                       /* pollRead */
    console_write_support,      /* write */
    NULL,                       /* setAttributes */
    NULL,                       /* stopRemoteTx */
    NULL,                       /* startRemoteTx */
    1                           /* outputUsesInterrupts */
  };
#else
  static const rtems_termios_callbacks pollCallbacks = {
    NULL,                       /* firstOpen */
    NULL,                       /* lastClose */
    console_inbyte_nonblocking, /* pollRead */
    console_write_support,      /* write */
    NULL,                       /* setAttributes */
    NULL,                       /* stopRemoteTx */
    NULL,                       /* startRemoteTx */
    0                           /* outputUsesInterrupts */
  };
#endif

  /*
   * Verify the minor number is valid.
   */
  if (minor < 0)
    return RTEMS_INVALID_NUMBER;

  if ( port > NUM_Z85C30_PORTS )
     return RTEMS_INVALID_NUMBER;

  /*
   *  open the port as a termios console driver.
   */

#if (CONSOLE_USE_INTERRUPTS)
   sc = rtems_termios_open( major, minor, arg, &intrCallbacks );

   Ports_85C30[ minor ].Protocol->console_termios_data = args->iop->data1;
#else
   sc = rtems_termios_open( major, minor, arg, &pollCallbacks );
#endif

  return sc;
}
Beispiel #4
0
/*
 * Open the device
 */
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void *arg
)
{
  rtems_status_code sc;

  if ( minor > NUM_PORTS - 1 )
    return RTEMS_INVALID_NUMBER;

  #if (UARTS_USE_TERMIOS == 1)
  {
    #if (UARTS_IO_MODE == 1)    /* RTEMS interrupt-driven I/O with termios */

      static const rtems_termios_callbacks callbacks = {
        m5xx_uart_firstOpen,           	/* firstOpen */
        m5xx_uart_lastClose,           	/* lastClose */
        NULL,                           /* pollRead */
        m5xx_uart_write,       	        /* write */
        m5xx_uart_setAttributes,    	/* setAttributes */
        NULL,                       	/* stopRemoteTx */
        NULL,                       	/* startRemoteTx */
        TERMIOS_IRQ_DRIVEN           	/* outputUsesInterrupts */
      };
      sc = rtems_termios_open( major, minor, arg, &callbacks );

    #else /* UARTS_IO_MODE != 1	*/	/* RTEMS polled I/O with termios */

      static const rtems_termios_callbacks callbacks = {
        m5xx_uart_firstOpen,           	/* firstOpen */
        m5xx_uart_lastClose,           	/* lastClose */
        m5xx_uart_pollRead,             /* pollRead */
        m5xx_uart_pollWrite,            /* write */
        m5xx_uart_setAttributes,        /* setAttributes */
        NULL,                           /* stopRemoteTx */
        NULL,                       	/* startRemoteTx */
        TERMIOS_POLLED                 	/* outputUsesInterrupts */
      };
      sc = rtems_termios_open( major, minor, arg, &callbacks );

    #endif

    return sc;
  }

  #else		/* no termios -- default to polled I/O */
  {
    sc = RTEMS_SUCCESSFUL;
  }
  #endif

  return sc;
}
rtems_device_driver termios_test_driver_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  static const rtems_termios_callbacks Callbacks = {
    NULL,                                    /* firstOpen */
    NULL,                                    /* lastClose */
    termios_test_driver_inbyte_nonblocking,  /* pollRead */
    termios_test_driver_write_support,       /* write */
    termios_test_driver_set_attributes,      /* setAttributes */
    NULL,                                    /* stopRemoteTx */
    NULL,                                    /* startRemoteTx */
    TERMIOS_TASK_DRIVEN                      /* outputUsesInterrupts */
  };

  if ( minor > 2 ) {
    puts( "ERROR - Termios_testdriver - only 1 minor supported" );
    rtems_test_exit(0);
  }

  sc = rtems_termios_open (major, minor, arg, &Callbacks);

  return RTEMS_SUCCESSFUL;
}
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  static const rtems_termios_callbacks pollCallbacks = {
    NULL,                        /* firstOpen */
    NULL,                        /* lastClose */
    console_inbyte_nonblocking,  /* pollRead */
    console_write_support,       /* write */
    NULL,                        /* setAttributes */
    NULL,                        /* stopRemoteTx */
    NULL,                        /* startRemoteTx */
    0                            /* outputUsesInterrupts */
  };

  assert( minor <= 1 );
  if ( minor > 2 )
    return RTEMS_INVALID_NUMBER;

  sc = rtems_termios_open (major, minor, arg, &pollCallbacks );

  return RTEMS_SUCCESSFUL;
}
rtems_device_driver console_open(
	rtems_device_major_number	major,
	rtems_device_minor_number	minor,
	void				*arg)
{
	rtems_status_code status;
	struct termios term;

	if ((minor >= CONSOLE_MAX) || !cons[minor].dev)
		return RTEMS_INVALID_NUMBER;

	status = rtems_termios_open(
			major,
			(int)cons[minor].dev,
			arg,
			cons[minor].dev->callbacks);

	/* Inherit UART hardware parameters from bootloader on system console */
	if ((status == RTEMS_SUCCESSFUL) && (cons[minor].flags & FLAG_SYSCON) &&
	    (cons[minor].dev->ops.get_uart_attrs != NULL)) {
		if (tcgetattr(STDIN_FILENO, &term) >= 0) {
			cons[minor].dev->ops.get_uart_attrs(cons[minor].dev,
								&term);
			term.c_oflag |= ONLCR;
			tcsetattr(STDIN_FILENO, TCSANOW, &term);
		}
	}

	return status;
}
Beispiel #8
0
/**
 *  @brief Console device driver OPEN entry point
 *
 *  @param  major diver major number
 *  @param  minor driver minor mumber
 *  @param  *arg pointer to parameters
 *  @return status code
 */
rtems_device_driver
console_open(rtems_device_major_number major,
             rtems_device_minor_number minor,
             void                      *arg)
{
  rtems_status_code              status;
  static rtems_termios_callbacks cb =
  {
    console_first_open,         /* firstOpen     */
    console_last_close,         /* lastClose     */
    gba_pollRead,               /* pollRead      */
    gba_write,                  /* write         */
    gba_setAttributes,          /* setAttributes */
    NULL,                       /* stopRemoteTx  */
    NULL,                       /* startRemoteTx */
    TERMIOS_POLLED              /* 1 = outputUsesInterrupts */
  };

  status = rtems_termios_open (major, minor, arg, &cb);

  if (status != RTEMS_SUCCESSFUL) {
      printk("Error openning console device\n");
      return status;
  }

  return RTEMS_SUCCESSFUL;
}
Beispiel #9
0
/*
 * serial_mouse - device driver OPEN entry point
 */
rtems_device_driver
serial_mouse_open(rtems_device_major_number major,
                rtems_device_minor_number minor,
                void                      *arg)
{
  rtems_status_code  status;
  static rtems_termios_callbacks cb =
  {
    NULL,	              /* firstOpen */
    serial_mouse_last_close,       /* lastClose */
    NULL,                          /* poll read  */
    BSP_WRITE_FUNC,        /* write */
    serial_mouse_conSetAttr,	     /* setAttributes */
    NULL,	              /* stopRemoteTx */
    NULL,	              /* startRemoteTx */
    1		              /* outputUsesInterrupts */
  };

  status = rtems_termios_open( major, minor, arg, &cb );
  if(status != RTEMS_SUCCESSFUL)
  {
     printk("Error openning serial_mouse device\n");
     return status;
  }

  /*
   * Pass data area info down to driver
   */
  BSP_uart_termios_set( BSP_UART_PORT,
                       ((rtems_libio_open_close_args_t *)arg)->iop->data1 );
  /* Enable interrupts  on channel */
  BSP_uart_intr_ctrl( BSP_UART_PORT, BSP_UART_INTR_CTRL_TERMIOS);
  return RTEMS_SUCCESSFUL;
}
Beispiel #10
0
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void  *arg
)
{
  return rtems_termios_open(major, minor, arg, &mmconsole_callbacks);
}
Beispiel #11
0
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
#if (CONSOLE_USE_INTERRUPTS)
  rtems_libio_open_close_args_t *args = arg;
  static const rtems_termios_callbacks intrCallbacks = {
    NULL,                        /* firstOpen */
    NULL,                        /* lastClose */
    NULL,                        /* pollRead */
    console_write_support,       /* write */
    NULL,                        /* setAttributes */
    NULL,                        /* stopRemoteTx */
    NULL,                        /* startRemoteTx */
    0                            /* outputUsesInterrupts */
  };
#else
  static const rtems_termios_callbacks pollCallbacks = {
    NULL,                        /* firstOpen */
    NULL,                        /* lastClose */
    console_inbyte_nonblocking,  /* pollRead */
    console_write_support,       /* write */
    NULL,                        /* setAttributes */
    NULL,                        /* stopRemoteTx */
    NULL,                        /* startRemoteTx */
    0                            /* outputUsesInterrupts */
  };
#endif

  assert( minor <= 1 );
  if ( minor > 2 )
    return RTEMS_INVALID_NUMBER;

#if (CONSOLE_USE_INTERRUPTS)
  sc = rtems_termios_open (major, minor, arg, &intrCallbacks);

  console_termios_data[ minor ] = args->iop->data1;
#else
  sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
#endif

  return RTEMS_SUCCESSFUL;
}
Beispiel #12
0
/* console_open --
 *     Open console device driver. Pass appropriate termios callback
 *     functions to termios library.
 *
 * PARAMETERS:
 *     major - major device number for console devices
 *     minor - minor device number for console
 *     arg - device opening argument
 *
 * RETURNS:
 *     RTEMS error code
 */
rtems_device_driver
console_open(rtems_device_major_number major,
        rtems_device_minor_number minor,
        void *arg)
{
    static const rtems_termios_callbacks intr_callbacks = {
        console_first_open,        /* firstOpen */
        console_last_close,        /* lastClose */
        NULL,                      /* pollRead */
        console_interrupt_write,   /* write */
        console_set_attributes,    /* setAttributes */
        console_stop_remote_tx,    /* stopRemoteTx */
        console_start_remote_tx,   /* startRemoteTx */
        1                          /* outputUsesInterrupts */
    };
    static const rtems_termios_callbacks poll_callbacks = {
        console_first_open,        /* firstOpen */
        console_last_close,        /* lastClose */
        console_poll_read,         /* pollRead */
        console_poll_write,        /* write */
        console_set_attributes,    /* setAttributes */
        console_stop_remote_tx,    /* stopRemoteTx */
        console_start_remote_tx,   /* startRemoteTx */
        0                          /* outputUsesInterrupts */
    };

    switch (console_mode)
    {
        case CONSOLE_MODE_RAW:
        case CONSOLE_MODE_IPL:
            return RTEMS_SUCCESSFUL;

        case CONSOLE_MODE_INT:
            return rtems_termios_open(major, minor, arg, &intr_callbacks);

        case CONSOLE_MODE_POLL:
            return rtems_termios_open(major, minor, arg, &poll_callbacks);

        default:
            rtems_fatal_error_occurred(0xC07A1310);
    }

    return RTEMS_INTERNAL_ERROR;
}
/*-------------------------------------------------------------------------+
| Console device driver OPEN entry point
+--------------------------------------------------------------------------*/
rtems_device_driver
console_open(rtems_device_major_number major,
                rtems_device_minor_number minor,
                void                      *arg)
{
  rtems_status_code              status;
  static rtems_termios_callbacks cb =
#if defined(USE_POLLED_IO)
  { 
     NULL,                              /* firstOpen */
     NULL,                              /* lastClose */
     NULL,                              /* pollRead */
     BSP_uart_termios_write_polled,     /* write */
     conSetAttr,                        /* setAttributes */
     NULL,                              /* stopRemoteTx */
     NULL,                              /* startRemoteTx */
     0                                  /* outputUsesInterrupts */
  };
#else
  { 
     console_first_open,                /* firstOpen */
     console_last_close,                /* lastClose */
     NULL,                              /* pollRead */
     BSP_uart_termios_write_com,        /* write */
     conSetAttr,                        /* setAttributes */
     NULL,                              /* stopRemoteTx */
     NULL,                              /* startRemoteTx */
     1                                  /* outputUsesInterrupts */
  };
#endif

  status = rtems_termios_open (major, minor, arg, &cb);

  if(status != RTEMS_SUCCESSFUL)
    {
      printk("Error opening console device\n");
      return status;
    }

  return RTEMS_SUCCESSFUL;
}

/*-------------------------------------------------------------------------+
| Console device driver CLOSE entry point
+--------------------------------------------------------------------------*/
rtems_device_driver
console_close(rtems_device_major_number major,
              rtems_device_minor_number minor,
              void                      *arg)
{
  rtems_device_driver res = RTEMS_SUCCESSFUL;

  res =  rtems_termios_close (arg);

  return res;
} /* console_close */
Beispiel #14
0
/*
 * Open the device
 */
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  static const rtems_termios_callbacks intrCallbacks = {
    smc1Initialize,    /* firstOpen */
    NULL,      /* lastClose */
    NULL,      /* pollRead */
    smc1InterruptWrite,  /* write */
    smc1SetAttributes,  /* setAttributes */
    NULL,      /* stopRemoteTx */
    NULL,      /* startRemoteTx */
    1      /* outputUsesInterrupts */
  };
  static const rtems_termios_callbacks pollCallbacks = {
    smc1Initialize,    /* firstOpen */
    NULL,      /* lastClose */
    smc1PollRead,    /* pollRead */
    smc1PollWrite,    /* write */
    smc1SetAttributes,  /* setAttributes */
    NULL,      /* stopRemoteTx */
    NULL,      /* startRemoteTx */
    0      /* outputUsesInterrupts */
  };

  /*
   * Do generic termios initialization
   */
  if (m360_smc1_interrupt) {
    rtems_libio_open_close_args_t *args = arg;

    sc = rtems_termios_open (major, minor, arg, &intrCallbacks);
    smc1ttyp = args->iop->data1;
  }
  else {
    sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
  }
  return sc;
}
static
rtems_device_driver my_pty_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  sc = rtems_termios_open(major,minor,arg,pty_get_termios_handlers(FALSE));
  return sc;
}
Beispiel #16
0
/*
 * Open the device
 */
rtems_device_driver console_open(
				 rtems_device_major_number major,
				 rtems_device_minor_number minor,
				 void                    * arg
				 )
{
  rtems_status_code status;
  int chan = minor;
  rtems_libio_open_close_args_t *args = (rtems_libio_open_close_args_t *)arg;
  static const rtems_termios_callbacks interruptCallbacks = {
    NULL,		/* firstOpen */
    NULL,		/* lastClose */
    NULL,	        /* pollRead */
    sccInterruptWrite,	/* write */
    sccSetAttributes,	/* setAttributes */
    NULL,		/* stopRemoteTx */
    NULL,		/* startRemoteTx */
    TERMIOS_IRQ_DRIVEN	/* outputUsesInterrupts */
  };
  static const rtems_termios_callbacks pollCallbacks = {
    NULL,		/* firstOpen */
    NULL,		/* lastClose */
    sccPollRead,	/* pollRead */
    sccPollWrite,	/* write */
    sccSetAttributes,	/* setAttributes */
    NULL,		/* stopRemoteTx */
    NULL,		/* startRemoteTx */
    0			/* outputUsesInterrupts */
  };

  if (m8xx_scc_mode[chan] == TERMIOS_IRQ_DRIVEN) {
    status = rtems_termios_open (major, minor, arg, &interruptCallbacks);
    sccttyp[chan] = args->iop->data1;
  }
  else {
    status = rtems_termios_open (major, minor, arg, &pollCallbacks);
    sccttyp[chan] = args->iop->data1;
  }
  return status;
}
Beispiel #17
0
/*
 * TTY2 device driver OPEN entry point
 */
rtems_device_driver
tty2_open(rtems_device_major_number major,
                rtems_device_minor_number minor,
                void                      *arg)
{
  rtems_status_code              status;
#ifndef USE_TASK_DRIVEN
  static rtems_termios_callbacks cb =
  {
    NULL,                        /* firstOpen */
    tty2_last_close,             /* lastClose */
    NULL,                        /* poll read */
    BSP_uart_termios_write_com2, /* write */
    tty2_conSetAttr,             /* setAttributes */
    NULL,                        /* stopRemoteTx */
    NULL,                        /* startRemoteTx */
    TERMIOS_IRQ_DRIVEN           /* outputUsesInterrupts */
  };
#else
  static rtems_termios_callbacks cb =
  {
    NULL,                        /* firstOpen */
    NULL,                        /* lastClose */
    BSP_uart_termios_read_com2,  /* poll read */
    BSP_uart_termios_write_com2, /* write */
    tty2_conSetAttr,             /* setAttributes */
    NULL,                        /* stopRemoteTx */
    NULL,                        /* startRemoteTx */
    TERMIOS_TASK_DRIVEN          /* outputUsesInterrupts */
  };
#endif

  status = rtems_termios_open (major, minor, arg, &cb);
  if(status != RTEMS_SUCCESSFUL)
  {
     printk("Error openning tty1 device\n");
     return status;
  }

  /*
   * Pass data area info down to driver
   */
  BSP_uart_termios_set( BSP_UART_COM2,
			 ((rtems_libio_open_close_args_t *)arg)->iop->data1 );
   /* Enable interrupts  on channel */
  BSP_uart_intr_ctrl( BSP_UART_COM2, BSP_UART_INTR_CTRL_TERMIOS);
  return RTEMS_SUCCESSFUL;
}
Beispiel #18
0
rtems_device_driver console_open(
    rtems_device_major_number major,
    rtems_device_minor_number minor,
    void                    * arg
)
{
    rtems_status_code rc;

    if (minor > (NUM_DEVS - 1)) {
        return RTEMS_INVALID_NUMBER;
    }

    rc = rtems_termios_open(major, minor, arg, &imx_uart_cbacks);

    return rc;
}
Beispiel #19
0
/*-------------------------------------------------------------------------+
| Console device driver OPEN entry point
+--------------------------------------------------------------------------*/
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                      *arg
)
{
  rtems_status_code              status;
  static rtems_termios_callbacks cb =
#if defined(USE_POLLED_IO)
  {
     NULL,                              /* firstOpen */
     NULL,                              /* lastClose */
     NULL,                              /* pollRead */
     BSP_uart_termios_write_polled,     /* write */
     conSetAttr,                        /* setAttributes */
     NULL,                              /* stopRemoteTx */
     NULL,                              /* startRemoteTx */
     TERMIOS_POLLED                     /* outputUsesInterrupts */
  };
#else
  {
     console_first_open,                /* firstOpen */
     console_last_close,                /* lastClose */
#if ( TERMIOS_OUTPUT_MODE == TERMIOS_TASK_DRIVEN )
     BSP_uart_termios_read_com,         /* pollRead */
#else
     NULL,                              /* pollRead */
#endif
     BSP_uart_termios_write_com,        /* write */
     conSetAttr,                        /* setAttributes */
     NULL,                              /* stopRemoteTx */
     NULL,                              /* startRemoteTx */
     TERMIOS_OUTPUT_MODE                /* outputUsesInterrupts */
  };
#endif

  status = rtems_termios_open (major, minor, arg, &cb);

  if (status != RTEMS_SUCCESSFUL) {
    printk("Error opening console device\n");
    return status;
  }

  return RTEMS_SUCCESSFUL;
}
Beispiel #20
0
rtems_device_driver termios_test_driver_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  int               rc;
  rtems_libio_open_close_args_t *args = arg;
  static const rtems_termios_callbacks Callbacks = {
    NULL,                                    /* firstOpen */
    NULL,                                    /* lastClose */
    termios_test_driver_inbyte_nonblocking,  /* pollRead */
    termios_test_driver_write_support,       /* write */
    termios_test_driver_set_attributes,      /* setAttributes */
    NULL,                                    /* stopRemoteTx */
    NULL,                                    /* startRemoteTx */
    0                                        /* outputUsesInterrupts */
  };

  if ( minor > 2 ) {
    puts( "ERROR - Termios_testdriver - only 1 minor supported" );
    rtems_test_exit(0);
  }

  sc = rtems_termios_open (major, minor, arg, &Callbacks);
  directive_failed( sc, "rtems_termios_open" );

  puts( "Termios_test_driver - rtems_set_initial_baud - bad baud - OK" );
  rc = rtems_termios_set_initial_baud( args->iop->data1, 5000 );
  if ( rc != -1 ) {
    printf( "ERROR - return %d\n", rc );
    rtems_test_exit(0);
  }

  puts( "Termios_test_driver - rtems_set_initial_baud - 38400 - OK" );
  rc = rtems_termios_set_initial_baud( args->iop->data1, 38400 );
  if ( rc ) {
    printf( "ERROR - return %d\n", rc );
    rtems_test_exit(0);
  }

  return RTEMS_SUCCESSFUL;
}
Beispiel #21
0
rtems_device_driver termios_test_driver_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  rtems_libio_open_close_args_t *args = arg;
  static const rtems_termios_callbacks Callbacks = {
    NULL,                                    /* firstOpen */
    NULL,                                    /* lastClose */
    #if defined(TASK_DRIVEN)
      termios_test_driver_inbyte_nonblocking,/* pollRead */
    #else
      NULL,                                  /* pollRead */
    #endif
    termios_test_driver_write_helper,        /* write */
    termios_test_driver_set_attributes,      /* setAttributes */
    NULL,                                    /* stopRemoteTx */
    NULL,                                    /* startRemoteTx */
    #if defined(TASK_DRIVEN)
      TERMIOS_TASK_DRIVEN                    /* outputUsesInterrupts */
    #else
      0                                      /* outputUsesInterrupts */
    #endif
  };

  if ( minor > 2 ) {
    puts( "ERROR - Termios_testdriver - only 1 minor supported" );
    rtems_test_exit(0);
  }

  sc = rtems_termios_open (major, minor, arg, &Callbacks);
  directive_failed( sc, "termios open" ); 

  Ttyp = args->iop->data1;   /* Keep cookie returned by termios_open */

  return RTEMS_SUCCESSFUL;
}
Beispiel #22
0
/*
 * paux device driver OPEN entry point
 */
rtems_device_driver paux_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                      *arg)
{
  rtems_status_code              status;
  static rtems_termios_callbacks cb =
  {
    NULL,	          /* firstOpen */
    paux_last_close,      /* lastClose */
    NULL,                 /* poll read  */
    write_aux_echo,       /* write */
    NULL,	          /* setAttributes */
    NULL,	          /* stopRemoteTx */
    NULL,	          /* startRemoteTx */
    0		          /* outputUsesInterrupts */
  };

  status = rtems_termios_open (major, minor, arg, &cb );
  termios_ttyp_paux = ( (rtems_libio_open_close_args_t *)arg)->iop->data1;
  return status;
}
Beispiel #23
0
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
#if CONSOLE_USE_INTERRUPTS
  /* Interrupt mode routines */
  static const rtems_termios_callbacks Callbacks = {
    leon3_console_first_open,    /* firstOpen */
    leon3_console_last_close,    /* lastClose */
    NULL,                        /* pollRead */
    leon3_console_write_support, /* write */
    leon3_console_set_attributes,/* setAttributes */
    NULL,                        /* stopRemoteTx */
    NULL,                        /* startRemoteTx */
    1                            /* outputUsesInterrupts */
  };
#else
  /* Polling mode routines */
  static const rtems_termios_callbacks Callbacks = {
    leon3_console_first_open,    /* firstOpen */
    NULL,                        /* lastClose */
    leon3_console_pollRead,      /* pollRead */
    leon3_console_write_polled,  /* write */
    leon3_console_set_attributes,/* setAttributes */
    NULL,                        /* stopRemoteTx */
    NULL,                        /* startRemoteTx */
    0                            /* outputUsesInterrupts */
  };
#endif

  assert(minor <= uarts);
  if (minor > uarts || minor == (syscon_uart_index + 1))
    return RTEMS_INVALID_NUMBER;

  return rtems_termios_open(major, minor, arg, &Callbacks);
}
Beispiel #24
0
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void *arg
)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  rtems_device_minor_number count = console_generic_info_count;

  if (minor < count) {
    const console_generic_info *info = &console_generic_info_table [minor];

    sc = rtems_termios_open(
      major,
      minor,
      arg,
      &info->callbacks->termios_callbacks
    );
  } else {
    sc = RTEMS_INVALID_ID;
  }

  return sc;
}
Beispiel #25
0
rtems_device_driver termios_test_driver_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  int               rc;
  rtems_libio_open_close_args_t *args = arg;
  static bool firstCall = true;

  static const rtems_termios_callbacks Callbacks = {
    NULL,                                    /* firstOpen */
    NULL,                                    /* lastClose */
    termios_test_driver_inbyte_nonblocking,  /* pollRead */
    termios_test_driver_write_support,       /* write */
    termios_test_driver_set_attributes,      /* setAttributes */
    NULL,                                    /* stopRemoteTx */
    NULL,                                    /* startRemoteTx */
    0                                        /* outputUsesInterrupts */
  };

  if ( minor > 2 ) {
    puts( "ERROR - Termios_testdriver - only 1 minor supported" );
    rtems_test_exit(0);
  }

  if( firstCall ) {
    static const uintptr_t allocSizes [] = {
      sizeof( struct rtems_termios_tty ),
      128,
      64,
      256
    };

    size_t i;

    firstCall = false;

    for (i = 0; i < sizeof( allocSizes ) / sizeof( allocSizes [0] ); ++i) {
      void *opaque = rtems_heap_greedy_allocate( allocSizes, i );

      sc = rtems_termios_open( major, minor, arg, &Callbacks );
      rtems_test_assert( sc == RTEMS_NO_MEMORY );

      rtems_heap_greedy_free( opaque );
    }
  }
  
  sc = rtems_termios_open (major, minor, arg, &Callbacks);
  directive_failed( sc, "rtems_termios_open" );

  puts( "Termios_test_driver - rtems_set_initial_baud - bad baud - OK" );
  rc = rtems_termios_set_initial_baud( args->iop->data1, 5000 );
  if ( rc != -1 ) {
    printf( "ERROR - return %d\n", rc );
    rtems_test_exit(0);
  }

  puts( "Termios_test_driver - rtems_set_initial_baud - 38400 - OK" );
  rc = rtems_termios_set_initial_baud( args->iop->data1, 38400 );
  if ( rc ) {
    printf( "ERROR - return %d\n", rc );
    rtems_test_exit(0);
  }

  return RTEMS_SUCCESSFUL;
}
/***************************************************************************
   Function : console_open

   Description : This actually opens the device depending on the minor 
   number set during initialisation. The device specific access routines are
   passed to termios when the devices is opened depending on whether it is
   polled or not.
 ***************************************************************************/
rtems_device_driver console_open(
	rtems_device_major_number major,
	rtems_device_minor_number minor,
	void  * arg)
{
	rtems_status_code                status = RTEMS_INVALID_NUMBER;
	rtems_libio_open_close_args_t   *args   = (rtems_libio_open_close_args_t *)arg;
	struct IntUartInfoStruct        *info;

	static const rtems_termios_callbacks IntUartPollCallbacks = {
		NULL,				  /* firstOpen */
		NULL,				  /* lastClose */
		IntUartPollRead,	  /* pollRead */
		IntUartPollWrite,	  /* write */
		IntUartSetAttributes, /* setAttributes */
		NULL,				  /* stopRemoteTx */
		NULL,				  /* startRemoteTx */
		TERMIOS_POLLED		  /* mode */
	};
	static const rtems_termios_callbacks IntUartIntrCallbacks = {
		IntUartInterruptOpen,  /* firstOpen */
		IntUartInterruptClose, /* lastClose */
		NULL,				   /* pollRead */
		IntUartInterruptWrite, /* write */
		IntUartSetAttributes,  /* setAttributes */
		NULL,				   /* stopRemoteTx */
		NULL,				   /* startRemoteTx */
		TERMIOS_IRQ_DRIVEN	   /* mode */
	};

	static const rtems_termios_callbacks IntUartTaskCallbacks = {
		IntUartInterruptOpen,  /* firstOpen */
		IntUartInterruptClose, /* lastClose */
		IntUartTaskRead,	   /* pollRead */
		IntUartInterruptWrite, /* write */
		IntUartSetAttributes,  /* setAttributes */
		NULL,				   /* stopRemoteTx */
		NULL,				   /* startRemoteTx */
		TERMIOS_TASK_DRIVEN	   /* mode */
	};

	/* open the port depending on the minor device number */
	if ( ( minor >= 0 ) && ( minor < MAX_UART_INFO ) )
	{
		info = &IntUartInfo[minor];
		switch ( info->iomode )
		{
			case TERMIOS_POLLED:
				status = rtems_termios_open(major, minor, arg, &IntUartPollCallbacks);
				break;
			case TERMIOS_IRQ_DRIVEN:
				status = rtems_termios_open(major, minor, arg, &IntUartIntrCallbacks);
				info->ttyp = args->iop->data1;
				break;
			case TERMIOS_TASK_DRIVEN:
				status = rtems_termios_open(major, minor, arg, &IntUartTaskCallbacks);
				info->ttyp = args->iop->data1;
				break;
		}
	}

	return( status );
}
rtems_device_driver termios_test_driver_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
  rtems_status_code sc;
  int               rc;
  rtems_libio_open_close_args_t *args = arg;
  void *alloc_ptr = (void *)0;
  static int test = 0;
  size_t freeMemory;
  
  static const rtems_termios_callbacks Callbacks = {
    NULL,                                    /* firstOpen */
    NULL,                                    /* lastClose */
    termios_test_driver_inbyte_nonblocking,  /* pollRead */
    termios_test_driver_write_support,       /* write */
    termios_test_driver_set_attributes,      /* setAttributes */
    NULL,                                    /* stopRemoteTx */
    NULL,                                    /* startRemoteTx */
    0                                        /* outputUsesInterrupts */
  };

  if ( minor > 2 ) {
    puts( "ERROR - Termios_testdriver - only 1 minor supported" );
    rtems_test_exit(0);
  }

  freeMemory = malloc_free_space();
  if( test == 0 ) {
    alloc_ptr = malloc( freeMemory - 4 );
    
    sc = rtems_termios_open (major, minor, arg, &Callbacks);
    rtems_test_assert( sc == RTEMS_NO_MEMORY );
    
    free( alloc_ptr );
    alloc_ptr = malloc( freeMemory - 4 - 10 -
			sizeof( struct rtems_termios_tty ) );
    
    sc = rtems_termios_open (major, minor, arg, &Callbacks);
    rtems_test_assert( sc == RTEMS_NO_MEMORY );
    
    free( alloc_ptr );
    alloc_ptr = malloc( freeMemory - 4 - 20 -
			sizeof( struct rtems_termios_tty ) -
			128 );
    
    sc = rtems_termios_open (major, minor, arg, &Callbacks);
    rtems_test_assert( sc == RTEMS_NO_MEMORY );
    
    free( alloc_ptr );
    alloc_ptr = malloc( freeMemory - 4 - 20 -
			sizeof( struct rtems_termios_tty ) -
			128 -
			80 );
    
    sc = rtems_termios_open (major, minor, arg, &Callbacks);
    rtems_test_assert( sc == RTEMS_NO_MEMORY );
    
    free( alloc_ptr );
    test = 1;
  }
  
  sc = rtems_termios_open (major, minor, arg, &Callbacks);
  directive_failed( sc, "rtems_termios_open" );

  puts( "Termios_test_driver - rtems_set_initial_baud - bad baud - OK" );
  rc = rtems_termios_set_initial_baud( args->iop->data1, 5000 );
  if ( rc != -1 ) {
    printf( "ERROR - return %d\n", rc );
    rtems_test_exit(0);
  }

  puts( "Termios_test_driver - rtems_set_initial_baud - 38400 - OK" );
  rc = rtems_termios_set_initial_baud( args->iop->data1, 38400 );
  if ( rc ) {
    printf( "ERROR - return %d\n", rc );
    rtems_test_exit(0);
  }

  return RTEMS_SUCCESSFUL;
}
/* PAGE
 *
 *  console_open
 *
 *  open a port as a termios console.
 *
 */
rtems_device_driver console_open(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void                    * arg
)
{
	rtems_status_code status;
	rtems_libio_open_close_args_t *args = arg;
	rtems_libio_ioctl_args_t IoctlArgs;
	struct termios	Termios;
	rtems_termios_callbacks Callbacks;
	console_fns *c;

	/*
	 * Verify the port number is valid.
	 */
	if(minor>Console_Port_Count)
	{
		return RTEMS_INVALID_NUMBER;
	}

	/*
	 *  open the port as a termios console driver.
	 */
	c = Console_Port_Tbl[minor].pDeviceFns;
	Callbacks.firstOpen     = c->deviceFirstOpen;
	Callbacks.lastClose     = c->deviceLastClose;
	Callbacks.pollRead      = c->deviceRead;
	Callbacks.write         = c->deviceWrite;
	Callbacks.setAttributes = c->deviceSetAttributes;
	Callbacks.stopRemoteTx  =
		Console_Port_Tbl[minor].pDeviceFlow->deviceStopRemoteTx;
	Callbacks.startRemoteTx =
		Console_Port_Tbl[minor].pDeviceFlow->deviceStartRemoteTx;
	Callbacks.outputUsesInterrupts = c->deviceOutputUsesInterrupts;
	status = rtems_termios_open ( major, minor, arg, &Callbacks);
	Console_Port_Data[minor].termios_data = args->iop->data1;

	if(minor!=Console_Port_Minor)
	{
		/*
		 * If this is not the console we do not want ECHO and
		 * so forth
		 */
		IoctlArgs.iop=args->iop;
		IoctlArgs.command=RTEMS_IO_GET_ATTRIBUTES;
		IoctlArgs.buffer=&Termios;
		rtems_termios_ioctl(&IoctlArgs);
		Termios.c_lflag=ICANON;
		IoctlArgs.command=RTEMS_IO_SET_ATTRIBUTES;
		rtems_termios_ioctl(&IoctlArgs);
	}

	if((args->iop->flags&LIBIO_FLAGS_READ) &&
	   Console_Port_Tbl[minor].pDeviceFlow &&
	   Console_Port_Tbl[minor].pDeviceFlow->deviceStartRemoteTx)
	{
		Console_Port_Tbl[minor].pDeviceFlow->deviceStartRemoteTx(minor);
	}

	return status;
}