linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: 刘小双 <liuxs226@gmail.com>
To: linuxppc-embedded@ozlabs.org
Subject: system call ioctl() problem
Date: Wed, 26 Mar 2008 18:13:14 +0800	[thread overview]
Message-ID: <e81b2fb40803260313i14fe5a6dmc21513180466c454@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2008-03-26 10:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-26 10:13 刘小双 [this message]
2008-03-26 12:04 ` system call ioctl() problem Anatolij Gustschin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e81b2fb40803260313i14fe5a6dmc21513180466c454@mail.gmail.com \
    --to=liuxs226@gmail.com \
    --cc=linuxppc-embedded@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).