2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <agesa_headers.h>
16 #include <amdblocks/image.h>
18 /* Check if the image has the desired module. */
19 static bool validate_image(void *module_chain
, const char module_signature
[8])
21 AMD_MODULE_HEADER
*mod_ptr
= (AMD_MODULE_HEADER
*)module_chain
;
22 uint64_t signature
= *(uint64_t *)module_signature
;
25 while ((mod_ptr
!= NULL
) &&
26 (MODULE_SIGNATURE
== *(uint32_t *)&mod_ptr
->ModuleHeaderSignature
)) {
27 checking_str
= (char *)&mod_ptr
->ModuleIdentifier
;
28 if (signature
== *(uint64_t *)checking_str
)
30 mod_ptr
= (AMD_MODULE_HEADER
*)mod_ptr
->NextBlock
;
36 * Find an image that has the desired module. The image is aligned within
39 void *amd_find_image(const void *start_address
, const void *end_address
,
40 uint32_t alignment
, const char name
[8])
42 uint8_t *current_ptr
= (uint8_t *)start_address
;
43 uint8_t *start
= (uint8_t *)start_address
;
44 uint8_t *end
= (uint8_t *)end_address
;
45 AMD_IMAGE_HEADER
*image_ptr
;
47 while ((current_ptr
>= start
) && (current_ptr
< end
)) {
48 if (IMAGE_SIGNATURE
== *((uint32_t *)current_ptr
)) {
49 image_ptr
= (AMD_IMAGE_HEADER
*) current_ptr
;
51 /* Check if the image has the desired module */
52 if (validate_image((void *)image_ptr
->ModuleInfoOffset
,
56 current_ptr
+= alignment
;