17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ae115bc7Smrj * Common Development and Distribution License (the "License"). 6ae115bc7Smrj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21ae115bc7Smrj 227c478bd9Sstevel@tonic-gate /* 23ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 26a3114836SGerry Liu /* 27a3114836SGerry Liu * Copyright (c) 2010, Intel Corporation. 28a3114836SGerry Liu * All rights reserved. 291c2d0470SPatrick Mooney * Copyright 2018 Joyent, Inc. 30a3114836SGerry Liu */ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifndef _SYS_PSM_TYPES_H 337c478bd9Sstevel@tonic-gate #define _SYS_PSM_TYPES_H 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * Platform Specific Module Types 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include <sys/types.h> 407c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 417c478bd9Sstevel@tonic-gate #include <sys/time.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * PSM_OPS definitions 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate typedef enum psm_intr_op_e { 517c478bd9Sstevel@tonic-gate PSM_INTR_OP_ALLOC_VECTORS = 0, /* 0. Allocate vectors */ 527c478bd9Sstevel@tonic-gate PSM_INTR_OP_FREE_VECTORS, /* 1. Free vectors */ 537c478bd9Sstevel@tonic-gate PSM_INTR_OP_NAVAIL_VECTORS, /* 2. Get # of available vectors */ 547c478bd9Sstevel@tonic-gate PSM_INTR_OP_XLATE_VECTOR, /* 3. Translate vector */ 557c478bd9Sstevel@tonic-gate PSM_INTR_OP_GET_PENDING, /* 4. Get pending information */ 567c478bd9Sstevel@tonic-gate PSM_INTR_OP_CLEAR_MASK, /* 5. Clear interrupt mask */ 577c478bd9Sstevel@tonic-gate PSM_INTR_OP_SET_MASK, /* 6. Set interrupt mask */ 587c478bd9Sstevel@tonic-gate PSM_INTR_OP_GET_CAP, /* 7. Get devices's capabilities */ 597c478bd9Sstevel@tonic-gate PSM_INTR_OP_SET_CAP, /* 8. Set devices's capabilities */ 607c478bd9Sstevel@tonic-gate PSM_INTR_OP_SET_PRI, /* 9. Set the interrupt priority */ 617c478bd9Sstevel@tonic-gate PSM_INTR_OP_GET_SHARED, /* 10. Get the shared intr info */ 627a364d25Sschwartz PSM_INTR_OP_CHECK_MSI, /* 11. Chk if device supports MSI */ 637a364d25Sschwartz PSM_INTR_OP_SET_CPU, /* 12. Set vector's CPU */ 642917a9c9Sschwartz PSM_INTR_OP_GET_INTR, /* 13. Get vector's info */ 652917a9c9Sschwartz PSM_INTR_OP_GRP_SET_CPU, /* 14. Set all device's vectors' CPU */ 662917a9c9Sschwartz PSM_INTR_OP_APIC_TYPE /* 15. Returns APIC type */ 677c478bd9Sstevel@tonic-gate } psm_intr_op_t; 687c478bd9Sstevel@tonic-gate 692df1fe9cSrandyf /* 702df1fe9cSrandyf * PSM_STATE definitions 712df1fe9cSrandyf */ 722df1fe9cSrandyf typedef enum psm_state_op_e { 732df1fe9cSrandyf PSM_STATE_ALLOC = 1, 742df1fe9cSrandyf PSM_STATE_FREE, 752df1fe9cSrandyf PSM_STATE_SAVE, 762df1fe9cSrandyf PSM_STATE_RESTORE 772df1fe9cSrandyf } psm_state_op_t; 782df1fe9cSrandyf 792df1fe9cSrandyf typedef struct psm_state_req { 802df1fe9cSrandyf psm_state_op_t psr_cmd; 812df1fe9cSrandyf union psm_req { 822df1fe9cSrandyf /* 832df1fe9cSrandyf * PSM_STATE_ALLOC, PSM_STATE_FREE, PSM_STATE_SAVE, 842df1fe9cSrandyf * PSM_STATE_RESTORE all use the same struct, 852df1fe9cSrandyf * but union for later expansion 862df1fe9cSrandyf */ 872df1fe9cSrandyf struct { 882df1fe9cSrandyf void *psr_state; 892df1fe9cSrandyf size_t psr_state_size; 902df1fe9cSrandyf } psm_state_req; 912df1fe9cSrandyf } req; 922df1fe9cSrandyf } psm_state_request_t; 932df1fe9cSrandyf 94a3114836SGerry Liu typedef enum psm_cpu_op_e { 95a3114836SGerry Liu PSM_CPU_ADD = 1, 96a3114836SGerry Liu PSM_CPU_REMOVE, 97a3114836SGerry Liu PSM_CPU_STOP 98a3114836SGerry Liu } psm_cpu_op_t; 99a3114836SGerry Liu 100a3114836SGerry Liu typedef struct psm_cpu_request { 101a3114836SGerry Liu psm_cpu_op_t pcr_cmd; 102a3114836SGerry Liu union { 103a3114836SGerry Liu struct { 104a3114836SGerry Liu processorid_t cpuid; 105a3114836SGerry Liu void *argp; 106a3114836SGerry Liu } cpu_add; 107a3114836SGerry Liu 108a3114836SGerry Liu struct { 109a3114836SGerry Liu processorid_t cpuid; 110a3114836SGerry Liu } cpu_remove; 111a3114836SGerry Liu 112a3114836SGerry Liu struct { 113a3114836SGerry Liu processorid_t cpuid; 114a3114836SGerry Liu void *ctx; 115a3114836SGerry Liu } cpu_stop; 116a3114836SGerry Liu } req; 117a3114836SGerry Liu } psm_cpu_request_t; 118a3114836SGerry Liu 119*918e0d92SRobert Mustacchi struct psm_ops { 1207c478bd9Sstevel@tonic-gate int (*psm_probe)(void); 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate void (*psm_softinit)(void); 1237c478bd9Sstevel@tonic-gate void (*psm_picinit)(void); 1247c478bd9Sstevel@tonic-gate int (*psm_intr_enter)(int ipl, int *vectorp); 1257c478bd9Sstevel@tonic-gate void (*psm_intr_exit)(int ipl, int irqno); 1267c478bd9Sstevel@tonic-gate void (*psm_setspl)(int ipl); 1277c478bd9Sstevel@tonic-gate int (*psm_addspl)(int irqno, int ipl, int min_ipl, int max_ipl); 1287c478bd9Sstevel@tonic-gate int (*psm_delspl)(int irqno, int ipl, int min_ipl, int max_ipl); 1297c478bd9Sstevel@tonic-gate int (*psm_disable_intr)(processorid_t cpun); 1307c478bd9Sstevel@tonic-gate void (*psm_enable_intr)(processorid_t cpun); 1317c478bd9Sstevel@tonic-gate int (*psm_softlvl_to_irq)(int ipl); 1327c478bd9Sstevel@tonic-gate void (*psm_set_softintr)(int ipl); 1337c478bd9Sstevel@tonic-gate void (*psm_set_idlecpu)(processorid_t cpun); 1347c478bd9Sstevel@tonic-gate void (*psm_unset_idlecpu)(processorid_t cpun); 1357c478bd9Sstevel@tonic-gate 1362df1fe9cSrandyf #if defined(PSMI_1_3) || defined(PSMI_1_4) || defined(PSMI_1_5) || \ 137a3114836SGerry Liu defined(PSMI_1_6) || defined(PSMI_1_7) 1387c478bd9Sstevel@tonic-gate int (*psm_clkinit)(int hertz); 1397c478bd9Sstevel@tonic-gate #else 1407c478bd9Sstevel@tonic-gate void (*psm_clkinit)(int hertz); 1417c478bd9Sstevel@tonic-gate #endif 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate int (*psm_get_clockirq)(int ipl); 1447c478bd9Sstevel@tonic-gate void (*psm_hrtimeinit)(void); 1457c478bd9Sstevel@tonic-gate hrtime_t (*psm_gethrtime)(void); 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate processorid_t (*psm_get_next_processorid)(processorid_t cpu_id); 148a3114836SGerry Liu #if defined(PSMI_1_5) || defined(PSMI_1_6) || defined(PSMI_1_7) 149ae115bc7Smrj int (*psm_cpu_start)(processorid_t cpun, caddr_t ctxt); 150ae115bc7Smrj #else 1517c478bd9Sstevel@tonic-gate void (*psm_cpu_start)(processorid_t cpun, caddr_t rm_code); 152ae115bc7Smrj #endif 1537c478bd9Sstevel@tonic-gate int (*psm_post_cpu_start)(void); 1547c478bd9Sstevel@tonic-gate #if defined(PSMI_1_2) || defined(PSMI_1_3) || defined(PSMI_1_4) || \ 155a3114836SGerry Liu defined(PSMI_1_5) || defined(PSMI_1_6) || defined(PSMI_1_7) 1567c478bd9Sstevel@tonic-gate void (*psm_shutdown)(int cmd, int fcn); 1577c478bd9Sstevel@tonic-gate #else 1587c478bd9Sstevel@tonic-gate void (*psm_shutdown)(void); 1597c478bd9Sstevel@tonic-gate #endif 1607c478bd9Sstevel@tonic-gate int (*psm_get_ipivect)(int ipl, int type); 1617c478bd9Sstevel@tonic-gate void (*psm_send_ipi)(processorid_t cpun, int ipl); 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate int (*psm_translate_irq)(dev_info_t *dip, int irqno); 1647c478bd9Sstevel@tonic-gate 165ae115bc7Smrj #if defined(PSMI_1_2) || defined(PSMI_1_3) || defined(PSMI_1_4) 1667c478bd9Sstevel@tonic-gate int (*psm_tod_get)(todinfo_t *tod); 1677c478bd9Sstevel@tonic-gate int (*psm_tod_set)(todinfo_t *tod); 168ae115bc7Smrj #endif 1697c478bd9Sstevel@tonic-gate void (*psm_notify_error)(int level, char *errmsg); 1707c478bd9Sstevel@tonic-gate #if defined(PSMI_1_2) || defined(PSMI_1_3) || defined(PSMI_1_4) || \ 171a3114836SGerry Liu defined(PSMI_1_5) || defined(PSMI_1_6) || defined(PSMI_1_7) 1727c478bd9Sstevel@tonic-gate void (*psm_notify_func)(int msg); 1737c478bd9Sstevel@tonic-gate #endif 1742df1fe9cSrandyf #if defined(PSMI_1_3) || defined(PSMI_1_4) || defined(PSMI_1_5) || \ 175a3114836SGerry Liu defined(PSMI_1_6) || defined(PSMI_1_7) 176*918e0d92SRobert Mustacchi void (*psm_timer_reprogram)(hrtime_t time); 1777c478bd9Sstevel@tonic-gate void (*psm_timer_enable)(void); 178*918e0d92SRobert Mustacchi void (*psm_timer_disable)(void); 179*918e0d92SRobert Mustacchi void (*psm_post_cyclic_setup)(void *arg); 1807c478bd9Sstevel@tonic-gate #endif 181a3114836SGerry Liu #if defined(PSMI_1_4) || defined(PSMI_1_5) || defined(PSMI_1_6) || \ 182a3114836SGerry Liu defined(PSMI_1_7) 1837c478bd9Sstevel@tonic-gate void (*psm_preshutdown)(int cmd, int fcn); 1847c478bd9Sstevel@tonic-gate #endif 185a3114836SGerry Liu #if defined(PSMI_1_5) || defined(PSMI_1_6) || defined(PSMI_1_7) 1867c478bd9Sstevel@tonic-gate int (*psm_intr_ops)(dev_info_t *dip, ddi_intr_handle_impl_t *handle, 1877c478bd9Sstevel@tonic-gate psm_intr_op_t op, int *result); 1887c478bd9Sstevel@tonic-gate #endif 189a3114836SGerry Liu #if defined(PSMI_1_6) || defined(PSMI_1_7) 1902df1fe9cSrandyf int (*psm_state)(psm_state_request_t *request); 1912df1fe9cSrandyf #endif 192a3114836SGerry Liu #if defined(PSMI_1_7) 193a3114836SGerry Liu int (*psm_cpu_ops)(psm_cpu_request_t *reqp); 1941c2d0470SPatrick Mooney 1951c2d0470SPatrick Mooney int (*psm_get_pir_ipivect)(void); 1961c2d0470SPatrick Mooney void (*psm_send_pir_ipi)(processorid_t cpu); 197*918e0d92SRobert Mustacchi void (*psm_cmci_setup)(processorid_t cpu, boolean_t); 198a3114836SGerry Liu #endif 1997c478bd9Sstevel@tonic-gate }; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate 202ae115bc7Smrj struct psm_info { 2037c478bd9Sstevel@tonic-gate ushort_t p_version; 2047c478bd9Sstevel@tonic-gate ushort_t p_owner; 205*918e0d92SRobert Mustacchi struct psm_ops *p_ops; 2067c478bd9Sstevel@tonic-gate char *p_mach_idstring; /* machine identification string */ 2077c478bd9Sstevel@tonic-gate char *p_mach_desc; /* machine descriptions */ 2087c478bd9Sstevel@tonic-gate }; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * version 2127c478bd9Sstevel@tonic-gate * 0x86vm where v = (version no. - 1) and m = (minor no. + 1) 2137c478bd9Sstevel@tonic-gate * i.e. psmi 1.0 has v=0 and m=1, psmi 1.1 has v=0 and m=2 2147c478bd9Sstevel@tonic-gate * also, 0x86 in the high byte is the signature of the psmi 2157c478bd9Sstevel@tonic-gate */ 2167c478bd9Sstevel@tonic-gate #define PSM_INFO_VER01 0x8601 2177c478bd9Sstevel@tonic-gate #define PSM_INFO_VER01_1 0x8602 2187c478bd9Sstevel@tonic-gate #define PSM_INFO_VER01_2 0x8603 2197c478bd9Sstevel@tonic-gate #define PSM_INFO_VER01_3 0x8604 2207c478bd9Sstevel@tonic-gate #define PSM_INFO_VER01_4 0x8605 2217c478bd9Sstevel@tonic-gate #define PSM_INFO_VER01_5 0x8606 222a3114836SGerry Liu #define PSM_INFO_VER01_6 0x8607 223a3114836SGerry Liu #define PSM_INFO_VER01_7 0x8608 2247c478bd9Sstevel@tonic-gate #define PSM_INFO_VER01_X (PSM_INFO_VER01_1 & 0xFFF0) /* ver 1.X */ 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate /* 2277c478bd9Sstevel@tonic-gate * owner field definitions 2287c478bd9Sstevel@tonic-gate */ 2297c478bd9Sstevel@tonic-gate #define PSM_OWN_SYS_DEFAULT 0x0001 2307c478bd9Sstevel@tonic-gate #define PSM_OWN_EXCLUSIVE 0x0002 2317c478bd9Sstevel@tonic-gate #define PSM_OWN_OVERRIDE 0x0003 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate #define PSM_NULL_INFO -1 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate /* 2367c478bd9Sstevel@tonic-gate * Arg to psm_notify_func 2377c478bd9Sstevel@tonic-gate */ 2387c478bd9Sstevel@tonic-gate #define PSM_DEBUG_ENTER 1 2397c478bd9Sstevel@tonic-gate #define PSM_DEBUG_EXIT 2 2407c478bd9Sstevel@tonic-gate #define PSM_PANIC_ENTER 3 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate /* 2437c478bd9Sstevel@tonic-gate * Soft-level to interrupt vector 2447c478bd9Sstevel@tonic-gate */ 2457c478bd9Sstevel@tonic-gate #define PSM_SV_SOFTWARE -1 2467c478bd9Sstevel@tonic-gate #define PSM_SV_MIXED -2 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate /* 2497c478bd9Sstevel@tonic-gate * Inter-processor interrupt type 2507c478bd9Sstevel@tonic-gate */ 2517c478bd9Sstevel@tonic-gate #define PSM_INTR_IPI_HI 0x01 2527c478bd9Sstevel@tonic-gate #define PSM_INTR_IPI_LO 0x02 2537c478bd9Sstevel@tonic-gate #define PSM_INTR_POKE 0x03 2547c478bd9Sstevel@tonic-gate 2557a364d25Sschwartz /* 2567a364d25Sschwartz * Get INTR flags 2577a364d25Sschwartz */ 2587a364d25Sschwartz #define PSMGI_CPU_USER_BOUND 0x80000000 /* user requested bind if set */ 2597a364d25Sschwartz #define PSMGI_CPU_FLAGS 0x80000000 /* all possible flags */ 2607a364d25Sschwartz 2617c478bd9Sstevel@tonic-gate /* 2627c478bd9Sstevel@tonic-gate * return code 2637c478bd9Sstevel@tonic-gate */ 2647c478bd9Sstevel@tonic-gate #define PSM_SUCCESS DDI_SUCCESS 2657c478bd9Sstevel@tonic-gate #define PSM_FAILURE DDI_FAILURE 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate #define PSM_INVALID_IPL 0 2687c478bd9Sstevel@tonic-gate #define PSM_INVALID_CPU -1 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate 271*918e0d92SRobert Mustacchi struct psm_ops_ver01 { 2727c478bd9Sstevel@tonic-gate int (*psm_probe)(void); 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate void (*psm_softinit)(void); 2757c478bd9Sstevel@tonic-gate void (*psm_picinit)(void); 2767c478bd9Sstevel@tonic-gate int (*psm_intr_enter)(int ipl, int *vectorp); 2777c478bd9Sstevel@tonic-gate void (*psm_intr_exit)(int ipl, int irqno); 2787c478bd9Sstevel@tonic-gate void (*psm_setspl)(int ipl); 2797c478bd9Sstevel@tonic-gate int (*psm_addspl)(int irqno, int ipl, int min_ipl, int max_ipl); 2807c478bd9Sstevel@tonic-gate int (*psm_delspl)(int irqno, int ipl, int min_ipl, int max_ipl); 2817c478bd9Sstevel@tonic-gate int (*psm_disable_intr)(processorid_t cpun); 2827c478bd9Sstevel@tonic-gate void (*psm_enable_intr)(processorid_t cpun); 2837c478bd9Sstevel@tonic-gate int (*psm_softlvl_to_irq)(int ipl); 2847c478bd9Sstevel@tonic-gate void (*psm_set_softintr)(int ipl); 2857c478bd9Sstevel@tonic-gate void (*psm_set_idlecpu)(processorid_t cpun); 2867c478bd9Sstevel@tonic-gate void (*psm_unset_idlecpu)(processorid_t cpun); 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate void (*psm_clkinit)(int hertz); 2897c478bd9Sstevel@tonic-gate int (*psm_get_clockirq)(int ipl); 2907c478bd9Sstevel@tonic-gate void (*psm_hrtimeinit)(void); 2917c478bd9Sstevel@tonic-gate hrtime_t (*psm_gethrtime)(void); 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate processorid_t (*psm_get_next_processorid)(processorid_t cpu_id); 2947c478bd9Sstevel@tonic-gate void (*psm_cpu_start)(processorid_t cpun, caddr_t rm_code); 2957c478bd9Sstevel@tonic-gate int (*psm_post_cpu_start)(void); 2967c478bd9Sstevel@tonic-gate void (*psm_shutdown)(void); 2977c478bd9Sstevel@tonic-gate int (*psm_get_ipivect)(int ipl, int type); 2987c478bd9Sstevel@tonic-gate void (*psm_send_ipi)(processorid_t cpun, int ipl); 2997c478bd9Sstevel@tonic-gate }; 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3027c478bd9Sstevel@tonic-gate } 3037c478bd9Sstevel@tonic-gate #endif 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate #endif /* _SYS_PSM_TYPES_H */ 306