找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10677|回复: 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);
    9 @0 z/ f+ s/ u, t
  2.   //
    1 }+ _; F; u/ d- X
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed. R, i" \% j. [* B2 i  K- \
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump( p% N. ~2 p4 t4 J& g
  5.   // All other return values for SetJump are undefined.4 M: V" p) `% A/ w4 M8 S
  6.   //
    ) P$ Z0 o1 H& [' J* R
  7.   if (Status == EFI_SUCCESS) {, P# @6 n+ t) R* U5 u
  8.   D. |9 q4 U& ~- v
  9.     //; ?) Z# u. Y5 g% o( A
  10.     // Call the image's entry point
    & _" G. [# s: g, P6 X% Q+ d* W
  11.     //
    # y( c3 Q& ^) O  n
  12.     Image->Started = TRUE;: v1 G9 Y" k7 d+ M/ \2 w
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);# P- N' Y$ Z$ l# j
  14. 5 d  u. q( E6 V
  15.     //6 L  E5 V  _2 I6 Z) y5 |
  16.     // Add some debug information if the image returned with error. 7 ?5 D& b* n/ A3 g1 Y. r" }5 q4 x
  17.     // This make the user aware and check if the driver image have already released
    1 ^! r( [1 |7 j
  18.     // all the resource in this situation. . H+ u/ Z8 Y( d, K8 v# |
  19.     //* a4 o: [0 g3 g$ `3 l- g* L
  20.     DEBUG_CODE (
    , L+ b1 R5 H) @1 c0 }
  21.       if (EFI_ERROR (Image->Status)) {
    1 m5 M( F/ v: i: A
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));) a8 R: h3 H- _4 ?& ^  q
  23.       }
    : T- z: {4 N# M! {) L' M
  24.     )+ e% ^5 e# Q# O! X3 n/ f
  25.    
    ! B: ], R1 E5 k* `6 X( {2 ^( _; _, t
  26.     //
    ( @2 W5 ^- z, j$ G4 E! }6 ^
  27.     // If the image returns, exit it through Exit(), p6 p# @) M& y/ a0 e
  28.     //
    2 a8 @6 ~3 T+ u5 T, [/ a; u5 h
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);- A8 h1 ]$ s9 A9 X. F
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
0 M9 s/ C- x3 ~7 `! M既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
" m, c5 [7 C6 s. _8 j, x而且目前来看driver只会返回Status而已,根据这个就可以做处理了.2 d3 V. [0 O2 B- a" A3 P/ F; ?

7 L9 O9 N- S" _/ j我感觉有点多此一举了...不解
发表于 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。
. G. u9 X/ _+ E/ ]/ N$ D" Q' z- S
0 Y* l- \  \  m7 |5 @EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.8 c, V6 o1 C" e. g0 z, G
没有用过,暂且记下了.7 P. v! n$ N) c2 a9 i" A

$ ?) s$ Q$ K* t$ m非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-25 03:41 , Processed in 0.039222 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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