github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/guest_pci_configuration.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 _GUEST_PCI_CONFIG_H
    16  #define _GUEST_PCI_CONFIG_H
    17  
    18  #include "list.h"
    19  #include "host_pci_configuration.h"
    20  #include "vmm_objects.h"
    21  
    22  struct _GUEST_PCI_DEVICE;
    23  
    24  typedef void (*GUEST_PCI_READ_HANDLER) (
    25      GUEST_CPU_HANDLE  gcpu,
    26      struct _GUEST_PCI_DEVICE *pci_device,
    27      UINT32 port_id,
    28      UINT32 port_size,
    29      void   *value);
    30  
    31  typedef void (*GUEST_PCI_WRITE_HANDLER) (
    32      GUEST_CPU_HANDLE  gcpu,
    33      struct _GUEST_PCI_DEVICE *pci_device,
    34      UINT32 port_id,
    35      UINT32 port_size,
    36      void   *value);
    37  
    38  typedef struct _GPCI_GUEST_PROFILE
    39  {
    40      GUEST_PCI_READ_HANDLER pci_read;
    41      GUEST_PCI_WRITE_HANDLER pci_write;
    42  } GPCI_GUEST_PROFILE;
    43  
    44  
    45  typedef enum
    46  {
    47      GUEST_DEVICE_VIRTUALIZATION_DIRECT_ASSIGNMENT,    
    48      GUEST_DEVICE_VIRTUALIZATION_HIDDEN    
    49  } GUEST_DEVICE_VIRTUALIZATION_TYPE;
    50  
    51  typedef struct _GUEST_PCI_DEVICE
    52  {
    53      GUEST_ID                 guest_id;
    54      char                     padding[2];
    55      GUEST_DEVICE_VIRTUALIZATION_TYPE type;
    56      HOST_PCI_DEVICE         *host_device;
    57      GUEST_PCI_READ_HANDLER   pci_read;
    58      GUEST_PCI_WRITE_HANDLER  pci_write;
    59      UINT8                   *config_space;
    60  } GUEST_PCI_DEVICE;
    61  
    62  typedef struct _GUEST_PCI_DEVICES
    63  {
    64      GUEST_ID guest_id;
    65      char padding[2];
    66      UINT32 num_devices;
    67      GUEST_PCI_DEVICE devices[PCI_MAX_NUM_SUPPORTED_DEVICES + 1]; 
    68      PCI_DEV_INDEX device_lookup_table[PCI_MAX_NUM_FUNCTIONS]; // index 0 is reserved to mark "not-present" device
    69      LIST_ELEMENT guests[1];
    70      PCI_CONFIG_ADDRESS *gcpu_pci_access_address;
    71  } GUEST_PCI_DEVICES;
    72  
    73  BOOLEAN gpci_initialize(void);
    74  
    75  BOOLEAN gpci_guest_initialize(GUEST_ID guest_id);
    76  
    77  BOOLEAN gpci_register_device(GUEST_ID  guest_id,
    78            GUEST_DEVICE_VIRTUALIZATION_TYPE type, HOST_PCI_DEVICE *host_pci_device,
    79            UINT8*  config_space, GUEST_PCI_READ_HANDLER pci_read,
    80            GUEST_PCI_WRITE_HANDLER pci_write);
    81  
    82  #ifdef INCLUDE_UNUSED_CODE
    83  void gpci_unregister_device(GUEST_ID guest_id, UINT16 bus, 
    84                              UINT16 device, UINT16 function);
    85  #endif
    86  
    87  GUEST_ID gpci_get_device_guest_id(UINT16 bus, UINT16 device, 
    88                                    UINT16 function);
    89  
    90  #endif