]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiSmbusLibSmbus2Ppi/SmbusLib.c
894372289fda3a8ef8f1a953b743ce41dbfb6147
[mirror_edk2.git] / MdePkg / Library / PeiSmbusLibSmbus2Ppi / SmbusLib.c
1 /** @file
2 Implementation of SmBusLib class library for PEI phase.
3
4 Copyright (c) 2006 - 2008, Intel Corporation<BR>
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
16 #include "InternalSmbusLib.h"
17
18 /**
19 Executes an SMBUS quick read command.
20
21 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
22 Only the SMBUS slave address field of SmBusAddress is required.
23 If Status is not NULL, then the status of the executed command is returned in Status.
24 If PEC is set in SmBusAddress, then ASSERT().
25 If Command in SmBusAddress is not zero, then ASSERT().
26 If Length in SmBusAddress is not zero, then ASSERT().
27 If any reserved bits of SmBusAddress are set, then ASSERT().
28
29 @param SmBusAddress Address that encodes the SMBUS Slave Address,
30 SMBUS Command, SMBUS Data Length, and PEC.
31 @param Status Return status for the executed command.
32 This is an optional parameter and may be NULL.
33 RETURN_SUCCESS The SMBUS command was executed.
34 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
35 RETURN_DEVICE_ERROR The request was not completed because a failure
36 reflected in the Host Status Register bit. Device errors are a result
37 of a transaction collision, illegal command field, unclaimed cycle
38 (host initiated), or bus errors (collisions).
39 RETURN_UNSUPPORTED The SMBus operation is not supported.
40
41 **/
42 VOID
43 EFIAPI
44 SmBusQuickRead (
45 IN UINTN SmBusAddress,
46 OUT RETURN_STATUS *Status OPTIONAL
47 )
48 {
49 ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
50 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
51 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
52 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
53
54 InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);
55 }
56
57 /**
58 Executes an SMBUS quick write command.
59
60 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
61 Only the SMBUS slave address field of SmBusAddress is required.
62 If Status is not NULL, then the status of the executed command is returned in Status.
63 If PEC is set in SmBusAddress, then ASSERT().
64 If Command in SmBusAddress is not zero, then ASSERT().
65 If Length in SmBusAddress is not zero, then ASSERT().
66 If any reserved bits of SmBusAddress are set, then ASSERT().
67
68 @param SmBusAddress Address that encodes the SMBUS Slave Address,
69 SMBUS Command, SMBUS Data Length, and PEC.
70 @param Status Return status for the executed command.
71 This is an optional parameter and may be NULL.
72 RETURN_SUCCESS The SMBUS command was executed.
73 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
74 RETURN_DEVICE_ERROR The request was not completed because a failure
75 reflected in the Host Status Register bit. Device errors are a result
76 of a transaction collision, illegal command field, unclaimed cycle
77 (host initiated), or bus errors (collisions).
78 RETURN_UNSUPPORTED The SMBus operation is not supported.
79
80 **/
81 VOID
82 EFIAPI
83 SmBusQuickWrite (
84 IN UINTN SmBusAddress,
85 OUT RETURN_STATUS *Status OPTIONAL
86 )
87 {
88 ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
89 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
90 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
91 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
92
93 InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);
94 }
95
96 /**
97 Executes an SMBUS receive byte command.
98
99 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
100 Only the SMBUS slave address field of SmBusAddress is required.
101 The byte received from the SMBUS is returned.
102 If Status is not NULL, then the status of the executed command is returned in Status.
103 If Command in SmBusAddress is not zero, then ASSERT().
104 If Length in SmBusAddress is not zero, then ASSERT().
105 If any reserved bits of SmBusAddress are set, then ASSERT().
106
107 @param SmBusAddress Address that encodes the SMBUS Slave Address,
108 SMBUS Command, SMBUS Data Length, and PEC.
109 @param Status Return status for the executed command.
110 This is an optional parameter and may be NULL.
111 RETURN_SUCCESS The SMBUS command was executed.
112 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
113 RETURN_DEVICE_ERROR The request was not completed because a failure
114 reflected in the Host Status Register bit. Device errors are a result
115 of a transaction collision, illegal command field, unclaimed cycle
116 (host initiated), or bus errors (collisions).
117 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
118 RETURN_UNSUPPORTED The SMBus operation is not supported.
119
120 @return The byte received from the SMBUS.
121
122 **/
123 UINT8
124 EFIAPI
125 SmBusReceiveByte (
126 IN UINTN SmBusAddress,
127 OUT RETURN_STATUS *Status OPTIONAL
128 )
129 {
130 UINT8 Byte;
131
132 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
133 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
134 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
135
136 InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);
137
138 return Byte;
139 }
140
141 /**
142 Executes an SMBUS send byte command.
143
144 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
145 The byte specified by Value is sent.
146 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
147 If Status is not NULL, then the status of the executed command is returned in Status.
148 If Command in SmBusAddress is not zero, then ASSERT().
149 If Length in SmBusAddress is not zero, then ASSERT().
150 If any reserved bits of SmBusAddress are set, then ASSERT().
151
152 @param SmBusAddress Address that encodes the SMBUS Slave Address,
153 SMBUS Command, SMBUS Data Length, and PEC.
154 @param Value The 8-bit value to send.
155 @param Status Return status for the executed command.
156 This is an optional parameter and may be NULL.
157 RETURN_SUCCESS The SMBUS command was executed.
158 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
159 RETURN_DEVICE_ERROR The request was not completed because a failure
160 reflected in the Host Status Register bit. Device errors are a result
161 of a transaction collision, illegal command field, unclaimed cycle
162 (host initiated), or bus errors (collisions).
163 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
164 RETURN_UNSUPPORTED The SMBus operation is not supported.
165
166 @return The parameter of Value.
167
168 **/
169 UINT8
170 EFIAPI
171 SmBusSendByte (
172 IN UINTN SmBusAddress,
173 IN UINT8 Value,
174 OUT RETURN_STATUS *Status OPTIONAL
175 )
176 {
177 UINT8 Byte;
178
179 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
180 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
181 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
182
183 Byte = Value;
184 InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);
185
186 return Value;
187 }
188
189 /**
190 Executes an SMBUS read data byte command.
191
192 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
193 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
194 The 8-bit value read from the SMBUS is returned.
195 If Status is not NULL, then the status of the executed command is returned in Status.
196 If Length in SmBusAddress is not zero, then ASSERT().
197 If any reserved bits of SmBusAddress are set, then ASSERT().
198
199 @param SmBusAddress Address that encodes the SMBUS Slave Address,
200 SMBUS Command, SMBUS Data Length, and PEC.
201 @param Status Return status for the executed command.
202 This is an optional parameter and may be NULL.
203 RETURN_SUCCESS The SMBUS command was executed.
204 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
205 RETURN_DEVICE_ERROR The request was not completed because a failure
206 reflected in the Host Status Register bit. Device errors are a result
207 of a transaction collision, illegal command field, unclaimed cycle
208 (host initiated), or bus errors (collisions).
209 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
210 RETURN_UNSUPPORTED The SMBus operation is not supported.
211
212 @return The byte read from the SMBUS.
213
214 **/
215 UINT8
216 EFIAPI
217 SmBusReadDataByte (
218 IN UINTN SmBusAddress,
219 OUT RETURN_STATUS *Status OPTIONAL
220 )
221 {
222 UINT8 Byte;
223
224 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
225 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
226
227 InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);
228
229 return Byte;
230 }
231
232 /**
233 Executes an SMBUS write data byte command.
234
235 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
236 The 8-bit value specified by Value is written.
237 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
238 Value is returned.
239 If Status is not NULL, then the status of the executed command is returned in Status.
240 If Length in SmBusAddress is not zero, then ASSERT().
241 If any reserved bits of SmBusAddress are set, then ASSERT().
242
243 @param SmBusAddress Address that encodes the SMBUS Slave Address,
244 SMBUS Command, SMBUS Data Length, and PEC.
245 @param Value The 8-bit value to write.
246 @param Status Return status for the executed command.
247 This is an optional parameter and may be NULL.
248 RETURN_SUCCESS The SMBUS command was executed.
249 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
250 RETURN_DEVICE_ERROR The request was not completed because a failure
251 reflected in the Host Status Register bit. Device errors are a result
252 of a transaction collision, illegal command field, unclaimed cycle
253 (host initiated), or bus errors (collisions).
254 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
255 RETURN_UNSUPPORTED The SMBus operation is not supported.
256
257 @return The parameter of Value.
258
259 **/
260 UINT8
261 EFIAPI
262 SmBusWriteDataByte (
263 IN UINTN SmBusAddress,
264 IN UINT8 Value,
265 OUT RETURN_STATUS *Status OPTIONAL
266 )
267 {
268 UINT8 Byte;
269
270 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
271 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
272
273 Byte = Value;
274 InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);
275
276 return Value;
277 }
278
279 /**
280 Executes an SMBUS read data word command.
281
282 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
283 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
284 The 16-bit value read from the SMBUS is returned.
285 If Status is not NULL, then the status of the executed command is returned in Status.
286 If Length in SmBusAddress is not zero, then ASSERT().
287 If any reserved bits of SmBusAddress are set, then ASSERT().
288
289 @param SmBusAddress Address that encodes the SMBUS Slave Address,
290 SMBUS Command, SMBUS Data Length, and PEC.
291 @param Status Return status for the executed command.
292 This is an optional parameter and may be NULL.
293 RETURN_SUCCESS The SMBUS command was executed.
294 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
295 RETURN_DEVICE_ERROR The request was not completed because a failure
296 reflected in the Host Status Register bit. Device errors are a result
297 of a transaction collision, illegal command field, unclaimed cycle
298 (host initiated), or bus errors (collisions).
299 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
300 RETURN_UNSUPPORTED The SMBus operation is not supported.
301
302 @return The byte read from the SMBUS.
303
304 **/
305 UINT16
306 EFIAPI
307 SmBusReadDataWord (
308 IN UINTN SmBusAddress,
309 OUT RETURN_STATUS *Status OPTIONAL
310 )
311 {
312 UINT16 Word;
313
314 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
315 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
316
317 InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);
318
319 return Word;
320 }
321
322 /**
323 Executes an SMBUS write data word command.
324
325 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
326 The 16-bit value specified by Value is written.
327 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
328 Value is returned.
329 If Status is not NULL, then the status of the executed command is returned in Status.
330 If Length in SmBusAddress is not zero, then ASSERT().
331 If any reserved bits of SmBusAddress are set, then ASSERT().
332
333 @param SmBusAddress Address that encodes the SMBUS Slave Address,
334 SMBUS Command, SMBUS Data Length, and PEC.
335 @param Value The 16-bit value to write.
336 @param Status Return status for the executed command.
337 This is an optional parameter and may be NULL.
338 RETURN_SUCCESS The SMBUS command was executed.
339 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
340 RETURN_DEVICE_ERROR The request was not completed because a failure
341 reflected in the Host Status Register bit. Device errors are a result
342 of a transaction collision, illegal command field, unclaimed cycle
343 (host initiated), or bus errors (collisions).
344 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
345 RETURN_UNSUPPORTED The SMBus operation is not supported.
346
347 @return The parameter of Value.
348
349 **/
350 UINT16
351 EFIAPI
352 SmBusWriteDataWord (
353 IN UINTN SmBusAddress,
354 IN UINT16 Value,
355 OUT RETURN_STATUS *Status OPTIONAL
356 )
357 {
358 UINT16 Word;
359
360 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
361 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
362
363 Word = Value;
364 InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);
365
366 return Value;
367 }
368
369 /**
370 Executes an SMBUS process call command.
371
372 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
373 The 16-bit value specified by Value is written.
374 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
375 The 16-bit value returned by the process call command is returned.
376 If Status is not NULL, then the status of the executed command is returned in Status.
377 If Length in SmBusAddress is not zero, then ASSERT().
378 If any reserved bits of SmBusAddress are set, then ASSERT().
379
380 @param SmBusAddress Address that encodes the SMBUS Slave Address,
381 SMBUS Command, SMBUS Data Length, and PEC.
382 @param Value The 16-bit value to write.
383 @param Status Return status for the executed command.
384 This is an optional parameter and may be NULL.
385 RETURN_SUCCESS The SMBUS command was executed.
386 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
387 RETURN_DEVICE_ERROR The request was not completed because a failure
388 reflected in the Host Status Register bit. Device errors are a result
389 of a transaction collision, illegal command field, unclaimed cycle
390 (host initiated), or bus errors (collisions).
391 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
392 RETURN_UNSUPPORTED The SMBus operation is not supported.
393
394 @return The 16-bit value returned by the process call command.
395
396 **/
397 UINT16
398 EFIAPI
399 SmBusProcessCall (
400 IN UINTN SmBusAddress,
401 IN UINT16 Value,
402 OUT RETURN_STATUS *Status OPTIONAL
403 )
404 {
405 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
406 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
407
408 InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);
409
410 return Value;
411 }
412
413 /**
414 Executes an SMBUS read block command.
415
416 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
417 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
418 Bytes are read from the SMBUS and stored in Buffer.
419 The number of bytes read is returned, and will never return a value larger than 32-bytes.
420 If Status is not NULL, then the status of the executed command is returned in Status.
421 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
422 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
423 If Length in SmBusAddress is not zero, then ASSERT().
424 If Buffer is NULL, then ASSERT().
425 If any reserved bits of SmBusAddress are set, then ASSERT().
426
427 @param SmBusAddress Address that encodes the SMBUS Slave Address,
428 SMBUS Command, SMBUS Data Length, and PEC.
429 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
430 @param Status Return status for the executed command.
431 This is an optional parameter and may be NULL.
432 RETURN_SUCCESS The SMBUS command was executed.
433 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
434 RETURN_DEVICE_ERROR The request was not completed because a failure
435 reflected in the Host Status Register bit. Device errors are a result
436 of a transaction collision, illegal command field, unclaimed cycle
437 (host initiated), or bus errors (collisions).
438 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
439 RETURN_UNSUPPORTED The SMBus operation is not supported.
440
441 @return The number of bytes read.
442
443 **/
444 UINTN
445 EFIAPI
446 SmBusReadBlock (
447 IN UINTN SmBusAddress,
448 OUT VOID *Buffer,
449 OUT RETURN_STATUS *Status OPTIONAL
450 )
451 {
452 ASSERT (Buffer != NULL);
453 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
454 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
455
456 return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);
457 }
458
459 /**
460 Executes an SMBUS write block command.
461
462 Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
463 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
464 Bytes are written to the SMBUS from Buffer.
465 The number of bytes written is returned, and will never return a value larger than 32-bytes.
466 If Status is not NULL, then the status of the executed command is returned in Status.
467 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
468 If Buffer is NULL, then ASSERT().
469 If any reserved bits of SmBusAddress are set, then ASSERT().
470
471 @param SmBusAddress Address that encodes the SMBUS Slave Address,
472 MBUS Command, SMBUS Data Length, and PEC.
473 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
474 @param Status Return status for the executed command.
475 This is an optional parameter and may be NULL.
476 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
477 RETURN_DEVICE_ERROR The request was not completed because a failure
478 reflected in the Host Status Register bit. Device errors are a result
479 of a transaction collision, illegal command field, unclaimed cycle
480 (host initiated), or bus errors (collisions).
481 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
482 RETURN_UNSUPPORTED The SMBus operation is not supported.
483
484 @return The number of bytes written.
485
486 **/
487 UINTN
488 EFIAPI
489 SmBusWriteBlock (
490 IN UINTN SmBusAddress,
491 OUT VOID *Buffer,
492 OUT RETURN_STATUS *Status OPTIONAL
493 )
494 {
495 UINTN Length;
496
497 ASSERT (Buffer != NULL);
498 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
499 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
500 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
501
502 Length = SMBUS_LIB_LENGTH (SmBusAddress);
503 return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);
504 }
505
506 /**
507 Executes an SMBUS block process call command.
508
509 Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
510 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
511 Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
512 If Status is not NULL, then the status of the executed command is returned in Status.
513 It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
514 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
515 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
516 If WriteBuffer is NULL, then ASSERT().
517 If ReadBuffer is NULL, then ASSERT().
518 If any reserved bits of SmBusAddress are set, then ASSERT().
519
520 @param SmBusAddress Address that encodes the SMBUS Slave Address,
521 SMBUS Command, SMBUS Data Length, and PEC.
522 @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
523 @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
524 @param Status Return status for the executed command.
525 This is an optional parameter and may be NULL.
526 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
527 RETURN_DEVICE_ERROR The request was not completed because a failure
528 reflected in the Host Status Register bit. Device errors are a result
529 of a transaction collision, illegal command field, unclaimed cycle
530 (host initiated), or bus errors (collisions).
531 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
532 RETURN_UNSUPPORTED The SMBus operation is not supported.
533
534 @return The number of bytes written.
535
536 **/
537 UINTN
538 EFIAPI
539 SmBusBlockProcessCall (
540 IN UINTN SmBusAddress,
541 IN VOID *WriteBuffer,
542 OUT VOID *ReadBuffer,
543 OUT RETURN_STATUS *Status OPTIONAL
544 )
545 {
546 UINTN Length;
547
548 ASSERT (WriteBuffer != NULL);
549 ASSERT (ReadBuffer != NULL);
550 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
551 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
552 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
553
554 Length = SMBUS_LIB_LENGTH (SmBusAddress);
555 //
556 // Assuming that ReadBuffer is large enough to save another memory copy.
557 //
558 ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);
559 return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);
560 }