From 58c1d2e9efc4909b0724a0b6821894589055ee5b Mon Sep 17 00:00:00 2001
From: 488_MP-4 <488_MP-4@iastate.edu>
Date: Wed, 6 Mar 2024 02:06:26 +0100
Subject: [PATCH] first write of mmap

---
 uboot-compiler/shmbuffer/main   | Bin 0 -> 16824 bytes
 uboot-compiler/shmbuffer/main.c |  31 +++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100755 uboot-compiler/shmbuffer/main
 create mode 100644 uboot-compiler/shmbuffer/main.c

diff --git a/uboot-compiler/shmbuffer/main b/uboot-compiler/shmbuffer/main
new file mode 100755
index 0000000000000000000000000000000000000000..d1a549d6ca963e6a11aeb791da7697669ee3c981
GIT binary patch
literal 16824
zcmeHOYitzP6~4P`g9)%U4>txHm{5=)$ZPYAA#vHYy=Gh)aKTP!6EYrq$9SuKIJ>jN
zj!NRj3CfDNK}w}IQKYy(suCqtsnk}`AJmA1rc#^2k5)8MDTzXBw<I+#iQETF&zU)A
zJu_ZYwQ7H54w^mpeD^%=oO@?{FLUpc(bi_a&nK7y;`0Kf(FzL*Q^nMFDgX<MI<XLb
zSBaHk4#*`YX4Qu+2DKJl@;iAM;Q`=iSA~Tl{IeD;m~#t}qup#Yf(-&<F6chct`sXs
zcJr&$PUc)+h$o>jkYxTA__L@0#N2L&O&O^+tHnsYllM`)e&TG0BHEoKyOU(ce1hUJ
z=X_#L@T#MHy14{(NRs(0gxl@_*|~WW=`+U|Nc*qqvHvDs8`<42nQnxea~$Rz?~7nZ
zU27Tsn_uqceH3rDe(0q9GpF>5nnb*7+m@O{tU3`-<@&4p>$X*I+Y-vALz~RV*e;BL
zV`|r)4gqdP5u-GkeX*2etpCx(Yu_(<-S^V&ww0G3UDjCoP~#hy*$2i%9VE2pA%QZM
z=fQ<K*8P7CN*0FvqV{$Y`E0ZYDx@Nn^8s621iy0@9PhQ5e(fyyR{)pbauYt!#rzBa
zF1eLKz8kL9MQ{QA(~aG+P4wmTtmw<cQ+kg`Ce=QX?$c62Q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dnIG+#4=MRbPxc^@R3~!O`dHpp)6TwcXvlH7hp998rdl4q>T8ncW_Q7^6F92i2
zI6lu4E6CohkFo5uh~krap^EMADIivX?d_b$j$JiO4m;_^a2HgD;Ntf1`xno^a@+0p
eBlw32Xot%=$F*v44qx2<ojOZnxy!&Mihlu2EY-LG

literal 0
HcmV?d00001

diff --git a/uboot-compiler/shmbuffer/main.c b/uboot-compiler/shmbuffer/main.c
new file mode 100644
index 000000000..0aadcad45
--- /dev/null
+++ b/uboot-compiler/shmbuffer/main.c
@@ -0,0 +1,31 @@
+#include<stdio.h>
+#include<stddef.h>
+#include<sys/mman.h>
+#include<fcntl.h>
+
+#define SHMADDR 0x3F000000
+
+int main(int argc, char *argv[])
+{
+    int fd;
+    int * memaddr;
+
+    fd = open("/dev/mem", O_RDWR);
+
+    if (fd == -1)
+    {
+        printf("can not access /dev/mem\n" );
+        return -1;
+    }
+
+    memaddr =
+    (int*)mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, SHMADDR);
+    if (memaddr == MAP_FAILED)
+    {
+        printf("mmap failed\n" );
+        return -1;
+    }
+    printf("value=%d\n", *memaddr);
+    
+
+}
\ No newline at end of file
-- 
GitLab