找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 9948|回复: 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);. C% J: \# F: `- F
  2.   //2 Q, u; C& w5 t  C
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed+ Q- \: m4 f1 b9 U# b! g& x
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump+ f3 R2 R9 {. c
  5.   // All other return values for SetJump are undefined.# {' S) S% h, U* ?. p. K
  6.   //
    ( l" Y5 c" h% W. }/ Q) u; p7 }9 l
  7.   if (Status == EFI_SUCCESS) {. K( W# I1 F1 t9 x) H

  8. , k8 |9 z  M( j; f7 ]7 G9 [+ L1 i) A
  9.     //  Z+ O* K! O. M/ z- }6 L
  10.     // Call the image's entry point
    . m3 E0 a& ^, B1 J4 _% c9 R
  11.     //
    7 E' n6 ~2 _% I, w& g; ^
  12.     Image->Started = TRUE;1 Y+ E( r/ ?2 T
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    8 q7 N& Y7 z# R, k4 S$ S
  14. 2 [9 E, ^; z" K9 X: A( ^
  15.     //
    0 Y' }6 B. x! }7 C& z# P+ K. o
  16.     // Add some debug information if the image returned with error.
    & T' K5 v* [5 N9 T( A/ }$ W
  17.     // This make the user aware and check if the driver image have already released
    , W( y/ Z1 W& z# B
  18.     // all the resource in this situation. & x( t. @3 o1 b1 y& L
  19.     //) K. @; B% k; u! |  h/ {# _# H- S
  20.     DEBUG_CODE (
    % S6 E& e; Q3 ^2 k: e' b4 c
  21.       if (EFI_ERROR (Image->Status)) {
    $ }. u6 J! H) u- j- g7 e" C# C4 J
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));1 {: a6 \8 A8 q2 R
  23.       }
    ( K  ^% I6 H9 {/ j
  24.     )
    6 i6 E/ G# e/ T9 ]4 [
  25.     + C. H1 u2 ?+ U6 _% n
  26.     //
    ; r- V3 f0 T, X5 k
  27.     // If the image returns, exit it through Exit()+ e" y* R! {/ k+ D
  28.     //0 `* J* S/ r; L
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    . ?# i; {8 d4 i( H. j% ~
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态/ S0 I% G- P% [* r4 z6 f
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
" ?0 l5 G* t+ K( B( l: X而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
- Q  ?* A8 O, \" I% ]
) d% Z+ @) {8 o) u$ F我感觉有点多此一举了...不解
发表于 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。
5 y$ Q% {& t( W( a  S( D( C$ W" |2 L# C% Y
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.  p- E6 N& c3 J" X& V1 J- c/ ]
没有用过,暂且记下了.4 d, w  Y8 A) y; S$ j7 S( A; c; r

  P+ m6 s9 U* @# p$ \& r非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-14 21:45 , Processed in 0.023707 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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