Skip to content

Commit

Permalink
peek and poke support
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrs committed Oct 17, 2012
1 parent efc7513 commit 1fdc18d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ int process_cmd(char * cmd) {
DEFINE_COMMAND(cmdline, kernel_cmdline);
DEFINE_COMMAND(boot, kernel_boot);
DEFINE_COMMAND(probemem, force_guess_memory);
DEFINE_COMMAND(poke, poke);
DEFINE_COMMAND(peek, peek);
/*
End command list. Do not add any more after here
*/
Expand Down
25 changes: 23 additions & 2 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void setget_mach(char * arg) {

void setget_phys(char * arg) {
unsigned start, size;
if ( (start = strtol(arg, &arg, 16)) && (size = strtol(arg, NULL, 16)) ) {
if ( (start = strtoul(arg, &arg, 16)) && (size = strtoul(arg, NULL, 16)) ) {
settings.phys.start = (void*)start;
settings.phys.size = size;
}
Expand All @@ -54,12 +54,33 @@ void setget_phys(char * arg) {

void setget_rdisksize(char * arg) {
unsigned num;
if ( (num = strtol(arg, NULL, 16)) ) {
if ( (num = strtoul(arg, NULL, 16)) ) {
settings.kernel_ramdisk_size = num;
}
printl("Kernel RAMDISK size set to %uK\n", settings.kernel_ramdisk_size);
}

void peek(char * arg) {
unsigned addr;
if ( (addr = strtoul(arg, NULL, 16)) ) {
if (addr & 0b11) {
printl("Warning: Address 0x%x is not word-aligned\n");
} else {
printl("*0x%x = 0x%x\n", addr, *(volatile unsigned*)addr);
}
}
}

void poke(char *arg) {
unsigned addr, value;
char *nextarg;
if ( (addr = strtoul(arg, &nextarg, 16)) && (value = strtoul(nextarg, NULL, 16)) ) {
if (!(addr & 0b11)) {
*(volatile unsigned*)addr = value;
}
}
peek(arg);
}

void dump_settings(char * ignored __attribute__((unused))) {
HEADER_LEVEL0(kernel);
Expand Down
3 changes: 3 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ void setget_mach(char * arg);
void setget_phys(char * arg);
void setget_rdisksize(char * arg);

void poke(char *arg);
void peek(char *arg);

#endif

0 comments on commit 1fdc18d

Please sign in to comment.