summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/coreboot/x2e_n150/config/fspgop2
-rw-r--r--util/dell-flash-unlock/Makefile2
-rw-r--r--util/dell-flash-unlock/dell_flash_unlock.c18
-rw-r--r--util/nvmutil/Makefile2
-rw-r--r--util/nvmutil/nvmutil.c74
-rw-r--r--util/spkmodem_recv/Makefile2
-rw-r--r--util/spkmodem_recv/spkmodem-recv.c17
7 files changed, 77 insertions, 40 deletions
diff --git a/config/coreboot/x2e_n150/config/fspgop b/config/coreboot/x2e_n150/config/fspgop
index 2e041b74..bcab6bbc 100644
--- a/config/coreboot/x2e_n150/config/fspgop
+++ b/config/coreboot/x2e_n150/config/fspgop
@@ -260,7 +260,7 @@ CONFIG_SOC_INTEL_UART_DEV_MAX=7
CONFIG_SOC_INTEL_COMMON_LPSS_UART_CLK_M_VAL=0x25a
CONFIG_SOC_INTEL_COMMON_LPSS_UART_CLK_N_VAL=0x7fff
CONFIG_FSP_TYPE_IOT=y
-CONFIG_FSP_HEADER_PATH="3rdparty/fsp/AlderLakeFspBinPkg/IoT/AlderLakeN/Include/"
+CONFIG_FSP_HEADER_PATH="3rdparty/fspcc36ae2b5775fa7400cb3282680afc0f6cb37a3c/AlderLakeFspBinPkg/IoT/AlderLakeN/Include/"
CONFIG_SOC_INTEL_COMMON_DEBUG_CONSENT=0
CONFIG_DATA_BUS_WIDTH=128
CONFIG_DIMMS_PER_CHANNEL=2
diff --git a/util/dell-flash-unlock/Makefile b/util/dell-flash-unlock/Makefile
index 8528c10e..7bb7e1b3 100644
--- a/util/dell-flash-unlock/Makefile
+++ b/util/dell-flash-unlock/Makefile
@@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: 2023 Nicholas Chin
CC=cc
-CFLAGS=-Wall -Wextra -Werror -O2 -pedantic
+CFLAGS=-Wall -Wextra -O2
SRCS=dell_flash_unlock.c accessors.c
all: $(SRCS) accessors.h
diff --git a/util/dell-flash-unlock/dell_flash_unlock.c b/util/dell-flash-unlock/dell_flash_unlock.c
index d59f5d5b..64fc6daf 100644
--- a/util/dell-flash-unlock/dell_flash_unlock.c
+++ b/util/dell-flash-unlock/dell_flash_unlock.c
@@ -47,9 +47,9 @@ main(int argc, char *argv[])
(void)argv;
if (sys_iopl(3) == -1)
- err(errno, "Could not access IO ports");
+ err(EXIT_FAILURE, "Could not access IO ports");
if ((devmemfd = open("/dev/mem", O_RDONLY)) == -1)
- err(errno, "/dev/mem");
+ err(EXIT_FAILURE, "/dev/mem");
/* Read RCBA and PMBASE from the LPC config registers */
long int rcba = pci_read_32(LPC_DEV, 0xf0) & 0xffffc000;
@@ -59,11 +59,11 @@ main(int argc, char *argv[])
rcba_mmio = mmap(0, RCBA_MMIO_LEN, PROT_READ, MAP_SHARED, devmemfd,
rcba);
if (rcba_mmio == MAP_FAILED)
- err(errno, "Could not map RCBA");
+ err(EXIT_FAILURE, "Could not map RCBA");
if (get_fdo_status() == 1) { /* Descriptor not overridden */
if (check_lpc_decode() == -1)
- err(errno = ECANCELED, "Can't forward I/O to LPC");
+ err(EXIT_FAILURE, "Can't forward I/O to LPC");
printf("Sending FDO override command to EC:\n");
ec_set_fdo();
@@ -80,7 +80,8 @@ main(int argc, char *argv[])
"to enable SMIs.\n (shutdown is buggy when "
"SMIs are disabled)\n");
} else {
- err(errno = ECANCELED, "Could not disable SMIs!");
+ errno = EIO;
+ err(EXIT_FAILURE, "Could not disable SMIs!");
}
} else { /* SMI locks not in place or bypassed */
if (get_gbl_smi_en()) {
@@ -97,7 +98,7 @@ main(int argc, char *argv[])
}
}
sys_iopl(0);
- return errno;
+ return EXIT_SUCCESS;
}
int
@@ -137,6 +138,7 @@ check_lpc_decode(void)
pci_write_32(LPC_DEV, 0x84 + 4 * gen_dec_free, 0x911);
return 0;
} else {
+ errno = EIO;
return -1;
}
}
@@ -165,7 +167,7 @@ send_ec_cmd(uint8_t cmd)
sys_outb(EC_INDEX, 0);
sys_outb(EC_DATA, cmd);
if (wait_ec() == -1)
- err(errno = ECANCELED, "Timeout while waiting for EC!");
+ err(EXIT_FAILURE, "Timeout while waiting for EC!");
}
int
@@ -179,6 +181,8 @@ wait_ec(void)
timeout--;
usleep(1000);
} while (busy && timeout > 0);
+ if (timeout <= 0)
+ errno = EIO;
return timeout > 0 ? 0 : -1;
}
diff --git a/util/nvmutil/Makefile b/util/nvmutil/Makefile
index 7c7411f9..e8350203 100644
--- a/util/nvmutil/Makefile
+++ b/util/nvmutil/Makefile
@@ -3,7 +3,7 @@
# SPDX-FileCopyrightText: 2023 Riku Viitanen <riku.viitanen@protonmail.com>
CC?=cc
-CFLAGS?=-Os -Wall -Wextra -Werror -pedantic
+CFLAGS?=-Os -Wall -Wextra
DESTDIR?=
PREFIX?=/usr/local
INSTALL?=install
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index e76fbc47..8cab66ac 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -77,26 +77,41 @@ op_t op[] = {
};
void (*cmd)(void) = NULL;
-#define err_if(x) if (x) err(EXIT_FAILURE, "%s", filename)
+#define err_if(x) \
+ do { \
+ if (x) { \
+ err(EXIT_FAILURE, "%s", filename); \
+ } \
+ } while(0)
#define xopen(f,l,p) \
do { \
- if ((f = open_on_eintr(l, p)) == -1) \
- err(EXIT_FAILURE, "%s", l); \
- if (fstat(f, &st) == -1) \
- err(EXIT_FAILURE, "%s", l); \
+ if ((f = open_on_eintr(l, p)) == -1) { \
+ err(EXIT_FAILURE, "%s", l); \
+ } \
+ if (fstat(f, &st) == -1) { \
+ err(EXIT_FAILURE, "%s", l); \
+ } \
} while(0)
-#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)
+#define word(pos16, partnum) \
+ (((uint16_t *) gbe[partnum])[pos16])
+
+#define setWord(pos16, p, val16) \
+ do { \
+ if (word(pos16, p) != val16) { \
+ nvmPartChanged[p] = 1 | (word(pos16, p) = val16); \
+ } \
+ } while(0)
-#define SUCCESS(x) ((x) >= 0)
+#define SUCCESS(x) \
+ ((x) >= 0)
#define reset_caller_errno(return_value) \
do { \
- if (SUCCESS(return_value) && (!errno)) \
- errno = saved_errno; \
+ if (SUCCESS(return_value) && (!errno)) { \
+ errno = saved_errno; \
+ } \
} while (0)
int
@@ -234,7 +249,7 @@ readGbe(void)
if (buf == NULL)
err(EXIT_FAILURE, "malloc");
- gbe[0] = (size_t) buf;
+ gbe[0] = (uintptr_t) buf;
gbe[1] = gbe[0] + (nf * (do_read[0] & do_read[1]));
ssize_t tnr = 0;
@@ -283,7 +298,7 @@ cmd_setmac(void)
if (mac_updated)
return;
- errno = EINVAL;
+ errno = ECANCELED;
err(EXIT_FAILURE, "Error updating MAC address");
}
@@ -376,6 +391,11 @@ cmd_dump(void)
printf("MAC (part %d): ", partnum);
macf(partnum);
hexdump(partnum);
+
+ if (numInvalid > 1) {
+ errno = EINVAL;
+ err(EXIT_FAILURE, "dump: No valid checksums");
+ }
}
}
@@ -407,6 +427,7 @@ hexdump(int partnum)
}
}
+/* WARNING: Cannot fail. Make sure the file is valid. */
void
cmd_setchecksum(void)
{
@@ -420,22 +441,30 @@ cmd_setchecksum(void)
void
cmd_brick(void)
{
- if (goodChecksum(part))
+ if (goodChecksum(part)) {
setWord(NVM_CHECKSUM_WORD, part,
((word(NVM_CHECKSUM_WORD, part)) ^ 0xFF));
+ } else {
+ errno = ECANCELED;
+ err(EXIT_FAILURE, "brick: Bad checksum in part %d", part);
+ }
}
void
cmd_copy(void)
{
nvmPartChanged[part ^ 1] = goodChecksum(part);
+ if (!nvmPartChanged[part ^ 1]) {
+ errno = ECANCELED;
+ err(EXIT_FAILURE, "copy: Bad checksum in part %d", part);
+ }
}
void
cmd_swap(void) {
if(!(goodChecksum(0) || goodChecksum(1))) {
- errno = EINVAL;
- err(EXIT_FAILURE, "Invalid checksums");
+ errno = ECANCELED;
+ err(EXIT_FAILURE, "swap: Bad checksums");
}
gbe[0] ^= gbe[1];
@@ -502,8 +531,10 @@ xclose(int *fd)
int saved_errno = errno;
int rval = 0;
- if (fd == NULL)
+ if (fd == NULL) {
+ errno = EBADF;
err(EXIT_FAILURE, "xclose: null pointer");
+ }
if (*fd < 0)
return;
@@ -710,21 +741,24 @@ if_err_sys(int condition)
#define fs_err_retry() \
do { \
if ((rval == -1) && \
- (errno == EINTR)) \
+ (errno == EINTR)) { \
return 1; \
- if (rval >= 0 && !errno) \
+ } \
+ if (rval >= 0 && !errno) { \
errno = saved_errno; \
- return 0; \
+ } \
} while(0)
int
fs_retry(int saved_errno, int rval)
{
fs_err_retry();
+ return 0;
}
int
rw_retry(int saved_errno, ssize_t rval)
{
fs_err_retry();
+ return 0;
}
diff --git a/util/spkmodem_recv/Makefile b/util/spkmodem_recv/Makefile
index 3c5dc51f..0132baf8 100644
--- a/util/spkmodem_recv/Makefile
+++ b/util/spkmodem_recv/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
CC?=cc
-CFLAGS?=-Os -Wall -Wextra -Werror -pedantic
+CFLAGS?=-Os -Wall -Wextra
DESTDIR?=
PREFIX?=/usr/local
INSTALL?=install
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c
index 4467282d..6fcd356f 100644
--- a/util/spkmodem_recv/spkmodem-recv.c
+++ b/util/spkmodem_recv/spkmodem-recv.c
@@ -23,7 +23,6 @@
#define FREQ_DATA_MAX 60
#define THRESHOLD 500
-#define ERR() (errno = errno ? errno : ECANCELED)
#define reset_char() ascii = 0, ascii_bit = 7
signed short frame[MAX_SAMPLES], pulse[MAX_SAMPLES];
@@ -42,17 +41,17 @@ main(int argc, char *argv[])
int c;
#ifdef __OpenBSD__
if (pledge("stdio", NULL) == -1)
- err(ERR(), "pledge");
+ err(EXIT_FAILURE, "pledge");
#endif
while ((c = getopt(argc, argv, "d")) != -1)
- if (!(debug = (c == 'd')))
- err(errno = EINVAL, NULL);
+ if (!(debug = (c == 'd'))) {
+ errno = EINVAL;
+ err(EXIT_FAILURE, "%c: Invalid option", c);
+ }
setvbuf(stdout, NULL, _IONBF, 0);
while (!feof(stdin))
handle_audio();
- if (errno && debug)
- err(errno, "Unhandled error, errno %d", errno);
- return errno;
+ return EXIT_SUCCESS;
}
void
@@ -83,7 +82,7 @@ decode_pulse(void)
fread(frame + ringpos, 1, sizeof(frame[0]), stdin);
if (ferror(stdin) != 0)
- err(ERR(), "Could not read from frame.");
+ err(EXIT_FAILURE, "Could not read from frame.");
if ((pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0))
++freq_separator;
@@ -118,7 +117,7 @@ print_stats(void)
{
long stdin_pos;
if ((stdin_pos = ftell(stdin)) == -1)
- err(ERR(), NULL);
+ err(EXIT_FAILURE, NULL);
printf ("%d %d %d @%ld\n", freq_data, freq_separator,
FREQ_DATA_THRESHOLD, stdin_pos - sizeof(frame));
}