2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
14 void map(int fd
, unsigned long virt
, unsigned long len
, int r
, int w
,
15 int x
, int phys_fd
, unsigned long long offset
)
17 struct proc_mm_op map
;
20 prot
= (r
? PROT_READ
: 0) | (w
? PROT_WRITE
: 0) |
23 map
= ((struct proc_mm_op
) { .op
= MM_MMAP
,
34 n
= os_write_file(fd
, &map
, sizeof(map
));
36 printk("map : /proc/mm map failed, err = %d\n", -n
);
39 int unmap(int fd
, void *addr
, unsigned long len
)
41 struct proc_mm_op unmap
;
44 unmap
= ((struct proc_mm_op
) { .op
= MM_MUNMAP
,
47 { .addr
= (unsigned long) addr
,
49 n
= os_write_file(fd
, &unmap
, sizeof(unmap
));
50 if(n
!= sizeof(unmap
)) {
60 int protect(int fd
, unsigned long addr
, unsigned long len
, int r
, int w
,
61 int x
, int must_succeed
)
63 struct proc_mm_op protect
;
66 prot
= (r
? PROT_READ
: 0) | (w
? PROT_WRITE
: 0) |
69 protect
= ((struct proc_mm_op
) { .op
= MM_MPROTECT
,
72 { .addr
= (unsigned long) addr
,
76 n
= os_write_file(fd
, &protect
, sizeof(protect
));
77 if(n
!= sizeof(protect
)) {
81 panic("protect failed, err = %d", -n
);
89 void before_mem_skas(unsigned long unused
)
94 * Overrides for Emacs so that we follow Linus's tabbing style.
95 * Emacs will notice this stuff at the end of the file and automatically
96 * adjust the settings for this buffer only. This must remain at the end
98 * ---------------------------------------------------------------------------
100 * c-file-style: "linux"