|
请做EFI的大侠&前辈指点一下,红色标记的那个宏怎么解释?
2 |" C' d u0 h' c$ K8 i0 X我调试发现他是取得那个字段的地址。7 E1 M" ^, q1 C7 V! r: k
大侠能详细解释一下吗?' u8 U: U; R3 Q
; x9 S7 t; Q* O0 g" m
这段是我Debug的用例。2 b: }2 f1 n! t- x) o
) z1 p8 p) c! R8 B# `+ [- @) d
#include "stdio.h"% d, H' c5 G( X
#include "stdlib.h": J2 l/ _, f5 W
#include "string.h"! g l! l6 g1 F/ C
: j! b3 X* r: x* `& ?$ Z2 [#define CHAR8 unsigned char6 w; h+ f2 b4 d/ s7 K1 K
6 o- q! c: Z9 j8 u, I. u
typedef struct _tagjany
. M7 D" m, ]4 }9 u& Z{
- o7 }& [) a6 V. [6 k/ p+ }( _ char name[8];
& K. P3 i; H+ Q6 a int age;9 z7 e1 f, o6 `) f
}JANY, *PJANY;0 r+ o5 l% k+ B3 u
1 f+ Y+ j5 t: D& {- R F. z- F X n
typedef struct _tagowen
- ?$ S* J- x( L$ C6 A- p2 \{8 o- d& L' _! W; Q) N% m8 b/ g* k
JANY jy;+ ^5 W- x7 m6 Z1 w
char home[5];
; Z: O7 f9 e* i1 i( _}OWEN, *POWEN;3 x1 }8 ^) X. j* u+ S [3 w
2 {7 a: Q# p" b. B# M$ v7 ^
#define PEI_CORE_HANDLE_SIGNATURE "owen.lu") |6 K( o+ \) p+ R6 O! g
5 ^. [6 _/ P, ^' b- P4 |, n2 Y! P
#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
3 l; y; t0 ]5 x2 C) S
+ V' M6 l. u. @#define PEI_CR(Record, TYPE, Field, Signature) \' o( d* i/ R/ Q. K4 a# ^
_CR(Record, TYPE, Field) ' ~5 X0 u5 ?' ^; N; h
* }' Z! R2 r$ l( _
#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \& |4 g o( S6 M/ @1 H
(PEI_CR(a, JANY, name, PEI_CORE_HANDLE_SIGNATURE))
# }- D# g1 Z+ g
+ n/ {; R& `4 q* i! d1 b' C+ P. {void main()2 u/ M3 w3 T$ K3 X* e
{$ P+ U! D& m; r
PJANY jany;8 \9 o: W5 g9 P* k4 y4 i4 `) {
POWEN owen;
3 `3 `- V- @3 Z* ]" `$ B e( H5 F6 k* h jany = malloc(sizeof(JANY));% Q! |7 H8 B2 c3 l, ^7 W- k
owen = malloc(sizeof(OWEN));
: K/ B& E3 d' k jany = PEI_CORE_INSTANCE_FROM_PS_THIS(owen);3 S+ M# Z1 g8 u2 r! l& R
free(owen);* C$ |- K: S8 W) @- b
free(jany);
/ S* s' n- I7 J7 o& N$ P" t return;
" M+ A* @5 S7 V# V% u1 W1 w} |
|