summaryrefslogtreecommitdiff
path: root/lib/efi_selftest
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-09-06 08:04:08 -0400
committerTom Rini <trini@konsulko.com>2019-09-06 08:04:08 -0400
commit6128e61429a5d989cbb1e1a92b02791f69615c42 (patch)
treef463d4e65bc5bec09c7cf6ee8a01991e441841e1 /lib/efi_selftest
parentece9834f7d223097cec92e3d3c70cd37b3768482 (diff)
parentfe1a81c1a47737d3ce6b6855a05468b7546d4982 (diff)
Merge tag 'efi-2019-10-rc4-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for v2019.10-rc4 (3) This includes the patches from Pull request for UEFI sub-system for v2019.10-rc4 (2) Fix UEFI specification compliance issues in the simple network protocol: * Correctly set and reset the interrupt status. * Support filling the header in the Transmit() service. * Correct the checking and setting of the network state. * Implement the MCastIPtoMAC() service. * Adjust the simple network protocol unit test. Fix UEFI specification compliance issues in the protocol. Fix UEFI specification compliance issues in the simple text output protocol: * Avoid out of bounds cursor position. * Do not set illegal screen mode. Fix UEFI specification compliance issues in the block IO protocol: * Check parameters. * Return correct status code if buffer is unaligned. Refactor initialization of EFI memory in preparation of support for > 3GB memory on x86.
Diffstat (limited to 'lib/efi_selftest')
-rw-r--r--lib/efi_selftest/efi_selftest_snp.c64
1 files changed, 56 insertions, 8 deletions
diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c
index 4c26619001..9797ecaf42 100644
--- a/lib/efi_selftest/efi_selftest_snp.c
+++ b/lib/efi_selftest/efi_selftest_snp.c
@@ -228,6 +228,26 @@ static int setup(const efi_handle_t handle,
efi_st_error("WaitForPacket event missing\n");
return EFI_ST_FAILURE;
}
+ if (net->mode->state == EFI_NETWORK_INITIALIZED) {
+ /*
+ * Shut down network adapter.
+ */
+ ret = net->shutdown(net);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to shut down network adapter\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+ if (net->mode->state == EFI_NETWORK_STARTED) {
+ /*
+ * Stop network adapter.
+ */
+ ret = net->stop(net);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to stop network adapter\n");
+ return EFI_ST_FAILURE;
+ }
+ }
/*
* Start network adapter.
*/
@@ -236,6 +256,10 @@ static int setup(const efi_handle_t handle,
efi_st_error("Failed to start network adapter\n");
return EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_STARTED) {
+ efi_st_error("Failed to start network adapter\n");
+ return EFI_ST_FAILURE;
+ }
/*
* Initialize network adapter.
*/
@@ -244,6 +268,10 @@ static int setup(const efi_handle_t handle,
efi_st_error("Failed to initialize network adapter\n");
return EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_INITIALIZED) {
+ efi_st_error("Failed to initialize network adapter\n");
+ return EFI_ST_FAILURE;
+ }
return EFI_ST_SUCCESS;
}
@@ -268,6 +296,7 @@ static int execute(void)
struct efi_mac_address destaddr;
size_t buffer_size;
u8 *addr;
+
/*
* The timeout is to occur after 10 s.
*/
@@ -298,6 +327,8 @@ static int execute(void)
events[0] = timer;
events[1] = net->wait_for_packet;
for (;;) {
+ u32 int_status;
+
/*
* Wait for packet to be received or timer event.
*/
@@ -323,8 +354,17 @@ static int execute(void)
* Receive packet
*/
buffer_size = sizeof(buffer);
- net->receive(net, NULL, &buffer_size, &buffer,
- &srcaddr, &destaddr, NULL);
+ ret = net->get_status(net, &int_status, NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to get status");
+ return EFI_ST_FAILURE;
+ }
+ if (!(int_status & EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT)) {
+ efi_st_error("RX interrupt not set");
+ return EFI_ST_FAILURE;
+ }
+ ret = net->receive(net, NULL, &buffer_size, &buffer,
+ &srcaddr, &destaddr, NULL);
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to receive packet");
return EFI_ST_FAILURE;
@@ -400,21 +440,29 @@ static int teardown(void)
}
if (net) {
/*
- * Stop network adapter.
+ * Shut down network adapter.
*/
- ret = net->stop(net);
+ ret = net->shutdown(net);
if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to stop network adapter\n");
+ efi_st_error("Failed to shut down network adapter\n");
exit_status = EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_STARTED) {
+ efi_st_error("Failed to shutdown network adapter\n");
+ return EFI_ST_FAILURE;
+ }
/*
- * Shut down network adapter.
+ * Stop network adapter.
*/
- ret = net->shutdown(net);
+ ret = net->stop(net);
if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to shut down network adapter\n");
+ efi_st_error("Failed to stop network adapter\n");
exit_status = EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_STOPPED) {
+ efi_st_error("Failed to stop network adapter\n");
+ return EFI_ST_FAILURE;
+ }
}
return exit_status;