找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10843|回复: 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);
      r* X! L, h1 B( c9 P0 @9 `1 u
  2.   //
    # U+ Z0 z; c6 i0 m3 g# ~
  3.   // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
    ' Q9 j% F2 l" L, y
  4.   // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
    8 M1 l% m3 }% e# p2 R6 D; N% E
  5.   // All other return values for SetJump are undefined.- @4 J8 r& @! r& E+ h6 w6 D
  6.   //" Z$ ?' I* T% M
  7.   if (Status == EFI_SUCCESS) {
    4 o; `2 M3 o5 C6 d  H0 N
  8. - t/ N: H& O! O; ]: v
  9.     //
    * f, M1 H& l1 P' S+ Y% v/ Z
  10.     // Call the image's entry point
    ( K# i' M, t$ N8 s5 z# n* y
  11.     //
    + p5 n8 o$ [  o3 ~/ a! j# L8 y
  12.     Image->Started = TRUE;
    - w9 J* L, v8 ~) e/ m7 g/ T; m5 z/ @
  13.     Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);7 g: J0 f5 w- G

  14. - x0 I4 b' _: H' z( S$ t2 j8 v! x: h
  15.     //
      F' V& L. i$ {+ }- D% D& z- {
  16.     // Add some debug information if the image returned with error.
    % U3 I- z8 o8 e8 c% O- c
  17.     // This make the user aware and check if the driver image have already released
    ! l% c! R" w& O* h; i' K- s( d
  18.     // all the resource in this situation. 0 A& F# e- q' ~
  19.     //
    & l9 j) g- i6 t' q3 W4 t5 @
  20.     DEBUG_CODE (
    5 R2 n  e: {0 C$ N4 M1 Y# V
  21.       if (EFI_ERROR (Image->Status)) {
      Y. T- U, u& J7 {
  22.         DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
    " [1 E+ n1 o+ D" I
  23.       }
    ! A; k) \0 \) i' Q; `" H) b9 R
  24.     )
    * ~" [; {: A) _* |1 M
  25.    
    ! G0 @  g4 V# M# \8 Q) d0 y, e, ~
  26.     //
    6 i1 s( i0 Z, H
  27.     // If the image returns, exit it through Exit()6 k3 Z/ i# {; M7 ?6 t, W3 j3 u
  28.     //
    ( f; q& a6 Z" i5 U+ U  C: L; @
  29.     CoreExit (ImageHandle, Image->Status, 0, NULL);
    ( n7 `( Q$ y6 J2 `; P/ F
  30.   }
复制代码
调用DXE driver前,为什么要用SetJump保存CPU的信息,driver返回后,再用CoreExit--LongJump恢复到SetJump时的状态  `& y6 H$ q- b! C! A& M
既然driver可以返回,为什么非要这样恢复到调用前的状态呢?难道在调用driver的过程CPU的状态可能会被破坏吗?
" F4 l. J: c( D而且目前来看driver只会返回Status而已,根据这个就可以做处理了.6 B8 R+ `8 a) H" `) ?( F; Y

: D+ w2 Q+ i6 w/ J4 R我感觉有点多此一举了...不解
发表于 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。7 B  l* Y! ^* e% V. Q
5 \* Z% s: X* x: G$ t% T. W6 M8 x
EFI_PEI_TRANSFER_CONTROL_PROTOCOL提供的SetJump/LongJump函数就是支持Exit boot service用的。类似于C的setjmp和longjmp库函数。
回复

使用道具 举报

 楼主| 发表于 2008-10-31 10:03:16 | 显示全部楼层
有点了解了,Exit()可以直接退出返回一些参数.
' X5 w8 G; w3 k; @, ~! r8 j/ w" |没有用过,暂且记下了.' z7 K: r# }, U9 }* \
# ]9 ^' [6 V. Y9 C3 w5 ?) B
非常感谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-29 06:04 , Processed in 0.085972 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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