找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10522|回复: 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);/ T0 U2 [1 M" x( Q4 h  A
  2.   //
    : g2 O# i0 P: _
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed4 ^2 Y: |* `- j% E: B
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    . A3 ?0 e: w- C
  5.   // All other return values for SetJump are undefined.1 y/ X! \% v/ p
  6.   //* I/ ]7 @( ?. `1 ~* @& G
  7.   if (Status == EFI_SUCCESS) {( [( N' ^. x- W9 g  L, c3 }$ I. _

  8. 2 @9 |% x+ s1 S
  9.     //8 a& m5 K/ m' e
  10.     // Call the image's entry point% T- W& X8 G: M) j2 A1 F
  11.     //
    & o0 |; R. u# \& V' m' k/ t" ?
  12.     Image->Started = TRUE;! j" M* N$ B0 s7 l' H3 Z
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);) l+ V2 ]& w* C! W7 X) r6 C6 F
  14. ' ~6 \0 n1 N- E8 K) I5 y) y0 ~
  15.     //, q8 c+ h4 {9 c+ T- g0 V
  16.     // Add some debug information if the image returned with error.
    ' I4 S7 ?: U( g/ J" R; i
  17.     // This make the user aware and check if the driver image have already released
    : C) w: I5 Q! o
  18.     // all the resource in this situation. : m# D5 ?0 b1 ~; U/ F( V
  19.     //
    2 ]# [: r+ _1 k
  20.     DEBUG_CODE (" c/ L8 l. i) v# G, O! W
  21.       if (EFI_ERROR (Image->Status)) {2 D5 [+ O7 }# c0 v! I% n
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    6 S" z' t7 p! }3 ]% _4 W! J1 ?
  23.       }6 B3 L1 j. h" e9 S! K
  24.     )
    % p5 _3 j! w6 M$ a: P( m
  25.     : o9 M- v  b# F
  26.     //
    0 ^2 q% `! O( I' h# C" Z# {8 @1 U
  27.     // If the image returns, exit it through Exit()
    + @5 V  U- ]' a, \! r
  28.     //, e% b/ v* B7 Z% p
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    2 X+ o7 o5 ^) K3 T
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
' f: g) K6 b* N8 a* \既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?; I) i" a3 _, Y
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
; F. s) b% L6 T
2 n1 W4 `& f3 `8 x9 H我感觉有点多此一举了...不解
发表于 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。1 a# q5 b* y9 f

' r3 f5 a; a9 a6 a0 s5 B) B3 aEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
$ B0 P" ~4 B7 m2 L+ ~没有用过,暂且记下了.
, G4 d; z; d" }7 t* m% @- R0 j) }  p) b/ H
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-5 17:39 , Processed in 0.052610 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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