简体   繁体   English

MMAP尝试将缓冲区缓冲区加倍时失败

[英]MMAP fails in attempt to double buffer framebufer

I am trying to implement a double buffer using ioctl(fd, FBIOPAN_DISPLAY... my single buffer code works fine 我正在尝试使用ioctl(fd,FBIOPAN_DISPLAY ...

screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);

when I try to increase the "length parameter" by using screensize*2, the mmap fails with EINVAL . 当我尝试通过使用screensize * 2来增加“长度参数”时, mmap失败并显示EINVAL I think it doesn't like my length parameter. 我认为它不喜欢我的length参数。

The screen size for a single buffer is 6,220,800 and for the double buffer is 12,441600. 单缓冲区的屏幕大小为6,220,800,双缓冲区的屏幕大小为12,441600。 This is an embedded system but it has 1 Gig of RAM. 这是一个嵌入式系统,但具有1 Gig的RAM。

The length parameter is size_t which on this system is only 4 bytes which would make me think that the max size I could use would be 4 Meg, yet 6 Meg works fine so I think I am missing something really simple. 长度参数是size_t,在这个系统上只有4个字节,这使我认为我可以使用的最大大小为4 Meg,但是6 Meg可以正常工作,所以我认为我缺少了一些非常简单的东西。 Is there a way to mmap a buffer larger than size_t? 有没有办法mmap大于size_t的缓冲区?

The man page says that length (the 2nd parameter) is of type size_t , so I don't think you are safe to pass a larger type. 手册页指出length(第二个参数)的类型为size_t ,因此我认为传递较大的类型是不安全的。

I would suggest you to just map the first part, and then remap the second part as shown in this SO Q&A . 我建议您只映射第一部分,然后重新映射第二部分,如本SO Q&A所示

Regarding the EINVAL : Following is stated in the man page: 关于EINVAL :手册页中说明了以下内容:

EINVAL We don't like addr, length, or offset (eg, they are too large, or not aligned on a page boundary). EINVAL我们不喜欢addr,length或offset(例如,它们太大或在页面边界上未对齐)。

EINVAL (since Linux 2.6.12) length was 0. EINVAL(从Linux 2.6.12开始)的长度为0。

EINVAL flags contained neither MAP_PRIVATE or MAP_SHARED, or contained both of these values. EINVAL标志既不包含MAP_PRIVATE也不包含MAP_SHARED,或者包含这两个值。

Are you sure you are page alligned? 您确定您是页面推荐人吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM