1/*- 2 * Copyright (c) 1999 Jonathan Lemon 3 * Copyright (c) 1999, 2000 Michael Smith 4 * Copyright (c) 2000 BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 42 unchanged lines hidden (view full) --- 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55 * SUCH DAMAGE. 56 */ 57 58#include <sys/cdefs.h> |
59__FBSDID("$FreeBSD: head/sys/dev/amr/amr_disk.c 125975 2004-02-18 21:36:53Z phk $"); |
60 61/* 62 * Disk driver for AMI MegaRaid controllers 63 */ 64 65#include <sys/param.h> 66#include <sys/systm.h> 67#include <sys/kernel.h> --- 61 unchanged lines hidden (view full) --- 129 label->d_type = DTYPE_SCSI; 130 label->d_secsize = AMR_BLKSIZE; 131 label->d_nsectors = sc->amrd_drive->al_sectors; 132 label->d_ntracks = sc->amrd_drive->al_heads; 133 label->d_ncylinders = sc->amrd_drive->al_cylinders; 134 label->d_secpercyl = sc->amrd_drive->al_sectors * sc->amrd_drive->al_heads; 135 label->d_secperunit = sc->amrd_drive->al_size; 136#else |
137 sc->amrd_disk->d_sectorsize = AMR_BLKSIZE; 138 sc->amrd_disk->d_mediasize = (off_t)sc->amrd_drive->al_size * AMR_BLKSIZE; 139 sc->amrd_disk->d_fwsectors = sc->amrd_drive->al_sectors; 140 sc->amrd_disk->d_fwheads = sc->amrd_drive->al_heads; |
141#endif 142 143 return (0); 144} 145/******************************************************************************** 146 * System crashdump support 147 */ 148 --- 93 unchanged lines hidden (view full) --- 242 sc->amrd_drive = device_get_ivars(dev); 243 sc->amrd_dev = dev; 244 245 device_printf(dev, "%uMB (%u sectors) RAID %d (%s)\n", 246 sc->amrd_drive->al_size / ((1024 * 1024) / AMR_BLKSIZE), 247 sc->amrd_drive->al_size, sc->amrd_drive->al_properties & AMR_DRV_RAID_MASK, 248 amr_describe_code(amr_table_drvstate, AMR_DRV_CURSTATE(sc->amrd_drive->al_state))); 249 |
250 sc->amrd_disk = disk_alloc(); 251 sc->amrd_disk->d_drv1 = sc; 252 sc->amrd_disk->d_maxsize = (AMR_NSEG - 1) * PAGE_SIZE; 253 sc->amrd_disk->d_open = amrd_open; 254 sc->amrd_disk->d_strategy = amrd_strategy; 255 sc->amrd_disk->d_name = "amrd"; 256 sc->amrd_disk->d_dump = (dumper_t *)amrd_dump; 257 sc->amrd_disk->d_unit = sc->amrd_unit; 258 sc->amrd_disk->d_flags = DISKFLAG_NEEDSGIANT; 259 disk_create(sc->amrd_disk, DISK_VERSION); |
260#ifdef FREEBSD_4 261 disks_registered++; 262#endif 263 264 return (0); 265} 266 267static int 268amrd_detach(device_t dev) 269{ 270 struct amrd_softc *sc = (struct amrd_softc *)device_get_softc(dev); 271 272 debug_called(1); 273 |
274 if (sc->amrd_disk->d_flags & DISKFLAG_OPEN) |
275 return(EBUSY); 276 277#ifdef FREEBSD_4 278 if (--disks_registered == 0) 279 cdevsw_remove(&amrddisk_cdevsw); 280#else |
281 disk_destroy(sc->amrd_disk); |
282#endif 283 return(0); 284} 285 |