source: rtems/c/src/lib/libbsp/powerpc/gen83xx/console/console-config.c @ e570c313

4.11
Last change on this file since e570c313 was e570c313, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 24, 2011 at 3:32:04 PM

2011-01-24 Joel Sherrill <joel.sherrill@…>

  • configure.ac, console/console-config.c, i2c/i2c_init.c, include/bsp.h, include/hwreg_vals.h, include/irq.h, include/tm27.h, include/tsec-config.h, irq/irq.c, network/network.c, spi/spi_init.c, startup/bspstart.c: Address some of the issues spotted by the check_bsp script.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Console configuration.
5 */
6
7/*
8 * Copyright (c) 2008, 2010 embedded brains GmbH.  All rights reserved.
9 *
10 *  embedded brains GmbH
11 *  Obere Lagerstr. 30
12 *  82178 Puchheim
13 *  Germany
14 *  <rtems@embedded-brains.de>
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.com/license/LICENSE.
19 *
20 *  $Id$
21 */
22
23#include <rtems/bspIo.h>
24
25#include <libchip/serial.h>
26#include <libchip/ns16550.h>
27
28#include <mpc83xx/mpc83xx.h>
29
30#include <bspopts.h>
31#include <bsp/irq.h>
32
33#ifdef BSP_USE_UART2
34  #define PORT_COUNT 2
35#else
36  #define PORT_COUNT 1
37#endif
38
39#ifdef BSP_USE_UART_INTERRUPTS
40  #define DEVICE_FNS &ns16550_fns
41#else
42  #define DEVICE_FNS &ns16550_fns_polled
43#endif
44
45static uint8_t gen83xx_console_get_register(uint32_t addr, uint8_t i)
46{
47  volatile uint8_t *reg = (volatile uint8_t *) addr;
48
49  return reg [i];
50}
51
52static void gen83xx_console_set_register(uint32_t addr, uint8_t i, uint8_t val)
53{
54  volatile uint8_t *reg = (volatile uint8_t *) addr;
55
56  reg [i] = val; 
57}
58
59unsigned long Console_Port_Count = PORT_COUNT;
60
61rtems_device_minor_number Console_Port_Minor = 0;
62
63console_data Console_Port_Data [PORT_COUNT];
64
65console_tbl Console_Port_Tbl [PORT_COUNT] = {
66  {
67    .sDeviceName = "/dev/ttyS0",
68    .deviceType = SERIAL_NS16550,
69    .pDeviceFns = DEVICE_FNS,
70    .deviceProbe = NULL,
71    .pDeviceFlow = NULL,
72    .ulMargin = 16,
73    .ulHysteresis = 8,
74    .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
75    .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [0],
76    .ulCtrlPort2 = 0,
77    .ulDataPort =  (uint32_t) &mpc83xx.duart [0],
78    .getRegister = gen83xx_console_get_register,
79    .setRegister = gen83xx_console_set_register,
80    .getData = NULL,
81    .setData = NULL,
82    .ulClock = 0,
83    .ulIntVector = BSP_IPIC_IRQ_UART1
84  }
85#ifdef BSP_USE_UART2
86  , {
87    .sDeviceName = "/dev/ttyS1",
88    .deviceType = SERIAL_NS16550,
89    .pDeviceFns = DEVICE_FNS,
90    .deviceProbe = NULL,
91    .pDeviceFlow = NULL,
92    .ulMargin = 16,
93    .ulHysteresis = 8,
94    .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
95    .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [1],
96    .ulCtrlPort2 = 0,
97    .ulDataPort =  (uint32_t) &mpc83xx.duart [1],
98    .getRegister = gen83xx_console_get_register,
99    .setRegister = gen83xx_console_set_register,
100    .getData = NULL,
101    .setData = NULL,
102    .ulClock = 0,
103    .ulIntVector = BSP_IPIC_IRQ_UART2
104  }
105#endif
106};
107
108static void gen83xx_output_char(char c)
109{
110  const console_fns *console = Console_Port_Tbl [Console_Port_Minor].pDeviceFns;
111 
112  if (c == '\n') {
113    console->deviceWritePolled((int) Console_Port_Minor, '\r');
114  }
115  console->deviceWritePolled((int) Console_Port_Minor, c);
116}
117
118BSP_output_char_function_type  BSP_output_char = gen83xx_output_char;
119
120BSP_polling_getchar_function_type BSP_poll_char = NULL;
Note: See TracBrowser for help on using the repository browser.