找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10785|回复: 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);8 N( C- g* W. h
  2.   //" x9 T" T  b5 I" }$ _
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    $ X0 W6 u7 _: q8 b
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    8 c  t. z' q2 w! M7 F
  5.   // All other return values for SetJump are undefined.
    - U0 J7 J  C3 j$ k0 ?. \, a1 @/ b; L
  6.   //
    7 U# D( t+ F0 r& U2 W) q
  7.   if (Status == EFI_SUCCESS) {( G! T, p* u3 i* |  z

  8. $ u  ?  `( x- R
  9.     //3 D6 b4 j4 k' ^! o9 @0 @* }$ P+ y, C
  10.     // Call the image's entry point! U  j9 i) r1 C# O; Y! @
  11.     //# l- _4 Y* p/ |7 S6 P
  12.     Image->Started = TRUE;
    3 ]: g2 t5 J' n9 Q
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    . ^. z; @# f! j5 E" N: h. y' W

  14. 3 I) ]2 A9 M! P* V0 h9 P- M: n
  15.     //
    0 n: g  D7 K' s; N7 a* G+ H  Q
  16.     // Add some debug information if the image returned with error. 4 }. T) {8 B% G7 x; Y" g1 R
  17.     // This make the user aware and check if the driver image have already released 0 s; H$ N$ b- z& R" Y# P& i
  18.     // all the resource in this situation.
    . q) M" d. h2 V0 n# `/ E; B8 P
  19.     //
    : g) E, ?+ Z3 k
  20.     DEBUG_CODE (% o0 i' _0 T4 C$ l( f' `+ g
  21.       if (EFI_ERROR (Image->Status)) {: [! |- _' ]$ B
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));" o8 I, h$ Z7 [2 s
  23.       }
    ! `' l1 Y9 b9 n
  24.     )
    : ?2 J0 Z! R$ ^9 o+ u
  25.     ' D8 g( j. B9 J3 V% @
  26.     //0 ?7 n, p/ w; \5 ?5 o
  27.     // If the image returns, exit it through Exit()
    6 `6 p/ H# A2 M, s% D
  28.     //
    : `7 p7 U) `- u: T
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    / P" l) F9 ]' d: y
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
0 Q8 O' f& x# y既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?' @3 y6 e' }9 B2 P. n' }
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.( l6 a4 V$ I/ n* E; x5 }  @- L. x

9 J0 T  ^$ H% Q, q0 {( t$ m0 T我感觉有点多此一举了...不解
发表于 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。3 Z& m: t% Y5 e# y

# |% ?6 n  \4 f/ k) f& _EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出 和 返回一些参数.; a7 }* @5 [% Y6 v% I: s$ _% E
没有用过,暂且记下了.% Y, _0 `$ L1 G. |
% o3 o0 T# r' J$ ]7 o
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-12 08:08 , Processed in 0.059948 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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