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 
UIO_INFO(9) Device drivers infrastructure STRUCT UIO_INFO(9) NAME
struct_uio_info - UIO device capabilities SYNOPSIS
struct uio_info { struct uio_device * uio_dev; const char * name; const char * version; struct uio_mem mem[MAX_UIO_MAPS]; struct uio_port port[MAX_UIO_PORT_REGIONS]; long irq; unsigned long irq_flags; void * priv; irqreturn_t (* handler) (int irq, struct uio_info *dev_info); int (* mmap) (struct uio_info *info, struct vm_area_struct *vma); int (* open) (struct uio_info *info, struct inode *inode); int (* release) (struct uio_info *info, struct inode *inode); int (* irqcontrol) (struct uio_info *info, s32 irq_on); }; MEMBERS
uio_dev the UIO device this info belongs to name device name version device driver version mem[MAX_UIO_MAPS] list of mappable memory regions, size==0 for end of list port[MAX_UIO_PORT_REGIONS] list of port regions, size==0 for end of list irq interrupt number or UIO_IRQ_CUSTOM irq_flags flags for request_irq priv optional private data handler the device's irq handler mmap mmap operation for this uio device open open operation for this uio device release release operation for this uio device irqcontrol disable/enable irqs when 0/1 is written to /dev/uioX COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 STRUCT UIO_INFO(9)