Rev 2726 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2726 | Rev 3386 | ||
---|---|---|---|
1 | #include <efi.h> |
1 | #include <efi.h> |
2 | #include <efilib.h> |
2 | #include <efilib.h> |
3 | 3 | ||
4 | EFI_STATUS |
4 | EFI_STATUS |
5 | efi_main( |
5 | efi_main( |
6 | EFI_HANDLE image_handle, |
6 | EFI_HANDLE image_handle, |
7 | EFI_SYSTEM_TABLE *systab |
7 | EFI_SYSTEM_TABLE *systab |
8 | ) |
8 | ) |
9 | { |
9 | { |
10 | EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL; |
10 | EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL; |
11 | EFI_STATUS efi_status; |
11 | EFI_STATUS efi_status; |
12 | EFI_LOADED_IMAGE *li; |
12 | EFI_LOADED_IMAGE *li; |
13 | UINTN pat = PoolAllocationType; |
13 | UINTN pat = PoolAllocationType; |
14 | VOID *void_li_p; |
14 | VOID *void_li_p; |
15 | 15 | ||
16 | InitializeLib(image_handle, systab); |
16 | InitializeLib(image_handle, systab); |
17 | PoolAllocationType = 2; /* klooj */ |
17 | PoolAllocationType = 2; /* klooj */ |
18 | 18 | ||
19 | Print(L"Hello World! (0xd=0x%x, 13=%d)\n", 13, 13); |
19 | Print(L"Hello World! (0xd=0x%x, 13=%d)\n", 13, 13); |
20 | 20 | ||
21 | Print(L"before InitializeLib(): PoolAllocationType=%d\n", |
21 | Print(L"before InitializeLib(): PoolAllocationType=%d\n", |
22 | pat); |
22 | pat); |
23 | 23 | ||
24 | Print(L" after InitializeLib(): PoolAllocationType=%d\n", |
24 | Print(L" after InitializeLib(): PoolAllocationType=%d\n", |
25 | PoolAllocationType); |
25 | PoolAllocationType); |
26 | 26 | ||
27 | /* |
27 | /* |
28 | * Locate loaded_image_handle instance. |
28 | * Locate loaded_image_handle instance. |
29 | */ |
29 | */ |
30 | 30 | ||
31 | Print(L"BS->HandleProtocol() "); |
31 | Print(L"BS->HandleProtocol() "); |
32 | 32 | ||
33 | efi_status = BS->HandleProtocol( |
33 | efi_status = BS->HandleProtocol( |
34 | image_handle, |
34 | image_handle, |
35 | &loaded_image_protocol, |
35 | &loaded_image_protocol, |
36 | &void_li_p); |
36 | &void_li_p); |
37 | li = void_li_p; |
37 | li = void_li_p; |
38 | 38 | ||
39 | Print(L"%xh (%r)\n", efi_status, efi_status); |
39 | Print(L"%xh (%r)\n", efi_status, efi_status); |
40 | 40 | ||
41 | if (efi_status != EFI_SUCCESS) { |
41 | if (efi_status != EFI_SUCCESS) { |
42 | return efi_status; |
42 | return efi_status; |
43 | } |
43 | } |
44 | 44 | ||
45 | Print(L" li: %xh\n", li); |
45 | Print(L" li: %xh\n", li); |
46 | 46 | ||
47 | if (!li) { |
47 | if (!li) { |
48 | return EFI_UNSUPPORTED; |
48 | return EFI_UNSUPPORTED; |
49 | } |
49 | } |
50 | 50 | ||
51 | Print(L" li->Revision: %xh\n", li->Revision); |
51 | Print(L" li->Revision: %xh\n", li->Revision); |
52 | Print(L" li->ParentHandle: %xh\n", li->ParentHandle); |
52 | Print(L" li->ParentHandle: %xh\n", li->ParentHandle); |
53 | Print(L" li->SystemTable: %xh\n", li->SystemTable); |
53 | Print(L" li->SystemTable: %xh\n", li->SystemTable); |
54 | Print(L" li->DeviceHandle: %xh\n", li->DeviceHandle); |
54 | Print(L" li->DeviceHandle: %xh\n", li->DeviceHandle); |
55 | Print(L" li->FilePath: %xh\n", li->FilePath); |
55 | Print(L" li->FilePath: %xh\n", li->FilePath); |
56 | Print(L" li->Reserved: %xh\n", li->Reserved); |
56 | Print(L" li->Reserved: %xh\n", li->Reserved); |
57 | Print(L" li->LoadOptionsSize: %xh\n", li->LoadOptionsSize); |
57 | Print(L" li->LoadOptionsSize: %xh\n", li->LoadOptionsSize); |
58 | Print(L" li->LoadOptions: %xh\n", li->LoadOptions); |
58 | Print(L" li->LoadOptions: %xh\n", li->LoadOptions); |
59 | Print(L" li->ImageBase: %xh\n", li->ImageBase); |
59 | Print(L" li->ImageBase: %xh\n", li->ImageBase); |
60 | Print(L" li->ImageSize: %xh\n", li->ImageSize); |
60 | Print(L" li->ImageSize: %xh\n", li->ImageSize); |
61 | Print(L" li->ImageCodeType: %xh\n", li->ImageCodeType); |
61 | Print(L" li->ImageCodeType: %xh\n", li->ImageCodeType); |
62 | Print(L" li->ImageDataType: %xh\n", li->ImageDataType); |
62 | Print(L" li->ImageDataType: %xh\n", li->ImageDataType); |
63 | Print(L" li->Unload: %xh\n", li->Unload); |
63 | Print(L" li->Unload: %xh\n", li->Unload); |
64 | 64 | ||
65 | #if 0 |
65 | #if 0 |
66 | typedef struct { |
66 | typedef struct { |
67 | UINT32 Revision; |
67 | UINT32 Revision; |
68 | EFI_HANDLE ParentHandle; |
68 | EFI_HANDLE ParentHandle; |
69 | struct _EFI_SYSTEM_TABLE *SystemTable; |
69 | struct _EFI_SYSTEM_TABLE *SystemTable; |
70 | 70 | ||
71 | // Source location of image |
71 | // Source location of image |
72 | EFI_HANDLE DeviceHandle; |
72 | EFI_HANDLE DeviceHandle; |
73 | EFI_DEVICE_PATH *FilePath; |
73 | EFI_DEVICE_PATH *FilePath; |
74 | VOID *Reserved; |
74 | VOID *Reserved; |
75 | 75 | ||
76 | // Images load options |
76 | // Images load options |
77 | UINT32 LoadOptionsSize; |
77 | UINT32 LoadOptionsSize; |
78 | VOID *LoadOptions; |
78 | VOID *LoadOptions; |
79 | 79 | ||
80 | // Location of where image was loaded |
80 | // Location of where image was loaded |
81 | VOID *ImageBase; |
81 | VOID *ImageBase; |
82 | UINT64 ImageSize; |
82 | UINT64 ImageSize; |
83 | EFI_MEMORY_TYPE ImageCodeType; |
83 | EFI_MEMORY_TYPE ImageCodeType; |
84 | EFI_MEMORY_TYPE ImageDataType; |
84 | EFI_MEMORY_TYPE ImageDataType; |
85 | 85 | ||
86 | // If the driver image supports a dynamic unload request |
86 | // If the driver image supports a dynamic unload request |
87 | EFI_IMAGE_UNLOAD Unload; |
87 | EFI_IMAGE_UNLOAD Unload; |
88 | 88 | ||
89 | } EFI_LOADED_IMAGE; |
89 | } EFI_LOADED_IMAGE; |
90 | #endif |
90 | #endif |
91 | 91 | ||
92 | return EFI_SUCCESS; |
92 | return EFI_SUCCESS; |
93 | } |
93 | } |
94 | 94 |