Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:09

0001 /*
0002  *  COPYRIGHT (c) 2010 Eugen Leontie.
0003  *
0004  *  The license and distribution terms for this file may be
0005  *  found in the file LICENSE in this distribution or at
0006  *  http://www.rtems.org/license/LICENSE.
0007  */
0008 
0009 #include <bsp.h>
0010 
0011 #include <libchip/serial.h>
0012 
0013 #include <rtems/bspIo.h>
0014 
0015 #include <boot/ofw.h>
0016 
0017 static int sun4v_console_device_first_open(int major, int minor, void *arg)
0018 {
0019   return 0;
0020 }
0021 
0022 static ssize_t sun4v_console_poll_write(int minor, const char *buf, size_t n)
0023 {
0024   ofw_write(buf, n);
0025   return 0;
0026 }
0027 
0028 static void sun4v_console_deviceInitialize (int minor)
0029 {
0030   
0031 }
0032 
0033 static int sun4v_console_poll_read(int minor){
0034   int a;
0035   ofw_read(&a,1);
0036   if ( a != 0 ) {
0037     return a>>24;
0038   }
0039   return -1;
0040 }
0041 
0042 static bool sun4v_console_deviceProbe (int minor){
0043   return true;
0044 }
0045 
0046 /*
0047  *  Polled mode functions
0048  */
0049 const console_fns pooled_functions={
0050   sun4v_console_deviceProbe,       /* deviceProbe */
0051   sun4v_console_device_first_open, /* deviceFirstOpen */
0052   NULL,                            /* deviceLastClose */
0053   sun4v_console_poll_read,         /* deviceRead */
0054   sun4v_console_poll_write,        /* deviceWrite */
0055   sun4v_console_deviceInitialize,  /* deviceInitialize */
0056   NULL,                            /* deviceWritePolled */
0057   NULL,                            /* deviceSetAttributes */
0058   NULL                             /* deviceOutputUsesInterrupts */
0059 };
0060 
0061 const console_flow sun4v_console_console_flow = {
0062   NULL, /* deviceStopRemoteTx */
0063   NULL  /* deviceStartRemoteTx */
0064 };
0065 
0066 console_tbl     Console_Configuration_Ports[] = {
0067   {
0068     "/dev/ttyS0",                 /* sDeviceName */
0069     SERIAL_CUSTOM,                /* deviceType */
0070     &pooled_functions,            /* pDeviceFns */
0071     NULL,                         /* deviceProbe, assume it is there */
0072     &sun4v_console_console_flow,  /* pDeviceFlow */
0073     0,                            /* ulMargin */
0074     0,                            /* ulHysteresis */
0075     (void *) NULL,                /* pDeviceParams */
0076     0,                            /* ulCtrlPort1 */
0077     0,                            /* ulCtrlPort2 */
0078     1,                            /* ulDataPort */
0079     NULL,                         /* getRegister */
0080     NULL,                         /* setRegister */
0081     NULL, /* unused */            /* getData */
0082     NULL, /* unused */            /* setData */
0083     0,                            /* ulClock */
0084     0                             /* ulIntVector -- base for port */
0085   },
0086 };
0087 
0088 /*
0089  *  Declare some information used by the console driver
0090  */
0091 
0092 #define NUM_CONSOLE_PORTS 1
0093 
0094 unsigned long  Console_Configuration_Count = NUM_CONSOLE_PORTS;
0095 
0096 /* putchar/getchar for printk */
0097 
0098 static void bsp_out_char (char c)
0099 {
0100   ofw_write(&c, 1);
0101 }
0102 
0103 BSP_output_char_function_type BSP_output_char = bsp_out_char;
0104 
0105 static int bsp_in_char( void ){
0106   int tmp;
0107   ofw_read( &tmp, 1 ); /* blocks */
0108   if( tmp != 0 ) {
0109     return tmp>>24;
0110   }
0111   return -1;
0112 }
0113 
0114 BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;
0115