/* * 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 #include #include #include "../biostest.h" static int ExecuteAmlMethod(const char *AmlPath,const char *AmlMethod) { char buffer[PATH_MAX]; int config, action; char *cmd; int fd; int ret; sprintf(buffer, "/proc/acpi/hotkey/event_config"); config = open(buffer, O_RDWR); if (!config) { printf("Error: fopen failed \n"); return -1; } fd = config; cmd = (char *) malloc(2*(sizeof(AmlPath)+ sizeof(AmlMethod))+80); memset(cmd, 0, sizeof(cmd)); cmd=strcpy(cmd, "0:"); cmd=strcat(cmd, AmlPath); cmd=strcat(cmd, ":"); cmd=strcat(cmd, AmlMethod); cmd=strcat(cmd, ":"); cmd=strcat(cmd, AmlPath); cmd=strcat(cmd, ":"); cmd=strcat(cmd, AmlMethod); cmd=strcat(cmd, ":1:1"); ret = write(fd, "1:1",3); ret = write(fd, cmd, 80); free(cmd); close(config); memset(buffer,0,PATH_MAX); sprintf(buffer, "/proc/acpi/hotkey/action"); action = open(buffer, O_RDWR); if (!action) { printf("Error: fopen failed \n"); return -1; } fd = action; cmd = (char *) malloc(10); memset(cmd, 0, 10); strcat(cmd, "1:0:1:0"); ret = write(fd, cmd, 10); free(cmd); close(action); if (ret<0) { printf("Error: pread failed %d\n, errno=%d", ret, errno); return -2; } return 0; } static void aml_hwpoke_call(void) { int myWin; newtComponent myForm; newtComponent myOk, myExecute; newtComponent resu; newtComponent myAmlPath, myAmlMethod; const char * amlpath, *amlmethod; int W,H; newtGetScreenSize(&W,&H); myWin = newtOpenWindow((W-40)/2,(H-19)/2,40,19, "Execute AML Method"); myForm = newtForm(NULL,NULL,0); myOk = newtButton(27,15, "Back"); newtFormAddComponent(myForm, myOk); newtFormAddComponent(myForm, newtLabel(2,2, "AML path")); myAmlPath= newtEntry(20, 2, "", 15, &amlpath, 0); newtFormAddComponent(myForm, myAmlPath); newtFormAddComponent(myForm, newtLabel(2,4, "AML method")); myAmlMethod= newtEntry(20, 4, "", 15, &amlmethod, NEWT_FLAG_RETURNEXIT); newtFormAddComponent(myForm, myAmlMethod); myExecute = newtButton(2,8, "Execute"); newtFormAddComponent(myForm, myExecute); while (1) { resu = newtRunForm(myForm); if (resu == myAmlMethod || resu==myExecute) { ExecuteAmlMethod(amlpath,amlmethod); } else break; } newtPopWindow(); } void run_test(void) { register_hw_poke("AML Methods", aml_hwpoke_call); }