blob: 9bb0c7972719546dc8f0a574b1d8f9305ee63ded [file] [log] [blame]
Martin Roth9b1b3352016-02-24 12:27:06 -08001/* config.c - MemTest-86 Version 3.4
2 *
3 * Released under version 2 of the Gnu Public License.
4 * By Chris Brady
5 * ----------------------------------------------------
6 * MemTest86+ V5.00 Specific code (GPL V2.0)
7 * By Samuel DEMEULEMEESTER, sdemeule@memtest.org
8 * http://www.x86-secret.com - http://www.memtest.org
9 */
10#include "test.h"
11#include "screen_buffer.h"
12#include "dmi.h"
13
14extern int bail, beepmode;
15extern struct tseq tseq[];
16extern short e820_nr;
17void performance();
18extern volatile short cpu_mode;
19extern volatile int test;
20extern void find_chunks();
Ben Gardner529d6142016-03-08 09:25:46 -060021extern volatile short start_seq;
Martin Roth9b1b3352016-02-24 12:27:06 -080022extern short restart_flag;
23extern short onepass;
24extern short btflag;
25
26extern void get_list(int x, int y, int len, char *buf);
27
Martin Roth5bb29b22016-03-27 20:51:17 -060028/* declared in test.h */
29char pop_save_buffer_1[2][POP_H][POP_W];
30char pop_save_buffer_2[2][POP2_H][POP2_W];
Martin Roth9b1b3352016-02-24 12:27:06 -080031
Martin Roth69593432016-03-27 19:46:03 -060032void get_config(void)
Martin Roth9b1b3352016-02-24 12:27:06 -080033{
34 int flag = 0, sflag = 0, i, j, k, n, m, prt = 0;
Ben Gardner529d6142016-03-08 09:25:46 -060035 int reprint_screen = 0;
36 char cp[64];
Martin Roth9b1b3352016-02-24 12:27:06 -080037 ulong page;
38
Martin Roth5bb29b22016-03-27 20:51:17 -060039 popup(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -080040 wait_keyup();
Ben Gardner529d6142016-03-08 09:25:46 -060041 while (!flag) {
Martin Roth9b1b3352016-02-24 12:27:06 -080042 cprint(POP_Y+1, POP_X+2, "Settings:");
43 cprint(POP_Y+3, POP_X+6, "(1) Test Selection");
44 cprint(POP_Y+4, POP_X+6, "(2) Address Range");
45 cprint(POP_Y+5, POP_X+6, "(3) Error Report Mode");
46 cprint(POP_Y+6, POP_X+6, "(4) Core Selection");
47 cprint(POP_Y+7, POP_X+6, "(5) Refresh Screen");
48 cprint(POP_Y+8, POP_X+6, "(6) Display DMI Data");
Piotr Król686a6732017-05-25 00:54:47 +020049#if !(CB_NOSPD)
Martin Roth9b1b3352016-02-24 12:27:06 -080050 cprint(POP_Y+9, POP_X+6, "(7) Display SPD Data");
Piotr Król686a6732017-05-25 00:54:47 +020051#endif
Ben Gardner529d6142016-03-08 09:25:46 -060052 cprint(POP_Y+11, POP_X+6, "(0) Continue");
Martin Roth9b1b3352016-02-24 12:27:06 -080053
54 /* Wait for key release */
55 /* Fooey! This nuts'es up the serial input. */
56 sflag = 0;
Ben Gardner529d6142016-03-08 09:25:46 -060057 switch (get_key()) {
Martin Roth9b1b3352016-02-24 12:27:06 -080058 case 2:
59 /* 1 - Test Selection */
Martin Roth5bb29b22016-03-27 20:51:17 -060060 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -080061 cprint(POP_Y+1, POP_X+2, "Test Selection:");
62 cprint(POP_Y+3, POP_X+6, "(1) Default Tests");
63 cprint(POP_Y+4, POP_X+6, "(2) Skip Current Test");
64 cprint(POP_Y+5, POP_X+6, "(3) Select Test");
Ben Gardner529d6142016-03-08 09:25:46 -060065 cprint(POP_Y+6, POP_X+6, "(4) Enter Test List");
Martin Roth9b1b3352016-02-24 12:27:06 -080066 cprint(POP_Y+7, POP_X+6, "(0) Cancel");
67 if (v->testsel < 0) {
68 cprint(POP_Y+3, POP_X+5, ">");
69 } else {
70 cprint(POP_Y+5, POP_X+5, ">");
71 }
72 wait_keyup();
73 while (!sflag) {
Ben Gardner529d6142016-03-08 09:25:46 -060074 switch (get_key()) {
Martin Roth9b1b3352016-02-24 12:27:06 -080075 case 2:
76 /* Default - All tests */
77 i = 0;
78 while (tseq[i].cpu_sel) {
Ben Gardner529d6142016-03-08 09:25:46 -060079 tseq[i].sel = 1;
80 i++;
Martin Roth9b1b3352016-02-24 12:27:06 -080081 }
82 find_ticks_for_pass();
83 sflag++;
84 break;
85 case 3:
86 /* Skip test */
87 bail++;
88 sflag++;
89 break;
90 case 4:
91 /* Select test */
Martin Roth5bb29b22016-03-27 20:51:17 -060092 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -080093 cprint(POP_Y+1, POP_X+3,
Ben Gardner529d6142016-03-08 09:25:46 -060094 "Test Selection:");
Martin Roth9b1b3352016-02-24 12:27:06 -080095 cprint(POP_Y+4, POP_X+5,
Ben Gardner529d6142016-03-08 09:25:46 -060096 "Test Number [1-11]: ");
Martin Roth9b1b3352016-02-24 12:27:06 -080097 n = getval(POP_Y+4, POP_X+24, 0) - 1;
Ben Gardner529d6142016-03-08 09:25:46 -060098 if (n <= 11) {
99 /* Deselect all tests */
100 i = 0;
101 while (tseq[i].cpu_sel) {
102 tseq[i].sel = 0;
103 i++;
Martin Roth9b1b3352016-02-24 12:27:06 -0800104 }
Ben Gardner529d6142016-03-08 09:25:46 -0600105 /* Now set the selection */
106 tseq[n].sel = 1;
107 v->pass = -1;
108 test = n;
109 find_ticks_for_pass();
110 sflag++;
111 bail++;
112 }
Martin Roth9b1b3352016-02-24 12:27:06 -0800113 break;
114 case 5:
115 /* Enter a test list */
Martin Roth5bb29b22016-03-27 20:51:17 -0600116 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800117 cprint(POP_Y+1, POP_X+3,
Ben Gardner529d6142016-03-08 09:25:46 -0600118 "Enter a comma separated list");
Martin Roth9b1b3352016-02-24 12:27:06 -0800119 cprint(POP_Y+2, POP_X+3,
Ben Gardner529d6142016-03-08 09:25:46 -0600120 "of tests to execute:");
Martin Roth9b1b3352016-02-24 12:27:06 -0800121 cprint(POP_Y+5, POP_X+5, "List: ");
122 /* Deselect all tests */
123 k = 0;
124 while (tseq[k].cpu_sel) {
Ben Gardner529d6142016-03-08 09:25:46 -0600125 tseq[k].sel = 0;
126 k++;
Martin Roth9b1b3352016-02-24 12:27:06 -0800127 }
128
129 /* Get the list */
130 for (i=0; i<64; i++) cp[i] = 0;
131 get_list(POP_Y+5, POP_X+10, 64, cp);
132
133 /* Now enable all of the tests in the
134 * list */
135 i = j = m = 0;
136 while (1) {
Ben Gardner529d6142016-03-08 09:25:46 -0600137 if (isdigit(cp[i])) {
138 n = cp[i]-'0';
139 j = j*10 + n;
140 i++;
141 if (cp[i] == ',' || cp[i] == 0) {
142 if (j < k) {
143 tseq[j].sel = 1;
144 m++;
145 }
146 if (cp[i] == 0) break;
147 j = 0;
148 i++;
149 }
Martin Roth9b1b3352016-02-24 12:27:06 -0800150 }
Martin Roth9b1b3352016-02-24 12:27:06 -0800151 }
152
153 /* If we didn't select at least one
154 * test turn them all back on */
155 if (m == 0) {
Ben Gardner529d6142016-03-08 09:25:46 -0600156 k = 0;
157 while (tseq[k].cpu_sel) {
158 tseq[k].sel = 1;
159 k++;
160 }
Martin Roth9b1b3352016-02-24 12:27:06 -0800161 }
162 v->pass = -1;
163 test = n;
164 find_ticks_for_pass();
165 sflag++;
Ben Gardner529d6142016-03-08 09:25:46 -0600166 bail++;
Martin Roth9b1b3352016-02-24 12:27:06 -0800167 break;
168 case 11:
169 case 57:
170 sflag++;
171 break;
172 }
173 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600174 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800175 break;
176 case 3:
177 /* 2 - Address Range */
Martin Roth5bb29b22016-03-27 20:51:17 -0600178 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800179 cprint(POP_Y+1, POP_X+2, "Test Address Range:");
180 cprint(POP_Y+3, POP_X+6, "(1) Set Lower Limit");
181 cprint(POP_Y+4, POP_X+6, "(2) Set Upper Limit");
182 cprint(POP_Y+5, POP_X+6, "(3) Test All Memory");
183 cprint(POP_Y+6, POP_X+6, "(0) Cancel");
184 wait_keyup();
185 while (!sflag) {
Ben Gardner529d6142016-03-08 09:25:46 -0600186 switch (get_key()) {
Martin Roth9b1b3352016-02-24 12:27:06 -0800187 case 2:
188 /* Lower Limit */
Martin Roth5bb29b22016-03-27 20:51:17 -0600189 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800190 cprint(POP_Y+2, POP_X+4,
Ben Gardner529d6142016-03-08 09:25:46 -0600191 "Lower Limit: ");
Martin Roth9b1b3352016-02-24 12:27:06 -0800192 cprint(POP_Y+4, POP_X+4,
Ben Gardner529d6142016-03-08 09:25:46 -0600193 "Current: ");
Martin Roth9b1b3352016-02-24 12:27:06 -0800194 aprint(POP_Y+4, POP_X+13, v->plim_lower);
195 cprint(POP_Y+6, POP_X+4,
Ben Gardner529d6142016-03-08 09:25:46 -0600196 "New: ");
Martin Roth9b1b3352016-02-24 12:27:06 -0800197 page = getval(POP_Y+6, POP_X+9, 12);
198 if (page + 1 <= v->plim_upper) {
199 v->plim_lower = page;
200 test--;
201 bail++;
202 }
203 adj_mem();
204 find_chunks();
205 find_ticks_for_pass();
206 sflag++;
207 break;
208 case 3:
209 /* Upper Limit */
Martin Roth5bb29b22016-03-27 20:51:17 -0600210 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800211 cprint(POP_Y+2, POP_X+4,
Ben Gardner529d6142016-03-08 09:25:46 -0600212 "Upper Limit: ");
Martin Roth9b1b3352016-02-24 12:27:06 -0800213 cprint(POP_Y+4, POP_X+4,
Ben Gardner529d6142016-03-08 09:25:46 -0600214 "Current: ");
Martin Roth9b1b3352016-02-24 12:27:06 -0800215 aprint(POP_Y+4, POP_X+13, v->plim_upper);
216 cprint(POP_Y+6, POP_X+4,
Ben Gardner529d6142016-03-08 09:25:46 -0600217 "New: ");
Martin Roth9b1b3352016-02-24 12:27:06 -0800218 page = getval(POP_Y+6, POP_X+9, 12);
Ben Gardner529d6142016-03-08 09:25:46 -0600219 if (page - 1 >= v->plim_lower) {
Martin Roth9b1b3352016-02-24 12:27:06 -0800220 v->plim_upper = page;
221 bail++;
222 test--;
223 }
224 adj_mem();
225 find_chunks();
226 find_ticks_for_pass();
227 sflag++;
228 break;
229 case 4:
230 /* All of memory */
231 v->plim_lower = 0;
232 v->plim_upper =
233 v->pmap[v->msegs - 1].end;
234 test--;
235 bail++;
236 adj_mem();
237 find_chunks();
238 find_ticks_for_pass();
239 sflag++;
240 break;
241 case 11:
242 case 57:
243 /* 0/CR - Continue */
244 sflag++;
245 break;
246 }
247 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600248 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800249 break;
250 case 4:
251 /* Error Mode */
Martin Roth5bb29b22016-03-27 20:51:17 -0600252 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800253 cprint(POP_Y+1, POP_X+2, "Printing Mode:");
254 cprint(POP_Y+3, POP_X+6, "(1) Error Summary");
255 cprint(POP_Y+4, POP_X+6, "(2) Individual Errors");
256 cprint(POP_Y+5, POP_X+6, "(3) BadRAM Patterns");
257 cprint(POP_Y+6, POP_X+6, "(4) Error Counts Only");
258 cprint(POP_Y+7, POP_X+6, "(5) Beep on Error");
259 cprint(POP_Y+8, POP_X+6, "(0) Cancel");
260 cprint(POP_Y+3+v->printmode, POP_X+5, ">");
261 if (beepmode) { cprint(POP_Y+7, POP_X+5, ">"); }
262 wait_keyup();
263 while (!sflag) {
Ben Gardner529d6142016-03-08 09:25:46 -0600264 switch (get_key()) {
Martin Roth9b1b3352016-02-24 12:27:06 -0800265 case 2:
266 /* Error Summary */
267 v->printmode=PRINTMODE_SUMMARY;
268 v->erri.eadr = 0;
269 v->erri.hdr_flag = 0;
270 sflag++;
271 break;
272 case 3:
273 /* Separate Addresses */
274 v->printmode=PRINTMODE_ADDRESSES;
275 v->erri.eadr = 0;
276 v->erri.hdr_flag = 0;
277 v->msg_line = LINE_SCROLL-1;
278 sflag++;
279 break;
280 case 4:
281 /* BadRAM Patterns */
282 v->printmode=PRINTMODE_PATTERNS;
283 v->erri.hdr_flag = 0;
284 sflag++;
285 prt++;
286 break;
287 case 5:
288 /* Error Counts Only */
289 v->printmode=PRINTMODE_NONE;
290 v->erri.hdr_flag = 0;
291 sflag++;
292 break;
293 case 6:
294 /* Set Beep On Error mode */
295 beepmode = !beepmode;
296 sflag++;
Martin Roth4dcd13d2016-02-24 13:53:07 -0800297 break;
Martin Roth9b1b3352016-02-24 12:27:06 -0800298 case 11:
299 case 57:
300 /* 0/CR - Continue */
301 sflag++;
302 break;
303 }
304 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600305 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800306 break;
307 case 5:
Ben Gardner529d6142016-03-08 09:25:46 -0600308 /* CPU Mode */
309 reprint_screen = 1;
Martin Roth5bb29b22016-03-27 20:51:17 -0600310 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800311 cprint(POP_Y+1, POP_X+2, "CPU Selection Mode:");
312 cprint(POP_Y+3, POP_X+6, "(1) Parallel (All)");
313 cprint(POP_Y+4, POP_X+6, "(2) Round Robin (RRb)");
314 cprint(POP_Y+5, POP_X+6, "(3) Sequential (Seq)");
315 cprint(POP_Y+6, POP_X+6, "(0) Cancel");
316 cprint(POP_Y+2+cpu_mode, POP_X+5, ">");
317 wait_keyup();
Ben Gardner529d6142016-03-08 09:25:46 -0600318 while (!sflag) {
319 switch (get_key()) {
Martin Roth9b1b3352016-02-24 12:27:06 -0800320 case 2:
321 if (cpu_mode != CPM_ALL) bail++;
322 cpu_mode = CPM_ALL;
323 sflag++;
Martin Roth5bb29b22016-03-27 20:51:17 -0600324 popdown(POP_SAVE_BUFFER_1);
Ben Gardner529d6142016-03-08 09:25:46 -0600325 cprint(9, 34, "All");
Martin Roth5bb29b22016-03-27 20:51:17 -0600326 popup(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800327 break;
328 case 3:
329 if (cpu_mode != CPM_RROBIN) bail++;
330 cpu_mode = CPM_RROBIN;
331 sflag++;
Martin Roth5bb29b22016-03-27 20:51:17 -0600332 popdown(POP_SAVE_BUFFER_1);
Ben Gardner529d6142016-03-08 09:25:46 -0600333 cprint(9, 34, "RRb");
Martin Roth5bb29b22016-03-27 20:51:17 -0600334 popup(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800335 break;
336 case 4:
337 if (cpu_mode != CPM_SEQ) bail++;
338 cpu_mode = CPM_SEQ;
339 sflag++;
Martin Roth5bb29b22016-03-27 20:51:17 -0600340 popdown(POP_SAVE_BUFFER_1);
Ben Gardner529d6142016-03-08 09:25:46 -0600341 cprint(9, 34, "Seq");
Martin Roth5bb29b22016-03-27 20:51:17 -0600342 popup(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800343 break;
344 case 11:
345 case 57:
346 /* 0/CR - Continue */
347 sflag++;
348 break;
349 }
350 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600351 popclear(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800352 break;
353 case 6:
354 reprint_screen = 1;
355 flag++;
356 break;
357 case 7:
358 /* Display DMI Memory Info */
Martin Roth5bb29b22016-03-27 20:51:17 -0600359 popup(POP_SAVE_BUFFER_2);
Ben Gardner529d6142016-03-08 09:25:46 -0600360 print_dmi_info();
Martin Roth5bb29b22016-03-27 20:51:17 -0600361 popdown(POP_SAVE_BUFFER_2);
Martin Roth9b1b3352016-02-24 12:27:06 -0800362 break;
363 case 8:
Martin Roth4dcd13d2016-02-24 13:53:07 -0800364 /* Display SPD Data */
Martin Roth5bb29b22016-03-27 20:51:17 -0600365 popup(POP_SAVE_BUFFER_2);
Martin Roth9b1b3352016-02-24 12:27:06 -0800366 show_spd();
Martin Roth5bb29b22016-03-27 20:51:17 -0600367 popdown(POP_SAVE_BUFFER_2);
Martin Roth9b1b3352016-02-24 12:27:06 -0800368 sflag++;
369 break;
370 case 11:
371 case 57:
372 case 28:
373 /* 0/CR/SP - Continue */
374 flag++;
375 break;
376 }
377 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600378 popdown(POP_SAVE_BUFFER_1);
Martin Roth9b1b3352016-02-24 12:27:06 -0800379 if (prt) {
380 printpatn();
381 }
Ben Gardner529d6142016-03-08 09:25:46 -0600382 if (reprint_screen) {
383 tty_print_screen();
384 }
Martin Roth9b1b3352016-02-24 12:27:06 -0800385}
386
Martin Roth5bb29b22016-03-27 20:51:17 -0600387void popup(int pop_x, int pop_y, int pop_h, int pop_w, char pop_save_buffer[2][pop_h][pop_w])
Martin Roth9b1b3352016-02-24 12:27:06 -0800388{
389 int i, j;
390 char *pp;
Martin Roth4dcd13d2016-02-24 13:53:07 -0800391
Martin Roth5bb29b22016-03-27 20:51:17 -0600392 for (i = pop_y; i < pop_y + pop_h; i++) {
393 for (j = pop_x; j < pop_x + pop_w; j++) {
394 /* Point to the write position in the screen */
Martin Roth9b1b3352016-02-24 12:27:06 -0800395 pp = (char *)(SCREEN_ADR + (i * 160) + (j * 2));
Martin Roth5bb29b22016-03-27 20:51:17 -0600396
397 /* pp and get_scrn_buf(i,j) should be equal here
398 * except on board that don't have screen (e.g. only serial port)
399 * that's why we save the screen buffer:
400 * save screen buffer */
401 pop_save_buffer[0][i - pop_y][j - pop_x] = get_scrn_buf(i, j);
402 *pp = ' '; /* Clear screen */
403 set_scrn_buf(i, j, ' '); /* Clear screen buffer */
Martin Roth9b1b3352016-02-24 12:27:06 -0800404 pp++;
Martin Roth5bb29b22016-03-27 20:51:17 -0600405 pop_save_buffer[1][i - pop_y][j - pop_x] = *pp; /* Save screen background color */
406 *pp = 0x07; /* Change screen Background to black */
Martin Roth9b1b3352016-02-24 12:27:06 -0800407 }
408 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600409 /* print the screen buffer in the serial console */
410 tty_print_region(pop_y, pop_x, pop_y+pop_h, pop_x+pop_w);
Martin Roth9b1b3352016-02-24 12:27:06 -0800411}
412
Martin Roth5bb29b22016-03-27 20:51:17 -0600413void popdown(int pop_x, int pop_y, int pop_h, int pop_w, char pop_save_buffer[2][pop_h][pop_w])
Martin Roth9b1b3352016-02-24 12:27:06 -0800414{
415 int i, j;
416 char *pp;
Martin Roth4dcd13d2016-02-24 13:53:07 -0800417
Martin Roth5bb29b22016-03-27 20:51:17 -0600418 for (i = pop_y; i < pop_y + pop_h; i++) {
419 for (j = pop_x; j < pop_x + pop_w; j++) {
420 /* Point to the write position in the screen */
Martin Roth9b1b3352016-02-24 12:27:06 -0800421 pp = (char *)(SCREEN_ADR + (i * 160) + (j * 2));
Martin Roth5bb29b22016-03-27 20:51:17 -0600422 *pp = pop_save_buffer[0][i-pop_y][j-pop_x]; /* Restore screen */
423 set_scrn_buf(i, j, pop_save_buffer[0][i - pop_y][j - pop_x]); /* Restore the screen buffer*/
Martin Roth9b1b3352016-02-24 12:27:06 -0800424 pp++;
Martin Roth5bb29b22016-03-27 20:51:17 -0600425 *pp = pop_save_buffer[1][i - pop_y][j - pop_x]; /* Restore screen color */
Martin Roth9b1b3352016-02-24 12:27:06 -0800426 }
427 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600428 /* print the screen buffer in the serial console */
429 tty_print_region(pop_y, pop_x, pop_y+pop_h, pop_x+pop_w);
Martin Roth9b1b3352016-02-24 12:27:06 -0800430}
431
Martin Roth5bb29b22016-03-27 20:51:17 -0600432void popclear(int pop_x, int pop_y, int pop_h, int pop_w, char pop_save_buffer[2][pop_h][pop_w])
Martin Roth9b1b3352016-02-24 12:27:06 -0800433{
434 int i, j;
435 char *pp;
Martin Roth4dcd13d2016-02-24 13:53:07 -0800436
Martin Roth5bb29b22016-03-27 20:51:17 -0600437 for (i = pop_y; i < pop_y + pop_h; i++) {
438 for (j =pop_x; j < pop_x + pop_w; j++) {
439 /* Point to the write position in the screen */
Martin Roth9b1b3352016-02-24 12:27:06 -0800440 pp = (char *)(SCREEN_ADR + (i * 160) + (j * 2));
Martin Roth5bb29b22016-03-27 20:51:17 -0600441 *pp = ' '; /* Clear screen */
442 set_scrn_buf(i, j, ' '); /* Clear screen buffer */
Martin Roth9b1b3352016-02-24 12:27:06 -0800443 pp++;
444 }
445 }
Martin Roth5bb29b22016-03-27 20:51:17 -0600446 /* print the screen buffer in the serial console */
447 tty_print_region(pop_y, pop_x, pop_y+pop_h, pop_x+pop_w);
Martin Roth9b1b3352016-02-24 12:27:06 -0800448}
449
Martin Roth9b1b3352016-02-24 12:27:06 -0800450void adj_mem(void)
451{
452 int i;
453
454 v->selected_pages = 0;
455 for (i=0; i< v->msegs; i++) {
456 /* Segment inside limits ? */
457 if (v->pmap[i].start >= v->plim_lower &&
Ben Gardner529d6142016-03-08 09:25:46 -0600458 v->pmap[i].end <= v->plim_upper) {
Martin Roth9b1b3352016-02-24 12:27:06 -0800459 v->selected_pages += (v->pmap[i].end - v->pmap[i].start);
460 continue;
461 }
462 /* Segment starts below limit? */
463 if (v->pmap[i].start < v->plim_lower) {
464 /* Also ends below limit? */
465 if (v->pmap[i].end < v->plim_lower) {
466 continue;
467 }
Martin Roth4dcd13d2016-02-24 13:53:07 -0800468
Martin Roth9b1b3352016-02-24 12:27:06 -0800469 /* Ends past upper limit? */
470 if (v->pmap[i].end > v->plim_upper) {
Martin Roth4dcd13d2016-02-24 13:53:07 -0800471 v->selected_pages +=
Martin Roth9b1b3352016-02-24 12:27:06 -0800472 v->plim_upper - v->plim_lower;
473 } else {
474 /* Straddles lower limit */
Martin Roth4dcd13d2016-02-24 13:53:07 -0800475 v->selected_pages +=
Martin Roth9b1b3352016-02-24 12:27:06 -0800476 (v->pmap[i].end - v->plim_lower);
477 }
478 continue;
479 }
480 /* Segment ends above limit? */
481 if (v->pmap[i].end > v->plim_upper) {
482 /* Also starts above limit? */
483 if (v->pmap[i].start > v->plim_upper) {
484 continue;
485 }
486 /* Straddles upper limit */
Martin Roth4dcd13d2016-02-24 13:53:07 -0800487 v->selected_pages +=
Martin Roth9b1b3352016-02-24 12:27:06 -0800488 (v->plim_upper - v->pmap[i].start);
489 }
490 }
491}