Debian Codegraph @

purgatory/arch/i386/purgatory-x86.c

raw
1 #include <stdint.h>
2 #include <purgatory.h>
3 #include "purgatory-x86.h"
4
5 /*
6 * CPU
7 * =============================================================================
8 */
9
10 void x86_setup_cpu(void)
11 {
12 #if 0
13 /* This code is only needed for old versions of the kexec kernel patch.
14 * While it is still a good idea doing this unconditionally breaks
15 * on older cpus that did not implemented cr4.
16 * So this code is disabled for now. If this is revisited
17 * I first need to detect cpuid support and then use cpuid
18 * to conditionally change newer cpu registers.
19 */
20 /* clear special bits in %cr4 */
21 asm volatile(
22 "movl %0, %%eax\n\t"
23 "movl %%eax, %%cr4\n\t"
24 : /* outputs */
25 : "r" (0)
26 );
27 #endif
28 }
29
30 uint8_t reset_vga = 0;
31 uint8_t legacy_timer = 0;
32 uint8_t legacy_pic = 0;
33 uint8_t panic_kernel = 0;
34 unsigned long jump_back_entry = 0;
35 char *cmdline_end = 0;
36
37 void setup_arch(void)
38 {
39 x86_setup_cpu();
40 if (reset_vga) x86_reset_vga();
41 if (legacy_pic) x86_setup_legacy_pic();
42 /* if (legacy_timer) x86_setup_legacy_timer(); */
43 }
44
45 static void x86_setup_jump_back_entry(void)
46 {
47 if (cmdline_end)
48 sprintf(cmdline_end, " kexec_jump_back_entry=0x%x",
49 jump_back_entry);
50 }
51
52 /* This function can be used to execute after the SHA256 verification. */
53 void post_verification_setup_arch(void)
54 {
55 if (panic_kernel) crashdump_backup_memory();
56 if (jump_back_entry) x86_setup_jump_back_entry();
57 }