def _start_config(): global _configuration_started, _ip4cp, _tcp4sbp, _done_event, _reconfig_event if _configuration_started: return handles = list(efi.locate_handles(efi.EFI_IP4_CONFIG_PROTOCOL_GUID)) if not handles: raise IOError("EFI_IP4_CONFIG_PROTOCOL not available") _ip4cp = efi.EFI_IP4_CONFIG_PROTOCOL.from_handle(handles[0]) handles = list(efi.locate_handles(efi.EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID)) if not handles: raise IOError("EFI_TCP4_SERVICE_BINDING_PROTOCOL not available") _tcp4sbp = efi.EFI_TCP4_SERVICE_BINDING_PROTOCOL.from_handle(handles[0]) _done_event = efi.event_signal() _reconfig_event = efi.event_signal(abort=_stop_config) efi.check_status(_ip4cp.Start(_ip4cp, _done_event.event, _reconfig_event.event)) print("IP configuration started") _configuration_started = True
def get_protocol(c): return c.from_handle(efi.locate_handles(c.guid)[0])