lkml.org 
[lkml]   [1999]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectHELP!! polling driver through ioctl
Date
Hi

In order to monitor a device driver, i ve written a little TCL app
with a C interface wich performs ioctl to the driver (background loop
with a 1 s period)

after several hours of monitoring my system goes mad , emacs gcc...
recive signal 11 ...
so I thinj the ioctl mecanism must be wrong


here is the implementation

user call ( get a info buffer filled by the driver each sec)

// background process
//
int updateLed(clientData)
ClientData clientData;
{

int temp,i,j,k;
struct interface *pIod;(it's only some unsigned long
parameters (ulong Param1, ulong Param2 ...)

unsigned long *ThisCommonArea,*p;
int state
[NUM_CHANNELS_PER_GROUP];
int
CommonAreaSize,protocol;
int
mLy1State,mLy2State,m_SignallingProtocol;
int
numdevice,number_of_pump;


pIod= (struct interface* )malloc(sizeof(struct interface));
CommonAreaSize= NEEDED_BUFFER_SIZE ;(40 bytes)

// common area between kernel and user space (filled by
driver)
ThisCommonArea=(unsigned long*)malloc(CommonAreaSize);
//param1 is group
//param 2 is common memory area
pIod->Param1 = group;
pIod->Param2 = (unsigned long)ThisCommonArea;
pIod->Param3 = CommonAreaSize;
temp=ioctl(fd, READ_INFO_FOR_MONITOR_PANEL ,pIod);

// now the buffer must be filled...

p=ThisCommonArea;
//
// first elt is protocol
//
protocol=*p;
m_SignallingProtocol=*p;
p++;
mLy1State=*p;
//
// update ly1 led
//
UpdateLy1(mLy1State);
p++;
mLy2State=*p;
//
// update ly2 led
//
UpdateLy2(mLy2State);
p++;
.........

and then

free(ThisCommonArea);
free(pIod);

//
// retrig timer
//
Tcl_CreateTimerHandler(1000,(Tcl_TimerProc*)updateLed,NULL);
return TCL_OK;
}


OK and now the kernel side

int ioctl.. ( )
{
..
case READ_INFO_FOR_MONITOR_PANEL:
//
// param 1 is group id
// param 2 is common memory area
// Param 3 is CommonAreaSize;

pbd= (struct interface* )kmalloc(sizeof(struct
interface),GFP_KERNEL);

memcpy_fromfs(pbd,(void*)arg,sizeof(struct
interface));

if ( (pbd->Param1 >= ThisAdapter->NumberOfGroups) )
{
pbd->Error=BACKDOOR_FAIL_SIZETOOSMALL;
break;
}

p = (DWORD *)(pbd->Param2);

//err= verify_area(VERIFY_WRITE, (void *)p, pbd-
>Param3);

put_user(ThisAdapter->SignallingProtocol[ pbd->Param1
],p++);

// Layer1 Status
put_user((DWORD)ThisAdapter->Bt8370Block[pbd-
>Param1].Status,p++);

...
kfree(pbd);
return OK;
..


does anyone see something wrong ???
Why is emacs or gcc crashing after this ??

thanks





______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.035 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site