linuxcheck.c
1 /* 2 * 3 * Copyright (C) 2018 Google Inc. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 */ 14 15 #include <libpayload-config.h> 16 #include <libpayload.h> 17 #include "linuxcheck.h" 18 19 extern struct console_output_driver *console_out; 20 extern struct sysinfo_t lib_sysinfo; 21 22 int main(void) 23 { 24 int ret, i; 25 26 buts("Greetings from linuxcheck, via hard-coded calls to serial functions.\n"); 27 if (console_out == NULL) 28 buts("Bad news: console_out is NULL\n"); 29 if (lib_sysinfo.serial == NULL) 30 buts("Bad news: lib_sysinfo.serial is NULL. Very little will work well.\n"); 31 ret = lib_get_sysinfo(); 32 if (ret) { 33 buts("lib_get_sysinfo() is non-zero"); 34 hex32(ret); 35 buts("\n"); 36 } 37 38 buts("The next line should be puts works\n"); 39 puts("puts works\n"); 40 buts("If you did not see puts works, then you have a console issues\n"); 41 buts("The next line should be 'printf works'\n"); 42 printf("printf works\n"); 43 buts(" ... if you did not see printf works, then you have a printf issue\n"); 44 printf("Number of memory ranges: %d\n", lib_sysinfo.n_memranges); 45 for (i = 0; i < lib_sysinfo.n_memranges; i++) { 46 printf("%d: base 0x%08llx size 0x%08llx type 0x%x\n", i, lib_sysinfo.memrange[i].base, lib_sysinfo.memrange[i].size, lib_sysinfo.memrange[i].type); 47 } 48 buts("Now we will halt. Bye"); 49 halt(); 50 return 0; 51 }