找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 9852|回复: 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);
    5 C9 q5 r4 H" Y0 T
  2.   //
    ! V& q( S* a5 ^) [) a; I4 m# P: F
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    0 p% g$ p. A" ?) `" y; W) u
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump& V5 ~# K( o9 e
  5.   // All other return values for SetJump are undefined.
    6 w, Y8 j+ D. ~  F2 g) o
  6.   //
    " |& @: s6 m  t& k6 C9 O
  7.   if (Status == EFI_SUCCESS) {3 ]- t: v' V& w8 y

  8. 7 q4 Z9 a  x; W7 H2 @# [
  9.     //
    0 D& i+ j: q- \5 |
  10.     // Call the image's entry point
    2 g; h0 d4 f3 r. S' F) z7 _
  11.     //; T/ ?2 P8 ?* o! u
  12.     Image->Started = TRUE;
    ! n. e  B2 {3 f+ e
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);+ @. B' d, ]1 N" e6 w- T- N4 I# v

  14. ) O+ q* U0 I' N
  15.     //
    - i4 b6 D; A5 p4 F
  16.     // Add some debug information if the image returned with error.
    2 E8 I/ y) p5 \: K
  17.     // This make the user aware and check if the driver image have already released $ O( E# u+ S* D4 x6 U9 v
  18.     // all the resource in this situation.
    : Q+ w- ^9 h( x9 o! ]
  19.     //, S' i5 u+ \* Z# w5 }, G; D5 P
  20.     DEBUG_CODE (  ]) B" {  `3 F/ Y5 w
  21.       if (EFI_ERROR (Image->Status)) {2 k+ R2 D2 H, x# p1 h' y# Z
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    9 F/ }' L" R7 D& A+ L# N
  23.       }
    3 @7 n; |$ q0 ?$ ^" m# {
  24.     )
    " S1 d; |, E% g
  25.     8 k3 ~% Y" z' d; G4 A
  26.     //* A6 o! a2 y$ f- V* [
  27.     // If the image returns, exit it through Exit()
    7 `: F% U- N2 Z4 G
  28.     //- N& s* N" H% [: V
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);: u, Q2 c4 z5 p9 ?$ k
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
8 a0 Q( D4 s* J* W0 G" v1 [; \既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
, \5 J9 q0 a+ t( x8 i而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
8 ~3 @) Z* b$ F5 f5 K* ?* b/ z+ @4 i3 {4 n! n* U
我感觉有点多此一举了...不解
发表于 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。
3 _! B& d3 |& X8 [% M2 L0 g7 x( N2 f. o6 s0 T5 ~
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
: S8 d6 \' J, ~: W5 M7 @  }没有用过,暂且记下了.
5 l2 Z, C3 F* N/ W% f# j, f
  E1 S4 l4 q/ V, I& |非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-12 06:54 , Processed in 0.024199 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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