From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 28 14:25:15 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0C83716A4C4 for ; Thu, 28 Aug 2003 14:25:15 -0700 (PDT) Received: from artax.karlin.mff.cuni.cz (artax.karlin.mff.cuni.cz [195.113.31.125]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3586543FF2 for ; Thu, 28 Aug 2003 14:25:14 -0700 (PDT) (envelope-from mikulas@artax.karlin.mff.cuni.cz) Received: by artax.karlin.mff.cuni.cz (Postfix, from userid 17421) id 7618A3FA4; Thu, 28 Aug 2003 23:25:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by artax.karlin.mff.cuni.cz (Postfix) with ESMTP id 740BB2FBD8; Thu, 28 Aug 2003 23:25:10 +0200 (CEST) Date: Thu, 28 Aug 2003 23:25:10 +0200 (CEST) From: Mikulas Patocka To: Dan Lukes In-Reply-To: <3F4B5374.1080306@obluda.cz> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-hackers@freebsd.org Subject: Re: Bug FreeBSD 4.8 ATA driver X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2003 21:25:15 -0000 On Tue, 26 Aug 2003, Dan Lukes wrote: > Mikulas Patocka napsal/wrote, On 08/20/03 01:39: > > I am reading FreeBSD ATA drivers because I want to use them as base for my > > ATA driver and I found a total nonsence: in ata-dma.c in FreeBSD 4.8, > > there is line > > > > if (!((pci_read_config(parent,0x40,4)>>(ch->unit<<8))&0x4000)) { > > > > if ch->unit is 1, config word is shifted by 256 bytes, which gives > > undefined result in C. How was this meant? What should it do? > > Hm, it should be (IMHO) > if (!((pci_read_config(parent,0x40,4)>>(ch->unit<<5))&0x4000)) That is incorrect too --- if ch->unit is 1, ch->unit<<5 is 32 and you can't shift 32-bit integer by 32 bits. > but I can't verify it as have no access to documentation for PIIX3 nor > acces to the PIIX3 hardware now. > > Note the position of '8' just above the '5' key on numeric keypad also ... > > FYI, the gcc compile the code as equivalent of > if (!((pci_read_config(parent,0x40,4)>>(0))&0x4000)) > effectively ignoring the ch->unit number. > > > If you want wrote your own ATA driver, it may be better to look into > current FreeBSD 5 ATA code - it's substantially rewrited. I noticed it too late --- when I copid all code from FreeBSD 4 :-/ > A smel bych, uz asi mimo konferenci, vedet, proc si pises vlastni ATA > ovladac ? No, zatim to neni moc verejny projekt. Mikulas