找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10668|回复: 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);
    + D$ c; _) W! q. Y: Q
  2.   //
    & W0 d' ]: s. m9 H1 U* S! a
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    : [7 m- z2 ]$ J5 E: q+ E& o
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    8 a8 P) D% }2 ~/ c9 G
  5.   // All other return values for SetJump are undefined.: }' G4 x& q- S5 N! r
  6.   //- i$ ^& T. T0 a
  7.   if (Status == EFI_SUCCESS) {
    0 o" W' o" r; F! x& |1 T: `

  8. ! J3 l8 |9 L* I8 l5 z, o! w
  9.     //+ a$ N& s& E' H, m: G$ i! C
  10.     // Call the image's entry point
    $ P0 H4 d8 l! G  j7 k, S
  11.     //
    . j* V4 a7 o' V
  12.     Image->Started = TRUE;
    / q7 o. B: w: Z* o# n  G- d
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);( J6 n% r/ |) a! D# [3 B. Y7 r  G& e
  14. " b# ?* {9 v: Y$ C* S' W
  15.     //
    : l+ \0 q0 Q/ @3 [# c% T% W
  16.     // Add some debug information if the image returned with error. " }4 Z; q) }! |& F$ `
  17.     // This make the user aware and check if the driver image have already released
    " z* F) q7 R2 Q" d4 c
  18.     // all the resource in this situation. ) }& T7 t- f7 r% F
  19.     //2 S6 w$ i2 y& l, N. G
  20.     DEBUG_CODE (
    * Z# @% \6 Z4 r" r8 ]
  21.       if (EFI_ERROR (Image->Status)) {
    8 s; x- k& z9 b* l" T2 D- p* {
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    , q. U& C% C  Q% O( D
  23.       }
    # p# G  p4 }' D2 N
  24.     )
    * A# H: y/ X0 O9 N
  25.     ( W: }. H* n0 }& z& g
  26.     //
    3 o. @. j  {' Z, c
  27.     // If the image returns, exit it through Exit()
    1 O1 a5 j  j5 F5 B( S" Q  ^
  28.     //& v) @( h( Z; Y: {; U# z) Y/ E
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);' ^7 ?+ i+ N6 J" _
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
: a( C/ Q- d1 E; s既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
4 y; c  S8 [) n/ x  y& h而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
; L3 X, S  F' K+ J3 `9 M2 q* W
6 J' d7 }! n3 U) I9 B" g+ S我感觉有点多此一举了...不解
发表于 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。
+ I0 O+ ?! N( U! o
* b4 T4 x7 f! LEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.* a) [2 ?; o5 D$ Z8 H$ G7 E% k
没有用过,暂且记下了.
- U. E9 i- d+ U1 h1 ]6 {/ q) V; k9 M' A5 z0 p0 r: H$ j
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-20 03:49 , Processed in 0.039246 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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