2 * Copyright (c) 2014 The Chromium OS Authors.
4 * Part of this file is adapted from coreboot
5 * src/arch/x86/include/arch/cpu.h and
6 * src/arch/x86/lib/cpu.c
8 * SPDX-License-Identifier: GPL-2.0+
15 X86_VENDOR_INVALID = 0,
26 X86_VENDOR_ANY = 0xfe,
27 X86_VENDOR_UNKNOWN = 0xff
38 * Generic CPUID function
40 static inline struct cpuid_result cpuid(int op)
42 struct cpuid_result result;
58 * Generic Extended CPUID function
60 static inline struct cpuid_result cpuid_ext(int op, unsigned ecx)
62 struct cpuid_result result;
78 * CPUID functions returning a single datum
80 static inline unsigned int cpuid_eax(unsigned int op)
84 __asm__("mov %%ebx, %%edi;"
89 : "ecx", "edx", "edi");
93 static inline unsigned int cpuid_ebx(unsigned int op)
95 unsigned int eax, ebx;
97 __asm__("mov %%ebx, %%edi;"
101 : "=a" (eax), "=S" (ebx)
103 : "ecx", "edx", "edi");
107 static inline unsigned int cpuid_ecx(unsigned int op)
109 unsigned int eax, ecx;
111 __asm__("mov %%ebx, %%edi;"
114 : "=a" (eax), "=c" (ecx)
120 static inline unsigned int cpuid_edx(unsigned int op)
122 unsigned int eax, edx;
124 __asm__("mov %%ebx, %%edi;"
127 : "=a" (eax), "=d" (edx)
133 /* Standard macro to see if a specific flag is changeable */
134 static inline int flag_is_changeable_p(uint32_t flag)
149 : "=&r" (f1), "=&r" (f2)
151 return ((f1^f2) & flag) != 0;
155 * cpu_enable_paging_pae() - Enable PAE-paging
157 * @cr3: Value to set in cr3 (PDPT or PML4T)
159 void cpu_enable_paging_pae(ulong cr3);
162 * cpu_disable_paging_pae() - Disable paging and PAE
164 void cpu_disable_paging_pae(void);
167 * cpu_has_64bit() - Check if the CPU has 64-bit support
169 * @return 1 if this CPU supports long mode (64-bit), 0 if not
171 int cpu_has_64bit(void);
174 * cpu_vendor_name() - Get CPU vendor name
176 * @vendor: CPU vendor enumeration number
178 * @return: Address to hold the CPU vendor name string
180 const char *cpu_vendor_name(int vendor);
183 * fill_processor_name() - Get processor name
185 * @processor_name: Address to hold the processor name string
187 void fill_processor_name(char *processor_name);
190 * cpu_call64() - Jump to a 64-bit Linux kernel (internal function)
192 * The kernel is uncompressed and the 64-bit entry point is expected to be
195 * This function is used internally - see cpu_jump_to_64bit() for a more
198 * @pgtable: Address of 24KB area containing the page table
199 * @setup_base: Pointer to the setup.bin information for the kernel
200 * @target: Pointer to the start of the kernel image
202 void cpu_call64(ulong pgtable, ulong setup_base, ulong target);
205 * cpu_jump_to_64bit() - Jump to a 64-bit Linux kernel
207 * The kernel is uncompressed and the 64-bit entry point is expected to be
210 * @setup_base: Pointer to the setup.bin information for the kernel
211 * @target: Pointer to the start of the kernel image
213 int cpu_jump_to_64bit(ulong setup_base, ulong target);