Print phys_base_ptr in testvbe.
[v86d.git] / testvbe.c
blobb9e1a1498a404b09f5555c7a64649e60f475e441
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <errno.h>
6 #include <time.h>
7 #include <fcntl.h>
9 #include "v86.h"
10 #include "testvbe.h"
12 #define reg16(reg) (reg & 0xffff)
13 #define failed(tsk) (reg16(tsk.regs.eax) != 0x004f)
15 int main(int argc, char *argv[])
17 struct uvesafb_task tsk;
18 struct vbe_ib ib;
19 u16 *s;
20 u8 *t;
22 if (v86_init())
23 return -1;
25 memset(&tsk, 0, sizeof(tsk));
26 tsk.regs.eax = 0x4f00;
27 tsk.flags = TF_VBEIB;
28 tsk.buf_len = sizeof(ib);
29 strncpy((char*)&ib.vbe_signature, "VBE2", 4);
31 if (v86_task(&tsk, (u8*)&ib))
32 return -1;
34 if (failed(tsk)) {
35 fprintf(stderr, "Getting VBE Info Block failed with eax = %.4x\n",
36 reg16(tsk.regs.eax));
37 return -1;
40 t = (u8*)&ib;
42 printf("VBE Version: %x.%.2x\n", ((ib.vbe_version & 0xf00) >> 8), (ib.vbe_version & 0xff));
43 printf("OEM String: %s\n", ib.oem_string_ptr + t);
44 printf("OEM Vendor Name: %s\n", ib.oem_vendor_name_ptr + t);
45 printf("OEM Prod. Name: %s\n", ib.oem_product_name_ptr + t);
46 printf("OEM Prod. Rev: %s\n", ib.oem_product_rev_ptr + t);
48 printf("\n%-6s %-6s mode\n", "ID", "attr");
49 printf("---------------------------\n");
51 for (s = t + ib.mode_list_ptr; *s != 0xffff; s++) {
52 struct vbe_mode_ib mib;
54 memset(&tsk, 0, sizeof(tsk));
55 tsk.regs.eax = 0x4f01;
56 tsk.regs.ecx = *s;
57 tsk.flags = TF_BUF_RET | TF_BUF_ESDI;
58 tsk.buf_len = sizeof(mib);
60 if (v86_task(&tsk, (u8*)&mib))
61 return -1;
63 if (failed(tsk)) {
64 fprintf(stderr, "Getting Mode Info Block for mode %.4x "
65 "failed with eax = %.4x\n", *s, reg16(tsk.regs.eax));
66 return -1;
69 printf("%-6.4x %-6.4x %dx%d-%d %x\n", *s, mib.mode_attr,
70 mib.x_res, mib.y_res, mib.bits_per_pixel, mib.phys_base_ptr);
73 v86_cleanup();
75 return 0;