cfi_dev.c (188086) | cfi_dev.c (188156) |
---|---|
1/*- 2 * Copyright (c) 2007, Juniper Networks, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2007, Juniper Networks, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/cfi/cfi_dev.c 188086 2009-02-03 19:07:41Z sam $"); | 31__FBSDID("$FreeBSD: head/sys/dev/cfi/cfi_dev.c 188156 2009-02-05 18:12:07Z sam $"); |
32 | 32 |
33#include "opt_cfi.h" 34 |
|
33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/bus.h> 36#include <sys/conf.h> 37#include <sys/ioccom.h> 38#include <sys/kernel.h> 39#include <sys/malloc.h> 40#include <sys/proc.h> --- 209 unchanged lines hidden (view full) --- 250 struct cfi_softc *sc; 251 struct cfiocqry *rq; 252 int error; 253 u_char val; 254 255 sc = dev->si_drv1; 256 error = 0; 257 | 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/bus.h> 38#include <sys/conf.h> 39#include <sys/ioccom.h> 40#include <sys/kernel.h> 41#include <sys/malloc.h> 42#include <sys/proc.h> --- 209 unchanged lines hidden (view full) --- 252 struct cfi_softc *sc; 253 struct cfiocqry *rq; 254 int error; 255 u_char val; 256 257 sc = dev->si_drv1; 258 error = 0; 259 |
258 switch(cmd) { | 260 switch (cmd) { |
259 case CFIOCQRY: 260 if (sc->sc_writing) { 261 error = cfi_block_finish(sc); 262 if (error) 263 break; 264 } | 261 case CFIOCQRY: 262 if (sc->sc_writing) { 263 error = cfi_block_finish(sc); 264 if (error) 265 break; 266 } |
265 | |
266 rq = (struct cfiocqry *)data; 267 if (rq->offset >= sc->sc_size / sc->sc_width) 268 return (ESPIPE); 269 if (rq->offset + rq->count > sc->sc_size / sc->sc_width) 270 return (ENOSPC); 271 272 while (!error && rq->count--) { 273 val = cfi_read_qry(sc, rq->offset++); 274 error = copyout(&val, rq->buffer++, 1); 275 } 276 break; | 267 rq = (struct cfiocqry *)data; 268 if (rq->offset >= sc->sc_size / sc->sc_width) 269 return (ESPIPE); 270 if (rq->offset + rq->count > sc->sc_size / sc->sc_width) 271 return (ENOSPC); 272 273 while (!error && rq->count--) { 274 val = cfi_read_qry(sc, rq->offset++); 275 error = copyout(&val, rq->buffer++, 1); 276 } 277 break; |
278#ifdef CFI_SUPPORT_STRATAFLASH 279 case CFIOCGFACTORYPR: 280 error = cfi_intel_get_factory_pr(sc, (uint64_t *)data); 281 break; 282 case CFIOCGOEMPR: 283 error = cfi_intel_get_oem_pr(sc, (uint64_t *)data); 284 break; 285 case CFIOCSOEMPR: 286 error = cfi_intel_set_oem_pr(sc, *(uint64_t *)data); 287 break; 288 case CFIOCGPLR: 289 error = cfi_intel_get_plr(sc, (uint32_t *)data); 290 break; 291 case CFIOCSPLR: 292 error = cfi_intel_set_plr(sc); 293 break; 294#endif /* CFI_SUPPORT_STRATAFLASH */ |
|
277 default: 278 error = ENOIOCTL; 279 break; 280 } 281 return (error); 282} | 295 default: 296 error = ENOIOCTL; 297 break; 298 } 299 return (error); 300} |