From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20185 invoked by alias); 17 Nov 2006 18:07:39 -0000 Received: (qmail 20172 invoked by uid 22791); 17 Nov 2006 18:07:38 -0000 X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from snape.ecoscentric.com (HELO snape.ecoscentric.com) (212.13.207.199) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 17 Nov 2006 18:07:29 +0000 Received: from localhost (localhost [127.0.0.1]) by snape.ecoscentric.com (Postfix) with ESMTP id D3369DC80E6; Fri, 17 Nov 2006 18:07:26 +0000 (GMT) X-Virus-Scanned: amavisd-new at ecoscentric.com Received: from snape.ecoscentric.com ([127.0.0.1]) by localhost (snape.ecoscentric.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6D7YlKopXvzA; Fri, 17 Nov 2006 18:07:22 +0000 (GMT) Message-ID: <455DFA59.1000607@eCosCentric.com> Date: Fri, 17 Nov 2006 18:07:00 -0000 From: Jonathan Larmour User-Agent: Thunderbird 1.5.0.8 (X11/20061107) MIME-Version: 1.0 To: Donald Walton CC: ecos-maintainers@ecos.sourceware.org, eCos Patches List Subject: Re: Possible error in IDE code..... References: <455DF3B0.9070102@dramail.com> In-Reply-To: <455DF3B0.9070102@dramail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact ecos-maintainers-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: ecos-maintainers-owner@ecos.sourceware.org X-SW-Source: 2006-11/txt/msg00003.txt.bz2 Donald Walton wrote: > In adding IDE support to my application, the software was not able to > read the MBR properly. It would read one byte and the rest of the > buffer would be zeroes. > > I tracked the problem to file - ide_disk.c, version 1.3, function - > ide_read_sector. One of the parameters passed in is len. It unclear > whether this is the buffer length or number of sectors to be read. > However, a value of 1 is passed in for the length and only one byte is > read. > > Correcting the problem is not a big deal but I would like to know > whether you meant for the length to be sector count or byte count. It's meant to be the sector count (with 512-byte sectors). It's my bad because I had updated this package after the CYGPKG_IO_DISK package changed in this regard, but I evidently missed this bit. I've checked in the below change. Update your CVS and try it out. Jifl Index: ChangeLog =================================================================== RCS file: /cvs/ecos/ecos/packages/devs/disk/ide/current/ChangeLog,v retrieving revision 1.3 retrieving revision 1.4 diff -u -5 -p -r1.3 -r1.4 --- ChangeLog 21 Sep 2006 16:36:24 -0000 1.3 +++ ChangeLog 17 Nov 2006 18:04:43 -0000 1.4 @@ -1,5 +1,11 @@ +2006-11-17 Jonathan Larmour + + * src/ide_disk.c (ide_read_sector, ide_write_sector): Length + is counted in sectors now, not bytes (due to change in io/disk + API). + 2006-09-21 Jonathan Larmour * src/ide_disk.h: DISK_FUNS is now implicitly static. (IDE_DISK_INSTANCE): Reflect updated io/disk API by using ide_disk_controller. Index: src/ide_disk.c =================================================================== RCS file: /cvs/ecos/ecos/packages/devs/disk/ide/current/src/ide_disk.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -5 -p -r1.3 -r1.4 --- src/ide_disk.c 21 Sep 2006 16:36:24 -0000 1.3 +++ src/ide_disk.c 17 Nov 2006 18:04:43 -0000 1.4 @@ -262,12 +262,12 @@ ide_read_sector(int ctlr, int dev, cyg_u // but who knows // for (j = 0, c=0 ; j < (CYGDAT_DEVS_DISK_IDE_SECTOR_SIZE / sizeof(cyg_uint16)); j++) { HAL_IDE_READ_UINT16(ctlr, IDE_REG_DATA, p); - if (c++>8)&0xff; + if (c++<(len*512)) *b++=p&0xff; + if (c++<(len*512)) *b++=(p>>8)&0xff; } return 1; } static int @@ -296,12 +296,12 @@ ide_write_sector(int ctlr, int dev, cyg_ // It would be fine if all buffers were word aligned, // but who knows // for (j = 0, c=0 ; j < (CYGDAT_DEVS_DISK_IDE_SECTOR_SIZE / sizeof(cyg_uint16)); j++) { - p = (c++