Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Paste Description for ata_read_sectors()

Quick bit of pseudo code outlining the approach for handling 1024 byte sector reads on the 80GB iPod for Rockbox.

ata_read_sectors()
Thursday, May 3rd, 2007 at 10:46:31am UTC 

  1. pseudo ata_read_sectors(IF_MV2(int drive,)
  2.                      unsigned long start,
  3.                      int incount,
  4.                      void* inbuf)
  5. {
  6.  
  7.     // Determine where to start
  8.     if (start % 2 != 0)                   // odd starting sector
  9.         realstart = start - 1;
  10.     else
  11.         realstart = start;
  12.  
  13.     // Determine how many sectors to read
  14.     if (realstart + incount % 2 != 0)     // odd number of sectors to read
  15.         realcount = incount + 1;
  16.     else
  17.         realcount = incount;
  18.  
  19.     copy_read_sectors(buf, wordcount);
  20.    
  21.     // Return the data actually requested.
  22.     // buf now (probably) contains more data than
  23.     // we wanted.
  24.    
  25.     if (realstart != start)
  26.         memcpy (realbuf, buf + ATA_SECTOR_SIZE , ATA_SECTOR_SIZE * count);
  27.     else
  28.         memcpy (realbuf, buf, ATA_SECTOR_SIZE * count);
  29.  
  30. }

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right