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 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*a3114836SGerry Liu * Use is subject to license terms. 24*a3114836SGerry Liu */ 25*a3114836SGerry Liu /* 26*a3114836SGerry Liu * Copyright (c) 2010, Intel Corporation. 27*a3114836SGerry Liu * All rights reserved. 28*a3114836SGerry Liu */ 29*a3114836SGerry Liu 30*a3114836SGerry Liu #ifndef _SYS_DRMACH_ACPI_H 31*a3114836SGerry Liu #define _SYS_DRMACH_ACPI_H 32*a3114836SGerry Liu #include <sys/types.h> 33*a3114836SGerry Liu #include <sys/cmn_err.h> 34*a3114836SGerry Liu #include <sys/param.h> 35*a3114836SGerry Liu #include <sys/sunddi.h> 36*a3114836SGerry Liu #include <sys/acpi/acpi.h> 37*a3114836SGerry Liu #include <sys/acpica.h> 38*a3114836SGerry Liu #include <sys/acpidev.h> 39*a3114836SGerry Liu #include <sys/drmach.h> 40*a3114836SGerry Liu 41*a3114836SGerry Liu #ifdef __cplusplus 42*a3114836SGerry Liu extern "C" { 43*a3114836SGerry Liu #endif 44*a3114836SGerry Liu 45*a3114836SGerry Liu #ifdef _KERNEL 46*a3114836SGerry Liu 47*a3114836SGerry Liu /* Use ACPI handle as DRMACH handle on x86 systems. */ 48*a3114836SGerry Liu #define DRMACH_HANDLE ACPI_HANDLE 49*a3114836SGerry Liu 50*a3114836SGerry Liu /* Macros to deal with object type. */ 51*a3114836SGerry Liu #define DRMACH_OBJ(id) ((drmach_common_t *)id) 52*a3114836SGerry Liu 53*a3114836SGerry Liu #define DRMACH_NULL_ID(id) ((id) == 0) 54*a3114836SGerry Liu 55*a3114836SGerry Liu #define DRMACH_IS_BOARD_ID(id) \ 56*a3114836SGerry Liu ((id != 0) && (DRMACH_OBJ(id)->isa == (void *)drmach_board_new)) 57*a3114836SGerry Liu 58*a3114836SGerry Liu #define DRMACH_IS_CPU_ID(id) \ 59*a3114836SGerry Liu ((id != 0) && (DRMACH_OBJ(id)->isa == (void *)drmach_cpu_new)) 60*a3114836SGerry Liu 61*a3114836SGerry Liu #define DRMACH_IS_MEM_ID(id) \ 62*a3114836SGerry Liu ((id != 0) && (DRMACH_OBJ(id)->isa == (void *)drmach_mem_new)) 63*a3114836SGerry Liu 64*a3114836SGerry Liu #define DRMACH_IS_IO_ID(id) \ 65*a3114836SGerry Liu ((id != 0) && (DRMACH_OBJ(id)->isa == (void *)drmach_io_new)) 66*a3114836SGerry Liu 67*a3114836SGerry Liu #define DRMACH_IS_DEVICE_ID(id) \ 68*a3114836SGerry Liu ((id != 0) && \ 69*a3114836SGerry Liu (DRMACH_OBJ(id)->isa == (void *)drmach_cpu_new || \ 70*a3114836SGerry Liu DRMACH_OBJ(id)->isa == (void *)drmach_mem_new || \ 71*a3114836SGerry Liu DRMACH_OBJ(id)->isa == (void *)drmach_io_new)) 72*a3114836SGerry Liu 73*a3114836SGerry Liu #define DRMACH_IS_ID(id) \ 74*a3114836SGerry Liu ((id != 0) && \ 75*a3114836SGerry Liu (DRMACH_OBJ(id)->isa == (void *)drmach_board_new || \ 76*a3114836SGerry Liu DRMACH_OBJ(id)->isa == (void *)drmach_cpu_new || \ 77*a3114836SGerry Liu DRMACH_OBJ(id)->isa == (void *)drmach_mem_new || \ 78*a3114836SGerry Liu DRMACH_OBJ(id)->isa == (void *)drmach_io_new)) 79*a3114836SGerry Liu 80*a3114836SGerry Liu #define DRMACH_INTERNAL_ERROR() \ 81*a3114836SGerry Liu drerr_new(1, EX86_INTERNAL, drmach_ie_fmt, __LINE__) 82*a3114836SGerry Liu 83*a3114836SGerry Liu #ifdef DEBUG 84*a3114836SGerry Liu extern int drmach_debug; 85*a3114836SGerry Liu 86*a3114836SGerry Liu #define DRMACH_PR if (drmach_debug) printf 87*a3114836SGerry Liu #else 88*a3114836SGerry Liu #define DRMACH_PR _NOTE(CONSTANTCONDITION) if (0) printf 89*a3114836SGerry Liu #endif /* DEBUG */ 90*a3114836SGerry Liu 91*a3114836SGerry Liu typedef struct { 92*a3114836SGerry Liu struct drmach_node *node; 93*a3114836SGerry Liu void *data; 94*a3114836SGerry Liu void *func; 95*a3114836SGerry Liu } drmach_node_walk_args_t; 96*a3114836SGerry Liu 97*a3114836SGerry Liu typedef struct drmach_node { 98*a3114836SGerry Liu void *here; 99*a3114836SGerry Liu 100*a3114836SGerry Liu DRMACH_HANDLE (*get_dnode)(struct drmach_node *node); 101*a3114836SGerry Liu dev_info_t *(*getdip)(struct drmach_node *node); 102*a3114836SGerry Liu int (*getproplen)(struct drmach_node *node, char *name, 103*a3114836SGerry Liu int *len); 104*a3114836SGerry Liu int (*getprop)(struct drmach_node *node, char *name, 105*a3114836SGerry Liu void *buf, int len); 106*a3114836SGerry Liu int (*walk)(struct drmach_node *node, void *data, 107*a3114836SGerry Liu int (*cb)(drmach_node_walk_args_t *args)); 108*a3114836SGerry Liu } drmach_node_t; 109*a3114836SGerry Liu 110*a3114836SGerry Liu typedef struct { 111*a3114836SGerry Liu int min_index; 112*a3114836SGerry Liu int max_index; 113*a3114836SGerry Liu int arr_sz; 114*a3114836SGerry Liu drmachid_t *arr; 115*a3114836SGerry Liu } drmach_array_t; 116*a3114836SGerry Liu 117*a3114836SGerry Liu typedef struct { 118*a3114836SGerry Liu void *isa; 119*a3114836SGerry Liu 120*a3114836SGerry Liu void (*dispose)(drmachid_t); 121*a3114836SGerry Liu sbd_error_t *(*release)(drmachid_t); 122*a3114836SGerry Liu sbd_error_t *(*status)(drmachid_t, drmach_status_t *); 123*a3114836SGerry Liu 124*a3114836SGerry Liu char name[MAXNAMELEN]; 125*a3114836SGerry Liu } drmach_common_t; 126*a3114836SGerry Liu 127*a3114836SGerry Liu typedef struct { 128*a3114836SGerry Liu drmach_common_t cm; 129*a3114836SGerry Liu uint_t bnum; 130*a3114836SGerry Liu int assigned; 131*a3114836SGerry Liu int powered; 132*a3114836SGerry Liu int connected; 133*a3114836SGerry Liu int cond; 134*a3114836SGerry Liu drmach_node_t *tree; 135*a3114836SGerry Liu drmach_array_t *devices; 136*a3114836SGerry Liu int boot_board; /* if board exists on bootup */ 137*a3114836SGerry Liu } drmach_board_t; 138*a3114836SGerry Liu 139*a3114836SGerry Liu typedef struct { 140*a3114836SGerry Liu drmach_common_t cm; 141*a3114836SGerry Liu drmach_board_t *bp; 142*a3114836SGerry Liu int unum; 143*a3114836SGerry Liu uint_t portid; 144*a3114836SGerry Liu int busy; 145*a3114836SGerry Liu int powered; 146*a3114836SGerry Liu const char *type; 147*a3114836SGerry Liu drmach_node_t *node; 148*a3114836SGerry Liu } drmach_device_t; 149*a3114836SGerry Liu 150*a3114836SGerry Liu typedef struct drmach_cpu { 151*a3114836SGerry Liu drmach_device_t dev; 152*a3114836SGerry Liu processorid_t cpuid; 153*a3114836SGerry Liu uint32_t apicid; 154*a3114836SGerry Liu } drmach_cpu_t; 155*a3114836SGerry Liu 156*a3114836SGerry Liu typedef struct drmach_mem { 157*a3114836SGerry Liu drmach_device_t dev; 158*a3114836SGerry Liu uint64_t mem_alignment; 159*a3114836SGerry Liu uint64_t slice_base; 160*a3114836SGerry Liu uint64_t slice_top; 161*a3114836SGerry Liu uint64_t slice_size; 162*a3114836SGerry Liu uint64_t base_pa; /* lowest installed memory base */ 163*a3114836SGerry Liu uint64_t nbytes; /* size of installed memory */ 164*a3114836SGerry Liu struct memlist *memlist; 165*a3114836SGerry Liu } drmach_mem_t; 166*a3114836SGerry Liu 167*a3114836SGerry Liu typedef struct drmach_io { 168*a3114836SGerry Liu drmach_device_t dev; 169*a3114836SGerry Liu } drmach_io_t; 170*a3114836SGerry Liu 171*a3114836SGerry Liu typedef struct drmach_domain_info { 172*a3114836SGerry Liu uint64_t floating; 173*a3114836SGerry Liu int allow_dr; 174*a3114836SGerry Liu } drmach_domain_info_t; 175*a3114836SGerry Liu 176*a3114836SGerry Liu typedef struct { 177*a3114836SGerry Liu drmach_board_t *obj; 178*a3114836SGerry Liu int ndevs; 179*a3114836SGerry Liu void *a; 180*a3114836SGerry Liu sbd_error_t *(*found)(void *a, const char *, int, drmachid_t); 181*a3114836SGerry Liu sbd_error_t *err; 182*a3114836SGerry Liu } drmach_board_cb_data_t; 183*a3114836SGerry Liu 184*a3114836SGerry Liu extern drmach_domain_info_t drmach_domain; 185*a3114836SGerry Liu 186*a3114836SGerry Liu extern drmach_board_t *drmach_board_new(uint_t, int); 187*a3114836SGerry Liu extern sbd_error_t *drmach_device_new(drmach_node_t *, 188*a3114836SGerry Liu drmach_board_t *, int, drmachid_t *); 189*a3114836SGerry Liu extern sbd_error_t *drmach_cpu_new(drmach_device_t *, drmachid_t *); 190*a3114836SGerry Liu extern sbd_error_t *drmach_mem_new(drmach_device_t *, drmachid_t *); 191*a3114836SGerry Liu extern sbd_error_t *drmach_io_new(drmach_device_t *, drmachid_t *); 192*a3114836SGerry Liu 193*a3114836SGerry Liu #endif /* _KERNEL */ 194*a3114836SGerry Liu 195*a3114836SGerry Liu #ifdef __cplusplus 196*a3114836SGerry Liu } 197*a3114836SGerry Liu #endif 198*a3114836SGerry Liu 199*a3114836SGerry Liu #endif /* _SYS_DRMACH_ACPI_H */ 200