找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10626|回复: 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);: }1 ]) T( S; Y; Q7 S- g' ?. k* j
  2.   //% K  q: T* E: E1 M7 A0 @' f* V. l
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed# I8 y: y4 ]: C
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump: w- H- U7 ?7 ^9 j( O0 Z
  5.   // All other return values for SetJump are undefined.
    - l9 b! u: c) J$ k9 j( V
  6.   //
    / y. |* F2 q3 T# p; G) l  W& b+ u
  7.   if (Status == EFI_SUCCESS) {
    * m! ]% o. {1 _' V9 G
  8. ' L! o4 Y& T/ {  W+ c! c
  9.     //9 l& G5 X! N, ~( `/ Z9 o! x& H
  10.     // Call the image's entry point
    : j- }, I3 p: u) s0 V& k" j3 m
  11.     //! n, P7 D$ S( A* _+ P6 o- V; g
  12.     Image->Started = TRUE;
    ) T' |- g# i) c- v* u' b5 r7 X
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);4 k  U2 L2 U: Z1 L$ e. t; L! ~

  14. & L' O/ l2 o1 }4 n
  15.     //
    6 Q/ a7 G: D! U. S4 d
  16.     // Add some debug information if the image returned with error.
    2 I! U9 ~% v3 f& |
  17.     // This make the user aware and check if the driver image have already released
    , z8 Y' j6 l. S  G
  18.     // all the resource in this situation.
    & c  ~; z4 k; e, v# m4 B0 @
  19.     //
    & ^4 q) F$ `# G* d0 X# L" W' v+ Z
  20.     DEBUG_CODE (" y' m% F# c6 B# w+ x( a
  21.       if (EFI_ERROR (Image->Status)) {
    ( F" i2 R8 l% \3 H! l+ ~9 Y0 @; R) }# c
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));6 \3 ~# i! K; s( i8 d3 Q. y& U+ f
  23.       }) s" G1 T9 q) {# k) R
  24.     )
    2 H+ M: c" E8 {
  25.     8 c9 Y, y0 e2 Q, W
  26.     //5 @7 n) T9 X# |4 r9 }
  27.     // If the image returns, exit it through Exit()
    ) O  Z) `6 X1 q, m- z: X' G
  28.     //7 e7 s( R2 L( i' o! a
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);9 N6 m: c, H' Q3 v! L
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
; T7 D8 B% M; l# H  \& f- G既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
1 H3 _) X) E8 q( _, E! A, [  h而且目前来看driver只会返回Status而已,根据这个就可以做处理了./ E4 g# T) k- Z4 N- H. c$ C$ j

4 K  Z. d6 }( \5 V3 o; T; _6 m我感觉有点多此一举了...不解
发表于 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% k! N+ P$ {9 b( M# g
8 Z, s( q9 Z3 w9 R7 P
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
( A( P; o+ e. Y/ }2 L没有用过,暂且记下了.
) x2 S8 B: i( K( U7 B! @: V  G+ n" l+ I% M
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-11 17:53 , Processed in 0.107402 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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