| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: flash.c,v 1.8 2011/07/15 19:19:57 cliff Exp $ */ | | 1 | /* $NetBSD: flash.c,v 1.9 2011/07/29 20:48:33 ahoka Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 Department of Software Engineering, | | 4 | * Copyright (c) 2011 Department of Software Engineering, |
5 | * University of Szeged, Hungary | | 5 | * University of Szeged, Hungary |
6 | * Copyright (c) 2011 Adam Hoka <ahoka@NetBSD.org> | | 6 | * Copyright (c) 2011 Adam Hoka <ahoka@NetBSD.org> |
7 | * Copyright (c) 2010 David Tengeri <dtengeri@inf.u-szeged.hu> | | 7 | * Copyright (c) 2010 David Tengeri <dtengeri@inf.u-szeged.hu> |
8 | * All rights reserved. | | 8 | * All rights reserved. |
9 | * | | 9 | * |
10 | * This code is derived from software contributed to The NetBSD Foundation | | 10 | * This code is derived from software contributed to The NetBSD Foundation |
11 | * by the Department of Software Engineering, University of Szeged, Hungary | | 11 | * by the Department of Software Engineering, University of Szeged, Hungary |
12 | * | | 12 | * |
13 | * Redistribution and use in source and binary forms, with or without | | 13 | * Redistribution and use in source and binary forms, with or without |
14 | * modification, are permitted provided that the following conditions | | 14 | * modification, are permitted provided that the following conditions |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | /*- | | 35 | /*- |
36 | * Framework for storage devices based on Flash technology | | 36 | * Framework for storage devices based on Flash technology |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | #include <sys/cdefs.h> | | 39 | #include <sys/cdefs.h> |
40 | __KERNEL_RCSID(0, "$NetBSD: flash.c,v 1.8 2011/07/15 19:19:57 cliff Exp $"); | | 40 | __KERNEL_RCSID(0, "$NetBSD: flash.c,v 1.9 2011/07/29 20:48:33 ahoka Exp $"); |
41 | | | 41 | |
42 | #include <sys/param.h> | | 42 | #include <sys/param.h> |
43 | #include <sys/types.h> | | 43 | #include <sys/types.h> |
44 | #include <sys/proc.h> | | 44 | #include <sys/proc.h> |
45 | #include <sys/errno.h> | | 45 | #include <sys/errno.h> |
46 | #include <sys/ioctl.h> | | 46 | #include <sys/ioctl.h> |
47 | #include <sys/device.h> | | 47 | #include <sys/device.h> |
48 | #include <sys/conf.h> | | 48 | #include <sys/conf.h> |
49 | #include <sys/kmem.h> | | 49 | #include <sys/kmem.h> |
50 | #include <sys/uio.h> | | 50 | #include <sys/uio.h> |
51 | #include <sys/kernel.h> | | 51 | #include <sys/kernel.h> |
52 | | | 52 | |
53 | #include <sys/atomic.h> | | 53 | #include <sys/atomic.h> |
| @@ -515,26 +515,36 @@ flash_get_softc(dev_t dev) | | | @@ -515,26 +515,36 @@ flash_get_softc(dev_t dev) |
515 | | | 515 | |
516 | device_t | | 516 | device_t |
517 | flash_get_device(dev_t dev) | | 517 | flash_get_device(dev_t dev) |
518 | { | | 518 | { |
519 | struct flash_softc *sc; | | 519 | struct flash_softc *sc; |
520 | int unit; | | 520 | int unit; |
521 | | | 521 | |
522 | unit = minor(dev); | | 522 | unit = minor(dev); |
523 | sc = device_lookup_private(&flash_cd, unit); | | 523 | sc = device_lookup_private(&flash_cd, unit); |
524 | | | 524 | |
525 | return sc->sc_dev; | | 525 | return sc->sc_dev; |
526 | } | | 526 | } |
527 | | | 527 | |
| | | 528 | flash_size_t |
| | | 529 | flash_get_size(dev_t dev) |
| | | 530 | { |
| | | 531 | const struct flash_softc *sc; |
| | | 532 | |
| | | 533 | sc = flash_get_softc(dev); |
| | | 534 | |
| | | 535 | return sc->sc_partinfo.part_size; |
| | | 536 | } |
| | | 537 | |
528 | static inline flash_off_t | | 538 | static inline flash_off_t |
529 | flash_get_part_offset(struct flash_softc * const sc, size_t poffset) | | 539 | flash_get_part_offset(struct flash_softc * const sc, size_t poffset) |
530 | { | | 540 | { |
531 | return sc->sc_partinfo.part_offset + poffset; | | 541 | return sc->sc_partinfo.part_offset + poffset; |
532 | } | | 542 | } |
533 | | | 543 | |
534 | int | | 544 | int |
535 | flash_erase(device_t self, struct flash_erase_instruction * const ei) | | 545 | flash_erase(device_t self, struct flash_erase_instruction * const ei) |
536 | { | | 546 | { |
537 | struct flash_softc * const sc = device_private(self); | | 547 | struct flash_softc * const sc = device_private(self); |
538 | KASSERT(ei != NULL); | | 548 | KASSERT(ei != NULL); |
539 | struct flash_erase_instruction e = *ei; | | 549 | struct flash_erase_instruction e = *ei; |
540 | | | 550 | |