Quellcode durchsuchen

[efi] Raise TPL within EFI_USB_IO_PROTOCOL entry points

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 6 Jahren
Ursprung
Commit
f672a27b34
1 geänderte Dateien mit 41 neuen und 6 gelöschten Zeilen
  1. 41
    6
      src/interface/efi/efi_usb.c

+ 41
- 6
src/interface/efi/efi_usb.c Datei anzeigen

@@ -505,6 +505,7 @@ efi_usb_control_transfer ( EFI_USB_IO_PROTOCOL *usbio,
505 505
 			   EFI_USB_DATA_DIRECTION direction,
506 506
 			   UINT32 timeout, VOID *data, UINTN len,
507 507
 			   UINT32 *status ) {
508
+	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
508 509
 	struct efi_usb_interface *usbintf =
509 510
 		container_of ( usbio, struct efi_usb_interface, usbio );
510 511
 	struct efi_usb_device *usbdev = usbintf->usbdev;
@@ -512,6 +513,7 @@ efi_usb_control_transfer ( EFI_USB_IO_PROTOCOL *usbio,
512 513
 				 USB_REQUEST_TYPE ( packet->Request ) );
513 514
 	unsigned int value = le16_to_cpu ( packet->Value );
514 515
 	unsigned int index = le16_to_cpu ( packet->Index );
516
+	EFI_TPL saved_tpl;
515 517
 	int rc;
516 518
 
517 519
 	DBGC2 ( usbdev, "USBDEV %s control %04x:%04x:%04x:%04x %s %dms "
@@ -520,6 +522,9 @@ efi_usb_control_transfer ( EFI_USB_IO_PROTOCOL *usbio,
520 522
 		efi_usb_direction_name ( direction ), timeout, data,
521 523
 		( ( size_t ) len ) );
522 524
 
525
+	/* Raise TPL */
526
+	saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
527
+
523 528
 	/* Clear status */
524 529
 	*status = 0;
525 530
 
@@ -563,6 +568,7 @@ efi_usb_control_transfer ( EFI_USB_IO_PROTOCOL *usbio,
563 568
 
564 569
  err_control:
565 570
  err_change_config:
571
+	bs->RestoreTPL ( saved_tpl );
566 572
 	return EFIRC ( rc );
567 573
 }
568 574
 
@@ -580,16 +586,21 @@ efi_usb_control_transfer ( EFI_USB_IO_PROTOCOL *usbio,
580 586
 static EFI_STATUS EFIAPI
581 587
 efi_usb_bulk_transfer ( EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data,
582 588
 			UINTN *len, UINTN timeout, UINT32 *status ) {
589
+	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
583 590
 	struct efi_usb_interface *usbintf =
584 591
 		container_of ( usbio, struct efi_usb_interface, usbio );
585 592
 	struct efi_usb_device *usbdev = usbintf->usbdev;
586 593
 	size_t actual = *len;
594
+	EFI_TPL saved_tpl;
587 595
 	int rc;
588 596
 
589 597
 	DBGC2 ( usbdev, "USBDEV %s bulk %s %p+%zx %dms\n", usbintf->name,
590 598
 		( ( endpoint & USB_ENDPOINT_IN ) ? "IN" : "OUT" ), data,
591 599
 		( ( size_t ) *len ), ( ( unsigned int ) timeout ) );
592 600
 
601
+	/* Raise TPL */
602
+	saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
603
+
593 604
 	/* Clear status */
594 605
 	*status = 0;
595 606
 
@@ -599,10 +610,12 @@ efi_usb_bulk_transfer ( EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data,
599 610
 					    data, &actual ) ) != 0 ) {
600 611
 		/* Assume that any error represents a timeout */
601 612
 		*status = EFI_USB_ERR_TIMEOUT;
602
-		return rc;
613
+		goto err_transfer;
603 614
 	}
604 615
 
605
-	return 0;
616
+ err_transfer:
617
+	bs->RestoreTPL ( saved_tpl );
618
+	return EFIRC ( rc );
606 619
 }
607 620
 
608 621
 /**
@@ -620,16 +633,21 @@ static EFI_STATUS EFIAPI
620 633
 efi_usb_sync_interrupt_transfer ( EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint,
621 634
 				  VOID *data, UINTN *len, UINTN timeout,
622 635
 				  UINT32 *status ) {
636
+	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
623 637
 	struct efi_usb_interface *usbintf =
624 638
 		container_of ( usbio, struct efi_usb_interface, usbio );
625 639
 	struct efi_usb_device *usbdev = usbintf->usbdev;
626 640
 	size_t actual = *len;
641
+	EFI_TPL saved_tpl;
627 642
 	int rc;
628 643
 
629 644
 	DBGC2 ( usbdev, "USBDEV %s sync intr %s %p+%zx %dms\n", usbintf->name,
630 645
 		( ( endpoint & USB_ENDPOINT_IN ) ? "IN" : "OUT" ), data,
631 646
 		( ( size_t ) *len ), ( ( unsigned int ) timeout ) );
632 647
 
648
+	/* Raise TPL */
649
+	saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
650
+
633 651
 	/* Clear status */
634 652
 	*status = 0;
635 653
 
@@ -639,10 +657,12 @@ efi_usb_sync_interrupt_transfer ( EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint,
639 657
 					    timeout, data, &actual ) ) != 0 ) {
640 658
 		/* Assume that any error represents a timeout */
641 659
 		*status = EFI_USB_ERR_TIMEOUT;
642
-		return rc;
660
+		goto err_transfer;
643 661
 	}
