找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10839|回复: 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);
    - `6 L$ ~1 D: V4 R% \- z- W
  2.   //
    7 f1 L0 i$ A1 p) D; u
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed; [; ~( v5 L. R3 z; L6 m
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    % r- p6 j) _5 I4 S. X. B9 X3 s5 i
  5.   // All other return values for SetJump are undefined.& s4 G4 ?1 |' E$ i/ m- S. F$ m
  6.   //
    4 ^6 r5 M  U1 D2 q. |
  7.   if (Status == EFI_SUCCESS) {
    2 J! \+ m% w0 b% o0 u8 ^& v! ?
  8. : s4 C0 Y3 H5 s* D
  9.     //4 n( b. e2 W/ X) a9 Y% M0 U2 D+ h
  10.     // Call the image's entry point
    # P* {6 X# O5 \5 A& l1 z( F) Y
  11.     //
    & h! O( I# M- L) G1 D
  12.     Image->Started = TRUE;4 Z; r% W. a$ R% I) {
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    9 ^9 Y" |# I: `# l' B

  14. ( ~3 f, Q0 v" C) X; R; U# N
  15.     //
    5 Y# O; e6 l* w/ ]$ P
  16.     // Add some debug information if the image returned with error.
    9 }7 N8 O( S3 U8 k  y- [+ N. A
  17.     // This make the user aware and check if the driver image have already released
    ) c* y: f% \' @; z6 k4 N; I
  18.     // all the resource in this situation. , U) O+ ~5 Z) @2 {" U) S
  19.     //
    + n* {4 T/ u1 G9 m* L: q) w+ c
  20.     DEBUG_CODE (1 _- J- c+ J: s5 e" Z  h( r, I
  21.       if (EFI_ERROR (Image->Status)) {
    ! f+ F# w' @# H% ]# w7 [
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));; X$ M# v" ~8 ~( Y7 a# U
  23.       }0 ?# A) d. j3 N* U
  24.     )  p/ ~5 Q" }& V" T9 u
  25.     1 c; `' U+ _. v. W1 g. M
  26.     //7 Q! f1 z5 {7 d  i1 X
  27.     // If the image returns, exit it through Exit()
    5 Q' W2 k, @. f1 r1 D/ H. ~
  28.     //
    * v6 H# |  ]! _+ R, r' w- D8 M
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);" F1 R$ c5 v6 y% P6 J$ K3 o
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
- j. g+ N8 V- v: t$ O' V/ M) k既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?; c+ m6 P; O* l) [# G
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
5 t. [! i7 ^9 T( m6 z/ r% w2 }# E' v- g) C! N# D
我感觉有点多此一举了...不解
发表于 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。0 u' @& d) j& Q( `; h( e

6 ~. R& r4 l4 F' LEFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出 和 返回一些参数.) L2 p! k/ t2 \8 K1 n3 Q- ?
没有用过,暂且记下了.
* E# J: I  |5 k2 X1 G; D
2 V9 q; D0 I. R$ R) H, o非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-3 23:08 , Processed in 0.116276 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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