今天又回头看了UEFI中关于Event的部分代码,每次都是看了忘,忘了看,所以决定写下来,虽然简单,但是也需要一遍遍的加深记忆。。。
gEventQueue
[Index] TPL分4个等级:Application=4 callback=8 Notify=16 High_level=31
Index为0~31
每个Entry为Event->NotifyLink
gEventSignalQueue
:每个Entry为 IEvent->SignalLink
mEventTable
:由Event type构成的数组
gEventQueueLock
(TPL_HIGH_LEVEL)
gEventPending
1.
CoreCreateEvent
、
CoreCreateEventEx
、
CoreCreateEventInternal
2.
CoreSignalEvent
:根据Event的TPL将其insert到
gEventQueue
[TPL]列表中,通过Event->NotifyLink链接起来,设置
gEventPending
对应的bit
3.
CoreDispatchEventNotifies
:根据参数TPL,remove
gEventQueue
[TPL]链表的entry,执行Event->NotifyFunction,清
gEventPending
对应bit
CoreRestoreTpl
会执行
CoreDispatchEventNotifies
4. timer event
4.1常用数据结构
mEfiTimerLock
(TPL_HIGH_LEVEL - 1)
、
mEfiSystemTimeLock
(TPL_HIGH_LEVEL)
mEfiTimerList
:其entry为Event->Timer.Link
4.2 func()
- 初始化的时候创建名为mEfiCheckTimerEvent的event,其type=signal,NotifyFunction=CoreCheckTimers,TPL=TPL_HIGH_LEVEL - 1
- CoreCheckTimers\CoreTimerTick\CoreSetTimer中当triggertime到达的话会调用CoreSignalEvent (mEfiCheckTimerEvent)
- CoreCheckTimers:查看mEfiTimerList中的每个Entry,若Event的TriggerTime到了则调用CoreSignalEvent;周期性的event则重新insert到mEfiTimerList中
- CoreSetTimer:通过调用CoreInsertEventTimer将event加入到mEfiTimerList中
- CoreTimerTick:遍历mEfiTimerList中的每个Entry,若Event的TriggerTime到了则调用CoreSignalEvent
- TimerInterruptHandler 为8254Time的中断处理函数,当Timer中断发生时,TPL会升级为TPL_HIGH_LEVEL,此时会禁止硬件中断,进而调用mTimerNotifyFunction;而mTimerNotifyFunction正是CoreTimerTick
看了@
Pedroa 的这篇博文
https://pedroa.blog.csdn.net/article/details/82258598,对于event的理解更为深刻,谢谢大神~

本文深入探讨了EFI Event的相关概念,包括Event Queue、TPL等级、Event的创建与信号处理。核心函数CoreCreateEvent、CoreSignalEvent和CoreDispatchEventNotifies的工作流程被详细解析。此外,还介绍了Timer事件的处理,如CoreCheckTimers、CoreTimerTick以及如何响应硬件中断。通过实例分析,加深了对EFI Event机制的理解。
2239

被折叠的 条评论
为什么被折叠?



