1/** 2 * @file apic_compat.h 3 * Definitions and functions for APIC interaction 4 * 5 * @remark Copyright 2002 OProfile authors 6 * @remark Read the file COPYING 7 * 8 * @author Philippe Elie 9 * @author John Levon 10 */ 11 12#ifndef APIC_COMPAT_H 13#define APIC_COMPAT_H 14 15#if V_BEFORE(2, 4, 0) 16/* even on SMP, some defines are missing in 2.2 */ 17#define APIC_LVR 0x30 18#define APIC_LVTPC 0x340 19#define APIC_LVTERR 0x370 20#define GET_APIC_VERSION(x) ((x)&0xFF) 21#define GET_APIC_MAXLVT(x) (((x) >> 16)&0xFF) 22#define APIC_INTEGRATED(x) ((x)&0xF0) 23#else 24#include <asm/apic.h> 25#include <asm/apicdef.h> 26#include <asm/mpspec.h> 27#endif 28 29#ifndef MSR_IA32_APICBASE 30#define MSR_IA32_APICBASE 0x1B 31#endif 32 33#ifndef APIC_SPIV_APIC_ENABLED 34#define APIC_SPIV_APIC_ENABLED (1 << 8) 35#endif 36 37#ifndef APIC_DEFAULT_PHYS_BASE 38#define APIC_DEFAULT_PHYS_BASE 0xfee00000 39#endif 40 41#if !defined(CONFIG_X86_LOCAL_APIC) 42 43#define APIC_DEFAULT_PHYS_BASE 0xfee00000 44#define APIC_SPIV 0xF0 45#define APIC_ESR 0x280 46#define APIC_LVTT 0x320 47#define APIC_LVT0 0x350 48#define APIC_LVT_MASKED (1 << 16) 49#define APIC_LVT_LEVEL_TRIGGER (1 << 15) 50#define APIC_MODE_NMI 0x4 51#define APIC_MODE_EXINT 0x7 52#define GET_APIC_DELIVERY_MODE(x) (((x) >> 8)&0x7) 53#define SET_APIC_DELIVERY_MODE(x, y) (((x)&~0x700)|((y) << 8)) 54#define APIC_LVT1 0x360 55#define APIC_SEND_PENDING (1 << 12) 56#define APIC_TDCR 0x3E0 57#define APIC_TDR_DIV_1 0xB 58 59/* when !CONFIG_X86_LOCAL_APIC we need to provide a valid va to map the 60 * the pa of APIC onto. This va must be un-cachable/un-swapable*/ 61/*#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))*/ 62extern unsigned long virt_apic_base; 63/* the other define above can be redefined until the ref is identical, this 64 * allow a compile time checking but this need to be redefined differently */ 65#undef APIC_BASE 66#define APIC_BASE virt_apic_base 67 68static __inline void apic_write(unsigned long reg, unsigned long v) 69{ 70 *((volatile u32 *)(APIC_BASE+reg)) = v; 71} 72 73static __inline unsigned long apic_read(unsigned long reg) 74{ 75 return *((volatile u32 *)(APIC_BASE+reg)); 76} 77 78#endif /* !defined(CONFIG_X86_LOCAL_APIC) */ 79 80#endif /* APIC_COMPAT_H */ 81