aboutsummaryrefslogtreecommitdiff
path: root/platforms
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2016-11-02 16:43:29 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-11-02 17:26:04 +1100
commit322317b06939befbe87397e8d26f4dfca975f763 (patch)
tree7709dec7e3df65314ec4090a15adb35941b78720 /platforms
parent36c2f299f51e67c720a86dc5f717eb3eddb4fa42 (diff)
downloadskiboot-322317b06939befbe87397e8d26f4dfca975f763.zip
skiboot-322317b06939befbe87397e8d26f4dfca975f763.tar.gz
skiboot-322317b06939befbe87397e8d26f4dfca975f763.tar.bz2
platforms/mambo: Support large unaligned reads
Recent changes to the skiboot resource loading code means that reads for BOOTKERNEL and ROOTFS partitions will be exactly the number of bytes required and no longer the (inaccurate) partition total size which happened to be block size aligned. Error when booting in mambo: 1140078: (1140078): [ 0.001132323,3] FLASH: failed to read content size 14252376 BOOTKERNEL partition, rc -1 Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> [initial review and changes by Mikey Neuling] Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'platforms')
-rw-r--r--platforms/mambo/mambo.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c
index bd151ed..7f910b2 100644
--- a/platforms/mambo/mambo.c
+++ b/platforms/mambo/mambo.c
@@ -131,22 +131,29 @@ static int bogus_disk_read(struct blocklevel_device *bl, uint64_t pos, void *buf
uint64_t len)
{
struct bogus_disk_info *bdi = bl->priv;
- int rc;
+ int rc, read_sectors = 0;
char b[BD_SECT_SZ];
- if ((len % BD_SECT_SZ) == 0)
- return callthru_disk_read(bdi->id, buf, pos/BD_SECT_SZ,
+ if (len >= BD_SECT_SZ) {
+ rc = callthru_disk_read(bdi->id, buf, pos/BD_SECT_SZ,
len/BD_SECT_SZ);
+ if (rc)
+ return rc;
+ read_sectors = (len / BD_SECT_SZ);
+ }
- /* We don't support block reads > BD_SECT_SZ */
- if (len > BD_SECT_SZ)
- return OPAL_PARAMETER;
+ if ((len % BD_SECT_SZ) == 0)
+ return 0;
- /* Skiboot does small reads for system flash header checking */
- rc = callthru_disk_read(bdi->id, b, pos/BD_SECT_SZ, 1);
+ /*
+ * Read any unaligned data into a temporaty buffer b, then copy
+ * to buf
+ */
+ rc = callthru_disk_read(bdi->id, b, (pos/BD_SECT_SZ) + read_sectors, 1);
if (rc)
return rc;
- memcpy(buf, &b[pos % BD_SECT_SZ], len);
+ memcpy(buf + (read_sectors * BD_SECT_SZ) , &b[pos % BD_SECT_SZ],
+ len - (read_sectors * BD_SECT_SZ));
return rc;
}