/* * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include static char *errors[][2] = { // On cpu2, inject only total 0x1 error, interval 5 seconds // working on Montecito latest PAL. {"First test: inject only, corrected, data cache, hier-2, physical addr(assigned by tool code).", "rm *.log -f;./err_inject_tool -i -e 2,1,5,4101,95>/dev/null 2>&1;result=0;result=`grep successful *.log|wc -l`;exit $result"}, // On cpu4, inject and consume total 0x1 error, interval 5 seconds // working on Montecito latest PAL. {"Second test: inject and consume, corrected, data cache, hier-2, physical addr(assigned by tool code).", "rm *.log -f;./err_inject_tool -i -e 4,1,5,4109,95>/dev/null 2>&1;result=0;result=`grep successful *.log|wc -l`;exit $result"}, // On cpu15, inject and consume total 0x1 error, interval 5 seconds // working on Montecito latest PAL. {"Third test: recoverable, DTR0, hier-2.", "rm *.log -f;./err_inject_tool -i -e 0xf,1,5,4249,15>/dev/null 2>&1;result=0;result=`grep successful *.log|wc -l`;exit $result"}, {NULL,NULL} }; static void inject_error(char *command) { int myHelloWin; newtComponent myHelloText, myHelloForm, myOk, myScales; int W,H; int result=0; newtGetScreenSize(&W,&H); myHelloWin = newtOpenWindow(1+(W-55)/2, 1+(H-11)/2, 55, 11,"PC speaker test"); myHelloForm = newtForm(NULL,NULL,0); myHelloText = newtTextbox(3,2,52,1, 0); newtFormAddComponent(myHelloForm, myHelloText); newtTextboxSetText(myHelloText, "Error Injection Testing. \n"); myScales = newtScale(3,4,49, 100); newtFormAddComponent(myHelloForm, myScales); myOk = newtButton(40,6, "Back"); newtFormAddComponent(myHelloForm, myOk); newtDrawForm(myHelloForm); newtRefresh(); result=system(command); newtScaleSet(myScales, 100); if (result) newtTextboxSetText(myHelloText, "Error Injection Testing succeeds. \n"); else newtTextboxSetText(myHelloText, "Error Injection Testing fails. \n"); newtRefresh(); newtDrawForm(myHelloForm); newtRefresh(); newtRunForm(myHelloForm); newtPopWindow(); } static void mci_inject(void) { int win; newtComponent myForm; newtComponent myOkButton; newtComponent myList; newtComponent resu; FILE *file; int W,H; int i; struct interactive_test *test; start_test("mci_inject", "Machine Check Insertion", "This test allows the user to insert Machine Check errors " "manually to test the MC handlers."); newtGetScreenSize(&W,&H); win = newtOpenWindow(1,2,W-3,H-4, "Select the error to inject"); myForm = newtForm(NULL, NULL, 0); myList = newtListbox(2,1,H-10, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); newtFormAddComponent(myForm, myList); newtListboxSetWidth(myList, W-6); i = 0; while (errors[i][0]!=NULL) { newtListboxAppendEntry(myList, errors[i][0], errors[i][1]); i++; } myOkButton = newtButton(2,H-8, "Back"); newtFormAddComponent(myForm, myOkButton); while (1) { resu = newtRunForm(myForm); if (resu == myList) { test = newtListboxGetCurrent(myList); if (test) inject_error((char *)test); } else break; } newtPopWindow(); finish_test("mci_inject"); } void run_test(void) { register_interactive_test("Software injected Machine Check Errors", mci_inject); }