找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10834|回复: 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);
    3 N, I( ?9 a: H6 E! P! n& w5 P! Q. `& q
  2.   //
    5 W9 |9 g" e% X4 Z: i; `: \
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed( R, X  ?: \8 ^$ U8 e" x- a
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump( [- _" ^+ o) j- p8 o
  5.   // All other return values for SetJump are undefined.+ W% K+ W. {: E4 `! x6 J/ a
  6.   //
    + z3 N: b* F! x4 V" w* ^
  7.   if (Status == EFI_SUCCESS) {
    + w- r/ v! F* n% S$ @) X
  8. 5 l& N4 z2 i! H5 D: X4 X' t
  9.     //3 n4 F3 z8 p, {  u. B  r
  10.     // Call the image's entry point
    - Y# z4 X+ S) a% u% H1 {0 ~
  11.     //) t8 y5 u* c) c+ U0 h1 {
  12.     Image->Started = TRUE;
    2 L( L, K1 v3 t& N2 I, h
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);1 P# Y/ F* T9 o& X0 o6 |4 |5 U

  14. 3 b4 P; W. T- p9 A$ M; s
  15.     //
    # I  @- h8 h# z) B2 g+ U6 W
  16.     // Add some debug information if the image returned with error.
    ) }% @6 `" C' R' ?0 {$ Q& E# {. c
  17.     // This make the user aware and check if the driver image have already released 3 U2 q8 e( H; p( ~, u$ G& |2 t) |, w
  18.     // all the resource in this situation.
    0 [# |; c5 |. V6 \& u3 \! |
  19.     //
      I& N1 I! a' k8 b0 e
  20.     DEBUG_CODE (
    $ ]' Z7 p5 d: P9 L" S: ~$ X+ K
  21.       if (EFI_ERROR (Image->Status)) {
    & c0 a6 O  z- X4 O
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));) Y7 y  F( ]/ D$ _% o" B
  23.       }# f3 f% Z3 s5 H$ ^
  24.     )) A: A2 s3 R; B. a0 W
  25.    
    4 ^/ `( t1 \% R4 f. T8 b  d' @
  26.     //( }5 B; i' r8 G
  27.     // If the image returns, exit it through Exit()  h) p% v8 J6 s, ?9 x& q
  28.     //& ~# ~2 g+ u4 w- B3 s  O& I
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);  s+ d9 h( O  H0 m
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
0 n8 J3 C; w5 S) e1 O; Z* d; h6 u1 P既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?( N0 ^$ _) ~0 I- i) O* `# O7 N9 Z
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
! y; T" a; E/ n8 m! A( D- L1 S2 L, s  ?: K) e% a& {: L4 h
我感觉有点多此一举了...不解
发表于 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。" F2 _( A9 m% {% _: v* Z
( z/ G# t' u* q% w
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出 和 返回一些参数.+ ^0 ^- L2 e! Y. ~. ?, K$ k' L
没有用过,暂且记下了.) c# S$ g( J+ e7 N9 N. L

6 l6 ~3 V& a  Z+ R3 e7 W% m非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-1 21:29 , Processed in 0.447149 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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