summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/ata.c17
-rw-r--r--firmware/drivers/ata.h4
2 files changed, 14 insertions, 7 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 8e2aa48017..ebe9602f01 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -136,10 +136,10 @@ static int wait_for_end_of_transfer(void)
136} 136}
137 137
138int ata_read_sectors(unsigned long start, 138int ata_read_sectors(unsigned long start,
139 unsigned char count, 139 int count,
140 void* buf) __attribute__ ((section (".icode"))); 140 void* buf) __attribute__ ((section (".icode")));
141int ata_read_sectors(unsigned long start, 141int ata_read_sectors(unsigned long start,
142 unsigned char count, 142 int count,
143 void* buf) 143 void* buf)
144{ 144{
145 int i; 145 int i;
@@ -169,7 +169,11 @@ int ata_read_sectors(unsigned long start,
169 169
170 led(true); 170 led(true);
171 171
172 ATA_NSECTOR = count; 172 if ( count == 256 )
173 ATA_NSECTOR = 0; /* 0 means 256 sectors */
174 else
175 ATA_NSECTOR = (unsigned char)count;
176
173 ATA_SECTOR = start & 0xff; 177 ATA_SECTOR = start & 0xff;
174 ATA_LCYL = (start >> 8) & 0xff; 178 ATA_LCYL = (start >> 8) & 0xff;
175 ATA_HCYL = (start >> 16) & 0xff; 179 ATA_HCYL = (start >> 16) & 0xff;
@@ -215,7 +219,7 @@ int ata_read_sectors(unsigned long start,
215} 219}
216 220
217int ata_write_sectors(unsigned long start, 221int ata_write_sectors(unsigned long start,
218 unsigned char count, 222 int count,
219 void* buf) 223 void* buf)
220{ 224{
221 int i; 225 int i;
@@ -242,7 +246,10 @@ int ata_write_sectors(unsigned long start,
242 246
243 led(true); 247 led(true);
244 248
245 ATA_NSECTOR = count; 249 if ( count == 256 )
250 ATA_NSECTOR = 0; /* 0 means 256 sectors */
251 else
252 ATA_NSECTOR = (unsigned char)count;
246 ATA_SECTOR = start & 0xff; 253 ATA_SECTOR = start & 0xff;
247 ATA_LCYL = (start >> 8) & 0xff; 254 ATA_LCYL = (start >> 8) & 0xff;
248 ATA_HCYL = (start >> 16) & 0xff; 255 ATA_HCYL = (start >> 16) & 0xff;
diff --git a/firmware/drivers/ata.h b/firmware/drivers/ata.h
index aa9c767cbb..4209fdcd1e 100644
--- a/firmware/drivers/ata.h
+++ b/firmware/drivers/ata.h
@@ -40,10 +40,10 @@ extern int ata_hard_reset(void);
40extern int ata_soft_reset(void); 40extern int ata_soft_reset(void);
41extern int ata_init(void); 41extern int ata_init(void);
42extern int ata_read_sectors(unsigned long start, 42extern int ata_read_sectors(unsigned long start,
43 unsigned char count, 43 int count,
44 void* buf); 44 void* buf);
45extern int ata_write_sectors(unsigned long start, 45extern int ata_write_sectors(unsigned long start,
46 unsigned char count, 46 int count,
47 void* buf); 47 void* buf);
48 48
49#endif 49#endif