Save and restore VGA display memory between suspend and resume.
This commit is contained in:
parent
866c0e9fc2
commit
10109cda1b
@ -1465,22 +1465,30 @@ vesa_save_state(video_adapter_t *adp, void *p, size_t size)
|
|||||||
vm_offset_t buf;
|
vm_offset_t buf;
|
||||||
size_t bsize;
|
size_t bsize;
|
||||||
|
|
||||||
if (adp != vesa_adp || vesa_state_buf_size == 0)
|
if (adp != vesa_adp || (size == 0 && vesa_state_buf_size == 0))
|
||||||
return ((*prevvidsw->save_state)(adp, p, size));
|
return ((*prevvidsw->save_state)(adp, p, size));
|
||||||
|
|
||||||
|
bsize = offsetof(adp_state_t, regs) + vesa_state_buf_size;
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return (offsetof(adp_state_t, regs) + vesa_state_buf_size);
|
return (bsize);
|
||||||
if (size < (offsetof(adp_state_t, regs) + vesa_state_buf_size))
|
if (vesa_state_buf_size > 0 && size < bsize)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
buf = adp->va_buffer;
|
if (VESA_MODE(adp->va_mode) && adp->va_buffer != 0) {
|
||||||
if (buf != 0) {
|
buf = adp->va_buffer;
|
||||||
bsize = adp->va_buffer_size;
|
bsize = adp->va_buffer_size;
|
||||||
|
} else {
|
||||||
|
buf = adp->va_window;
|
||||||
|
bsize = adp->va_window_size;
|
||||||
|
}
|
||||||
|
if (buf != 0) {
|
||||||
vesa_vmem_buf = malloc(bsize, M_DEVBUF, M_NOWAIT);
|
vesa_vmem_buf = malloc(bsize, M_DEVBUF, M_NOWAIT);
|
||||||
if (vesa_vmem_buf != NULL)
|
if (vesa_vmem_buf != NULL)
|
||||||
bcopy((void *)buf, vesa_vmem_buf, bsize);
|
bcopy((void *)buf, vesa_vmem_buf, bsize);
|
||||||
} else
|
} else
|
||||||
vesa_vmem_buf = NULL;
|
vesa_vmem_buf = NULL;
|
||||||
|
if (vesa_state_buf_size == 0)
|
||||||
|
return ((*prevvidsw->save_state)(adp, p, size));
|
||||||
((adp_state_t *)p)->sig = V_STATE_SIG;
|
((adp_state_t *)p)->sig = V_STATE_SIG;
|
||||||
return (vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs));
|
return (vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs));
|
||||||
}
|
}
|
||||||
@ -1490,27 +1498,34 @@ vesa_load_state(video_adapter_t *adp, void *p)
|
|||||||
{
|
{
|
||||||
vm_offset_t buf;
|
vm_offset_t buf;
|
||||||
size_t bsize;
|
size_t bsize;
|
||||||
int mode;
|
int error, mode;
|
||||||
|
|
||||||
if (adp != vesa_adp)
|
if (adp != vesa_adp)
|
||||||
return ((*prevvidsw->load_state)(adp, p));
|
return ((*prevvidsw->load_state)(adp, p));
|
||||||
|
|
||||||
/* Try BIOS POST to restore a sane state. */
|
/* Try BIOS POST to restore a sane state. */
|
||||||
(void)vesa_bios_post();
|
(void)vesa_bios_post();
|
||||||
bsize = adp->va_buffer_size;
|
|
||||||
mode = adp->va_mode;
|
mode = adp->va_mode;
|
||||||
(void)vesa_set_mode(adp, adp->va_initial_mode);
|
error = vesa_set_mode(adp, adp->va_initial_mode);
|
||||||
if (mode != adp->va_initial_mode)
|
if (mode != adp->va_initial_mode)
|
||||||
(void)vesa_set_mode(adp, mode);
|
error = vesa_set_mode(adp, mode);
|
||||||
|
|
||||||
if (((adp_state_t *)p)->sig != V_STATE_SIG)
|
|
||||||
return ((*prevvidsw->load_state)(adp, p));
|
|
||||||
if (vesa_vmem_buf != NULL) {
|
if (vesa_vmem_buf != NULL) {
|
||||||
buf = adp->va_buffer;
|
if (error == 0) {
|
||||||
if (buf != 0)
|
if (VESA_MODE(mode) && adp->va_buffer != 0) {
|
||||||
bcopy(vesa_vmem_buf, (void *)buf, bsize);
|
buf = adp->va_buffer;
|
||||||
|
bsize = adp->va_buffer_size;
|
||||||
|
} else {
|
||||||
|
buf = adp->va_window;
|
||||||
|
bsize = adp->va_window_size;
|
||||||
|
}
|
||||||
|
if (buf != 0)
|
||||||
|
bcopy(vesa_vmem_buf, (void *)buf, bsize);
|
||||||
|
}
|
||||||
free(vesa_vmem_buf, M_DEVBUF);
|
free(vesa_vmem_buf, M_DEVBUF);
|
||||||
}
|
}
|
||||||
|
if (((adp_state_t *)p)->sig != V_STATE_SIG)
|
||||||
|
return ((*prevvidsw->load_state)(adp, p));
|
||||||
return (vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs));
|
return (vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user