找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10764|回复: 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);
    + E+ |: q& L  `( z) L
  2.   //1 h/ g$ {0 a. [! M
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    & G' K' U: m( P0 ~
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    ) q3 e9 e( @: k$ o3 @2 s" N8 d
  5.   // All other return values for SetJump are undefined.
    4 a6 g, R/ D: e
  6.   //8 V$ b& D9 H! {: z3 o
  7.   if (Status == EFI_SUCCESS) {; Q1 N& t. }& \& i' e! h
  8. 9 C8 _0 y* T, W- l9 v. L7 z
  9.     //: f2 L8 [+ w4 l+ J5 F! h' j$ R  _
  10.     // Call the image's entry point2 e+ H' P6 ]2 g3 t# o  s2 ?  F" ?3 |2 A
  11.     //0 h- Y9 t, }  b1 R
  12.     Image->Started = TRUE;
    / u; c9 ^2 u6 O! q7 S' n8 O0 g3 u
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    # g$ E6 }+ C5 S  r5 e0 f

  14. & C- P7 }/ m; t5 Z
  15.     //* P7 }8 f- n( s& S& m2 A: o6 ?
  16.     // Add some debug information if the image returned with error. 6 ~6 r! I. G" J
  17.     // This make the user aware and check if the driver image have already released
    + L& w8 U+ Q7 M. [& p" o
  18.     // all the resource in this situation. 3 \. o# C- W* Y% n
  19.     //( {( x% V* ~0 O0 {. ]1 Y: L
  20.     DEBUG_CODE (1 j; S/ p1 I9 {! I% B
  21.       if (EFI_ERROR (Image->Status)) {+ ?1 `: }1 P7 w8 [7 i0 G, h% ?
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));6 W9 G5 h1 [% v! _
  23.       }
    : d6 ~) g2 @, X
  24.     )
    + }( g- _& u( ?/ E0 ?
  25.     3 O5 |0 B- g+ A
  26.     //' B, D- O% o" V7 o6 l6 i
  27.     // If the image returns, exit it through Exit()
    7 |, @8 I% g; j% u! W- h  n
  28.     //
    # E: x: `8 m% q3 _) ?9 N
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    5 `4 h9 T; ^7 V6 w4 x
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
7 g: f# h! o6 h: |9 m- d2 F既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?8 L4 b, q3 i9 q. Y( ?$ C3 ?# N
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.7 C' j- T: a; m! `- ]- v) R
! e* P( m5 |% Y/ k6 l" X% Z
我感觉有点多此一举了...不解
发表于 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。/ B% g: t0 N( X! b( Q+ k1 E. C) W
$ T- g' \* H$ S0 b
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.% @- D# o! ~% I1 N' q2 {
没有用过,暂且记下了.) H  C/ f. I- f7 D4 O

  k) ^5 i& l: M# I. q! o/ J- }& h非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-4 18:57 , Processed in 0.052908 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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