4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync/** @file
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * X86 (and AMD64) Local APIC registers (VMM,++).
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync *
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * apic.mac is generated from this file by running 'kmk incs' in the root.
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync */
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2010-2012 Oracle Corporation
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync *
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * available from http://www.virtualbox.org. This file is free software;
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * you can redistribute it and/or modify it under the terms of the GNU
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * General Public License (GPL) as published by the Free Software
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync *
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * The contents of this file may alternatively be used under the terms
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * of the Common Development and Distribution License Version 1.0
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * VirtualBox OSE distribution, in which case the provisions of the
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * CDDL are applicable instead of those of the GPL.
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync *
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * You may elect to license modified versions of this file under the
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync * terms and conditions of either the GPL or the CDDL or both.
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync */
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#ifndef ___VBox_apic_h
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#define ___VBox_apic_h
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync
7420e5ee5565b181c144eabb14da0da9e8cce657vboxsync#include <iprt/types.h>
7420e5ee5565b181c144eabb14da0da9e8cce657vboxsync
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#define APIC_REG_VERSION 0x0030
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_VERSION_GET_VER(u32) (u32 & 0xff)
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_VERSION_GET_MAX_LVT(u32) ((u32 & 0xff0000) >> 16)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync/* Defines according to Figure 10-8 of the Intel Software Developers Manual Vol 3A */
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#define APIC_REG_LVT_LINT0 0x0350
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#define APIC_REG_LVT_LINT1 0x0360
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#define APIC_REG_LVT_ERR 0x0370
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#define APIC_REG_LVT_PC 0x0340
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync#define APIC_REG_LVT_THMR 0x0330
6ba6cd69eba9efb4a3838ccf50235e68e8458f1avboxsync#define APIC_REG_LVT_CMCI 0x02F0
80df0ee26f97f8e12c6bb0506d4d901ce7a76357vboxsync#define APIC_REG_EILVT0 0x0500
80df0ee26f97f8e12c6bb0506d4d901ce7a76357vboxsync#define APIC_REG_EILVT1 0x0510
80df0ee26f97f8e12c6bb0506d4d901ce7a76357vboxsync#define APIC_REG_EILVT2 0x0520
73977ab417566ee6bc70654b77d1402ca47d6b67vboxsync#define APIC_REG_EILVT3 0x0530
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_MODE_MASK (RT_BIT(8) | RT_BIT(9) | RT_BIT(10))
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_MODE_FIXED 0
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_MODE_NMI RT_BIT(10)
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_MODE_EXTINT (RT_BIT(8) | RT_BIT(9) | RT_BIT(10))
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_PIN_POLARIY RT_BIT(13)
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_REMOTE_IRR RT_BIT(14)
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_LEVEL_TRIGGER RT_BIT(15)
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#define APIC_REG_LVT_MASKED RT_BIT(16)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync
56dd9cee948a9c54f78376adb1aa98b1b3214ee2vboxsyncDECLINLINE(uint32_t) ApicRegRead(void *pvBase, uint32_t offReg)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync{
56dd9cee948a9c54f78376adb1aa98b1b3214ee2vboxsync return *(const volatile uint32_t *)((uintptr_t)pvBase + offReg);
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync}
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync
6cac05f856d982151579a9d445a109960c2c07d2vboxsync
6cac05f856d982151579a9d445a109960c2c07d2vboxsync#ifdef ___iprt_asm_amd64_x86_h
6cac05f856d982151579a9d445a109960c2c07d2vboxsync/**
6cac05f856d982151579a9d445a109960c2c07d2vboxsync * Reads an X2APIC register.
6cac05f856d982151579a9d445a109960c2c07d2vboxsync *
6cac05f856d982151579a9d445a109960c2c07d2vboxsync * @param offReg MMIO offset, APIC_REG_XXX.
6cac05f856d982151579a9d445a109960c2c07d2vboxsync */
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncDECLINLINE(uint32_t) ApicX2RegRead32(uint32_t offReg)
6cac05f856d982151579a9d445a109960c2c07d2vboxsync{
6cac05f856d982151579a9d445a109960c2c07d2vboxsync return ASMRdMsr((offReg >> 4) + MSR_IA32_X2APIC_START);
6cac05f856d982151579a9d445a109960c2c07d2vboxsync}
6cac05f856d982151579a9d445a109960c2c07d2vboxsync#endif
6cac05f856d982151579a9d445a109960c2c07d2vboxsync
b25beb02262250b10b8ab40797a8b6c55fc81783vboxsync#endif /* ___VBox_apic_h */
7420e5ee5565b181c144eabb14da0da9e8cce657vboxsync