1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 14 unchanged lines hidden (view full) ---
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/aac/aac_disk.c 125975 2004-02-18 21:36:53Z phk $");
32
33#include "opt_aac.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/sysctl.h>
39
--- 312 unchanged lines hidden (view full) ---
352 sc->ad_cylinders = (sc->ad_size / (sc->ad_heads * sc->ad_sectors));
353
354 device_printf(dev, "%uMB (%u sectors)\n",
355 sc->ad_size / ((1024 * 1024) / AAC_BLOCK_SIZE),
356 sc->ad_size);
357
358 /* attach a generic disk device to ourselves */
359 sc->unit = device_get_unit(dev);
360 sc->ad_disk = disk_alloc();
361 sc->ad_disk->d_drv1 = sc;
362 sc->ad_disk->d_name = "aacd";
363 sc->ad_disk->d_maxsize = aac_iosize_max;
364 sc->ad_disk->d_open = aac_disk_open;
365 sc->ad_disk->d_close = aac_disk_close;
366 sc->ad_disk->d_strategy = aac_disk_strategy;
367 sc->ad_disk->d_dump = aac_disk_dump;
368 sc->ad_disk->d_sectorsize = AAC_BLOCK_SIZE;
369 sc->ad_disk->d_mediasize = (off_t)sc->ad_size * AAC_BLOCK_SIZE;
370 sc->ad_disk->d_fwsectors = sc->ad_sectors;
371 sc->ad_disk->d_fwheads = sc->ad_heads;
372 sc->ad_disk->d_unit = sc->unit;
373 disk_create(sc->ad_disk, DISK_VERSION);
374
375 return (0);
376}
377
378/*
379 * Disconnect ourselves from the system.
380 */
381static int
382aac_disk_detach(device_t dev)
383{
384 struct aac_disk *sc;
385
386 debug_called(2);
387
388 sc = (struct aac_disk *)device_get_softc(dev);
389
390 if (sc->ad_flags & AAC_DISK_OPEN)
391 return(EBUSY);
392
393 disk_destroy(sc->ad_disk);
394
395 return(0);
396}
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 14 unchanged lines hidden (view full) ---
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/aac/aac_disk.c 125975 2004-02-18 21:36:53Z phk $");
32
33#include "opt_aac.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/sysctl.h>
39
--- 312 unchanged lines hidden (view full) ---
352 sc->ad_cylinders = (sc->ad_size / (sc->ad_heads * sc->ad_sectors));
353
354 device_printf(dev, "%uMB (%u sectors)\n",
355 sc->ad_size / ((1024 * 1024) / AAC_BLOCK_SIZE),
356 sc->ad_size);
357
358 /* attach a generic disk device to ourselves */
359 sc->unit = device_get_unit(dev);
360 sc->ad_disk = disk_alloc();
361 sc->ad_disk->d_drv1 = sc;
362 sc->ad_disk->d_name = "aacd";
363 sc->ad_disk->d_maxsize = aac_iosize_max;
364 sc->ad_disk->d_open = aac_disk_open;
365 sc->ad_disk->d_close = aac_disk_close;
366 sc->ad_disk->d_strategy = aac_disk_strategy;
367 sc->ad_disk->d_dump = aac_disk_dump;
368 sc->ad_disk->d_sectorsize = AAC_BLOCK_SIZE;
369 sc->ad_disk->d_mediasize = (off_t)sc->ad_size * AAC_BLOCK_SIZE;
370 sc->ad_disk->d_fwsectors = sc->ad_sectors;
371 sc->ad_disk->d_fwheads = sc->ad_heads;
372 sc->ad_disk->d_unit = sc->unit;
373 disk_create(sc->ad_disk, DISK_VERSION);
374
375 return (0);
376}
377
378/*
379 * Disconnect ourselves from the system.
380 */
381static int
382aac_disk_detach(device_t dev)
383{
384 struct aac_disk *sc;
385
386 debug_called(2);
387
388 sc = (struct aac_disk *)device_get_softc(dev);
389
390 if (sc->ad_flags & AAC_DISK_OPEN)
391 return(EBUSY);
392
393 disk_destroy(sc->ad_disk);
394
395 return(0);
396}