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