Patrick Georgi | 593124d | 2020-05-10 19:44:08 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Arthur Heymans | be291e8 | 2019-01-06 07:35:11 +0100 | [diff] [blame] | 2 | |
Frans Hendriks | 162d704 | 2021-01-18 15:51:01 +0100 | [diff] [blame] | 3 | #include <cbmem.h> |
Julius Werner | 5358467 | 2021-01-11 16:44:06 -0800 | [diff] [blame] | 4 | #include <cbfs.h> |
Arthur Heymans | be291e8 | 2019-01-06 07:35:11 +0100 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <fsp/util.h> |
| 7 | |
| 8 | asmlinkage void chipset_teardown_car_main(void) |
| 9 | { |
| 10 | FSP_INFO_HEADER *fih; |
| 11 | uint32_t status; |
| 12 | FSP_TEMP_RAM_EXIT temp_ram_exit; |
Arthur Heymans | be291e8 | 2019-01-06 07:35:11 +0100 | [diff] [blame] | 13 | |
Frans Hendriks | 162d704 | 2021-01-18 15:51:01 +0100 | [diff] [blame] | 14 | /* CBMEM_ID_VBOOT_WORKBUF is used as vboot workbuffer. |
| 15 | * Init CBMEM before loading fsp, to have buffer available */ |
| 16 | cbmem_initialize(); |
| 17 | |
Julius Werner | 5358467 | 2021-01-11 16:44:06 -0800 | [diff] [blame] | 18 | void *fsp = cbfs_map("fsp.bin", NULL); |
| 19 | if (!fsp) { |
Arthur Heymans | be291e8 | 2019-01-06 07:35:11 +0100 | [diff] [blame] | 20 | die("Unable to locate fsp.bin\n"); |
| 21 | } else { |
| 22 | /* This leaks a mapping which this code assumes is benign as |
| 23 | * the flash is memory mapped CPU's address space. */ |
| 24 | |
| 25 | /* FIXME: the implementation of find_fsp is utter garbage |
| 26 | as it casts error values to FSP_INFO_HEADER pointers. |
| 27 | Checking for return values can only be done sanely once |
| 28 | that is fixed. */ |
Julius Werner | 5358467 | 2021-01-11 16:44:06 -0800 | [diff] [blame] | 29 | fih = find_fsp((uintptr_t)fsp); |
Arthur Heymans | be291e8 | 2019-01-06 07:35:11 +0100 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | temp_ram_exit = (FSP_TEMP_RAM_EXIT)(fih->TempRamExitEntryOffset + |
| 33 | fih->ImageBase); |
| 34 | printk(BIOS_DEBUG, "Calling TempRamExit: %p\n", temp_ram_exit); |
| 35 | status = temp_ram_exit(NULL); |
| 36 | |
| 37 | if (status != FSP_SUCCESS) { |
| 38 | printk(BIOS_CRIT, "TempRamExit returned 0x%08x\n", status); |
| 39 | die("TempRamExit returned an error!\n"); |
| 40 | } |
| 41 | } |