4 #define addr(t) (((t & 0xffff0000) >> 12) + (t & 0x0000ffff))
6 #define vbeib_get_string(name) \
11 ib->name = t - lbuf; \
12 l = strnlen((char*)buf + ib->name, bufend-t); \
13 if (buf[ib->name + l] != 0) \
14 buf[ib->name + l] = 0; \
17 } else if (t > 0xa0000 && fsize > 0) { \
18 strncpy((char*)cbuf, vptr(t), fsize); \
19 l = strnlen((char*)cbuf, fsize); \
22 ib->name = tsk->buf_len - fsize; \
33 int v86_task(struct uvesafb_task
*tsk
, u8
*buf
)
37 ulog(LOG_DEBUG
, "task flags: 0x%02x\n", tsk
->flags
);
38 ulog(LOG_DEBUG
, "EAX=0x%08x EBX=0x%08x ECX=0x%08x EDX=0x%08x\n",
39 tsk
->regs
.eax
, tsk
->regs
.ebx
, tsk
->regs
.ecx
, tsk
->regs
.edx
);
40 ulog(LOG_DEBUG
, "ESP=0x%08x EBP=0x%08x ESI=0x%08x EDI=0x%08x\n",
41 tsk
->regs
.esp
, tsk
->regs
.ebp
, tsk
->regs
.esi
, tsk
->regs
.edi
);
43 /* Get the VBE Info Block */
44 if (tsk
->flags
& TF_VBEIB
) {
51 lbuf
= v86_mem_alloc(tsk
->buf_len
);
53 ulog(LOG_ERR
, "Memory allocation for a VBE IB buffer failed.");
56 memcpy(vptr(lbuf
), buf
, tsk
->buf_len
);
57 tsk
->regs
.es
= lbuf
>> 4;
58 tsk
->regs
.edi
= 0x0000;
60 if (v86_int(0x10, &tsk
->regs
) || (tsk
->regs
.eax
& 0xffff) != 0x004f)
63 ib
= (struct vbe_ib
*)buf
;
64 bufend
= lbuf
+ sizeof(*ib
);
65 memcpy(buf
, vptr(lbuf
), tsk
->buf_len
);
67 /* The original VBE Info Block is 512 bytes long. */
68 fsize
= tsk
->buf_len
- 512;
71 t
= addr(ib
->mode_list_ptr
);
72 /* Mode list is in the buffer, we're good. */
74 ulog(LOG_DEBUG
, "The mode list is in the buffer at %.8x.", t
);
75 ib
->mode_list_ptr
= t
- lbuf
;
76 td
= (u16
*) (buf
+ ib
->mode_list_ptr
);
78 while (fsize
> 2 && *td
!= 0xffff) {
89 /* Mode list is in the ROM. We copy as much of it as we can
90 * to the task buffer. */
91 } else if (t
> 0xa0000) {
94 ulog(LOG_DEBUG
, "The mode list is in the Video ROM at %.8x", t
);
98 while (fsize
> 2 && (tmp
= v_rdw(t
)) != 0xffff) {
106 ib
->mode_list_ptr
= 512;
111 /* Mode list is somewhere else. We're seriously screwed. */
113 ulog(LOG_ERR
, "Can't retrieve mode list from %x\n", t
);
114 ib
->mode_list_ptr
= 0;
117 vbeib_get_string(oem_string_ptr
);
118 vbeib_get_string(oem_vendor_name_ptr
);
119 vbeib_get_string(oem_product_name_ptr
);
120 vbeib_get_string(oem_product_rev_ptr
);
125 lbuf
= v86_mem_alloc(tsk
->buf_len
);
127 ulog(LOG_ERR
, "Memory allocation for a v86d task buffer failed.");
130 memcpy(vptr(lbuf
), buf
, tsk
->buf_len
);
133 if (tsk
->flags
& TF_BUF_ESDI
) {
134 tsk
->regs
.es
= lbuf
>> 4;
135 tsk
->regs
.edi
= 0x0000;
138 if (tsk
->flags
& TF_BUF_ESBX
) {
139 tsk
->regs
.es
= lbuf
>> 4;
140 tsk
->regs
.ebx
= 0x0000;
143 if (v86_int(0x10, &tsk
->regs
) || (tsk
->regs
.eax
& 0xffff) != 0x004f)
146 if (tsk
->buf_len
&& tsk
->flags
& TF_BUF_RET
) {
147 memcpy(buf
, vptr(lbuf
), tsk
->buf_len
);