Andrey Petrov | 465fc13 | 2016-02-25 14:16:33 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 Intel Corp. |
| 5 | * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.) |
| 6 | * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | */ |
| 13 | |
| 14 | #include <arch/io.h> |
| 15 | #include <arch/cpu.h> |
| 16 | #include <console/console.h> |
| 17 | #include <fsp/api.h> |
| 18 | #include <fsp/util.h> |
| 19 | #include <memrange.h> |
| 20 | #include <string.h> |
| 21 | #include <timestamp.h> |
| 22 | |
| 23 | typedef asmlinkage enum fsp_status (*fsp_memory_init_fn) |
| 24 | (void *raminit_upd, void **hob_list); |
| 25 | |
| 26 | static enum fsp_status do_fsp_memory_init(void **hob_list_ptr, |
| 27 | struct fsp_header *hdr) |
| 28 | { |
| 29 | enum fsp_status status; |
| 30 | fsp_memory_init_fn fsp_raminit; |
| 31 | struct FSPM_UPD fspm_upd, *upd; |
| 32 | |
| 33 | post_code(0x34); |
| 34 | |
| 35 | upd = (struct FSPM_UPD *)(hdr->cfg_region_offset + hdr->image_base); |
| 36 | |
| 37 | if (upd->FspUpdHeader.Signature != FSPM_UPD_SIGNATURE) { |
| 38 | printk(BIOS_ERR, "Invalid FSPM signature\n"); |
| 39 | return FSP_INCOMPATIBLE_VERSION; |
| 40 | } |
| 41 | |
| 42 | /* Copy the default values from the UPD area */ |
| 43 | memcpy(&fspm_upd, upd, sizeof(fspm_upd)); |
| 44 | |
| 45 | /* Give SoC and mainboard a chance to update the UPD */ |
| 46 | platform_fsp_memory_init_params_cb(&fspm_upd); |
| 47 | |
| 48 | /* Call FspMemoryInit */ |
| 49 | fsp_raminit = (void *)(hdr->image_base + hdr->memory_init_entry_offset); |
| 50 | printk(BIOS_DEBUG, "Calling FspMemoryInit: 0x%p\n", fsp_raminit); |
| 51 | printk(BIOS_SPEW, "\t%p: raminit_upd\n", &fspm_upd); |
| 52 | printk(BIOS_SPEW, "\t%p: hob_list ptr\n", hob_list_ptr); |
| 53 | |
| 54 | timestamp_add_now(TS_FSP_MEMORY_INIT_START); |
| 55 | status = fsp_raminit(&fspm_upd, hob_list_ptr); |
| 56 | post_code(0x37); |
| 57 | timestamp_add_now(TS_FSP_MEMORY_INIT_END); |
| 58 | |
| 59 | printk(BIOS_DEBUG, "FspMemoryInit returned 0x%08x\n", status); |
| 60 | |
| 61 | return status; |
| 62 | } |
| 63 | |
| 64 | enum fsp_status fsp_memory_init(void **hob_list, struct range_entry *range) |
| 65 | { |
| 66 | struct fsp_header hdr; |
| 67 | |
| 68 | /* TODO: do not hardcode CBFS file names */ |
| 69 | if (fsp_load_binary(&hdr, "blobs/fspm.bin", range) != CB_SUCCESS) |
| 70 | return FSP_NOT_FOUND; |
| 71 | |
| 72 | return do_fsp_memory_init(hob_list, &hdr); |
| 73 | } |