From 62eeb52af7efe656f518baf59555e29c15bfa3be Mon Sep 17 00:00:00 2001 From: Elvin Li Date: Tue, 10 Dec 2013 01:42:56 +0000 Subject: Per PI 1.3 spec, when Reserved bit set in the SlaveAddress parameter, EFI_NOT_FOUND should be returned in EFI_I2C_HOST_PROTOCOL.QueueRequest(). Signed-off-by: Elvin Li Reviewed-by: Leahy Leroy P Reviewed-by: Lin Jie git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14952 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'MdeModulePkg/Bus/I2c') diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c index e153a4dc2b..392ca2ade5 100644 --- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c +++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c @@ -930,6 +930,7 @@ I2cHostQueueRequest ( I2C_HOST_CONTEXT *I2cHostContext; BOOLEAN FirstRequest; UINTN RequestPacketSize; + UINTN StartBit; SyncEvent = NULL; FirstRequest = FALSE; @@ -938,6 +939,27 @@ I2cHostQueueRequest ( if (RequestPacket == NULL) { return EFI_INVALID_PARAMETER; } + + if ((SlaveAddress & I2C_ADDRESSING_10_BIT) != 0) { + // + // 10-bit address, bits 0-9 are used for 10-bit I2C slave addresses, + // bits 10-30 are reserved bits and must be zero + // + StartBit = 10; + } else { + // + // 7-bit address, Bits 0-6 are used for 7-bit I2C slave addresses, + // bits 7-30 are reserved bits and must be zero + // + StartBit = 7; + } + + if (BitFieldRead32 ((UINT32)SlaveAddress, StartBit, 30) != 0) { + // + // Reserved bit set in the SlaveAddress parameter + // + return EFI_NOT_FOUND; + } I2cHostContext = I2C_HOST_CONTEXT_FROM_PROTOCOL (This); -- cgit v1.2.3