forked from fi01/android_run_root_shell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmm.c
76 lines (61 loc) · 1.92 KB
/
mm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/system_properties.h>
#include "kallsyms.h"
#include "mm.h"
typedef struct _supported_device {
const char *device;
const char *build_id;
unsigned long int remap_pfn_range_address;
} supported_device;
static supported_device supported_devices[] = {
{ "IS17SH", "01.00.04", 0xc0208a34 },
{ "SH-04E", "01.00.02", 0xc00e458c },
{ "SOL21", "9.1.D.0.395", 0xc010e33c },
{ "HTL21", "JRO03C", 0xc00ff32c },
{ "SC-04E", "JDQ39.SC04EOMUAMDI", 0xc011383c },
{ "SC-04E", "JDQ39.SC04EOMUAMF1", 0xc01138a4 },
{ "SC-04E", "JDQ39.SC04EOMUAMF2", 0xc01138a0 },
{ "SC-04E", "JDQ39.SC04EOMUAMG2", 0xc01138a8 },
};
static int n_supported_devices = sizeof(supported_devices) / sizeof(supported_devices[0]);
unsigned long int
_get_remap_pfn_range_address(void)
{
int i;
char device[PROP_VALUE_MAX];
char build_id[PROP_VALUE_MAX];
__system_property_get("ro.product.model", device);
__system_property_get("ro.build.display.id", build_id);
for (i = 0; i < n_supported_devices; i++) {
if (!strcmp(device, supported_devices[i].device) &&
!strcmp(build_id, supported_devices[i].build_id)) {
return supported_devices[i].remap_pfn_range_address;
}
}
printf("%s (%s) is not supported.\n", device, build_id);
return 0;
}
void *
get_remap_pfn_range_address(void)
{
if (kallsyms_exist()) {
return kallsyms_get_symbol_address("remap_pfn_range");
}
return (void*)_get_remap_pfn_range_address();
}
static unsigned long int kernel_phys_offset = 0;
void
set_kernel_phys_offset(unsigned long int offset)
{
kernel_phys_offset = offset;
}
#define PAGE_SHIFT 12
int
ptmx_mmap(struct file *filep, struct vm_area_struct *vma)
{
return remap_pfn_range(vma, vma->vm_start,
kernel_phys_offset >> PAGE_SHIFT,
vma->vm_end - vma->vm_start, vma->vm_page_prot);
}