2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
8 #include <sys/ptrace.h>
14 void map(int fd, unsigned long virt, unsigned long phys, unsigned long len,
17 struct proc_mm_op map;
18 struct mem_region *region;
21 prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
23 region = phys_region(phys);
25 map = ((struct proc_mm_op) { .op = MM_MMAP,
34 .offset = phys_offset(phys)
36 n = os_write_file(fd, &map, sizeof(map));
38 printk("map : /proc/mm map failed, errno = %d\n", errno);
41 int unmap(int fd, void *addr, int len)
43 struct proc_mm_op unmap;
46 unmap = ((struct proc_mm_op) { .op = MM_MUNMAP,
49 { .addr = (unsigned long) addr,
51 n = os_write_file(fd, &unmap, sizeof(unmap));
52 if((n != 0) && (n != sizeof(unmap)))
57 int protect(int fd, unsigned long addr, unsigned long len, int r, int w,
58 int x, int must_succeed)
60 struct proc_mm_op protect;
63 prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
66 protect = ((struct proc_mm_op) { .op = MM_MPROTECT,
69 { .addr = (unsigned long) addr,
73 n = os_write_file(fd, &protect, sizeof(protect));
74 if((n != 0) && (n != sizeof(protect))){
76 panic("protect failed, errno = %d", errno);
82 void before_mem_skas(unsigned long unused)
87 * Overrides for Emacs so that we follow Linus's tabbing style.
88 * Emacs will notice this stuff at the end of the file and automatically
89 * adjust the settings for this buffer only. This must remain at the end
91 * ---------------------------------------------------------------------------
93 * c-file-style: "linux"