#ifndef __THREAD_MACROS_LOADED #define __THREAD_MACROS_LOADED 1 /* IDENT X-18 */ /* */ /* ************************************************************************* */ /* * * */ /* * HPE CONFIDENTIAL. This software is confidential proprietary software * */ /* * licensed by Hewlett Packard Enterprise Development, LP, and is not * */ /* * authorized to be used, duplicated or disclosed to anyone without the * */ /* * prior written permission of HPE. * */ /* * Copyright 2017 Hewlett Packard Enterprise Development, LP * */ /* * * */ /* * VMS SOFTWARE, INC. CONFIDENTIAL. This software is confidential * */ /* * proprietary software licensed by VMS Software, Inc., and is not * */ /* * authorized to be used, duplicated or disclosed to anyone without * */ /* * the prior written permission of VMS Software, Inc. * */ /* * Copyright 2017 VMS Software, Inc. * */ /* * * */ /* ************************************************************************* */ /* *++ * FACILITY: * * VMS Executive (LIB) * * ABSTRACT: * * This header file provides macros and functions that are used * for kernel thread support. * * AUTHOR: * * Ellen M. Batbouta * * CREATION DATE: 09-Mar-1995 * * MODIFICATION HISTORY: * * X-18 CEG0919 Clair Grant 25-Sep-2020 * Change comment in X-17 * * X-17 CEG0910 Clair Grant 24-Sep-2020 * Replace "// comment" style to eliminate * confusion when compiling /STANDARD=VAXC. * * X-16 CV-0262 Camiel Vanderhoeven 1-Nov-2018 * Deal with possibility of null PCB in get_curktb. * * X-15 AHM Drew Mason 30-Nov-2017 * Add definition of __RUNCONST to let SYSBOOT modify * run-time constants. Use typed PCB_PL and KTB_PL * pointers instead of the ambiguous "*". * * X-14 CEG0167 Clair Grant 09-Jun-2017 * Verified conditionals for x86 port. * Updated copyright t0 VSI. * * X-13 KLN3096 Karen L. Noel 2-Oct-2002 * o Port get_curktb to IA64. * o Fix ident. * * X-11 DJM Dennis Mattoon 20-MAR-02 * Replaced call_pal asm statement with an equivalent call * to the __PAL_LDQP builtin. * * X-10 KLN2085 Karen L. Noel 11-Jun-1998 * Fix some more DEC C level4 informationals. * * X-9 KLN2075 Karen L. Noel 12-May-1998 * The compiler doesn't like upper cased externs compiled * with lower cased externs of the same name. Most code * uses lower case, so just switch this case to lower. * * X-8 Dave Bernardo 07-Mar-1998 * Fix return in get_curktb. Cleanup pointer size madness. * * X-7 DMB Dave Bernardo 04-Nov-1996 * Add new WTAMI algorithm * * X-6 MAS Mary A. Sullivan 17-May-1996 * Use more standard '__int64' rather than 'int64' in * our casts (from X-3) since we don't explicitly include * ints.h, and besides it makes the latest C compiler * happy. * * X-5 PKW355 Paul K. M. Weiss 17-May-1996 * Define pktadef for PKW353 * * X-4 PKW353 Paul K. M. Weiss 15-May-1996 * Add get_curpkta caller's mode routine * * X-3 MAS Mary A. Sullivan 17-Jan-1996 * Declare 'pcbb' as a 64-bit pointer and use 64-bit * arithmetic on my_id calculation. * * X-2 JCH703 John C. Hallyburton, Jr. 17-Apr-1995 * Change logical "&&" to bitwise "&" in my_id calculation, so * the correct KTB pointer will be returned instead of PCB. * Rework code slightly. Note the compiler could do a little * better by realizing it was SEXTL-ing pcbb then masking off * only the low 9 bits, so why SEXTL in the first place? * *-- */ /* This construct allows SYSBOOT write access to variables that are run-time constants, but need to be initialized at boot time. */ #ifdef __SYSBOOT #define __RUNCONST #else #define __RUNCONST const #endif /* Include any header files we need to make these macros work */ #include #include #include #include #include #pragma __required_pointer_size __save /* Save the previously-defined required ptr size */ #pragma __required_pointer_size __short /* And set ptr size default to 32-bit pointers */ /* Define function to get the address of the current kernel thread block (KTB) */ #pragma inline (get_curktb) static KTB_PL get_curktb(void) { #ifndef __ALPHA /* Verified for IA64 port - KLN; x86 - Clair Grant */ extern int swis$get_current_kt_id(void); extern PCB_PL __RUNCONST ctl$gl_pcb; int my_id; KTB_PPL ktbvec; #if !defined(__ia64) /* Verified for x86 port - Camiel Vanderhoeven */ if (ctl$gl_pcb == (PCB_PL)0) return (KTB_PL)0; #endif /* If process has 1 execution context, ktb is pcb */ if (ctl$gl_pcb->pcb$l_kt_count <= 1) return ((KTB_PL)ctl$gl_pcb); /* This is a multithreaded process with more than 1 execution context. */ my_id = swis$get_current_kt_id(); ktbvec = ctl$gl_pcb->pcb$l_ktbvec; return (ktbvec[my_id]); #endif #ifdef __ALPHA /* Verified for IA64 port - KLN; x86 - Clair Grant */ extern PCB_PL __RUNCONST ctl$gl_pcb; extern __RUNCONST int mmg$gl_bwp_mask; VOID_PQ pcbb; int my_id; KTB_PPL ktbvec; /* Does process have more than 1 execution context? */ if (ctl$gl_pcb->pcb$l_kt_count <= 1) return ((KTB_PL)ctl$gl_pcb); else { /* This is a multithreaded process with more than 1 execution context. */ pcbb = __PAL_MFPR_PCBB(); if ( (__int64) pcbb & (__int64) (FRED$K_LENGTH - 1)) return ((KTB_PL)ctl$gl_pcb); if (ctl$gl_pcb->pcb$v_fredlock == 0) { /* This is a multithreaded process with 1 FRED page */ my_id = (int) (((__int64) pcbb & (__int64) mmg$gl_bwp_mask) >> FRED$K_SHIFT); ktbvec = ctl$gl_pcb->pcb$l_ktbvec; return (ktbvec[my_id]); } else { /* This is a multithreaded process with more than 1 FRED page */ return (KTB_PL)(__PAL_LDQP((void *)((__int64)pcbb + FRED$C_KTB_KT_ID))); } } #endif } #pragma inline (get_curpkta) static PKTA * get_curpkta(void) { int my_id; extern int sys$get_kt_id(void); extern int ctl$gl_multithread; extern PKTA ctl$a_initial_pkta; #pragma __required_pointer_size __long /* And set ptr size default to 64-bit pointers */ extern PKTA **ctl$gq_pktavec; #pragma __required_pointer_size __short /* And set ptr size default to 32-bit pointers */ if (ctl$gl_multithread <= 1) return &ctl$a_initial_pkta; else { my_id = sys$get_kt_id(); return ((PKTA *) ctl$gq_pktavec[my_id]); } } #pragma __required_pointer_size __restore /* Restore the previously-defined required ptr size */ #endif /* __THREAD_MACROS_LOADED */