1 /** 2 * Copyright (C) 2017 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 17 #define _GNU_SOURCE 18 #include <sys/types.h> 19 20 #include <asm/ioctl.h> 21 #include <errno.h> 22 #include <fcntl.h> 23 #include <stdio.h> 24 #include <stdlib.h> 25 #include <string.h> 26 #include <sys/mman.h> 27 #include <sys/wait.h> 28 #include <unistd.h> 29 30 char *pci_msm_path = "/sys/kernel/debug/pci-msm/"; 31 32 #define SIZE 64 33 34 int write_file(int fd, char *str) { 35 int ret; 36 ret = write(fd, str, SIZE); 37 return 0; 38 } 39 40 int open_file(char *filename) { 41 int fd; 42 char file[125] = {0}; 43 44 sprintf(file, "%s%s", pci_msm_path, filename); 45 46 fd = open(file, O_RDWR); 47 if (fd < 0) { 48 exit(1); 49 } 50 return fd; 51 } 52 53 void set_aer_enable() { 54 int fd; 55 char buf[SIZE] = {0}; 56 57 fd = open_file("aer_enable"); 58 59 write_file(fd, buf); 60 61 close(fd); 62 } 63 64 void set_wr_offset() { 65 int fd; 66 char buf[SIZE] = {0}; 67 68 fd = open_file("wr_offset"); 69 70 sprintf(buf, "%s", "9999999"); 71 72 write_file(fd, buf); 73 74 close(fd); 75 } 76 77 void set_test_case() { 78 int fd; 79 char buf[SIZE] = {0}; 80 buf[0] = '1'; 81 buf[1] = '2'; 82 83 fd = open_file("case"); 84 85 write_file(fd, buf); 86 87 close(fd); 88 } 89 90 void set_base_sel() { 91 int fd; 92 char buf[SIZE] = {0}; 93 buf[0] = '1'; 94 95 fd = open_file("base_sel"); 96 97 write_file(fd, buf); 98 99 close(fd); 100 } 101 102 int main(int argc, char *argv[]) { 103 set_wr_offset(); 104 set_base_sel(); 105 set_test_case(); 106 return 0; 107 } 108