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