Deleted Added
sdiff udiff text old ( 120329 ) new ( 125975 )
full compact
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 120329 2003-09-22 04:59:07Z njl $");
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.d_drv1 = dsc;
126 dsc->ipsd_disk.d_name = "ipsd";
127 dsc->ipsd_disk.d_maxsize = IPS_MAX_IO_SIZE;
128 dsc->ipsd_disk.d_open = ipsd_open;
129 dsc->ipsd_disk.d_close = ipsd_close;
130 dsc->ipsd_disk.d_strategy = ipsd_strategy;
131
132 totalsectors = dsc->sc->drives[dsc->disk_number].sector_count;
133 if ((totalsectors > 0x400000) &&
134 ((dsc->sc->adapter_info.miscflags & 0x8) == 0)) {
135 dsc->ipsd_disk.d_fwheads = IPS_NORM_HEADS;
136 dsc->ipsd_disk.d_fwsectors = IPS_NORM_SECTORS;
137 } else {
138 dsc->ipsd_disk.d_fwheads = IPS_COMP_HEADS;
139 dsc->ipsd_disk.d_fwsectors = IPS_COMP_SECTORS;
140 }
141 dsc->ipsd_disk.d_sectorsize = IPS_BLKSIZE;
142 dsc->ipsd_disk.d_mediasize = (off_t)totalsectors * IPS_BLKSIZE;
143 disk_create(dsc->unit, &dsc->ipsd_disk, 0, NULL, NULL);
144
145 device_printf(dev, "Logical Drive (%dMB)\n",
146 dsc->sc->drives[dsc->disk_number].sector_count >> 11);
147 return 0;
148}
149
150static int ipsd_detach(device_t dev)
151{
152 ipsdisk_softc_t *dsc;
153
154 DEVICE_PRINTF(2, dev,"in detach\n");
155 dsc = (ipsdisk_softc_t *)device_get_softc(dev);
156 if(dsc->state & IPS_DEV_OPEN)
157 return (EBUSY);
158 disk_destroy(&dsc->ipsd_disk);
159 return 0;
160}
161