using a new grub command
Hi,
I've added my code to read the frontkeys to a file \grub-1.99.tar\grub-1.99\grub-1.99\grub-core\commands\i386\pc\checkfrontkeys.c and it compiles fine (with ./configure, make and make install). Later on the scripts install the file correctly as I can see checkfrontkeys.mod in /boot/grub
So what I then do is adding the following lines to /etc/grub.d/00_header".
After that I execute grub-mkconfig and update-grub2. The command checkfrontkeys no appears correctly in /boot/grub/grub.cfg
But on starting my tablet I see error: unknown command 'checkfrontkeys'
Where else do I need to register the command checkfrontkeys so that grub recognizes it? (makefiles etc.)
Thank you in advance
Joachim
code added to /etc/grub.d/00_header:
cat << EOF
echo "before checkfrontkeys"
checkfrontkeysresult = checkfrontkeys;
echo checkfrontkeysresult
echo "after checkfrontkeys"
EOF
(cat << EOF
if [ -s \$prefix/grubenv ]; then
load_env
fi
EOF
....)
/* checkfrontkeys.c - command to play a tune */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2007,2009 Free Software Foundation, Inc. *
* GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRUB 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/dl.h>
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/term.h>
#include <grub/misc.h>
#include <grub/machine/time.h>
#include <grub/cpu/io.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/cmos.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_tgrub_cmd_checkfrontkeys (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
if(argc == 1) {}
if(args[0] == args[0]) {}
unsigned char bits9;
//unsigned char keybits;
//keybits = 32;
grub_outb(32, 0x20A);
grub_outw(-16832, 0x20C);
bits9 = grub_inb(0x209);/* echo "bits9= "
echo ${bits9}
if [${bits9} = 64]; then
set default="1"
elif [${bits9} = 32]; then
set default="2"
elif [${bits9} = 16]; then
set default="3"
else
set default="0"
fi*/
grub_printf ("bits9=%c\n", bits9);
grub_dprintf ("bits9", "bits9= 0x%02x\n",
bits9);
return bits9;
}static grub_command_t cmd;GRUB_MOD_INIT(checkfrontkeys)
{
cmd = grub_register_command ("checkfrontkeys", grub_cmd_checkfrontkeys,
0,
N_("check the status of the front keys."));
}GRUB_MOD_FINI(checkfrontkeys)
{
grub_unregister_command (cmd);
}
Quoted 1 line · Joachim Mammele
checkfrontkeysresult = checkfrontkeys;
There is no such syntax in neither bash nor GRUB
Look at hello.c as to how make a command.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Thank you.
With this I want to assign the value that was returned by checkfrontkeys to checkfrontkeysresult in order to echo it in the next line (and later on work with in doing some if(checkfrontkeysresult == "0x12")... And what do I need to change in grub.cfg in order to call hello.
Would the command "hello" be enough or do I need also a "insmod hello"?
Am 25.04.2012 11:57, schrieb Vladimir '?-coder/phcoder' Serbinenko:
Quoted 11 lines · Joachim Mammele
Quoted 1 line
checkfrontkeysresult = checkfrontkeys;
There is no such syntax in neither bash nor GRUB
Look athello.cas to how make a command._______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 5 lines
Joachim Mammele Egelhaafstrasse 3 70565 Stuttgart Mobil: 0162/4603792 E-Mail: [email protected]