beri_disk_cfi.c (313355) | beri_disk_cfi.c (328889) |
---|---|
1/*- 2 * Copyright (c) 2013-2014 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 15 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2013-2014 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 15 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c 313355 2017-02-06 22:03:07Z tsoome $"); | 32__FBSDID("$FreeBSD: stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c 328889 2018-02-05 17:01:18Z kevans $"); |
33 34#include <sys/param.h> 35 36#include <bootstrap.h> 37#include <stdarg.h> 38 39#include <stand.h> 40#include <disk.h> 41 42#include <cfi.h> 43 44static int beri_cfi_disk_init(void); 45static int beri_cfi_disk_open(struct open_file *, ...); 46static int beri_cfi_disk_close(struct open_file *); 47static void beri_cfi_disk_cleanup(void); 48static int beri_cfi_disk_strategy(void *, int, daddr_t, size_t, 49 char *, size_t *); | 33 34#include <sys/param.h> 35 36#include <bootstrap.h> 37#include <stdarg.h> 38 39#include <stand.h> 40#include <disk.h> 41 42#include <cfi.h> 43 44static int beri_cfi_disk_init(void); 45static int beri_cfi_disk_open(struct open_file *, ...); 46static int beri_cfi_disk_close(struct open_file *); 47static void beri_cfi_disk_cleanup(void); 48static int beri_cfi_disk_strategy(void *, int, daddr_t, size_t, 49 char *, size_t *); |
50static void beri_cfi_disk_print(int); | 50static int beri_cfi_disk_print(int); |
51 52struct devsw beri_cfi_disk = { 53 .dv_name = "cfi", 54 .dv_type = DEVT_DISK, 55 .dv_init = beri_cfi_disk_init, 56 .dv_strategy = beri_cfi_disk_strategy, 57 .dv_open = beri_cfi_disk_open, 58 .dv_close = beri_cfi_disk_close, --- 48 unchanged lines hidden (view full) --- 107beri_cfi_disk_close(struct open_file *f) 108{ 109 struct disk_devdesc *dev; 110 111 dev = (struct disk_devdesc *)f->f_devdata; 112 return (disk_close(dev)); 113} 114 | 51 52struct devsw beri_cfi_disk = { 53 .dv_name = "cfi", 54 .dv_type = DEVT_DISK, 55 .dv_init = beri_cfi_disk_init, 56 .dv_strategy = beri_cfi_disk_strategy, 57 .dv_open = beri_cfi_disk_open, 58 .dv_close = beri_cfi_disk_close, --- 48 unchanged lines hidden (view full) --- 107beri_cfi_disk_close(struct open_file *f) 108{ 109 struct disk_devdesc *dev; 110 111 dev = (struct disk_devdesc *)f->f_devdata; 112 return (disk_close(dev)); 113} 114 |
115static void | 115static int |
116beri_cfi_disk_print(int verbose) 117{ 118 struct disk_devdesc dev; 119 char line[80]; | 116beri_cfi_disk_print(int verbose) 117{ 118 struct disk_devdesc dev; 119 char line[80]; |
120 int ret; |
|
120 | 121 |
121 sprintf(line, " cfi%d CFI flash device\n", 0); 122 pager_output(line); | 122 printf("%s devices:", beri_cfi_disk.dv_name); 123 if ((ret = pager_output("\n")) != 0) 124 return (ret); 125 126 snprintf(line, sizeof(line), " cfi%d CFI flash device\n", 0); 127 ret = pager_output(line); 128 if (ret != 0) 129 return (ret); |
123 dev.d_dev = &beri_cfi_disk; 124 dev.d_unit = 0; 125 dev.d_slice = -1; 126 dev.d_partition = -1; 127 if (disk_open(&dev, cfi_get_mediasize(), 128 cfi_get_sectorsize(), 0) == 0) { | 130 dev.d_dev = &beri_cfi_disk; 131 dev.d_unit = 0; 132 dev.d_slice = -1; 133 dev.d_partition = -1; 134 if (disk_open(&dev, cfi_get_mediasize(), 135 cfi_get_sectorsize(), 0) == 0) { |
129 sprintf(line, " cfi%d", 0); 130 disk_print(&dev, line, verbose); | 136 snprintf(line, sizeof(line), " cfi%d", 0); 137 ret = disk_print(&dev, line, verbose); |
131 disk_close(&dev); 132 } 133 | 138 disk_close(&dev); 139 } 140 |
141 return (ret); |
|
134} 135 136static void 137beri_cfi_disk_cleanup(void) 138{ 139 140 disk_cleanup(&beri_cfi_disk); 141} | 142} 143 144static void 145beri_cfi_disk_cleanup(void) 146{ 147 148 disk_cleanup(&beri_cfi_disk); 149} |