#include <stdio.h>
#include <smem.h>
Include dependency graph for poke.c:
Go to the source code of this file.
Defines | |
#define | NAME "RAM" |
Functions | |
void * | ram_get (char *name, long int base, long int size) |
void | ram_free (char *name, long int base) |
int | main (int argc, char **argv) |
|
|
|
Definition at line 7 of file poke.c. Referenced by main().
00008 { 00009 void *ram; 00010 00011 /* remove any previous defs of phys mem */ 00012 smem_remove(name); 00013 00014 if ((ram = (void *) 00015 smem_create(name, (char *) base, size, SM_READ | SM_WRITE)) == NULL) 00016 { 00017 perror("can't get physical memory"); 00018 return (void *) 0; 00019 } 00020 00021 return ram; 00022 } |
|
Definition at line 24 of file poke.c. Referenced by main().
00025 { 00026 smem_create("", (char *) base, (long int) 0, SM_DETACH); 00027 smem_remove(name); 00028 } |
|
Definition at line 30 of file poke.c. 00031 { 00032 int value; 00033 long int addr; 00034 void *ram; 00035 static char syntax[] = "syntax: %s <addr> <value>\n"; 00036 00037 if (argc != 3) 00038 { 00039 printf(syntax, argv[0]); 00040 exit(1); 00041 } 00042 00043 if (sscanf(argv[1], "%x", &addr) != 1) 00044 { 00045 printf(syntax, argv[0]); 00046 exit(1); 00047 } 00048 00049 if (sscanf(argv[2], "%x", &value) != 1) 00050 { 00051 printf(syntax, argv[0]); 00052 exit(1); 00053 } 00054 00055 /* get RAM */ 00056 ram = ram_get(NAME, addr, sizeof(int)); 00057 00058 /* write the value */ 00059 *((char *) ram) = value; 00060 00061 printf("wrote %X to %X\n", (int) *((char *) ram), addr); 00062 00063 ram_free(NAME, addr); 00064 00065 return 0; 00066 } |