UEFI规范驱动模型(一):驱动模型包含的要素

来源:互联网 发布:淘宝今日分享任务在哪 编辑:程序博客网 时间:2024/06/06 12:46

       UEFI规范中对UEFI Driver的介绍有两章分别是第2章overview(2.5节Uefi Driver Model)和第10章Uefi Driver Model详细介绍,对UEFI类型的驱动即UEFI Driver的实现方式进行了规定,下面结合代码以PS2键盘驱动的实现为例,对UEFI Driver 的实现方式进行介绍,详细如下:

1、PS2键盘驱动的组成:

    1)PS2键盘驱动函数实现在Ps2Keyboard.c里面,Ps2Keyboard.c包含在Ps2KeyboardDxe.inf模块里,如图1所示;

    2)打开Ps2KeyboardDxe.inf文件,可知该“模块”的入口点为InitializePs2Keyboard();函数,如图2所示,该函数的具体实现即图1中InitializePs2Keyboard();函数;

    3)InitializePs2Keyboard();函数中通过EfiLibInstallDriverBindingComponentName2();函数将  gKeyboardControllerDriver()函数注册到Iange Handle上(驱动程序通过LoadImage()protocol加载到内存后,会为其创建一个image handle),gKeyboardControllerDriver()是一个EFI_DRIVER_BINDING_PROTOCOL类型的函数,具体实现见图3;

    4)EFI_DRIVER_BINDING_PROTOCOL类型的函数gKeyboardControllerDriver();包括:

     EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver = {
                  KbdControllerDriverSupported,
                  KbdControllerDriverStart,
                  KbdControllerDriverStop,
                  0xa,
                  NULL,
                  NULL
                                                                };

      其中:

    • KbdControllerDriverSupported()函数作用是:“Tests to see if this driver supports a given controller.
    • KbdControllerDriverStar()函数作用是:“ If a driver’s Device Handle Supported() function passes, then the driver can be  connected to the controller by calling the driver’s Start() function.”
    • KbdControllerDriverStop()函数作用是:“ Stop() function that forces the driver to stop managing a device handle.”
      综上所述,一个UEFI Driver modle包括Support、Start、Stop三个函数,三个函数通过EFI_DRIVER_BINDING_PROTOCOL类型的实例加载,整个驱动的入口函数由驱动模块xx.inf文件中EntryPoint指定。



                                              图1 PS2键盘驱动组成 



图2 PS2键盘驱动入口函数



图3 gKeyboardControllerDriver()函数的具体实现


原创粉丝点击