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 |
---|
6 | * http://www.rtems.org/license/LICENSE. |
---|
7 | */ |
---|
8 | |
---|
9 | #include <bsp.h> |
---|
10 | |
---|
11 | #include <libchip/serial.h> |
---|
12 | |
---|
13 | #include <boot/ofw.h> |
---|
14 | |
---|
15 | int sun4v_console_device_first_open(int major, int minor, void *arg) |
---|
16 | { |
---|
17 | return 0; |
---|
18 | } |
---|
19 | |
---|
20 | static ssize_t sun4v_console_poll_write(int minor, const char *buf, size_t n) |
---|
21 | { |
---|
22 | ofw_write(buf, n); |
---|
23 | return 0; |
---|
24 | } |
---|
25 | |
---|
26 | void sun4v_console_deviceInitialize (int minor) |
---|
27 | { |
---|
28 | |
---|
29 | } |
---|
30 | |
---|
31 | int sun4v_console_poll_read(int minor){ |
---|
32 | int a; |
---|
33 | ofw_read(&a,1); |
---|
34 | if(a!=0){ |
---|
35 | return a>>24; |
---|
36 | } |
---|
37 | return -1; |
---|
38 | } |
---|
39 | |
---|
40 | bool sun4v_console_deviceProbe (int minor){ |
---|
41 | return true; |
---|
42 | } |
---|
43 | |
---|
44 | /* |
---|
45 | * Polled mode functions |
---|
46 | */ |
---|
47 | const console_fns pooled_functions={ |
---|
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 */ |
---|
57 | }; |
---|
58 | |
---|
59 | const console_flow sun4v_console_console_flow = { |
---|
60 | NULL, /* deviceStopRemoteTx */ |
---|
61 | NULL /* deviceStartRemoteTx */ |
---|
62 | }; |
---|
63 | |
---|
64 | console_tbl Console_Configuration_Ports[] = { |
---|
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 | }, |
---|
84 | }; |
---|
85 | |
---|
86 | /* |
---|
87 | * Declare some information used by the console driver |
---|
88 | */ |
---|
89 | |
---|
90 | #define NUM_CONSOLE_PORTS 1 |
---|
91 | |
---|
92 | unsigned long Console_Configuration_Count = NUM_CONSOLE_PORTS; |
---|
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 | |
---|
103 | static int bsp_in_char( void ){ |
---|
104 | int tmp; |
---|
105 | ofw_read( &tmp, 1 ); /* blocks */ |
---|
106 | if( tmp != 0 ) { |
---|
107 | return tmp>>24; |
---|
108 | } |
---|
109 | return -1; |
---|
110 | } |
---|
111 | |
---|
112 | BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char; |
---|
113 | |
---|