找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10980|回复: 3

请教: UEFI CoreStartImage中为什么用EFI_PEI_TRANSFER_CONTROL_PROTOCOL?

[复制链接]
发表于 2008-10-28 10:50:31 | 显示全部楼层 |阅读模式
EDK_20080905(各家IBV的应该类似),文件Image.c,在CoreStartImage(),如下一段中:
  1.   Status = gEfiPeiTransferControl->SetJump (gEfiPeiTransferControl, Image->JumpContext);
    6 u* \3 y& z9 j" }. V
  2.   //
      V1 E+ N3 y7 i% P. E* o
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed; k% [& W4 P" ?6 ?( b: A
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    ! L% n. y, }  I9 ~  k
  5.   // All other return values for SetJump are undefined.
    , _: J) Y  ?  `9 a
  6.   //$ y7 C7 s+ \) l6 E0 H' [3 s
  7.   if (Status == EFI_SUCCESS) {+ I9 }& s4 T; x2 [2 n! q
  8. . l0 i- W/ ?5 z5 b# g4 w" |
  9.     //
    8 _" E: T- F" Z' O# Z
  10.     // Call the image's entry point$ D) q+ u, k, M% c9 ?  l6 n) s( o
  11.     //: b+ K  |0 H  L2 c; E$ v
  12.     Image->Started = TRUE;
    + Y5 q$ |- I( o" E/ ?( m  ^- X: |
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    8 M5 G; k5 b+ z! W& E
  14. 8 {5 u& H6 ^' ~6 q
  15.     //8 U* z" T" ^& Q
  16.     // Add some debug information if the image returned with error.
    * B! F7 Q& B3 y( H
  17.     // This make the user aware and check if the driver image have already released
    0 S, V' n1 J' H
  18.     // all the resource in this situation.
    0 E" L# D5 C, M; z5 y
  19.     //* n6 ]" P- n, Q- u; I% H* M
  20.     DEBUG_CODE (: i( `" r* w- l5 s$ {3 P
  21.       if (EFI_ERROR (Image->Status)) {$ t4 _& T0 G0 |2 E& ?
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    + e6 W! d6 V& Y; c4 I
  23.       }
    2 L/ H6 o7 \4 o# x+ {# A
  24.     )6 ~3 l# p7 a6 V! c: t5 F
  25.     3 ^& r# L' e6 D3 ?  L/ |% n
  26.     //
    ; \# G, P  @" ~# s% m" \, j) I
  27.     // If the image returns, exit it through Exit()
    2 a: A9 J! [8 x# i# z$ a
  28.     //+ Q% Q/ U* o6 q! ]& t
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);& Q* C: u! o4 Z; W( J1 |+ {
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
, ~2 o% o* ]# I6 L: @5 [' t  s0 E既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
9 W0 w" e  G2 N- ^" b3 P; B4 i而且目前来看driver只会返回Status而已,根据这个就可以做处理了.5 U9 W3 J' L* Q
7 `7 J( }2 S+ e) N- f/ L% _
我感觉有点多此一举了...不解
发表于 2008-10-28 22:29:18 | 显示全部楼层
我觉得可能是要保证DXE driver之间的独立性吧。
回复

使用道具 举报

发表于 2008-10-29 13:42:13 | 显示全部楼层
C程序可以用return语句在main()里退出,也可以用exit()函数在程序里任何合适的地方退出。UEFI也提供了类似的机制,即Exit boot service。与从UEFI driver的入口函数中用return退出相比,用Exit()除了可以在其它的函数中直接退出,而不用先返回到入口函数再退出之外,还可以返回额外的Exit data。8 s- j8 z+ H2 y4 }9 L+ V' q0 V
! y; e1 [$ R8 q
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出 和 返回一些参数.) @" S3 A3 T$ |/ \9 k
没有用过,暂且记下了.
: b+ \) F2 g  S0 F; U) C; J
& b4 a6 @! \' [  Y/ [4 C非常感谢!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入计匠网

本版积分规则

Archiver|手机版|小黑屋|计匠网

GMT+8, 2026-11-22 05:16 , Processed in 0.699170 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表