summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Perfetto <josh@snowrise.com>2011-08-08 14:48:15 -0700
committerJosh Perfetto <josh@snowrise.com>2011-08-08 14:48:15 -0700
commit66ab1c0c59a3a599d7adefebb1bd9ddf2cd82b2a (patch)
tree60e10be8aed7cf69ed72882683936f320e9afb7f
parent7e4ec0964f57fb0584b033c6c85cae77eb42a7d6 (diff)
downloadopenpcr-66ab1c0c59a3a599d7adefebb1bd9ddf2cd82b2a.tar.gz
openpcr-66ab1c0c59a3a599d7adefebb1bd9ddf2cd82b2a.zip
Add Linux NCC
-rwxr-xr-xncc/unix/bin/nccbin0 -> 7855 bytes
-rw-r--r--ncc/unix/main.cpp29
2 files changed, 29 insertions, 0 deletions
diff --git a/ncc/unix/bin/ncc b/ncc/unix/bin/ncc
new file mode 100755
index 0000000..7a50b39
--- /dev/null
+++ b/ncc/unix/bin/ncc
Binary files differ
diff --git a/ncc/unix/main.cpp b/ncc/unix/main.cpp
new file mode 100644
index 0000000..4d23a69
--- /dev/null
+++ b/ncc/unix/main.cpp
@@ -0,0 +1,29 @@
+#include <iostream>
+#include <fcntl.h>
+
+char buf[4096] __attribute__((aligned (16)));
+
+int main (int argc, char * const argv[]) {
+ if (argc != 2) {
+ std::cout << "Incorrect usage\n";
+ return 0;
+ }
+
+ //align buffer to 4096 boundary. Linker alignment limited this to 128 bytes, so doing it
+ //brute-force as have tons of memory to waste
+ char buf[8192];
+ char* pBuf = (char*)(((unsigned int)&buf / 4096) * 4096 + 4096);
+
+ int fHandle;
+ if (fHandle = open(argv[1], O_RDONLY | O_DIRECT)) {
+ int bytesRead = read(fHandle, pBuf, 4096);
+ pBuf[bytesRead] = '\0';
+ std::cout << pBuf;
+ } else {
+ std::cerr << "Failed to open direct access";
+ }
+ close(fHandle);
+
+ return 0;
+}
+