Rev 2479 | Rev 2677 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2479 | Rev 2619 | ||
---|---|---|---|
Line 80... | Line 80... | ||
80 | 80 | ||
81 | static void clrscr(void) |
81 | static void clrscr(void) |
82 | { |
82 | { |
83 | int i; |
83 | int i; |
84 | 84 | ||
85 | for (i = 0; i < scr_width*scr_height; i++) { |
85 | for (i = 0; i < scr_width * scr_height; i++) { |
86 | scr_addr[i * 2] = ' '; |
86 | scr_addr[i * 2] = ' '; |
87 | scr_addr[i * 2 + 1] = style; |
87 | scr_addr[i * 2 + 1] = style; |
88 | } |
88 | } |
89 | } |
89 | } |
90 | 90 | ||
Line 123... | Line 123... | ||
123 | static void scroll(int rows) |
123 | static void scroll(int rows) |
124 | { |
124 | { |
125 | int i; |
125 | int i; |
126 | if (rows > 0) { |
126 | if (rows > 0) { |
127 | memcpy(scr_addr, ((char *) scr_addr) + rows * scr_width * 2, |
127 | memcpy(scr_addr, ((char *) scr_addr) + rows * scr_width * 2, |
128 | scr_width * scr_height * 2 - rows * scr_width * 2); |
128 | scr_width * scr_height * 2 - rows * scr_width * 2); |
129 | for (i = 0; i < rows * scr_width; i++) |
129 | for (i = 0; i < rows * scr_width; i++) |
130 | (((short *) scr_addr) + scr_width * scr_height - rows * |
130 | (((short *) scr_addr) + scr_width * scr_height - rows * |
131 | scr_width)[i] = ((style << 8) + ' '); |
131 | scr_width)[i] = ((style << 8) + ' '); |
132 | } else if (rows < 0) { |
132 | } else if (rows < 0) { |
133 | memcpy(((char *)scr_addr) - rows * scr_width * 2, scr_addr, |
133 | memcpy(((char *)scr_addr) - rows * scr_width * 2, scr_addr, |
134 | scr_width * scr_height * 2 + rows * scr_width * 2); |
134 | scr_width * scr_height * 2 + rows * scr_width * 2); |
135 | for (i = 0; i < -rows * scr_width; i++) |
135 | for (i = 0; i < -rows * scr_width; i++) |
136 | ((short *)scr_addr)[i] = ((style << 8 ) + ' '); |
136 | ((short *)scr_addr)[i] = ((style << 8 ) + ' '); |
137 | } |
137 | } |
138 | } |
138 | } |
139 | 139 | ||
Line 150... | Line 150... | ||
150 | int i; |
150 | int i; |
151 | 151 | ||
152 | for (i = 0; i < scr_width * scr_height; i++) { |
152 | for (i = 0; i < scr_width * scr_height; i++) { |
153 | scr_addr[i * 2] = data[i].character; |
153 | scr_addr[i * 2] = data[i].character; |
154 | scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color, |
154 | scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color, |
155 | data[i].style.bg_color); |
155 | data[i].style.bg_color); |
156 | } |
156 | } |
157 | } |
157 | } |
158 | 158 | ||
159 | static int save_screen(void) |
159 | static int save_screen(void) |
160 | { |
160 | { |
161 | int i; |
161 | int i; |
162 | 162 | ||
163 | for (i=0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++) |
163 | for (i = 0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++) |
164 | ; |
164 | ; |
165 | if (i == MAX_SAVED_SCREENS) |
165 | if (i == MAX_SAVED_SCREENS) |
166 | return EINVAL; |
166 | return EINVAL; |
167 | if (!(saved_screens[i].data = malloc(2 * scr_width * scr_height))) |
167 | if (!(saved_screens[i].data = malloc(2 * scr_width * scr_height))) |
168 | return ENOMEM; |
168 | return ENOMEM; |
Line 173... | Line 173... | ||
173 | 173 | ||
174 | static int print_screen(int i) |
174 | static int print_screen(int i) |
175 | { |
175 | { |
176 | if (saved_screens[i].data) |
176 | if (saved_screens[i].data) |
177 | memcpy(scr_addr, saved_screens[i].data, 2 * scr_width * |
177 | memcpy(scr_addr, saved_screens[i].data, 2 * scr_width * |
178 | scr_height); |
178 | scr_height); |
179 | else |
179 | else |
180 | return EINVAL; |
180 | return EINVAL; |
181 | return i; |
181 | return i; |
182 | } |
182 | } |
183 | 183 | ||
Line 193... | Line 193... | ||
193 | keyfield_t *interbuf = NULL; |
193 | keyfield_t *interbuf = NULL; |
194 | size_t intersize = 0; |
194 | size_t intersize = 0; |
195 | int i; |
195 | int i; |
196 | 196 | ||
197 | if (client_connected) { |
197 | if (client_connected) { |
198 | ipc_answer_fast(iid, ELIMIT, 0,0); |
198 | ipc_answer_0(iid, ELIMIT); |
199 | return; |
199 | return; |
200 | } |
200 | } |
201 | client_connected = 1; |
201 | client_connected = 1; |
202 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
202 | ipc_answer_0(iid, EOK); /* Accept connection */ |
203 | 203 | ||
204 | while (1) { |
204 | while (1) { |
205 | callid = async_get_call(&call); |
205 | callid = async_get_call(&call); |
206 | switch (IPC_GET_METHOD(call)) { |
206 | switch (IPC_GET_METHOD(call)) { |
207 | case IPC_M_PHONE_HUNGUP: |
207 | case IPC_M_PHONE_HUNGUP: |
208 | client_connected = 0; |
208 | client_connected = 0; |
209 | ipc_answer_fast(callid, 0, 0, 0); |
209 | ipc_answer_0(callid, EOK); |
210 | return; /* Exit thread */ |
210 | return; /* Exit thread */ |
211 | case IPC_M_AS_AREA_SEND: |
211 | case IPC_M_AS_AREA_SEND: |
212 | /* We accept one area for data interchange */ |
212 | /* We accept one area for data interchange */ |
213 | intersize = IPC_GET_ARG2(call); |
213 | intersize = IPC_GET_ARG2(call); |
214 | if (intersize >= scr_width * scr_height * |
214 | if (intersize >= scr_width * scr_height * |
215 | sizeof(*interbuf)) { |
215 | sizeof(*interbuf)) { |
216 | receive_comm_area(callid, &call, (void *) |
216 | receive_comm_area(callid, &call, |
217 | &interbuf); |
217 | (void *) &interbuf); |
218 | continue; |
218 | continue; |
219 | } |
219 | } |
220 | retval = EINVAL; |
220 | retval = EINVAL; |
221 | break; |
221 | break; |
222 | case FB_DRAW_TEXT_DATA: |
222 | case FB_DRAW_TEXT_DATA: |
Line 226... | Line 226... | ||
226 | } |
226 | } |
227 | draw_text_data(interbuf); |
227 | draw_text_data(interbuf); |
228 | retval = 0; |
228 | retval = 0; |
229 | break; |
229 | break; |
230 | case FB_GET_CSIZE: |
230 | case FB_GET_CSIZE: |
231 | ipc_answer_fast(callid, 0, scr_height, scr_width); |
231 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
232 | continue; |
232 | continue; |
233 | case FB_CLEAR: |
233 | case FB_CLEAR: |
234 | clrscr(); |
234 | clrscr(); |
235 | retval = 0; |
235 | retval = 0; |
236 | break; |
236 | break; |
Line 298... | Line 298... | ||
298 | break; |
298 | break; |
299 | 299 | ||
300 | default: |
300 | default: |
301 | retval = ENOENT; |
301 | retval = ENOENT; |
302 | } |
302 | } |
303 | ipc_answer_fast(callid, retval, 0, 0); |
303 | ipc_answer_0(callid, retval); |
304 | } |
304 | } |
305 | } |
305 | } |
306 | 306 | ||
307 | int ega_init(void) |
307 | int ega_init(void) |
308 | { |
308 | { |
Line 316... | Line 316... | ||
316 | 316 | ||
317 | sz = scr_width * scr_height * 2; |
317 | sz = scr_width * scr_height * 2; |
318 | scr_addr = as_get_mappable_page(sz); |
318 | scr_addr = as_get_mappable_page(sz); |
319 | 319 | ||
320 | physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> |
320 | physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> |
321 | PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
321 | PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
322 | 322 | ||
323 | async_set_client_connection(ega_client_connection); |
323 | async_set_client_connection(ega_client_connection); |
324 | 324 | ||
325 | return 0; |
325 | return 0; |
326 | } |
326 | } |