1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_PSM_TYPES_H 28 #define _SYS_PSM_TYPES_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 /* 33 * Platform Specific Module Types 34 */ 35 36 #include <sys/types.h> 37 #include <sys/cpuvar.h> 38 #include <sys/time.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* 45 * PSM_OPS definitions 46 */ 47 typedef enum psm_intr_op_e { 48 PSM_INTR_OP_ALLOC_VECTORS = 0, /* 0. Allocate vectors */ 49 PSM_INTR_OP_FREE_VECTORS, /* 1. Free vectors */ 50 PSM_INTR_OP_NAVAIL_VECTORS, /* 2. Get # of available vectors */ 51 PSM_INTR_OP_XLATE_VECTOR, /* 3. Translate vector */ 52 PSM_INTR_OP_GET_PENDING, /* 4. Get pending information */ 53 PSM_INTR_OP_CLEAR_MASK, /* 5. Clear interrupt mask */ 54 PSM_INTR_OP_SET_MASK, /* 6. Set interrupt mask */ 55 PSM_INTR_OP_GET_CAP, /* 7. Get devices's capabilities */ 56 PSM_INTR_OP_SET_CAP, /* 8. Set devices's capabilities */ 57 PSM_INTR_OP_SET_PRI, /* 9. Set the interrupt priority */ 58 PSM_INTR_OP_GET_SHARED, /* 10. Get the shared intr info */ 59 PSM_INTR_OP_CHECK_MSI, /* 11. Chk if device supports MSI */ 60 PSM_INTR_OP_SET_CPU, /* 12. Set vector's CPU */ 61 PSM_INTR_OP_GET_INTR /* 13. Get vector's info */ 62 } psm_intr_op_t; 63 64 struct psm_ops { 65 int (*psm_probe)(void); 66 67 void (*psm_softinit)(void); 68 void (*psm_picinit)(void); 69 int (*psm_intr_enter)(int ipl, int *vectorp); 70 void (*psm_intr_exit)(int ipl, int irqno); 71 void (*psm_setspl)(int ipl); 72 int (*psm_addspl)(int irqno, int ipl, int min_ipl, int max_ipl); 73 int (*psm_delspl)(int irqno, int ipl, int min_ipl, int max_ipl); 74 int (*psm_disable_intr)(processorid_t cpun); 75 void (*psm_enable_intr)(processorid_t cpun); 76 int (*psm_softlvl_to_irq)(int ipl); 77 void (*psm_set_softintr)(int ipl); 78 void (*psm_set_idlecpu)(processorid_t cpun); 79 void (*psm_unset_idlecpu)(processorid_t cpun); 80 81 #if defined(PSMI_1_3) || defined(PSMI_1_4) || defined(PSMI_1_5) 82 int (*psm_clkinit)(int hertz); 83 #else 84 void (*psm_clkinit)(int hertz); 85 #endif 86 87 int (*psm_get_clockirq)(int ipl); 88 void (*psm_hrtimeinit)(void); 89 hrtime_t (*psm_gethrtime)(void); 90 91 processorid_t (*psm_get_next_processorid)(processorid_t cpu_id); 92 #if defined(PSMI_1_5) 93 int (*psm_cpu_start)(processorid_t cpun, caddr_t ctxt); 94 #else 95 void (*psm_cpu_start)(processorid_t cpun, caddr_t rm_code); 96 #endif 97 int (*psm_post_cpu_start)(void); 98 #if defined(PSMI_1_2) || defined(PSMI_1_3) || defined(PSMI_1_4) || \ 99 defined(PSMI_1_5) 100 void (*psm_shutdown)(int cmd, int fcn); 101 #else 102 void (*psm_shutdown)(void); 103 #endif 104 int (*psm_get_ipivect)(int ipl, int type); 105 void (*psm_send_ipi)(processorid_t cpun, int ipl); 106 107 int (*psm_translate_irq)(dev_info_t *dip, int irqno); 108 109 #if defined(PSMI_1_2) || defined(PSMI_1_3) || defined(PSMI_1_4) 110 int (*psm_tod_get)(todinfo_t *tod); 111 int (*psm_tod_set)(todinfo_t *tod); 112 #endif 113 void (*psm_notify_error)(int level, char *errmsg); 114 #if defined(PSMI_1_2) || defined(PSMI_1_3) || defined(PSMI_1_4) || \ 115 defined(PSMI_1_5) 116 void (*psm_notify_func)(int msg); 117 #endif 118 #if defined(PSMI_1_3) || defined(PSMI_1_4) || defined(PSMI_1_5) 119 void (*psm_timer_reprogram)(hrtime_t time); 120 void (*psm_timer_enable)(void); 121 void (*psm_timer_disable)(void); 122 void (*psm_post_cyclic_setup)(void *arg); 123 #endif 124 #if defined(PSMI_1_4) || defined(PSMI_1_5) 125 void (*psm_preshutdown)(int cmd, int fcn); 126 #endif 127 #if defined(PSMI_1_5) 128 int (*psm_intr_ops)(dev_info_t *dip, ddi_intr_handle_impl_t *handle, 129 psm_intr_op_t op, int *result); 130 #endif 131 }; 132 133 134 struct psm_info { 135 ushort_t p_version; 136 ushort_t p_owner; 137 struct psm_ops *p_ops; 138 char *p_mach_idstring; /* machine identification string */ 139 char *p_mach_desc; /* machine descriptions */ 140 }; 141 142 /* 143 * version 144 * 0x86vm where v = (version no. - 1) and m = (minor no. + 1) 145 * i.e. psmi 1.0 has v=0 and m=1, psmi 1.1 has v=0 and m=2 146 * also, 0x86 in the high byte is the signature of the psmi 147 */ 148 #define PSM_INFO_VER01 0x8601 149 #define PSM_INFO_VER01_1 0x8602 150 #define PSM_INFO_VER01_2 0x8603 151 #define PSM_INFO_VER01_3 0x8604 152 #define PSM_INFO_VER01_4 0x8605 153 #define PSM_INFO_VER01_5 0x8606 154 #define PSM_INFO_VER01_X (PSM_INFO_VER01_1 & 0xFFF0) /* ver 1.X */ 155 156 /* 157 * owner field definitions 158 */ 159 #define PSM_OWN_SYS_DEFAULT 0x0001 160 #define PSM_OWN_EXCLUSIVE 0x0002 161 #define PSM_OWN_OVERRIDE 0x0003 162 163 #define PSM_NULL_INFO -1 164 165 /* 166 * Arg to psm_notify_func 167 */ 168 #define PSM_DEBUG_ENTER 1 169 #define PSM_DEBUG_EXIT 2 170 #define PSM_PANIC_ENTER 3 171 172 /* 173 * Soft-level to interrupt vector 174 */ 175 #define PSM_SV_SOFTWARE -1 176 #define PSM_SV_MIXED -2 177 178 /* 179 * Inter-processor interrupt type 180 */ 181 #define PSM_INTR_IPI_HI 0x01 182 #define PSM_INTR_IPI_LO 0x02 183 #define PSM_INTR_POKE 0x03 184 185 /* 186 * Get INTR flags 187 */ 188 #define PSMGI_CPU_USER_BOUND 0x80000000 /* user requested bind if set */ 189 #define PSMGI_CPU_FLAGS 0x80000000 /* all possible flags */ 190 191 /* 192 * return code 193 */ 194 #define PSM_SUCCESS DDI_SUCCESS 195 #define PSM_FAILURE DDI_FAILURE 196 197 #define PSM_INVALID_IPL 0 198 #define PSM_INVALID_CPU -1 199 200 201 struct psm_ops_ver01 { 202 int (*psm_probe)(void); 203 204 void (*psm_softinit)(void); 205 void (*psm_picinit)(void); 206 int (*psm_intr_enter)(int ipl, int *vectorp); 207 void (*psm_intr_exit)(int ipl, int irqno); 208 void (*psm_setspl)(int ipl); 209 int (*psm_addspl)(int irqno, int ipl, int min_ipl, int max_ipl); 210 int (*psm_delspl)(int irqno, int ipl, int min_ipl, int max_ipl); 211 int (*psm_disable_intr)(processorid_t cpun); 212 void (*psm_enable_intr)(processorid_t cpun); 213 int (*psm_softlvl_to_irq)(int ipl); 214 void (*psm_set_softintr)(int ipl); 215 void (*psm_set_idlecpu)(processorid_t cpun); 216 void (*psm_unset_idlecpu)(processorid_t cpun); 217 218 void (*psm_clkinit)(int hertz); 219 int (*psm_get_clockirq)(int ipl); 220 void (*psm_hrtimeinit)(void); 221 hrtime_t (*psm_gethrtime)(void); 222 223 processorid_t (*psm_get_next_processorid)(processorid_t cpu_id); 224 void (*psm_cpu_start)(processorid_t cpun, caddr_t rm_code); 225 int (*psm_post_cpu_start)(void); 226 void (*psm_shutdown)(void); 227 int (*psm_get_ipivect)(int ipl, int type); 228 void (*psm_send_ipi)(processorid_t cpun, int ipl); 229 }; 230 231 #ifdef __cplusplus 232 } 233 #endif 234 235 #endif /* _SYS_PSM_TYPES_H */ 236