]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h
Check in driver to produce CPU I/O 2 Protocol for IA32 and X64 architecture.
[mirror_edk2.git] / UefiCpuPkg / CpuIo2Dxe / CpuIo2Dxe.h
1 /** @file
2 Internal include file for the CPU I/O 2 Protocol implementation.
3
4 Copyright (c) 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _CPU_IO2_H_
16 #define _CPU_IO2_H_
17
18 #include <Protocol/CpuIo2.h>
19
20 #include <Library/DebugLib.h>
21 #include <Library/IoLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/UefiBootServicesTableLib.h>
24
25 #define IA32_MAX_IO_ADDRESS 0xFFFF
26
27 typedef union {
28 UINT8 volatile *Buf;
29 UINT8 volatile *Ui8;
30 UINT16 volatile *Ui16;
31 UINT32 volatile *Ui32;
32 UINT64 volatile *Ui64;
33 UINTN volatile Ui;
34 } PTR;
35
36 /**
37 Enables a driver to read memory-mapped registers in the PI System memory space.
38
39 @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance.
40 @param[in] Width Signifies the width of the memory operation.
41 @param[in] Address The base address of the memory operation.
42 @param[in] Count The number of memory operations to perform. The number of bytes moved
43 is Width size * Count, starting at Address.
44 @param[out] Buffer The destination buffer to store the results.
45
46 @retval EFI_SUCCESS The data was read from or written to the EFI system.
47 @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. Or Buffer is NULL.
48 @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width.
49 Or,The address range specified by Address, Width, and Count is not valid for this EFI system.
50
51 **/
52 EFI_STATUS
53 EFIAPI
54 CpuMemoryServiceRead (
55 IN EFI_CPU_IO2_PROTOCOL *This,
56 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
57 IN UINT64 Address,
58 IN UINTN Count,
59 OUT VOID *Buffer
60 );
61
62 /**
63 Enables a driver to write memory-mapped registers in the PI System memory space.
64
65 @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance.
66 @param[in] Width Signifies the width of the memory operation.
67 @param[in] Address The base address of the memory operation.
68 @param[in] Count The number of memory operations to perform. The number of bytes moved
69 is Width size * Count, starting at Address.
70 @param[in] Buffer The source buffer from which to write data.
71
72 @retval EFI_SUCCESS The data was read from or written to the EFI system.
73 @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. Or Buffer is NULL.
74 @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width.
75 Or,The address range specified by Address, Width, and Count is not valid for this EFI system.
76
77 **/
78 EFI_STATUS
79 EFIAPI
80 CpuMemoryServiceWrite (
81 IN EFI_CPU_IO2_PROTOCOL *This,
82 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
83 IN UINT64 Address,
84 IN UINTN Count,
85 IN VOID *Buffer
86 );
87
88 /**
89 Enables a driver to read registers in the PI CPU I/O space.
90
91 @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance.
92 @param[in] Width Signifies the width of the I/O operation.
93 @param[in] UserAddress The base address of the I/O operation. The caller is responsible
94 for aligning the Address if required.
95 @param[in] Count The number of I/O operations to perform. The number of bytes moved
96 is Width size * Count, starting at Address.
97 @param[out] UserBuffer The destination buffer to store the results.
98
99 @retval EFI_SUCCESS The data was read from or written to the EFI system.
100 @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. Or Buffer is NULL.
101 @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width.
102 Or,The address range specified by Address, Width, and Count is not valid for this EFI system.
103
104 **/
105 EFI_STATUS
106 EFIAPI
107 CpuIoServiceRead (
108 IN EFI_CPU_IO2_PROTOCOL *This,
109 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
110 IN UINT64 UserAddress,
111 IN UINTN Count,
112 OUT VOID *UserBuffer
113 );
114
115 /**
116 Enables a driver to write registers in the PI CPU I/O space.
117
118 @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance.
119 @param[in] Width Signifies the width of the I/O operation.
120 @param[in] UserAddress The base address of the I/O operation. The caller is responsible
121 for aligning the Address if required.
122 @param[in] Count The number of I/O operations to perform. The number of bytes moved
123 is Width size * Count, starting at Address.
124 @param[in] UserBuffer The source buffer from which to write data.
125
126 @retval EFI_SUCCESS The data was read from or written to the EFI system.
127 @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. Or Buffer is NULL.
128 @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width.
129 Or,The address range specified by Address, Width, and Count is not valid for this EFI system.
130
131 **/
132 EFI_STATUS
133 EFIAPI
134 CpuIoServiceWrite (
135 IN EFI_CPU_IO2_PROTOCOL *This,
136 IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
137 IN UINT64 UserAddress,
138 IN UINTN Count,
139 IN VOID *UserBuffer
140 );
141
142 #endif