TianoCore EDK2 master
Loading...
Searching...
No Matches
SmbusLib.c
Go to the documentation of this file.
1
10#include "InternalSmbusLib.h"
11
38VOID
39EFIAPI
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
79VOID
80EFIAPI
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
123UINT8
124EFIAPI
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
171UINT8
172EFIAPI
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
219UINT8
220EFIAPI
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
266UINT8
267EFIAPI
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
314UINT16
315EFIAPI
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
362UINT16
363EFIAPI
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
412UINT16
413EFIAPI
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
463UINTN
464EFIAPI
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
510UINTN
511EFIAPI
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
563UINTN
564EFIAPI
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}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINT16 EFIAPI SmBusReadDataWord(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:316
UINT8 EFIAPI SmBusWriteDataByte(IN UINTN SmBusAddress, IN UINT8 Value, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:268
UINTN EFIAPI SmBusWriteBlock(IN UINTN SmBusAddress, OUT VOID *Buffer, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:512
UINT16 EFIAPI SmBusProcessCall(IN UINTN SmBusAddress, IN UINT16 Value, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:414
VOID EFIAPI SmBusQuickWrite(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:81
UINTN EFIAPI SmBusReadBlock(IN UINTN SmBusAddress, OUT VOID *Buffer, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:465
UINT8 EFIAPI SmBusReceiveByte(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:125
VOID EFIAPI SmBusQuickRead(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:40
UINT16 EFIAPI SmBusWriteDataWord(IN UINTN SmBusAddress, IN UINT16 Value, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:364
UINTN EFIAPI SmBusBlockProcessCall(IN UINTN SmBusAddress, IN VOID *WriteBuffer, OUT VOID *ReadBuffer, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:565
UINT8 EFIAPI SmBusSendByte(IN UINTN SmBusAddress, IN UINT8 Value, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:173
UINT8 EFIAPI SmBusReadDataByte(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
Definition: SmbusLib.c:221
UINTN InternalSmBusExec(IN EFI_SMBUS_OPERATION SmbusOperation, IN UINTN SmBusAddress, IN UINTN Length, IN OUT VOID *Buffer, OUT RETURN_STATUS *Status OPTIONAL)
Definition: DxeSmbusLib.c:69
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define SMBUS_LIB_LENGTH(SmBusAddress)
Definition: SmbusLib.h:53
#define SMBUS_LIB_RESERVED(SmBusAddress)
Definition: SmbusLib.h:67
#define SMBUS_LIB_COMMAND(SmBusAddress)
Definition: SmbusLib.h:46
#define SMBUS_LIB_PEC(SmBusAddress)
Definition: SmbusLib.h:60