Mercurial > mplayer.hg
annotate osdep/vbelib.c @ 15980:85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
author | aurel |
---|---|
date | Sat, 16 Jul 2005 14:49:21 +0000 |
parents | 1cb0e1833515 |
children |
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 | |
2632 | 7 of GNU General Public licence v2. |
2243 | 8 Written by Nick Kurshev <nickols_k@mail.ru> |
12660
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
9 Neomagic TV out support by Rudolf Marek <r.marek et sh.cvut.cz> |
2243 | 10 */ |
11455 | 11 |
12 #include <../config.h> | |
13 #ifdef HAVE_VESA | |
14 | |
2243 | 15 #include "vbelib.h" |
16 #include "lrmi.h" | |
17 #include <stdlib.h> | |
18 #include <string.h> | |
19 #include <stdio.h> | |
20 #include <sys/io.h> | |
2610 | 21 #include <sys/mman.h> |
22 #include <sys/types.h> | |
23 #include <sys/stat.h> | |
2407 | 24 #include <ctype.h> |
2610 | 25 #include <unistd.h> |
26 #include <fcntl.h> | |
15980
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
27 #include <sys/ioctl.h> |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
28 #include <linux/kd.h> |
2243 | 29 |
30 static struct VesaProtModeInterface vbe_pm_info; | |
2632 | 31 static struct VesaModeInfoBlock curr_mode_info; |
2243 | 32 |
2536 | 33 static inline int VERR(const void *p) |
2515 | 34 { |
35 register int retval; | |
36 __asm __volatile( | |
37 "xorl %0, %0\n\t" | |
38 "verr %1\n\t" | |
39 "setnz %b0" | |
4405
7eda15bbb3f9
fixing assembly bug. By Thierry Vignaud <tvignaud@mandrakesoft.com>
nick
parents:
3016
diff
changeset
|
40 :"=q"(retval) |
2515 | 41 :"m"(*(unsigned char *)p) |
4405
7eda15bbb3f9
fixing assembly bug. By Thierry Vignaud <tvignaud@mandrakesoft.com>
nick
parents:
3016
diff
changeset
|
42 :"memory","cc"); |
2515 | 43 return retval; |
44 } | |
45 | |
46 #if 0 | |
2536 | 47 static inline int VERW(const void *p) |
2515 | 48 { |
49 register int retval; | |
50 __asm __volatile( | |
51 "xorl %0, %0\n\t" | |
52 "verw %1\n\t" | |
53 "setnz %b0" | |
4405
7eda15bbb3f9
fixing assembly bug. By Thierry Vignaud <tvignaud@mandrakesoft.com>
nick
parents:
3016
diff
changeset
|
54 :"=q"(retval) |
2515 | 55 :"m"(*(unsigned char *)p) |
4405
7eda15bbb3f9
fixing assembly bug. By Thierry Vignaud <tvignaud@mandrakesoft.com>
nick
parents:
3016
diff
changeset
|
56 :"memory","cc"); |
2515 | 57 return retval; |
58 } | |
59 #endif | |
60 | |
2294 | 61 #define HAVE_VERBOSE_VAR 1 |
62 | |
63 #ifdef HAVE_VERBOSE_VAR | |
64 extern int verbose; | |
65 | |
66 static void __dump_regs(struct LRMI_regs *r) | |
67 { | |
68 printf("vbelib: eax=%08lXh ebx=%08lXh ecx=%08lXh edx=%08lXh\n" | |
69 "vbelib: edi=%08lXh esi=%08lXh ebp=%08lXh esp=%08lXh\n" | |
2445 | 70 "vbelib: ds=%04Xh es=%04Xh ss=%04Xh cs:ip=%04X:%04X\n" |
71 "vbelib: fs=%04Xh gs=%04Xh ss:sp=%04X:%04X flags=%04X\n" | |
72 ,(unsigned long)r->eax,(unsigned long)r->ebx,(unsigned long)r->ecx,(unsigned long)r->edx | |
73 ,(unsigned long)r->edi,(unsigned long)r->esi,(unsigned long)r->ebp,(unsigned long)r->reserved | |
2294 | 74 ,r->ds,r->es,r->ss,r->cs,r->ip |
75 ,r->fs,r->gs,r->ss,r->sp,r->flags); | |
76 } | |
77 | |
78 static inline int VBE_LRMI_int(int int_no, struct LRMI_regs *r) | |
79 { | |
80 int retval; | |
81 if(verbose > 1) | |
82 { | |
83 printf("vbelib: registers before int %02X\n",int_no); | |
84 __dump_regs(r); | |
85 } | |
86 retval = LRMI_int(int_no,r); | |
87 if(verbose > 1) | |
88 { | |
2445 | 89 printf("vbelib: Interrupt handler returns: %X\n",retval); |
2294 | 90 printf("vbelib: registers after int %02X\n",int_no); |
91 __dump_regs(r); | |
92 } | |
93 return retval; | |
94 } | |
95 #else | |
96 #define VBE_LRMI_int(int_no,regs) (VBE_LRMI_int(int_no,regs)) | |
97 #endif | |
98 | |
15980
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
99 /** |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
100 * Set console to graphics or text mode. |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
101 * This is a clean way to enable/disable console text output |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
102 * and cursor blinking. |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
103 * |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
104 * @param mode The new wanted mode. Can be either KD_GRAPHICS to switch |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
105 * to graphics mode or anything else to switch back to the |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
106 * original mode. |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
107 */ |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
108 static void kd_set_mode(int mode) |
3016
ea414257856f
Hide terminal's output and text-mode cursor for LCD and DFP
nick
parents:
2913
diff
changeset
|
109 { |
15980
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
110 static int old_mode = KD_TEXT; |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
111 int fd; |
3016
ea414257856f
Hide terminal's output and text-mode cursor for LCD and DFP
nick
parents:
2913
diff
changeset
|
112 |
15980
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
113 if ((fd = open("/dev/tty0", O_RDWR)) < 0) |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
114 return; |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
115 if(mode == KD_GRAPHICS) |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
116 old_mode = ioctl(fd, KDGETMODE); |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
117 else |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
118 mode = old_mode; |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
119 ioctl(fd, KDSETMODE, mode); |
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
120 close(fd); |
3016
ea414257856f
Hide terminal's output and text-mode cursor for LCD and DFP
nick
parents:
2913
diff
changeset
|
121 } |
ea414257856f
Hide terminal's output and text-mode cursor for LCD and DFP
nick
parents:
2913
diff
changeset
|
122 |
2407 | 123 static unsigned hh_int_10_seg; |
2610 | 124 static int fd_mem; |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
125 /* |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
126 the list of supported video modes is stored in the reserved portion of |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
127 the SuperVGA information record by some implementations, and it may |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
128 thus be necessary to either copy the mode list or use a different |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
129 buffer for all subsequent VESA calls |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
130 */ |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
131 static void *controller_info; |
2243 | 132 int vbeInit( void ) |
133 { | |
2407 | 134 unsigned short iopl_port; |
2359 | 135 size_t i; |
2243 | 136 if(!LRMI_init()) return VBE_VM86_FAIL; |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
137 if(!(controller_info = LRMI_alloc_real(sizeof(struct VbeInfoBlock)))) return VBE_OUT_OF_DOS_MEM; |
2243 | 138 /* |
139 Allow read/write to ALL io ports | |
140 */ | |
2407 | 141 hh_int_10_seg = *(unsigned short *)PhysToVirtSO(0x0000,0x0042); |
2359 | 142 /* Video BIOS should be at C000:0000 and above */ |
2407 | 143 hh_int_10_seg >>= 12; |
144 if(hh_int_10_seg < 0xC) return VBE_BROKEN_BIOS; | |
2243 | 145 ioperm(0, 1024, 1); |
146 iopl(3); | |
147 memset(&vbe_pm_info,0,sizeof(struct VesaProtModeInterface)); | |
13568
1cb0e1833515
Currently vbeGetProtModeInfo call the 0x4f0a function of int 10h the get
faust3
parents:
13352
diff
changeset
|
148 vbeGetProtModeInfo(&vbe_pm_info); |
2359 | 149 i = 0; |
2913 | 150 if(vbe_pm_info.iopl_ports) /* Can be NULL !!!*/ |
2552 | 151 while((iopl_port=vbe_pm_info.iopl_ports[i]) != 0xFFFF |
152 && vbe_pm_info.iopl_ports[i++] > 1023) ioperm(iopl_port,1,1); | |
2359 | 153 iopl(3); |
2610 | 154 fd_mem = open("/dev/mem",O_RDWR); |
15980
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
155 kd_set_mode(KD_GRAPHICS); |
2243 | 156 return VBE_OK; |
157 } | |
158 | |
2610 | 159 int vbeDestroy( void ) |
160 { | |
15980
85fd2ee1c094
proper disabling/enabling of console output for vo_vesa
aurel
parents:
13568
diff
changeset
|
161 kd_set_mode(KD_TEXT); |
2610 | 162 close(fd_mem); |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
163 LRMI_free_real(controller_info); |
2610 | 164 return VBE_OK; |
165 } | |
2243 | 166 |
2536 | 167 /* Fixme!!! This code is compatible only with mplayer's version of lrmi*/ |
168 static inline int is_addr_valid(const void *p) | |
169 { | |
170 return (p < (const void *)0x502) || | |
171 (p >= (const void *)0x10000 && p < (const void *)0x20000) || | |
172 (p >= (const void *)0xa0000 && p < (const void *)0x100000); | |
173 } | |
174 | |
175 static int check_str(const unsigned char *str) | |
2515 | 176 { |
177 size_t i; | |
178 int null_found = 0; | |
179 for(i = 0;i < 256;i++) | |
180 { | |
2536 | 181 if(is_addr_valid(&str[i])) |
2515 | 182 { |
2536 | 183 if(VERR(&str[i])) |
184 { | |
185 if(!str[i]) { null_found = 1; break; } | |
186 } | |
187 else break; | |
2515 | 188 } |
189 else break; | |
190 } | |
191 return null_found; | |
192 } | |
193 | |
2536 | 194 static int check_wrd(const unsigned short *str) |
2515 | 195 { |
196 size_t i; | |
197 int ffff_found = 0; | |
198 for(i = 0;i < 1024;i++) | |
199 { | |
2536 | 200 if(is_addr_valid(&str[i])) |
2515 | 201 { |
2536 | 202 if(VERR(&str[i])) |
203 { | |
204 if(str[i] == 0xffff) { ffff_found = 1; break; } | |
205 } | |
206 else break; | |
2515 | 207 } |
208 else break; | |
209 } | |
210 return ffff_found; | |
211 } | |
212 | |
2407 | 213 static void print_str(unsigned char *str) |
214 { | |
215 size_t i; | |
216 fflush(stdout); | |
217 printf("vbelib: "); | |
218 for(i = 0;i < 256;i++) { printf("%02X(%c) ",str[i],isprint(str[i])?str[i]:'.'); if(!str[i]) break; } | |
219 printf("\n"); | |
220 fflush(stdout); | |
221 } | |
222 | |
223 static void print_wrd(unsigned short *str) | |
224 { | |
225 size_t i; | |
226 fflush(stdout); | |
227 printf("vbelib: "); | |
228 for(i = 0;i < 256;i++) { printf("%04X ",str[i]); if(str[i] == 0xffff) break; } | |
229 printf("\n"); | |
230 fflush(stdout); | |
231 } | |
232 | |
2243 | 233 int vbeGetControllerInfo(struct VbeInfoBlock *data) |
234 { | |
235 struct LRMI_regs r; | |
236 int retval; | |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
237 memcpy(controller_info,data,sizeof(struct VbeInfoBlock)); |
2243 | 238 memset(&r,0,sizeof(struct LRMI_regs)); |
239 r.eax = 0x4f00; | |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
240 r.es = VirtToPhysSeg(controller_info); |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
241 r.edi = VirtToPhysOff(controller_info); |
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
242 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 243 retval = r.eax & 0xffff; |
244 if(retval == 0x4f) | |
245 { | |
246 FarPtr fpdata; | |
247 retval = VBE_OK; | |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
248 memcpy(data,controller_info,sizeof(struct VbeInfoBlock)); |
2243 | 249 fpdata.seg = (unsigned long)(data->OemStringPtr) >> 16; |
250 fpdata.off = (unsigned long)(data->OemStringPtr) & 0xffff; | |
251 data->OemStringPtr = PhysToVirt(fpdata); | |
2515 | 252 if(!check_str(data->OemStringPtr)) data->OemStringPtr = NULL; |
2294 | 253 #ifdef HAVE_VERBOSE_VAR |
2407 | 254 if(verbose > 1) |
255 { | |
256 printf("vbelib: OemStringPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemStringPtr); | |
2515 | 257 if(data->OemStringPtr) print_str(data->OemStringPtr); |
2518 | 258 fflush(stdout); |
2407 | 259 } |
2294 | 260 #endif |
2243 | 261 fpdata.seg = (unsigned long)(data->VideoModePtr) >> 16; |
262 fpdata.off = (unsigned long)(data->VideoModePtr) & 0xffff; | |
263 data->VideoModePtr = PhysToVirt(fpdata); | |
2515 | 264 if(!check_wrd(data->VideoModePtr)) |
265 { | |
266 data->VideoModePtr = NULL; | |
267 retval = VBE_BROKEN_BIOS; | |
268 } | |
2294 | 269 #ifdef HAVE_VERBOSE_VAR |
2407 | 270 if(verbose > 1) |
271 { | |
272 printf("vbelib: VideoModePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->VideoModePtr); | |
2515 | 273 if(data->VideoModePtr) print_wrd(data->VideoModePtr); |
2518 | 274 fflush(stdout); |
2407 | 275 } |
2294 | 276 #endif |
2243 | 277 fpdata.seg = (unsigned long)(data->OemVendorNamePtr) >> 16; |
278 fpdata.off = (unsigned long)(data->OemVendorNamePtr) & 0xffff; | |
279 data->OemVendorNamePtr = PhysToVirt(fpdata); | |
2515 | 280 if(!check_str(data->OemVendorNamePtr)) data->OemVendorNamePtr = NULL; |
2294 | 281 #ifdef HAVE_VERBOSE_VAR |
2407 | 282 if(verbose > 1) |
283 { | |
284 printf("vbelib: OemVendorNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemVendorNamePtr); | |
2515 | 285 if(data->OemVendorNamePtr) print_str(data->OemVendorNamePtr); |
2518 | 286 fflush(stdout); |
2407 | 287 } |
2294 | 288 #endif |
2243 | 289 fpdata.seg = (unsigned long)(data->OemProductNamePtr) >> 16; |
290 fpdata.off = (unsigned long)(data->OemProductNamePtr) & 0xffff; | |
291 data->OemProductNamePtr = PhysToVirt(fpdata); | |
2515 | 292 if(!check_str(data->OemProductNamePtr)) data->OemProductNamePtr = NULL; |
2294 | 293 #ifdef HAVE_VERBOSE_VAR |
2407 | 294 if(verbose > 1) |
295 { | |
296 printf("vbelib: OemProductNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductNamePtr); | |
2515 | 297 if(data->OemVendorNamePtr) print_str(data->OemProductNamePtr); |
2518 | 298 fflush(stdout); |
2407 | 299 } |
2294 | 300 #endif |
2243 | 301 fpdata.seg = (unsigned long)(data->OemProductRevPtr) >> 16; |
302 fpdata.off = (unsigned long)(data->OemProductRevPtr) & 0xffff; | |
303 data->OemProductRevPtr = PhysToVirt(fpdata); | |
2515 | 304 if(!check_str(data->OemProductRevPtr)) data->OemProductRevPtr = NULL; |
2294 | 305 #ifdef HAVE_VERBOSE_VAR |
2407 | 306 if(verbose > 1) |
307 { | |
308 printf("vbelib: OemProductRevPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductRevPtr); | |
2515 | 309 if(data->OemProductRevPtr) print_str(data->OemProductRevPtr); |
2518 | 310 fflush(stdout); |
2407 | 311 } |
2294 | 312 #endif |
2243 | 313 } |
314 return retval; | |
315 } | |
316 | |
317 int vbeGetModeInfo(unsigned mode,struct VesaModeInfoBlock *data) | |
318 { | |
319 struct LRMI_regs r; | |
320 void *rm_space; | |
321 int retval; | |
322 if(!(rm_space = LRMI_alloc_real(sizeof(struct VesaModeInfoBlock)))) return VBE_OUT_OF_DOS_MEM; | |
323 memset(&r,0,sizeof(struct LRMI_regs)); | |
324 r.eax = 0x4f01; | |
325 r.ecx = mode; | |
326 r.es = VirtToPhysSeg(rm_space); | |
327 r.edi = VirtToPhysOff(rm_space); | |
2294 | 328 if(!VBE_LRMI_int(0x10,&r)) |
2243 | 329 { |
330 LRMI_free_real(rm_space); | |
331 return VBE_VM86_FAIL; | |
332 } | |
333 retval = r.eax & 0xffff; | |
334 if(retval == 0x4f) | |
335 { | |
336 retval = VBE_OK; | |
337 memcpy(data,rm_space,sizeof(struct VesaModeInfoBlock)); | |
338 } | |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
339 LRMI_free_real(rm_space); |
2243 | 340 return retval; |
341 } | |
342 | |
12660
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
343 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
344 int vbeSetTV(unsigned int vesa_mode,unsigned int TV_mode) { |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
345 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
346 #define NR_MODES 8 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
347 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
348 unsigned int mode_table[NR_MODES] = |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
349 {0x101,0x103,0x111,0x114,0x120,0x121,0x122,0x123}; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
350 unsigned int tv_table[][NR_MODES] = { |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
351 {0x201,0x202,0x211,0x212,0x221,0x231,0x222,0x232}, |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
352 {0x200,0x203,0x210,0x213,0x220,0x230,0xFFFF,0xFFFF}}; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
353 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
354 /* |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
355 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
356 Alternate mode map. If modes like 320x240 and 400x300 does not work, but |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
357 640x480 and 800x600 work, then try to replace above two lines with this |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
358 lines and write email to me if it works. |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
359 r.marek et sh.cvut.cz |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
360 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
361 {0x201,0x202,0x211,0x212,0x222,0x223,0x224,0x225}, |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
362 {0x200,0x203,0x210,0x213,0x220,0x221,0xFFFF,0xFFFF}}; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
363 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
364 */ |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
365 int i,retval; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
366 struct LRMI_regs r; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
367 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
368 memset(&r,0,sizeof(struct LRMI_regs)); |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
369 for (i=0;((mode_table[i]!=(vesa_mode&0x3FF))&&(i<NR_MODES));i++) ; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
370 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
371 if (i==NR_MODES) return 0; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
372 if(verbose > 1) printf("vbelib: Trying to set TV mode %x\n",tv_table[TV_mode][i]); |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
373 r.eax = 0x4f14; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
374 r.ebx = 0x20; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
375 r.edx = 0; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
376 r.edi = 0; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
377 r.ecx = tv_table[TV_mode][i]; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
378 retval = VBE_LRMI_int(0x10,&r); |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
379 if(!retval) return VBE_VM86_FAIL; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
380 return r.eax & 0xffff; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
381 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
382 } |
2243 | 383 int vbeSetMode(unsigned mode,struct VesaCRTCInfoBlock *data) |
384 { | |
385 struct LRMI_regs r; | |
386 void *rm_space = NULL; | |
387 int retval; | |
388 memset(&r,0,sizeof(struct LRMI_regs)); | |
389 if(data) | |
390 { | |
391 if(!(rm_space = LRMI_alloc_real(sizeof(struct VesaCRTCInfoBlock)))) return VBE_OUT_OF_DOS_MEM; | |
392 r.es = VirtToPhysSeg(rm_space); | |
393 r.edi = VirtToPhysOff(rm_space); | |
394 memcpy(rm_space,data,sizeof(struct VesaCRTCInfoBlock)); | |
395 } | |
396 r.eax = 0x4f02; | |
397 r.ebx = mode; | |
2294 | 398 retval = VBE_LRMI_int(0x10,&r); |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
399 LRMI_free_real(rm_space); |
2243 | 400 if(!retval) return VBE_VM86_FAIL; |
401 retval = r.eax & 0xffff; | |
2632 | 402 if(retval == 0x4f) |
403 { | |
404 /* Just info for internal use (currently in SetDiplayStart func). */ | |
13568
1cb0e1833515
Currently vbeGetProtModeInfo call the 0x4f0a function of int 10h the get
faust3
parents:
13352
diff
changeset
|
405 vbeGetModeInfo(mode,&curr_mode_info); |
2632 | 406 retval = VBE_OK; |
407 } | |
2243 | 408 return retval; |
409 } | |
410 | |
411 int vbeGetMode(unsigned *mode) | |
412 { | |
413 struct LRMI_regs r; | |
414 int retval; | |
415 memset(&r,0,sizeof(struct LRMI_regs)); | |
416 r.eax = 0x4f03; | |
2294 | 417 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 418 retval = r.eax & 0xffff; |
419 if(retval == 0x4f) | |
420 { | |
421 *mode = r.ebx; | |
422 retval = VBE_OK; | |
423 } | |
424 return retval; | |
425 } | |
426 | |
7069 | 427 int vbeGetPixelClock(unsigned *mode,unsigned *pixel_clock) // in Hz |
428 { | |
429 struct LRMI_regs r; | |
430 int retval; | |
431 memset(&r,0,sizeof(struct LRMI_regs)); | |
432 r.eax = 0x4f0b; | |
433 r.ebx = 0; | |
434 r.edx = *mode; | |
435 r.ecx = *pixel_clock; | |
436 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
437 retval = r.eax & 0xffff; | |
438 if(retval == 0x4f) | |
439 { | |
440 *pixel_clock = r.ecx; | |
441 retval = VBE_OK; | |
442 } | |
443 return retval; | |
444 } | |
445 | |
446 | |
2243 | 447 int vbeSaveState(void **data) |
448 { | |
449 struct LRMI_regs r; | |
450 int retval; | |
451 void *rm_space; | |
452 memset(&r,0,sizeof(struct LRMI_regs)); | |
453 r.eax = 0x4f04; | |
454 r.edx = 0x00; | |
455 r.ecx = 0x0f; | |
2294 | 456 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 457 retval = r.eax & 0xffff; |
458 if(retval != 0x4f) return retval; | |
459 if(!(rm_space = LRMI_alloc_real((r.ebx & 0xffff)*64))) return VBE_OUT_OF_DOS_MEM; | |
460 r.eax = 0x4f04; | |
461 r.edx = 0x01; | |
462 r.ecx = 0x0f; | |
463 r.es = VirtToPhysSeg(rm_space); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
464 r.ebx = VirtToPhysOff(rm_space); |
2294 | 465 if(!VBE_LRMI_int(0x10,&r)) |
2243 | 466 { |
467 LRMI_free_real(rm_space); | |
468 return VBE_VM86_FAIL; | |
469 } | |
470 retval = r.eax & 0xffff; | |
471 if(retval != 0x4f) | |
472 { | |
473 LRMI_free_real(rm_space); | |
474 return retval; | |
475 } | |
476 *data = rm_space; | |
477 return VBE_OK; | |
478 } | |
479 | |
480 int vbeRestoreState(void *data) | |
481 { | |
482 struct LRMI_regs r; | |
483 int retval; | |
484 memset(&r,0,sizeof(struct LRMI_regs)); | |
485 r.eax = 0x4f04; | |
486 r.edx = 0x02; | |
487 r.ecx = 0x0f; | |
488 r.es = VirtToPhysSeg(data); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
489 r.ebx = VirtToPhysOff(data); |
2294 | 490 retval = VBE_LRMI_int(0x10,&r); |
2243 | 491 LRMI_free_real(data); |
492 if(!retval) return VBE_VM86_FAIL; | |
493 retval = r.eax & 0xffff; | |
494 if(retval == 0x4f) retval = VBE_OK; | |
495 return retval; | |
496 } | |
497 | |
498 int vbeGetWindow(unsigned *win_num) | |
499 { | |
500 struct LRMI_regs r; | |
501 int retval; | |
502 memset(&r,0,sizeof(struct LRMI_regs)); | |
503 r.eax = 0x4f05; | |
504 r.ebx = (*win_num & 0x0f) | 0x0100; | |
2294 | 505 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 506 retval = r.eax & 0xffff; |
507 if(retval == 0x4f) | |
508 { | |
509 *win_num = r.edx & 0xffff; | |
510 retval = VBE_OK; | |
511 } | |
512 return retval; | |
513 } | |
514 | |
515 int vbeSetWindow(unsigned win_num,unsigned win_gran) | |
516 { | |
517 int retval; | |
518 if(vbe_pm_info.SetWindowCall) | |
519 { | |
2294 | 520 /* Don't verbose this stuff from performance reasons */ |
2243 | 521 /* 32-bit function call is much better of int 10h */ |
522 __asm __volatile( | |
523 "pushl %%ebx\n" | |
524 "movl %1, %%ebx\n" | |
525 ::"a"(0x4f05),"S"(win_num & 0x0f),"d"(win_gran):"memory"); | |
526 (*vbe_pm_info.SetWindowCall)(); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
527 __asm __volatile("popl %%ebx":::"memory"); |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
528 retval = VBE_OK; |
2243 | 529 } |
530 else | |
531 { | |
532 struct LRMI_regs r; | |
533 memset(&r,0,sizeof(struct LRMI_regs)); | |
534 r.eax = 0x4f05; | |
535 r.ebx = win_num & 0x0f; | |
536 r.edx = win_gran; | |
2294 | 537 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 538 retval = r.eax & 0xffff; |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
539 if(retval == 0x4f) retval = VBE_OK; |
2243 | 540 } |
541 return retval; | |
542 } | |
543 | |
2632 | 544 int vbeGetScanLineLength(unsigned *num_pixels,unsigned *num_bytes) |
545 { | |
546 struct LRMI_regs r; | |
547 int retval; | |
548 memset(&r,0,sizeof(struct LRMI_regs)); | |
549 r.eax = 0x4f06; | |
550 r.ebx = 1; | |
551 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
552 retval = r.eax & 0xffff; | |
553 if(retval == 0x4f) | |
554 { | |
555 if(num_bytes) *num_bytes = r.ebx & 0xffff; | |
556 if(num_pixels) *num_pixels= r.ecx & 0xffff; | |
557 retval = VBE_OK; | |
558 } | |
559 return retval; | |
560 } | |
561 | |
562 int vbeGetMaxScanLines(unsigned *num_pixels,unsigned *num_bytes, unsigned *num_lines) | |
563 { | |
564 struct LRMI_regs r; | |
565 int retval; | |
566 memset(&r,0,sizeof(struct LRMI_regs)); | |
567 r.eax = 0x4f06; | |
568 r.ebx = 3; | |
569 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
570 retval = r.eax & 0xffff; | |
571 if(retval == 0x4f) | |
572 { | |
573 if(num_bytes) *num_bytes = r.ebx & 0xffff; | |
574 if(num_pixels) *num_pixels= r.ecx & 0xffff; | |
575 if(num_lines) *num_lines = r.edx & 0xffff; | |
576 retval = VBE_OK; | |
577 } | |
578 return retval; | |
579 } | |
580 | |
581 int vbeSetScanLineLength(unsigned num_pixels) | |
582 { | |
583 int retval; | |
584 struct LRMI_regs r; | |
585 memset(&r,0,sizeof(struct LRMI_regs)); | |
586 r.eax = 0x4f06; | |
587 r.ebx = 0; | |
588 r.ecx = num_pixels; | |
589 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
590 retval = r.eax & 0xffff; | |
591 if(retval == 0x4f) retval = VBE_OK; | |
592 return retval; | |
593 } | |
594 | |
595 int vbeSetScanLineLengthB(unsigned num_bytes) | |
596 { | |
597 int retval; | |
598 struct LRMI_regs r; | |
599 memset(&r,0,sizeof(struct LRMI_regs)); | |
600 r.eax = 0x4f06; | |
601 r.ebx = 2; | |
602 r.ecx = num_bytes; | |
603 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
604 retval = r.eax & 0xffff; | |
605 if(retval == 0x4f) retval = VBE_OK; | |
606 return retval; | |
607 } | |
608 | |
609 int vbeGetDisplayStart(unsigned *pixel_num,unsigned *scan_line) | |
610 { | |
611 struct LRMI_regs r; | |
612 int retval; | |
613 memset(&r,0,sizeof(struct LRMI_regs)); | |
614 r.eax = 0x4f07; | |
615 r.ebx = 1; | |
616 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
617 retval = r.eax & 0xffff; | |
618 if(retval == 0x4f) | |
619 { | |
620 if(pixel_num) *pixel_num = r.ecx & 0xffff; | |
621 if(scan_line) *scan_line = r.edx & 0xffff; | |
622 retval = VBE_OK; | |
623 } | |
624 return retval; | |
625 } | |
626 | |
627 int vbeSetDisplayStart(unsigned long offset, int vsync) | |
628 { | |
629 int retval; | |
630 if(vbe_pm_info.SetDisplayStart) | |
631 { | |
632 /* Don't verbose this stuff from performance reasons */ | |
633 /* 32-bit function call is much better of int 10h */ | |
634 __asm __volatile( | |
635 "pushl %%ebx\n" | |
636 "movl %1, %%ebx\n" | |
637 ::"a"(0x4f07),"S"(vsync ? 0x80 : 0), | |
2686 | 638 "c"((offset>>2) & 0xffff),"d"((offset>>18)&0xffff):"memory"); |
2632 | 639 (*vbe_pm_info.SetDisplayStart)(); |
640 __asm __volatile("popl %%ebx":::"memory"); | |
641 retval = VBE_OK; | |
642 } | |
643 else | |
644 { | |
645 struct LRMI_regs r; | |
646 unsigned long pixel_num; | |
647 memset(&r,0,sizeof(struct LRMI_regs)); | |
2686 | 648 pixel_num = offset%(unsigned long)curr_mode_info.BytesPerScanLine; |
649 if(pixel_num*(unsigned long)curr_mode_info.BytesPerScanLine!=offset) pixel_num++; | |
2632 | 650 r.eax = 0x4f07; |
2693 | 651 r.ebx = vsync ? 0x82 : 2; |
2632 | 652 r.ecx = pixel_num; |
653 r.edx = offset/(unsigned long)curr_mode_info.BytesPerScanLine; | |
654 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
655 retval = r.eax & 0xffff; | |
656 if(retval == 0x4f) retval = VBE_OK; | |
13568
1cb0e1833515
Currently vbeGetProtModeInfo call the 0x4f0a function of int 10h the get
faust3
parents:
13352
diff
changeset
|
657 else retval = VBE_BROKEN_BIOS; |
2632 | 658 } |
659 return retval; | |
660 } | |
661 | |
2693 | 662 int vbeSetScheduledDisplayStart(unsigned long offset, int vsync) |
663 { | |
664 int retval; | |
665 struct LRMI_regs r; | |
666 unsigned long pixel_num; | |
667 memset(&r,0,sizeof(struct LRMI_regs)); | |
668 pixel_num = offset%(unsigned long)curr_mode_info.BytesPerScanLine; | |
669 if(pixel_num*(unsigned long)curr_mode_info.BytesPerScanLine!=offset) pixel_num++; | |
670 r.eax = 0x4f07; | |
671 r.ebx = vsync ? 0x82 : 2; | |
672 r.ecx = offset; | |
673 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
674 retval = r.eax & 0xffff; | |
675 if(retval == 0x4f) retval = VBE_OK; | |
676 return retval; | |
677 } | |
678 | |
2243 | 679 struct realVesaProtModeInterface |
680 { | |
681 unsigned short SetWindowCall; | |
682 unsigned short SetDisplayStart; | |
683 unsigned short SetPaletteData; | |
684 unsigned short iopl_ports; | |
685 }__attribute__((packed)); | |
686 | |
687 int vbeGetProtModeInfo(struct VesaProtModeInterface *pm_info) | |
688 { | |
689 struct LRMI_regs r; | |
690 int retval; | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
691 unsigned info_offset; |
2243 | 692 struct realVesaProtModeInterface *rm_info; |
693 memset(&r,0,sizeof(struct LRMI_regs)); | |
694 r.eax = 0x4f0a; | |
695 r.ebx = 0; | |
2294 | 696 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 697 retval = r.eax & 0xffff; |
698 if(retval == 0x4f) | |
699 { | |
2407 | 700 retval = VBE_OK; |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
701 info_offset = r.edi&0xffff; |
2407 | 702 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
|
703 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
|
704 pm_info->SetWindowCall = PhysToVirtSO(r.es,info_offset+rm_info->SetWindowCall); |
2552 | 705 if(!is_addr_valid(pm_info->SetWindowCall)) retval = VBE_BROKEN_BIOS; |
2294 | 706 #ifdef HAVE_VERBOSE_VAR |
707 if(verbose > 1) printf("vbelib: SetWindowCall=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetWindowCall,pm_info->SetWindowCall); | |
708 #endif | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
709 pm_info->SetDisplayStart = PhysToVirtSO(r.es,info_offset+rm_info->SetDisplayStart); |
2552 | 710 if(!is_addr_valid(pm_info->SetDisplayStart)) retval = VBE_BROKEN_BIOS; |
2294 | 711 #ifdef HAVE_VERBOSE_VAR |
712 if(verbose > 1) printf("vbelib: SetDisplayStart=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetDisplayStart,pm_info->SetDisplayStart); | |
713 #endif | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
714 pm_info->SetPaletteData = PhysToVirtSO(r.es,info_offset+rm_info->SetPaletteData); |
2552 | 715 if(!is_addr_valid(pm_info->SetPaletteData)) retval = VBE_BROKEN_BIOS; |
2294 | 716 #ifdef HAVE_VERBOSE_VAR |
717 if(verbose > 1) printf("vbelib: SetPaletteData=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetPaletteData,pm_info->SetPaletteData); | |
718 #endif | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
719 pm_info->iopl_ports = PhysToVirtSO(r.es,info_offset+rm_info->iopl_ports); |
2913 | 720 if(!rm_info->iopl_ports) pm_info->iopl_ports = NULL; |
721 else | |
2515 | 722 if(!check_wrd(pm_info->iopl_ports)) |
723 { | |
724 pm_info->iopl_ports = NULL; | |
2913 | 725 /* retval = VBE_BROKEN_BIOS; <- It's for broken BIOSes only */ |
2515 | 726 } |
2294 | 727 #ifdef HAVE_VERBOSE_VAR |
2407 | 728 if(verbose > 1) |
729 { | |
730 printf("vbelib: iopl_ports=%04X:%04X => %p\n",r.es,info_offset+rm_info->iopl_ports,pm_info->iopl_ports); | |
2515 | 731 if(pm_info->iopl_ports) print_wrd(pm_info->iopl_ports); |
2518 | 732 fflush(stdout); |
2407 | 733 } |
2294 | 734 #endif |
2243 | 735 } |
736 return retval; | |
737 } | |
2410 | 738 /* --------- Standard VGA stuff -------------- */ |
739 int vbeWriteString(int x, int y, int attr, char *str) | |
740 { | |
741 struct LRMI_regs r; | |
742 void *rm_space = NULL; | |
743 int retval; | |
744 memset(&r,0,sizeof(struct LRMI_regs)); | |
745 r.ecx = strlen(str); | |
746 r.edx = ((y<<8)&0xff00)|(x&0xff); | |
747 r.ebx = attr; | |
748 if(!(rm_space = LRMI_alloc_real(r.ecx))) return VBE_OUT_OF_DOS_MEM; | |
749 r.es = VirtToPhysSeg(rm_space); | |
750 r.ebp = VirtToPhysOff(rm_space); | |
751 memcpy(rm_space,str,r.ecx); | |
752 r.eax = 0x1300; | |
753 retval = VBE_LRMI_int(0x10,&r); | |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
754 LRMI_free_real(rm_space); |
2410 | 755 if(!retval) return VBE_VM86_FAIL; |
756 retval = r.eax & 0xffff; | |
757 if(retval == 0x4f) retval = VBE_OK; | |
758 return retval; | |
2460 | 759 } |
2610 | 760 |
761 void * vbeMapVideoBuffer(unsigned long phys_addr,unsigned long size) | |
762 { | |
763 void *lfb; | |
764 if(fd_mem == -1) return NULL; | |
765 if(verbose > 1) printf("vbelib: vbeMapVideoBuffer(%08lX,%08lX)\n",phys_addr,size); | |
766 /* Here we don't need with MAP_FIXED and prefered address (first argument) */ | |
767 lfb = mmap((void *)0,size,PROT_READ | PROT_WRITE,MAP_SHARED,fd_mem,phys_addr); | |
768 return lfb == (void *)-1 ? 0 : lfb; | |
769 } | |
770 | |
771 void vbeUnmapVideoBuffer(unsigned long linear_addr,unsigned long size) | |
772 { | |
773 if(verbose > 1) printf("vbelib: vbeUnmapVideoBuffer(%08lX,%08lX)\n",linear_addr,size); | |
774 munmap((void *)linear_addr,size); | |
775 } | |
11455 | 776 |
777 #endif |