Retrieve the mode info block */
| 199 | |
| 200 | /* Retrieve the mode info block */ |
| 201 | static boolean |
| 202 | vesa_GetModeInfo(unsigned mode, struct ModeInfoBlock *info) |
| 203 | { |
| 204 | int mode_info_sel = -1; /* custodial */ |
| 205 | int mode_info_seg; |
| 206 | __dpmi_regs regs; |
| 207 | |
| 208 | mode_info_seg = __dpmi_allocate_dos_memory( |
| 209 | (sizeof(*info) + 15) / 16, |
| 210 | &mode_info_sel); |
| 211 | if (mode_info_seg < 0) goto error; |
| 212 | |
| 213 | memset(info, 0, sizeof(*info)); |
| 214 | dosmemput(info, sizeof(*info), mode_info_seg * 16L); |
| 215 | |
| 216 | memset(®s, 0, sizeof(regs)); |
| 217 | regs.x.ax = 0x4F01; |
| 218 | regs.x.cx = mode; |
| 219 | regs.x.di = 0; |
| 220 | regs.x.es = mode_info_seg; |
| 221 | (void) __dpmi_int(VIDEO_BIOS, ®s); |
| 222 | |
| 223 | if (regs.x.ax != 0x004F) goto error; |
| 224 | dosmemget(mode_info_seg * 16L, sizeof(*info), info); |
| 225 | if (!(info->ModeAttributes & 0x0001)) goto error; |
| 226 | |
| 227 | if (!(info->ModeAttributes & 0x0002)) { |
| 228 | /* Older VESA BIOS that did not return certain mode properties, but |
| 229 | that has fixed mode numbers; search the table to find the right |
| 230 | mode properties */ |
| 231 | |
| 232 | unsigned i; |
| 233 | |
| 234 | for (i = 0; i < SIZE(old_mode_table); ++i) { |
| 235 | if (mode == old_mode_table[i].mode) { |
| 236 | break; |
| 237 | } |
| 238 | } |
| 239 | if (i >= SIZE(old_mode_table)) goto error; |
| 240 | |
| 241 | info->XResolution = old_mode_table[i].XResolution; |
| 242 | info->YResolution = old_mode_table[i].YResolution; |
| 243 | info->NumberOfPlanes = 1; |
| 244 | info->BitsPerPixel = old_mode_table[i].BitsPerPixel; |
| 245 | info->NumberOfBanks = 1; |
| 246 | info->MemoryModel = old_mode_table[i].MemoryModel; |
| 247 | } |
| 248 | |
| 249 | __dpmi_free_dos_memory(mode_info_sel); |
| 250 | return TRUE; |
| 251 | |
| 252 | error: |
| 253 | if (mode_info_sel != -1) __dpmi_free_dos_memory(mode_info_sel); |
| 254 | return FALSE; |
| 255 | } |
| 256 | |
| 257 | static unsigned |
| 258 | vesa_map_frame_buffer(unsigned phys_addr, unsigned size) |
no outgoing calls
no test coverage detected