找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10354|回复: 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);
    : |; Z6 z4 D; E1 Z
  2.   //
      g) C- d7 Y7 }' Z3 I
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed  T, Y8 \' [* T0 x# D* ]
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump6 J7 [: O) m& B
  5.   // All other return values for SetJump are undefined.
    4 n+ ^, _9 K6 u& M: ^7 Z, {; t
  6.   //
    ; S7 X9 Q4 }+ q! s7 H* _
  7.   if (Status == EFI_SUCCESS) {
    . ]7 B, R: t  ?6 w8 D

  8. - T% a) o: }% d; `) Q) v9 q
  9.     //
    ' Y* L4 R! [6 X' x) j) q$ t# X8 g
  10.     // Call the image's entry point: H" }  P3 F5 [3 n, c4 H: `
  11.     //: A$ k6 o# ~5 n7 O: S
  12.     Image->Started = TRUE;4 E2 J+ \* ]0 A5 h- a
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    : w- V3 K# N( `4 q9 I

  14. 6 H0 @6 z$ u' s' m( |
  15.     //' N8 T. n3 Z  {& g( W
  16.     // Add some debug information if the image returned with error.
    ! }# N0 `$ d9 p8 ~
  17.     // This make the user aware and check if the driver image have already released
    ! r: L2 ^, A, d- D9 o0 U  o% `* k
  18.     // all the resource in this situation. " x: K$ o4 _: u2 b
  19.     //
      m) E' ]4 ]$ ^
  20.     DEBUG_CODE (
    + W/ `- F1 |* |. ^
  21.       if (EFI_ERROR (Image->Status)) {5 [4 l# l" C. O! N- ~6 a$ @) K
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    $ \  Q- j4 P8 b9 x
  23.       }) P# J, g- t6 c' L
  24.     )
    . K% U3 O& Q7 g( ?$ c* v
  25.    
    1 t6 w9 v& B- p! [% K6 N, Q
  26.     //
    3 Y, \0 H0 R! }% @, j' `
  27.     // If the image returns, exit it through Exit()! ~  i% T8 S: h) N6 m9 @$ L/ x" H
  28.     //
    - t; l' |1 o* r! m5 n6 p' }; h% A3 L
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);- S9 o/ S) d, l
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态; ?: a* B  y, m3 V( y
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
: ^* L2 W, _# k5 C+ h9 s而且目前来看driver只会返回Status而已,根据这个就可以做处理了.0 h' n8 a3 ?, I' k. {
5 r2 d. V1 c! s; N& _9 r3 y
我感觉有点多此一举了...不解
发表于 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。
2 l5 p8 j$ x* ]  Q& A! b0 {0 X) S. G; J
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.1 v0 G6 B% I- g2 h5 O
没有用过,暂且记下了.1 ^" ?0 {5 N' {; e

$ J0 _& b! z% b* z- S5 W非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-12 05:38 , Processed in 0.058996 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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