From 13b2ac642a8476f1ed06234de11428fe6136ee1c Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 1 Mar 2016 21:36:53 +0300 Subject: [PATCH 1/7] Add makefile --- Makefile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..53f0afd --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +CPPFLAGS=-Wall -O2 + +main: main.c From cdb273007752665586549715114bc5dfab6a6f10 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 1 Mar 2016 21:38:50 +0300 Subject: [PATCH 2/7] Fix compilation on 32bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 53f0afd..0a9b996 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,3 @@ -CPPFLAGS=-Wall -O2 +CPPFLAGS=-Wall -O2 -msse2 main: main.c From 47dcbe79491c57be0d3266ba78687fb1f354bc2c Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 1 Mar 2016 22:08:43 +0300 Subject: [PATCH 3/7] add make clean target --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 0a9b996..3c1b7b5 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ CPPFLAGS=-Wall -O2 -msse2 main: main.c + +.PHONY: clean + +clean: + rm -f main From 3b662e133e81f4bcfc9836c6ae5cdbdd0ddeeeac Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 1 Mar 2016 22:27:35 +0300 Subject: [PATCH 4/7] Compiles on both linux and mach --- main.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/main.c b/main.c index 5218224..31d59c2 100644 --- a/main.c +++ b/main.c @@ -4,10 +4,44 @@ #include #include +#include +#include +#ifdef __MACH__ #include #include +#endif #include +#ifndef NSEC_PER_SEC +#define NSEC_PER_SEC 1000000000ull +#endif + +#ifndef __MACH__ +typedef struct timespec mach_timespec_t; +typedef unsigned int mach_port_t; + +static inline uint64_t mach_absolute_time(void) { + mach_timespec_t tp; + int res = clock_gettime(CLOCK_MONOTONIC_RAW, &tp); + if (res < 0) { + perror("clock_gettime"); + exit(1); + } + uint64_t result = tp.tv_sec * NSEC_PER_SEC; + result += tp.tv_nsec; + return result; +} + +static inline void nanosleep_for(time_t sec, long nsec, mach_timespec_t *remain) { + mach_timespec_t req = { sec, nsec }; + int res = nanosleep(&req, remain); + if (res < 0) { + perror("nanosleep"); + exit(1); + } +} +#endif // __MACH__ + __m128i reg; __m128i reg_zero; __m128i reg_one; @@ -28,17 +62,23 @@ static inline void square_am_signal(float time, float frequency) { _mm_stream_si128(®, reg_one); _mm_stream_si128(®, reg_zero); } +#ifdef __MACH__ clock_sleep_trap(clock_port, TIME_ABSOLUTE, reset / NSEC_PER_SEC, reset % NSEC_PER_SEC, &remain); +#else + nanosleep_for((period / 2) / NSEC_PER_SEC, (period / 2) % NSEC_PER_SEC, &remain); +#endif start = reset; } } int main() { +#ifdef __MACH__ mach_timebase_info_data_t theTimeBaseInfo; mach_timebase_info(&theTimeBaseInfo); puts("TESTING TIME BASE: the following should be 1 / 1"); printf(" Mach base: %u / %u nanoseconds\n\n", theTimeBaseInfo.numer, theTimeBaseInfo.denom); +#endif uint64_t start = mach_absolute_time(); uint64_t end = mach_absolute_time(); From 79e708aaf3a168104129ef4ba607781bb32ce6c9 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 1 Mar 2016 22:29:27 +0300 Subject: [PATCH 5/7] Fix compilation warning --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 31d59c2..39a8345 100644 --- a/main.c +++ b/main.c @@ -82,7 +82,7 @@ int main() uint64_t start = mach_absolute_time(); uint64_t end = mach_absolute_time(); - printf("TESTING TIME TO EXECUTE mach_absolute_time()\n Result: %lld nanoseconds\n\n", end - start); + printf("TESTING TIME TO EXECUTE mach_absolute_time()\n Result: %"PRIu64" nanoseconds\n\n", end - start); reg_zero = _mm_set_epi32(0, 0, 0, 0); reg_one = _mm_set_epi32(-1, -1, -1, -1); From 522abdf570d0e5a949b86f9c2822d5ae4e03a728 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Wed, 2 Mar 2016 20:02:36 +0300 Subject: [PATCH 6/7] Use absolute time as per PR#3. https://github.com/fulldecent/system-bus-radio/pull/3 --- main.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 39a8345..3ff20bb 100644 --- a/main.c +++ b/main.c @@ -17,12 +17,13 @@ #endif #ifndef __MACH__ +#define TIME_ABSOLUTE CLOCK_REALTIME typedef struct timespec mach_timespec_t; typedef unsigned int mach_port_t; static inline uint64_t mach_absolute_time(void) { mach_timespec_t tp; - int res = clock_gettime(CLOCK_MONOTONIC_RAW, &tp); + int res = clock_gettime(CLOCK_REALTIME, &tp); if (res < 0) { perror("clock_gettime"); exit(1); @@ -32,11 +33,12 @@ static inline uint64_t mach_absolute_time(void) { return result; } -static inline void nanosleep_for(time_t sec, long nsec, mach_timespec_t *remain) { +// non-conformant wrapper just for the purposes of this application +static inline void clock_sleep_trap(mach_port_t clock_port, int sleep_type, time_t sec, long nsec, mach_timespec_t *remain) { mach_timespec_t req = { sec, nsec }; - int res = nanosleep(&req, remain); + int res = clock_nanosleep(sleep_type, TIMER_ABSTIME, &req, remain); if (res < 0) { - perror("nanosleep"); + perror("clock_nanosleep"); exit(1); } } @@ -62,11 +64,7 @@ static inline void square_am_signal(float time, float frequency) { _mm_stream_si128(®, reg_one); _mm_stream_si128(®, reg_zero); } -#ifdef __MACH__ clock_sleep_trap(clock_port, TIME_ABSOLUTE, reset / NSEC_PER_SEC, reset % NSEC_PER_SEC, &remain); -#else - nanosleep_for((period / 2) / NSEC_PER_SEC, (period / 2) % NSEC_PER_SEC, &remain); -#endif start = reset; } } From 054aae4ddb72b12f81355f3d1c8e0fbc8bcdf92f Mon Sep 17 00:00:00 2001 From: William Entriken Date: Fri, 4 Mar 2016 17:31:51 -0500 Subject: [PATCH 7/7] move to _mm_stream_si128 folder --- README.md | 4 ++-- Makefile => Using _mm_stream_si128/Makefile | 0 Using _mm_stream_si128/main | Bin 0 -> 17064 bytes main.c => Using _mm_stream_si128/main.c | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename Makefile => Using _mm_stream_si128/Makefile (100%) create mode 100755 Using _mm_stream_si128/main rename main.c => Using _mm_stream_si128/main.c (100%) diff --git a/README.md b/README.md index ce33b33..42d900f 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Publicly available documents already discuss exfiltration from secured systems u How to Use It ------------------ -Compile the program using: +Compile the program using make: - gcc main.c -Wall -O2 -o main + make And run it on an Apple MacBook Air (13-inch, Early 2015): diff --git a/Makefile b/Using _mm_stream_si128/Makefile similarity index 100% rename from Makefile rename to Using _mm_stream_si128/Makefile diff --git a/Using _mm_stream_si128/main b/Using _mm_stream_si128/main new file mode 100755 index 0000000000000000000000000000000000000000..140a798c82de1f96af24d77f6f2871d78cf88407 GIT binary patch literal 17064 zcmeI4YitzP702&_H#`g((>x#n;wgg4ylmXiiig2oz+xQM7_cdXM}{@t#TM&bXLnu9 z)24wmj^o&=kXk~CorIgEO0sv7fG#dKTuyXQ;! z4t^L6qz%(!$WOW#PEJi%S5>32%Hn9}uK4;UrR({g5)p=POz11}JtTJM`P5Q>u)-g~ zzW98LMZOs#o_ylo+3u@vWjGYQ_XEf0YZm#kL;~`0E_-aMx-uGzl!aD_i1>ULM83mf zocyk>Tdf#S)ymMCvQUXy77Bzlzx(-U&d~YM8lpyid=7m?S5@_ws)2~F+;8~Z^Kp@H zh?qqFgMMCGcayLnRCSi8$Rj3EhxMhcyA-j{SbxH&^+tJ(+^QN1s?oLO#o?e@5sUPg z&qzo4jk$CLS|7BIji#zW--Gg{V7|7F#RT%Z=A-(I&jf|wyoSrm!yyrVUwt_upK%^2 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bGPQV1U7VcOwQhH9+ySdVC)PPJx03?5c~ zzjR1F@%XOJ!JUna#6zX@7ZA=*Koa6H5-9|a;V|v+cox-I=dl{m{3)t66=Lu>8Pa~= z?)*Hd=fB6UwmvBRM+oQpAqnvqh7^LwK$v!T!L-9;G*DXSF_q5UKX7}NUxyex zto*(`hA zyorj5$3a9859;|ck~xrscAhBTPFy_MsZoyQ(T^XKr08CM|&4=cZ4G7xXRKIWrh;t@s!@mNFY2aw!#CCH-) zvjvZQn09#7q8jTwb|9M1MVY(+V(_r?c}YdQIS&si*476ih)0;xe~lYQyd9Fz`tTw} zKniO&q_SXJ0D>D*Ik+q5UW;n1^Qc2KpH8)AL%>6N;TKyecwi=Ny+h6J!^$Du%71R+Rt{=V|hNrM&)OPfZrL^MIVuacvs;mTl%T1bN0a;mxzbo;C zD5IOJTI<^5ENah~PDD@J65O4@M1RMem0f&G?z#-rea0oaA90K2J z0)s}RETjSl<*h7@?~mbS*`HHyk5r7^%R^=dl3AO(3r_7KM%GQt^Itl3HG>`m6ja=^{$0-$!L+ zmix*=><4-c72!yXO^NtfHeCSe%^F8S4z0jDwX4`OT3}gkc6tSpEnvOEAwN^s`6FS5 ztFM1qfyf&qH9kzmM6FR8$%SVe(CE4co~C0GF1#4;OOGHQ1D*e`fEb@QL609V{1w9g zq3|n&pCkMl;VbZwjt-?Yy4=;(55@UEiSu8M^Bd!Q+%3`Gv&LODM%RyUx6ye2Imc{F z#+%~zGZ$xEqm8o+{%XX(N)uJ13Qs4C{rdQQYs74I==-{_3u8s-YvI0Ci2AAh52PF$ AxBvhE literal 0 HcmV?d00001 diff --git a/main.c b/Using _mm_stream_si128/main.c similarity index 100% rename from main.c rename to Using _mm_stream_si128/main.c