找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10625|回复: 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);
    2 s# m; P0 k+ z  E
  2.   //
    , P8 R' k! d/ R4 S1 Y
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    8 P. G5 p; e! q% H' g
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    ' n9 L* B# e, Y. E
  5.   // All other return values for SetJump are undefined.% ]4 p% E" R$ o
  6.   //
    6 u! _9 z  p1 w  G- j
  7.   if (Status == EFI_SUCCESS) {
    ' {" ?( g1 U! p) I
  8. . C# r$ C5 A" y: M( a2 a
  9.     //( G# a! P, c/ Z3 j% d
  10.     // Call the image's entry point
    % O- E/ Y5 i* y! p, P4 Q# E
  11.     //5 l. O0 d9 [' \' `* N
  12.     Image->Started = TRUE;: }! B, ]3 `& }6 p( T3 w8 ]
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);8 s% Z' x% N' t& U) y

  14. 7 M7 s) J( n. z  I0 @  v/ k$ Q: H
  15.     //  G7 P# I. O; Q9 q1 x4 O
  16.     // Add some debug information if the image returned with error.
    ' h: N2 ^  j9 Q" _
  17.     // This make the user aware and check if the driver image have already released
    8 _  [- j/ i- T' ?
  18.     // all the resource in this situation. 9 r$ d" k1 E3 Z  K3 ?+ n  z
  19.     //7 o, N* {) _0 ?( G" V( O
  20.     DEBUG_CODE (( L+ }, g/ W; ?# p# q
  21.       if (EFI_ERROR (Image->Status)) {
    3 J1 D& P  [& Z
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    7 J/ |+ R: u! j5 r/ F4 [  F
  23.       }
    ! v; c3 c& s" T8 q3 o5 ^7 v1 f
  24.     )& j* `' P2 X- V8 u9 O. h$ G
  25.    
    8 B. t+ w$ Y: W0 s7 R
  26.     //# V( t/ L4 x, i" ^' o- h) l
  27.     // If the image returns, exit it through Exit()
    " h  I0 N6 i+ Z# S5 [  j
  28.     //
    ! V! o/ L( z% z) [: f
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    3 s6 v" O/ g. D% S- T) A
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态8 B  E( d. S. j2 O# n
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
  `& h9 J2 J0 t2 x% X  D# `而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
6 d& ~' F( b0 ]  o% W8 B# {' M7 g0 Y  o- P+ O3 r9 l
我感觉有点多此一举了...不解
发表于 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。
' K" e" ~8 c- K: [
$ E% T* ~. k+ h* {& M% P4 A( yEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
( ?/ m, u" s$ k* r没有用过,暂且记下了.
. S+ O; S7 }7 _) a" N4 R' j$ Q- B
$ A* g+ T+ i- g' G; g: c# n非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-11 16:58 , Processed in 0.049038 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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