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 120988 2003-10-10 22:49:40Z ps $");
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.d_drv1 = sc;
251 sc->amrd_disk.d_maxsize = (AMR_NSEG - 1) * PAGE_SIZE;
252 sc->amrd_disk.d_open = amrd_open;
253 sc->amrd_disk.d_strategy = amrd_strategy;
254 sc->amrd_disk.d_name = "amrd";
255 sc->amrd_disk.d_dump = (dumper_t *)amrd_dump;
256 disk_create(sc->amrd_unit, &sc->amrd_disk, 0, NULL, NULL);
257#ifdef FREEBSD_4
258 disks_registered++;
259#endif
260
261 return (0);
262}
263
264static int
265amrd_detach(device_t dev)
266{
267 struct amrd_softc *sc = (struct amrd_softc *)device_get_softc(dev);
268
269 debug_called(1);
270
271 if (sc->amrd_disk.d_flags & DISKFLAG_OPEN)
272 return(EBUSY);
273
274#ifdef FREEBSD_4
275 if (--disks_registered == 0)
276 cdevsw_remove(&amrddisk_cdevsw);
277#else
278 disk_destroy(&sc->amrd_disk);
279#endif
280 return(0);
281}
282
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 120988 2003-10-10 22:49:40Z ps $");
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.d_drv1 = sc;
251 sc->amrd_disk.d_maxsize = (AMR_NSEG - 1) * PAGE_SIZE;
252 sc->amrd_disk.d_open = amrd_open;
253 sc->amrd_disk.d_strategy = amrd_strategy;
254 sc->amrd_disk.d_name = "amrd";
255 sc->amrd_disk.d_dump = (dumper_t *)amrd_dump;
256 disk_create(sc->amrd_unit, &sc->amrd_disk, 0, NULL, NULL);
257#ifdef FREEBSD_4
258 disks_registered++;
259#endif
260
261 return (0);
262}
263
264static int
265amrd_detach(device_t dev)
266{
267 struct amrd_softc *sc = (struct amrd_softc *)device_get_softc(dev);
268
269 debug_called(1);
270
271 if (sc->amrd_disk.d_flags & DISKFLAG_OPEN)
272 return(EBUSY);
273
274#ifdef FREEBSD_4
275 if (--disks_registered == 0)
276 cdevsw_remove(&amrddisk_cdevsw);
277#else
278 disk_destroy(&sc->amrd_disk);
279#endif
280 return(0);
281}
282