找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10192|回复: 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);! S4 Q7 d0 `" `# t- U2 }, B
  2.   //
    ) G6 [9 V4 o7 N# c3 T. |
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
      K4 L8 L) d5 D2 j( l
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    4 L4 j) D  S9 a/ o* Y- x$ e
  5.   // All other return values for SetJump are undefined.; ^. X9 t) ?% e7 o! t: C
  6.   //
    8 y# ]; s; N5 b5 v( v$ D+ E
  7.   if (Status == EFI_SUCCESS) {! g. m2 U8 h# x5 q$ e: d4 f* [

  8. + s  `( d" w$ G: t, t7 I' O0 s
  9.     //* f, t* z! T, L) l- u- V! T
  10.     // Call the image's entry point
    0 Z7 |* [% F) V% w
  11.     //: E4 ^! P8 i, x$ y& N# o. e
  12.     Image->Started = TRUE;/ ?: a7 p6 L& |8 f$ k* Q8 P
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
      h% @: K" d/ `5 q7 P4 d# h' ^; [! Y7 i

  14. . [" Q6 @3 @7 _$ b8 e
  15.     //
    0 l4 g, r9 g- A' m& W5 I- ?2 V* J
  16.     // Add some debug information if the image returned with error.
    . w2 A8 F4 X- }% _! q+ Q) ^3 l
  17.     // This make the user aware and check if the driver image have already released ( c& b& _* m- B, p
  18.     // all the resource in this situation. , \1 C1 u- W5 a# h, h, C
  19.     //4 E6 D* t5 l1 J9 Y" c+ @  D
  20.     DEBUG_CODE (
    % J# C% H  z) p3 g# H, C
  21.       if (EFI_ERROR (Image->Status)) {
    3 S3 E5 v# |  P, k1 O( I) Z  s6 B+ h; l
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
      l2 _/ \2 N2 o5 J5 e# u, h
  23.       }
    + Q. X3 {2 ]4 o- x) v( k/ z2 F; j
  24.     )8 {" E/ [# X; @+ C- G
  25.    
    ! G8 _% O; Z. y2 Z1 U' M
  26.     //
    % }: v$ R  i' E  x6 h" y
  27.     // If the image returns, exit it through Exit()
    5 l4 \/ e; d9 y0 W0 G/ s0 Z5 T
  28.     //
      G; y/ H" T. t$ V6 ^9 g  D" [
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);% x" G) m" D6 R) z
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
2 c( p" V; X/ a; F/ R" c6 J既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
2 U, i- s3 Y8 R0 x1 g/ S* v9 c而且目前来看driver只会返回Status而已,根据这个就可以做处理了.7 N* w# s! l* l% g5 I9 x+ \
9 V9 G; ]5 y2 d
我感觉有点多此一举了...不解
发表于 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。
: W' p7 I4 x9 N" O& [3 I$ y* T9 s
5 _: r" Q: w: ^: x' c7 D' o* xEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.; h1 @0 P9 N. r$ G% N: v2 O
没有用过,暂且记下了.! \0 d; t3 L: J2 ~9 Z
8 W. f+ q' P- P2 i
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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