/* $NetBSD: cpunode.c,v 1.8 2021/08/07 16:19:02 thorpej Exp $ */
/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
* Agency and which was developed by Matt Thomas of 3am Software Foundry.
*
* This material is based upon work supported by the Defense Advanced Research
* Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
* Contract No. N66001-09-C-2073.
* Approved for Public Release, Distribution Unlimited
*
* 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.
*/
for (u_int childmask = 1; cnl->cnl_name != NULL; cnl++) {
bool inclusive = true;
bool found = (cnl->cnl_ids[0] == 0);
#if DEBUG > 1
aprint_normal_dev(self, "dev=%s[%u], addr=%x@%x",
cnl->cnl_name, cnl->cnl_instance, cnl->cnl_size,
cnl->cnl_addr);
if (cnl->cnl_nintr > 0) {
aprint_normal(", intrs=%u", cnl->cnl_intrs[0]);
for (u_int i = 1; i < cnl->cnl_nintr; i++)
aprint_normal(",%u", cnl->cnl_intrs[i]);
}
aprint_normal("\n");
#endif
for (u_int i = 0;
!found
&& i < __arraycount(cnl->cnl_ids)
&& cnl->cnl_ids[i] != 0;
i++) {
if (cnl->cnl_ids[i] == 0xffff) {
inclusive = false;
continue;
}
found = (cnl->cnl_ids[i] == my_id);
}
/*
* found & inclusive == match
* !found & !inclusive == match
* found & !inclusive == no match
* !found & inclusive == no match
* therefore
* found ^ inclusive = no match
* so
* !(found ^ inclusive) = match
*/
if (found ^ inclusive)
continue;