github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/host/hw/reset.c (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  #include "vmm_defs.h"
    16  #include "hw_utils.h"
    17  #include "common_libc.h"
    18  #include "vmm_dbg.h"
    19  #include "file_codes.h"
    20  #define VMM_DEADLOOP()          VMM_DEADLOOP_LOG(RESET_C)
    21  #define VMM_ASSERT(__condition) VMM_ASSERT_LOG(RESET_C, __condition)
    22  #ifdef JLMDEBUG
    23  #include "jlmdebug.h"
    24  #endif
    25  
    26  #pragma warning( disable : 4214) // warning C4214: nonstandard extension used : bit field types other than int
    27  // With the default Microsoft extensions (/Ze), bitfield structure members can be of any integer type.
    28  
    29  #define RESET_CONTROL_REGISTER_IO_PORT         0xCF9
    30  
    31  typedef enum {
    32      SystemResetBit = 1, // 0 = cpu_reset generates an INIT(Soft Reset), 1 = cpu_reset generates platform reset (Hard Reset)
    33      CpuResetBit    = 2, // 0->1 transition generates the reset type specified by system_reset
    34      FullResetBit   = 3
    35  } RESET_CONTROL_REGISTER_BITS;
    36  
    37  #define SET_SYSTEM_RESET( v )  BIT_SET( v, SystemResetBit )
    38  #define CLR_SYSTEM_RESET( v )  BIT_CLR( v, SystemResetBit )
    39  #define GET_SYSTEM_RESET( v )  BIT_GET( v, SystemResetBit )
    40  
    41  #define SET_CPU_RESET( v )  BIT_SET( v, CpuResetBit )
    42  #define CLR_CPU_RESET( v )  BIT_CLR( v, CpuResetBit )
    43  #define GET_CPU_RESET( v )  BIT_GET( v, CpuResetBit )
    44  
    45  #define SET_FULL_RESET( v )  BIT_SET( v, FullResetBit )
    46  #define CLR_FULL_RESET( v )  BIT_CLR( v, FullResetBit )
    47  #define GET_FULL_RESET( v )  BIT_GET( v, FullResetBit )
    48  
    49  void hw_reset_platform(void)
    50  {
    51    UINT8  reset_control_register;
    52  
    53    // Write the ICH register required to perform a platform reset (Cold Reset)
    54    reset_control_register = hw_read_port_8(RESET_CONTROL_REGISTER_IO_PORT);
    55  
    56    SET_CPU_RESET( reset_control_register );
    57    SET_SYSTEM_RESET( reset_control_register );
    58  
    59    hw_write_port_8 (RESET_CONTROL_REGISTER_IO_PORT, reset_control_register);
    60  
    61    // Never returns
    62    VMM_DEADLOOP ();
    63  }
    64