1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
// SPDX-License-Identifier: GPL-2.0
#define boot_fmt(fmt) "alt: " fmt
#include "boot.h"
#define a_debug boot_debug
#include "../kernel/alternative.c"
static void alt_debug_all(int type)
{
int i;
switch (type) {
case ALT_TYPE_FACILITY:
for (i = 0; i < ARRAY_SIZE(alt_debug.facilities); i++)
alt_debug.facilities[i] = -1UL;
break;
case ALT_TYPE_FEATURE:
for (i = 0; i < ARRAY_SIZE(alt_debug.mfeatures); i++)
alt_debug.mfeatures[i] = -1UL;
break;
case ALT_TYPE_SPEC:
alt_debug.spec = 1;
break;
}
}
static void alt_debug_modify(int type, unsigned int nr, bool clear)
{
switch (type) {
case ALT_TYPE_FACILITY:
if (clear)
__clear_facility(nr, alt_debug.facilities);
else
__set_facility(nr, alt_debug.facilities);
break;
case ALT_TYPE_FEATURE:
if (clear)
__clear_machine_feature(nr, alt_debug.mfeatures);
else
__set_machine_feature(nr, alt_debug.mfeatures);
break;
}
}
static char *alt_debug_parse(int type, char *str)
{
unsigned long val, endval;
char *endp;
bool clear;
int i;
if (*str == ':') {
str++;
} else {
alt_debug_all(type);
return str;
}
clear = false;
if (*str == '!') {
alt_debug_all(type);
clear = true;
str++;
}
while (*str) {
val = simple_strtoull(str, &endp, 0);
if (str == endp)
break;
str = endp;
if (*str == '-') {
str++;
endval = simple_strtoull(str, &endp, 0);
if (str == endp)
break;
str = endp;
while (val <= endval) {
alt_debug_modify(type, val, clear);
val++;
}
} else {
alt_debug_modify(type, val, clear);
}
if (*str != ',')
break;
str++;
}
return str;
}
/*
* Use debug-alternative command line parameter for debugging:
* "debug-alternative"
* -> print debug message for every single alternative
*
* "debug-alternative=0;2"
* -> print debug message for all alternatives with type 0 and 2
*
* "debug-alternative=0:0-7"
* -> print debug message for all alternatives with type 0 and with
* facility numbers within the range of 0-7
* (if type 0 is ALT_TYPE_FACILITY)
*
* "debug-alternative=0:!8;1"
* -> print debug message for all alternatives with type 0, for all
* facility number, except facility 8, and in addition print all
* alternatives with type 1
*/
void alt_debug_setup(char *str)
{
unsigned long type;
char *endp;
int i;
if (!str) {
alt_debug_all(ALT_TYPE_FACILITY);
alt_debug_all(ALT_TYPE_FEATURE);
alt_debug_all(ALT_TYPE_SPEC);
return;
}
while (*str) {
type = simple_strtoull(str, &endp, 0);
if (str == endp)
break;
str = endp;
switch (type) {
case ALT_TYPE_FACILITY:
case ALT_TYPE_FEATURE:
str = alt_debug_parse(type, str);
break;
case ALT_TYPE_SPEC:
alt_debug_all(ALT_TYPE_SPEC);
break;
}
if (*str != ';')
break;
str++;
}
}
|