找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10620|回复: 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);" A, q5 g9 h+ o6 Z0 m; W
  2.   //2 V! h: K$ o* Y* c6 p( u/ y6 m
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    + z6 p. [) ~' K% R  M1 L2 e) t% @
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    4 o; o8 Z3 v: f! P) }
  5.   // All other return values for SetJump are undefined.
    7 [, E2 }8 x% s0 X7 w
  6.   //
    " Z! K4 B/ j+ N+ ?8 N1 i
  7.   if (Status == EFI_SUCCESS) {; E& q& [1 x6 E
  8. 5 o& i8 R4 p3 h8 I
  9.     //) x, B5 T8 B, `8 ]# `* Y- k
  10.     // Call the image's entry point2 e# v- q% f7 W$ ]) D5 @' @$ ]
  11.     //
    5 ]1 e1 E* F6 V  k& a1 ?8 u) R/ o
  12.     Image->Started = TRUE;
    ) I& Z& N& s% Y8 p' F0 p3 B
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    - {# x8 t4 [1 e0 M3 n

  14. 4 P1 B, l* o& w/ l3 ^9 X
  15.     //! W  P# n3 y0 m+ M- `. `. l8 ^
  16.     // Add some debug information if the image returned with error.
    3 O8 N# w$ P& U* B  g( D% Q
  17.     // This make the user aware and check if the driver image have already released
    $ Q  Y5 K. ^& k3 l: E0 ]3 K* w9 K- X) U
  18.     // all the resource in this situation.
    ! Y% c5 c1 b. T7 Q# g7 _6 c# x
  19.     //6 M2 n9 \/ o; O6 l5 F3 f. R) V
  20.     DEBUG_CODE (9 A0 _( R  J/ a
  21.       if (EFI_ERROR (Image->Status)) {( R9 a0 t. U# N9 V# P+ R
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));: E7 ]5 K! U5 m* i* g% g
  23.       }' {" k# s3 B; p, q
  24.     )
    , j, M/ l0 x5 i
  25.     1 t4 @2 M- v# ~- @7 X! w* p
  26.     //
    . x4 R4 V* n" a: v7 O
  27.     // If the image returns, exit it through Exit()" e, s+ o. G+ S
  28.     //
    $ v; M3 J9 a- z4 X; I, b% _
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);1 I. V3 H/ B: y/ P
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
1 I* O# O  B  z既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
. W+ l; Z1 W7 U' n2 |$ ?而且目前来看driver只会返回Status而已,根据这个就可以做处理了." V" n7 f0 p7 P

3 b# Y4 `, \7 X1 j3 p+ V我感觉有点多此一举了...不解
发表于 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。
* l# I) u+ q0 O) }8 h: |
! k: Z$ M6 y* D: _9 t3 GEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.. [% [- X. F& q6 w6 t
没有用过,暂且记下了.
# B& Z3 V0 H9 U) E: N5 X# D' I$ N8 }6 c
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-4 14:33 , Processed in 0.067384 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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