mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 04:22:15 +02:00
util/nvmutil: re-introduce do_read in readGbe
lots of block devices use 4KB block size. it makes sense to have this optimisation here. i previously removed it, along with the one that only reads the NVM area - that one is still gone, because it was largely pointless. because of this modification returning, i also re-introduced the check in setWord against nvmPartModified - otherwise, for example, running cmd brick 0 would brick part 0 but then write all zeroes to part 1. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+10
-2
@@ -43,6 +43,7 @@ uint8_t buf[SIZE_8KB];
|
|||||||
uint16_t mac[3] = {0, 0, 0};
|
uint16_t mac[3] = {0, 0, 0};
|
||||||
size_t partsize;
|
size_t partsize;
|
||||||
int flags, rfd, fd, part, e = 1;
|
int flags, rfd, fd, part, e = 1;
|
||||||
|
int nvmPartModified[2] = {0, 0};
|
||||||
|
|
||||||
const char *strMac = NULL, *strRMac = "xx:xx:xx:xx:xx:xx", *fname = "";
|
const char *strMac = NULL, *strRMac = "xx:xx:xx:xx:xx:xx", *fname = "";
|
||||||
|
|
||||||
@@ -184,8 +185,13 @@ xopen(int *f, const char *l, int p, struct stat *st)
|
|||||||
void
|
void
|
||||||
readGbe(void)
|
readGbe(void)
|
||||||
{
|
{
|
||||||
|
int do_read[2] = {1, 1};
|
||||||
|
if ((cmd == cmd_copy) || (cmd == cmd_brick) || (cmd == cmd_setchecksum))
|
||||||
|
do_read[part ^ 1] = 0;
|
||||||
|
|
||||||
for (int p = 0; p < 2; p++)
|
for (int p = 0; p < 2; p++)
|
||||||
readGbe_part(p);
|
if (do_read[p])
|
||||||
|
readGbe_part(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -415,6 +421,7 @@ void
|
|||||||
setWord(int pos16, int p, uint16_t val16)
|
setWord(int pos16, int p, uint16_t val16)
|
||||||
{
|
{
|
||||||
check_bounds(pos16, p);
|
check_bounds(pos16, p);
|
||||||
|
nvmPartModified[p] = 1;
|
||||||
((uint16_t *) (buf + (SIZE_4KB * p)))[pos16] = val16;
|
((uint16_t *) (buf + (SIZE_4KB * p)))[pos16] = val16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +439,8 @@ writeGbe(void)
|
|||||||
{
|
{
|
||||||
if (flags != O_RDONLY)
|
if (flags != O_RDONLY)
|
||||||
for (int p = 0; p < 2; p++)
|
for (int p = 0; p < 2; p++)
|
||||||
writeGbe_part(p);
|
if (nvmPartModified[p])
|
||||||
|
writeGbe_part(p);
|
||||||
err_if(close(fd) == -1);
|
err_if(close(fd) == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user