/*
* Copyright (c) 2003 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
/*
* Support for autoconfiguration of RAID sets on ATA RAID controllers.
*/
/*
* Register a finalizer which will be used to actually configure
* the logical disks configured by ataraid.
*/
finalize_done = 0;
if (config_finalize_register(NULL, ata_raid_finalize) != 0)
aprint_normal("WARNING: "
"unable to register ATA RAID finalizer\n");
}
/*
* Use the config_finalizer to rescan for new devices, since the
* ld_ataraid driver might not be immediately available.
*/
/* ARGSUSED */
static int
ataraid_rescan(device_t self, const char *ifattr, const int *locs)
{
finalize_done = 0;
(void)ata_raid_finalize(self);
return 0;
}
/*
* ata_raid_type_name:
*
* Return the type of ATA RAID.
*/
const char *
ata_raid_type_name(u_int type)
{
static const char *ata_raid_type_names[] = {
"Promise",
"Adaptec",
"VIA V-RAID",
"nVidia",
"JMicron",
"Intel MatrixRAID"
};
if (type < __arraycount(ata_raid_type_names))
return ata_raid_type_names[type];
/*
* Only run once for each instantiation
*/
if (finalize_done)
return 0;
finalize_done = 1;
if (TAILQ_EMPTY(&ataraid_array_info_list))
goto out;
if (config_attach_pseudo(&ataraid_cfdata) == NULL)
printf("%s: unable to attach an instance\n",
ataraid_cd.cd_name);
out:
return 1;
}
/*
* ataraid_match:
*
* Autoconfiguration glue: match routine.
*/
static int
ataraid_match(device_t parent, cfdata_t cf, void *aux)
{
/* pseudo-device; always present */
return 1;
}
/*
* ataraid_attach:
*
* Autoconfiguration glue: attach routine. We attach the children.
*/
static void
ataraid_attach(device_t parent, device_t self, void *aux)
{
struct ataraid_array_info *aai;
int locs[ATARAIDCF_NLOCS];
/*
* We're a pseudo-device, so we get to announce our own
* presence.
*/
aprint_normal_dev(self, "found %u RAID volume%s\n",
ataraid_array_info_count,
ataraid_array_info_count == 1 ? "" : "s");