From owner-freebsd-drivers@FreeBSD.ORG Mon Apr 10 12:31:39 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 23CAC16A401 for ; Mon, 10 Apr 2006 12:31:39 +0000 (UTC) (envelope-from nickolas@atlas.ua) Received: from colt.tsua.net (colt.tsua.net [212.40.34.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3376F43D49 for ; Mon, 10 Apr 2006 12:31:36 +0000 (GMT) (envelope-from nickolas@atlas.ua) Received: from localhost (localhost [127.0.0.1]) by colt.tsua.net (Postfix) with ESMTP id 78DCC105083 for ; Mon, 10 Apr 2006 15:31:35 +0300 (EEST) Received: from colt.tsua.net ([127.0.0.1]) by localhost (colt.tsua.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 78413-01 for ; Mon, 10 Apr 2006 15:31:35 +0300 (EEST) Received: by colt.tsua.net (Postfix, from userid 426) id 247A9105101; Mon, 10 Apr 2006 15:31:35 +0300 (EEST) Received: from mail.atlas.kiev.ua (atlas-ss-1.tsua.net [212.40.33.65]) by colt.tsua.net (Postfix) with ESMTP id E96D81050AB for ; Mon, 10 Apr 2006 15:31:34 +0300 (EEST) Received: from exim (helo=mail.atlas.kiev.ua) by mail.atlas.kiev.ua with local-smtp (Exim 4.43 (FreeBSD)) id 1FSve2-0005D8-93 for freebsd-drivers@freebsd.org; Mon, 10 Apr 2006 15:37:26 +0300 Received: from [172.16.4.222] (helo=dragon60116) by mail.atlas.kiev.ua with esmtp (Exim 4.43 (FreeBSD)) id 1FSve2-0005Ck-3E for freebsd-drivers@freebsd.org; Mon, 10 Apr 2006 15:37:26 +0300 Date: Mon, 10 Apr 2006 15:31:39 +0300 From: Nickolas X-Mailer: The Bat! (v3.71.04) UNREG / CD5BF9353B3B7091 Organization: atlas X-Priority: 3 (Normal) Message-ID: <811970386.20060410153139@atlas.ua> To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at tsua.net Subject: Context switching X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Nickolas List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Apr 2006 12:31:39 -0000 Hello All! I'm porting a CPI card driver from linux to FreeBSD. Some initialization routines require much time (~1-2 seconds). Initialization of hardware should be done during opening device special file. So, I need to switch thread context. I'm doing it in such way: mi_switch(SW_VOL, choosethread()); -- Best regards, Nickolas mailto:nickolas@atlas.ua From owner-freebsd-drivers@FreeBSD.ORG Mon Apr 10 12:53:47 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 4AA4216A404 for ; Mon, 10 Apr 2006 12:53:47 +0000 (UTC) (envelope-from nickolas@atlas.ua) Received: from colt.tsua.net (colt.tsua.net [212.40.34.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACF1E43D45 for ; Mon, 10 Apr 2006 12:53:46 +0000 (GMT) (envelope-from nickolas@atlas.ua) Received: from localhost (localhost [127.0.0.1]) by colt.tsua.net (Postfix) with ESMTP id 9F9981050D0 for ; Mon, 10 Apr 2006 15:53:45 +0300 (EEST) Received: from colt.tsua.net ([127.0.0.1]) by localhost (colt.tsua.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 85269-05 for ; Mon, 10 Apr 2006 15:53:45 +0300 (EEST) Received: by colt.tsua.net (Postfix, from userid 426) id 0A13910518B; Mon, 10 Apr 2006 15:53:45 +0300 (EEST) Received: from mail.atlas.kiev.ua (atlas-ss-1.tsua.net [212.40.33.65]) by colt.tsua.net (Postfix) with ESMTP id 7853E1051BC for ; Mon, 10 Apr 2006 15:53:43 +0300 (EEST) Received: from exim (helo=mail.atlas.kiev.ua) by mail.atlas.kiev.ua with local-smtp (Exim 4.43 (FreeBSD)) id 1FSvt6-00061W-RS for freebsd-drivers@freebsd.org; Mon, 10 Apr 2006 15:53:00 +0300 Received: from exim (helo=mail.atlas.kiev.ua) by mail.atlas.kiev.ua with local-smtp (Exim 4.43 (FreeBSD)) id 1FSvrL-0005w6-HL for freebsd-drivers@freebsd.org; Mon, 10 Apr 2006 15:51:11 +0300 Received: from [172.16.4.222] (helo=dragon60116) by mail.atlas.kiev.ua with esmtp (Exim 4.43 (FreeBSD)) id 1FSvrL-0005w1-1i for freebsd-drivers@freebsd.org; Mon, 10 Apr 2006 15:51:11 +0300 Date: Mon, 10 Apr 2006 15:45:42 +0300 From: Nickolas X-Mailer: The Bat! (v3.71.04) UNREG / CD5BF9353B3B7091 Organization: atlas X-Priority: 3 (Normal) Message-ID: <637898557.20060410154542@atlas.ua> To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at tsua.net Subject: Context switching X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Nickolas List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Apr 2006 12:53:47 -0000 Hello All! I'm porting a CPI card driver from linux to FreeBSD. Some initialization routines require much time (~1-2 seconds). Initialization of hardware should be done during opening device special file. So, I need to switch thread context. I'm doing it in such way: mi_switch(SW_VOL, choosethread()); Main trouble: system panic after program exit. dmesg output: -------------------------- Fatal trap 12: page fault while in user mode fault virtual address = 0xbfbfe5bc fault code = user write, protection violation instruction pointer = 0x1f:0x8074604 stack pointer = 0x2f:0xbfbfe5c0 frame pointer = 0x2f:0xbfbfe5f8 code segment = base 0xc090f8c0, limit 0x0, type 0x13 = DPL 0, pres 1, def32 1, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 472 (bash) trap number = 12 panic: page fault -------------------------- Please, tell how correct context switching should be implemented? OS version: FreeBSD 5.4 -- Best regards, Nickolas mailto:nickolas@atlas.ua From owner-freebsd-drivers@FreeBSD.ORG Mon Apr 10 15:31:54 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 AD37116A401 for ; Mon, 10 Apr 2006 15:31:54 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id B88F943D6E for ; Mon, 10 Apr 2006 15:31:45 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.4/8.13.4) with ESMTP id k3AFUDUL041739; Mon, 10 Apr 2006 09:30:13 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 10 Apr 2006 09:30:15 -0600 (MDT) Message-Id: <20060410.093015.34601940.imp@bsdimp.com> To: nickolas@atlas.ua From: "M. Warner Losh" In-Reply-To: <637898557.20060410154542@atlas.ua> References: <637898557.20060410154542@atlas.ua> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-drivers@freebsd.org Subject: Re: Context switching 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: Mon, 10 Apr 2006 15:31:54 -0000 In message: <637898557.20060410154542@atlas.ua> Nickolas writes: : Hello All! : : I'm porting a CPI card driver from linux to FreeBSD. : Some initialization routines require much time (~1-2 seconds). : Initialization of hardware should be done during opening device : special file. So, I need to switch thread context. : : I'm doing it in such way: : : mi_switch(SW_VOL, choosethread()); : : Main trouble: system panic after program exit. : : dmesg output: : -------------------------- : Fatal trap 12: page fault while in user mode : fault virtual address = 0xbfbfe5bc : fault code = user write, protection violation : instruction pointer = 0x1f:0x8074604 : stack pointer = 0x2f:0xbfbfe5c0 : frame pointer = 0x2f:0xbfbfe5f8 : code segment = base 0xc090f8c0, limit 0x0, type 0x13 : = DPL 0, pres 1, def32 1, gran 1 : processor eflags = interrupt enabled, resume, IOPL = 0 : current process = 472 (bash) : trap number = 12 : panic: page fault : -------------------------- : : Please, tell how correct context switching should be implemented? Create a thread on attach. Have it msleep. Use wakeup from open and have open msleep. The thread then runs, does its init and wakes up the open thread to continue. Of course, you could likely do all that in the open thread... Warner From owner-freebsd-drivers@FreeBSD.ORG Tue Apr 11 19:01:04 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 177F416A405 for ; Tue, 11 Apr 2006 19:01:04 +0000 (UTC) (envelope-from weigly@wattyl.com.au) Received: from atn.nu (BSN-77-132-30.dial-up.dsl.siol.net [193.77.132.30]) by mx1.FreeBSD.org (Postfix) with SMTP id E0E2743D45 for ; Tue, 11 Apr 2006 19:01:02 +0000 (GMT) (envelope-from weigly@wattyl.com.au) Message-ID: <000001c65d9a$31858ae0$57dca8c0@mjw78> From: "Augusto Weigle" To: freebsd-drivers@freebsd.org Date: Tue, 11 Apr 2006 15:00:26 -0400 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: keoaf news X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Augusto Weigle List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2006 19:01:04 -0000 De l ar Home Ow u ne e r ,=20 =20 Your c t re x di l t doesn't matter to us !=20 =20 If you O j WN real e w st b at j e and want=20 I m MM g EDI j AT r E c j as s h to s o pen m d ANY way you like,=20 or simply wish to L h OW r ER your monthly=20 p b aym w ent t s by a third or more,=20 here are the de j al c s we have T d OD h AY :=20 =20 $ 48 k 8 , 000 at a 3 p , 67% f m ix h ed - r q at g e=20 $ 3 z 72 , 000 at a 3 , 9 k 0% v f ar y iabl a e - r k at p e=20 $ 49 s 2 , 000 at a 3 , 2 k 1% in q ter t es o t - only=20 $ 2 g 48 , 000 at a 3 , 3 t 6% f n ixe q d - r n at d e=20 $ 1 s 98 , 000 at a 3 h , 55% v g ari n abl f e - r h at s e=20 =20 H s urr n y, when these d t ea k ls are gone,=20 they are gone ! =20 Don't worry about a k ppro c va k l, your=20 c w re u di v t will not di h squ o alify you !=20 =20 V t isi h t our sit k e =20 =20 Sincerely, Augusto Weigle=20 =20 A h pp x rova j l Manager