diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-19 21:10:20 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-19 21:10:20 +0000 |
commit | 66ac30863aa486b48a3d662e547c0001136ae215 (patch) | |
tree | b4e420a9ed840907ac6b7fdcc773a94cf86914fb /sys/arch | |
parent | f5ef959b5645e3464d0fa350ba37e18edd599934 (diff) |
Since a part of the nvram may be write-protected on some machines, check
the nvram writes and return EROFS if one or more bytes were found to be
immutable.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/aviion/dev/nvram.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/arch/aviion/dev/nvram.c b/sys/arch/aviion/dev/nvram.c index 67fa1ae4227..23990e6320a 100644 --- a/sys/arch/aviion/dev/nvram.c +++ b/sys/arch/aviion/dev/nvram.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvram.c,v 1.2 2006/05/21 12:22:02 miod Exp $ */ +/* $OpenBSD: nvram.c,v 1.3 2006/06/19 21:10:19 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -566,11 +566,27 @@ nvramwrite(dev_t dev, struct uio *uio, int flags) dest = (u_int32_t *)bus_space_vaddr(sc->sc_iot, sc->sc_ioh); cnt = sc->sc_len; while (cnt-- != 0) { - if ((*dest & 0xff) != *src) + if ((*dest & 0xff) != *src) { *dest = (u_int32_t)*src; + /* + * A jumper on the motherboard may write-protect + * the 0x80 bytes at offset 0x80 (i.e. addresses + * 0x200-0x3ff), so check our write had successed. + * If it failed, discard the remainder of the changes + * and return EROFS. + */ + if ((*dest & 0xff) != *src) + rc = EROFS; + } + } dest++; src++; } - return (0); + if (rc != 0) { + /* reset NVRAM copy contents */ + read_nvram(sc); + } + + return (rc); } |