LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-10-2012, 01:14 AM   #1
siashero
LQ Newbie
 
Registered: May 2012
Posts: 3

Rep: Reputation: Disabled
Red face why the ioctl return an error bad address when i try to ctrol an pci device?


hello,i recently debug an pci device,but when i try to use to syscall to read the config register i got an error bad address from the ioctl.
the code is below:
fd: fd=open("/dev/Plx/Plx9054",O_RDWR|O_NONBLOCK);
this code works well.
unsigned long args=1;
ioctl: i=ioctl(fd,PLX_IOCTL_CHIP_TYPE_GET,args);
the cmd PLX_IOCTL_CHIP_TYPE_GET is used to get the chip type of the pci device.It's defined in the PlxIoctl.h.(I used the PLX SDK to compile my pci driver)The args I don't know how to use it.so here i give it an one.But the syscall ioctl return an error bad address.what's wrong?
i trace the function ioctl defined in the pci drive.here is the code:
PLX_RET_IOCTL
Dispatch_IoControl(
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
struct inode *inode,
#endif
struct file *filp,
unsigned int cmd,
unsigned long args
)
{ int status;
VOID *pOwner;
PLX_PARAMS IoBuffer;
PLX_PARAMS *pIoBuffer;
DEVICE_EXTENSION *pdx;


DebugPrintf_Cont(("\n"));

// Get the device extension
if (iminor(filp->f_dentry->d_inode) == PLX_MNGMT_INTERFACE)
{
// Management interface node only supports some IOCTLS
pdx = NULL;
}
else
{
pdx = ((DEVICE_OBJECT*)(filp->private_data))->DeviceExtension;
}

// Copy the I/O Control message from user space
status =
copy_from_user(
&IoBuffer,
(PLX_PARAMS*)args,
sizeof(PLX_PARAMS)
);

if (status != 0)
{
ErrorPrintf((
"ERROR - Unable to copy user I/O message data\n"
));
}

of coure i also has been given an error unable to copy user I/O message data from the debug monitor.
But why? can any body help me ?
 
Old 05-11-2012, 06:22 AM   #2
emntech
LQ Newbie
 
Registered: May 2012
Posts: 8

Rep: Reputation: Disabled
You need to create an object of type PLX_PARAMS and send its address as third argument to the ioctl, basically like this;

PLX_PARAMS args;

i=ioctl(fd,PLX_IOCTL_CHIP_TYPE_GET, &args);

Once the ioctl function is returned you will have your data in the args.
 
1 members found this post helpful.
Old 05-13-2012, 06:05 AM   #3
siashero
LQ Newbie
 
Registered: May 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Wink

Quote:
Originally Posted by emntech View Post
You need to create an object of type PLX_PARAMS and send its address as third argument to the ioctl, basically like this;

PLX_PARAMS args;

i=ioctl(fd,PLX_IOCTL_CHIP_TYPE_GET, &args);

Once the ioctl function is returned you will have your data in the args.
ok,thanks.i will try it later.
 
Old 05-13-2012, 08:53 PM   #4
siashero
LQ Newbie
 
Registered: May 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by emntech View Post
You need to create an object of type PLX_PARAMS and send its address as third argument to the ioctl, basically like this;

PLX_PARAMS args;

i=ioctl(fd,PLX_IOCTL_CHIP_TYPE_GET, &args);

Once the ioctl function is returned you will have your data in the args.
i havd tried it.But it does not work,and returns an kernel panic.can andybody have ideas?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Buffer I/O error on device dm-2, Failed to load Selinux policy, Bad address Marcolino Linux - Newbie 3 12-24-2012 11:53 PM
[SOLVED] Error no 25: Inappropriate ioctl for device for RTC cruiser Linux - Software 1 10-16-2011 11:13 PM
[SOLVED] Return error from ioctl command wybourn Programming 2 07-22-2010 02:22 AM
ioctl -> Bad address keros Programming 4 02-19-2009 02:51 AM
ioctl: LOOP_CLR_FD: No such device or address newbie2007 Linux - Newbie 1 01-27-2008 11:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration