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

4.115
Last change on this file since 8a54204 was 8a54204, checked in by Sebastian Huber <sebastian.huber@…>, on 11/12/10 at 14:16:57

2010-11-12 Sebastian Huber <sebastian.huber@…>

  • console/console.h, console/console.c, console/config.c, console/ns16550cfg.c: Removed files.
  • console/console-config.c: New file.
  • Makefile.am: Reflect changes above.
  • configure.ac: New BSP options.
  • include/bsp.h: Use new BSP options.
  • network/network.c: Avoid memory leak.
  • startup/bspstart.c: Initialize console port table.
  • spi/spi_init.c: Update for SD card API changes.
  • 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
21#include <rtems/bspIo.h>
22
23#include <libchip/serial.h>
24#include <libchip/ns16550.h>
25
26#include <mpc83xx/mpc83xx.h>
27
28#include <bspopts.h>
29#include <bsp/irq.h>
30
31#ifdef BSP_USE_UART2
32  #define PORT_COUNT 2
33#else
34  #define PORT_COUNT 1
35#endif
36
37#ifdef BSP_USE_UART_INTERRUPTS
38  #define DEVICE_FNS &ns16550_fns
39#else
40  #define DEVICE_FNS &ns16550_fns_polled
41#endif
42
43static uint8_t gen83xx_console_get_register(uint32_t addr, uint8_t i)
44{
45  volatile uint8_t *reg = (volatile uint8_t *) addr;
46
47  return reg [i];
48}
49
50static void gen83xx_console_set_register(uint32_t addr, uint8_t i, uint8_t val)
51{
52  volatile uint8_t *reg = (volatile uint8_t *) addr;
53
54  reg [i] = val;
55}
56
57unsigned long Console_Port_Count = PORT_COUNT;
58
59rtems_device_minor_number Console_Port_Minor = 0;
60
61console_data Console_Port_Data [PORT_COUNT];
62
63console_tbl Console_Port_Tbl [PORT_COUNT] = {
64  {
65    .sDeviceName = "/dev/ttyS0",
66    .deviceType = SERIAL_NS16550,
67    .pDeviceFns = DEVICE_FNS,
68    .deviceProbe = NULL,
69    .pDeviceFlow = NULL,
70    .ulMargin = 16,
71    .ulHysteresis = 8,
72    .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
73    .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [0],
74    .ulCtrlPort2 = 0,
75    .ulDataPort =  (uint32_t) &mpc83xx.duart [0],
76    .getRegister = gen83xx_console_get_register,
77    .setRegister = gen83xx_console_set_register,
78    .getData = NULL,
79    .setData = NULL,
80    .ulClock = 0,
81    .ulIntVector = BSP_IPIC_IRQ_UART1
82  }
83#ifdef BSP_USE_UART2
84  , {
85    .sDeviceName = "/dev/ttyS1",
86    .deviceType = SERIAL_NS16550,
87    .pDeviceFns = DEVICE_FNS,
88    .deviceProbe = NULL,
89    .pDeviceFlow = NULL,
90    .ulMargin = 16,
91    .ulHysteresis = 8,
92    .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
93    .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [1],
94    .ulCtrlPort2 = 0,
95    .ulDataPort =  (uint32_t) &mpc83xx.duart [1],
96    .getRegister = gen83xx_console_get_register,
97    .setRegister = gen83xx_console_set_register,
98    .getData = NULL,
99    .setData = NULL,
100    .ulClock = 0,
101    .ulIntVector = BSP_IPIC_IRQ_UART2
102  }
103#endif
104};
105
106static void gen83xx_output_char(char c)
107{
108  const console_fns *console = Console_Port_Tbl [Console_Port_Minor].pDeviceFns;
109 
110  if (c == '\n') {
111    console->deviceWritePolled((int) Console_Port_Minor, '\r');
112  }
113  console->deviceWritePolled((int) Console_Port_Minor, c);
114}
115
116BSP_output_char_function_type  BSP_output_char = gen83xx_output_char;
117
118BSP_polling_getchar_function_type BSP_poll_char = NULL;
Note: See TracBrowser for help on using the repository browser.