Mercurial > mplayer.hg
comparison linux/vbelib.c @ 2407:2e4c17f4a744
More verbosing
author | nick |
---|---|
date | Tue, 23 Oct 2001 07:05:05 +0000 |
parents | ee6ef0b10655 |
children | 27ca5ad3c7e9 |
comparison
equal
deleted
inserted
replaced
2406:2547932c6ef0 | 2407:2e4c17f4a744 |
---|---|
11 #include "lrmi.h" | 11 #include "lrmi.h" |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 #include <string.h> | 13 #include <string.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <sys/io.h> | 15 #include <sys/io.h> |
16 #include <ctype.h> | |
16 | 17 |
17 static struct VesaProtModeInterface vbe_pm_info; | 18 static struct VesaProtModeInterface vbe_pm_info; |
18 | 19 |
19 #define HAVE_VERBOSE_VAR 1 | 20 #define HAVE_VERBOSE_VAR 1 |
20 | 21 |
52 } | 53 } |
53 #else | 54 #else |
54 #define VBE_LRMI_int(int_no,regs) (VBE_LRMI_int(int_no,regs)) | 55 #define VBE_LRMI_int(int_no,regs) (VBE_LRMI_int(int_no,regs)) |
55 #endif | 56 #endif |
56 | 57 |
58 static unsigned hh_int_10_seg; | |
57 int vbeInit( void ) | 59 int vbeInit( void ) |
58 { | 60 { |
59 unsigned short iopl_port,int_10_seg; | 61 unsigned short iopl_port; |
60 size_t i; | 62 size_t i; |
61 if(!LRMI_init()) return VBE_VM86_FAIL; | 63 if(!LRMI_init()) return VBE_VM86_FAIL; |
62 /* | 64 /* |
63 Allow read/write to ALL io ports | 65 Allow read/write to ALL io ports |
64 */ | 66 */ |
65 int_10_seg = *(unsigned short *)PhysToVirtSO(0x0000,0x0042); | 67 hh_int_10_seg = *(unsigned short *)PhysToVirtSO(0x0000,0x0042); |
66 /* Video BIOS should be at C000:0000 and above */ | 68 /* Video BIOS should be at C000:0000 and above */ |
67 if((int_10_seg >> 12) < 0xC) return VBE_BROKEN_BIOS; | 69 hh_int_10_seg >>= 12; |
70 if(hh_int_10_seg < 0xC) return VBE_BROKEN_BIOS; | |
68 ioperm(0, 1024, 1); | 71 ioperm(0, 1024, 1); |
69 iopl(3); | 72 iopl(3); |
70 memset(&vbe_pm_info,0,sizeof(struct VesaProtModeInterface)); | 73 memset(&vbe_pm_info,0,sizeof(struct VesaProtModeInterface)); |
71 vbeGetProtModeInfo(&vbe_pm_info); | 74 vbeGetProtModeInfo(&vbe_pm_info); |
72 i = 0; | 75 i = 0; |
75 return VBE_OK; | 78 return VBE_OK; |
76 } | 79 } |
77 | 80 |
78 int vbeDestroy( void ) { return VBE_OK; } | 81 int vbeDestroy( void ) { return VBE_OK; } |
79 | 82 |
83 static void print_str(unsigned char *str) | |
84 { | |
85 size_t i; | |
86 fflush(stdout); | |
87 printf("vbelib: "); | |
88 for(i = 0;i < 256;i++) { printf("%02X(%c) ",str[i],isprint(str[i])?str[i]:'.'); if(!str[i]) break; } | |
89 printf("\n"); | |
90 fflush(stdout); | |
91 } | |
92 | |
93 static void print_wrd(unsigned short *str) | |
94 { | |
95 size_t i; | |
96 fflush(stdout); | |
97 printf("vbelib: "); | |
98 for(i = 0;i < 256;i++) { printf("%04X ",str[i]); if(str[i] == 0xffff) break; } | |
99 printf("\n"); | |
100 fflush(stdout); | |
101 } | |
102 | |
80 int vbeGetControllerInfo(struct VbeInfoBlock *data) | 103 int vbeGetControllerInfo(struct VbeInfoBlock *data) |
81 { | 104 { |
82 struct LRMI_regs r; | 105 struct LRMI_regs r; |
83 void *rm_space; | 106 void *rm_space; |
84 int retval; | 107 int retval; |
101 memcpy(data,rm_space,sizeof(struct VbeInfoBlock)); | 124 memcpy(data,rm_space,sizeof(struct VbeInfoBlock)); |
102 fpdata.seg = (unsigned long)(data->OemStringPtr) >> 16; | 125 fpdata.seg = (unsigned long)(data->OemStringPtr) >> 16; |
103 fpdata.off = (unsigned long)(data->OemStringPtr) & 0xffff; | 126 fpdata.off = (unsigned long)(data->OemStringPtr) & 0xffff; |
104 data->OemStringPtr = PhysToVirt(fpdata); | 127 data->OemStringPtr = PhysToVirt(fpdata); |
105 #ifdef HAVE_VERBOSE_VAR | 128 #ifdef HAVE_VERBOSE_VAR |
106 if(verbose > 1) printf("vbelib: OemStringPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemStringPtr); | 129 if(verbose > 1) |
130 { | |
131 printf("vbelib: OemStringPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemStringPtr); | |
132 print_str(data->OemStringPtr); | |
133 } | |
107 #endif | 134 #endif |
108 fpdata.seg = (unsigned long)(data->VideoModePtr) >> 16; | 135 fpdata.seg = (unsigned long)(data->VideoModePtr) >> 16; |
109 fpdata.off = (unsigned long)(data->VideoModePtr) & 0xffff; | 136 fpdata.off = (unsigned long)(data->VideoModePtr) & 0xffff; |
110 data->VideoModePtr = PhysToVirt(fpdata); | 137 data->VideoModePtr = PhysToVirt(fpdata); |
111 #ifdef HAVE_VERBOSE_VAR | 138 #ifdef HAVE_VERBOSE_VAR |
112 if(verbose > 1) printf("vbelib: VideoModePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->VideoModePtr); | 139 if(verbose > 1) |
140 { | |
141 printf("vbelib: VideoModePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->VideoModePtr); | |
142 print_wrd(data->VideoModePtr); | |
143 } | |
113 #endif | 144 #endif |
114 fpdata.seg = (unsigned long)(data->OemVendorNamePtr) >> 16; | 145 fpdata.seg = (unsigned long)(data->OemVendorNamePtr) >> 16; |
115 fpdata.off = (unsigned long)(data->OemVendorNamePtr) & 0xffff; | 146 fpdata.off = (unsigned long)(data->OemVendorNamePtr) & 0xffff; |
116 data->OemVendorNamePtr = PhysToVirt(fpdata); | 147 data->OemVendorNamePtr = PhysToVirt(fpdata); |
117 #ifdef HAVE_VERBOSE_VAR | 148 #ifdef HAVE_VERBOSE_VAR |
118 if(verbose > 1) printf("vbelib: OemVendorNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemVendorNamePtr); | 149 if(verbose > 1) |
150 { | |
151 printf("vbelib: OemVendorNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemVendorNamePtr); | |
152 print_str(data->OemVendorNamePtr); | |
153 } | |
119 #endif | 154 #endif |
120 fpdata.seg = (unsigned long)(data->OemProductNamePtr) >> 16; | 155 fpdata.seg = (unsigned long)(data->OemProductNamePtr) >> 16; |
121 fpdata.off = (unsigned long)(data->OemProductNamePtr) & 0xffff; | 156 fpdata.off = (unsigned long)(data->OemProductNamePtr) & 0xffff; |
122 data->OemProductNamePtr = PhysToVirt(fpdata); | 157 data->OemProductNamePtr = PhysToVirt(fpdata); |
123 #ifdef HAVE_VERBOSE_VAR | 158 #ifdef HAVE_VERBOSE_VAR |
124 if(verbose > 1) printf("vbelib: OemProductNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductNamePtr); | 159 if(verbose > 1) |
160 { | |
161 printf("vbelib: OemProductNamePtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductNamePtr); | |
162 print_str(data->OemProductNamePtr); | |
163 } | |
125 #endif | 164 #endif |
126 fpdata.seg = (unsigned long)(data->OemProductRevPtr) >> 16; | 165 fpdata.seg = (unsigned long)(data->OemProductRevPtr) >> 16; |
127 fpdata.off = (unsigned long)(data->OemProductRevPtr) & 0xffff; | 166 fpdata.off = (unsigned long)(data->OemProductRevPtr) & 0xffff; |
128 data->OemProductRevPtr = PhysToVirt(fpdata); | 167 data->OemProductRevPtr = PhysToVirt(fpdata); |
129 #ifdef HAVE_VERBOSE_VAR | 168 #ifdef HAVE_VERBOSE_VAR |
130 if(verbose > 1) printf("vbelib: OemProductRevPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductRevPtr); | 169 if(verbose > 1) |
170 { | |
171 printf("vbelib: OemProductRevPtr=%04X:%04X => %p\n",fpdata.seg,fpdata.off,data->OemProductRevPtr); | |
172 print_str(data->OemProductRevPtr); | |
173 } | |
131 #endif | 174 #endif |
132 } | 175 } |
133 return retval; | 176 return retval; |
134 } | 177 } |
135 | 178 |
314 r.ebx = 0; | 357 r.ebx = 0; |
315 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; | 358 if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL; |
316 retval = r.eax & 0xffff; | 359 retval = r.eax & 0xffff; |
317 if(retval == 0x4f) | 360 if(retval == 0x4f) |
318 { | 361 { |
362 retval = VBE_OK; | |
319 info_offset = r.edi&0xffff; | 363 info_offset = r.edi&0xffff; |
364 if((r.es >> 12) != hh_int_10_seg) retval = VBE_BROKEN_BIOS; | |
320 rm_info = PhysToVirtSO(r.es,info_offset); | 365 rm_info = PhysToVirtSO(r.es,info_offset); |
321 pm_info->SetWindowCall = PhysToVirtSO(r.es,info_offset+rm_info->SetWindowCall); | 366 pm_info->SetWindowCall = PhysToVirtSO(r.es,info_offset+rm_info->SetWindowCall); |
322 #ifdef HAVE_VERBOSE_VAR | 367 #ifdef HAVE_VERBOSE_VAR |
323 if(verbose > 1) printf("vbelib: SetWindowCall=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetWindowCall,pm_info->SetWindowCall); | 368 if(verbose > 1) printf("vbelib: SetWindowCall=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetWindowCall,pm_info->SetWindowCall); |
324 #endif | 369 #endif |
330 #ifdef HAVE_VERBOSE_VAR | 375 #ifdef HAVE_VERBOSE_VAR |
331 if(verbose > 1) printf("vbelib: SetPaletteData=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetPaletteData,pm_info->SetPaletteData); | 376 if(verbose > 1) printf("vbelib: SetPaletteData=%04X:%04X => %p\n",r.es,info_offset+rm_info->SetPaletteData,pm_info->SetPaletteData); |
332 #endif | 377 #endif |
333 pm_info->iopl_ports = PhysToVirtSO(r.es,info_offset+rm_info->iopl_ports); | 378 pm_info->iopl_ports = PhysToVirtSO(r.es,info_offset+rm_info->iopl_ports); |
334 #ifdef HAVE_VERBOSE_VAR | 379 #ifdef HAVE_VERBOSE_VAR |
335 if(verbose > 1) printf("vbelib: iopl_ports=%04X:%04X => %p\n",r.es,info_offset+rm_info->iopl_ports,pm_info->iopl_ports); | 380 if(verbose > 1) |
336 #endif | 381 { |
337 retval = VBE_OK; | 382 printf("vbelib: iopl_ports=%04X:%04X => %p\n",r.es,info_offset+rm_info->iopl_ports,pm_info->iopl_ports); |
338 } | 383 print_wrd(pm_info->iopl_ports); |
339 return retval; | 384 } |
340 } | 385 #endif |
386 } | |
387 return retval; | |
388 } |