Skip to contentSkip to conversation

memory commands

PATCH In review Hollis Blanchard 2 participants 8 messages Dec 13, 2005 – Jan 2, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory commands

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.

The one tricky thing is that I added a "trap" shortcut. On PowerPC, and I assume on Sparc, when the processor hits a trap instruction while the firmware still owns the exception handlers, the firmware will provide helpful debug facilities (such as dumping the register state at the time of the trap). Inserting trap instructions has been very helpful to me for GRUB debugging (for example the OS X loader I've been working on). However, it may not make sense to have something like that on architectures like i386, which is why I made it depend on the HAVE_CPU_INSERT_TRAP define.

Comments?

-Hollis

2005-12-12 Hollis Blanchard <[email protected]>

* commands/memory.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 memory.mod. (memory_mod_SOURCES): New variable. (memory_mod_CFLAGS): Likewise. (memory_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.

? .vimrc
? build
? tmp.diff
Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.210

ChangeLog +19 -0
diff -u -p -r1.210 ChangeLog
@@ -1,3 +1,22 @@
+2005-12-12  Hollis Blanchard  <[email protected]>
+
+	* commands/memory.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 memory.mod.
+	(memory_mod_SOURCES): New variable.
+	(memory_mod_CFLAGS): Likewise.
+	(memory_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  <[email protected]>
 
 	* configure.ac: Accept `powerpc64' as host_cpu.

Index: commands/memory.c
===================================================================
RCS file: commands/memory.c

memory.c new file +116 -0

116 lines not on this page · raw message

Index: conf/common.mk
===================================================================
RCS file: /sources/grub/grub2/conf/common.mk,v
retrieving revision 1.4

common.mk +68 -4

84 lines not on this page · raw message

Index: conf/common.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/common.rmk,v
retrieving revision 1.3

common.rmk +22 -4
diff -u -p -r1.3 common.rmk
@@ -111,10 +111,23 @@ gpt_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 
 # Commands.
-pkgdata_MODULES += 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 += \
+	boot.mod \
+	cat.mod \
+	cmp.mod \
+	configfile.mod \
+	default.mod \
+	font.mod \
+	hello.mod \
+	help.mod \
+	ls.mod \
+	loopback.mod \
+	memory.mod \
+	timeout.mod \
+	search.mod \
+	terminal.mod \
+	terminfo.mod \
+	test.mod
 
 # For hello.mod.
 hello_mod_SOURCES = hello/hello.c
@@ -191,6 +204,11 @@ terminfo_mod_SOURCES = term/terminfo.c t
 terminfo_mod_CFLAGS = $(COMMON_CFLAGS)
 terminfo_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For memory.mod.
+memory_mod_SOURCES = commands/memory.c
+memory_mod_CFLAGS = $(COMMON_CFLAGS)
+memory_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 
 # Misc.
 pkgdata_MODULES += gzio.mod 

Index: conf/i386-pc.mk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.mk,v
retrieving revision 1.60

i386-pc.mk +4 -3
diff -u -p -r1.60 i386-pc.mk
@@ -258,9 +258,10 @@ kernel_img-symlist.d: symlist.c
 
 -include kernel_img-symlist.d
 
-kernel_img_HEADERS = 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 = 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/i386-pc.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.57

i386-pc.rmk +4 -3
diff -u -p -r1.57 i386-pc.rmk
@@ -30,9 +30,10 @@ kernel_img_SOURCES = kern/i386/pc/startu
 	kern/env.c disk/i386/pc/biosdisk.c \
 	term/i386/pc/console.c \
 	symlist.c
-kernel_img_HEADERS = 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 = 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.mk
===================================================================
RCS file: /sources/grub/grub2/conf/powerpc-ieee1275.mk,v retrieving revision 1.53

powerpc-ieee1275.mk +27 -10
diff -u -p -r1.53 powerpc-ieee1275.mk
@@ -9,11 +9,11 @@ COMMON_CFLAGS = -ffreestanding -msoft-fl
 MOSTLYCLEANFILES += grubof_symlist.c kernel_syms.lst
 DEFSYMFILES += kernel_syms.lst
 
-grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
+grubof_HEADERS = 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
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
@@ -84,11 +84,12 @@ grub_emu_SOURCES = 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
-CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o
-MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_default.d grub_emu-commands_help.d grub_emu-commands_search.d grub_emu-commands_terminal.d grub_emu-commands_test.d grub_emu-commands_ls.d grub_emu-commands_timeout.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_context.d grub_emu-normal_execute.d grub_emu-normal_function.d grub_emu-normal_lexer.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_powerpc_ieee1275_misc.d grub_emu-grub_script_tab.d grub_emu-grub_emu_init.d
+	util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c  \
+	kern/powerpc/misc.c
+CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o grub_emu-kern_powerpc_misc.o
+MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_default.d grub_emu-commands_help.d grub_emu-commands_search.d grub_emu-commands_terminal.d grub_emu-commands_test.d grub_emu-commands_ls.d grub_emu-commands_timeout.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_context.d grub_emu-normal_execute.d grub_emu-normal_function.d grub_emu-normal_lexer.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_powerpc_ieee1275_misc.d grub_emu-grub_script_tab.d grub_emu-grub_emu_init.d grub_emu-kern_powerpc_misc.d
 
-grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o
+grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o grub_emu-kern_powerpc_misc.o
 	$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS)
 
 grub_emu-commands_boot.o: commands/boot.c
@@ -619,6 +620,14 @@ grub_emu-grub_emu_init.d: grub_emu_init.
 
 -include grub_emu-grub_emu_init.d
 
+grub_emu-kern_powerpc_misc.o: kern/powerpc/misc.c
+	$(BUILD_CC) -Ikern/powerpc -I$(srcdir)/kern/powerpc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
+
+grub_emu-kern_powerpc_misc.d: kern/powerpc/misc.c
+	set -e; 	  $(BUILD_CC) -Ikern/powerpc -I$(srcdir)/kern/powerpc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< 	  | sed 's,misc\.o[ :]*,grub_emu-kern_powerpc_misc.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include grub_emu-kern_powerpc_misc.d
+
 
 grub_emu_LDFLAGS = $(LIBCURSES)
 
@@ -629,11 +638,11 @@ grubof_SOURCES = 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
-CLEANFILES += grubof grubof-kern_powerpc_ieee1275_crt0.o grubof-kern_powerpc_ieee1275_cmain.o grubof-kern_ieee1275_ieee1275.o grubof-kern_main.o grubof-kern_device.o grubof-kern_disk.o grubof-kern_dl.o grubof-kern_file.o grubof-kern_fs.o grubof-kern_err.o grubof-kern_misc.o grubof-kern_mm.o grubof-kern_loader.o grubof-kern_rescue.o grubof-kern_term.o grubof-kern_powerpc_ieee1275_init.o grubof-term_ieee1275_ofconsole.o grubof-kern_powerpc_ieee1275_openfw.o grubof-disk_ieee1275_ofdisk.o grubof-kern_parser.o grubof-kern_partition.o grubof-kern_env.o grubof-kern_powerpc_dl.o grubof-grubof_symlist.o grubof-kern_powerpc_cache.o
-MOSTLYCLEANFILES += grubof-kern_powerpc_ieee1275_crt0.d grubof-kern_powerpc_ieee1275_cmain.d grubof-kern_ieee1275_ieee1275.d grubof-kern_main.d grubof-kern_device.d grubof-kern_disk.d grubof-kern_dl.d grubof-kern_file.d grubof-kern_fs.d grubof-kern_err.d grubof-kern_misc.d grubof-kern_mm.d grubof-kern_loader.d grubof-kern_rescue.d grubof-kern_term.d grubof-kern_powerpc_ieee1275_init.d grubof-term_ieee1275_ofconsole.d grubof-kern_powerpc_ieee1275_openfw.d grubof-disk_ieee1275_ofdisk.d grubof-kern_parser.d grubof-kern_partition.d grubof-kern_env.d grubof-kern_powerpc_dl.d grubof-grubof_symlist.d grubof-kern_powerpc_cache.d
+	grubof_symlist.c kern/powerpc/cache.S kern/powerpc/misc.c
+CLEANFILES += grubof grubof-kern_powerpc_ieee1275_crt0.o grubof-kern_powerpc_ieee1275_cmain.o grubof-kern_ieee1275_ieee1275.o grubof-kern_main.o grubof-kern_device.o grubof-kern_disk.o grubof-kern_dl.o grubof-kern_file.o grubof-kern_fs.o grubof-kern_err.o grubof-kern_misc.o grubof-kern_mm.o grubof-kern_loader.o grubof-kern_rescue.o grubof-kern_term.o grubof-kern_powerpc_ieee1275_init.o grubof-term_ieee1275_ofconsole.o grubof-kern_powerpc_ieee1275_openfw.o grubof-disk_ieee1275_ofdisk.o grubof-kern_parser.o grubof-kern_partition.o grubof-kern_env.o grubof-kern_powerpc_dl.o grubof-grubof_symlist.o grubof-kern_powerpc_cache.o grubof-kern_powerpc_misc.o
+MOSTLYCLEANFILES += grubof-kern_powerpc_ieee1275_crt0.d grubof-kern_powerpc_ieee1275_cmain.d grubof-kern_ieee1275_ieee1275.d grubof-kern_main.d grubof-kern_device.d grubof-kern_disk.d grubof-kern_dl.d grubof-kern_file.d grubof-kern_fs.d grubof-kern_err.d grubof-kern_misc.d grubof-kern_mm.d grubof-kern_loader.d grubof-kern_rescue.d grubof-kern_term.d grubof-kern_powerpc_ieee1275_init.d grubof-term_ieee1275_ofconsole.d grubof-kern_powerpc_ieee1275_openfw.d grubof-disk_ieee1275_ofdisk.d grubof-kern_parser.d grubof-kern_partition.d grubof-kern_env.d grubof-kern_powerpc_dl.d grubof-grubof_symlist.d grubof-kern_powerpc_cache.d grubof-kern_powerpc_misc.d
 
-grubof: grubof-kern_powerpc_ieee1275_crt0.o grubof-kern_powerpc_ieee1275_cmain.o grubof-kern_ieee1275_ieee1275.o grubof-kern_main.o grubof-kern_device.o grubof-kern_disk.o grubof-kern_dl.o grubof-kern_file.o grubof-kern_fs.o grubof-kern_err.o grubof-kern_misc.o grubof-kern_mm.o grubof-kern_loader.o grubof-kern_rescue.o grubof-kern_term.o grubof-kern_powerpc_ieee1275_init.o grubof-term_ieee1275_ofconsole.o grubof-kern_powerpc_ieee1275_openfw.o grubof-disk_ieee1275_ofdisk.o grubof-kern_parser.o grubof-kern_partition.o grubof-kern_env.o grubof-kern_powerpc_dl.o grubof-grubof_symlist.o grubof-kern_powerpc_cache.o
+grubof: grubof-kern_powerpc_ieee1275_crt0.o grubof-kern_powerpc_ieee1275_cmain.o grubof-kern_ieee1275_ieee1275.o grubof-kern_main.o grubof-kern_device.o grubof-kern_disk.o grubof-kern_dl.o grubof-kern_file.o grubof-kern_fs.o grubof-kern_err.o grubof-kern_misc.o grubof-kern_mm.o grubof-kern_loader.o grubof-kern_rescue.o grubof-kern_term.o grubof-kern_powerpc_ieee1275_init.o grubof-term_ieee1275_ofconsole.o grubof-kern_powerpc_ieee1275_openfw.o grubof-disk_ieee1275_ofdisk.o grubof-kern_parser.o grubof-kern_partition.o grubof-kern_env.o grubof-kern_powerpc_dl.o grubof-grubof_symlist.o grubof-kern_powerpc_cache.o grubof-kern_powerpc_misc.o
 	$(CC) -o $@ $^ $(LDFLAGS) $(grubof_LDFLAGS)
 
 grubof-kern_powerpc_ieee1275_crt0.o: kern/powerpc/ieee1275/crt0.S
@@ -836,6 +845,14 @@ grubof-kern_powerpc_cache.d: kern/powerp
 
 -include grubof-kern_powerpc_cache.d
 
+grubof-kern_powerpc_misc.o: kern/powerpc/misc.c
+	$(CC) -Ikern/powerpc -I$(srcdir)/kern/powerpc $(CPPFLAGS) $(CFLAGS) $(grubof_CFLAGS) -c -o $@ $<
+
+grubof-kern_powerpc_misc.d: kern/powerpc/misc.c
+	set -e; 	  $(CC) -Ikern/powerpc -I$(srcdir)/kern/powerpc $(CPPFLAGS) $(CFLAGS) $(grubof_CFLAGS) -M $< 	  | sed 's,misc\.o[ :]*,grubof-kern_powerpc_misc.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include grubof-kern_powerpc_misc.d
+
 grubof_HEADERS = grub/powerpc/ieee1275/ieee1275.h
 grubof_CFLAGS = $(COMMON_CFLAGS)
 grubof_ASFLAGS = $(COMMON_ASFLAGS)

Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.51

powerpc-ieee1275.rmk +5 -4
diff -u -p -r1.51 powerpc-ieee1275.rmk
@@ -9,11 +9,11 @@ COMMON_CFLAGS = -ffreestanding -msoft-fl
 MOSTLYCLEANFILES += grubof_symlist.c kernel_syms.lst
 DEFSYMFILES += kernel_syms.lst
 
-grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
+grubof_HEADERS = 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
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
@@ -54,7 +54,8 @@ grub_emu_SOURCES = 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
 
 grub_emu_LDFLAGS = $(LIBCURSES)
 
@@ -65,7 +66,7 @@ grubof_SOURCES = 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 = grub/powerpc/ieee1275/ieee1275.h
 grubof_CFLAGS = $(COMMON_CFLAGS)
 grubof_ASFLAGS = $(COMMON_ASFLAGS)

Index: conf/sparc64-ieee1275.mk
===================================================================
RCS file: /sources/grub/grub2/conf/sparc64-ieee1275.mk,v retrieving revision 1.8

sparc64-ieee1275.mk +2 -2
diff -u -p -r1.8 sparc64-ieee1275.mk
@@ -10,11 +10,11 @@ COMMON_LDFLAGS = -melf64_sparc
 MOSTLYCLEANFILES += grubof_symlist.c kernel_syms.lst
 DEFSYMFILES += kernel_syms.lst
 
-grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
+grubof_HEADERS = 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
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@

Index: conf/sparc64-ieee1275.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/sparc64-ieee1275.rmk,v retrieving revision 1.8

sparc64-ieee1275.rmk +2 -2
diff -u -p -r1.8 sparc64-ieee1275.rmk
@@ -10,11 +10,11 @@ COMMON_LDFLAGS = -melf64_sparc
 MOSTLYCLEANFILES += grubof_symlist.c kernel_syms.lst
 DEFSYMFILES += kernel_syms.lst
 
-grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
+grubof_HEADERS = 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
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@

Index: include/grub/misc.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/misc.h,v retrieving revision 1.17

grub/misc.h +2 -0
diff -u -p -r1.17 misc.h
@@ -76,4 +76,6 @@ grub_ssize_t EXPORT_FUNC(grub_utf8_to_uc
 					     const grub_uint8_t *src,
 					     grub_size_t size);
 
+void EXPORT_FUNC(grub_hexdump) (const void *ptr, unsigned long bytes);
+
 #endif /* ! GRUB_MISC_HEADER */

Index: include/grub/i386/misc.h
===================================================================
RCS file: include/grub/i386/misc.h

grub/i386/misc.h new file +25 -0
diff -N include/grub/i386/misc.h
@@ -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
===================================================================
RCS file: include/grub/powerpc/misc.h

grub/powerpc/misc.h new file +26 -0
diff -N include/grub/powerpc/misc.h
@@ -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
===================================================================
RCS file: include/grub/sparc64/misc.h

grub/sparc64/misc.h new file +25 -0
diff -N include/grub/sparc64/misc.h
@@ -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
===================================================================
RCS file: /sources/grub/grub2/kern/misc.c,v
retrieving revision 1.25

misc.c +26 -0
diff -u -p -r1.25 misc.c
@@ -875,3 +875,29 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, 
 
   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 = 4 * sizeof (grub_uint32_t);
+
+  /* Word-align `ptr'.  */
+  chr = (char *) ((unsigned long) ptr & ~0x3);
+
+  for (i = 0; i < bytes; i += stride)
+    {
+      int *word = (int *) (chr + i);
+      grub_printf ("%08x: %08x %08x %08x %08x  ", (grub_uint32_t) word,
+		   word[0], word[1], word[2], word[3]);
+
+      for (j = 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
===================================================================
RCS file: kern/powerpc/misc.c

powerpc/misc.c new file +29 -0
diff -N kern/powerpc/misc.c
@@ -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 <grub/misc.h>
+#include <grub/cache.h>
+
+int grub_cpu_insert_trap (void *address)
+{
+  grub_uint32_t *instruction = address;
+
+  *instruction = 0x7fe00008; /* trap */
+  grub_arch_sync_caches ((void *) address, sizeof (grub_uint32_t));
+
#1 lore raw
Quoted 11 lines · Hollis Blanchard

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).

Quoted 1 line

Comments?

I'd like to do a full review later in the weekend, if possible.

--
Marco

#2 lore raw
Quoted 14 lines · Marco Gerards
Quoted 11 lines · Hollis Blanchard

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.

Quoted 8 lines

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).

Quoted 1 line

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

Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.210

ChangeLog +19 -0
diff -u -p -r1.210 ChangeLog
@@ -1,3 +1,22 @@
+2005-12-12  Hollis Blanchard  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* configure.ac: Accept `powerpc64' as host_cpu.

Index: conf/common.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/common.rmk,v
retrieving revision 1.3

common.rmk +22 -4
diff -u -p -r1.3 common.rmk
@@ -111,10 +111,23 @@ gpt_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 
 # Commands.
-pkgdata_MODULES += 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 += \
+	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
 
 # For hello.mod.
 hello_mod_SOURCES = hello/hello.c
@@ -191,6 +204,11 @@ terminfo_mod_SOURCES = term/terminfo.c t
 terminfo_mod_CFLAGS = $(COMMON_CFLAGS)
 terminfo_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For memdebug.mod.
+memdebug_mod_SOURCES = commands/memdebug.c
+memdebug_mod_CFLAGS = $(COMMON_CFLAGS)
+memdebug_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 
 # Misc.
 pkgdata_MODULES += gzio.mod 

Index: conf/i386-pc.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.57

i386-pc.rmk +4 -3
diff -u -p -r1.57 i386-pc.rmk
@@ -30,9 +30,10 @@ kernel_img_SOURCES = kern/i386/pc/startu
 	kern/env.c disk/i386/pc/biosdisk.c \
 	term/i386/pc/console.c \
 	symlist.c
-kernel_img_HEADERS = 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 = 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
===================================================================
RCS file: /sources/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.51

powerpc-ieee1275.rmk +5 -4
diff -u -p -r1.51 powerpc-ieee1275.rmk
@@ -9,11 +9,11 @@ COMMON_CFLAGS = -ffreestanding -msoft-fl
 MOSTLYCLEANFILES += grubof_symlist.c kernel_syms.lst
 DEFSYMFILES += kernel_syms.lst
 
-grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
+grubof_HEADERS = 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
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
@@ -54,7 +54,8 @@ grub_emu_SOURCES = 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
 
 grub_emu_LDFLAGS = $(LIBCURSES)
 
@@ -65,7 +66,7 @@ grubof_SOURCES = 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 = grub/powerpc/ieee1275/ieee1275.h
 grubof_CFLAGS = $(COMMON_CFLAGS)
 grubof_ASFLAGS = $(COMMON_ASFLAGS)

Index: conf/sparc64-ieee1275.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/sparc64-ieee1275.rmk,v retrieving revision 1.8

sparc64-ieee1275.rmk +2 -2
diff -u -p -r1.8 sparc64-ieee1275.rmk
@@ -10,11 +10,11 @@ COMMON_LDFLAGS = -melf64_sparc
 MOSTLYCLEANFILES += grubof_symlist.c kernel_syms.lst
 DEFSYMFILES += kernel_syms.lst
 
-grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \
+grubof_HEADERS = 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
 
 grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh
 	sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@

Index: include/grub/misc.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/misc.h,v retrieving revision 1.17

grub/misc.h +2 -0
diff -u -p -r1.17 misc.h
@@ -76,4 +76,6 @@ grub_ssize_t EXPORT_FUNC(grub_utf8_to_uc
 					     const grub_uint8_t *src,
 					     grub_size_t size);
 
+void EXPORT_FUNC(grub_hexdump) (const void *ptr, unsigned long bytes);
+
 #endif /* ! GRUB_MISC_HEADER */

Index: include/grub/i386/misc.h
===================================================================
RCS file: include/grub/i386/misc.h

grub/i386/misc.h new file +25 -0
diff -N include/grub/i386/misc.h
@@ -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
===================================================================
RCS file: include/grub/powerpc/misc.h

grub/powerpc/misc.h new file +26 -0
diff -N include/grub/powerpc/misc.h
@@ -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
===================================================================
RCS file: include/grub/sparc64/misc.h

grub/sparc64/misc.h new file +25 -0
diff -N include/grub/sparc64/misc.h
@@ -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
===================================================================
RCS file: /sources/grub/grub2/kern/misc.c,v
retrieving revision 1.25

misc.c +26 -0
diff -u -p -r1.25 misc.c
@@ -875,3 +875,29 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, 
 
   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 = 4 * sizeof (grub_uint32_t);
+
+  /* Word-align `ptr'.  */
+  chr = (char *) ((unsigned long) ptr & ~0x3);
+
+  for (i = 0; i < bytes; i += stride)
+    {
+      int *word = (int *) (chr + i);
+      grub_printf ("%08x: %08x %08x %08x %08x  ", (grub_uint32_t) word,
+		   word[0], word[1], word[2], word[3]);
+
+      for (j = 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
===================================================================
RCS file: kern/powerpc/misc.c

powerpc/misc.c new file +31 -0
diff -N kern/powerpc/misc.c
@@ -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 <grub/misc.h>
+#include <grub/cache.h>
+
+int grub_cpu_insert_trap (void *address)
+{
+  grub_uint32_t *instruction = address;
+
+  *instruction = 0x7fe00008; /* trap */
+  grub_arch_sync_caches ((void *) address, sizeof (*instruction));
+
+  return 0;
+}

Index: commands/memdebug.c
===================================================================
RCS file: commands/memdebug.c

memdebug.c new file +116 -0

116 lines not on this page · raw message

#3 lore raw
Quoted 10 lines · Hollis Blanchard
Quoted 8 lines

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).

Quoted 1 line

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".

Cool, thanks :)

ChangeLog line 7

Quoted 8 lines

+2005-12-12 Hollis Blanchard <[email protected]>

ChangeLog +6 -0
+
+	* 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.

Why don't you use trap.[ch]? Calling it misc is a bit too generic I think, and I'm afraid everyone put everything in it.

memdebug.c line 104

Quoted 3 lines
memdebug.c new file +3 -0
+  grub_register_command ("memset", grub_cmd_memset, GRUB_COMMAND_FLAG_BOTH,
+			 "memset address (value [len] | trap)",
+			 "Write a 32-bit quantity to memory.", 0);

This syntax is a bit unusual, I think (for a GNU program). Mainly because it has quite some conditional parameters. How about:

memset --value=len

or:

memset --trap

Can you please explain what this command does? To be honest I don't really understand it immediately from the sourcecode. ;-)

--
Marco

#4 lore raw
Quoted 5 lines · Marco Gerards
Quoted 4 lines

+2005-12-12 Hollis Blanchard <[email protected]>

ChangeLog +2 -0
+
+	* commands/memdebug.c: New file.
Quoted 7 lines

ChangeLog line 7

Quoted 4 lines
ChangeLog +4 -0
+	* kern/powerpc/misc.c: Likewise.
+	* include/grub/powerpc/misc.h: Likewise.
+	* include/grub/i386/misc.h: Likewise.
+	* include/grub/sparc64/misc.h: Likewise.

Why don't you use trap.[ch]? Calling it misc is a bit too generic I think, and I'm afraid everyone put everything in it.

That was my intention. Our build system makes it too painful to introduce (then move and rename and remove) new files, and this didn't seem important enough to merit its own header anyways.

Quoted 8 lines

Review

Quoted 4 lines

+ grub_register_command ("memset", grub_cmd_memset, GRUB_COMMAND_FLAG_BOTH,

(quoted diff) +2 -0
+			 "memset address (value [len] | trap)",
+			 "Write a 32-bit quantity to memory.", 0);

This syntax is a bit unusual, I think (for a GNU program). Mainly because it has quite some conditional parameters. How about:

Quoted 5 lines

memset --value=len

or:

memset --trap

"memset --address=foo --value=bar --len=baz" and "memset --address=foo --value=trap"? Far too much typing for a very simple operation.

Quoted 2 lines

Can you please explain what this command does? To be honest I don't really understand it immediately from the sourcecode. ;-)

It writes a value into a region of memory.

-Hollis

#5 lore raw
Quoted 14 lines · Hollis Blanchard
Quoted 5 lines · Marco Gerards
Quoted 4 lines

+2005-12-12 Hollis Blanchard <[email protected]>

ChangeLog +2 -0
+
+	* commands/memdebug.c: New file.
Quoted 7 lines

ChangeLog line 7

Quoted 4 lines
ChangeLog +4 -0
+	* kern/powerpc/misc.c: Likewise.
+	* include/grub/powerpc/misc.h: Likewise.
+	* include/grub/i386/misc.h: Likewise.
+	* include/grub/sparc64/misc.h: Likewise.

Why don't you use trap.[ch]? Calling it misc is a bit too generic I think, and I'm afraid everyone put everything in it.

Quoted 3 lines

That was my intention. Our build system makes it too painful to introduce (then move and rename and remove) new files, and this didn't seem important enough to merit its own header anyways.

It's the current practise already. The disadvantage of adding things to misc.c is that everything will go in it and it will become a mess. Can you please rename these files before committing?

Quoted 8 lines
Quoted 8 lines

Review

Quoted 4 lines

+ grub_register_command ("memset", grub_cmd_memset, GRUB_COMMAND_FLAG_BOTH,

(quoted diff) +2 -0
+			 "memset address (value [len] | trap)",
+			 "Write a 32-bit quantity to memory.", 0);

This syntax is a bit unusual, I think (for a GNU program). Mainly because it has quite some conditional parameters. How about:

Quoted 8 lines
Quoted 5 lines

memset --value=len

or:

memset --trap

"memset --address=foo --value=bar --len=baz" and "memset --address=foo --value=trap"? Far too much typing for a very simple operation.

Can you come up with something better, but without conditional arguments?

Quoted 4 lines
Quoted 2 lines

Can you please explain what this command does? To be honest I don't really understand it immediately from the sourcecode. ;-)

It writes a value into a region of memory.

*G*

How about trap? I didn't understand that part. In that case you write the trap instruction to that address? Shouldn't you flush the instruction cache in that case?

Have you considered adding a feature so instead of an address a symbol name can be used? :-)

--
Marco

#6 lore raw
Quoted 3 lines · Marco Gerards

How about trap? I didn't understand that part. In that case you write the trap instruction to that address? Shouldn't you flush the instruction cache in that case?

Yes, and I do.

Quoted 2 lines

Have you considered adding a feature so instead of an address a symbol name can be used? :-)

So far I haven't wanted a feature like that, but in the future it could be added.

-Hollis

#7 lore raw
Quoted 7 lines · Hollis Blanchard
Quoted 3 lines · Marco Gerards

How about trap? I didn't understand that part. In that case you write the trap instruction to that address? Shouldn't you flush the instruction cache in that case?

Yes, and I do.

Oh, I must have read over it, sorry.

Quoted 5 lines
Quoted 2 lines

Have you considered adding a feature so instead of an address a symbol name can be used? :-)

So far I haven't wanted a feature like that, but in the future it could be added.

Right.

--
Marco