^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* ----------------------------------------------------------------------- *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright 2008 rPath, Inc. - All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * ----------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This is a host program to preprocess the CPU strings into a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * compact format suitable for the setup code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "../include/asm/required-features.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "../include/asm/disabled-features.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "../include/asm/cpufeatures.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "../include/asm/vmxfeatures.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "../kernel/cpu/capflags.c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int main(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) printf("static const char x86_cap_strs[] =\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) for (i = 0; i < NCAPINTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) for (j = 0; j < 32; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) str = x86_cap_flags[i*32+j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (i == NCAPINTS-1 && j == 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* The last entry must be unconditional; this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) also consumes the compiler-added null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) character */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (!str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) str = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) printf("\t\"\\x%02x\\x%02x\"\"%s\"\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) i, j, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } else if (str) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) printf("#if REQUIRED_MASK%d & (1 << %d)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) "\t\"\\x%02x\\x%02x\"\"%s\\0\"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) "#endif\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) i, j, i, j, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) printf("\t;\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }