github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/hw/mtrrs_abstraction.h (about)

     1  /*
     2   * Copyright (c) 2013 Intel Corporation
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *     http://www.apache.org/licenses/LICENSE-2.0
     8   * Unless required by applicable law or agreed to in writing, software
     9   * distributed under the License is distributed on an "AS IS" BASIS,
    10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11   * See the License for the specific language governing permissions and
    12   * limitations under the License.
    13   */
    14  
    15  #ifndef MTRR_ABSTRACTION_H
    16  #define MTRR_ABSTRACTION_H
    17  
    18  #include <vmm_defs.h>
    19  #include <vmm_phys_mem_types.h>
    20  
    21  #define IA32_MTRRCAP_ADDR  0xFE
    22  #define IA32_MTRR_DEF_TYPE_ADDR 0x2FF
    23  #define IA32_MTRR_FIX64K_00000_ADDR 0x250
    24  #define IA32_MTRR_FIX16K_80000_ADDR 0x258
    25  #define IA32_MTRR_FIX16K_A0000_ADDR 0x259
    26  #define IA32_MTRR_FIX4K_C0000_ADDR  0x268
    27  #define IA32_MTRR_FIX4K_C8000_ADDR  0x269
    28  #define IA32_MTRR_FIX4K_D0000_ADDR  0x26A
    29  #define IA32_MTRR_FIX4K_D8000_ADDR  0x26B
    30  #define IA32_MTRR_FIX4K_E0000_ADDR  0x26C
    31  #define IA32_MTRR_FIX4K_E8000_ADDR  0x26D
    32  #define IA32_MTRR_FIX4K_F0000_ADDR  0x26E
    33  #define IA32_MTRR_FIX4K_F8000_ADDR  0x26F
    34  #define IA32_MTRR_PHYSBASE0_ADDR    0x200
    35  #define IA32_MTRR_PHYSMASK0_ADDR    0x201
    36  #define IA32_MTRR_PHYSBASE1_ADDR    0x202
    37  #define IA32_MTRR_PHYSMASK1_ADDR    0x203
    38  #define IA32_MTRR_PHYSBASE2_ADDR    0x204
    39  #define IA32_MTRR_PHYSMASK2_ADDR    0x205
    40  #define IA32_MTRR_PHYSBASE3_ADDR    0x206
    41  #define IA32_MTRR_PHYSMASK3_ADDR    0x207
    42  #define IA32_MTRR_PHYSBASE4_ADDR    0x208
    43  #define IA32_MTRR_PHYSMASK4_ADDR    0x209
    44  #define IA32_MTRR_PHYSBASE5_ADDR    0x20a
    45  #define IA32_MTRR_PHYSMASK5_ADDR    0x20b
    46  #define IA32_MTRR_PHYSBASE6_ADDR    0x20c
    47  #define IA32_MTRR_PHYSMASK6_ADDR    0x20d
    48  #define IA32_MTRR_PHYSBASE7_ADDR    0x20e
    49  #define IA32_MTRR_PHYSMASK7_ADDR    0x20f
    50  #define IA32_MTRR_PHYSBASE8_ADDR    0x210
    51  #define IA32_MTRR_PHYSMASK8_ADDR    0x211
    52  #define IA32_MTRR_PHYSBASE9_ADDR    0x212
    53  #define IA32_MTRR_PHYSMASK9_ADDR    0x213
    54  
    55  /*
    56   * Needs to be changed as per the MTRR value above
    57   */
    58  #define IA32_MTRR_MAX_PHYSMASK_ADDR  IA32_MTRR_PHYSMASK9_ADDR
    59  
    60  
    61  /* Function: mtrrs_abstraction_bsp_initialize
    62  *  Description: This function must be called during initialization
    63  *               on BSP. It caches the MTRRs in its internal data structures.
    64  *  Return Value: TRUE in case of successful initialization, FALSE otherwise
    65  */
    66  BOOLEAN mtrrs_abstraction_bsp_initialize(void);
    67  
    68  /* Function: mtrrs_abstraction_ap_initialize
    69  *  Description: This function must be called during initialization
    70  *               on AP (not BSP). It checks whether cached information from
    71  *               BSP corresponds to current AP.
    72  *  Return Value: TRUE in case of successful initialization, FALSE otherwise
    73  */
    74  BOOLEAN mtrrs_abstraction_ap_initialize(void);
    75  
    76  
    77  /* Function: mtrrs_abstraction_get_memory_type
    78  *  Description: This function returns the memory type of given Host
    79  *               Physical Address (HPA)
    80  *  Return Value: Memory type.
    81  */
    82  VMM_PHYS_MEM_TYPE mtrrs_abstraction_get_memory_type(HPA address);
    83  
    84  VMM_PHYS_MEM_TYPE mtrrs_abstraction_get_range_memory_type(HPA address, OUT UINT64 *size,UINT64 totalsize);
    85  
    86  /* Function: mtrrs_abstraction_track_mtrr_update
    87  *  Description: This function must be called if any of MTRRs is updated in
    88  *               order to update its internal caches.
    89  *  Return Value: TRUE in case the update is successful
    90  *                FALSE in case the mtrr_index is wrong or value is invalid
    91  */
    92  BOOLEAN mtrrs_abstraction_track_mtrr_update(UINT32 mtrr_index, UINT64 value);
    93  
    94  /* Function: mtrrs_abstraction_get_num_of_variable_range_regs
    95  *  Description: This function returns the number of variable MTRRs
    96  *               supported by the processor
    97  *  Return Value: number of variable MTRRs
    98  */
    99  UINT32 mtrrs_abstraction_get_num_of_variable_range_regs(void);
   100  
   101  /* Function: mtrrs_is_variable_mtrrr_supported
   102  *  Description: This function returns whether the msr_id is
   103  *               supported by the processor or not
   104  *  Return Value: FALSE in case the MTRR MSR is unsupported on this processor
   105  *                TRUE in case the MSR is supported on this processor
   106  */
   107  BOOLEAN mtrrs_is_variable_mtrrr_supported(UINT32 msr_id);
   108  
   109  #endif