找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10667|回复: 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);
    % {# X6 Q1 |3 t# ]+ N
  2.   //2 z: x& W: W: w9 G& ?! [
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed9 q! r: P5 i3 R, G% W9 p2 [
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    # X6 u( W% O. e, z1 L
  5.   // All other return values for SetJump are undefined.
    4 Y; i6 h, T* c
  6.   //4 _( B! N  c+ ]' O% g
  7.   if (Status == EFI_SUCCESS) {
    3 u0 F, M9 D% F, l4 x7 h6 S; @
  8. 3 j- b- c* v/ f6 D3 Z7 x1 g4 k/ l
  9.     //
    3 \" V3 @1 X( H: t
  10.     // Call the image's entry point
    ' B' v' H$ V* G- X  D; Q6 m
  11.     //
    0 V, K  T* e& d5 J7 L
  12.     Image->Started = TRUE;
    # T' J0 e' M7 d. d0 t9 d) ]1 H4 ^0 y4 a- n
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);8 s0 q& M" X+ ^( W: B6 \

  14. 7 _+ M4 r& F! ?, y' {( i' B$ f
  15.     //  j7 i* Z2 C1 `2 X/ J; C. r& `
  16.     // Add some debug information if the image returned with error.
    . {* F( k7 S) c1 Y) `% P
  17.     // This make the user aware and check if the driver image have already released ( l: ~5 u0 @. k3 ^8 ?
  18.     // all the resource in this situation. 7 Y: Z1 ^+ B3 K7 F# K/ C
  19.     //9 Y4 C, T- u) g
  20.     DEBUG_CODE (
    $ m( C/ r* [, @4 ^% R' U& k* H- D: m
  21.       if (EFI_ERROR (Image->Status)) {
    ' i+ a3 F7 N6 H2 `5 [6 Y( }3 R! X! T
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    6 C- A4 v6 j0 d) ~, c# _0 k6 D: Q
  23.       }
    ! p3 B, M& A6 Z* h# [% L
  24.     )) J! s% I" a0 W) Y  D/ ^3 W, r
  25.    
    * R  |7 ]9 E! {! F
  26.     //
    8 s/ O; i/ J' H
  27.     // If the image returns, exit it through Exit()5 P% x9 b& `. B9 I1 |, M8 D
  28.     //# P! m" z, {" g) w( Z& Y
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
      O8 E" P* |3 j
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态6 V8 r! h7 }( [5 _3 ?) z; `
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?5 s0 G" C0 P6 A" w4 x" O/ ~4 Y3 z
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
% p3 n# Q. `' L" {0 m0 ^' W  ]& x3 ~8 @/ A3 h9 w8 E
我感觉有点多此一举了...不解
发表于 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。* y- g: E; W- k8 h! B) Y. L
) G5 ]4 ?. a, x* _8 f9 B
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.3 C. u  l/ ~' y3 _3 a& Q0 f5 B
没有用过,暂且记下了.
/ h* z6 n; |& `+ L/ Y
% w7 n" k1 N- ^; t2 c非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-20 03:39 , Processed in 0.038451 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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