grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using a new grub command


From: Joachim Mammele
Subject: using a new grub command
Date: Wed, 25 Apr 2012 11:46:40 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

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_t
grub_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);

}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]