644 662
 
645
-	return 0;
663
+ err_transfer:
664
+	bs->RestoreTPL ( saved_tpl );
665
+	return EFIRC ( rc );
646 666
 }
647 667
 
648 668
 /**
@@ -662,9 +682,11 @@ efi_usb_async_interrupt_transfer ( EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint,
662 682
 				   BOOLEAN start, UINTN interval, UINTN len,
663 683
 				   EFI_ASYNC_USB_TRANSFER_CALLBACK callback,
664 684
 				   VOID *context ) {
685
+	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
665 686
 	struct efi_usb_interface *usbintf =
666 687
 		container_of ( usbio, struct efi_usb_interface, usbio );
667 688
 	struct efi_usb_device *usbdev = usbintf->usbdev;
689
+	EFI_TPL saved_tpl;
668 690
 	int rc;
669 691
 
670 692
 	DBGC2 ( usbdev, "USBDEV %s async intr %s len %#zx int %d %p/%p\n",
@@ -673,6 +695,9 @@ efi_usb_async_interrupt_transfer ( EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint,
673 695
 		( ( size_t ) len ), ( ( unsigned int ) interval ),
674 696
 		callback, context );
675 697
 
698
+	/* Raise TPL */
699
+	saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
700
+
676 701
 	/* Start/stop transfer as applicable */
677 702
 	if ( start ) {
678 703
 
@@ -687,11 +712,13 @@ efi_usb_async_interrupt_transfer ( EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint,
687 712
 		/* Stop transfer */
688 713
 		efi_usb_async_stop ( usbintf, endpoint );
689 714
 
690
-	}
715
+		/* Success */
716
+		rc = 0;
691 717
 
692
-	return 0;
718
+	}
693 719
 
694 720
  err_start:
721
+	bs->RestoreTPL ( saved_tpl );
695 722
 	return EFIRC ( rc );
696 723
 }
697 724
 
@@ -889,12 +916,16 @@ efi_usb_get_string_descriptor ( EFI_USB_IO_PROTOCOL *usbio, UINT16 language,
889 916
 	struct usb_descriptor_header header;
890 917
 	VOID *buffer;
891 918
 	size_t len;
919
+	EFI_TPL saved_tpl;
892 920
 	EFI_STATUS efirc;
893 921
 	int rc;
894 922
 
895 923
 	DBGC2 ( usbdev, "USBDEV %s get string %d:%d descriptor\n",
896 924
 		usbintf->name, language, index );
897 925
 
926
+	/* Raise TPL */
927
+	saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
928
+
898 929
 	/* Read descriptor header */
899 930
 	if ( ( rc = usb_get_descriptor ( usbdev->usb, 0, USB_STRING_DESCRIPTOR,
900 931
 					 index, language, &header,
@@ -928,6 +959,9 @@ efi_usb_get_string_descriptor ( EFI_USB_IO_PROTOCOL *usbio, UINT16 language,
928 959
 		  ( len - sizeof ( header ) ) );
929 960
 	memset ( ( buffer + len - sizeof ( header ) ), 0, sizeof ( **string ) );
930 961
 
962
+	/* Restore TPL */
963
+	bs->RestoreTPL ( saved_tpl );
964
+
931 965
 	/* Return allocated string */
932 966
 	*string = buffer;
933 967
 	return 0;
@@ -936,6 +970,7 @@ efi_usb_get_string_descriptor ( EFI_USB_IO_PROTOCOL *usbio, UINT16 language,
936 970
 	bs->FreePool ( buffer );
937 971
  err_alloc:
938 972
  err_get_header:
973
+	bs->RestoreTPL ( saved_tpl );
939 974
 	return EFIRC ( rc );
940 975
 }
941 976
 

Laden…
Abbrechen
Speichern