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.com/license/LICENSE. |
---|
7 | * |
---|
8 | * $Id$ |
---|
9 | */ |
---|
10 | |
---|
11 | |
---|
12 | #include <bsp.h> |
---|
13 | |
---|
14 | #include <libchip/serial.h> |
---|
15 | |
---|
16 | extern void ofw_write(const char *,const int ); |
---|
17 | extern void ofw_read(void *,int ); |
---|
18 | |
---|
19 | int sun4v_console_device_first_open(int major, int minor, void *arg) |
---|
20 | { |
---|
21 | return 0; |
---|
22 | } |
---|
23 | |
---|
24 | static ssize_t sun4v_console_poll_write(int minor, const char *buf, size_t n) |
---|
25 | { |
---|
26 | ofw_write(buf, n); |
---|
27 | return 0; |
---|
28 | } |
---|
29 | |
---|
30 | void sun4v_console_deviceInitialize (int minor) |
---|
31 | { |
---|
32 | |
---|
33 | } |
---|
34 | |
---|
35 | int sun4v_console_poll_read(int minor){ |
---|
36 | int a; |
---|
37 | ofw_read(&a,1); |
---|
38 | if(a!=0){ |
---|
39 | return a>>24; |
---|
40 | } |
---|
41 | return -1; |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | bool sun4v_console_deviceProbe (int minor){ |
---|
46 | return true; |
---|
47 | } |
---|
48 | |
---|
49 | /* |
---|
50 | * Polled mode functions |
---|
51 | */ |
---|
52 | console_fns pooled_functions={ |
---|
53 | sun4v_console_deviceProbe, /*bool (*deviceProbe)(int minor);*/ |
---|
54 | sun4v_console_device_first_open, /*int (*deviceFirstOpen)(int major, int minor, void *arg);*/ |
---|
55 | NULL, /*int (*deviceLastClose)(int major, int minor, void *arg);*/ |
---|
56 | sun4v_console_poll_read, /*int (*deviceRead)(int minor);*/ |
---|
57 | sun4v_console_poll_write, /*ssize_t (*deviceWrite)(int minor, const char *buf, size_t len);*/ |
---|
58 | sun4v_console_deviceInitialize, /*void (*deviceInitialize)(int minor);*/ |
---|
59 | NULL, /*void (*deviceWritePolled)(int minor, char cChar);*/ |
---|
60 | NULL, /*int (*deviceSetAttributes)(int minor, const struct termios *t);*/ |
---|
61 | NULL /*bool deviceOutputUsesInterrupts;*/ |
---|
62 | }; |
---|
63 | |
---|
64 | console_flow sun4v_console_console_flow={ |
---|
65 | NULL,/*int (*deviceStopRemoteTx)(int minor);*/ |
---|
66 | NULL/*int (*deviceStartRemoteTx)(int minor);*/ |
---|
67 | }; |
---|
68 | |
---|
69 | |
---|
70 | console_tbl Console_Configuration_Ports[] = { |
---|
71 | { |
---|
72 | NULL, /* sDeviceName */ |
---|
73 | SERIAL_CUSTOM, /* deviceType */ |
---|
74 | &pooled_functions, /* pDeviceFns */ |
---|
75 | NULL, /* deviceProbe, assume it is there */ |
---|
76 | &sun4v_console_console_flow, /* pDeviceFlow */ |
---|
77 | 0, /* ulMargin */ |
---|
78 | 0, /* ulHysteresis */ |
---|
79 | (void *) NULL, /* NULL */ /* pDeviceParams */ |
---|
80 | 0, /* ulCtrlPort1 */ |
---|
81 | 0, /* ulCtrlPort2 */ |
---|
82 | 1, /* ulDataPort */ |
---|
83 | NULL, /* getRegister */ |
---|
84 | NULL, /* setRegister */ |
---|
85 | NULL, /* unused */ /* getData */ |
---|
86 | NULL, /* unused */ /* setData */ |
---|
87 | 0, /* ulClock */ |
---|
88 | 0 /* ulIntVector -- base for port */ |
---|
89 | }, |
---|
90 | }; |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | /* |
---|
95 | * Declare some information used by the console driver |
---|
96 | */ |
---|
97 | |
---|
98 | #define NUM_CONSOLE_PORTS 1 |
---|
99 | |
---|
100 | unsigned long Console_Configuration_Count = NUM_CONSOLE_PORTS; |
---|
101 | |
---|
102 | |
---|
103 | /* putchar/getchar for printk */ |
---|
104 | |
---|
105 | static void bsp_out_char (char c) |
---|
106 | { |
---|
107 | ofw_write(&c, 1); |
---|
108 | } |
---|
109 | |
---|
110 | BSP_output_char_function_type BSP_output_char = bsp_out_char; |
---|
111 | |
---|
112 | static int bsp_in_char( void ){ |
---|
113 | int tmp; |
---|
114 | ofw_read( &tmp, 1 ); /* blocks */ |
---|
115 | if( tmp != 0 ) { |
---|
116 | return tmp>>24; |
---|
117 | } |
---|
118 | return -1; |
---|
119 | } |
---|
120 | |
---|
121 | BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char; |
---|
122 | |
---|