/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72Q src/bos/kernel/sys/processor.h 1.17.1.3                         */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1993,2018              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/* @(#)48	1.17.1.3  src/bos/kernel/sys/processor.h, sysml, bos72Q, q2018_33A7 8/2/18 18:38:41 */

/*
 *   COMPONENT_NAME: SYSPROC
 *
 *   FUNCTIONS: none
 *
 *   ORIGINS: 27,83
 *
 *
 *   (C) COPYRIGHT International Business Machines Corp. 1993
 *   All Rights Reserved
 *   Licensed Materials - Property of IBM
 *   US Government Users Restricted Rights - Use, duplication or
 *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 */
#ifndef _H_PROCESSOR
#define _H_PROCESSOR

#include <sys/kerrno.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef short  cpu_t;                   /* logical processor ID              */
typedef short  cpuidx_t;                /* cpu index on srad                 */
typedef short  sradid_t;                /* logical Srad ID                   */
typedef short  processor_t;             /* physical processor ID             */
typedef short  smt_thread_priority_t;   /* SMT thread priority level         */
typedef unsigned short smt_thread_id_t; /* ID of an SMT thread within a core */

/*
 * Bind a process/thread to a processor 
 */
extern int bindprocessor(int What, int Who, cpu_t Where); 
/*
 * Values for What
 */
#define BINDPROCESS  1    /* Bind all threads in process Who        */
#define BINDTHREAD   2    /* Only bind thread Who                   */
/*
 * Values for Where
 */
#define PROCESSOR_CLASS_ANY ((cpu_t)(-1))  /* Unbound               */
/*
 * The next one is  T E M P O R A R I L Y !
 */
extern cpu_t mycpu(void);
/*
 * Kernel internal
 */
#ifdef _KERNEL
extern int switch_cpu(cpu_t Where, int Options);
#define SET_PROCESSOR_ID   1
#define RESET_PROCESSOR_ID 2
#define MP_MASTER          0
#define PREVIOUSLY_FUNNELLED 0x10000

extern unsigned long long kget_mypurr(void);
extern unsigned long long kget_my_spurr(void);
#endif	/* _KERNEL */

/*
 * Kernel Services
 */
typedef short jitter_dispatch_window_t;
#define UNFAVORED_JITTER_DISPATCH_WINDOW (0)
#define FAVORED_JITTER_DISPATCH_WINDOW   (1)

kerrno_t enable_jitter_dispatch_windows(int, int);
kerrno_t set_jitter_dispatch_window(jitter_dispatch_window_t);
kerrno_t disable_jitter_dispatch_windows(void);
kerrno_t set_elongated_decr(int, int);
kerrno_t reset_elongated_decr(void);
kerrno_t read_smt_priority(smt_thread_priority_t *);

/*
 * CPU Barrier Services
 */
extern void cpu_speculation_barrier(void);
extern void cpu_context_barrier(int);
#define CCB_EXIT	-1      /* Trusted context exit          */
#define CCB_ALL		 0      /* Trusted context entry or exit */
#define CCB_ENTRY	 1      /* Trusted context entry         */

#ifdef __cplusplus
}
#endif

#endif /* _H_PROCESSOR */
