From: phcoder <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Interrupt testing
Date: Sat, 07 Mar 2009 16:43:01 +0100 [thread overview]
Message-ID: <49B29605.4020802@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
Hello. Here is a trivial patch for testing which interrupts are and
which aren't handled by BIOS. Can be used as a simple but not reliable
test for boot viruses
--
Regards
Vladimir 'phcoder' Serbinenko
[-- Attachment #2: inttest.diff --]
[-- Type: text/x-patch, Size: 4138 bytes --]
Index: conf/i386-pc.rmk
===================================================================
--- conf/i386-pc.rmk (revision 2021)
+++ conf/i386-pc.rmk (working copy)
@@ -172,3 +181,3 @@
vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \
ata.mod vga.mod memdisk.mod pci.mod lspci.mod \
aout.mod _bsd.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \
datehook.mod lsmmap.mod ata_pthru.mod hdparm.mod \
- usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod
+ usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod \
+ inttest.mod
+# For inttest.mod.
+inttest_mod_SOURCES = commands/i386/pc/inttest.c
+inttest_mod_CFLAGS = $(COMMON_CFLAGS) -Werror
+inttest_mod_LDFLAGS = $(COMMON_LDFLAGS)
Index: ChangeLog
===================================================================
--- ChangeLog (revision 2021)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2009-03-07 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Interrupt tests
+
+ * commands/i386/pc/inttest.c: new file
+ * conf/i386-pc.rmk: new module inttest.mod
+
2009-03-07 Bean <bean123ch@gmail.com>
* loader/i386/efi/linux.c (grub_rescue_cmd_initrd): Fix a bug in initrd
Index: commands/i386/pc/inttest.c
===================================================================
--- commands/i386/pc/inttest.c (revision 0)
+++ commands/i386/pc/inttest.c (revision 0)
@@ -0,0 +1,85 @@
+/* inttest.c - simple interrupt testing */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+
+static grub_err_t
+grub_cmd_intreport (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_uint32_t *vects = 0;
+ int i;
+ for (i = 0; i < 0x100; i++)
+ if(((vects[i] >> 16) + ((vects[i] & 0xffff) >> 4)) >= 0xc000)
+ grub_printf("int %xh in BIOS %x:%x\n",
+ i, vects[i]>>16, vects[i]&0xffff);
+ else
+ grub_printf("int %xh not in BIOS %x:%x\n",
+ i, vects[i]>>16, vects[i]&0xffff);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_inttest (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_uint32_t *vects = 0;
+ int i;
+ for (i = 0; i <= 0x1c; i++)
+ if(((vects[i] >> 16) + ((vects[i] & 0xffff) >> 4)) < 0xc000)
+ return grub_error (GRUB_ERR_TEST_FAILURE, "interrupt %xh isn't in BIOS",
+ i);
+ if(((vects[0x4a] >> 16) + ((vects[0x4a] & 0xffff) >> 4)) < 0xc000)
+ return grub_error (GRUB_ERR_TEST_FAILURE, "interrupt 4ah isn't in BIOS",
+ i);
+ if(((vects[0x70] >> 16) + ((vects[0x70] & 0xffff) >> 4)) < 0xc000)
+ return grub_error (GRUB_ERR_TEST_FAILURE, "interrupt 70h isn't in BIOS",
+ i);
+
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(intreport)
+{
+ (void)mod; /* To stop warning. */
+ grub_register_command ("intreport", grub_cmd_intreport,
+ GRUB_COMMAND_FLAG_BOTH,
+ "intreport",
+ "Report which interrupts are and which aren't in BIOS",
+ 0);
+ grub_register_command ("inttest", grub_cmd_inttest,
+ GRUB_COMMAND_FLAG_BOTH,
+ "inttest",
+ "Test that commonly used interrupts are in BIOS",
+ 0);
+
+}
+
+GRUB_MOD_FINI(intreport)
+{
+ grub_unregister_command ("intreport");
+ grub_unregister_command ("inttest");
+}
next reply other threads:[~2009-03-07 15:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-07 15:43 phcoder [this message]
2009-03-08 12:32 ` Interrupt testing Robert Millan
2009-08-28 17:21 ` Vladimir 'phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49B29605.4020802@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.