MCPcopy Create free account
hub / github.com/coreboot/coreboot / timestamps_module_init

Function timestamps_module_init

payloads/coreinfo/timestamps_module.c:132–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132static int timestamps_module_init(void)
133{
134 /* Make sure that lib_sysinfo is initialized */
135 int ret = lib_get_sysinfo();
136
137 if (ret)
138 return -1;
139
140 struct timestamp_table *timestamps = phys_to_virt(lib_sysinfo.tstamp_table);
141
142 if (timestamps == NULL)
143 return -1;
144
145 /* Extract timestamps information */
146 u64 base_time = timestamps->base_time;
147 u16 max_entries = timestamps->max_entries;
148 u32 n_entries = timestamps->num_entries;
149
150 timestamp_set_tick_freq(timestamps->tick_freq_mhz);
151
152 char *buffer;
153 u32 buff_cur = 0;
154 uint64_t prev_stamp;
155 uint64_t total_time;
156
157 /* Allocate a buffer big enough to contain all of the possible
158 * entries plus the other information (number entries, total time). */
159 buffer = malloc((max_entries + 4) * SCREEN_X * sizeof(char));
160
161 if (buffer == NULL)
162 return -3;
163
164 /* Write the content */
165 buff_cur += snprintf(buffer, SCREEN_X, "%d entries total:\n\n",
166 n_entries);
167
168 prev_stamp = 0;
169 timestamp_print_entry(buffer, SCREEN_X, &buff_cur, 0, base_time,
170 prev_stamp);
171 prev_stamp = base_time;
172
173 total_time = 0;
174 for (u32 i = 0; i < n_entries; i++) {
175 uint64_t stamp;
176 const struct timestamp_entry *tse = &timestamps->entries[i];
177
178 stamp = tse->entry_stamp + base_time;
179 total_time += timestamp_print_entry(buffer, SCREEN_X,
180 &buff_cur, tse->entry_id, stamp, prev_stamp);
181 prev_stamp = stamp;
182 }
183
184 buff_cur += snprintf(buffer + buff_cur, SCREEN_X, "\nTotal Time: ");
185 buff_cur += snprintf(buffer + buff_cur, SCREEN_X, "%llu", total_time);
186 buff_cur += snprintf(buffer + buff_cur, SCREEN_X, "\n");
187
188 /* Calculate how many characters will be displayed on screen */
189 u32 chars_count = calculate_chars_count(buffer, buff_cur + 1,

Callers

nothing calls this directly

Calls 8

timestamp_set_tick_freqFunction · 0.70
timestamp_print_entryFunction · 0.70
calculate_chars_countFunction · 0.70
lib_get_sysinfoFunction · 0.50
mallocFunction · 0.50
snprintfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected