Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 4 | * Copyright (C) 2018 Intel Corp. |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <device/pci_def.h> |
| 18 | #include <cpu/x86/mtrr.h> |
| 19 | #include <cpu/x86/cache.h> |
| 20 | #include <cpu/x86/cr.h> |
| 21 | #include <cpu/x86/post_code.h> |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 22 | #include <../../../../../arch/x86/walkcbfs.S> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 23 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 24 | |
| 25 | .extern temp_ram_init_params |
| 26 | |
| 27 | .global bootblock_pre_c_entry |
| 28 | bootblock_pre_c_entry: |
| 29 | |
| 30 | .global cache_as_ram |
| 31 | cache_as_ram: |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 32 | post_code(0x21) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 33 | |
| 34 | /* find fsp in cbfs */ |
| 35 | lea fsp_name, %esi |
| 36 | mov $1f, %esp |
| 37 | jmp walkcbfs_asm |
| 38 | 1: |
| 39 | cmp $0, %eax |
| 40 | jz .halt_forever |
| 41 | mov CBFS_FILE_OFFSET(%eax), %ebx |
| 42 | bswap %ebx |
| 43 | add %eax, %ebx |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 44 | add $0x94, %ebx |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 45 | |
| 46 | /* |
| 47 | * save mm2 into ebp, because TempRamInit API doesn't preserve |
| 48 | * mm2 register |
| 49 | */ |
| 50 | movd %mm2, %ebp |
| 51 | |
| 52 | /* |
| 53 | * ebx = FSP INFO HEADER |
| 54 | * Calculate entry into FSP |
| 55 | */ |
| 56 | movl 0x30(%ebx), %eax /* Load TempRamInitEntryOffset */ |
| 57 | addl 0x1c(%ebx), %eax /* add the FSP ImageBase */ |
| 58 | |
| 59 | /* |
| 60 | * Pass early init variables on a fake stack (no memory yet) |
| 61 | * as well as the return location |
| 62 | */ |
| 63 | leal CAR_init_stack, %esp |
| 64 | |
| 65 | /* call FSP binary to setup temporary stack */ |
| 66 | jmp *%eax |
| 67 | |
| 68 | /* |
| 69 | * If the TempRamInit API is successful, then when returning, the ECX and |
| 70 | * EDX registers will point to the temporary but writeable memory range |
| 71 | * available to the bootloader where ECX is the start and EDX is the end of |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 72 | * the range i.e. [ECX,EDX). See FSP Integration Guide for more information. |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 73 | * |
| 74 | * Return Values: |
| 75 | * EAX | Return Status |
| 76 | * ECX | Temporary Memory Start |
| 77 | * EDX | Temporary Memory End |
| 78 | * EBX, EDI, ESI, EBP, MM0, MM1 | Preserved Through API Call |
| 79 | */ |
| 80 | |
| 81 | CAR_init_done: |
| 82 | cmp $0, %eax |
| 83 | jnz .halt_forever |
| 84 | |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 85 | /* Setup bootblock stack */ |
| 86 | mov %edx, %esp |
| 87 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 88 | /* clear CAR_GLOBAL area as it is not shared */ |
| 89 | cld |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 90 | xor %eax, %eax |
| 91 | movl $(_car_global_end), %ecx |
| 92 | movl $(_car_global_start), %edi |
| 93 | sub %edi, %ecx |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 94 | shrl $2, %ecx |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 95 | rep stosl |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 96 | |
| 97 | /* Restore the timestamp from bootblock_crt0.S (ebp:mm1) */ |
| 98 | push %ebp |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 99 | movd %mm1, %eax |
| 100 | push %eax |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 101 | |
| 102 | /* We can call into C functions now */ |
| 103 | call bootblock_c_entry |
| 104 | |
| 105 | /* Never reached */ |
| 106 | |
| 107 | .halt_forever: |
| 108 | post_code(POST_DEAD_CODE) |
| 109 | hlt |
| 110 | jmp .halt_forever |
| 111 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 112 | CAR_init_stack: |
| 113 | .long CAR_init_done |
| 114 | .long temp_ram_init_params |
| 115 | |
| 116 | fsp_name: |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame^] | 117 | .string "fspt.bin" |