* system call ioctl() problem
@ 2008-03-26 10:13 刘小双
2008-03-26 12:04 ` Anatolij Gustschin
0 siblings, 1 reply; 2+ messages in thread
From: 刘小双 @ 2008-03-26 10:13 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 4270 bytes --]
hi,all
Here is a question I didn't make out, i wonder if anybody can figure it
out. My platform is mpc8540 with graphics chip Fujitsu MB86296, my kernel
version is 2.6.12.6. I'm about to write a gfxdriver so DirectFB can call
this gfxdriver to make MB86296 do some drawing things. I wrote a program to
test if the MB86296 drawing registers can be read and written. here is some
part of the pragram:
/* fbtest.c */
int fb; //descriptor of framebuffer device
unsigned long mmio;
fb = open("/dev/fb",O_RDWR);
mmio = (unsigned long
*)mmap(0,0x2000000,PROT_READ|PROT_WRITE,MAP_SHARED,fb,0);
unsigned long ntest=0x5f5f5f5f;
*( unsigned long
*)(mmio+GDC_DRAW_BASE-GDC_HOST_BASE+GDC_REG_BACKGROUND_COLOR)=ntest; // set
value in Background Color register with ntest
printf("*( unsigned long
*)(mmio+GDC_DRAW_BASE-GDC_HOST_BASE+GDC_REG_BACKGROUND_COLOR)=%x\n",*(unsigned
long *)(mmio+GDC_DRAW_BASE-GDC_HOST_BASE+GDC_REG_BACKGROUND_COLOR));
msync((void *)mmio,0x2000000,MS_SYNC);
unsigned long ioctlReadRes[2];
ioctlReadRes[0]=GDC_REG_BACKGROUND_COLOR; //Background Color register
offset address from drawing register bsae address
printf("ioctlReadRes = %x\n",ioctlReadRes);
ioctl(fb,FBIO_MB86290_READ_DRAW_REG,ioctlReadRes); // read what is in
Background Color register,put it in ioctlReadRes[1]
printf("ioctlReadRes[0]=%x,ioctlReadRes[1]=%x\n",ioctlReadRes[0],ioctlReadRes[1]);
Then I use debug tool strace to trace exe of this program,here is the
result:
bash-3.00# strace ./fbtest
execve("./fbtest", ["./fbtest"], [/* 18 vars */]) = 0
uname({sys="Linux", node="super85xx", ...}) = 0
brk(0) = 0x10011000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x30017000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or
directory)
open("/mnt/gtkdfb/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or
directory)
stat64("/mnt/gtkdfb/lib/tls", 0x7fe46fb8) = -1 ENOENT (No such file or
directory)
open("/mnt/gtkdfb/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or
directory)
stat64("/mnt/gtkdfb/lib", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=12946, ...}) = 0
mmap(NULL, 12946, PROT_READ, MAP_PRIVATE, 3, 0) = 0x30018000
close(3) = 0
open("/lib/tls/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\307"..., 512)
=
512
fstat64(3, {st_mode=S_IFREG|0777, st_size=1303116, ...}) = 0
mmap(0xfeab000, 1328676, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0)
= 0xfeab000
mprotect(0xffd8000, 95780, PROT_NONE) = 0
mmap(0xffe7000, 24576, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12c000) = 0xffe7000
mmap(0xffed000, 9764, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffed000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x3001c000
mprotect(0xffe7000, 8192, PROT_READ) = 0
mprotect(0x30026000, 4096, PROT_READ) = 0
munmap(0x30018000, 12946) = 0
open("/dev/fb", O_RDWR) = 3
mmap(NULL, 33554432, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x30028000
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(5, 1), ...}) = 0
ioctl(1, TCGETS or TCGETS, {B115200 opost isig icanon echo ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x32028000
write(1, "*( unsigned long *)(mmio+GDC_DRA"..., 74*( unsigned long
*)(mmio+GDC_DRAW_BASE+GDC_REG_BACKGROUND_COLOR)=5f5f5f5f
) = 74
msync(0x30028000, 33554432, MS_SYNC) = 0
write(1, "ioctlReadRes = 7fe47914\n", 24ioctlReadRes = 7fe47914
) = 24
ioctl(3, 0x20004d2f, 0x7fe47914) = -1 EINVAL (Invalid argument)
write(1, "ioctlReadRes[0]=484,ioctlReadRes"...,
45ioctlReadRes[0]=484,ioctlReadRes[1]=30026f58
) = 45
munmap(0x32028000, 4096) = 0
exit_group(45) = ?
from above, I think the problem is in ioctl call, which shows "EINVAL
(Invalid argument)", so I added printk() to xx_ioctl() in fb driver, and it
showed xx_ioctl() was not called .Then I checked xx_ioctl() was right.
where is my problem? how to call ioctl() right??
Thanks
[-- Attachment #2: Type: text/html, Size: 5774 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: system call ioctl() problem
2008-03-26 10:13 system call ioctl() problem 刘小双
@ 2008-03-26 12:04 ` Anatolij Gustschin
0 siblings, 0 replies; 2+ messages in thread
From: Anatolij Gustschin @ 2008-03-26 12:04 UTC (permalink / raw)
To: ???; +Cc: linuxppc-embedded
Hello,
??? wrote:
> hi,all
> Here is a question I didn't make out, i wonder if anybody can figure
> it out. My platform is mpc8540 with graphics chip Fujitsu MB86296, my
> kernel version is 2.6.12.6 <http://2.6.12.6>. I'm about to write a
> gfxdriver so DirectFB can call this gfxdriver to make MB86296 do some
> drawing things. I wrote a program to test if the MB86296 drawing
> registers can be read and written. here is some part of the pragram:
[snip]
> ioctl(3, 0x20004d2f, 0x7fe47914) = -1 EINVAL (Invalid argument)
> write(1, "ioctlReadRes[0]=484,ioctlReadRes"...,
> 45ioctlReadRes[0]=484,ioctlReadRes[1]=30026f58
> ) = 45
> munmap(0x32028000, 4096) = 0
> exit_group(45) = ?
>
>
> from above, I think the problem is in ioctl call, which shows "EINVAL
> (Invalid argument)", so I added printk() to xx_ioctl() in fb driver, and
> it showed xx_ioctl() was not called .Then I checked xx_ioctl() was
> right. where is my problem? how to call ioctl() right??
probably, your problem is missing mb86290-driver specific ioctl
hook in the "mb86290fb_ops" structure definition in
drivers/video/mb86290/mb86290fb.c.
Ensure that this structure definition contains something like this:
.fb_ioctl = mb86290fb_ioctl,
Without this assignment only generic framebuffer ioctl will be called,
maybe therefore you can not see driver specific ioctl call. Generic
ioctl "doesn't understand" FBIO_MB86290_READ_DRAW_REG argument and
simply returns -EINVAL.
Best regards,
Anatolij
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-26 12:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-26 10:13 system call ioctl() problem 刘小双
2008-03-26 12:04 ` Anatolij Gustschin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).