/* $NetBSD: ld_amr.c,v 1.26 2025/04/13 02:34:03 rin Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* AMI RAID controller front-end for ld(4) driver.
*/
if (ld->sc_maxqueuecnt > AMR_MAX_CMDS_PU)
ld->sc_maxqueuecnt = AMR_MAX_CMDS_PU;
/*
* Print status information and attach to the ld driver proper.
*/
statestr = amr_drive_state(amr->amr_drive[sc->sc_hwunit].al_state,
&happy);
if (happy)
ld->sc_flags = LDF_ENABLED;
aprint_normal(": RAID %d, %s\n",
amr->amr_drive[sc->sc_hwunit].al_properties & AMR_DRV_RAID_MASK,
statestr);
if (bp == NULL) {
/*
* Polled commands must not sit on the software queue. Wait
* up to 30 seconds for the command to complete.
*/
rv = amr_ccb_poll(amr, ac, 30000);
amr_ccb_unmap(amr, ac);
amr_ccb_free(amr, ac);
} else {
ac->ac_handler = ld_amr_handler;
ac->ac_context = bp;
ac->ac_dv = sc->sc_ld.sc_dv;
amr_ccb_enqueue(amr, ac);
rv = 0;
}
#ifdef _MODULE
/*
* XXX Don't allow ioconf.c to redefine the "struct cfdriver ld_cd"
* XXX it will be defined in the common-code module
*/
#undef CFDRIVER_DECL
#define CFDRIVER_DECL(name, class, attr)
#include "ioconf.c"
#endif
static int
ld_amr_modcmd(modcmd_t cmd, void *opaque)
{
#ifdef _MODULE
/*
* We ignore the cfdriver_vec[] that ioconf provides, since
* the cfdrivers are attached already.
*/
static struct cfdriver * const no_cfdriver_vec[] = { NULL };
#endif
int error = 0;