Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <cpu/x86/cache.h> |
| 15 | #include <cpu/x86/post_code.h> |
| 16 | |
| 17 | .global bootblock_pre_c_entry |
| 18 | bootblock_pre_c_entry: |
| 19 | |
| 20 | cache_as_ram: |
| 21 | post_code(0x20) |
| 22 | /* |
| 23 | * Nothing to do here on qemu, RAM works just fine without any |
| 24 | * initialization. |
| 25 | */ |
| 26 | |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 27 | /* Clear the cache memory region. This will also clear CAR GLOBAL */ |
Kyösti Mälkki | a7cac0a | 2019-08-18 08:30:30 +0300 | [diff] [blame] | 28 | movl $_car_region_start, %edi |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 29 | movl $_car_region_end, %ecx |
Kyösti Mälkki | a7cac0a | 2019-08-18 08:30:30 +0300 | [diff] [blame] | 30 | sub %edi, %ecx |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 31 | shr $2, %ecx |
| 32 | xorl %eax, %eax |
| 33 | rep stosl |
| 34 | |
Kyösti Mälkki | a7cac0a | 2019-08-18 08:30:30 +0300 | [diff] [blame] | 35 | post_code(0x21) |
| 36 | |
| 37 | movl $_car_stack_end, %esp |
| 38 | |
| 39 | /* Align the stack and keep aligned for call to bootblock_c_entry() */ |
| 40 | and $0xfffffff0, %esp |
Kyösti Mälkki | a7cac0a | 2019-08-18 08:30:30 +0300 | [diff] [blame] | 41 | |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 42 | /* Restore the BIST result and timestamps. */ |
Patrick Rudolph | b1ef725 | 2019-09-28 17:44:01 +0200 | [diff] [blame^] | 43 | #if defined(__x86_64__) |
| 44 | movd %mm1, %rdi |
| 45 | shld %rdi, 32 |
| 46 | movd %mm1, %rsi |
| 47 | or %rsi, %rdi |
| 48 | movd %mm2, %rsi |
| 49 | #else |
| 50 | sub $4, %esp |
| 51 | |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 52 | movd %mm0, %ebx |
| 53 | movd %mm1, %eax |
| 54 | movd %mm2, %edx |
| 55 | |
| 56 | pushl %ebx |
| 57 | pushl %edx |
| 58 | pushl %eax |
Patrick Rudolph | b1ef725 | 2019-09-28 17:44:01 +0200 | [diff] [blame^] | 59 | #endif |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 60 | |
| 61 | before_c_entry: |
| 62 | post_code(0x29) |
| 63 | call bootblock_c_entry_bist |
| 64 | /* Never returns */ |
| 65 | .Lhlt: |
| 66 | post_code(POST_DEAD_CODE) |
| 67 | hlt |
| 68 | jmp .Lhlt |