找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 9741|回复: 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);
    5 x4 I3 E2 a" D# E+ N
  2.   //$ v/ N, \4 ^, C3 r
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed2 ~- n# i) i" Z0 d, z
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    ) `4 G# ^8 G& [$ v1 q
  5.   // All other return values for SetJump are undefined.
    / q2 d/ Q( L. F6 f  V- R$ E
  6.   //
    0 \9 T' x& a" Y4 ]6 u4 G
  7.   if (Status == EFI_SUCCESS) {
    " j+ T- b& w& f# C* U- I6 v
  8. 6 D0 V8 @) Y8 j! L
  9.     //" C( s5 \  J  C
  10.     // Call the image's entry point
    . P3 ?) b# W" h
  11.     //
    7 g% T: @$ H9 O" M
  12.     Image->Started = TRUE;
    7 {$ Z; y" Z6 \8 ^- j
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);3 c( Y/ k+ A. u
  14. " o" o+ c% E1 L- @
  15.     //" `& O! P+ R- `/ Z$ V3 c4 F+ p
  16.     // Add some debug information if the image returned with error.
    + {) M' _$ _! ]  x6 H" u$ V) D
  17.     // This make the user aware and check if the driver image have already released $ d# B) X3 l3 A8 \; H8 ~
  18.     // all the resource in this situation. - U$ ^+ H: c$ M( s! a6 W
  19.     //
    & G8 ?/ }+ v1 ^, ^" a" X
  20.     DEBUG_CODE (
    ! O' t6 K/ c- ]! Q; _
  21.       if (EFI_ERROR (Image->Status)) {8 Q8 }$ [: U0 D8 H0 v4 Z
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));  }  x# X% w: D% _: Z, Q$ P
  23.       }) I' b% D$ K5 G+ z6 @
  24.     ): |! I' A1 e% A! x4 T9 D1 p
  25.     , c; T  M( j/ @
  26.     //) X: V7 ~" ]3 ~! A2 b' `. m
  27.     // If the image returns, exit it through Exit()
    : q4 v$ h7 y2 k! x
  28.     //
    7 S# H. r  T4 y! p
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);  `  a' C; I5 g2 M. l
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
8 ]4 O: h6 W, V既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?: u2 I% c& J7 l6 i
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
! d7 S$ U4 E6 [! z" m! ~! f, @, g2 ]" e0 x) ?5 n* u3 N
我感觉有点多此一举了...不解
发表于 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。
, V/ D; X) J1 e( Q6 \8 o. J* f' `% L0 G
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
1 K2 a' W8 A2 N4 T9 q没有用过,暂且记下了.; a" G, D. ?$ t/ p

6 ^* o  D) F4 L) `/ C" P+ g' ~3 c6 J非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-3-5 00:29 , Processed in 0.026819 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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