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
313UINT16
314EFIAPI
316 IN UINTN SmBusAddress,
317 OUT RETURN_STATUS *Status OPTIONAL
318 )
319{
320 UINT16 Word;
321
322 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
323 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
324
325 InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);
326
327 return Word;
328}
329
360UINT16
361EFIAPI
363 IN UINTN SmBusAddress,
364 IN UINT16 Value,
365 OUT RETURN_STATUS *Status OPTIONAL
366 )
367{
368 UINT16 Word;
369
370 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
371 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
372
373 Word = Value;
374 InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);
375
376 return Value;
377}
378
409UINT16
410EFIAPI
412 IN UINTN SmBusAddress,
413 IN UINT16 Value,
414 OUT RETURN_STATUS *Status OPTIONAL
415 )
416{
417 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
418 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
419
420 InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);
421
422 return Value;
423}
424
458UINTN
459EFIAPI
461 IN UINTN SmBusAddress,
462 OUT VOID *Buffer,
463 OUT RETURN_STATUS *Status OPTIONAL
464 )
465{
466 ASSERT (Buffer != NULL);
467 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
468 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
469
470 return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);
471}
472
503UINTN
504EFIAPI
506 IN UINTN SmBusAddress,
507 OUT VOID *Buffer,
508 OUT RETURN_STATUS *Status OPTIONAL
509 )
510{
511 UINTN Length;
512
513 ASSERT (Buffer != NULL);
514 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
515 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
516 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
517
518 Length = SMBUS_LIB_LENGTH (SmBusAddress);
519 return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);
520}
521
555UINTN
556EFIAPI
558 IN UINTN SmBusAddress,
559 IN VOID *WriteBuffer,
560 OUT VOID *ReadBuffer,
561 OUT RETURN_STATUS *Status OPTIONAL
562 )
563{
564 UINTN Length;
565
566 ASSERT (WriteBuffer != NULL);
567 ASSERT (ReadBuffer != NULL);
568 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
569 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
570 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
571
572 Length = SMBUS_LIB_LENGTH (SmBusAddress);
573 //
574 // Assuming that ReadBuffer is large enough to save another memory copy.
575 //
576 ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);
577 return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);
578}
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