找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 9874|回复: 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);) K. O# V3 h8 m# ]1 {
  2.   //3 B; j4 v. _* p4 R) q, T2 u4 l5 d* h
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed+ H  t2 F4 v- e) S" J: f
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump) |! N! H+ L1 |( s: ~
  5.   // All other return values for SetJump are undefined.' ]# b! \  K# \4 @8 z+ f  C; v
  6.   //. R2 ]9 C+ S& l+ s8 i* K# N/ k( o
  7.   if (Status == EFI_SUCCESS) {6 {9 p( y" g5 C* [0 j" w
  8. 2 n3 c8 d" D7 l3 k% m
  9.     //0 e% E& g: G( ~1 ]. Z( L
  10.     // Call the image's entry point7 u0 V  \7 }. V
  11.     //6 @; |+ k" v; s- k  X6 }
  12.     Image->Started = TRUE;
    8 Y/ m! X* ]: N; |, ?) o
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    5 l' Z+ k. J& X* K4 f4 B

  14. 3 k) F5 j* X3 Z4 t# [" J
  15.     //2 A- A# N* g4 z8 H
  16.     // Add some debug information if the image returned with error. & ]) A- c$ m. U' T* K/ k2 Y
  17.     // This make the user aware and check if the driver image have already released
    # F- w. q- h3 [' ^4 ^
  18.     // all the resource in this situation. 2 |% t+ U# F# x! h5 g
  19.     //, z/ |0 g6 C+ p$ X# ~9 S
  20.     DEBUG_CODE (1 S; s+ M7 D# U( t# @% B4 o" D
  21.       if (EFI_ERROR (Image->Status)) {3 z$ t& }$ s8 \' D0 h' F& \
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));/ {2 P1 @6 O) P" S2 j2 c+ b0 ^" Z
  23.       }; _' d$ |$ s; r! p  |
  24.     )! C2 y2 S+ g) g" R1 k- m0 C' q+ P
  25.    
    ; @- G+ n6 e. }3 P% j& t
  26.     //
      v( T8 C- o3 X
  27.     // If the image returns, exit it through Exit()" ~* Q, X& k+ R: `2 n& O
  28.     //
    - X- f  Z: S/ \9 D. M, n+ A  _
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    / N) ^) e- M2 [& O& @" Y; {9 b+ ~) t2 D
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
2 S2 g- m$ c/ G6 u1 \* D既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?* b1 I/ s3 h+ s! g4 x+ _7 J
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
) s) \0 Q9 E2 F0 K  I; j7 i' a! ^' J( Y0 N& X" A. |7 a. r$ _" D
我感觉有点多此一举了...不解
发表于 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。; H4 Q2 A) i/ e6 }6 E6 V
# ^8 W$ O3 A$ d8 F  s8 U0 E
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.6 l( O/ H7 j# ?/ ]! `
没有用过,暂且记下了.7 j" ^& G, F( R6 w" Y# E
$ f& t7 N3 j2 P2 @+ l) I. D9 m
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-29 05:04 , Processed in 0.056223 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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