xlnx-bbram.c (3b35d4542c8537a9269f6372df531ced6c960084) xlnx-bbram.c (a9262f551eba44d4d0f9e396d7124c059a93e204)
1/*
2 * QEMU model of the Xilinx BBRAM Battery Backed RAM
3 *
4 * Copyright (c) 2014-2021 Xilinx Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 110 unchanged lines hidden (view full) ---

119 s->blk_ro = true;
120 }
121 }
122 if (s->blk_ro) {
123 warn_report("%s: Skip saving updates to read-only BBRAM backstore.",
124 blk_name(s->blk));
125 }
126
1/*
2 * QEMU model of the Xilinx BBRAM Battery Backed RAM
3 *
4 * Copyright (c) 2014-2021 Xilinx Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 110 unchanged lines hidden (view full) ---

119 s->blk_ro = true;
120 }
121 }
122 if (s->blk_ro) {
123 warn_report("%s: Skip saving updates to read-only BBRAM backstore.",
124 blk_name(s->blk));
125 }
126
127 if (blk_pread(s->blk, 0, ram, nr, 0) < 0) {
127 if (blk_pread(s->blk, 0, nr, ram, 0) < 0) {
128 error_setg(errp,
129 "%s: Failed to read %u bytes from BBRAM backstore.",
130 blk_name(s->blk), nr);
131 return;
132 }
133
134 /* Convert from little-endian backstore for each 32-bit word */
135 nr /= 4;

--- 18 unchanged lines hidden (view full) ---

154 ARRAY_FIELD_DP32(s->regs, BBRAM_STATUS, BBRAM_ZEROIZED, 0);
155 }
156
157 if (!s->blk || s->blk_ro) {
158 return;
159 }
160
161 offset = hwaddr - A_BBRAM_0;
128 error_setg(errp,
129 "%s: Failed to read %u bytes from BBRAM backstore.",
130 blk_name(s->blk), nr);
131 return;
132 }
133
134 /* Convert from little-endian backstore for each 32-bit word */
135 nr /= 4;

--- 18 unchanged lines hidden (view full) ---

154 ARRAY_FIELD_DP32(s->regs, BBRAM_STATUS, BBRAM_ZEROIZED, 0);
155 }
156
157 if (!s->blk || s->blk_ro) {
158 return;
159 }
160
161 offset = hwaddr - A_BBRAM_0;
162 rc = blk_pwrite(s->blk, offset, &le32, 4, 0);
162 rc = blk_pwrite(s->blk, offset, 4, &le32, 0);
163 if (rc < 0) {
164 bbram_bdrv_error(s, rc, g_strdup_printf("write to offset %u", offset));
165 }
166}
167
168static void bbram_bdrv_zero(XlnxBBRam *s)
169{
170 int rc;

--- 375 unchanged lines hidden ---
163 if (rc < 0) {
164 bbram_bdrv_error(s, rc, g_strdup_printf("write to offset %u", offset));
165 }
166}
167
168static void bbram_bdrv_zero(XlnxBBRam *s)
169{
170 int rc;

--- 375 unchanged lines hidden ---