42
42
#include "ewlog.h"
43
43
#include "heci_impl.h"
44
44
#include "heci_protocol.h"
45
+ #include "heci2_protocol.h"
45
46
46
47
#define UNUSED_PARAM __attribute__((__unused__))
47
48
48
49
#define CPMS 19200
49
50
#define HPET_BASE_ADDRESS 0xFED00000
50
51
#define ClockCycles () read32((void *)(HPET_BASE_ADDRESS + 0xf0))
51
52
53
+ static EFI_HECI_PROTOCOL * heci ;
54
+
52
55
static void init_timer (void )
53
56
{
54
57
uint32_t reg ;
@@ -574,9 +577,77 @@ static EFI_STATUS EFIAPI HeciSubmitCommand(
574
577
return EFI_UNSUPPORTED ;
575
578
}
576
579
580
+ static EFIAPI EFI_STATUS
581
+ heci2_send_w_ack (UNUSED_PARAM HECI2_DEVICE HeciDev ,
582
+ UINT32 * Message ,
583
+ UINT32 Length ,
584
+ UINT32 * RecLength ,
585
+ UINT8 HostAddress ,
586
+ UINT8 MEAddress )
587
+ {
588
+ return heci -> SendwACK (Message , Length , RecLength , HostAddress , MEAddress );
589
+ }
590
+
591
+ static EFIAPI EFI_STATUS
592
+ heci2_read_msg (UNUSED_PARAM HECI2_DEVICE HeciDev ,
593
+ UINT32 Blocking ,
594
+ UINT32 * MessageBody ,
595
+ UINT32 * Length )
596
+ {
597
+ return heci -> ReadMsg (Blocking , MessageBody , Length );
598
+ }
599
+
600
+ static EFIAPI EFI_STATUS
601
+ heci2_send_msg (UNUSED_PARAM HECI2_DEVICE HeciDev ,
602
+ UINT32 * Message ,
603
+ UINT32 Length ,
604
+ UINT8 HostAddress ,
605
+ UINT8 MEAddress )
606
+ {
607
+ return heci -> SendMsg (Message , Length , HostAddress , MEAddress );
608
+ }
609
+
610
+ static EFIAPI EFI_STATUS
611
+ heci2_reset_heci (UNUSED_PARAM HECI2_DEVICE HeciDev )
612
+ {
613
+ return heci -> ResetHeci ();
614
+ }
615
+
616
+ static EFIAPI EFI_STATUS
617
+ heci2_init_heci (UNUSED_PARAM HECI2_DEVICE HeciDev )
618
+ {
619
+ return heci -> InitHeci ();
620
+ }
621
+
622
+ static EFIAPI EFI_STATUS
623
+ heci2_me_reset_wait (UNUSED_PARAM HECI2_DEVICE HeciDev ,
624
+ UINT32 Delay )
625
+ {
626
+ return heci -> SeCResetWait (Delay );
627
+ }
628
+
629
+ static EFIAPI EFI_STATUS
630
+ heci2_re_init_heci (UNUSED_PARAM HECI2_DEVICE HeciDev )
631
+ {
632
+ return heci -> ReInitHeci ();
633
+ }
634
+
635
+ static EFIAPI EFI_STATUS
636
+ heci2_get_me_status (UNUSED_PARAM UINT32 * Status )
637
+ {
638
+ return heci -> GetSeCStatus (Status );
639
+ }
640
+
641
+ static EFIAPI EFI_STATUS
642
+ heci2_get_me_mode (UINT32 * Mode )
643
+ {
644
+ return heci -> GetSeCMode (Mode );
645
+ }
577
646
578
647
static EFI_GUID heci_guid = HECI_PROTOCOL_GUID ;
579
648
static EFI_HANDLE handle ;
649
+ static EFI_GUID heci2_guid = EFI_HECI2_PROTOCOL_GUID ;
650
+ static EFI_HANDLE handle2 ;
580
651
581
652
static EFI_STATUS heci_init (EFI_SYSTEM_TABLE * st )
582
653
{
@@ -594,11 +665,37 @@ static EFI_STATUS heci_init(EFI_SYSTEM_TABLE * st)
594
665
.EnableSeCPG = HeciEnableSeCPG ,
595
666
.HeciSubmitCommand = HeciSubmitCommand ,
596
667
};
597
- EFI_HECI_PROTOCOL * heci_drv ;
668
+ static struct EFI_HECI2_PROTOCOL_ heci2_default = {
669
+ .SendwACK = heci2_send_w_ack ,
670
+ .ReadMsg = heci2_read_msg ,
671
+ .SendMsg = heci2_send_msg ,
672
+ .ResetHeci = heci2_reset_heci ,
673
+ .InitHeci = heci2_init_heci ,
674
+ .MeResetWait = heci2_me_reset_wait ,
675
+ .ReInitHeci = heci2_re_init_heci ,
676
+ .GetMeStatus = heci2_get_me_status ,
677
+ .GetMeMode = heci2_get_me_mode
678
+ };
679
+ EFI_STATUS ret ;
680
+ EFI_HECI2_PROTOCOL * heci2_drv ;
681
+
682
+ ret = interface_init (st , & heci_guid , & handle ,
683
+ & heci_default , sizeof (heci_default ),
684
+ (void * * )& heci );
685
+ if (EFI_ERROR (ret )) {
686
+ ewerr ("Failed to register HECI protocol" );
687
+ return ret ;
688
+ }
689
+
690
+ ret = interface_init (st , & heci2_guid , & handle2 ,
691
+ & heci2_default , sizeof (heci2_default ),
692
+ (void * * )& heci2_drv );
693
+ if (EFI_ERROR (ret )) {
694
+ ewerr ("Failed to register HECI2 protocol" );
695
+ interface_free (st , & heci_guid , handle );
696
+ }
598
697
599
- return interface_init (st , & heci_guid , & handle ,
600
- & heci_default , sizeof (heci_default ),
601
- (void * * )& heci_drv );
698
+ return ret ;
602
699
}
603
700
604
701
static EFI_STATUS heci_exit (EFI_SYSTEM_TABLE * st )
0 commit comments