找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10373|回复: 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);
    + {) D6 c5 m, e& P2 |/ l+ ^1 |
  2.   //
    # S7 |$ [( `/ \  m, j" [9 }
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    ( p" A- c9 }4 _- e2 q9 {0 i
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump, e( d' s, |  l8 L& a
  5.   // All other return values for SetJump are undefined.- C; c8 ~6 R2 l  W& B9 H
  6.   //
    / W* [; c2 s" p( W3 p4 K# ]
  7.   if (Status == EFI_SUCCESS) {
    , F& h; H# a2 \, k

  8. 0 w; I+ H; e5 A; a. s
  9.     //
    $ Y! \* ~% u" r0 p+ u
  10.     // Call the image's entry point# o2 o+ _  n2 z) \
  11.     //% \4 [3 l2 b0 t% Y( \7 X
  12.     Image->Started = TRUE;
    4 {# Y2 i3 S) g
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);. v; |  n( z+ z2 y/ p& M

  14. 8 R$ i6 N8 M- ~1 K
  15.     //( z) g+ N4 h+ _! C; [
  16.     // Add some debug information if the image returned with error.
    0 \5 C- w7 }2 R" z3 z" k4 f
  17.     // This make the user aware and check if the driver image have already released + K" l3 ^9 s2 T( }! G
  18.     // all the resource in this situation.
    # I. a5 j( K" O% o
  19.     //
    : Q* k/ O" w% J! q
  20.     DEBUG_CODE (
    5 A6 e) R! U$ c) z% A
  21.       if (EFI_ERROR (Image->Status)) {
    ' h% {: c* ^% w) j  i  G
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));; a# Y, x6 ]: z0 q1 b9 S1 l, N
  23.       }
    : z- S$ O' ~! ^! G/ K& I& _
  24.     )
    8 ]0 }3 z5 ?' u. X; q
  25.    
      R7 F  Z' T/ t% z1 f" j* Z$ f
  26.     //; j) I# D2 p" H8 P+ x" w
  27.     // If the image returns, exit it through Exit()
      J5 Y. o- l1 x, v
  28.     //4 N2 j  j7 \3 ~; g! r
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    , i0 _/ a7 b. a1 u3 T, t$ ~) e7 x
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态5 y! J. t! L7 i2 p* \/ b% m
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?- B+ Q' e% [0 M4 A6 h
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
1 Z2 S; Y% N$ I  o& ]& R
% p6 y/ ^( r2 W$ c我感觉有点多此一举了...不解
发表于 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。. ~/ k% l$ c; w4 C
, h: [# P/ F( \1 T- ]7 e
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
6 d( P) p! `/ R; {7 y没有用过,暂且记下了.
8 w7 r) W6 p5 H: V& u. o: y2 H9 Y7 ^6 \
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-18 22:42 , Processed in 0.070780 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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