Mercurial > mplayer.hg
annotate osdep/vbelib.c @ 13519:6bf63a7524d8
Sync with 1.759:
Documentation of x264 3-pass mode, and fixes on lavc's *_mask
options, pointed out by Jiri Heryan
author | gpoirier |
---|---|
date | Fri, 01 Oct 2004 15:53:09 +0000 |
parents | 166a12bd5470 |
children | 1cb0e1833515 |
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; |
2552 | 131 int retval; |
2243 | 132 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
|
133 if(!(controller_info = LRMI_alloc_real(sizeof(struct VbeInfoBlock)))) return VBE_OUT_OF_DOS_MEM; |
2243 | 134 /* |
135 Allow read/write to ALL io ports | |
136 */ | |
2407 | 137 hh_int_10_seg = *(unsigned short *)PhysToVirtSO(0x0000,0x0042); |
2359 | 138 /* Video BIOS should be at C000:0000 and above */ |
2407 | 139 hh_int_10_seg >>= 12; |
140 if(hh_int_10_seg < 0xC) return VBE_BROKEN_BIOS; | |
2243 | 141 ioperm(0, 1024, 1); |
142 iopl(3); | |
143 memset(&vbe_pm_info,0,sizeof(struct VesaProtModeInterface)); | |
2552 | 144 retval = vbeGetProtModeInfo(&vbe_pm_info); |
145 if(retval != VBE_OK) return retval; | |
2359 | 146 i = 0; |
2913 | 147 if(vbe_pm_info.iopl_ports) /* Can be NULL !!!*/ |
2552 | 148 while((iopl_port=vbe_pm_info.iopl_ports[i]) != 0xFFFF |
149 && vbe_pm_info.iopl_ports[i++] > 1023) ioperm(iopl_port,1,1); | |
2359 | 150 iopl(3); |
2610 | 151 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
|
152 hide_terminal_output(); |
2243 | 153 return VBE_OK; |
154 } | |
155 | |
2610 | 156 int vbeDestroy( void ) |
157 { | |
10114
f6a788f113a8
uninit fix by Aurelien JACOBS <aurel at gnuage.org>
faust3
parents:
9380
diff
changeset
|
158 if (my_stdout) __set_cursor_type(my_stdout,1); |
2610 | 159 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
|
160 LRMI_free_real(controller_info); |
2610 | 161 return VBE_OK; |
162 } | |
2243 | 163 |
2536 | 164 /* Fixme!!! This code is compatible only with mplayer's version of lrmi*/ |
165 static inline int is_addr_valid(const void *p) | |
166 { | |
167 return (p < (const void *)0x502) || | |
168 (p >= (const void *)0x10000 && p < (const void *)0x20000) || | |
169 (p >= (const void *)0xa0000 && p < (const void *)0x100000); | |
170 } | |
171 | |
172 static int check_str(const unsigned char *str) | |
2515 | 173 { |
174 size_t i; | |
175 int null_found = 0; | |
176 for(i = 0;i < 256;i++) | |
177 { | |
2536 | 178 if(is_addr_valid(&str[i])) |
2515 | 179 { |
2536 | 180 if(VERR(&str[i])) |
181 { | |
182 if(!str[i]) { null_found = 1; break; } | |
183 } | |
184 else break; | |
2515 | 185 } |
186 else break; | |
187 } | |
188 return null_found; | |
189 } | |
190 | |
2536 | 191 static int check_wrd(const unsigned short *str) |
2515 | 192 { |
193 size_t i; | |
194 int ffff_found = 0; | |
195 for(i = 0;i < 1024;i++) | |
196 { | |
2536 | 197 if(is_addr_valid(&str[i])) |
2515 | 198 { |
2536 | 199 if(VERR(&str[i])) |
200 { | |
201 if(str[i] == 0xffff) { ffff_found = 1; break; } | |
202 } | |
203 else break; | |
2515 | 204 } |
205 else break; | |
206 } | |
207 return ffff_found; | |
208 } | |
209 | |
2407 | 210 static void print_str(unsigned char *str) |
211 { | |
212 size_t i; | |
213 fflush(stdout); | |
214 printf("vbelib: "); | |
215 for(i = 0;i < 256;i++) { printf("%02X(%c) ",str[i],isprint(str[i])?str[i]:'.'); if(!str[i]) break; } | |
216 printf("\n"); | |
217 fflush(stdout); | |
218 } | |
219 | |
220 static void print_wrd(unsigned short *str) | |
221 { | |
222 size_t i; | |
223 fflush(stdout); | |
224 printf("vbelib: "); | |
225 for(i = 0;i < 256;i++) { printf("%04X ",str[i]); if(str[i] == 0xffff) break; } | |
226 printf("\n"); | |
227 fflush(stdout); | |
228 } | |
229 | |
2243 | 230 int vbeGetControllerInfo(struct VbeInfoBlock *data) |
231 { | |
232 struct LRMI_regs r; | |
233 int retval; | |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
234 memcpy(controller_info,data,sizeof(struct VbeInfoBlock)); |
2243 | 235 memset(&r,0,sizeof(struct LRMI_regs)); |
236 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
|
237 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
|
238 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
|
239 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 240 retval = r.eax & 0xffff; |
241 if(retval == 0x4f) | |
242 { | |
243 FarPtr fpdata; | |
244 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
|
245 memcpy(data,controller_info,sizeof(struct VbeInfoBlock)); |
2243 | 246 fpdata.seg = (unsigned long)(data->OemStringPtr) >> 16; |
247 fpdata.off = (unsigned long)(data->OemStringPtr) & 0xffff; | |
248 data->OemStringPtr = PhysToVirt(fpdata); | |
2515 | 249 if(!check_str(data->OemStringPtr)) data->OemStringPtr = NULL; |
2294 | 250 #ifdef HAVE_VERBOSE_VAR |
2407 | 251 if(verbose > 1) |
252 { | |
253 printf("vbelib: OemStringPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemStringPtr); | |
2515 | 254 if(data->OemStringPtr) print_str(data->OemStringPtr); |
2518 | 255 fflush(stdout); |
2407 | 256 } |
2294 | 257 #endif |
2243 | 258 fpdata.seg = (unsigned long)(data->VideoModePtr) >> 16; |
259 fpdata.off = (unsigned long)(data->VideoModePtr) & 0xffff; | |
260 data->VideoModePtr = PhysToVirt(fpdata); | |
2515 | 261 if(!check_wrd(data->VideoModePtr)) |
262 { | |
263 data->VideoModePtr = NULL; | |
264 retval = VBE_BROKEN_BIOS; | |
265 } | |
2294 | 266 #ifdef HAVE_VERBOSE_VAR |
2407 | 267 if(verbose > 1) |
268 { | |
269 printf("vbelib: VideoModePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->VideoModePtr); | |
2515 | 270 if(data->VideoModePtr) print_wrd(data->VideoModePtr); |
2518 | 271 fflush(stdout); |
2407 | 272 } |
2294 | 273 #endif |
2243 | 274 fpdata.seg = (unsigned long)(data->OemVendorNamePtr) >> 16; |
275 fpdata.off = (unsigned long)(data->OemVendorNamePtr) & 0xffff; | |
276 data->OemVendorNamePtr = PhysToVirt(fpdata); | |
2515 | 277 if(!check_str(data->OemVendorNamePtr)) data->OemVendorNamePtr = NULL; |
2294 | 278 #ifdef HAVE_VERBOSE_VAR |
2407 | 279 if(verbose > 1) |
280 { | |
281 printf("vbelib: OemVendorNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemVendorNamePtr); | |
2515 | 282 if(data->OemVendorNamePtr) print_str(data->OemVendorNamePtr); |
2518 | 283 fflush(stdout); |
2407 | 284 } |
2294 | 285 #endif |
2243 | 286 fpdata.seg = (unsigned long)(data->OemProductNamePtr) >> 16; |
287 fpdata.off = (unsigned long)(data->OemProductNamePtr) & 0xffff; | |
288 data->OemProductNamePtr = PhysToVirt(fpdata); | |
2515 | 289 if(!check_str(data->OemProductNamePtr)) data->OemProductNamePtr = NULL; |
2294 | 290 #ifdef HAVE_VERBOSE_VAR |
2407 | 291 if(verbose > 1) |
292 { | |
293 printf("vbelib: OemProductNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductNamePtr); | |
2515 | 294 if(data->OemVendorNamePtr) print_str(data->OemProductNamePtr); |
2518 | 295 fflush(stdout); |
2407 | 296 } |
2294 | 297 #endif |
2243 | 298 fpdata.seg = (unsigned long)(data->OemProductRevPtr) >> 16; |
299 fpdata.off = (unsigned long)(data->OemProductRevPtr) & 0xffff; | |
300 data->OemProductRevPtr = PhysToVirt(fpdata); | |
2515 | 301 if(!check_str(data->OemProductRevPtr)) data->OemProductRevPtr = NULL; |
2294 | 302 #ifdef HAVE_VERBOSE_VAR |
2407 | 303 if(verbose > 1) |
304 { | |
305 printf("vbelib: OemProductRevPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductRevPtr); | |
2515 | 306 if(data->OemProductRevPtr) print_str(data->OemProductRevPtr); |
2518 | 307 fflush(stdout); |
2407 | 308 } |
2294 | 309 #endif |
2243 | 310 } |
311 return retval; | |
312 } | |
313 | |
314 int vbeGetModeInfo(unsigned mode,struct VesaModeInfoBlock *data) | |
315 { | |
316 struct LRMI_regs r; | |
317 void *rm_space; | |
318 int retval; | |
319 if(!(rm_space = LRMI_alloc_real(sizeof(struct VesaModeInfoBlock)))) return VBE_OUT_OF_DOS_MEM; | |
320 memset(&r,0,sizeof(struct LRMI_regs)); | |
321 r.eax = 0x4f01; | |
322 r.ecx = mode; | |
323 r.es = VirtToPhysSeg(rm_space); | |
324 r.edi = VirtToPhysOff(rm_space); | |
2294 | 325 if(!VBE_LRMI_int(0x10,&r)) |
2243 | 326 { |
327 LRMI_free_real(rm_space); | |
328 return VBE_VM86_FAIL; | |
329 } | |
330 retval = r.eax & 0xffff; | |
331 if(retval == 0x4f) | |
332 { | |
333 retval = VBE_OK; | |
334 memcpy(data,rm_space,sizeof(struct VesaModeInfoBlock)); | |
335 } | |
6473
6c45b8bf9a3e
date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13
atmos4
parents:
4405
diff
changeset
|
336 LRMI_free_real(rm_space); |
2243 | 337 return retval; |
338 } | |
339 | |
12660
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 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
|
342 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
343 #define NR_MODES 8 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
344 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
345 unsigned int mode_table[NR_MODES] = |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
346 {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
|
347 unsigned int tv_table[][NR_MODES] = { |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
348 {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
|
349 {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
|
350 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
351 /* |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
352 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
353 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
|
354 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
|
355 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
|
356 r.marek et sh.cvut.cz |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
357 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
358 {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
|
359 {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
|
360 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
361 */ |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
362 int i,retval; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
363 struct LRMI_regs r; |
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 memset(&r,0,sizeof(struct LRMI_regs)); |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
366 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
|
367 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
368 if (i==NR_MODES) return 0; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
369 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
|
370 r.eax = 0x4f14; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
371 r.ebx = 0x20; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
372 r.edx = 0; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
373 r.edi = 0; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
374 r.ecx = tv_table[TV_mode][i]; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
375 retval = VBE_LRMI_int(0x10,&r); |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
376 if(!retval) return VBE_VM86_FAIL; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
377 return r.eax & 0xffff; |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
378 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
11455
diff
changeset
|
379 } |
2243 | 380 int vbeSetMode(unsigned mode,struct VesaCRTCInfoBlock *data) |
381 { | |
382 struct LRMI_regs r; | |
383 void *rm_space = NULL; | |
384 int retval; | |
385 memset(&r,0,sizeof(struct LRMI_regs)); | |
386 if(data) | |
387 { | |
388 if(!(rm_space = LRMI_alloc_real(sizeof(struct VesaCRTCInfoBlock)))) return VBE_OUT_OF_DOS_MEM; | |
389 r.es = VirtToPhysSeg(rm_space); | |
390 r.edi = VirtToPhysOff(rm_space); | |
391 memcpy(rm_space,data,sizeof(struct VesaCRTCInfoBlock)); | |
392 } | |
393 r.eax = 0x4f02; | |
394 r.ebx = mode; | |
2294 | 395 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
|
396 LRMI_free_real(rm_space); |
2243 | 397 if(!retval) return VBE_VM86_FAIL; |
398 retval = r.eax & 0xffff; | |
2632 | 399 if(retval == 0x4f) |
400 { | |
401 /* Just info for internal use (currently in SetDiplayStart func). */ | |
402 vbeGetModeInfo(mode&0x1f,&curr_mode_info); | |
403 retval = VBE_OK; | |
404 } | |
2243 | 405 return retval; |
406 } | |
407 | |
408 int vbeGetMode(unsigned *mode) | |
409 { | |
410 struct LRMI_regs r; | |
411 int retval; | |
412 memset(&r,0,sizeof(struct LRMI_regs)); | |
413 r.eax = 0x4f03; | |
2294 | 414 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 415 retval = r.eax & 0xffff; |
416 if(retval == 0x4f) | |
417 { | |
418 *mode = r.ebx; | |
419 retval = VBE_OK; | |
420 } | |
421 return retval; | |
422 } | |
423 | |
7069 | 424 int vbeGetPixelClock(unsigned *mode,unsigned *pixel_clock) // in Hz |
425 { | |
426 struct LRMI_regs r; | |
427 int retval; | |
428 memset(&r,0,sizeof(struct LRMI_regs)); | |
429 r.eax = 0x4f0b; | |
430 r.ebx = 0; | |
431 r.edx = *mode; | |
432 r.ecx = *pixel_clock; | |
433 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
434 retval = r.eax & 0xffff; | |
435 if(retval == 0x4f) | |
436 { | |
437 *pixel_clock = r.ecx; | |
438 retval = VBE_OK; | |
439 } | |
440 return retval; | |
441 } | |
442 | |
443 | |
2243 | 444 int vbeSaveState(void **data) |
445 { | |
446 struct LRMI_regs r; | |
447 int retval; | |
448 void *rm_space; | |
449 memset(&r,0,sizeof(struct LRMI_regs)); | |
450 r.eax = 0x4f04; | |
451 r.edx = 0x00; | |
452 r.ecx = 0x0f; | |
2294 | 453 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 454 retval = r.eax & 0xffff; |
455 if(retval != 0x4f) return retval; | |
456 if(!(rm_space = LRMI_alloc_real((r.ebx & 0xffff)*64))) return VBE_OUT_OF_DOS_MEM; | |
457 r.eax = 0x4f04; | |
458 r.edx = 0x01; | |
459 r.ecx = 0x0f; | |
460 r.es = VirtToPhysSeg(rm_space); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
461 r.ebx = VirtToPhysOff(rm_space); |
2294 | 462 if(!VBE_LRMI_int(0x10,&r)) |
2243 | 463 { |
464 LRMI_free_real(rm_space); | |
465 return VBE_VM86_FAIL; | |
466 } | |
467 retval = r.eax & 0xffff; | |
468 if(retval != 0x4f) | |
469 { | |
470 LRMI_free_real(rm_space); | |
471 return retval; | |
472 } | |
473 *data = rm_space; | |
474 return VBE_OK; | |
475 } | |
476 | |
477 int vbeRestoreState(void *data) | |
478 { | |
479 struct LRMI_regs r; | |
480 int retval; | |
481 memset(&r,0,sizeof(struct LRMI_regs)); | |
482 r.eax = 0x4f04; | |
483 r.edx = 0x02; | |
484 r.ecx = 0x0f; | |
485 r.es = VirtToPhysSeg(data); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
486 r.ebx = VirtToPhysOff(data); |
2294 | 487 retval = VBE_LRMI_int(0x10,&r); |
2243 | 488 LRMI_free_real(data); |
489 if(!retval) return VBE_VM86_FAIL; | |
490 retval = r.eax & 0xffff; | |
491 if(retval == 0x4f) retval = VBE_OK; | |
492 return retval; | |
493 } | |
494 | |
495 int vbeGetWindow(unsigned *win_num) | |
496 { | |
497 struct LRMI_regs r; | |
498 int retval; | |
499 memset(&r,0,sizeof(struct LRMI_regs)); | |
500 r.eax = 0x4f05; | |
501 r.ebx = (*win_num & 0x0f) | 0x0100; | |
2294 | 502 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 503 retval = r.eax & 0xffff; |
504 if(retval == 0x4f) | |
505 { | |
506 *win_num = r.edx & 0xffff; | |
507 retval = VBE_OK; | |
508 } | |
509 return retval; | |
510 } | |
511 | |
512 int vbeSetWindow(unsigned win_num,unsigned win_gran) | |
513 { | |
514 int retval; | |
515 if(vbe_pm_info.SetWindowCall) | |
516 { | |
2294 | 517 /* Don't verbose this stuff from performance reasons */ |
2243 | 518 /* 32-bit function call is much better of int 10h */ |
519 __asm __volatile( | |
520 "pushl %%ebx\n" | |
521 "movl %1, %%ebx\n" | |
522 ::"a"(0x4f05),"S"(win_num & 0x0f),"d"(win_gran):"memory"); | |
523 (*vbe_pm_info.SetWindowCall)(); | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
524 __asm __volatile("popl %%ebx":::"memory"); |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
525 retval = VBE_OK; |
2243 | 526 } |
527 else | |
528 { | |
529 struct LRMI_regs r; | |
530 memset(&r,0,sizeof(struct LRMI_regs)); | |
531 r.eax = 0x4f05; | |
532 r.ebx = win_num & 0x0f; | |
533 r.edx = win_gran; | |
2294 | 534 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
2243 | 535 retval = r.eax & 0xffff; |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
536 if(retval == 0x4f) retval = VBE_OK; |
2243 | 537 } |
538 return retval; | |
539 } | |
540 | |
2632 | 541 int vbeGetScanLineLength(unsigned *num_pixels,unsigned *num_bytes) |
542 { | |
543 struct LRMI_regs r; | |
544 int retval; | |
545 memset(&r,0,sizeof(struct LRMI_regs)); | |
546 r.eax = 0x4f06; | |
547 r.ebx = 1; | |
548 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
549 retval = r.eax & 0xffff; | |
550 if(retval == 0x4f) | |
551 { | |
552 if(num_bytes) *num_bytes = r.ebx & 0xffff; | |
553 if(num_pixels) *num_pixels= r.ecx & 0xffff; | |
554 retval = VBE_OK; | |
555 } | |
556 return retval; | |
557 } | |
558 | |
559 int vbeGetMaxScanLines(unsigned *num_pixels,unsigned *num_bytes, unsigned *num_lines) | |
560 { | |
561 struct LRMI_regs r; | |
562 int retval; | |
563 memset(&r,0,sizeof(struct LRMI_regs)); | |
564 r.eax = 0x4f06; | |
565 r.ebx = 3; | |
566 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
567 retval = r.eax & 0xffff; | |
568 if(retval == 0x4f) | |
569 { | |
570 if(num_bytes) *num_bytes = r.ebx & 0xffff; | |
571 if(num_pixels) *num_pixels= r.ecx & 0xffff; | |
572 if(num_lines) *num_lines = r.edx & 0xffff; | |
573 retval = VBE_OK; | |
574 } | |
575 return retval; | |
576 } | |
577 | |
578 int vbeSetScanLineLength(unsigned num_pixels) | |
579 { | |
580 int retval; | |
581 struct LRMI_regs r; | |
582 memset(&r,0,sizeof(struct LRMI_regs)); | |
583 r.eax = 0x4f06; | |
584 r.ebx = 0; | |
585 r.ecx = num_pixels; | |
586 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
587 retval = r.eax & 0xffff; | |
588 if(retval == 0x4f) retval = VBE_OK; | |
589 return retval; | |
590 } | |
591 | |
592 int vbeSetScanLineLengthB(unsigned num_bytes) | |
593 { | |
594 int retval; | |
595 struct LRMI_regs r; | |
596 memset(&r,0,sizeof(struct LRMI_regs)); | |
597 r.eax = 0x4f06; | |
598 r.ebx = 2; | |
599 r.ecx = num_bytes; | |
600 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
601 retval = r.eax & 0xffff; | |
602 if(retval == 0x4f) retval = VBE_OK; | |
603 return retval; | |
604 } | |
605 | |
606 int vbeGetDisplayStart(unsigned *pixel_num,unsigned *scan_line) | |
607 { | |
608 struct LRMI_regs r; | |
609 int retval; | |
610 memset(&r,0,sizeof(struct LRMI_regs)); | |
611 r.eax = 0x4f07; | |
612 r.ebx = 1; | |
613 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
614 retval = r.eax & 0xffff; | |
615 if(retval == 0x4f) | |
616 { | |
617 if(pixel_num) *pixel_num = r.ecx & 0xffff; | |
618 if(scan_line) *scan_line = r.edx & 0xffff; | |
619 retval = VBE_OK; | |
620 } | |
621 return retval; | |
622 } | |
623 | |
624 int vbeSetDisplayStart(unsigned long offset, int vsync) | |
625 { | |
626 int retval; | |
627 if(vbe_pm_info.SetDisplayStart) | |
628 { | |
629 /* Don't verbose this stuff from performance reasons */ | |
630 /* 32-bit function call is much better of int 10h */ | |
631 __asm __volatile( | |
632 "pushl %%ebx\n" | |
633 "movl %1, %%ebx\n" | |
634 ::"a"(0x4f07),"S"(vsync ? 0x80 : 0), | |
2686 | 635 "c"((offset>>2) & 0xffff),"d"((offset>>18)&0xffff):"memory"); |
2632 | 636 (*vbe_pm_info.SetDisplayStart)(); |
637 __asm __volatile("popl %%ebx":::"memory"); | |
638 retval = VBE_OK; | |
639 } | |
640 else | |
641 { | |
2686 | 642 #if 0 |
643 /* Something wrong here */ | |
2632 | 644 struct LRMI_regs r; |
645 unsigned long pixel_num; | |
646 memset(&r,0,sizeof(struct LRMI_regs)); | |
2686 | 647 pixel_num = offset%(unsigned long)curr_mode_info.BytesPerScanLine; |
648 if(pixel_num*(unsigned long)curr_mode_info.BytesPerScanLine!=offset) pixel_num++; | |
2632 | 649 r.eax = 0x4f07; |
2693 | 650 r.ebx = vsync ? 0x82 : 2; |
2632 | 651 r.ecx = pixel_num; |
652 r.edx = offset/(unsigned long)curr_mode_info.BytesPerScanLine; | |
653 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | |
654 retval = r.eax & 0xffff; | |
655 if(retval == 0x4f) retval = VBE_OK; | |
2686 | 656 #endif |
657 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 |