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,12 +577,82 @@ 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
{
654
+ EFI_STATUS ret ;
655
+
583
656
static EFI_HECI_PROTOCOL heci_default = {
584
657
.SendwACK = HeciSendwACK ,
585
658
.ReadMsg = HeciReadMsg ,
@@ -594,11 +667,37 @@ static EFI_STATUS heci_init(EFI_SYSTEM_TABLE * st)
594
667
.EnableSeCPG = HeciEnableSeCPG ,
595
668
.HeciSubmitCommand = HeciSubmitCommand ,
596
669
};
597
- EFI_HECI_PROTOCOL * heci_drv ;
670
+ static struct EFI_HECI2_PROTOCOL_ heci2_default = {
671
+ .SendwACK = heci2_send_w_ack ,
672
+ .ReadMsg = heci2_read_msg ,
673
+ .SendMsg = heci2_send_msg ,
674
+ .ResetHeci = heci2_reset_heci ,
675
+ .InitHeci = heci2_init_heci ,
676
+ .MeResetWait = heci2_me_reset_wait ,
677
+ .ReInitHeci = heci2_re_init_heci ,
678
+ .GetMeStatus = heci2_get_me_status ,
679
+ .GetMeMode = heci2_get_me_mode
680
+ };
681
+
682
+ EFI_HECI2_PROTOCOL * heci2_drv ;
683
+
684
+ ret = interface_init (st , & heci_guid , & handle ,
685
+ & heci_default , sizeof (heci_default ),
686
+ (void * * )& heci );
687
+ if (EFI_ERROR (ret )) {
688
+ ewerr ("Failed to register HECI protocol" );
689
+ return ret ;
690
+ }
691
+
692
+ ret = interface_init (st , & heci2_guid , & handle2 ,
693
+ & heci2_default , sizeof (heci2_default ),
694
+ (void * * )& heci2_drv );
695
+ if (EFI_ERROR (ret )) {
696
+ ewerr ("Failed to register HECI2 protocol" );
697
+ interface_free (st , & heci_guid , handle );
698
+ }
598
699
599
- return interface_init (st , & heci_guid , & handle ,
600
- & heci_default , sizeof (heci_default ),
601
- (void * * )& heci_drv );
700
+ return ret ;
602
701
}
603
702
604
703
static EFI_STATUS heci_exit (EFI_SYSTEM_TABLE * st )
0 commit comments