From owner-freebsd-drivers@FreeBSD.ORG Wed Sep 6 00:01:17 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6604A16A4DE for ; Wed, 6 Sep 2006 00:01:17 +0000 (UTC) (envelope-from lydianconcepts@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.234]) by mx1.FreeBSD.org (Postfix) with ESMTP id DE25B43D45 for ; Wed, 6 Sep 2006 00:01:16 +0000 (GMT) (envelope-from lydianconcepts@gmail.com) Received: by wr-out-0506.google.com with SMTP id 68so719274wri for ; Tue, 05 Sep 2006 17:01:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=BIJpWA3g/JzvGF719WH7AGiimOK1yFvtWVQ1YIg0JauIaAdXAZpoxqdePYf+0Fzgs22ji2nGaGSt1xJRB67us9BQWcmBpI1eKD7K4+CjgQ/76NIJv38XMR/+3dym6jxRIrZjvVJUvnTOdM0iZr1yBWHWOiZfbOBYCsD0/XVK7/I= Received: by 10.90.120.13 with SMTP id s13mr2022368agc; Tue, 05 Sep 2006 17:01:16 -0700 (PDT) Received: by 10.90.70.14 with HTTP; Tue, 5 Sep 2006 17:01:16 -0700 (PDT) Message-ID: <7579f7fb0609051701u6a863428m7ec8d488ac7a8047@mail.gmail.com> Date: Tue, 5 Sep 2006 17:01:16 -0700 From: "Matthew Jacob" To: "Kristis Makris" In-Reply-To: <1157500005.3414.92.camel@syd.mkgnu.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1157500005.3414.92.camel@syd.mkgnu.net> Cc: freebsd-drivers@freebsd.org Subject: Re: ioctl: uiomove, copyin, copyout X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Sep 2006 00:01:17 -0000 > > 1) Finding the equivalent of the Linux copy_to_user and copy_from_user > routines. Are those copyin, and copyout ? Yes. > > > 2) Getting the ioctl operation to work. When issuing an ioctl from > userspace I get: > My guess is that your ioctl codes are being interpred. Check the format of your ioctl code to make sure that it follows BSD rules for getting passed to your driver w/o interpretation. Linux IIRC follows SYSV ioctl semantics, which means that the ioctl is never interpreted by the kernel above the driver. BSD ioctls semantics looks at the type nibble to decide whether the ioctl parameters can be copied directly to the kernel and presented to driver as a pointer you can just de-reference rather than a pointer you have to perform copyin on. Check sys/ioccom.h. > # dynamos_control -o 9 > ioctl error for command 9: Inappropriate ioctl for device > errno is 25 > it's an ENOTTY > > ... while in the driver I have: > > static d_read_t dynreplace_file_operations_read; > static d_ioctl_t dynreplace_file_operations_ioctl; > > static struct cdevsw dynreplace_cdevsw = { > .d_version = D_VERSION, > .d_open = dynreplace_file_operations_open, > .d_close = dynreplace_file_operations_release, > .d_read = dynreplace_file_operations_read, > .d_ioctl = dynreplace_file_operations_ioctl, > .d_name = MODULE_NAME_STR, > }; > > > int dynreplace_file_operations_ioctl(struct cdev *dev, u_long cmd, > caddr_t data, int flags, struct thread *td) > { > print( "ioctl - MAIN\n"); > return 0; > } > > ... the _read operation works as expected, but I don't even see the > print statement from _ioctl. > > > The ioctl(2) manpage reads: > > [ENOTTY] The d argument is not associated with a > character special device. > > This can't be true since the read operation works, and: > > # ls -lrta /dev/dynamos > crwx------ 1 root wheel 0, 95 Sep 2 16:31 /dev/dynamos > > and... > > [ENOTTY] The specified request does not apply to the kind > of object that the descriptor d references. > > Is this last part somehow enforced by the kernel ? > > I know I have an uncommon build process, since the driver is built for > multiple OSs, but if I can get the read operation to work why would > ioctl be so difficult ? > > Am I missing something ? > > > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org" >