Rev 3235 | Rev 3716 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3235 | Rev 3672 | ||
|---|---|---|---|
| Line 47... | Line 47... | ||
| 47 | #include <sysinfo.h> |
47 | #include <sysinfo.h> |
| 48 | #include <as.h> |
48 | #include <as.h> |
| 49 | #include <align.h> |
49 | #include <align.h> |
| 50 | #include <ddi.h> |
50 | #include <ddi.h> |
| 51 | 51 | ||
| - | 52 | #include "serial_console.h" |
|
| 52 | #include "msim.h" |
53 | #include "msim.h" |
| 53 | 54 | ||
| 54 | #define WIDTH 80 |
55 | #define WIDTH 80 |
| 55 | #define HEIGHT 25 |
56 | #define HEIGHT 25 |
| 56 | 57 | ||
| Line 64... | Line 65... | ||
| 64 | static void msim_putc(const char c) |
65 | static void msim_putc(const char c) |
| 65 | { |
66 | { |
| 66 | *virt_addr = c; |
67 | *virt_addr = c; |
| 67 | } |
68 | } |
| 68 | 69 | ||
| 69 | static void msim_puts(char *str) |
- | |
| 70 | { |
- | |
| 71 | while (*str) |
- | |
| 72 | *virt_addr = *(str++); |
- | |
| 73 | } |
- | |
| 74 | - | ||
| 75 | static void msim_clrscr(void) |
- | |
| 76 | { |
- | |
| 77 | msim_puts("\033[2J"); |
- | |
| 78 | } |
- | |
| 79 | - | ||
| 80 | static void msim_goto(const unsigned int row, const unsigned int col) |
- | |
| 81 | { |
- | |
| 82 | if ((row > HEIGHT) || (col > WIDTH)) |
- | |
| 83 | return; |
- | |
| 84 | - | ||
| 85 | char control[MAX_CONTROL]; |
- | |
| 86 | snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1); |
- | |
| 87 | msim_puts(control); |
- | |
| 88 | } |
- | |
| 89 | - | ||
| 90 | static void msim_set_style(const unsigned int mode) |
- | |
| 91 | { |
- | |
| 92 | char control[MAX_CONTROL]; |
- | |
| 93 | snprintf(control, MAX_CONTROL, "\033[%um", mode); |
- | |
| 94 | msim_puts(control); |
- | |
| 95 | } |
- | |
| 96 | - | ||
| 97 | static void msim_cursor_disable(void) |
- | |
| 98 | { |
- | |
| 99 | msim_puts("\033[?25l"); |
- | |
| 100 | } |
- | |
| 101 | - | ||
| 102 | static void msim_cursor_enable(void) |
- | |
| 103 | { |
- | |
| 104 | msim_puts("\033[?25h"); |
- | |
| 105 | } |
- | |
| 106 | - | ||
| 107 | static void msim_scroll(int i) |
- | |
| 108 | { |
- | |
| 109 | if (i > 0) { |
- | |
| 110 | msim_goto(HEIGHT - 1, 0); |
- | |
| 111 | while (i--) |
- | |
| 112 | msim_puts("\033D"); |
- | |
| 113 | } else if (i < 0) { |
- | |
| 114 | msim_goto(0, 0); |
- | |
| 115 | while (i++) |
- | |
| 116 | msim_puts("\033M"); |
- | |
| 117 | } |
- | |
| 118 | } |
- | |
| 119 | - | ||
| 120 | static void msim_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
70 | static void msim_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
| 121 | { |
71 | { |
| 122 | int retval; |
72 | int retval; |
| 123 | ipc_callid_t callid; |
73 | ipc_callid_t callid; |
| 124 | ipc_call_t call; |
74 | ipc_call_t call; |
| Line 139... | Line 89... | ||
| 139 | client_connected = 1; |
89 | client_connected = 1; |
| 140 | ipc_answer_0(iid, EOK); |
90 | ipc_answer_0(iid, EOK); |
| 141 | 91 | ||
| 142 | /* Clear the terminal, set scrolling region |
92 | /* Clear the terminal, set scrolling region |
| 143 | to 0 - 25 lines */ |
93 | to 0 - 25 lines */ |
| 144 | msim_clrscr(); |
94 | serial_clrscr(); |
| 145 | msim_goto(0, 0); |
95 | serial_goto(0, 0); |
| 146 | msim_puts("\033[0;25r"); |
96 | serial_puts("\033[0;25r"); |
| 147 | 97 | ||
| 148 | while (true) { |
98 | while (true) { |
| 149 | callid = async_get_call(&call); |
99 | callid = async_get_call(&call); |
| 150 | switch (IPC_GET_METHOD(call)) { |
100 | switch (IPC_GET_METHOD(call)) { |
| 151 | case IPC_M_PHONE_HUNGUP: |
101 | case IPC_M_PHONE_HUNGUP: |
| Line 155... | Line 105... | ||
| 155 | case FB_PUTCHAR: |
105 | case FB_PUTCHAR: |
| 156 | c = IPC_GET_ARG1(call); |
106 | c = IPC_GET_ARG1(call); |
| 157 | newrow = IPC_GET_ARG2(call); |
107 | newrow = IPC_GET_ARG2(call); |
| 158 | newcol = IPC_GET_ARG3(call); |
108 | newcol = IPC_GET_ARG3(call); |
| 159 | if ((lastcol != newcol) || (lastrow != newrow)) |
109 | if ((lastcol != newcol) || (lastrow != newrow)) |
| 160 | msim_goto(newrow, newcol); |
110 | serial_goto(newrow, newcol); |
| 161 | lastcol = newcol + 1; |
111 | lastcol = newcol + 1; |
| 162 | lastrow = newrow; |
112 | lastrow = newrow; |
| 163 | msim_putc(c); |
113 | msim_putc(c); |
| 164 | retval = 0; |
114 | retval = 0; |
| 165 | break; |
115 | break; |
| 166 | case FB_CURSOR_GOTO: |
116 | case FB_CURSOR_GOTO: |
| 167 | newrow = IPC_GET_ARG1(call); |
117 | newrow = IPC_GET_ARG1(call); |
| 168 | newcol = IPC_GET_ARG2(call); |
118 | newcol = IPC_GET_ARG2(call); |
| 169 | msim_goto(newrow, newcol); |
119 | serial_goto(newrow, newcol); |
| 170 | lastrow = newrow; |
120 | lastrow = newrow; |
| 171 | lastcol = newcol; |
121 | lastcol = newcol; |
| 172 | retval = 0; |
122 | retval = 0; |
| 173 | break; |
123 | break; |
| 174 | case FB_GET_CSIZE: |
124 | case FB_GET_CSIZE: |
| 175 | ipc_answer_2(callid, EOK, HEIGHT, WIDTH); |
125 | ipc_answer_2(callid, EOK, HEIGHT, WIDTH); |
| 176 | continue; |
126 | continue; |
| 177 | case FB_CLEAR: |
127 | case FB_CLEAR: |
| 178 | msim_clrscr(); |
128 | serial_clrscr(); |
| 179 | retval = 0; |
129 | retval = 0; |
| 180 | break; |
130 | break; |
| 181 | case FB_SET_STYLE: |
131 | case FB_SET_STYLE: |
| 182 | fgcolor = IPC_GET_ARG1(call); |
132 | fgcolor = IPC_GET_ARG1(call); |
| 183 | bgcolor = IPC_GET_ARG2(call); |
133 | bgcolor = IPC_GET_ARG2(call); |
| 184 | if (fgcolor < bgcolor) |
134 | if (fgcolor < bgcolor) |
| 185 | msim_set_style(0); |
135 | serial_set_style(0); |
| 186 | else |
136 | else |
| 187 | msim_set_style(7); |
137 | serial_set_style(7); |
| 188 | retval = 0; |
138 | retval = 0; |
| 189 | break; |
139 | break; |
| 190 | case FB_SCROLL: |
140 | case FB_SCROLL: |
| 191 | i = IPC_GET_ARG1(call); |
141 | i = IPC_GET_ARG1(call); |
| 192 | if ((i > HEIGHT) || (i < -HEIGHT)) { |
142 | if ((i > HEIGHT) || (i < -HEIGHT)) { |
| 193 | retval = EINVAL; |
143 | retval = EINVAL; |
| 194 | break; |
144 | break; |
| 195 | } |
145 | } |
| 196 | msim_scroll(i); |
146 | serial_scroll(i); |
| 197 | msim_goto(lastrow, lastcol); |
147 | serial_goto(lastrow, lastcol); |
| 198 | retval = 0; |
148 | retval = 0; |
| 199 | break; |
149 | break; |
| 200 | case FB_CURSOR_VISIBILITY: |
150 | case FB_CURSOR_VISIBILITY: |
| 201 | if(IPC_GET_ARG1(call)) |
151 | if(IPC_GET_ARG1(call)) |
| 202 | msim_cursor_enable(); |
152 | serial_cursor_enable(); |
| 203 | else |
153 | else |
| 204 | msim_cursor_disable(); |
154 | serial_cursor_disable(); |
| 205 | retval = 0; |
155 | retval = 0; |
| 206 | break; |
156 | break; |
| 207 | default: |
157 | default: |
| 208 | retval = ENOENT; |
158 | retval = ENOENT; |
| 209 | } |
159 | } |
| Line 216... | Line 166... | ||
| 216 | void *phys_addr = (void *) sysinfo_value("fb.address.physical"); |
166 | void *phys_addr = (void *) sysinfo_value("fb.address.physical"); |
| 217 | virt_addr = (char *) as_get_mappable_page(1); |
167 | virt_addr = (char *) as_get_mappable_page(1); |
| 218 | 168 | ||
| 219 | physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE); |
169 | physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE); |
| 220 | 170 | ||
| - | 171 | serial_console_init(msim_putc, WIDTH, HEIGHT); |
|
| - | 172 | ||
| 221 | async_set_client_connection(msim_client_connection); |
173 | async_set_client_connection(msim_client_connection); |
| 222 | return 0; |
174 | return 0; |
| 223 | } |
175 | } |
| 224 | 176 | ||
| 225 | /** |
177 | /** |