# Copyright (c) 2021 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import array import fcntl import os import struct import uuid from autotest_lib.client.bin import test, utils from autotest_lib.client.common_lib import error class firmware_CheckEOPState(test.test): """Validates that the ME has been told by firmware that POST is done""" # Needed by autotest version = 1 def read_post_boot_state(self): """Fail if the ME should be capable of reporting EOP but doesn't.""" HECI_MKHI = uuid.UUID('{8e6a6715-9abc-4043-88ef-9e39c6f63e0f}') IOCTL_MEI_CONNECT_CLIENT = 0xc0104801 # _IOWR('H', 1, 16); try: mei_dev = os.open('/dev/mei0', os.O_RDWR) except OSError: raise error.TestFail('ME device not found, probably old kernel.') # Connect to MKHI buf = array.array('B', 16 * [0]) struct.pack_into('<16s', buf, 0, HECI_MKHI.bytes_le) fcntl.ioctl(mei_dev, IOCTL_MEI_CONNECT_CLIENT, buf) max_msg_length, protocol_version = struct.unpack_from('