summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/ep1a/console/printk_support.c
blob: 7e8febdd2d1a85de5eda49ccf08acaa0fc0be882 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 *  This file contains the ep1a printk support routines
 *
 *  COPYRIGHT (c) 2011.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 */

#include <bsp.h>
#include <rtems/libio.h>
#include <stdlib.h>
#include <assert.h>
#include <termios.h>
#include <rtems/bspIo.h>

rtems_device_minor_number         BSPPrintkPort = 0;

/* const char arg to be compatible with BSP_output_char decl. */
void
debug_putc_onlcr(const char c)
{
  volatile int i;

  /*
   * Note:  Hack to get printk to work.  Depends upon bit
   *        and silverchip to initialize the port and just
   *        forces a character to be polled out of com1
   *        regardless of where the console is.
   */

  volatile unsigned char *ptr = (void *)0xff800000;

  if ('\n'==c){
     *ptr = '\r';
     __asm__ volatile("sync");
     for (i=0;i<0x0fff;i++);
  }

  *ptr = c;
  __asm__ volatile("sync");
  for (i=0;i<0x0fff;i++);
}

BSP_output_char_function_type     BSP_output_char = debug_putc_onlcr;
BSP_polling_getchar_function_type BSP_poll_char = NULL;