Last active
June 1, 2023 21:18
-
-
Save four0four/6bb30f67dff7e58664a4711eefde7cb8 to your computer and use it in GitHub Desktop.
Revisions
-
four0four revised this gist
Jun 1, 2023 . No changes.There are no files selected for viewing
-
four0four revised this gist
Jun 1, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) do_write = 1; } if((fd = open(filename, O_RDWR | O_SYNC)) == -1) exit(-1); //fprintf(stderr, "%s opened.\n", filename); -
four0four revised this gist
Jun 1, 2023 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,6 @@ int main(int argc, char* argv[]) int fd = -1; char *filename = argv[1]; uint32_t target = strtoul(argv[2], 0, 0); uint32_t writeval = 0; int do_write = 0; @@ -49,7 +48,7 @@ int main(int argc, char* argv[]) void *map_base = mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); //fprintf(stderr, "%p\n", map_base); -
four0four created this gist
Jun 1, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ /* smutool Tool for SMU * Copyright (C) 2015 Damien Zammit <[email protected]> * Copyright (C) 2023 Sheep Sun <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * See <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <inttypes.h> #include <pci/pci.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/io.h> #include <stdlib.h> #include <unistd.h> #define SMU_DATA 0x204 #define SMU_ADDR 0x200 int main(int argc, char* argv[]) { int fd = -1; char *filename = argv[1]; uint32_t target = strtoul(argv[2], 0, 0); size_t map_size = 0x1000; uint32_t writeval = 0; int do_write = 0; if(argc > 3) { writeval = strtoul(argv[3], 0, 0); do_write = 1; } if((fd = open(filename, O_RDWR | O_SYNC)) == -1) exit(-1); //fprintf(stderr, "%s opened.\n", filename); void *map_base = mmap(0, map_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); //fprintf(stderr, "%p\n", map_base); volatile uint32_t *smu_data_m = map_base + SMU_DATA; volatile uint32_t *smu_addr_m = map_base + SMU_ADDR; if (do_write == 0) { *smu_addr_m = target; uint32_t res = *smu_data_m; //fprintf(stderr, "[%p] -> 0x%08x\n",target, res) ; printf("0x%08x\n",res); } else { *smu_addr_m = target; *smu_data_m = writeval; //fprintf(stderr, "0x%08x -> [%p] (-> 0x%08x)\n", writeval, target, *smu_data_m); } //fprintf(stderr, "exiting\n"); return 0; }