Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1EskHG-0007uH-GJ for mharc-grub-devel@gnu.org; Sat, 31 Dec 2005 12:12:24 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EskHD-0007m3-Ig for grub-devel@gnu.org; Sat, 31 Dec 2005 12:12:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EskHA-0007h6-VE for grub-devel@gnu.org; Sat, 31 Dec 2005 12:12:18 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EskHA-0007gH-KX for grub-devel@gnu.org; Sat, 31 Dec 2005 12:12:16 -0500 Received: from [209.86.89.69] (helo=smtpauth09.mail.atl.earthlink.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EskHt-00036D-Hh for grub-devel@gnu.org; Sat, 31 Dec 2005 12:13:01 -0500 Received: from [63.246.184.80] (helo=[192.168.0.100]) by smtpauth09.mail.atl.earthlink.net with asmtp (Exim 4.34) id 1EskFe-00040m-QQ for grub-devel@gnu.org; Sat, 31 Dec 2005 12:10:43 -0500 Mime-Version: 1.0 (Apple Message framework v623) In-Reply-To: <87slst871q.fsf@xs4all.nl> References: <247878a1a3ba32e60a89ff5f7a9272ab@penguinppc.org> <87slst871q.fsf@xs4all.nl> Content-Type: multipart/mixed; boundary=Apple-Mail-2-975530095 Message-Id: From: Hollis Blanchard Date: Sat, 31 Dec 2005 11:10:36 -0600 To: The development of GRUB 2 X-Mailer: Apple Mail (2.623) X-ELNK-Trace: 77a46389d001b1f223bcf3e39c2f8b5f1aa676d7e74259b7b3291a7d08dfec79637005d4c0c1649af42d0b8643c2196c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 63.246.184.80 Subject: Re: [patch] memory commands X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Dec 2005 17:12:20 -0000 --Apple-Mail-2-975530095 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On Dec 16, 2005, at 8:12 AM, Marco Gerards wrote: > Hollis Blanchard writes: > >> This patch adds a "memory" module, which currently contains two >> commands: >> Usage: memdump [address [len]] >> Dump the contents of memory. >> >> Usage: memset address (value [len] | trap) >> Write a 32-bit quantity to memory. >> >> Future commands could include "memload" (load a file into memory) and >> "memsearch" (search for a given value or string in a specified area of >> memory. I haven't needed those yet. > > Personally I prefer to call this module `memdebug'. In that case it > is clear that it is intended for debugging, not for other memory > related commands (which we might need someday, but are not related at > all). > >> Comments? > > I'd like to do a full review later in the weekend, if possible. Here is the patch with the module renamed to "memdebug". -Hollis --Apple-Mail-2-975530095 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; x-unix-mode=0644; name="memdebug.txt" Content-Disposition: attachment; filename=memdebug.txt Index: ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/ChangeLog,v retrieving revision 1.210 diff -u -p -r1.210 ChangeLog --- ChangeLog 10 Dec 2005 05:24:58 -0000 1.210 +++ ChangeLog 31 Dec 2005 16:58:56 -0000 @@ -1,3 +1,22 @@ +2005-12-12 Hollis Blanchard + + * commands/memdebug.c: New file. + * kern/powerpc/misc.c: Likewise. + * include/grub/powerpc/misc.h: Likewise. + * include/grub/i386/misc.h: Likewise. + * include/grub/sparc64/misc.h: Likewise. + * conf/common.rmk (pkgdata_MODULES): Add memdebug.mod. + (memdebug_mod_SOURCES): New variable. + (memdebug_mod_CFLAGS): Likewise. + (memdebug_mod_LDFLAGS): Likewise. + * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add + kern/powerpc/misc.c. + (grubof_SOURCES): Likewise. + (grubof_HEADERS): Add cache.h and cpu/misc.h. + * conf/i386-pc.rmk (kernel_img_HEADERS): Likewise. + * conf/sparc64-ieee1275.rmk (grubof_HEADERS): Likewise. + * include/grub/misc.h (grub_hexdump): New prototype. + 2005-12-09 Hollis Blanchard =20 * configure.ac: Accept `powerpc64' as host_cpu. Index: conf/common.rmk =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/conf/common.rmk,v retrieving revision 1.3 diff -u -p -r1.3 common.rmk --- conf/common.rmk 3 Dec 2005 17:54:55 -0000 1.3 +++ conf/common.rmk 31 Dec 2005 16:58:56 -0000 @@ -111,10 +111,23 @@ gpt_mod_LDFLAGS =3D $(COMMON_LDFLAGS) =20 =20 # Commands. -pkgdata_MODULES +=3D hello.mod boot.mod terminal.mod ls.mod \ - cmp.mod cat.mod help.mod font.mod search.mod \ - loopback.mod default.mod timeout.mod configfile.mod \ - terminfo.mod test.mod +pkgdata_MODULES +=3D \ + boot.mod \ + cat.mod \ + cmp.mod \ + configfile.mod \ + default.mod \ + font.mod \ + hello.mod \ + help.mod \ + ls.mod \ + loopback.mod \ + memdebug.mod \ + timeout.mod \ + search.mod \ + terminal.mod \ + terminfo.mod \ + test.mod =20 # For hello.mod. hello_mod_SOURCES =3D hello/hello.c @@ -191,6 +204,11 @@ terminfo_mod_SOURCES =3D term/terminfo.c t terminfo_mod_CFLAGS =3D $(COMMON_CFLAGS) terminfo_mod_LDFLAGS =3D $(COMMON_LDFLAGS) =20 +# For memdebug.mod. +memdebug_mod_SOURCES =3D commands/memdebug.c +memdebug_mod_CFLAGS =3D $(COMMON_CFLAGS) +memdebug_mod_LDFLAGS =3D $(COMMON_LDFLAGS) + =20 # Misc. pkgdata_MODULES +=3D gzio.mod=20 Index: conf/i386-pc.rmk =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v retrieving revision 1.57 diff -u -p -r1.57 i386-pc.rmk --- conf/i386-pc.rmk 3 Dec 2005 17:54:55 -0000 1.57 +++ conf/i386-pc.rmk 31 Dec 2005 16:58:57 -0000 @@ -30,9 +30,10 @@ kernel_img_SOURCES =3D kern/i386/pc/startu kern/env.c disk/i386/pc/biosdisk.c \ term/i386/pc/console.c \ symlist.c -kernel_img_HEADERS =3D arg.h boot.h device.h disk.h dl.h elf.h env.h = err.h \ - file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h = partition.h \ - pc_partition.h rescue.h symbol.h term.h types.h \ +kernel_img_HEADERS =3D arg.h boot.h cache.h device.h disk.h dl.h elf.h = env.h \ + err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ + partition.h pc_partition.h rescue.h symbol.h term.h types.h \ + cpu/misc.h \ machine/biosdisk.h machine/boot.h machine/console.h = machine/init.h \ machine/memory.h machine/loader.h machine/time.h machine/vga.h \ machine/vbe.h Index: conf/powerpc-ieee1275.rmk =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.51 diff -u -p -r1.51 powerpc-ieee1275.rmk --- conf/powerpc-ieee1275.rmk 23 Nov 2005 02:23:08 -0000 1.51 +++ conf/powerpc-ieee1275.rmk 31 Dec 2005 16:58:57 -0000 @@ -9,11 +9,11 @@ COMMON_CFLAGS =3D -ffreestanding -msoft-fl MOSTLYCLEANFILES +=3D grubof_symlist.c kernel_syms.lst DEFSYMFILES +=3D kernel_syms.lst =20 -grubof_HEADERS =3D arg.h boot.h device.h disk.h dl.h elf.h env.h err.h = \ +grubof_HEADERS =3D arg.h boot.h cache.h device.h disk.h dl.h elf.h = env.h err.h \ file.h fs.h kernel.h misc.h mm.h net.h parser.h rescue.h = symbol.h \ term.h types.h powerpc/libgcc.h loader.h \ partition.h pc_partition.h ieee1275/ieee1275.h machine/time.h \ - machine/kernel.h + machine/kernel.h cpu/misc.h =20 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) = gensymlist.sh sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@ @@ -54,7 +54,8 @@ grub_emu_SOURCES =3D commands/boot.c comma partmap/acorn.c = \ util/console.c util/grub-emu.c util/misc.c = \ util/i386/pc/biosdisk.c util/i386/pc/getroot.c = \ - util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c + util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c = \ + kern/powerpc/misc.c =20 grub_emu_LDFLAGS =3D $(LIBCURSES) =20 @@ -65,7 +66,7 @@ grubof_SOURCES =3D kern/powerpc/ieee1275/c kern/powerpc/ieee1275/init.c term/ieee1275/ofconsole.c = \ kern/powerpc/ieee1275/openfw.c disk/ieee1275/ofdisk.c = \ kern/parser.c kern/partition.c kern/env.c kern/powerpc/dl.c = \ - grubof_symlist.c kern/powerpc/cache.S + grubof_symlist.c kern/powerpc/cache.S kern/powerpc/misc.c grubof_HEADERS =3D grub/powerpc/ieee1275/ieee1275.h grubof_CFLAGS =3D $(COMMON_CFLAGS) grubof_ASFLAGS =3D $(COMMON_ASFLAGS) Index: conf/sparc64-ieee1275.rmk =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/conf/sparc64-ieee1275.rmk,v retrieving revision 1.8 diff -u -p -r1.8 sparc64-ieee1275.rmk --- conf/sparc64-ieee1275.rmk 18 Nov 2005 10:51:00 -0000 1.8 +++ conf/sparc64-ieee1275.rmk 31 Dec 2005 16:58:57 -0000 @@ -10,11 +10,11 @@ COMMON_LDFLAGS =3D -melf64_sparc MOSTLYCLEANFILES +=3D grubof_symlist.c kernel_syms.lst DEFSYMFILES +=3D kernel_syms.lst =20 -grubof_HEADERS =3D arg.h boot.h device.h disk.h dl.h elf.h env.h err.h = \ +grubof_HEADERS =3D arg.h boot.h cache.h device.h disk.h dl.h elf.h = env.h err.h \ file.h fs.h kernel.h misc.h mm.h net.h parser.h rescue.h = symbol.h \ term.h types.h sparc64/libgcc.h loader.h \ partition.h pc_partition.h ieee1275/ieee1275.h machine/time.h \ - machine/kernel.h + machine/kernel.h cpu/misc.h =20 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) = gensymlist.sh sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@ Index: include/grub/misc.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/include/grub/misc.h,v retrieving revision 1.17 diff -u -p -r1.17 misc.h --- include/grub/misc.h 24 Oct 2005 10:23:46 -0000 1.17 +++ include/grub/misc.h 31 Dec 2005 16:58:57 -0000 @@ -76,4 +76,6 @@ grub_ssize_t EXPORT_FUNC(grub_utf8_to_uc const grub_uint8_t *src, grub_size_t size); =20 +void EXPORT_FUNC(grub_hexdump) (const void *ptr, unsigned long bytes); + #endif /* ! GRUB_MISC_HEADER */ Index: include/grub/i386/misc.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: include/grub/i386/misc.h diff -N include/grub/i386/misc.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/grub/i386/misc.h 31 Dec 2005 16:58:57 -0000 @@ -0,0 +1,25 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_MISC_CPU_HEADER +#define GRUB_MISC_CPU_HEADER 1 + +#undef HAVE_CPU_INSERT_TRAP + +#endif /* ! GRUB_MISC_CPU_HEADER */ Index: include/grub/powerpc/misc.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: include/grub/powerpc/misc.h diff -N include/grub/powerpc/misc.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/grub/powerpc/misc.h 31 Dec 2005 16:58:57 -0000 @@ -0,0 +1,26 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_MISC_CPU_HEADER +#define GRUB_MISC_CPU_HEADER 1 + +#define HAVE_CPU_INSERT_TRAP +int EXPORT_FUNC(grub_cpu_insert_trap) (void *address); + +#endif /* ! GRUB_MISC_CPU_HEADER */ Index: include/grub/sparc64/misc.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: include/grub/sparc64/misc.h diff -N include/grub/sparc64/misc.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/grub/sparc64/misc.h 31 Dec 2005 16:58:57 -0000 @@ -0,0 +1,25 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_MISC_CPU_HEADER +#define GRUB_MISC_CPU_HEADER 1 + +#undef HAVE_CPU_INSERT_TRAP + +#endif /* ! GRUB_MISC_CPU_HEADER */ Index: kern/misc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/grub/grub2/kern/misc.c,v retrieving revision 1.25 diff -u -p -r1.25 misc.c --- kern/misc.c 28 Oct 2005 03:14:33 -0000 1.25 +++ kern/misc.c 31 Dec 2005 16:58:57 -0000 @@ -875,3 +875,29 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest,=20 =20 return p - dest; } + +void +grub_hexdump (const void *ptr, unsigned long bytes) +{ + const char *chr; + unsigned long i; + unsigned long j; + const unsigned int stride =3D 4 * sizeof (grub_uint32_t); + + /* Word-align `ptr'. */ + chr =3D (char *) ((unsigned long) ptr & ~0x3); + + for (i =3D 0; i < bytes; i +=3D stride) + { + int *word =3D (int *) (chr + i); + grub_printf ("%08x: %08x %08x %08x %08x ", (grub_uint32_t) word, + word[0], word[1], word[2], word[3]); + + for (j =3D 0; j < stride; j++) + if (grub_isprint (chr[i+j])) + grub_putchar (chr[i+j]); + else + grub_putchar ('.'); + grub_putchar ('\n'); + } +} Index: kern/powerpc/misc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: kern/powerpc/misc.c diff -N kern/powerpc/misc.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ kern/powerpc/misc.c 31 Dec 2005 16:58:57 -0000 @@ -0,0 +1,31 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005 Free Software Foundation, Inc. + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include + +int grub_cpu_insert_trap (void *address) +{ + grub_uint32_t *instruction =3D address; + + *instruction =3D 0x7fe00008; /* trap */ + grub_arch_sync_caches ((void *) address, sizeof (*instruction)); + + return 0; +} Index: commands/memdebug.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: commands/memdebug.c diff -N commands/memdebug.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ commands/memdebug.c 31 Dec 2005 17:02:52 -0000 @@ -0,0 +1,116 @@ +/* memdebug.c - commands to manipulate the contents of memory */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003,2005 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +static grub_err_t +grub_cmd_memdump (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) + +{ + static unsigned long address =3D 0; + static unsigned long bytes =3D 64; + + if (argc > 2) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments"); + + if (argc > 0) + address =3D grub_strtoul (args[0], 0, 0); + + if (argc > 1) + bytes =3D grub_strtoul (args[1], 0, 0); + + grub_hexdump ((void *) address, bytes); + + address +=3D bytes; /* Remember position for next memdump. */ + + return 0; +} + +static grub_err_t +grub_cmd_memset (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) + +{ + grub_uint32_t *ptr; + grub_uint32_t value; + int repeat =3D 1; + int i; + + if (argc < 2) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "too few arguments"); + + if (argc > 3) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments"); + + ptr =3D (grub_uint32_t *) grub_strtoul (args[0], 0, 0); + +#ifdef HAVE_CPU_INSERT_TRAP + if (0 =3D=3D grub_strcmp ("trap", args[1])) + return grub_cpu_insert_trap (ptr); +#endif /* HAVE_CPU_INSERT_TRAP */ + + value =3D grub_strtoul (args[1], 0, 0); + + if (argc > 2) + { + int bytes =3D grub_strtoul (args[2], 0, 0); + repeat =3D bytes / sizeof (grub_uint32_t); + } + + for (i =3D 0; i < repeat; i++) + { + *ptr =3D value; + ptr++; + } + grub_arch_sync_caches (ptr, repeat * sizeof (grub_uint32_t)); + + return 0; +} + +=0C +GRUB_MOD_INIT(memdebug) +{ + (void) mod; + grub_register_command ("memdump", grub_cmd_memdump, = GRUB_COMMAND_FLAG_BOTH, + "memdump [address [len]]", + "Dump the contents of memory.", 0); +#ifdef HAVE_CPU_INSERT_TRAP + grub_register_command ("memset", grub_cmd_memset, = GRUB_COMMAND_FLAG_BOTH, + "memset address (value [len] | trap)", + "Write a 32-bit quantity to memory.", 0); +#else /* HAVE_CPU_INSERT_TRAP */ + grub_register_command ("memset", grub_cmd_memset, = GRUB_COMMAND_FLAG_BOTH, + "memset address value [len]", + "Write a 32-bit quantity to memory.", 0); +#endif /* HAVE_CPU_INSERT_TRAP */ +} + +GRUB_MOD_FINI(memdebug) +{ + grub_unregister_command ("memdump"); + grub_unregister_command ("memset"); +} --Apple-Mail-2-975530095--