H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame] | 1 | /* ----------------------------------------------------------------------- * |
| 2 | * |
| 3 | * Copyright 2008 rPath, Inc. - All Rights Reserved |
| 4 | * |
| 5 | * This file is part of the Linux kernel, and is made available under |
| 6 | * the terms of the GNU General Public License version 2 or (at your |
| 7 | * option) any later version; incorporated herein by reference. |
| 8 | * |
| 9 | * ----------------------------------------------------------------------- */ |
| 10 | |
| 11 | /* |
| 12 | * This is a host program to preprocess the CPU strings into a |
| 13 | * compact format suitable for the setup code. |
| 14 | */ |
| 15 | |
| 16 | #include <stdio.h> |
| 17 | |
H. Peter Anvin | 7414aa4 | 2008-08-27 17:56:44 -0700 | [diff] [blame] | 18 | #include "../kernel/cpu/capflags.c" |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame] | 19 | |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame] | 20 | int main(void) |
| 21 | { |
H. Peter Anvin | 97fc055 | 2008-09-16 15:09:26 -0700 | [diff] [blame] | 22 | int i, j; |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame] | 23 | const char *str; |
| 24 | |
| 25 | printf("static const char x86_cap_strs[] = \n"); |
| 26 | |
H. Peter Anvin | 97fc055 | 2008-09-16 15:09:26 -0700 | [diff] [blame] | 27 | for (i = 0; i < NCAPINTS; i++) { |
| 28 | for (j = 0; j < 32; j++) { |
| 29 | str = x86_cap_flags[i*32+j]; |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame] | 30 | |
H. Peter Anvin | 97fc055 | 2008-09-16 15:09:26 -0700 | [diff] [blame] | 31 | 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 Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame] | 45 | } |
| 46 | } |
| 47 | printf("\t;\n"); |
| 48 | return 0; |
| 49 | } |