Rev 1964 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1964 | Rev 1968 | ||
---|---|---|---|
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 | 37 | ||
38 | #include <stdlib.h> |
38 | #include <stdlib.h> |
39 | #include <unistd.h> |
39 | #include <unistd.h> |
40 | #include <align.h> |
40 | #include <align.h> |
41 | #include <async.h> |
41 | #include <async.h> |
42 | #include <ipc/ipc.h> |
42 | #include <ipc/ipc.h> |
43 | #include <errno.h> |
43 | #include <errno.h> |
44 | #include <stdio.h> |
44 | #include <stdio.h> |
45 | #include <ddi.h> |
45 | #include <ddi.h> |
46 | #include <sysinfo.h> |
46 | #include <sysinfo.h> |
47 | #include <as.h> |
47 | #include <as.h> |
48 | #include <ipc/fb.h> |
48 | #include <ipc/fb.h> |
49 | #include <ipc/ipc.h> |
49 | #include <ipc/ipc.h> |
50 | #include <ipc/ns.h> |
50 | #include <ipc/ns.h> |
51 | #include <ipc/services.h> |
51 | #include <ipc/services.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 | 64 | ||
65 | #define EGA_IO_ADDRESS 0x3d4 |
65 | #define EGA_IO_ADDRESS 0x3d4 |
66 | #define EGA_IO_SIZE 2 |
66 | #define EGA_IO_SIZE 2 |
67 | 67 | ||
68 | #define NORMAL_COLOR 0x0f |
68 | #define NORMAL_COLOR 0x0f |
69 | #define INVERTED_COLOR 0xf0 |
69 | #define INVERTED_COLOR 0xf0 |
70 | 70 | ||
71 | #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) |
71 | #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) |
72 | 72 | ||
73 | typedef unsigned char u8; |
73 | typedef unsigned char u8; |
74 | typedef unsigned short u16; |
74 | typedef unsigned short u16; |
75 | typedef unsigned int u32; |
75 | typedef unsigned int u32; |
76 | 76 | ||
77 | 77 | ||
78 | /* Allow only 1 connection */ |
78 | /* Allow only 1 connection */ |
79 | static int client_connected = 0; |
79 | static int client_connected = 0; |
80 | 80 | ||
81 | static unsigned int scr_width; |
81 | static unsigned int scr_width; |
82 | static unsigned int scr_height; |
82 | static unsigned int scr_height; |
83 | static char *scr_addr; |
83 | static char *scr_addr; |
84 | 84 | ||
85 | static unsigned int style = NORMAL_COLOR; |
85 | static unsigned int style = NORMAL_COLOR; |
86 | 86 | ||
87 | static inline void outb(u16 port, u8 b) |
87 | static inline void outb(u16 port, u8 b) |
88 | { |
88 | { |
89 | asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port)); |
89 | asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port)); |
90 | } |
90 | } |
91 | 91 | ||
92 | static inline void outw(u16 port, u16 w) |
92 | static inline void outw(u16 port, u16 w) |
93 | { |
93 | { |
94 | asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port)); |
94 | asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port)); |
95 | } |
95 | } |
96 | 96 | ||
97 | static inline void outl(u16 port, u32 l) |
97 | static inline void outl(u16 port, u32 l) |
98 | { |
98 | { |
99 | asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port)); |
99 | asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port)); |
100 | } |
100 | } |
101 | 101 | ||
102 | static inline u8 inb(u16 port) |
102 | static inline u8 inb(u16 port) |
103 | { |
103 | { |
104 | u8 val; |
104 | u8 val; |
105 | 105 | ||
106 | asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port)); |
106 | asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port)); |
107 | return val; |
107 | return val; |
108 | } |
108 | } |
109 | 109 | ||
110 | static inline u16 inw(u16 port) |
110 | static inline u16 inw(u16 port) |
111 | { |
111 | { |
112 | u16 val; |
112 | u16 val; |
113 | 113 | ||
114 | asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port)); |
114 | asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port)); |
115 | return val; |
115 | return val; |
116 | } |
116 | } |
117 | 117 | ||
118 | static inline u32 inl(u16 port) |
118 | static inline u32 inl(u16 port) |
119 | { |
119 | { |
120 | u32 val; |
120 | u32 val; |
121 | 121 | ||
122 | asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port)); |
122 | asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port)); |
123 | return val; |
123 | return val; |
124 | } |
124 | } |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | 128 | ||
129 | static void clrscr(void) |
129 | static void clrscr(void) |
130 | { |
130 | { |
131 | int i; |
131 | int i; |
132 | 132 | ||
133 | for (i=0; i < scr_width*scr_height; i++) { |
133 | for (i=0; i < scr_width*scr_height; i++) { |
134 | scr_addr[i*2] = ' '; |
134 | scr_addr[i*2] = ' '; |
135 | scr_addr[i*2+1] = style; |
135 | scr_addr[i*2+1] = style; |
136 | } |
136 | } |
137 | } |
137 | } |
138 | 138 | ||
139 | static void cursor_goto(unsigned int row, unsigned int col) |
139 | static void cursor_goto(unsigned int row, unsigned int col) |
140 | { |
140 | { |
141 | int ega_cursor; |
141 | int ega_cursor; |
142 | 142 | ||
143 | ega_cursor=col+scr_width*row; |
143 | ega_cursor=col+scr_width*row; |
144 | 144 | ||
145 | outb(EGA_IO_ADDRESS , 0xe); |
145 | outb(EGA_IO_ADDRESS , 0xe); |
146 | outb(EGA_IO_ADDRESS + 1, (ega_cursor >>8) & 0xff); |
146 | outb(EGA_IO_ADDRESS + 1, (ega_cursor >>8) & 0xff); |
147 | outb(EGA_IO_ADDRESS , 0xf); |
147 | outb(EGA_IO_ADDRESS , 0xf); |
148 | outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff); |
148 | outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff); |
149 | } |
149 | } |
150 | 150 | ||
151 | static void cursor_disable(void) |
151 | static void cursor_disable(void) |
152 | { |
152 | { |
153 | u8 stat; |
153 | u8 stat; |
154 | outb(EGA_IO_ADDRESS , 0xa); |
154 | outb(EGA_IO_ADDRESS , 0xa); |
155 | stat=inb(EGA_IO_ADDRESS + 1); |
155 | stat=inb(EGA_IO_ADDRESS + 1); |
156 | outb(EGA_IO_ADDRESS , 0xa); |
156 | outb(EGA_IO_ADDRESS , 0xa); |
157 | outb(EGA_IO_ADDRESS +1 ,stat | (1<<5) ); |
157 | outb(EGA_IO_ADDRESS +1 ,stat | (1<<5) ); |
158 | } |
158 | } |
159 | 159 | ||
160 | static void cursor_enable(void) |
160 | static void cursor_enable(void) |
161 | { |
161 | { |
162 | u8 stat; |
162 | u8 stat; |
163 | outb(EGA_IO_ADDRESS , 0xa); |
163 | outb(EGA_IO_ADDRESS , 0xa); |
164 | stat=inb(EGA_IO_ADDRESS + 1); |
164 | stat=inb(EGA_IO_ADDRESS + 1); |
165 | outb(EGA_IO_ADDRESS , 0xa); |
165 | outb(EGA_IO_ADDRESS , 0xa); |
166 | outb(EGA_IO_ADDRESS +1 ,stat & (~(1<<5)) ); |
166 | outb(EGA_IO_ADDRESS +1 ,stat & (~(1<<5)) ); |
167 | } |
167 | } |
168 | 168 | ||
169 | static void scroll(int rows) |
169 | static void scroll(int rows) |
170 | { |
170 | { |
171 | int i; |
171 | int i; |
172 | if (rows > 0) { |
172 | if (rows > 0) { |
173 | memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2, scr_width * scr_height * 2 - rows * scr_width * 2); |
173 | memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2, scr_width * scr_height * 2 - rows * scr_width * 2); |
174 | for (i = 0; i < rows * scr_width ; i ++) |
174 | for (i = 0; i < rows * scr_width ; i ++) |
175 | (((short *)scr_addr) + scr_width * scr_height - rows * scr_width) [i] = ((style << 8) + ' '); |
175 | (((short *)scr_addr) + scr_width * scr_height - rows * scr_width) [i] = ((style << 8) + ' '); |
176 | } else if (rows < 0) { |
176 | } else if (rows < 0) { |
177 | 177 | ||
178 | memcpy (((char *)scr_addr) - rows * scr_width * 2 ,scr_addr ,scr_width * scr_height * 2 + rows * scr_width * 2); |
178 | memcpy (((char *)scr_addr) - rows * scr_width * 2 ,scr_addr ,scr_width * scr_height * 2 + rows * scr_width * 2); |
179 | for (i = 0; i < - rows * scr_width ; i++) |
179 | for (i = 0; i < - rows * scr_width ; i++) |
180 | ((short *)scr_addr) [i] = ((style << 8 ) + ' '); |
180 | ((short *)scr_addr) [i] = ((style << 8 ) + ' '); |
181 | } |
181 | } |
182 | } |
182 | } |
183 | 183 | ||
184 | static void printchar(char c, unsigned int row, unsigned int col) |
184 | static void printchar(char c, unsigned int row, unsigned int col) |
185 | { |
185 | { |
186 | scr_addr[(row*scr_width + col)*2] = c; |
186 | scr_addr[(row*scr_width + col)*2] = c; |
187 | scr_addr[(row*scr_width + col)*2+1] = style; |
187 | scr_addr[(row*scr_width + col)*2+1] = style; |
188 | 188 | ||
189 | cursor_goto(row,col+1); |
189 | cursor_goto(row,col+1); |
190 | } |
190 | } |
191 | 191 | ||
192 | static void draw_text_data(keyfield_t *data) |
192 | static void draw_text_data(keyfield_t *data) |
193 | { |
193 | { |
194 | int i; |
194 | int i; |
195 | 195 | ||
196 | for (i=0; i < scr_width*scr_height; i++) { |
196 | for (i=0; i < scr_width*scr_height; i++) { |
197 | scr_addr[i*2] = data[i].character; |
197 | scr_addr[i*2] = data[i].character; |
198 | scr_addr[i*2+1] = EGA_STYLE(data[i].style.fg_color, data[i].style.bg_color); |
198 | scr_addr[i*2+1] = EGA_STYLE(data[i].style.fg_color, data[i].style.bg_color); |
199 | } |
199 | } |
200 | } |
200 | } |
201 | 201 | ||
202 | static int save_screen(void) |
202 | static int save_screen(void) |
203 | { |
203 | { |
204 | int i; |
204 | int i; |
205 | short *mem; |
205 | short *mem; |
206 | for (i=0 ;( i < MAX_SAVED_SCREENS ) && (saved_screens[i].data); i++); |
206 | for (i=0 ;( i < MAX_SAVED_SCREENS ) && (saved_screens[i].data); i++); |
207 | if (i == MAX_SAVED_SCREENS) |
207 | if (i == MAX_SAVED_SCREENS) |
208 | return EINVAL; |
208 | return EINVAL; |
209 | if (!(saved_screens[i].data=malloc( 2 * scr_width*scr_height ))) |
209 | if (!(saved_screens[i].data=malloc( 2 * scr_width*scr_height ))) |
210 | return ENOMEM; |
210 | return ENOMEM; |
211 | memcpy (saved_screens[i].data ,scr_addr ,2 * scr_width * scr_height) |
211 | memcpy (saved_screens[i].data ,scr_addr ,2 * scr_width * scr_height) |
212 | ; |
212 | ; |
213 | return i; |
213 | return i; |
214 | } |
214 | } |
215 | 215 | ||
216 | static int print_screen(int i) |
216 | static int print_screen(int i) |
217 | { |
217 | { |
218 | if (saved_screens[i].data) |
218 | if (saved_screens[i].data) |
219 | memcpy (scr_addr,saved_screens[i].data, 2 * scr_width * scr_height); |
219 | memcpy (scr_addr,saved_screens[i].data, 2 * scr_width * scr_height); |
220 | else return EINVAL; |
220 | else return EINVAL; |
221 | return i; |
221 | return i; |
222 | } |
222 | } |
223 | 223 | ||
224 | 224 | ||
225 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
225 | static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
226 | { |
226 | { |
227 | int retval; |
227 | int retval; |
228 | ipc_callid_t callid; |
228 | ipc_callid_t callid; |
229 | ipc_call_t call; |
229 | ipc_call_t call; |
230 | char c; |
230 | char c; |
231 | unsigned int row, col; |
231 | unsigned int row, col; |
232 | int bgcolor,fgcolor; |
232 | int bgcolor,fgcolor; |
233 | keyfield_t *interbuf = NULL; |
233 | keyfield_t *interbuf = NULL; |
234 | size_t intersize = 0; |
234 | size_t intersize = 0; |
235 | int i; |
235 | int i; |
236 | 236 | ||
237 | if (client_connected) { |
237 | if (client_connected) { |
238 | ipc_answer_fast(iid, ELIMIT, 0,0); |
238 | ipc_answer_fast(iid, ELIMIT, 0,0); |
239 | return; |
239 | return; |
240 | } |
240 | } |
241 | client_connected = 1; |
241 | client_connected = 1; |
242 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
242 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
243 | 243 | ||
244 | while (1) { |
244 | while (1) { |
245 | callid = async_get_call(&call); |
245 | callid = async_get_call(&call); |
246 | switch (IPC_GET_METHOD(call)) { |
246 | switch (IPC_GET_METHOD(call)) { |
247 | case IPC_M_PHONE_HUNGUP: |
247 | case IPC_M_PHONE_HUNGUP: |
248 | client_connected = 0; |
248 | client_connected = 0; |
249 | ipc_answer_fast(callid,0,0,0); |
249 | ipc_answer_fast(callid,0,0,0); |
250 | return; /* Exit thread */ |
250 | return; /* Exit thread */ |
251 | case IPC_M_AS_AREA_SEND: |
251 | case IPC_M_AS_AREA_SEND: |
252 | /* We accept one area for data interchange */ |
252 | /* We accept one area for data interchange */ |
253 | intersize = IPC_GET_ARG2(call); |
253 | intersize = IPC_GET_ARG2(call); |
254 | if (intersize >= scr_width*scr_height*sizeof(*interbuf)) { |
254 | if (intersize >= scr_width*scr_height*sizeof(*interbuf)) { |
255 | receive_comm_area(callid,&call,(void **)&interbuf); |
255 | receive_comm_area(callid,&call,(void **)&interbuf); |
256 | continue; |
256 | continue; |
257 | } |
257 | } |
258 | retval = EINVAL; |
258 | retval = EINVAL; |
259 | break; |
259 | break; |
260 | case FB_DRAW_TEXT_DATA: |
260 | case FB_DRAW_TEXT_DATA: |
261 | if (!interbuf) { |
261 | if (!interbuf) { |
262 | retval = EINVAL; |
262 | retval = EINVAL; |
263 | break; |
263 | break; |
264 | } |
264 | } |
265 | draw_text_data(interbuf); |
265 | draw_text_data(interbuf); |
266 | retval = 0; |
266 | retval = 0; |
267 | break; |
267 | break; |
268 | case FB_GET_CSIZE: |
268 | case FB_GET_CSIZE: |
269 | ipc_answer_fast(callid, 0, scr_height, scr_width); |
269 | ipc_answer_fast(callid, 0, scr_height, scr_width); |
270 | continue; |
270 | continue; |
271 | case FB_CLEAR: |
271 | case FB_CLEAR: |
272 | clrscr(); |
272 | clrscr(); |
273 | retval = 0; |
273 | retval = 0; |
274 | break; |
274 | break; |
275 | case FB_PUTCHAR: |
275 | case FB_PUTCHAR: |
276 | c = IPC_GET_ARG1(call); |
276 | c = IPC_GET_ARG1(call); |
277 | row = IPC_GET_ARG2(call); |
277 | row = IPC_GET_ARG2(call); |
278 | col = IPC_GET_ARG3(call); |
278 | col = IPC_GET_ARG3(call); |
279 | if (col >= scr_width || row >= scr_height) { |
279 | if (col >= scr_width || row >= scr_height) { |
280 | retval = EINVAL; |
280 | retval = EINVAL; |
281 | break; |
281 | break; |
282 | } |
282 | } |
283 | printchar(c,row,col); |
283 | printchar(c,row,col); |
284 | retval = 0; |
284 | retval = 0; |
285 | break; |
285 | break; |
286 | case FB_CURSOR_GOTO: |
286 | case FB_CURSOR_GOTO: |
287 | row = IPC_GET_ARG1(call); |
287 | row = IPC_GET_ARG1(call); |
288 | col = IPC_GET_ARG2(call); |
288 | col = IPC_GET_ARG2(call); |
289 | if (row >= scr_height || col >= scr_width) { |
289 | if (row >= scr_height || col >= scr_width) { |
290 | retval = EINVAL; |
290 | retval = EINVAL; |
291 | break; |
291 | break; |
292 | } |
292 | } |
293 | cursor_goto(row,col); |
293 | cursor_goto(row,col); |
294 | retval = 0; |
294 | retval = 0; |
295 | break; |
295 | break; |
296 | case FB_SCROLL: |
296 | case FB_SCROLL: |
297 | i = IPC_GET_ARG1(call); |
297 | i = IPC_GET_ARG1(call); |
298 | if (i > scr_height || i < (- (int)scr_height)) { |
298 | if (i > scr_height || i < (- (int)scr_height)) { |
299 | retval = EINVAL; |
299 | retval = EINVAL; |
300 | break; |
300 | break; |
301 | } |
301 | } |
302 | scroll(i); |
302 | scroll(i); |
303 | retval = 0; |
303 | retval = 0; |
304 | break; |
304 | break; |
305 | case FB_CURSOR_VISIBILITY: |
305 | case FB_CURSOR_VISIBILITY: |
306 | if(IPC_GET_ARG1(call)) |
306 | if(IPC_GET_ARG1(call)) |
307 | cursor_enable(); |
307 | cursor_enable(); |
308 | else |
308 | else |
309 | cursor_disable(); |
309 | cursor_disable(); |
310 | retval = 0; |
310 | retval = 0; |
311 | break; |
311 | break; |
312 | case FB_SET_STYLE: |
312 | case FB_SET_STYLE: |
313 | fgcolor = IPC_GET_ARG1(call); |
313 | fgcolor = IPC_GET_ARG1(call); |
314 | bgcolor = IPC_GET_ARG2(call); |
314 | bgcolor = IPC_GET_ARG2(call); |
315 | style = EGA_STYLE(fgcolor, bgcolor); |
315 | style = EGA_STYLE(fgcolor, bgcolor); |
316 | break; |
316 | break; |
317 | case FB_VP_DRAW_PIXMAP: |
317 | case FB_VP_DRAW_PIXMAP: |
318 | i = IPC_GET_ARG2(call); |
318 | i = IPC_GET_ARG2(call); |
319 | retval = print_screen(i); |
319 | retval = print_screen(i); |
320 | break; |
320 | break; |
321 | case FB_VP2PIXMAP: |
321 | case FB_VP2PIXMAP: |
322 | retval = save_screen(); |
322 | retval = save_screen(); |
323 | break; |
323 | break; |
324 | case FB_DROP_PIXMAP: |
324 | case FB_DROP_PIXMAP: |
325 | i = IPC_GET_ARG1(call); |
325 | i = IPC_GET_ARG1(call); |
326 | if (i >= MAX_SAVED_SCREENS) { |
326 | if (i >= MAX_SAVED_SCREENS) { |
327 | retval = EINVAL; |
327 | retval = EINVAL; |
328 | break; |
328 | break; |
329 | } |
329 | } |
330 | if (saved_screens[i].data) { |
330 | if (saved_screens[i].data) { |
331 | free(saved_screens[i].data); |
331 | free(saved_screens[i].data); |
332 | saved_screens[i].data = NULL; |
332 | saved_screens[i].data = NULL; |
333 | } |
333 | } |
334 | break; |
334 | break; |
335 | 335 | ||
336 | default: |
336 | default: |
337 | retval = ENOENT; |
337 | retval = ENOENT; |
338 | } |
338 | } |
339 | ipc_answer_fast(callid,retval,0,0); |
339 | ipc_answer_fast(callid,retval,0,0); |
340 | } |
340 | } |
341 | } |
341 | } |
342 | 342 | ||
343 | int ega_init(void) |
343 | int ega_init(void) |
344 | { |
344 | { |
345 | void *ega_ph_addr; |
345 | void *ega_ph_addr; |
346 | size_t sz; |
346 | size_t sz; |
347 | 347 | ||
348 | 348 | ||
349 | ega_ph_addr=(void *)sysinfo_value("fb.address.physical"); |
349 | ega_ph_addr=(void *)sysinfo_value("fb.address.physical"); |
350 | scr_width=sysinfo_value("fb.width"); |
350 | scr_width=sysinfo_value("fb.width"); |
351 | scr_height=sysinfo_value("fb.height"); |
351 | scr_height=sysinfo_value("fb.height"); |
352 | iospace_enable(task_get_id(),(void *)EGA_IO_ADDRESS,2); |
352 | iospace_enable(task_get_id(),(void *)EGA_IO_ADDRESS,2); |
353 | 353 | ||
354 | sz = scr_width*scr_height*2; |
354 | sz = scr_width*scr_height*2; |
355 | scr_addr = as_get_mappable_page(sz); |
355 | scr_addr = as_get_mappable_page(sz); |
356 | 356 | ||
357 | map_physmem(ega_ph_addr, scr_addr, ALIGN_UP(sz,PAGE_SIZE)>>PAGE_WIDTH, |
357 | map_physmem(ega_ph_addr, scr_addr, ALIGN_UP(sz,PAGE_SIZE)>>PAGE_WIDTH, |
358 | AS_AREA_READ | AS_AREA_WRITE); |
358 | AS_AREA_READ | AS_AREA_WRITE); |
359 | 359 | ||
360 | async_set_client_connection(ega_client_connection); |
360 | async_set_client_connection(ega_client_connection); |
361 | 361 | ||
362 | return 0; |
362 | return 0; |
363 | } |
363 | } |
364 | 364 | ||
365 | 365 | ||
366 | /** |
366 | /** |
367 | * @} |
367 | * @} |
368 | */ |
368 | */ |
369 | 369 |