summaryrefslogtreecommitdiff
path: root/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SimicsUefiDeviceLib.h
blob: 894ad1e07d9a9c5bc1ba9c9152e1662f59a0e2db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/** @file
  Library for detecting and accessing the Simics UEFI PCI config device.

  Provides shared helpers that probe PCI config space for the virtual
  Simics device and perform subsequent reads/writes through the
  PCI Root Bridge I/O protocol.

  Copyright (c) 2026, Intel Corporation. All rights reserved. <BR>

  SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef SIMICS_UEFI_DEVICE_LIB_H_
#define SIMICS_UEFI_DEVICE_LIB_H_

/**
  Check for the presence of the Simics UEFI PCI config device.

  Reads PCDs for bus/device/function, assembles the PCI config address,
  locates the PCI Root Bridge I/O protocol, and probes the vendor /
  subsystem IDs to confirm the expected Simics device is present.

  @retval EFI_SUCCESS          The Simics UEFI device was found.
  @retval EFI_NOT_FOUND        The device is not present or IDs do not match.
  @retval other                LocateProtocol or PCI read failed.
**/
EFI_STATUS
EFIAPI
SimicsUefiDeviceCheck (
  VOID
  );

/**
  Read from PCI config space of the Simics UEFI device.

  Locates the device and reads at the given offset.  Callers that
  have already obtained the protocol / address via SimicsUefiDeviceCheck
  may use the protocol pointer directly instead.

  @param[in]  Offset  Byte offset within PCI config space.
  @param[in]  Width   Access width in bytes (1, 2, 4, or 8).
  @param[out] Buffer  Destination for the data read.

  @retval EFI_SUCCESS            Read completed successfully.
  @retval EFI_INVALID_PARAMETER  Width is not 1, 2, 4, or 8.
  @retval other                  Device not found or read failed.
**/
EFI_STATUS
EFIAPI
SimicsUefiDeviceRead (
  IN  UINT64  Offset,
  IN  UINT8   Width,
  OUT VOID    *Buffer
  );

/**
  Write to PCI config space of the Simics UEFI device.

  @param[in] Offset  Byte offset within PCI config space.
  @param[in] Width   Access width in bytes (1, 2, 4, or 8).
  @param[in] Buffer  Source data to write.

  @retval EFI_SUCCESS            Write completed successfully.
  @retval EFI_INVALID_PARAMETER  Width is not 1, 2, 4, or 8.
  @retval other                  Device not found or write failed.
**/
EFI_STATUS
EFIAPI
SimicsUefiDeviceWrite (
  IN UINT64  Offset,
  IN UINT8   Width,
  IN VOID    *Buffer
  );

#endif // SIMICS_UEFI_DEVICE_LIB_H_