找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 9963|回复: 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);
    8 B. V) z  u4 R# N0 v
  2.   //
    8 Q3 g8 H( W6 W+ A, a& z+ {5 T
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed# r9 G3 @0 d& n& p
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump' s2 w# ?/ k- W
  5.   // All other return values for SetJump are undefined.6 o0 k4 b; n- w1 [/ C9 A/ q# h
  6.   //
    6 u! o! w1 g6 o5 S3 I! o+ g0 r
  7.   if (Status == EFI_SUCCESS) {) `8 t) ]: ~, j# z7 ^

  8. 2 t: s6 t  P( B' j* p+ c; F, O( S' f
  9.     //" Z8 o* `- L2 l
  10.     // Call the image's entry point
    # q0 L" V% [5 Z! D% K% ^
  11.     //3 G" i$ f. i0 @/ _* ?
  12.     Image->Started = TRUE;
    ! R1 q* z$ f* K$ U
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);; j. U/ k3 b; x# ?1 f
  14. # L8 A. W# N+ ~1 h
  15.     //# ]4 h2 {! `! z
  16.     // Add some debug information if the image returned with error. / e- l& o% s  o, ^9 o7 \. s
  17.     // This make the user aware and check if the driver image have already released
    9 |( ?. J* j! k4 f) @3 P
  18.     // all the resource in this situation.
    - v2 f* m: }5 e/ W; j/ w0 T4 S+ D; K9 g
  19.     //
      A3 Z6 n+ V* Q7 O% ]
  20.     DEBUG_CODE (3 V7 L% O! A7 v0 ~- t, V) c$ S
  21.       if (EFI_ERROR (Image->Status)) {
    8 _3 y. A& _) A4 o; G$ x+ k
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    . ^* m4 v5 ?- A. q$ X: Q
  23.       }
    ; w# y3 h/ M) A* J4 ^. o+ I3 N$ R! f% V
  24.     )
    - i) g0 U$ |7 w
  25.    
    ; t8 G( ], Y( P+ J% @( ?
  26.     //- M1 b' O( @3 z: \4 m) m4 k1 l
  27.     // If the image returns, exit it through Exit()' s( X5 o# b) B) s( y
  28.     //; C# b' ], u! e, q. x5 f0 l3 s( Y. c
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    * e. B5 f" r1 L8 Q
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态2 q  ^, P0 Q2 J6 Y5 H
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?0 p" ~6 _) \0 o1 e$ L% m; q4 H$ M2 Q
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
# O6 u9 k# E/ d' ^8 a; f' u4 P+ f, A0 K: n8 J
我感觉有点多此一举了...不解
发表于 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。
/ Q( }0 q3 O' i1 x  w0 U, V1 I+ H# [% L" ?( p' L0 `; l
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.8 \; {- a+ |( Y" \  J# }; E
没有用过,暂且记下了.1 P" X5 b6 s8 ^

9 Z. w1 R5 @5 y8 q) t: p3 J非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-17 15:23 , Processed in 0.042285 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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