static int version_test1(fwts_framework *fw) { char *str; fwts_release *release; release = fwts_release_get(); if (release) { bool not_ubuntu = strcmp(release->distributor, "Ubuntu"); fwts_release_free(release); /* Following is Ubuntu specific, so don't fail */ if (not_ubuntu) { fwts_skipped(fw, "Information not available with this kernel."); return FWTS_OK; } } if ((str = fwts_get("/proc/version_signature")) == NULL) fwts_skipped(fw, "Cannot get version signature info from " "/proc/version_signature"); else { fwts_chop_newline(str); fwts_log_info(fw, "Signature: %s", str); free(str); } fwts_infoonly(fw); return FWTS_OK; }
static int version_test4(fwts_framework *fw) { char *str; if (((str = fwts_get("/sys/module/acpi/parameters/acpica_version")) == NULL) && ((str = fwts_get("/proc/acpi/info")) == NULL)) fwts_log_info(fw, "Cannot get ACPI version info from " "/sys/module/acpi/parameters/acpica_version " "or /proc/acpi/info, system does not have ACPI."); else { fwts_chop_newline(str); fwts_log_info(fw, "ACPI Version: %s", str); free(str); } fwts_infoonly(fw); return FWTS_OK; }
static int version_test3(fwts_framework *fw) { char *str; if ((str = fwts_get("/proc/cmdline")) == NULL) fwts_log_info(fw, "Cannot get version info from /proc/cmdline"); else { fwts_chop_newline(str); fwts_log_info(fw, "Kernel boot command line: %s", str); free(str); } fwts_infoonly(fw); return FWTS_OK; }
static int crs_get_bios_date(fwts_framework *fw, int *day, int *mon, int *year) { char *date; static const char *bios_date = "/sys/class/dmi/id/bios_date"; *mon = *day = *year = 0; if ((date = fwts_get(bios_date)) == NULL) { fwts_log_error(fw, "Cannot read %s.", bios_date); return FWTS_ERROR; } /* Assume mon/day/year, but we only care about the year anyway */ sscanf(date, "%d/%d/%d", mon, day, year); free(date); return FWTS_OK; }
/* * fwts_button_match_state_proc() * find matching button state and keep count of matching * any non-matching states found, via proc iterface */ static int fwts_button_match_state_proc( const int button, int *matched, int *not_matched) { DIR *dir; struct dirent *entry; char *acpi_button_lid = FWTS_PROC_ACPI_BUTTON "/lid"; char *acpi_button_power = FWTS_PROC_ACPI_BUTTON "/power"; char *button_dir; char *field; char *match; switch (button) { case FWTS_BUTTON_LID_ANY: button_dir = acpi_button_lid; field = "state"; match = ""; break; case FWTS_BUTTON_LID_OPENED: button_dir = acpi_button_lid; field = "state"; match = "open"; break; case FWTS_BUTTON_LID_CLOSED: button_dir = acpi_button_lid; field = "state"; match = "close"; break; case FWTS_BUTTON_POWER_EXISTS: button_dir = acpi_button_power; field = "info"; match = "Power Button"; break; default: return FWTS_ERROR; } if ((dir = opendir(button_dir)) == NULL) return FWTS_ERROR; do { entry = readdir(dir); if (entry && strlen(entry->d_name) > 2) { char path[PATH_MAX]; char *data; snprintf(path, sizeof(path), "%s/%s/%s", button_dir, entry->d_name, field); if ((data = fwts_get(path)) != NULL) { if (strstr(data, match)) (*matched)++; else (*not_matched)++; free(data); } } } while (entry); closedir(dir); return FWTS_OK; }
static int crs_test1(fwts_framework *fw) { fwts_list *klog; int day, mon, year; char *cmdline; if ((cmdline = fwts_get("/proc/cmdline")) == NULL) { fwts_log_error(fw, "Cannot read /proc/cmdline"); return FWTS_ERROR; } if (crs_get_bios_date(fw, &day, &mon, &year) != FWTS_OK) { fwts_log_error(fw, "Cannot determine age of BIOS."); free(cmdline); return FWTS_ERROR; } if ((klog = fwts_klog_read()) == NULL) { fwts_log_error(fw, "Cannot read kernel log."); free(cmdline); return FWTS_ERROR; } if (fwts_klog_regex_find(fw, klog, "PCI: Ignoring host bridge windows from ACPI;") > 0) { if (strstr(cmdline, "pci=nocrs") != NULL) { fwts_skipped(fw, "Kernel was booted with pci=nocrs, Ignoring host bridge windows _CRS settings from ACPI, skipping test."); } else { if (year == 0) { fwts_failed(fw, LOG_LEVEL_MEDIUM, "BIOSTooOld", "The kernel could not determine the BIOS age " "and has assumed that your BIOS is too old to correctly " "specify the host bridge MMIO aperture using _CRS."); fwts_log_advice(fw, "You can override this by booting with \"pci=use_crs\"."); } else if (year < 2008) { fwts_passed(fw, "The kernel has detected an old BIOS (%d/%d/%d) " "and has assumed that your BIOS is too old to correctly " "specify the host bridge MMIO aperture using _CRS.", mon, day, year); fwts_log_advice(fw, "You can override this by booting with \"pci=use_crs\"."); } else { fwts_failed(fw, LOG_LEVEL_MEDIUM, "HostBridgeWindows", "The kernel is ignoring host bridge windows from ACPI for some unknown reason. " "pci=nocrs has not been used as a boot parameter and the BIOS may be recent enough " "to support this (%d/%d/%d)", mon, day, year); } } } else if (fwts_klog_regex_find(fw, klog, "PCI: Using host bridge windows from ACPI;") > 0) { if (strstr(cmdline, "pci=use_crs") != NULL) { if (year == 0) { fwts_failed(fw, LOG_LEVEL_MEDIUM, "BIOSNoReleaseDate", "The BIOS does not seem to have release date, hence pci=use_crs was required."); } else if (year < 2008) { fwts_passed(fw, "The BIOS is relatively old (%d/%d/%d) and hence pci=use_crs was required to " "enable host bridge windows _CRS settings from ACPI.", mon, day, year); } else { fwts_failed(fw, LOG_LEVEL_LOW, "BIOSSupportBridgeWindows", "Kernel was booted with pci=use_crs but this may be uncessary as " "the BIOS is new enough to support automatic bridge windows configuring using _CRS from ACPI. " "However, the workaround may be necessary because _CRS is incorrect or not implemented in the " "DSDT."); } } else { fwts_passed(fw, "The kernel has detected a BIOS newer than the end of 2007 (%d/%d/%d) " "and has assumed that your BIOS can correctly " "specify the host bridge MMIO aperture using _CRS. If this does not work " "correctly you can override this by booting with \"pci=nocrs\".", mon, day, year); } } else { fwts_skipped(fw, "Cannot find host bridge message in kernel log, skipping test."); } fwts_list_free(klog, free); free(cmdline); return FWTS_OK; }