找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10193|回复: 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);- {, W0 l5 G. g8 F' f4 k
  2.   //! J' ]7 k0 [: y4 N3 ~; j
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed) q# T3 o! d" w! m+ U
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    8 h% s, l: K2 y% \$ G4 F. f1 B5 A6 G
  5.   // All other return values for SetJump are undefined.% z. B3 M% L" T' G6 p
  6.   //
    ( w9 i. M# ~5 M1 j1 F3 w
  7.   if (Status == EFI_SUCCESS) {
    * b7 k0 B+ S* w+ y/ V

  8. ; J* `2 `: D8 e1 g. p& L
  9.     //9 \1 g: r+ p! J6 e& |1 |
  10.     // Call the image's entry point  L4 i, W# z; M( s
  11.     //
    / b/ m% w2 H& O( V* [
  12.     Image->Started = TRUE;
    5 n: d3 x( t6 J9 Y5 {2 a6 Q7 |4 l
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    " x" j/ {$ Z, [$ l+ d2 ~% x
  14. + Q) E0 C' @% J3 ~! ?
  15.     //1 [; R+ D5 P9 D
  16.     // Add some debug information if the image returned with error. 3 z. N: i+ V  z- ?
  17.     // This make the user aware and check if the driver image have already released
    / x! Q% ~( p1 P' m  j
  18.     // all the resource in this situation. : D. A6 ]3 X# G) @
  19.     //
    + I  l% w. p2 F# b1 [3 v
  20.     DEBUG_CODE (
    ; R; t- [7 K) `  C
  21.       if (EFI_ERROR (Image->Status)) {( Q6 M& i; D( u4 K0 G
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));5 Q" W* j4 W( i1 ?& s/ P0 x9 h" D
  23.       }2 C# v9 t3 S. d$ y7 b0 [  {
  24.     )8 @- U3 K. S7 e' C! Y
  25.    
    * h4 V" {/ }& Q
  26.     //
    & C& f4 T9 i( R5 \
  27.     // If the image returns, exit it through Exit()
    / z- {" n" f; i( R3 V; [4 p* I5 L
  28.     //) S& e9 m. g* I0 N8 s, d/ V0 G' L
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    , ]8 o! o8 J  x' Z/ ~
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
' d/ N( N; V) o1 X# D- W$ K既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?- I7 Q5 W2 y8 Q2 h0 i* o% I
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
3 y3 l8 m0 L! W6 h0 M/ i
1 ]1 O! `# S5 [9 V我感觉有点多此一举了...不解
发表于 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。
" v8 \# u4 o7 {2 g, n0 P9 i" A/ n' s( G' ]$ d
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
: W3 }8 P! L4 l2 l没有用过,暂且记下了.
3 B( w, g8 q- Y9 q2 c1 \/ C7 X3 Z; m" z4 ^3 s; Z* R; @
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-1 08:36 , Processed in 0.081294 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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