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
RADIO(9)						   BSD Kernel Developer's Manual						  RADIO(9)

NAME
radio -- interface between low and high level radio drivers DESCRIPTION
The radio device driver is divided into a high level, hardware independent layer, and a low level hardware dependent layer. The interface between these is the radio_hw_if structure. struct radio_hw_if { int (*open)(void *, int, int, struct lwp *); int (*close)(void *, int, int, struct lwp *); int (*get_info)(void *, struct radio_info *); int (*set_info)(void *, struct radio_info *); int (*search)(void *, int); }; The high level radio driver attaches to the low level driver when the latter calls radio_attach_mi. This call should be void radio_attach_mi(rhwp, hdlp, dev) struct radio_hw_if *rhwp; void *hdlp; struct device *dev; The radio_hw_if struct is as shown above. The hdlp argument is a handle to some low level data structure. It is sent as the first argument to all the functions in radio_hw_if when the high level driver calls them. dev is the device struct for the hardware device. The fields of radio_hw_if are described in some more detail below. int open (void *, int flags, int fmt, struct lwp *p); Optional. Is called when the radio device is opened. Returns 0 on success, otherwise an error code. int close (void *, int flags, int fmt, struct lwp *p); Optional. Is called when the radio device is closed. Returns 0 on success, otherwise an error code. int get_info (void *, struct radio_info *); Fill the radio_info struct. Returns 0 on success, otherwise an error code. int set_info (void *, struct radio_info *); Set values from the radio_info struct. Returns 0 on success, otherwise an error code. int search (void *, int); Returns 0 on success, otherwise an error code. SEE ALSO
radio(4) BSD
December 20, 2005 BSD