/* $NetBSD: madt.c,v 1.6 2023/07/13 18:43:34 mrg Exp $ */
/*-
* Copyright (c) 2001 Doug Rabson
* All rights reserved.
*
* 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 AUTHOR 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 AUTHOR 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.
*
* $FreeBSD: src/sys/ia64/acpica/madt.c,v 1.20 2007/03/22 18:16:42 jkim Exp $
*/
/* Save the address of the processor interrupt block. */
if (bootverbose)
printf("\tLocal APIC address=0x%x\n", table->Address);
ia64_lapic_address = table->Address;
if (table->Flags & ACPI_MADT_PCAT_COMPAT)
has_i8259 = 1;
end = (char *)table + table->Header.Length;
p = (char *)(table + 1);
while (p < end) {
entry = (ACPI_SUBTABLE_HEADER *)p;
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
{
ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic =
(ACPI_MADT_LOCAL_APIC_OVERRIDE *)entry;
ia64_lapic_address = lapic->Address;
break;
}
#ifdef MULTIPROCESSOR
case ACPI_MADT_TYPE_LOCAL_SAPIC:
{
ACPI_MADT_LOCAL_SAPIC *sapic =
(ACPI_MADT_LOCAL_SAPIC *)entry;
if (sapic->LapicFlags & ACPI_MADT_ENABLED)
cpu_mp_add(sapic->ProcessorId,
sapic->Id, sapic->Eid);
break;
}
#endif
default:
break;
}
p += entry->Length;
}
}
}
/*
* Count the number of local SAPIC entries in the APIC table. Every enabled
* entry corresponds to a processor.
*/
int
ia64_count_cpus(void)
{
ACPI_PHYSICAL_ADDRESS rsdp_ptr;
ACPI_MADT_LOCAL_SAPIC *entry;
ACPI_TABLE_MADT *table;
ACPI_TABLE_RSDP *rsdp;
ACPI_TABLE_XSDT *xsdt;
char *end, *p;
int cpus, t, tables;
if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
return 0;