[566a1806] | 1 | /* |
---|
| 2 | * COPYRIGHT (c) 2010 Eugen Leontie. |
---|
| 3 | * |
---|
| 4 | * The license and distribution terms for this file may be |
---|
| 5 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 6 | * http://www.rtems.org/license/LICENSE. |
---|
[566a1806] | 7 | */ |
---|
| 8 | |
---|
| 9 | #include <bsp.h> |
---|
| 10 | |
---|
| 11 | #include <libchip/serial.h> |
---|
| 12 | |
---|
[a0f27360] | 13 | #include <boot/ofw.h> |
---|
[566a1806] | 14 | |
---|
| 15 | int sun4v_console_device_first_open(int major, int minor, void *arg) |
---|
| 16 | { |
---|
[053b7e04] | 17 | return 0; |
---|
[566a1806] | 18 | } |
---|
| 19 | |
---|
| 20 | static ssize_t sun4v_console_poll_write(int minor, const char *buf, size_t n) |
---|
| 21 | { |
---|
[053b7e04] | 22 | ofw_write(buf, n); |
---|
| 23 | return 0; |
---|
[566a1806] | 24 | } |
---|
| 25 | |
---|
| 26 | void sun4v_console_deviceInitialize (int minor) |
---|
| 27 | { |
---|
[053b7e04] | 28 | |
---|
[566a1806] | 29 | } |
---|
| 30 | |
---|
| 31 | int sun4v_console_poll_read(int minor){ |
---|
[053b7e04] | 32 | int a; |
---|
| 33 | ofw_read(&a,1); |
---|
| 34 | if(a!=0){ |
---|
| 35 | return a>>24; |
---|
| 36 | } |
---|
| 37 | return -1; |
---|
[566a1806] | 38 | } |
---|
| 39 | |
---|
| 40 | bool sun4v_console_deviceProbe (int minor){ |
---|
[053b7e04] | 41 | return true; |
---|
[566a1806] | 42 | } |
---|
| 43 | |
---|
| 44 | /* |
---|
| 45 | * Polled mode functions |
---|
| 46 | */ |
---|
[c8bd3cd] | 47 | const console_fns pooled_functions={ |
---|
[053b7e04] | 48 | sun4v_console_deviceProbe, /* deviceProbe */ |
---|
| 49 | sun4v_console_device_first_open, /* deviceFirstOpen */ |
---|
| 50 | NULL, /* deviceLastClose */ |
---|
| 51 | sun4v_console_poll_read, /* deviceRead */ |
---|
| 52 | sun4v_console_poll_write, /* deviceWrite */ |
---|
| 53 | sun4v_console_deviceInitialize, /* deviceInitialize */ |
---|
| 54 | NULL, /* deviceWritePolled */ |
---|
| 55 | NULL, /* deviceSetAttributes */ |
---|
| 56 | NULL /* deviceOutputUsesInterrupts */ |
---|
[566a1806] | 57 | }; |
---|
| 58 | |
---|
[c8bd3cd] | 59 | const console_flow sun4v_console_console_flow = { |
---|
[053b7e04] | 60 | NULL, /* deviceStopRemoteTx */ |
---|
| 61 | NULL /* deviceStartRemoteTx */ |
---|
[566a1806] | 62 | }; |
---|
| 63 | |
---|
[a7f3a657] | 64 | console_tbl Console_Configuration_Ports[] = { |
---|
[053b7e04] | 65 | { |
---|
| 66 | "/dev/ttyS0", /* sDeviceName */ |
---|
| 67 | SERIAL_CUSTOM, /* deviceType */ |
---|
| 68 | &pooled_functions, /* pDeviceFns */ |
---|
| 69 | NULL, /* deviceProbe, assume it is there */ |
---|
| 70 | &sun4v_console_console_flow, /* pDeviceFlow */ |
---|
| 71 | 0, /* ulMargin */ |
---|
| 72 | 0, /* ulHysteresis */ |
---|
| 73 | (void *) NULL, /* pDeviceParams */ |
---|
| 74 | 0, /* ulCtrlPort1 */ |
---|
| 75 | 0, /* ulCtrlPort2 */ |
---|
| 76 | 1, /* ulDataPort */ |
---|
| 77 | NULL, /* getRegister */ |
---|
| 78 | NULL, /* setRegister */ |
---|
| 79 | NULL, /* unused */ /* getData */ |
---|
| 80 | NULL, /* unused */ /* setData */ |
---|
| 81 | 0, /* ulClock */ |
---|
| 82 | 0 /* ulIntVector -- base for port */ |
---|
| 83 | }, |
---|
[566a1806] | 84 | }; |
---|
| 85 | |
---|
| 86 | /* |
---|
| 87 | * Declare some information used by the console driver |
---|
| 88 | */ |
---|
| 89 | |
---|
| 90 | #define NUM_CONSOLE_PORTS 1 |
---|
| 91 | |
---|
[a7f3a657] | 92 | unsigned long Console_Configuration_Count = NUM_CONSOLE_PORTS; |
---|
[566a1806] | 93 | |
---|
| 94 | /* putchar/getchar for printk */ |
---|
| 95 | |
---|
| 96 | static void bsp_out_char (char c) |
---|
| 97 | { |
---|
| 98 | ofw_write(&c, 1); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | BSP_output_char_function_type BSP_output_char = bsp_out_char; |
---|
| 102 | |
---|
[019fd4b] | 103 | static int bsp_in_char( void ){ |
---|
[053b7e04] | 104 | int tmp; |
---|
| 105 | ofw_read( &tmp, 1 ); /* blocks */ |
---|
| 106 | if( tmp != 0 ) { |
---|
| 107 | return tmp>>24; |
---|
| 108 | } |
---|
| 109 | return -1; |
---|
[019fd4b] | 110 | } |
---|
| 111 | |
---|
| 112 | BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char; |
---|
| 113 | |
---|