1/*- 2 * Written by: David Jeffery 3 * Copyright (c) 2002 Adaptec Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/ips/ips_disk.c 125975 2004-02-18 21:36:53Z phk $"); |
30 31#include <dev/ips/ips.h> 32#include <dev/ips/ips_disk.h> 33#include <sys/stat.h> 34 35static int ipsd_probe(device_t dev); 36static int ipsd_attach(device_t dev); 37static int ipsd_detach(device_t dev); --- 79 unchanged lines hidden (view full) --- 117 118 dsc = (ipsdisk_softc_t *)device_get_softc(dev); 119 bzero(dsc, sizeof(ipsdisk_softc_t)); 120 adapter = device_get_parent(dev); 121 dsc->dev = dev; 122 dsc->sc = device_get_softc(adapter); 123 dsc->unit = device_get_unit(dev); 124 dsc->disk_number = (uintptr_t) device_get_ivars(dev); |
125 dsc->ipsd_disk = disk_alloc(); 126 dsc->ipsd_disk->d_drv1 = dsc; 127 dsc->ipsd_disk->d_name = "ipsd"; 128 dsc->ipsd_disk->d_maxsize = IPS_MAX_IO_SIZE; 129 dsc->ipsd_disk->d_open = ipsd_open; 130 dsc->ipsd_disk->d_close = ipsd_close; 131 dsc->ipsd_disk->d_strategy = ipsd_strategy; |
132 133 totalsectors = dsc->sc->drives[dsc->disk_number].sector_count; 134 if ((totalsectors > 0x400000) && 135 ((dsc->sc->adapter_info.miscflags & 0x8) == 0)) { |
136 dsc->ipsd_disk->d_fwheads = IPS_NORM_HEADS; 137 dsc->ipsd_disk->d_fwsectors = IPS_NORM_SECTORS; |
138 } else { |
139 dsc->ipsd_disk->d_fwheads = IPS_COMP_HEADS; 140 dsc->ipsd_disk->d_fwsectors = IPS_COMP_SECTORS; |
141 } |
142 dsc->ipsd_disk->d_sectorsize = IPS_BLKSIZE; 143 dsc->ipsd_disk->d_mediasize = (off_t)totalsectors * IPS_BLKSIZE; 144 dsc->ipsd_disk->d_unit = dsc->unit; 145 dsc->ipsd_disk->d_flags = DISKFLAG_NEEDSGIANT; 146 disk_create(dsc->ipsd_disk, DISK_VERSION); |
147 148 device_printf(dev, "Logical Drive (%dMB)\n", 149 dsc->sc->drives[dsc->disk_number].sector_count >> 11); 150 return 0; 151} 152 153static int ipsd_detach(device_t dev) 154{ 155 ipsdisk_softc_t *dsc; 156 157 DEVICE_PRINTF(2, dev,"in detach\n"); 158 dsc = (ipsdisk_softc_t *)device_get_softc(dev); 159 if(dsc->state & IPS_DEV_OPEN) 160 return (EBUSY); |
161 disk_destroy(dsc->ipsd_disk); |
162 return 0; 163} 164 |