前段时间弄关机图片,即直接操作wince的显示缓冲区,往里面放一个关机或休眠画面的二进制数据。发现有两种方法,如下(硬件平台 S3C2440):
第一种方法:
#define IMAGE_FRAMEBUFFER_UA_BASE 0xA0100000 //显示缓冲区虚拟地址
SetKMode(TRUE); //进入内核模式。
memcpy((void *)(IMAGE_FRAMEBUFFER_UA_BASE , (void *)(buffer_rgb) , Size);
SetKMode(FALSE);
第二种方法:
直接操作framebuffer。参照LCD驱动的做法。做完下列操作即可以操作framebuffer:
#define IMAGE_FRAMEBUFFER_DMA_BASE 0x30100000 //显存物理地址
DWORD m_VirtualFrameBuffer;
ULONG fbSize;
HANDLE m_hVFBMapping;
fbSize = 0x100000;
// Use CreateFileMapping/MapViewOfFile to guarantee the VirtualFrameBuffer
// pointer is allocated in shared memory.
m_hVFBMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, fbSize, NULL);
if (m_hVFBMapping != NULL) {
m_VirtualFrameBuffer = (DWORD)MapViewOfFile(m_hVFBMapping, FILE_MAP_WRITE, 0, 0, 0);
} else {
m_VirtualFrameBuffer = NULL;
}
if (VirtualCopy((void *)m_VirtualFrameBuffer, (void *)(IMAGE_FRAMEBUFFER_DMA_BASE >> 8), fbSize, PAGE_READWRITE | PAGE_NOCACHE | PAGE_PHYSICAL)) {
CeSetMemoryAttributes ((void *)m_VirtualFrameBuffer, (void *)(IMAGE_FRAMEBUFFER_DMA_BASE >> 8), fbSize, PAGE_WRITECOMBINE);
}
memset ((void*)m_VirtualFrameBuffer, 0xA0, fbSize);