Mercurial > mplayer.hg
annotate linux/vbelib.c @ 2555:66837325b929
config.h cleanup, few things added to steram/demuxer headers
author | arpi |
---|---|
date | Tue, 30 Oct 2001 17:03:11 +0000 |
parents | bd734d41a407 |
children | 65cb69a90a9f |
rev | line source |
---|---|
2243 | 1 /* |
2 This file contains implementation of VESA library which is based on | |
3 LRMI (Linux real-mode interface). | |
4 So it's not an emulator - it calls real int 10h handler under Linux. | |
5 Note: VESA is available only on x86 systems. | |
6 You can redistribute this file under terms and conditions | |
7 GNU General Public licence v2. | |
8 Written by Nick Kurshev <nickols_k@mail.ru> | |
9 */ | |
10 #include "vbelib.h" | |
11 #include "lrmi.h" | |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 #include <stdio.h> | |
15 #include <sys/io.h> | |
2407 | 16 #include <ctype.h> |
2243 | 17 |
18 static struct VesaProtModeInterface vbe_pm_info; | |
19 | |
2536 | 20 static inline int VERR(const void *p) |
2515 | 21 { |
22 register int retval; | |
23 __asm __volatile( | |
24 "xorl %0, %0\n\t" | |
25 "verr %1\n\t" | |
26 "setnz %b0" | |
27 :"=r"(retval) | |
28 :"m"(*(unsigned char *)p) | |
29 :"memory"); | |
30 return retval; | |
31 } | |
32 | |
33 #if 0 | |
2536 | 34 static inline int VERW(const void *p) |
2515 | 35 { |
36 register int retval; | |
37 __asm __volatile( | |
38 "xorl %0, %0\n\t" | |
39 "verw %1\n\t" | |
40 "setnz %b0" | |
41 :"=r"(retval) | |
42 :"m"(*(unsigned char *)p) | |
43 :"memory"); | |
44 return retval; | |
45 } | |
46 #endif | |
47 | |
2294 | 48 #define HAVE_VERBOSE_VAR 1 |
49 | |
50 #ifdef HAVE_VERBOSE_VAR | |
51 extern int verbose; | |
52 | |
53 static void __dump_regs(struct LRMI_regs *r) | |
54 { | |
55 printf("vbelib: eax=%08lXh ebx=%08lXh ecx=%08lXh edx=%08lXh\n" | |
56 "vbelib: edi=%08lXh esi=%08lXh ebp=%08lXh esp=%08lXh\n" | |
2445 | 57 "vbelib: ds=%04Xh es=%04Xh ss=%04Xh cs:ip=%04X:%04X\n" |
58 "vbelib: fs=%04Xh gs=%04Xh ss:sp=%04X:%04X flags=%04X\n" | |
59 ,(unsigned long)r->eax,(unsigned long)r->ebx,(unsigned long)r->ecx,(unsigned long)r->edx | |
60 ,(unsigned long)r->edi,(unsigned long)r->esi,(unsigned long)r->ebp,(unsigned long)r->reserved | |
2294 | 61 ,r->ds,r->es,r->ss,r->cs,r->ip |
62 ,r->fs,r->gs,r->ss,r->sp,r->flags); | |
63 } | |
64 | |
65 static inline int VBE_LRMI_int(int int_no, struct LRMI_regs *r) | |
66 { | |
67 int retval; | |
68 if(verbose > 1) | |
69 { | |
70 printf("vbelib: registers before int %02X\n",int_no); | |
71 __dump_regs(r); | |
72 } | |
73 retval = LRMI_int(int_no,r); | |
74 if(verbose > 1) | |
75 { | |
2445 | 76 printf("vbelib: Interrupt handler returns: %X\n",retval); |
2294 | 77 printf("vbelib: registers after int %02X\n",int_no); |
78 __dump_regs(r); | |
79 } | |
80 return retval; | |
81 } | |
82 #else | |
83 #define VBE_LRMI_int(int_no,regs) (VBE_LRMI_int(int_no,regs)) | |
84 #endif | |
85 | |
2407 | 86 static unsigned hh_int_10_seg; |
2243 | 87 int vbeInit( void ) |
88 { | |
2407 | 89 unsigned short iopl_port; |
2359 | 90 size_t i; |
2552 | 91 int retval; |
2243 | 92 if(!LRMI_init()) return VBE_VM86_FAIL; |
93 /* | |
94 Allow read/write to ALL io ports | |
95 */ | |
2407 | 96 hh_int_10_seg = *(unsigned short *)PhysToVirtSO(0x0000,0x0042); |
2359 | 97 /* Video BIOS should be at C000:0000 and above */ |
2407 | 98 hh_int_10_seg >>= 12; |
99 if(hh_int_10_seg < 0xC) return VBE_BROKEN_BIOS; | |
2243 | 100 ioperm(0, 1024, 1); |
101 iopl(3); | |
102 memset(&vbe_pm_info,0,sizeof(struct VesaProtModeInterface)); | |
2552 | 103 retval = vbeGetProtModeInfo(&vbe_pm_info); |
104 if(retval != VBE_OK) return retval; | |
2359 | 105 i = 0; |
2552 | 106 while((iopl_port=vbe_pm_info.iopl_ports[i]) != 0xFFFF |
107 && vbe_pm_info.iopl_ports[i++] > 1023) ioperm(iopl_port,1,1); | |
2359 | 108 iopl(3); |
2243 | 109 return VBE_OK; |
110 } | |
111 | |
112 int vbeDestroy( void ) { return VBE_OK; } | |
113 | |
2536 | 114 /* Fixme!!! This code is compatible only with mplayer's version of lrmi*/ |
115 static inline int is_addr_valid(const void *p) | |
116 { | |
117 return (p < (const void *)0x502) || | |
118 (p >= (const void *)0x10000 && p < (const void *)0x20000) || | |
119 (p >= (const void *)0xa0000 && p < (const void *)0x100000); | |
120 } | |
121 | |
122 static int check_str(const unsigned char *str) | |
2515 | 123 { |
124 size_t i; | |
125 int null_found = 0; | |
126 for(i = 0;i < 256;i++) | |
127 { | |
2536 | 128 if(is_addr_valid(&str[i])) |
2515 | 129 { |
2536 | 130 if(VERR(&str[i])) |
131 { | |
132 if(!str[i]) { null_found = 1; break; } | |
133 } | |
134 else break; | |
2515 | 135 } |
136 else break; | |
137 } | |
138 return null_found; | |
139 } | |
140 | |
2536 | 141 static int check_wrd(const unsigned short *str) |
2515 | 142 { |
143 size_t i; | |
144 int ffff_found = 0; | |
145 for(i = 0;i < 1024;i++) | |
146 { | |
2536 | 147 if(is_addr_valid(&str[i])) |
2515 | 148 { |
2536 | 149 if(VERR(&str[i])) |
150 { | |
151 if(str[i] == 0xffff) { ffff_found = 1; break; } | |
152 } | |
153 else break; | |
2515 | 154 } |
155 else break; | |
156 } | |
157 return ffff_found; | |
158 } | |
159 | |
2407 | 160 static void print_str(unsigned char *str) |
161 { | |
162 size_t i; | |
163 fflush(stdout); | |
164 printf("vbelib: "); | |
165 for(i = 0;i < 256;i++) { printf("%02X(%c) ",str[i],isprint(str[i])?str[i]:'.'); if(!str[i]) break; } | |
166 printf("\n"); | |
167 fflush(stdout); | |
168 } | |
169 | |
170 static void print_wrd(unsigned short *str) | |
171 { | |
172 size_t i; | |
173 fflush(stdout); | |
174 printf("vbelib: "); | |
175 for(i = 0;i < 256;i++) { printf("%04X ",str[i]); if(str[i] == 0xffff) break; } | |
176 printf("\n"); | |
177 fflush(stdout); | |
178 } | |
179 | |
2243 | 180 int vbeGetControllerInfo(struct VbeInfoBlock *data) |
181 { | |
182 struct LRMI_regs r; | |
183 void *rm_space; | |
184 int retval; | |
185 if(!(rm_space = LRMI_alloc_real(sizeof(struct VbeInfoBlock)))) return VBE_OUT_OF_DOS_MEM; | |
186 memcpy(rm_space,data,sizeof(struct VbeInfoBlock)); | |
187 memset(&r,0,sizeof(struct LRMI_regs)); | |
188 r.eax = 0x4f00; | |
189 r.es = VirtToPhysSeg(rm_space); | |
190 r.edi = VirtToPhysOff(rm_space); | |
2294 | 191 if(!VBE_LRMI_int(0x10,&r)) |
2243 | 192 { |
193 LRMI_free_real(rm_space); | |
194 return VBE_VM86_FAIL; | |
195 } | |
196 retval = r.eax & 0xffff; | |
197 if(retval == 0x4f) | |
198 { | |
199 FarPtr fpdata; | |
200 retval = VBE_OK; | |
201 memcpy(data,rm_space,sizeof(struct VbeInfoBlock)); | |
202 fpdata.seg = (unsigned long)(data->OemStringPtr) >> 16; | |
203 fpdata.off = (unsigned long)(data->OemStringPtr) & 0xffff; | |
204 data->OemStringPtr = PhysToVirt(fpdata); | |
2515 | 205 if(!check_str(data->OemStringPtr)) data->OemStringPtr = NULL; |
2294 | 206 #ifdef HAVE_VERBOSE_VAR |
2407 | 207 if(verbose > 1) |
208 { | |
209 printf("vbelib: OemStringPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemStringPtr); | |
2515 | 210 if(data->OemStringPtr) print_str(data->OemStringPtr); |
2518 | 211 fflush(stdout); |
2407 | 212 } |
2294 | 213 #endif |
2243 | 214 fpdata.seg = (unsigned long)(data->VideoModePtr) >> 16; |
215 fpdata.off = (unsigned long)(data->VideoModePtr) & 0xffff; | |
216 data->VideoModePtr = PhysToVirt(fpdata); | |
2515 | 217 if(!check_wrd(data->VideoModePtr)) |
218 { | |
219 data->VideoModePtr = NULL; | |
220 retval = VBE_BROKEN_BIOS; | |
221 } | |
2294 | 222 #ifdef HAVE_VERBOSE_VAR |
2407 | 223 if(verbose > 1) |
224 { | |
225 printf("vbelib: VideoModePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->VideoModePtr); | |
2515 | 226 if(data->VideoModePtr) print_wrd(data->VideoModePtr); |
2518 | 227 fflush(stdout); |
2407 | 228 } |
2294 | 229 #endif |
2243 | 230 fpdata.seg = (unsigned long)(data->OemVendorNamePtr) >> 16; |
231 fpdata.off = (unsigned long)(data->OemVendorNamePtr) & 0xffff; | |
232 data->OemVendorNamePtr = PhysToVirt(fpdata); | |
2515 | 233 if(!check_str(data->OemVendorNamePtr)) data->OemVendorNamePtr = NULL; |
2294 | 234 #ifdef HAVE_VERBOSE_VAR |
2407 | 235 if(verbose > 1) |
236 { | |
237 printf("vbelib: OemVendorNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemVendorNamePtr); | |
2515 | 238 if(data->OemVendorNamePtr) print_str(data->OemVendorNamePtr); |
2518 | 239 fflush(stdout); |
2407 | 240 } |
2294 | 241 #endif |
2243 | 242 fpdata.seg = (unsigned long)(data->OemProductNamePtr) >> 16; |
243 fpdata.off = (unsigned long)(data->OemProductNamePtr) & 0xffff; | |
244 data->OemProductNamePtr = PhysToVirt(fpdata); | |
2515 | 245 if(!check_str(data->OemProductNamePtr)) data->OemProductNamePtr = NULL; |
2294 | 246 #ifdef HAVE_VERBOSE_VAR |
2407 | 247 if(verbose > 1) |
248 { | |
249 printf("vbelib: OemProductNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductNamePtr); | |
2515 | 250 if(data->OemVendorNamePtr) print_str(data->OemProductNamePtr); |
2518 | 251 fflush(stdout); |
2407 | 252 } |
2294 | 253 #endif |
2243 | 254 fpdata.seg = (unsigned long)(data->OemProductRevPtr) >> 16; |
255 fpdata.off = (unsigned long)(data->OemProductRevPtr) & 0xffff; | |
256 data->OemProductRevPtr = PhysToVirt(fpdata); | |
2515 | 257 if(!check_str(data->OemProductRevPtr)) data->OemProductRevPtr = NULL; |
2294 | 258 #ifdef HAVE_VERBOSE_VAR |
2407 | 259 if(verbose > 1) |
260 { | |
261 printf("vbelib: OemProductRevPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductRevPtr); | |
2515 | 262 if(data->OemProductRevPtr) print_str(data->OemProductRevPtr); |
2518 | 263 fflush(stdout); |
2407 | 264 } |
2294 | 265 #endif |
2243 | 266 } |
267 return retval; | |
268 } | |
269 | |
270 int vbeGetModeInfo(unsigned mode,struct VesaModeInfoBlock *data) | |
271 { | |
272 struct LRMI_regs r; | |
273 void *rm_space; | |
274 int retval; | |
275 if(!(rm_space = LRMI_alloc_real(sizeof(struct VesaModeInfoBlock)))) return VBE_OUT_OF_DOS_MEM; | |
276 memset(&r,0,sizeof(struct LRMI_regs)); | |
277 r.eax = 0x4f01; | |
278 r.ecx = mode; | |
279 r.es = VirtToPhysSeg(rm_space); | |
280 r.edi = VirtToPhysOff(rm_space); | |
2294 | 281 if(!VBE_LRMI_int(0x10,&r)) |
2243 | 282 { |
283 LRMI_free_real(rm_space); | |
284 return VBE_VM86_FAIL; | |
285 } | |
286 retval = r.eax & 0xffff; | |
287 if(retval == 0x4f) | |
288 { | |
289 retval = VBE_OK; | |
290 memcpy(data,rm_space,sizeof(struct VesaModeInfoBlock)); | |
291 } | |
292 return retval; | |
293 } | |
294 | |
295 int vbeSetMode(unsigned mode,struct VesaCRTCInfoBlock *data) | |
296 { | |
297 struct LRMI_regs r; | |
298 void *rm_space = NULL; | |
299 int retval; | |
300 memset(&r,0,sizeof(struct LRMI_regs)); | |
301 if(data) | |
302 { | |
303 if(!(rm_space = LRMI_alloc_real(sizeof(struct VesaCRTCInfoBlock)))) return VBE_OUT_OF_DOS_MEM; | |
304 r.es = VirtToPhysSeg(rm_space); | |
305 r.edi = VirtToPhysOff(rm_space); | |
306 memcpy(rm_space,data,sizeof(struct VesaCRTCInfoBlock)); | |
307 } | |
308 r.eax = 0x4f02; | |
309 r.ebx = mode; | |
2294 | 310 retval = VBE_LRMI_int(0x10,&r); |
2243 | 311 if(rm_space) LRMI_free_real(rm_space); |
312 if(!retval) return VBE_VM86_FAIL; | |
313 retval = r.eax & 0xffff; | |
314 if(retval == 0x4f) retval = VBE_OK; | |
315 return retval; | |
316 } | |
317 | |
318 int vbeGetMode(unsigned *mode) | |
319 { | |
320 struct LRMI_regs r; | |
321 int retval; | |
322 memset(&r,0,sizeof(struct LRMI_regs)); | |
323 r.eax = 0x4f03; | |
2294 | 324 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 325 retval = r.eax & 0xffff; |
326 if(retval == 0x4f) | |
327 { | |
328 *mode = r.ebx; | |
329 retval = VBE_OK; | |
330 } | |
331 return retval; | |
332 } | |
333 | |
334 int vbeSaveState(void **data) | |
335 { | |
336 struct LRMI_regs r; | |
337 int retval; | |
338 void *rm_space; | |
339 memset(&r,0,sizeof(struct LRMI_regs)); | |
340 r.eax = 0x4f04; | |
341 r.edx = 0x00; | |
342 r.ecx = 0x0f; | |
2294 | 343 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 344 retval = r.eax & 0xffff; |
345 if(retval != 0x4f) return retval; | |
346 if(!(rm_space = LRMI_alloc_real((r.ebx & 0xffff)*64))) return VBE_OUT_OF_DOS_MEM; | |
347 r.eax = 0x4f04; | |
348 r.edx = 0x01; | |
349 r.ecx = 0x0f; | |
350 r.es = VirtToPhysSeg(rm_space); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
351 r.ebx = VirtToPhysOff(rm_space); |
2294 | 352 if(!VBE_LRMI_int(0x10,&r)) |
2243 | 353 { |
354 LRMI_free_real(rm_space); | |
355 return VBE_VM86_FAIL; | |
356 } | |
357 retval = r.eax & 0xffff; | |
358 if(retval != 0x4f) | |
359 { | |
360 LRMI_free_real(rm_space); | |
361 return retval; | |
362 } | |
363 *data = rm_space; | |
364 return VBE_OK; | |
365 } | |
366 | |
367 int vbeRestoreState(void *data) | |
368 { | |
369 struct LRMI_regs r; | |
370 int retval; | |
371 memset(&r,0,sizeof(struct LRMI_regs)); | |
372 r.eax = 0x4f04; | |
373 r.edx = 0x02; | |
374 r.ecx = 0x0f; | |
375 r.es = VirtToPhysSeg(data); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
376 r.ebx = VirtToPhysOff(data); |
2294 | 377 retval = VBE_LRMI_int(0x10,&r); |
2243 | 378 LRMI_free_real(data); |
379 if(!retval) return VBE_VM86_FAIL; | |
380 retval = r.eax & 0xffff; | |
381 if(retval == 0x4f) retval = VBE_OK; | |
382 return retval; | |
383 } | |
384 | |
385 int vbeGetWindow(unsigned *win_num) | |
386 { | |
387 struct LRMI_regs r; | |
388 int retval; | |
389 memset(&r,0,sizeof(struct LRMI_regs)); | |
390 r.eax = 0x4f05; | |
391 r.ebx = (*win_num & 0x0f) | 0x0100; | |
2294 | 392 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 393 retval = r.eax & 0xffff; |
394 if(retval == 0x4f) | |
395 { | |
396 *win_num = r.edx & 0xffff; | |
397 retval = VBE_OK; | |
398 } | |
399 return retval; | |
400 } | |
401 | |
402 int vbeSetWindow(unsigned win_num,unsigned win_gran) | |
403 { | |
404 int retval; | |
405 if(vbe_pm_info.SetWindowCall) | |
406 { | |
2294 | 407 /* Don't verbose this stuff from performance reasons */ |
2243 | 408 /* 32-bit function call is much better of int 10h */ |
409 __asm __volatile( | |
410 "pushl %%ebx\n" | |
411 "movl %1, %%ebx\n" | |
412 ::"a"(0x4f05),"S"(win_num & 0x0f),"d"(win_gran):"memory"); | |
413 (*vbe_pm_info.SetWindowCall)(); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
414 __asm __volatile("popl %%ebx":::"memory"); |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
415 retval = VBE_OK; |
2243 | 416 } |
417 else | |
418 { | |
419 struct LRMI_regs r; | |
420 memset(&r,0,sizeof(struct LRMI_regs)); | |
421 r.eax = 0x4f05; | |
422 r.ebx = win_num & 0x0f; | |
423 r.edx = win_gran; | |
2294 | 424 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 425 retval = r.eax & 0xffff; |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
426 if(retval == 0x4f) retval = VBE_OK; |
2243 | 427 } |
428 return retval; | |
429 } | |
430 | |
431 struct realVesaProtModeInterface | |
432 { | |
433 unsigned short SetWindowCall; | |
434 unsigned short SetDisplayStart; | |
435 unsigned short SetPaletteData; | |
436 unsigned short iopl_ports; | |
437 }__attribute__((packed)); | |
438 | |
439 int vbeGetProtModeInfo(struct VesaProtModeInterface *pm_info) | |
440 { | |
441 struct LRMI_regs r; | |
442 int retval; | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
443 unsigned info_offset; |
2243 | 444 struct realVesaProtModeInterface *rm_info; |
445 memset(&r,0,sizeof(struct LRMI_regs)); | |
446 r.eax = 0x4f0a; | |
447 r.ebx = 0; | |
2294 | 448 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 449 retval = r.eax & 0xffff; |
450 if(retval == 0x4f) | |
451 { | |
2407 | 452 retval = VBE_OK; |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
453 info_offset = r.edi&0xffff; |
2407 | 454 if((r.es >> 12) != hh_int_10_seg) retval = VBE_BROKEN_BIOS; |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
455 rm_info = PhysToVirtSO(r.es,info_offset); |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
456 pm_info->SetWindowCall = PhysToVirtSO(r.es,info_offset+rm_info->SetWindowCall); |
2552 | 457 if(!is_addr_valid(pm_info->SetWindowCall)) retval = VBE_BROKEN_BIOS; |
2294 | 458 #ifdef HAVE_VERBOSE_VAR |
459 if(verbose > 1) printf("vbelib: SetWindowCall=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetWindowCall,pm_info->SetWindowCall); | |
460 #endif | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
461 pm_info->SetDisplayStart = PhysToVirtSO(r.es,info_offset+rm_info->SetDisplayStart); |
2552 | 462 if(!is_addr_valid(pm_info->SetDisplayStart)) retval = VBE_BROKEN_BIOS; |
2294 | 463 #ifdef HAVE_VERBOSE_VAR |
464 if(verbose > 1) printf("vbelib: SetDisplayStart=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetDisplayStart,pm_info->SetDisplayStart); | |
465 #endif | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
466 pm_info->SetPaletteData = PhysToVirtSO(r.es,info_offset+rm_info->SetPaletteData); |
2552 | 467 if(!is_addr_valid(pm_info->SetPaletteData)) retval = VBE_BROKEN_BIOS; |
2294 | 468 #ifdef HAVE_VERBOSE_VAR |
469 if(verbose > 1) printf("vbelib: SetPaletteData=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetPaletteData,pm_info->SetPaletteData); | |
470 #endif | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
471 pm_info->iopl_ports = PhysToVirtSO(r.es,info_offset+rm_info->iopl_ports); |
2515 | 472 if(!check_wrd(pm_info->iopl_ports)) |
473 { | |
474 pm_info->iopl_ports = NULL; | |
475 retval = VBE_BROKEN_BIOS; | |
476 } | |
2294 | 477 #ifdef HAVE_VERBOSE_VAR |
2407 | 478 if(verbose > 1) |
479 { | |
480 printf("vbelib: iopl_ports=%04X:%04X => %p\n",r.es,info_offset+rm_info->iopl_ports,pm_info->iopl_ports); | |
2515 | 481 if(pm_info->iopl_ports) print_wrd(pm_info->iopl_ports); |
2518 | 482 fflush(stdout); |
2407 | 483 } |
2294 | 484 #endif |
2243 | 485 } |
486 return retval; | |
487 } | |
2410 | 488 /* --------- Standard VGA stuff -------------- */ |
489 int vbeWriteString(int x, int y, int attr, char *str) | |
490 { | |
491 struct LRMI_regs r; | |
492 void *rm_space = NULL; | |
493 int retval; | |
494 memset(&r,0,sizeof(struct LRMI_regs)); | |
495 r.ecx = strlen(str); | |
496 r.edx = ((y<<8)&0xff00)|(x&0xff); | |
497 r.ebx = attr; | |
498 if(!(rm_space = LRMI_alloc_real(r.ecx))) return VBE_OUT_OF_DOS_MEM; | |
499 r.es = VirtToPhysSeg(rm_space); | |
500 r.ebp = VirtToPhysOff(rm_space); | |
501 memcpy(rm_space,str,r.ecx); | |
502 r.eax = 0x1300; | |
503 retval = VBE_LRMI_int(0x10,&r); | |
504 if(rm_space) LRMI_free_real(rm_space); | |
505 if(!retval) return VBE_VM86_FAIL; | |
506 retval = r.eax & 0xffff; | |
507 if(retval == 0x4f) retval = VBE_OK; | |
508 return retval; | |
2460 | 509 } |