ofw_disk.c revision 67204
1f/* 2 * Copyright (C) 2000 Benno Rice. 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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 * $FreeBSD: head/sys/boot/ofw/libofw/ofw_disk.c 67204 2000-10-16 10:46:22Z obrien $ 26 */ 27 28/* 29 * Disk I/O routines using Open Firmware 30 */ 31 32#include <sys/param.h> 33#include <sys/disklabel.h> 34#include <sys/disklabel_mbr.h> 35 36#include <netinet/in.h> 37 38#include <stand.h> 39 40#include "bootstrap.h" 41#include "libofw.h" 42#include "openfirm.h" 43 44static int ofwd_init(void); 45static int ofwd_strategy(void *devdata, int flag, daddr_t dblk, 46 size_t size, char *buf, size_t *rsize); 47static int ofwd_open(struct open_file *f, ...); 48static int ofwd_close(struct open_file *f); 49static void ofwd_print(int verbose); 50 51struct devsw ofwdisk = { 52 "disk", 53 DEVT_DISK, 54 ofwd_init, 55 ofwd_strategy, 56 ofwd_open, 57 ofwd_close, 58 noioctl, 59 ofwd_print 60}; 61 62static struct ofwdinfo { 63 int ofwd_unit; 64 char ofwd_path[255]; 65} ofwdinfo[MAXDEV]; 66static int nofwdinfo = 0; 67 68static int 69ofwd_init(void) 70{ 71 int ret; 72 char devpath[255]; 73 ihandle_t instance; 74 75 ofw_devsearch_init(); 76 while((ret = ofw_devsearch("block", devpath)) != 0) { 77 if (ret == -1) 78 return (1); 79 80 instance = OF_open(devpath); 81 if (instance != -1) { 82 ofwdinfo[nofwdinfo].ofwd_unit = nofwdinfo; 83 strncpy(ofwdinfo[nofwdinfo].ofwd_path, devpath, 255); 84 printf("disk%d is %s\n", nofwdinfo, devpath); 85 nofwdinfo++; 86 OF_close(instance); 87 } 88 89 if (nofwdinfo > MAXDEV) { 90 printf("Hit MAXDEV probing disks.\n"); 91 return (1); 92 } 93 } 94 95 return (0); 96} 97 98static int 99ofwd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, 100 size_t *rsize) 101{ 102 return (0); 103} 104 105static int 106ofwd_open(struct open_file *f, ...) 107{ 108 return (0); 109} 110 111static int 112ofwd_close(struct open_file *f) 113{ 114 return (0); 115} 116 117static void 118ofwd_print(int verbose) 119{ 120 printf("ofwd_print called.\n"); 121 return; 122} 123