2 * Copyright (c) 2012 Robert N. M. Watson
3 * Copyright (c) 2012 SRI International
6 * This software was developed by SRI International and the University of
7 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
8 * ("CTSRD"), as part of the DARPA CRASH research programme.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 off_t ir_off; /* Offset of range to delete (set to 0xFF) */
39 size_t ir_size; /* Size of range */
42 #define ISF_ERASE _IOW('I', 1, struct isf_range)
45 * Ordinary read and write operations are limited to 512 bytes.
46 * We support erasing 128K blocks and ignore the fact that portions of the
47 * flash are in fact divided into 32K blocks.
49 #define ISF_SECTORSIZE (512)
50 #define ISF_ERASE_BLOCK (128 * 1024)
53 MALLOC_DECLARE(M_ISF);
63 struct resource *isf_res;
66 struct disk *isf_disk;
67 struct proc *isf_proc;
71 * Fields relating to in-progress and pending I/O, if any.
73 struct bio_queue_head isf_bioq;
74 uint16_t isf_rbuf[ISF_SECTORSIZE / 2];
76 enum bstate *isf_bstate;
79 #define ISF_LOCK(sc) mtx_lock(&(sc)->isf_lock)
80 #define ISF_LOCK_ASSERT(sc) mtx_assert(&(sc)->isf_lock, MA_OWNED)
81 #define ISF_LOCK_DESTROY(sc) mtx_destroy(&(sc)->isf_lock)
82 #define ISF_LOCK_INIT(sc) mtx_init(&(sc)->isf_lock, "isf", NULL, \
84 #define ISF_SLEEP(sc, wait, timo) mtx_sleep((wait), \
85 &(sc)->isf_lock, PRIBIO, \
87 #define ISF_UNLOCK(sc) mtx_unlock(&(sc)->isf_lock)
88 #define ISF_WAKEUP(sc) wakeup((sc))
90 int isf_attach(struct isf_softc *sc);
91 void isf_detach(struct isf_softc *sc);
93 extern devclass_t isf_devclass;
96 #endif /* _DEV_ISF_H_ */