找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10715|回复: 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);6 g% Z" I0 M1 @! v( g  U* R
  2.   //
    + u# z* C' W  i, h9 l1 S; G
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed% L5 |0 b8 Y& n! y' |$ {
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    # @# A' S2 P) H5 `
  5.   // All other return values for SetJump are undefined.9 c& P: f& Y! V
  6.   //4 h, G/ L9 A/ ]
  7.   if (Status == EFI_SUCCESS) {
    , u6 y0 t$ k/ {( q5 [" q) [" Q1 p
  8. 8 D& `' l0 b+ g: D3 T" v1 R
  9.     //( \/ {& \& F. p7 Z$ h0 o+ H
  10.     // Call the image's entry point
    ' Y# Y! F4 _- c' C; P
  11.     //
    , h% U: g" B" t
  12.     Image->Started = TRUE;
    $ `2 J4 ^. }: r" e( ?. z6 S6 |; i
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    ) \2 U0 h; d7 }, M5 q. v* E$ v: G4 h

  14. " K" {0 x- C: l* P% V
  15.     //
    " o& q4 j5 Q3 f, n! y
  16.     // Add some debug information if the image returned with error.
    0 w. U. S1 A: k4 E' o
  17.     // This make the user aware and check if the driver image have already released 8 m: y* q: Z, ^: s
  18.     // all the resource in this situation. + H: P. K& [% W% ~+ @
  19.     //
    / [1 J, b$ I$ w9 X) s
  20.     DEBUG_CODE (5 H5 l" }4 Q' K) [& x
  21.       if (EFI_ERROR (Image->Status)) {
    - j+ o3 ^+ X, o' K( w) n
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));  [2 p6 Q2 l: `+ W* a
  23.       }
      C$ C5 X3 e7 i
  24.     )
    ) A7 f( q1 o- r2 p% i3 d2 i
  25.     4 n" h9 z% o; e, H) z
  26.     //
    + [1 e& c; ~+ {7 o. r
  27.     // If the image returns, exit it through Exit()& O' o( o5 {% ~/ x8 d8 o
  28.     //) z2 a; E3 Z$ e
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    ' ]! c! L3 ]' R3 g. C1 z
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
' P4 y8 b8 P; L& a% t既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?! H9 D. @: j9 s1 ^+ M- r
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
7 @5 \8 `. O; a8 ^5 d* W! N5 v5 M, M: Q  E" J* o6 I. G
我感觉有点多此一举了...不解
发表于 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。. {8 v3 n: o+ A) h) \2 _

. ^3 H. z( c( G6 _  cEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
8 [4 p- K; x" W$ \6 V没有用过,暂且记下了.: a" \* U% o1 k' r9 m6 ]" a

( l5 I$ k% ~+ s/ T3 C非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-16 07:36 , Processed in 0.042432 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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