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 
CCW_DRIVER(9) The ccw bus STRUCT CCW_DRIVER(9) NAME
struct_ccw_driver - device driver for channel attached devices SYNOPSIS
struct ccw_driver { struct ccw_device_id * ids; int (* probe) (struct ccw_device *); void (* remove) (struct ccw_device *); int (* set_online) (struct ccw_device *); int (* set_offline) (struct ccw_device *); int (* notify) (struct ccw_device *, int); void (* path_event) (struct ccw_device *, int *); void (* shutdown) (struct ccw_device *); int (* prepare) (struct ccw_device *); void (* complete) (struct ccw_device *); int (* freeze) (struct ccw_device *); int (* thaw) (struct ccw_device *); int (* restore) (struct ccw_device *); enum uc_todo (* uc_handler) (struct ccw_device *, struct irb *); struct device_driver driver; enum interruption_class int_class; }; MEMBERS
ids ids supported by this driver probe function called on probe remove function called on remove set_online called when setting device online set_offline called when setting device offline notify notify driver of device state changes path_event notify driver of channel path events shutdown called at device shutdown prepare prepare for pm state transition complete undo work done in prepare freeze callback for freezing during hibernation snapshotting thaw undo work done in freeze restore callback for restoring after hibernation uc_handler callback for unit check handler driver embedded device driver structure int_class interruption class to use for accounting interrupts AUTHOR
Cornelia Huck <cornelia.huck@de.ibm.com> Author. COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 STRUCT CCW_DRIVER(9)