#ifndef _SYS_APIC_COMMON_H
#define _SYS_APIC_COMMON_H
#include <sys/psm_types.h>
#include <sys/avintr.h>
#include <sys/privregs.h>
#include <sys/pci.h>
#include <sys/cyclic.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/psm_common.h>
enum apic_ioapic_method_type {
APIC_MUL_IOAPIC_NONE,
APIC_MUL_IOAPIC_MASK,
APIC_MUL_IOAPIC_DEOI,
APIC_MUL_IOAPIC_IOXAPIC,
APIC_MUL_IOAPIC_IIR,
APIC_MUL_IOAPIC_PCPLUSMP
};
#define APIX_IS_DIRECTED_EOI(type) \
((type) == APIC_MUL_IOAPIC_DEOI || (type) == APIC_MUL_IOAPIC_IIR)
#define APIX_IS_MASK_RDT(type) \
((type) == APIC_MUL_IOAPIC_NONE || (type) == APIC_MUL_IOAPIC_MASK)
extern int apix_enable;
extern int apix_loaded(void);
extern enum apic_ioapic_method_type apix_mul_ioapic_method;
extern int apic_oneshot;
extern int apic_oneshot_enable;
extern int apic_enable_dynamic_migration;
extern struct psm_ops *psmops;
extern volatile uint32_t *apicadr;
extern uchar_t apic_io_vectbase[MAX_IO_APIC];
extern uchar_t apic_io_vectend[MAX_IO_APIC];
extern uchar_t apic_io_ver[MAX_IO_APIC];
extern int apic_io_max;
extern int apic_nvidia_io_max;
extern int apic_setspl_delay;
extern int apic_clkvect;
extern int apic_errvect;
extern int apic_enable_error_intr;
extern int apic_error_display_delay;
extern int apic_cpcovf_vect;
extern int apic_enable_cpcovf_intr;
extern int apic_cmci_vect;
extern int cmi_enable_cmci;
extern void cmi_cmci_trap(void);
extern kmutex_t cmci_cpu_setup_lock;
extern int cmci_cpu_setup_registered;
extern int apic_forceload;
extern int apic_coarse_hrtime;
extern int apic_flat_model;
extern int apic_panic_on_nmi;
extern int apic_panic_on_apic_error;
extern int apic_verbose;
extern int apic_pir_vect;
#ifdef DEBUG
extern int apic_debug;
extern int apic_restrict_vector;
extern int apic_debug_msgbuf[APIC_DEBUG_MSGBUFSIZE];
extern int apic_debug_msgbufindex;
#endif
extern uint_t apic_nsec_per_intr;
extern uint_t apic_nticks;
extern uint_t apic_skipped_redistribute;
extern uint_t last_count_read;
extern lock_t apic_mode_switch_lock;
extern lock_t apic_gethrtime_lock;
extern volatile int apic_hrtime_stamp;
extern volatile hrtime_t apic_nsec_since_boot;
extern uint_t apic_hertz_count;
extern uint64_t apic_ticks_per_SFnsecs;
extern int apic_hrtime_error;
extern int apic_remote_hrterr;
extern int apic_num_nmis;
extern int apic_apic_error;
extern int apic_num_apic_errors;
extern int apic_num_cksum_errors;
extern int apic_error;
extern lock_t apic_nmi_lock;
extern lock_t apic_error_lock;
extern uint32_t apic_divide_reg_init;
extern apic_intrmap_ops_t *apic_vt_ops;
#ifdef DEBUG
extern int apic_break_on_cpu;
extern int apic_stretch_interrupts;
extern int apic_stretch_ISR;
#endif
extern cyclic_id_t apic_cyclic_id;
extern uint_t apic_nmi_intr(caddr_t arg, caddr_t);
extern int apic_clkinit();
extern hrtime_t apic_gettime();
extern hrtime_t apic_gethrtime();
extern int apic_cpu_start(processorid_t cpuid, caddr_t ctx);
extern int apic_cpu_stop(processorid_t cpuid, caddr_t ctx);
extern int apic_cpu_add(psm_cpu_request_t *reqp);
extern int apic_cpu_remove(psm_cpu_request_t *reqp);
extern int apic_cpu_ops(psm_cpu_request_t *reqp);
extern void apic_switch_ipi_callback(boolean_t enter);
extern void apic_send_ipi(int cpun, int ipl);
extern void apic_set_idlecpu(processorid_t cpun);
extern void apic_unset_idlecpu(processorid_t cpun);
extern void apic_shutdown(int cmd, int fcn);
extern void apic_preshutdown(int cmd, int fcn);
extern processorid_t apic_get_next_processorid(processorid_t cpun);
extern uint64_t apic_calibrate();
extern int apic_get_pir_ipivect(void);
extern void apic_send_pir_ipi(processorid_t);
extern int apic_error_intr();
extern void apic_cpcovf_mask_clear(void);
extern void apic_cmci_setup(processorid_t, boolean_t);
extern void apic_intrmap_init(int apic_mode);
extern processorid_t apic_find_cpu(int flag);
extern processorid_t apic_get_next_bind_cpu(void);
extern int apic_support_msi;
extern int apic_multi_msi_enable;
extern int apic_msix_enable;
extern uint32_t apic_get_localapicid(uint32_t cpuid);
extern uchar_t apic_get_ioapicid(uchar_t ioapicindex);
typedef enum nmi_action {
NMI_ACTION_UNSET,
NMI_ACTION_PANIC,
NMI_ACTION_IGNORE,
NMI_ACTION_KMDB
} nmi_action_t;
extern nmi_action_t nmi_action;
#ifdef __cplusplus
}
#endif
#endif