找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10724|回复: 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);
    0 O4 O/ c5 H$ ~& R
  2.   //% A5 l4 F+ [! j, g* N6 `$ D
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed3 X* J1 S& U& Q" I! t3 y
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    + s) A0 N. d6 n2 r: c
  5.   // All other return values for SetJump are undefined.
    - `6 l- A0 d. O, j- M6 |- M$ O
  6.   //% P% }- b7 S. v' m$ c: c0 A& t
  7.   if (Status == EFI_SUCCESS) {0 o9 a# O+ r! y: X
  8. & O# d# H& M' D! ~$ K8 ^
  9.     //* E; T; W- Q( q
  10.     // Call the image's entry point
    3 k* v3 J1 a* }! K. o
  11.     //" n5 y, R* l, C( Z6 v6 a. q
  12.     Image->Started = TRUE;& F5 z& p) ^8 Q0 d/ K' c& ?
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
    7 w- B7 J- x* G3 H3 T5 R0 Z

  14. , {6 Z2 h( t+ _0 ^
  15.     //3 J: [2 {# P& u( ~+ T; I, M
  16.     // Add some debug information if the image returned with error.
    3 u' e( a& L4 H' ^
  17.     // This make the user aware and check if the driver image have already released : h5 T: m9 Y( f  Z+ @9 c) b
  18.     // all the resource in this situation. ' z# A1 V* c) o6 Y3 i. n5 J
  19.     //8 A7 Y: p- U1 y0 j
  20.     DEBUG_CODE (
    8 N% P$ g$ x7 x* [: E
  21.       if (EFI_ERROR (Image->Status)) {# D* o$ l! K! y% t0 ~- C9 i
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));+ j1 `( Z. i8 G8 q/ l
  23.       }
    & F- Y; [8 e: q0 J
  24.     )5 k. ~# ?6 P% q: [) X6 I
  25.     ( m2 M- y3 J& G0 ]0 z
  26.     //
    ! ^: P' G% [( i
  27.     // If the image returns, exit it through Exit()
    4 h8 n7 h& O( `# c
  28.     //0 @; C) C* G& y# I
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);6 N! t( n% A4 w" S: J, _
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态
- @$ t* V' Z: h9 K2 J$ V% r既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?7 T1 Y+ v% G6 \/ M
而且目前来看driver只会返回Status而已,根据这个就可以做处理了.
) i& _* P% A/ a/ A! I, ~4 T& g  z2 h3 L3 B  |/ A8 n4 U; q* E( x
我感觉有点多此一举了...不解
发表于 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。
  q8 m  T; x( r; ^" K2 I7 P- Z
) r* z1 N, r+ I' v) X$ N/ ?EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.- z' G5 O! [0 J3 L
没有用过,暂且记下了.- W& j, f. D3 V
8 p( G# b8 X3 }! O4 c" p; p
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-19 21:04 , Processed in 0.253710 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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