public inbox for ecos-maintainers@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Larmour <jifl@eCosCentric.com>
To: Donald Walton <dwalton@dramail.com>
Cc: ecos-maintainers@ecos.sourceware.org,
	  eCos Patches List <ecos-patches@ecos.sourceware.org>
Subject: Re: Possible error in IDE code.....
Date: Fri, 17 Nov 2006 18:07:00 -0000	[thread overview]
Message-ID: <455DFA59.1000607@eCosCentric.com> (raw)
In-Reply-To: <455DF3B0.9070102@dramail.com>

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  <jifl@eCosCentric.com>
+
+       * 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  <jifl@eCosCentric.com>

         * 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++<len) *b++=p&0xff;
-        if (c++<len) *b++=(p>>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++<len) ? *b++ : 0;
-        p |= (c++<len) ? (*b++<<8) : 0;
+        p = (c++<(len*512)) ? *b++ : 0;
+        p |= (c++<(len*512)) ? (*b++<<8) : 0;
          HAL_IDE_WRITE_UINT16(ctlr, IDE_REG_DATA, p);
      }
      return 1;
  }


-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
------["The best things in life aren't things."]------      Opinions==mine

      reply	other threads:[~2006-11-17 18:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-17 17:39 Donald Walton
2006-11-17 18:07 ` Jonathan Larmour [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=455DFA59.1000607@eCosCentric.com \
    --to=jifl@ecoscentric.com \
    --cc=dwalton@dramail.com \
    --cc=ecos-maintainers@ecos.sourceware.org \
    --cc=ecos-patches@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).