File indexing completed on 2025-05-11 08:23:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <rtems/bspIo.h>
0035
0036 #include <libchip/ns16550.h>
0037
0038 #include <mpc83xx/mpc83xx.h>
0039
0040 #include <bsp.h>
0041 #include <bsp/irq.h>
0042 #include <bsp/console-termios.h>
0043
0044 #ifdef BSP_USE_UART_INTERRUPTS
0045 #define DEVICE_FNS &ns16550_handler_interrupt
0046 #else
0047 #define DEVICE_FNS &ns16550_handler_polled
0048 #endif
0049
0050 static uint8_t gen83xx_console_get_register(uintptr_t addr, uint8_t i)
0051 {
0052 volatile uint8_t *reg = (volatile uint8_t *) addr;
0053
0054 return reg [i];
0055 }
0056
0057 static void gen83xx_console_set_register(uintptr_t addr, uint8_t i, uint8_t val)
0058 {
0059 volatile uint8_t *reg = (volatile uint8_t *) addr;
0060
0061 reg [i] = val;
0062 }
0063
0064 static ns16550_context gen83xx_uart_context_0 = {
0065 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 0"),
0066 .get_reg = gen83xx_console_get_register,
0067 .set_reg = gen83xx_console_set_register,
0068 .port = (uintptr_t) &mpc83xx.duart[0],
0069 #if MPC83XX_CHIP_TYPE / 10 == 830
0070 .irq = BSP_IPIC_IRQ_UART,
0071 #else
0072 .irq = BSP_IPIC_IRQ_UART1,
0073 #endif
0074 .initial_baud = BSP_CONSOLE_BAUD
0075 };
0076
0077 #ifdef BSP_USE_UART2
0078 static ns16550_context gen83xx_uart_context_1 = {
0079 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 1"),
0080 .get_reg = gen83xx_console_get_register,
0081 .set_reg = gen83xx_console_set_register,
0082 .port = (uintptr_t) &mpc83xx.duart[1],
0083 #if MPC83XX_CHIP_TYPE / 10 == 830
0084 .irq = BSP_IPIC_IRQ_UART,
0085 #else
0086 .irq = BSP_IPIC_IRQ_UART2,
0087 #endif
0088 .initial_baud = BSP_CONSOLE_BAUD
0089 };
0090 #endif
0091
0092 const console_device console_device_table[] = {
0093 {
0094 .device_file = "/dev/ttyS0",
0095 .probe = ns16550_probe,
0096 .handler = DEVICE_FNS,
0097 .context = &gen83xx_uart_context_0.base
0098 }
0099 #ifdef BSP_USE_UART2
0100 , {
0101 .device_file = "/dev/ttyS1",
0102 .probe = ns16550_probe,
0103 .handler = DEVICE_FNS,
0104 .context = &gen83xx_uart_context_1.base
0105 }
0106 #endif
0107 };
0108
0109 const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
0110
0111 static void gen83xx_output_char(char c)
0112 {
0113 rtems_termios_device_context *ctx = console_device_table[0].context;
0114
0115 ns16550_polled_putchar(ctx, c);
0116 }
0117
0118 BSP_output_char_function_type BSP_output_char = gen83xx_output_char;
0119
0120 BSP_polling_getchar_function_type BSP_poll_char = NULL;