Rev 3657 | Rev 3866 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3657 | Rev 3755 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2006 Ondrej Palkovsky |
2 | * Copyright (c) 2006 Ondrej Palkovsky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @defgroup egafb EGA framebuffer |
29 | /** @defgroup egafb EGA framebuffer |
30 | * @brief HelenOS EGA framebuffer. |
30 | * @brief HelenOS EGA framebuffer. |
31 | * @ingroup fbs |
31 | * @ingroup fbs |
32 | * @{ |
32 | * @{ |
33 | */ |
33 | */ |
34 | /** @file |
34 | /** @file |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #include <stdlib.h> |
37 | #include <stdlib.h> |
38 | #include <unistd.h> |
38 | #include <unistd.h> |
39 | #include <align.h> |
39 | #include <align.h> |
40 | #include <async.h> |
40 | #include <async.h> |
41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
42 | #include <errno.h> |
42 | #include <errno.h> |
43 | #include <stdio.h> |
43 | #include <stdio.h> |
44 | #include <ddi.h> |
44 | #include <ddi.h> |
45 | #include <sysinfo.h> |
45 | #include <sysinfo.h> |
46 | #include <as.h> |
46 | #include <as.h> |
47 | #include <ipc/fb.h> |
47 | #include <ipc/fb.h> |
48 | #include <ipc/ipc.h> |
48 | #include <ipc/ipc.h> |
49 | #include <ipc/ns.h> |
49 | #include <ipc/ns.h> |
50 | #include <ipc/services.h> |
50 | #include <ipc/services.h> |
51 | #include <libarch/ddi.h> |
51 | #include <libarch/ddi.h> |
52 | 52 | ||
53 | #include "ega.h" |
53 | #include "ega.h" |
54 | #include "../console/screenbuffer.h" |
54 | #include "../console/screenbuffer.h" |
55 | #include "main.h" |
55 | #include "main.h" |
56 | 56 | ||
57 | #define MAX_SAVED_SCREENS 256 |
57 | #define MAX_SAVED_SCREENS 256 |
58 | typedef struct saved_screen { |
58 | typedef struct saved_screen { |
59 | short *data; |
59 | short *data; |
60 | } saved_screen; |
60 | } saved_screen; |
61 | 61 | ||
62 | saved_screen saved_screens[MAX_SAVED_SCREENS]; |
62 | saved_screen saved_screens[MAX_SAVED_SCREENS]; |
63 | 63 | ||
64 | #define EGA_IO_ADDRESS 0x3d4 |
64 | #define EGA_IO_ADDRESS 0x3d4 |
65 | #define EGA_IO_SIZE 2 |
65 | #define EGA_IO_SIZE 2 |
66 | 66 | ||
67 | int ega_normal_color=0x0f; |
67 | int ega_normal_color=0x0f; |
68 | int ega_inverted_color=0xf0; |
68 | int ega_inverted_color=0xf0; |
69 | 69 | ||
70 | #define NORMAL_COLOR ega_normal_color |
70 | #define NORMAL_COLOR ega_normal_color |
71 | #define INVERTED_COLOR ega_inverted_color |
71 | #define INVERTED_COLOR ega_inverted_color |
72 | 72 | ||
73 | #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) |
73 | #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) |
74 | 74 | ||
75 | /* Allow only 1 connection */ |
75 | /* Allow only 1 connection */ |
76 | static int client_connected = 0; |
76 | static int client_connected = 0; |
77 | 77 | ||
78 | static unsigned int scr_width; |
78 | static unsigned int scr_width; |
79 | static unsigned int scr_height; |
79 | static unsigned int scr_height; |
80 | static char *scr_addr; |
80 | static char *scr_addr; |
81 | 81 | ||
82 | static unsigned int style; |
82 | static unsigned int style; |
83 | 83 | ||
84 | static void clrscr(void) |
84 | static void clrscr(void) |
85 | { |
85 | { |
86 | int i; |
86 | int i; |
87 | 87 | ||
88 | for (i = 0; i < scr_width * scr_height; i++) { |
88 | for (i = 0; i < scr_width * scr_height; i++) { |
89 | scr_addr[i * 2] = ' '; |
89 | scr_addr[i * 2] = ' '; |
90 | scr_addr[i * 2 + 1] = style; |
90 | scr_addr[i * 2 + 1] = style; |
91 | } |
91 | } |
92 | } |
92 | } |
93 | 93 | ||
94 | static void cursor_goto(unsigned int row, unsigned int col) |
94 | static void cursor_goto(unsigned int row, unsigned int col) |
95 | { |
95 | { |
96 | int ega_cursor; |
96 | int ega_cursor; |
97 | 97 | ||
98 | ega_cursor = col + scr_width * row; |
98 | ega_cursor = col + scr_width * row; |
99 | 99 | ||
100 | outb(EGA_IO_ADDRESS, 0xe); |
100 | outb(EGA_IO_ADDRESS, 0xe); |
101 | outb(EGA_IO_ADDRESS + 1, (ega_cursor >> 8) & 0xff); |
101 | outb(EGA_IO_ADDRESS + 1, (ega_cursor >> 8) & 0xff); |
102 | outb(EGA_IO_ADDRESS, 0xf); |
102 | outb(EGA_IO_ADDRESS, 0xf); |
103 | outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff); |
103 | outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff); |
104 | } |
104 | } |
105 | 105 | ||
106 | static void cursor_disable(void) |
106 | static void cursor_disable(void) |
107 | { |
107 | { |
108 | uint8_t stat; |
108 | uint8_t stat; |
109 | 109 | ||
110 | outb(EGA_IO_ADDRESS, 0xa); |
110 | outb(EGA_IO_ADDRESS, 0xa); |
111 | stat=inb(EGA_IO_ADDRESS + 1); |
111 | stat=inb(EGA_IO_ADDRESS + 1); |
112 | outb(EGA_IO_ADDRESS, 0xa); |
112 | outb(EGA_IO_ADDRESS, 0xa); |
113 | outb(EGA_IO_ADDRESS + 1, stat | (1 << 5)); |
113 | outb(EGA_IO_ADDRESS + 1, stat | (1 << 5)); |
114 | } |
114 | } |
115 | 115 | ||
116 | static void cursor_enable(void) |
116 | static void cursor_enable(void) |
117 | { |
117 | { |
118 | uint8_t stat; |
118 | uint8_t stat; |
119 | 119 | ||
120 | outb(EGA_IO_ADDRESS, 0xa); |
120 | outb(EGA_IO_ADDRESS, 0xa); |
121 | stat=inb(EGA_IO_ADDRESS + 1); |
121 | stat=inb(EGA_IO_ADDRESS + 1); |
122 | outb(EGA_IO_ADDRESS, 0xa); |
122 | outb(EGA_IO_ADDRESS, 0xa); |
123 | outb(EGA_IO_ADDRESS + 1, stat & (~(1 << 5))); |
123 | outb(EGA_IO_ADDRESS + 1, stat & (~(1 << 5))); |
124 | } |
124 | } |
125 | 125 | ||
126 | static void scroll(int rows) |
126 | static void scroll(int rows) |
127 | { |
127 | { |
128 | int i; |
128 | int i; |
129 | if (rows > 0) { |
129 | if (rows > 0) { |
130 | memcpy(scr_addr, ((char *) scr_addr) + rows * scr_width * 2, |
130 | memmove(scr_addr, ((char *) scr_addr) + rows * scr_width * 2, |
131 | scr_width * scr_height * 2 - rows * scr_width * 2); |
131 | scr_width * scr_height * 2 - rows * scr_width * 2); |
132 | for (i = 0; i < rows * scr_width; i++) |
132 | for (i = 0; i < rows * scr_width; i++) |
133 | (((short *) scr_addr) + scr_width * scr_height - rows * |
133 | (((short *) scr_addr) + scr_width * scr_height - rows * |
134 | scr_width)[i] = ((style << 8) + ' '); |
134 | scr_width)[i] = ((style << 8) + ' '); |
135 | } else if (rows < 0) { |
135 | } else if (rows < 0) { |
136 | memcpy(((char *)scr_addr) - rows * scr_width * 2, scr_addr, |
136 | memmove(((char *)scr_addr) - rows * scr_width * 2, scr_addr, |
137 | scr_width * scr_height * 2 + rows * scr_width * 2); |
137 | scr_width * scr_height * 2 + rows * scr_width * 2); |
138 | for (i = 0; i < -rows * scr_width; i++) |
138 | for (i = 0; i < -rows * scr_width; i++) |
139 | ((short *)scr_addr)[i] = ((style << 8 ) + ' '); |
139 | ((short *)scr_addr)[i] = ((style << 8 ) + ' '); |
140 | } |
140 | } |
141 | } |
141 | } |
142 | 142 | ||
143 | static void printchar(char c, unsigned int row, unsigned int col) |
143 | static void printchar(char c, unsigned int row, unsigned int col) |
144 | { |
144 | { |
145 | scr_addr[(row * scr_width + col) * 2] = c; |
145 | scr_addr[(row * scr_width + col) * 2] = c; |
146 | scr_addr[(row * scr_width + col) * 2 + 1] = style; |
146 | scr_addr[(row * scr_width + col) * 2 + 1] = style; |
147 | 147 | ||
148 | cursor_goto(row, col + 1); |
148 | cursor_goto(row, col + 1); |
149 | } |
149 | } |
150 | 150 | ||
151 | static void draw_text_data(keyfield_t *data) |
151 | static void draw_text_data(keyfield_t *data) |
152 | { |
152 | { |
153 | int i; |
153 | int i; |
154 | 154 | ||
155 | for (i = 0; i < scr_width * scr_height; i++) { |
155 | for (i = 0; i < scr_width * scr_height; i++) { |
156 | scr_addr[i * 2] = data[i].character; |
156 | scr_addr[i * 2] = data[i].character; |
157 | scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color, |
157 | scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color, |
158 | data[i].style.bg_color); |
158 | data[i].style.bg_color); |
159 | } |
159 | } |
160 | } |
160 | } |
161 | 161 | ||
162 | static int save_screen(void) |
162 | static int save_screen(void) |
163 | { |
163 | { |
164 | int i; |
164 | int i; |
165 | 165 | ||
166 | for (i = 0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++) |
166 | for (i = 0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++) |
167 | ; |
167 | ; |
168 | if (i == MAX_SAVED_SCREENS) |
168 | if (i == MAX_SAVED_SCREENS) |
169 | return EINVAL; |
169 | return EINVAL; |
170 | if (!(saved_screens[i].data = malloc(2 * scr_width * scr_height))) |
170 | if (!(saved_screens[i].data = malloc(2 * scr_width * scr_height))) |
171 | return ENOMEM; |
171 | return ENOMEM; |
172 | memcpy(saved_screens[i].data, scr_addr, 2 * scr_width * scr_height); |
172 | memcpy(saved_screens[i].data, scr_addr, 2 * scr_width * scr_height); |
173 | 173 | ||
174 | return i; |
174 | return i; |
175 | } |
175 | } |
176 | 176 | ||
177 | static int print_screen(int i) |
177 | static int print_screen(int i) |
178 | { |
178 | { |
179 | if (saved_screens[i].data) |
179 | if (saved_screens[i].data) |
180 | memcpy(scr_addr, saved_screens[i].data, 2 * scr_width * |
180 | memcpy(scr_addr, saved_screens[i].data, 2 * scr_width * |
181 | scr_height); |
181 | scr_height); |
182 | else |
182 | else |
183 | return EINVAL; |
183 | return EINVAL; |
184 | return i; |
184 | return i; |
185 | } |
185 | } |
186 | 186 | ||
187 | 187 | ||
188 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
188 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
189 | { |
189 | { |
190 | int retval; |
190 | int retval; |
191 | ipc_callid_t callid; |
191 | ipc_callid_t callid; |
192 | ipc_call_t call; |
192 | ipc_call_t call; |
193 | char c; |
193 | char c; |
194 | unsigned int row, col; |
194 | unsigned int row, col; |
195 | int bgcolor,fgcolor; |
195 | int bgcolor,fgcolor; |
196 | keyfield_t *interbuf = NULL; |
196 | keyfield_t *interbuf = NULL; |
197 | size_t intersize = 0; |
197 | size_t intersize = 0; |
198 | int i; |
198 | int i; |
199 | 199 | ||
200 | if (client_connected) { |
200 | if (client_connected) { |
201 | ipc_answer_0(iid, ELIMIT); |
201 | ipc_answer_0(iid, ELIMIT); |
202 | return; |
202 | return; |
203 | } |
203 | } |
204 | client_connected = 1; |
204 | client_connected = 1; |
205 | ipc_answer_0(iid, EOK); /* Accept connection */ |
205 | ipc_answer_0(iid, EOK); /* Accept connection */ |
206 | 206 | ||
207 | while (1) { |
207 | while (1) { |
208 | callid = async_get_call(&call); |
208 | callid = async_get_call(&call); |
209 | switch (IPC_GET_METHOD(call)) { |
209 | switch (IPC_GET_METHOD(call)) { |
210 | case IPC_M_PHONE_HUNGUP: |
210 | case IPC_M_PHONE_HUNGUP: |
211 | client_connected = 0; |
211 | client_connected = 0; |
212 | ipc_answer_0(callid, EOK); |
212 | ipc_answer_0(callid, EOK); |
213 | return; /* Exit thread */ |
213 | return; /* Exit thread */ |
214 | case IPC_M_SHARE_OUT: |
214 | case IPC_M_SHARE_OUT: |
215 | /* We accept one area for data interchange */ |
215 | /* We accept one area for data interchange */ |
216 | intersize = IPC_GET_ARG2(call); |
216 | intersize = IPC_GET_ARG2(call); |
217 | if (intersize >= scr_width * scr_height * |
217 | if (intersize >= scr_width * scr_height * |
218 | sizeof(*interbuf)) { |
218 | sizeof(*interbuf)) { |
219 | receive_comm_area(callid, &call, |
219 | receive_comm_area(callid, &call, |
220 | (void *) &interbuf); |
220 | (void *) &interbuf); |
221 | continue; |
221 | continue; |
222 | } |
222 | } |
223 | retval = EINVAL; |
223 | retval = EINVAL; |
224 | break; |
224 | break; |
225 | case FB_DRAW_TEXT_DATA: |
225 | case FB_DRAW_TEXT_DATA: |
226 | if (!interbuf) { |
226 | if (!interbuf) { |
227 | retval = EINVAL; |
227 | retval = EINVAL; |
228 | break; |
228 | break; |
229 | } |
229 | } |
230 | draw_text_data(interbuf); |
230 | draw_text_data(interbuf); |
231 | retval = 0; |
231 | retval = 0; |
232 | break; |
232 | break; |
233 | case FB_GET_CSIZE: |
233 | case FB_GET_CSIZE: |
234 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
234 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
235 | continue; |
235 | continue; |
236 | case FB_CLEAR: |
236 | case FB_CLEAR: |
237 | clrscr(); |
237 | clrscr(); |
238 | retval = 0; |
238 | retval = 0; |
239 | break; |
239 | break; |
240 | case FB_PUTCHAR: |
240 | case FB_PUTCHAR: |
241 | c = IPC_GET_ARG1(call); |
241 | c = IPC_GET_ARG1(call); |
242 | row = IPC_GET_ARG2(call); |
242 | row = IPC_GET_ARG2(call); |
243 | col = IPC_GET_ARG3(call); |
243 | col = IPC_GET_ARG3(call); |
244 | if (col >= scr_width || row >= scr_height) { |
244 | if (col >= scr_width || row >= scr_height) { |
245 | retval = EINVAL; |
245 | retval = EINVAL; |
246 | break; |
246 | break; |
247 | } |
247 | } |
248 | printchar(c, row, col); |
248 | printchar(c, row, col); |
249 | retval = 0; |
249 | retval = 0; |
250 | break; |
250 | break; |
251 | case FB_CURSOR_GOTO: |
251 | case FB_CURSOR_GOTO: |
252 | row = IPC_GET_ARG1(call); |
252 | row = IPC_GET_ARG1(call); |
253 | col = IPC_GET_ARG2(call); |
253 | col = IPC_GET_ARG2(call); |
254 | if (row >= scr_height || col >= scr_width) { |
254 | if (row >= scr_height || col >= scr_width) { |
255 | retval = EINVAL; |
255 | retval = EINVAL; |
256 | break; |
256 | break; |
257 | } |
257 | } |
258 | cursor_goto(row, col); |
258 | cursor_goto(row, col); |
259 | retval = 0; |
259 | retval = 0; |
260 | break; |
260 | break; |
261 | case FB_SCROLL: |
261 | case FB_SCROLL: |
262 | i = IPC_GET_ARG1(call); |
262 | i = IPC_GET_ARG1(call); |
263 | if (i > scr_height || i < -((int) scr_height)) { |
263 | if (i > scr_height || i < -((int) scr_height)) { |
264 | retval = EINVAL; |
264 | retval = EINVAL; |
265 | break; |
265 | break; |
266 | } |
266 | } |
267 | scroll(i); |
267 | scroll(i); |
268 | retval = 0; |
268 | retval = 0; |
269 | break; |
269 | break; |
270 | case FB_CURSOR_VISIBILITY: |
270 | case FB_CURSOR_VISIBILITY: |
271 | if(IPC_GET_ARG1(call)) |
271 | if(IPC_GET_ARG1(call)) |
272 | cursor_enable(); |
272 | cursor_enable(); |
273 | else |
273 | else |
274 | cursor_disable(); |
274 | cursor_disable(); |
275 | retval = 0; |
275 | retval = 0; |
276 | break; |
276 | break; |
277 | case FB_SET_STYLE: |
277 | case FB_SET_STYLE: |
278 | fgcolor = IPC_GET_ARG1(call); |
278 | fgcolor = IPC_GET_ARG1(call); |
279 | bgcolor = IPC_GET_ARG2(call); |
279 | bgcolor = IPC_GET_ARG2(call); |
280 | style = EGA_STYLE(fgcolor, bgcolor); |
280 | style = EGA_STYLE(fgcolor, bgcolor); |
281 | retval = 0; |
281 | retval = 0; |
282 | break; |
282 | break; |
283 | case FB_VP_DRAW_PIXMAP: |
283 | case FB_VP_DRAW_PIXMAP: |
284 | i = IPC_GET_ARG2(call); |
284 | i = IPC_GET_ARG2(call); |
285 | retval = print_screen(i); |
285 | retval = print_screen(i); |
286 | break; |
286 | break; |
287 | case FB_VP2PIXMAP: |
287 | case FB_VP2PIXMAP: |
288 | retval = save_screen(); |
288 | retval = save_screen(); |
289 | break; |
289 | break; |
290 | case FB_DROP_PIXMAP: |
290 | case FB_DROP_PIXMAP: |
291 | i = IPC_GET_ARG1(call); |
291 | i = IPC_GET_ARG1(call); |
292 | if (i >= MAX_SAVED_SCREENS) { |
292 | if (i >= MAX_SAVED_SCREENS) { |
293 | retval = EINVAL; |
293 | retval = EINVAL; |
294 | break; |
294 | break; |
295 | } |
295 | } |
296 | if (saved_screens[i].data) { |
296 | if (saved_screens[i].data) { |
297 | free(saved_screens[i].data); |
297 | free(saved_screens[i].data); |
298 | saved_screens[i].data = NULL; |
298 | saved_screens[i].data = NULL; |
299 | } |
299 | } |
300 | retval = 0; |
300 | retval = 0; |
301 | break; |
301 | break; |
302 | 302 | ||
303 | default: |
303 | default: |
304 | retval = ENOENT; |
304 | retval = ENOENT; |
305 | } |
305 | } |
306 | ipc_answer_0(callid, retval); |
306 | ipc_answer_0(callid, retval); |
307 | } |
307 | } |
308 | } |
308 | } |
309 | 309 | ||
310 | int ega_init(void) |
310 | int ega_init(void) |
311 | { |
311 | { |
312 | void *ega_ph_addr; |
312 | void *ega_ph_addr; |
313 | size_t sz; |
313 | size_t sz; |
314 | 314 | ||
315 | ega_ph_addr = (void *) sysinfo_value("fb.address.physical"); |
315 | ega_ph_addr = (void *) sysinfo_value("fb.address.physical"); |
316 | scr_width = sysinfo_value("fb.width"); |
316 | scr_width = sysinfo_value("fb.width"); |
317 | scr_height = sysinfo_value("fb.height"); |
317 | scr_height = sysinfo_value("fb.height"); |
318 | if(sysinfo_value("fb.blinking")) |
318 | if(sysinfo_value("fb.blinking")) |
319 | { |
319 | { |
320 | ega_normal_color&=0x77; |
320 | ega_normal_color&=0x77; |
321 | ega_inverted_color&=0x77; |
321 | ega_inverted_color&=0x77; |
322 | } |
322 | } |
323 | style = NORMAL_COLOR; |
323 | style = NORMAL_COLOR; |
324 | 324 | ||
325 | iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2); |
325 | iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2); |
326 | 326 | ||
327 | sz = scr_width * scr_height * 2; |
327 | sz = scr_width * scr_height * 2; |
328 | scr_addr = as_get_mappable_page(sz); |
328 | scr_addr = as_get_mappable_page(sz); |
329 | 329 | ||
330 | physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> |
330 | physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> |
331 | PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
331 | PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
332 | 332 | ||
333 | async_set_client_connection(ega_client_connection); |
333 | async_set_client_connection(ega_client_connection); |
334 | 334 | ||
335 | return 0; |
335 | return 0; |
336 | } |
336 | } |
337 | 337 | ||
338 | 338 | ||
339 | /** |
339 | /** |
340 | * @} |
340 | * @} |
341 | */ |
341 | */ |
342 | 342 |