MMAP尝试将缓冲区缓冲区加倍时失败 [英] MMAP fails in attempt to double buffer framebufer

查看:169
本文介绍了MMAP尝试将缓冲区缓冲区加倍时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ioctl(fd,FBIOPAN_DISPLAY ... 我的单个缓冲区代码可以正常工作

I am trying to implement a double buffer using ioctl(fd, FBIOPAN_DISPLAY... my single buffer code works fine

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

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

当我尝试通过使用screensize * 2来增加长度参数"时,mmap失败,并显示EINVAL.我认为它不喜欢我的length参数.

when I try to increase the "length parameter" by using screensize*2, the mmap fails with EINVAL. I think it doesn't like my length parameter.

单个缓冲区的屏幕大小为6,220,800,而双缓冲区的屏幕大小为12,441600.这是一个嵌入式系统,但具有1 Gig的RAM.

The screen size for a single buffer is 6,220,800 and for the double buffer is 12,441600. This is an embedded system but it has 1 Gig of RAM.

length参数是size_t,在这个系统上只有4个字节,这使我认为我可以使用的最大大小为4 Meg,但是6 Meg可以正常工作,所以我认为我缺少了一些非常简单的东西.有没有办法mmap大于size_t的缓冲区?

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. Is there a way to mmap a buffer larger than size_t?

推荐答案

手册页表示长度(第二个参数)的类型为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.

我建议您先映射第一部分,然后重新映射第二部分,如下所示

I would suggest you to just map the first part, and then remap the second part as shown in this SO Q&A.

关于EINVAL: 手册页中说明了以下内容:

Regarding the EINVAL: Following is stated in the man page:

EINVAL 我们不喜欢addr,length或offset(例如,它们太大或在页面边界上未对齐).

EINVAL We don't like addr, length, or offset (e.g., they are too large, or not aligned on a page boundary).

EINVAL (从Linux 2.6.12开始)长度为0.

EINVAL (since Linux 2.6.12) length was 0.

EINVAL 标志既不包含MAP_PRIVATE也不包含MAP_SHARED,也不包含这两个值.

EINVAL flags contained neither MAP_PRIVATE or MAP_SHARED, or contained both of these values.

您确定您对页面感兴趣吗?

Are you sure you are page alligned?

这篇关于MMAP尝试将缓冲区缓冲区加倍时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