From owner-freebsd-drivers@FreeBSD.ORG Wed Dec 19 16:06:09 2007 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 379FF16A477 for ; Wed, 19 Dec 2007 16:06:09 +0000 (UTC) (envelope-from walsimou@walsimou.com) Received: from dns.walsimou.com (walscop001.walsimou.com [82.228.201.70]) by mx1.freebsd.org (Postfix) with ESMTP id B7C0D13C4D9 for ; Wed, 19 Dec 2007 16:06:08 +0000 (UTC) (envelope-from walsimou@walsimou.com) Received: from [192.168.1.236] ([192.168.1.236]) (SSL: TLSv1/SSLv3,256bits,AES256-SHA) by dns.walsimou.com with esmtp; Wed, 19 Dec 2007 16:57:08 +0100 id 00078D7A.0000000047693F54.00002C88 Message-ID: <47693F0A.3000304@walsimou.com> Date: Wed, 19 Dec 2007 16:55:54 +0100 From: Gaye Abdoulaye Walsimou User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: write/read data to/from parallel port 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, 19 Dec 2007 16:06:09 -0000 Hello List, I am trying to learn driver writing under FreeBSD. My first goal is reading/writing data through parallel port (0x378). here is some dmesg output ppc0: at port 0x378-0x37f irq 7 on isa0 ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/16 bytes threshold Do I have to read all doc about ISA devices in the arch-handbook, because there isn't any other way to do it? Here is what I began to do (inspired by the arch-handbook, I can kldload and kldunload) : #include #include #include /* uprintf */ #include #include /* defines used in kernel.h */ #include /* types used in module initialization */ #include /* cdevsw struct */ #include /* uio struct */ #include /* Function prototypes */ static d_open_t mpp0_open; static d_close_t mpp0_close; static d_read_t mpp0_read; static d_write_t mpp0_write; /* Character device entry points */ static struct cdevsw mpp0_cdevsw = { .d_version = D_VERSION, .d_open = mpp0_open, .d_close = mpp0_close, .d_read = mpp0_read, .d_write = mpp0_write, .d_name = "mpp0", }; /* vars */ static struct cdev *mpp0_dev; /* * This function is called by the kld[un]load(2) system calls to * determine what actions to take when a module is loaded or unloaded. */ static int mpp0_loader(struct module *m, int what, void *arg) { int err = 0; switch (what) { case MOD_LOAD: /* kldload */ mpp0_dev = make_dev(&mpp0_cdevsw, 0, UID_ROOT, GID_WHEEL, 0666, "mpp0"); uprintf("mpp0 device loaded.\n"); break; case MOD_UNLOAD: /* kldunload*/ destroy_dev(mpp0_dev); uprintf("mpp0 device unloaded.\n"); break; default: err = EOPNOTSUPP; break; } return(err); } static int mpp0_open(struct cdev *dev, int oflags, int devtype, struct thread *p) { int err = 0; uprintf("Opened device \"mpp0\" successfully.\n"); return(err); } static int mpp0_close(struct cdev *dev, int fflag, int devtype, struct thread *p) { uprintf("Closing device \"mpp0\" successfully.\n"); return(0); } static int mpp0_read(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; if(uio->uio_resid > 0) { uprintf("Reading device \"mpp0\"\n"); } return(err); } static int mpp0_write(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; if(uio->uio_resid > 0) { uprintf("Writing device \"mpp0\"\n"); } return(err); } DEV_MODULE(mpp0,mpp0_loader,NULL);