/* * Copyright (C) 2006, Intel Corporation * * This file is part of the Linux-ready Firmware Developer Kit * * This program file is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation;version 2.1 of the License. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program in a file named COPYING; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ #define _GNU_SOURCE /* * Author: Shaohua Li */ #include #include #include #include #include #include #include #include #include "../biostest.h" static unsigned long get_bios_ebda(void) { int fd; unsigned short tmp; fd = open("/dev/mem", O_RDONLY); if (fd <= 0) return 0; /* * there is a real-mode segmented pointer pointing to the * 4K EBDA area at 0x40E. */ if (lseek(fd, 0x40E, SEEK_SET) == -1) goto error; if (read(fd, &tmp, sizeof(unsigned short)) <= 0) goto error; close(fd); return ((unsigned long)tmp) << 4; error: close(fd); return 0; } /* run_test() -- This plugin validates if the EBDA region * is correctly reserved and mapped in the * the E820 table. */ void run_test(void) { unsigned long addr = get_bios_ebda(); char buf[4096]; if (addr == 0) return; start_test("ebda", "EBDA region", "This test validates if the EBDA region is mapped and reserved in the E820 table."); if (!e820_is_reserved(addr)) { sprintf(buf, "E820: EBDA region at 0x%lx is not reserved in the E820 table", addr); report_result("ebda", WARN, buf, NULL, NULL); } else { sprintf(buf, "EBDA region is correctly reserved in the E820 table."); report_result("ebda", PASS, buf, NULL, NULL); } finish_test("ebda"); }