mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-19 19:23:24 +02:00
util/nvmutil: make word/setWord a function
having this as a macro makes the code quite brittle. better to have it as a function. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+17
-5
@@ -20,9 +20,10 @@ void cmd_setchecksum(void), cmd_brick(void), swap(int partnum), writeGbe(void),
|
|||||||
parseMacString(const char *strMac, uint16_t *mac), cmd_swap(void),
|
parseMacString(const char *strMac, uint16_t *mac), cmd_swap(void),
|
||||||
openFiles(const char *path), cmd_copy(void), writeGbe_part(int),
|
openFiles(const char *path), cmd_copy(void), writeGbe_part(int),
|
||||||
readGbe_part(int), usage(char*), set_io_flags(int, char **),
|
readGbe_part(int), usage(char*), set_io_flags(int, char **),
|
||||||
set_cmd(int, char **);
|
set_cmd(int, char **), setWord(int, int, uint16_t);
|
||||||
int goodChecksum(int partnum);
|
int goodChecksum(int partnum);
|
||||||
uint8_t hextonum(char chs), rhex(void);
|
uint8_t hextonum(char chs), rhex(void);
|
||||||
|
uint16_t word(int, int);
|
||||||
|
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
void block_unveil(void);
|
void block_unveil(void);
|
||||||
@@ -72,10 +73,6 @@ void (*cmd)(void) = NULL;
|
|||||||
err(SET_ERR(ECANCELED), "%s", l); \
|
err(SET_ERR(ECANCELED), "%s", l); \
|
||||||
if (fstat(f, &st) == -1) err(SET_ERR(ECANCELED), "%s", l)
|
if (fstat(f, &st) == -1) err(SET_ERR(ECANCELED), "%s", l)
|
||||||
|
|
||||||
#define word(pos16, partnum) ((uint16_t *) gbe[partnum])[pos16]
|
|
||||||
#define setWord(pos16, p, val16) if (word(pos16, p) != val16) \
|
|
||||||
nvmPartChanged[p] = 1 | (word(pos16, p) = val16)
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -405,6 +402,21 @@ goodChecksum(int partnum)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t
|
||||||
|
word(int pos16, int p)
|
||||||
|
{
|
||||||
|
return ((uint16_t *) gbe[p])[pos16];
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setWord(int pos16, int p, uint16_t val16)
|
||||||
|
{
|
||||||
|
if (((uint16_t *) gbe[p])[pos16] != val16) {
|
||||||
|
nvmPartChanged[p] = 1;
|
||||||
|
((uint16_t *) gbe[p])[pos16] = val16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
writeGbe(void)
|
writeGbe(void)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user