blob: 9caa10e822172d0c091460af8dcf25d37cf2032e [file] [log] [blame]
Thomas Gleixnerd6910052019-05-22 09:51:29 +02001// SPDX-License-Identifier: GPL-2.0-or-later
H. Peter Anvinf0be6c62008-02-04 16:48:00 +01002/* ----------------------------------------------------------------------- *
3 *
4 * Copyright 2008 rPath, Inc. - All Rights Reserved
5 *
H. Peter Anvinf0be6c62008-02-04 16:48:00 +01006 * ----------------------------------------------------------------------- */
7
8/*
9 * This is a host program to preprocess the CPU strings into a
10 * compact format suitable for the setup code.
11 */
12
13#include <stdio.h>
14
David Howellsabbf1592012-10-02 18:01:26 +010015#include "../include/asm/required-features.h"
Dave Hansen381aa072014-09-11 14:15:13 -070016#include "../include/asm/disabled-features.h"
Borislav Petkovcd4d09e2016-01-26 22:12:04 +010017#include "../include/asm/cpufeatures.h"
H. Peter Anvin7414aa42008-08-27 17:56:44 -070018#include "../kernel/cpu/capflags.c"
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010019
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010020int main(void)
21{
H. Peter Anvin97fc0552008-09-16 15:09:26 -070022 int i, j;
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010023 const char *str;
24
Frans Pop3235dc32010-02-06 18:47:17 +010025 printf("static const char x86_cap_strs[] =\n");
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010026
H. Peter Anvin97fc0552008-09-16 15:09:26 -070027 for (i = 0; i < NCAPINTS; i++) {
28 for (j = 0; j < 32; j++) {
29 str = x86_cap_flags[i*32+j];
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010030
H. Peter Anvin97fc0552008-09-16 15:09:26 -070031 if (i == NCAPINTS-1 && j == 31) {
32 /* The last entry must be unconditional; this
33 also consumes the compiler-added null
34 character */
35 if (!str)
36 str = "";
37 printf("\t\"\\x%02x\\x%02x\"\"%s\"\n",
38 i, j, str);
39 } else if (str) {
40 printf("#if REQUIRED_MASK%d & (1 << %d)\n"
41 "\t\"\\x%02x\\x%02x\"\"%s\\0\"\n"
42 "#endif\n",
43 i, j, i, j, str);
44 }
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010045 }
46 }
47 printf("\t;\n");
48 return 0;
49}