1/* $NetBSD: acpi_srat.h,v 1.3 2010/03/05 08:30:48 jruoho Exp $ */
2
3/*
4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christoph Egger.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _SYS_DEV_ACPI_ACPI_SRAT_H
33#define _SYS_DEV_ACPI_ACPI_SRAT_H
34
35typedef uint32_t acpisrat_nodeid_t;
36
37struct acpisrat_cpu {
38 acpisrat_nodeid_t nodeid;
39 uint32_t apicid;
40 uint32_t sapiceid;
41 uint32_t flags;
42
43 /* clockdomain has a meaningful value when the ACPI MADT table has
44 * ACPI_MADT_TYPE_LOCAL_X2APIC and/or ACPI_MADT_TYPE_LOCAL_X2APIC_NMI
45 * entries or ACPI CPU device have a _CDM.
46 */
47 uint32_t clockdomain;
48};
49
50struct acpisrat_mem {
51 acpisrat_nodeid_t nodeid;
52 uint64_t baseaddress;
53 uint64_t length;
54 uint32_t flags;
55};
56
57/* Returns true if ACPI SRAT table is available.
58 *
59 * If table does not exist, all functions below
60 * have undefined behaviour.
61 */
62bool acpisrat_exist(void);
63
64/* Initializes parser. Must be the first function
65 * being called when table is available.
66 */
67int acpisrat_init(void);
68
69/* Re-parse ACPI SRAT table. Useful after
70 * hotplugging cpu or RAM.
71 */
72int acpisrat_refresh(void);
73
74/* Free allocated memory. Should be called
75 * when acpisrat is no longer of any use.
76 */
77int acpisrat_exit(void);
78
79void acpisrat_dump(void);
80
81/* Get number of NUMA nodes */
82uint32_t acpisrat_nodes(void);
83
84/* Get number of cpus in the node.
85 * 0 means, this is a cpu-less node.
86 */
87uint32_t acpisrat_node_cpus(acpisrat_nodeid_t);
88
89/* Get number of memory ranges in the node
90 * 0 means, this node has no RAM.
91 */
92uint32_t acpisrat_node_memoryranges(acpisrat_nodeid_t);
93
94/* Retrieve cpu and memory info. */
95void acpisrat_cpu(acpisrat_nodeid_t, uint32_t cpunum, struct acpisrat_cpu *);
96void acpisrat_mem(acpisrat_nodeid_t, uint32_t memrange, struct acpisrat_mem *);
97
98#endif /* !_SYS_DEV_ACPI_ACPI_SRAT_H */
99