Debian Codegraph @

src/northbridge/intel/haswell/native_raminit/ranges.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 #ifndef HASWELL_RAMINIT_RANGES_H
4 #define HASWELL_RAMINIT_RANGES_H
5
6 #include <types.h>
7
8 /*
9 * Many algorithms shmoo some parameter to determine the largest passing
10 * range. Provide a common implementation to avoid redundant boilerplate.
11 */
12 struct passing_range {
13 int32_t start;
14 int32_t end;
15 };
16
17 /* Structure for linear parameters, such as roundtrip delays */
18 struct linear_train_data {
19 struct passing_range current;
20 struct passing_range largest;
21 };
22
23 /*
24 * Phase ranges are "circular": the first and last indices are contiguous.
25 * To correctly determine the largest passing range, one has to combine
26 * the initial range and the current range when processing the last index.
27 */
28 struct phase_train_data {
29 struct passing_range initial;
30 struct passing_range current;
31 struct passing_range largest;
32 };
33
34 static inline int32_t range_width(const struct passing_range range)
35 {
36 return range.end - range.start;
37 }
38
39 static inline int32_t range_center(const struct passing_range range)
40 {
41 return range.start + range_width(range) / 2;
42 }
43
44 void linear_record_pass(
45 struct linear_train_data *data,
46 bool pass,
47 int32_t value,
48 int32_t start,
49 int32_t step);
50
51 void phase_record_pass(
52 struct phase_train_data *data,
53 bool pass,
54 int32_t value,
55 int32_t start,
56 int32_t step);
57
58 void phase_append_initial_to_current(
59 struct phase_train_data *data,
60 int32_t start,
61 int32_t step);
62
63 void phase_append_current_to_initial(
64 struct phase_train_data *data,
65 int32_t start,
66 int32_t step);
67
68 #endif