blob: 9a8ab5ba4263321b56ed668c8efea395ddc6bf3c [file] [log] [blame]
Mariusz Szafranskia4041332017-08-02 17:28:17 +02001/*
2 * This file is part of the coreboot project.
3 *
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +08004 * Copyright (C) 2018 Intel Corp.
Mariusz Szafranskia4041332017-08-02 17:28:17 +02005 *
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>
22
Arthur Heymans0eb9c572019-01-05 18:21:47 +010023#define CBFS_FILE_MAGIC 0
24#define CBFS_FILE_LEN (CBFS_FILE_MAGIC + 8)
25#define CBFS_FILE_TYPE (CBFS_FILE_LEN + 4)
26#define CBFS_FILE_CHECKSUM (CBFS_FILE_TYPE + 4)
27#define CBFS_FILE_OFFSET (CBFS_FILE_CHECKSUM + 4)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020028
29.extern temp_ram_init_params
30
31.global bootblock_pre_c_entry
32bootblock_pre_c_entry:
33
34.global cache_as_ram
35cache_as_ram:
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080036 post_code(0x21)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020037
38 /* find fsp in cbfs */
39 lea fsp_name, %esi
40 mov $1f, %esp
41 jmp walkcbfs_asm
421:
43 cmp $0, %eax
44 jz .halt_forever
45 mov CBFS_FILE_OFFSET(%eax), %ebx
46 bswap %ebx
47 add %eax, %ebx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080048 add $0x94, %ebx
Mariusz Szafranskia4041332017-08-02 17:28:17 +020049
50 /*
51 * save mm2 into ebp, because TempRamInit API doesn't preserve
52 * mm2 register
53 */
54 movd %mm2, %ebp
55
56 /*
57 * ebx = FSP INFO HEADER
58 * Calculate entry into FSP
59 */
60 movl 0x30(%ebx), %eax /* Load TempRamInitEntryOffset */
61 addl 0x1c(%ebx), %eax /* add the FSP ImageBase */
62
63 /*
64 * Pass early init variables on a fake stack (no memory yet)
65 * as well as the return location
66 */
67 leal CAR_init_stack, %esp
68
69 /* call FSP binary to setup temporary stack */
70 jmp *%eax
71
72/*
73 * If the TempRamInit API is successful, then when returning, the ECX and
74 * EDX registers will point to the temporary but writeable memory range
75 * available to the bootloader where ECX is the start and EDX is the end of
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080076 * the range i.e. [ECX,EDX). See FSP Integration Guide for more information.
Mariusz Szafranskia4041332017-08-02 17:28:17 +020077 *
78 * Return Values:
79 * EAX | Return Status
80 * ECX | Temporary Memory Start
81 * EDX | Temporary Memory End
82 * EBX, EDI, ESI, EBP, MM0, MM1 | Preserved Through API Call
83 */
84
85CAR_init_done:
86 cmp $0, %eax
87 jnz .halt_forever
88
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080089 /* Setup bootblock stack */
90 mov %edx, %esp
91
Mariusz Szafranskia4041332017-08-02 17:28:17 +020092 /* clear CAR_GLOBAL area as it is not shared */
93 cld
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080094 xor %eax, %eax
95 movl $(_car_global_end), %ecx
96 movl $(_car_global_start), %edi
97 sub %edi, %ecx
Mariusz Szafranskia4041332017-08-02 17:28:17 +020098 shrl $2, %ecx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080099 rep stosl
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200100
101 /* Restore the timestamp from bootblock_crt0.S (ebp:mm1) */
102 push %ebp
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +0800103 movd %mm1, %eax
104 push %eax
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200105
106 /* We can call into C functions now */
107 call bootblock_c_entry
108
109 /* Never reached */
110
111.halt_forever:
112 post_code(POST_DEAD_CODE)
113 hlt
114 jmp .halt_forever
115
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200116CAR_init_stack:
117 .long CAR_init_done
118 .long temp_ram_init_params
119
120fsp_name:
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +0800121 .string "fspt.bin"