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