freeBSD device driver (use struct uio)


 
Thread Tools Search this Thread
Top Forums Programming freeBSD device driver (use struct uio)
# 1  
Old 07-31-2002
freeBSD device driver (use struct uio)

Hi, everybody

I have next problem...

1) My Example program code
void main()
{
int fd;
int len;
int buf[256];
fd=open("mydev", O_RDONLY);
lseek(fd, 0, SEEK_SET);
len=read(fd, buf, sizeof(buf));
}

2) My Example Driver code

static int mydev_read(dev_t dev, ?, ?, struct uio* uio)
{
int newbuf[10];
int lennewbuf;
lenbuf=uio->uio_resid; //this is size of programm buffer (see up sizeof(buf))
uio->uio_resid=10*sizeof(int); //I try set new size returned buffer
moveuio(?,?,?,?);//I copy data to program buffer
return 0;
}

3) And Question...
Why is len variable (in Program code) after call read() == sizeof(buf), but I set in Driver code uio_resid to value
10*sizeof(int)?

It's All Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Programming

Compiling virtual network adapter driver problem (net_device struct)

Hi, I found on linuxgazette.net/93/bhaskaran.html page very useful sample of virtual driver (not connected to real hardware). I try to compile it with no effect. So: I got fresh Ubuntu 9.10 (kernel 2.6.31-14) My source is saved in networkAdapter.c file in /usr/src/myModules directory. I... (21 Replies)
Discussion started by: Chrisdot
21 Replies

2. BSD

FreeBSD 7.2 and hme driver

Hi, I'm using a Sun's quad network card, which uses hme driver. Driver is built into kernel (puting if_hme_load="YES" in loader.conf doesn't solve the problem). Every time machine reboots, driver doesn't come up soon enough and the interfaces don't configure properly. For now, the only way to... (1 Reply)
Discussion started by: Luka
1 Replies

3. Programming

regarding device driver

Hi All, I have a device driver that uses UARTserial port to write/read to-from a device. That device driver is working fine on FC3 machine( kernel version 2.6.12)... Now I am switching to FC9 (kernel version 2.6.25.11-97).I have changed the interrupt flag SA_INTERRUPT to IRQF_DISABLED... (0 Replies)
Discussion started by: rajuprade
0 Replies

4. UNIX for Advanced & Expert Users

help regarding device driver

Hi All, I have a device driver that uses UARTserial port to write/read to-from a device. That device driver is working fine on FC3 machine( kernel version 2.6.12)... Now I am switching to FC9 (kernel version 2.6.25.11-97).I have changed the interrupt flag SA_INTERRUPT to IRQF_DISABLED... (0 Replies)
Discussion started by: rajuprade
0 Replies

5. Solaris

SUNWglmr -- rasctrl environment monitoring driver for i2c or SCSI device driver ?

I've been researching minimizeing Solaris 8 and found that on the web page http://www.sun.com/bigadmin/content/packagelist/s8u7PkgList/p2.html the package SUNWglmr is listed as "rasctrl environment monitoring driver for i2c, (Root) (32-bit)" while in the document "Solaris 8 minimize-updt1.pdf"... (1 Reply)
Discussion started by: roygoodwin
1 Replies
Login or Register to Ask a Question
STRUCT 
USB_DEVICE_DR(9) Host-Side Data Types and Macro STRUCT USB_DEVICE_DR(9) NAME
struct_usb_device_driver - identifies USB device driver to usbcore SYNOPSIS
struct usb_device_driver { const char * name; int (* probe) (struct usb_device *udev); void (* disconnect) (struct usb_device *udev); int (* suspend) (struct usb_device *udev, pm_message_t message); int (* resume) (struct usb_device *udev, pm_message_t message); struct usbdrv_wrap drvwrap; unsigned int supports_autosuspend:1; }; MEMBERS
name The driver name should be unique among USB drivers, and should normally be the same as the module name. probe Called to see if the driver is willing to manage a particular device. If it is, probe returns zero and uses dev_set_drvdata to associate driver-specific data with the device. If unwilling to manage the device, return a negative errno value. disconnect Called when the device is no longer accessible, usually because it has been (or is being) disconnected or the driver's module is being unloaded. suspend Called when the device is going to be suspended by the system. resume Called when the device is being resumed by the system. drvwrap Driver-model core structure wrapper. supports_autosuspend if set to 0, the USB core will not allow autosuspend for devices bound to this driver. DESCRIPTION
USB drivers must provide all the fields listed above except drvwrap. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 STRUCT USB_DEVICE_DR(9)