1*a3114836SGerry Liu /* 2*a3114836SGerry Liu * CDDL HEADER START 3*a3114836SGerry Liu * 4*a3114836SGerry Liu * The contents of this file are subject to the terms of the 5*a3114836SGerry Liu * Common Development and Distribution License (the "License"). 6*a3114836SGerry Liu * You may not use this file except in compliance with the License. 7*a3114836SGerry Liu * 8*a3114836SGerry Liu * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*a3114836SGerry Liu * or http://www.opensolaris.org/os/licensing. 10*a3114836SGerry Liu * See the License for the specific language governing permissions 11*a3114836SGerry Liu * and limitations under the License. 12*a3114836SGerry Liu * 13*a3114836SGerry Liu * When distributing Covered Code, include this CDDL HEADER in each 14*a3114836SGerry Liu * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*a3114836SGerry Liu * If applicable, add the following below this CDDL HEADER, with the 16*a3114836SGerry Liu * fields enclosed by brackets "[]" replaced with your own identifying 17*a3114836SGerry Liu * information: Portions Copyright [yyyy] [name of copyright owner] 18*a3114836SGerry Liu * 19*a3114836SGerry Liu * CDDL HEADER END 20*a3114836SGerry Liu */ 21*a3114836SGerry Liu 22*a3114836SGerry Liu /* 23*a3114836SGerry Liu * Copyright (c) 2010, Intel Corporation. 24*a3114836SGerry Liu * All rights reserved. 25*a3114836SGerry Liu */ 26*a3114836SGerry Liu /* 27*a3114836SGerry Liu * Interfaces to support System Board Dynamic Reconfiguration. 28*a3114836SGerry Liu */ 29*a3114836SGerry Liu 30*a3114836SGerry Liu #ifndef _SYS_ACPIDEV_DR_H 31*a3114836SGerry Liu #define _SYS_ACPIDEV_DR_H 32*a3114836SGerry Liu #include <sys/types.h> 33*a3114836SGerry Liu #include <sys/obpdefs.h> 34*a3114836SGerry Liu #include <sys/cpuvar.h> 35*a3114836SGerry Liu #include <sys/memlist.h> 36*a3114836SGerry Liu #include <sys/sunddi.h> 37*a3114836SGerry Liu #include <sys/acpi/acpi.h> 38*a3114836SGerry Liu #include <sys/acpica.h> 39*a3114836SGerry Liu #include <sys/acpidev.h> 40*a3114836SGerry Liu #include <sys/acpidev_rsc.h> 41*a3114836SGerry Liu 42*a3114836SGerry Liu #ifdef __cplusplus 43*a3114836SGerry Liu extern "C" { 44*a3114836SGerry Liu #endif 45*a3114836SGerry Liu 46*a3114836SGerry Liu #ifdef _KERNEL 47*a3114836SGerry Liu 48*a3114836SGerry Liu /* Maximum number of DR capable system boards supported. */ 49*a3114836SGerry Liu #define ACPIDEV_DR_MAX_BOARDS 0x40 50*a3114836SGerry Liu #define ACPIDEV_DR_SEGS_PER_MEM_DEV 0x10 51*a3114836SGerry Liu #define ACPIDEV_DR_MEMLISTS_PER_SEG 0x10 52*a3114836SGerry Liu #define ACPIDEV_DR_MAX_MEMLIST_ENTRIES 0x10000 53*a3114836SGerry Liu 54*a3114836SGerry Liu #define ACPIDEV_DR_PROP_PORTID "portid" 55*a3114836SGerry Liu #define ACPIDEV_DR_PROP_BOARDNUM OBP_BOARDNUM 56*a3114836SGerry Liu #define ACPIDEV_DR_PROP_DEVNAME OBP_NAME 57*a3114836SGerry Liu 58*a3114836SGerry Liu /* 59*a3114836SGerry Liu * Format strings for DR capable system boards. 60*a3114836SGerry Liu * They will be used as attachment point names. 61*a3114836SGerry Liu */ 62*a3114836SGerry Liu #define ACPIDEV_DR_CPU_BD_FMT "CPU%u" 63*a3114836SGerry Liu #define ACPIDEV_DR_MEMORY_BD_FMT "MEM%u" 64*a3114836SGerry Liu #define ACPIDEV_DR_IO_BD_FMT "IO%u" 65*a3114836SGerry Liu #define ACPIDEV_DR_SYSTEM_BD_FMT "SB%u" 66*a3114836SGerry Liu 67*a3114836SGerry Liu typedef enum { 68*a3114836SGerry Liu ACPIDEV_INVALID_BOARD = 0, 69*a3114836SGerry Liu ACPIDEV_CPU_BOARD, 70*a3114836SGerry Liu ACPIDEV_MEMORY_BOARD, 71*a3114836SGerry Liu ACPIDEV_IO_BOARD, 72*a3114836SGerry Liu ACPIDEV_SYSTEM_BOARD 73*a3114836SGerry Liu } acpidev_board_type_t; 74*a3114836SGerry Liu 75*a3114836SGerry Liu /* Check whether the system is DR capable. */ 76*a3114836SGerry Liu extern int acpidev_dr_capable(void); 77*a3114836SGerry Liu 78*a3114836SGerry Liu extern uint32_t acpidev_dr_max_boards(void); 79*a3114836SGerry Liu extern uint32_t acpidev_dr_max_mem_units_per_board(void); 80*a3114836SGerry Liu extern uint32_t acpidev_dr_max_io_units_per_board(void); 81*a3114836SGerry Liu extern uint32_t acpidev_dr_max_cmp_units_per_board(void); 82*a3114836SGerry Liu extern uint32_t acpidev_dr_max_cpu_units_per_cmp(void); 83*a3114836SGerry Liu extern uint32_t acpidev_dr_max_segments_per_mem_device(void); 84*a3114836SGerry Liu extern uint32_t acpidev_dr_max_memlists_per_segment(void); 85*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_get_mem_alignment(ACPI_HANDLE hdl, uint64_t *ap); 86*a3114836SGerry Liu 87*a3114836SGerry Liu /* Initialize support of DR operations. */ 88*a3114836SGerry Liu extern void acpidev_dr_init(void); 89*a3114836SGerry Liu 90*a3114836SGerry Liu /* Scan for DR capable boards and setup environment for DR operations. */ 91*a3114836SGerry Liu extern void acpidev_dr_check(acpidev_walk_info_t *infop); 92*a3114836SGerry Liu 93*a3114836SGerry Liu /* 94*a3114836SGerry Liu * Initialize DR interfaces to enable DR operations. 95*a3114836SGerry Liu */ 96*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_initialize(dev_info_t *pdip); 97*a3114836SGerry Liu 98*a3114836SGerry Liu /* Get ACPI handle of the DR capable board. */ 99*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_get_board_handle(uint_t board, 100*a3114836SGerry Liu ACPI_HANDLE *hdlp); 101*a3114836SGerry Liu 102*a3114836SGerry Liu /* Get board type of the DR capable board. */ 103*a3114836SGerry Liu extern acpidev_board_type_t acpidev_dr_get_board_type(ACPI_HANDLE hdl); 104*a3114836SGerry Liu 105*a3114836SGerry Liu /* Get board number of the DR capable board. */ 106*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_get_board_number(ACPI_HANDLE hdl, 107*a3114836SGerry Liu uint32_t *bnump); 108*a3114836SGerry Liu 109*a3114836SGerry Liu /* Get board name of the DR capable board. */ 110*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_get_board_name(ACPI_HANDLE hdl, 111*a3114836SGerry Liu char *buf, size_t len); 112*a3114836SGerry Liu 113*a3114836SGerry Liu /* Get attachment point of the DR capable board. */ 114*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_get_attachment_point(ACPI_HANDLE hdl, 115*a3114836SGerry Liu char *buf, size_t len); 116*a3114836SGerry Liu 117*a3114836SGerry Liu /* 118*a3114836SGerry Liu * Figure out device type of the object/device. 119*a3114836SGerry Liu * It only supports device types which may be involved in DR operations. 120*a3114836SGerry Liu */ 121*a3114836SGerry Liu extern acpidev_class_id_t acpidev_dr_device_get_class(ACPI_HANDLE hdl); 122*a3114836SGerry Liu 123*a3114836SGerry Liu /* Get memory device index/id. */ 124*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_get_memory_index(ACPI_HANDLE hdl, 125*a3114836SGerry Liu uint32_t *idxp); 126*a3114836SGerry Liu 127*a3114836SGerry Liu /* Check whether the device is a DR capable board or not. */ 128*a3114836SGerry Liu extern int acpidev_dr_device_is_board(ACPI_HANDLE hdl); 129*a3114836SGerry Liu 130*a3114836SGerry Liu /* Check whether the device is present or not. */ 131*a3114836SGerry Liu extern int acpidev_dr_device_is_present(ACPI_HANDLE hdl); 132*a3114836SGerry Liu 133*a3114836SGerry Liu /* Check whether the device is powered-on or not. */ 134*a3114836SGerry Liu extern int acpidev_dr_device_is_powered(ACPI_HANDLE hdl); 135*a3114836SGerry Liu 136*a3114836SGerry Liu /* Check whether the device is DR capable. */ 137*a3114836SGerry Liu extern int acpidev_dr_device_hotplug_capable(ACPI_HANDLE hdl); 138*a3114836SGerry Liu 139*a3114836SGerry Liu /* Check whether the device has an eject device list. */ 140*a3114836SGerry Liu extern int acpidev_dr_device_has_edl(ACPI_HANDLE hdl); 141*a3114836SGerry Liu 142*a3114836SGerry Liu /* 143*a3114836SGerry Liu * Simulate OBP property interfaces to support drmach driver, 144*a3114836SGerry Liu * so we can keep drmach in consistency with SPARC version. 145*a3114836SGerry Liu * Return size of data copied to buf if it's big enough, 146*a3114836SGerry Liu * otherwise return size of buffer needed. 147*a3114836SGerry Liu */ 148*a3114836SGerry Liu extern int acpidev_dr_device_getprop(ACPI_HANDLE hdl, char *name, 149*a3114836SGerry Liu caddr_t buf, size_t len); 150*a3114836SGerry Liu 151*a3114836SGerry Liu /* 152*a3114836SGerry Liu * Get "reg" or "assigned-address" property of the device. 153*a3114836SGerry Liu * Return "assigned-address" property if assigned is non-zero, 154*a3114836SGerry Liu * otherwise return "reg" property. 155*a3114836SGerry Liu * Caller needs to release returned resources by calling 156*a3114836SGerry Liu * acpidev_dr_device_free_regspec(). 157*a3114836SGerry Liu */ 158*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_get_regspec(ACPI_HANDLE hdl, 159*a3114836SGerry Liu boolean_t assigned, acpidev_regspec_t **regpp, uint_t *cntp); 160*a3114836SGerry Liu 161*a3114836SGerry Liu /* Free resources returned by acpidev_dr_device_get_regspec(). */ 162*a3114836SGerry Liu extern void acpidev_dr_device_free_regspec(acpidev_regspec_t *regp, 163*a3114836SGerry Liu uint_t count); 164*a3114836SGerry Liu 165*a3114836SGerry Liu /* Walk devices in eject device list (ACPI _EDL method). */ 166*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_walk_edl(ACPI_HANDLE hdl, 167*a3114836SGerry Liu ACPI_WALK_CALLBACK cb, void *arg, void **retval); 168*a3114836SGerry Liu 169*a3114836SGerry Liu /* Walk devices in eject dependency list (ACPI _EJD method). */ 170*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_walk_ejd(ACPI_HANDLE hdl, 171*a3114836SGerry Liu ACPI_WALK_CALLBACK cb, void *arg, void **retval); 172*a3114836SGerry Liu 173*a3114836SGerry Liu /* 174*a3114836SGerry Liu * Walk child and dependent devices which may be involved in DR operations. 175*a3114836SGerry Liu * PCI host bridges embedded in physical processors may be presented in eject 176*a3114836SGerry Liu * device list instead of as children of processors. 177*a3114836SGerry Liu */ 178*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_walk_device(ACPI_HANDLE hdl, 179*a3114836SGerry Liu uint_t max_lvl, ACPI_WALK_CALLBACK cb, void *arg, void **retval); 180*a3114836SGerry Liu 181*a3114836SGerry Liu /* Check whether the device is in working state without any error. */ 182*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_check_status(ACPI_HANDLE hdl); 183*a3114836SGerry Liu 184*a3114836SGerry Liu /* Power on the device. */ 185*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_poweron(ACPI_HANDLE hdl); 186*a3114836SGerry Liu 187*a3114836SGerry Liu /* Power off the device. */ 188*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_poweroff(ACPI_HANDLE hdl); 189*a3114836SGerry Liu 190*a3114836SGerry Liu /* 191*a3114836SGerry Liu * Create device nodes for hot-added devices under hdl. 192*a3114836SGerry Liu * Return: 193*a3114836SGerry Liu * AE_OK: on success 194*a3114836SGerry Liu * AE_SUPPORT: if it's not capable of DR operation. 195*a3114836SGerry Liu * AE_ERROR: for other errors 196*a3114836SGerry Liu */ 197*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_insert(ACPI_HANDLE hdl); 198*a3114836SGerry Liu 199*a3114836SGerry Liu /* 200*a3114836SGerry Liu * Destroy device nodes to be removed under hdl. 201*a3114836SGerry Liu * AE_OK: on success 202*a3114836SGerry Liu * AE_SUPPORT: if it's not capable of DR operation. 203*a3114836SGerry Liu * AE_ERROR: for other errors 204*a3114836SGerry Liu */ 205*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_device_remove(ACPI_HANDLE hdl); 206*a3114836SGerry Liu 207*a3114836SGerry Liu /* Block dynamic reconfiguration operations. */ 208*a3114836SGerry Liu extern void acpidev_dr_lock_all(void); 209*a3114836SGerry Liu 210*a3114836SGerry Liu /* Unblock dynamic reconfiguration operations. */ 211*a3114836SGerry Liu extern void acpidev_dr_unlock_all(void); 212*a3114836SGerry Liu 213*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_allocate_cpuid(ACPI_HANDLE hdl, 214*a3114836SGerry Liu processorid_t *idp); 215*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_free_cpuid(ACPI_HANDLE hdl); 216*a3114836SGerry Liu 217*a3114836SGerry Liu /* 218*a3114836SGerry Liu * Query NUMA relative information for the CPU device. 219*a3114836SGerry Liu * It returns APIC id, Proximity id and latency information of the CPU device. 220*a3114836SGerry Liu * Latency information is retrieved from the ACPI _SLI method or the ACPI SLIT 221*a3114836SGerry Liu * table. 222*a3114836SGerry Liu */ 223*a3114836SGerry Liu extern int acpidev_dr_get_cpu_numa_info(cpu_t *cp, void **hdlpp, 224*a3114836SGerry Liu uint32_t *apicidp, uint32_t *pxmidp, uint32_t *slicntp, uchar_t **slipp); 225*a3114836SGerry Liu 226*a3114836SGerry Liu /* 227*a3114836SGerry Liu * Release resources allocated by acpidev_dr_get_cpu_numa_info(). 228*a3114836SGerry Liu */ 229*a3114836SGerry Liu extern void acpidev_dr_free_cpu_numa_info(void *hdlp); 230*a3114836SGerry Liu 231*a3114836SGerry Liu /* 232*a3114836SGerry Liu * Query NUMA relative information for a memory device. 233*a3114836SGerry Liu * It returns proximity id and latency information of the memory device. 234*a3114836SGerry Liu * Latency information is obtained from the ACPI _SLI method or the ACPI 235*a3114836SGerry Liu * SLIT table. 236*a3114836SGerry Liu */ 237*a3114836SGerry Liu extern ACPI_STATUS acpidev_dr_get_mem_numa_info(ACPI_HANDLE hdl, 238*a3114836SGerry Liu struct memlist *ml, void **hdlpp, uint32_t *pxmidp, 239*a3114836SGerry Liu uint32_t *slicntp, uchar_t **slipp); 240*a3114836SGerry Liu 241*a3114836SGerry Liu /* 242*a3114836SGerry Liu * Release resources allocated by acpidev_dr_get_mem_numa_info(). 243*a3114836SGerry Liu */ 244*a3114836SGerry Liu extern void acpidev_dr_free_mem_numa_info(void *hdlp); 245*a3114836SGerry Liu 246*a3114836SGerry Liu #endif /* _KERNEL */ 247*a3114836SGerry Liu 248*a3114836SGerry Liu #ifdef __cplusplus 249*a3114836SGerry Liu } 250*a3114836SGerry Liu #endif 251*a3114836SGerry Liu 252*a3114836SGerry Liu #endif /* _SYS_ACPIDEV_DR_H */ 253