找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10550|回复: 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);
    - ]  b8 ?6 N4 m0 N, s1 E. x
  2.   //
    ' m( q3 b) _2 u
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed# i* s' B9 g( c7 F+ G! r
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
      c% F% k" ]! m5 W3 P, N$ r
  5.   // All other return values for SetJump are undefined.% }+ f; p# H+ l- o% R- P
  6.   //
    1 ~% @7 e/ `5 _4 i! D4 V( o7 M
  7.   if (Status == EFI_SUCCESS) {# U7 u/ q! H" ^4 M0 d* P5 T0 @
  8. 0 G. t) N8 ]7 G7 T
  9.     //+ z( N7 D/ j9 `& T
  10.     // Call the image's entry point9 |% q% C- l* Y. `
  11.     //
    ) M- L$ e9 Y) F
  12.     Image->Started = TRUE;6 @; q. ^5 z1 ?% Y2 y& W: u0 i
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);0 `% X& W1 G! n  ]5 k4 L1 H# B* n$ l" n$ v
  14. 1 W6 H7 p4 \  k+ c& _
  15.     //
    2 M3 n8 a# o4 l6 x. ?
  16.     // Add some debug information if the image returned with error. & ^- r2 |. |4 j7 f+ C) ^
  17.     // This make the user aware and check if the driver image have already released 5 |; q" q7 [/ ]) J
  18.     // all the resource in this situation.
    ( ]& S) T3 E% f! F5 }1 U
  19.     //
    ' ~" A7 b/ \0 w- C
  20.     DEBUG_CODE (; p- I+ L  \. S# y2 P, m$ |1 R, b, i
  21.       if (EFI_ERROR (Image->Status)) {* O! I8 @, U; ^+ d+ B
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    4 K* T8 P$ t, I- H' C1 b" S' n
  23.       }# P9 b9 L2 J' |: p0 ~
  24.     )
    ( C! R2 O3 j, L+ L7 _7 V9 q
  25.    
      C  a$ G. t4 t" Y
  26.     //8 J! f) o  |$ M
  27.     // If the image returns, exit it through Exit()# P! F8 V9 }) H
  28.     //0 Z7 e! W4 q! I* W: z4 A4 l
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    7 N, Y) H$ M+ J& @) R- ?
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态1 Q" [0 ~) H* k& |, c- q
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
% H8 E3 G2 i$ y' @9 Y/ [. i$ V+ \而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
% Q% b& ^; i3 [- V& }. I- }: F
: `. V  U8 \0 }) p我感觉有点多此一举了...不解
发表于 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。
# N+ R) Q3 s$ Y2 D, `9 ^& }
0 O# a3 R2 z- m1 Y' o; O% HEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
: }' D$ |8 X) ^* @没有用过,暂且记下了.$ u' i/ }) k2 @, T1 k

* P! i4 d" j( o9 |% ~非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-15 06:50 , Processed in 0.611166 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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