BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / commit / 03048a95d88cc7a78171393371f5c22a0250a014 / stdio / dbgprintf.c

// Related

OrionLibC

Barry Importing existing Orion LibC 03048a9 (2 years, 2 months ago)
diff --git a/stdio/dbgprintf.c b/stdio/dbgprintf.c
new file mode 100644
index 0000000..c1f5729
--- /dev/null
+++ b/stdio/dbgprintf.c
@@ -0,0 +1,30 @@
+#include <stdarg.h>
+#include <sys/syscall.h>
+
+int vsprintf(char *buf, const char *fmt, va_list args);
+
+/* Send message to Kernel Output */
+void
+dbgprintf(char *fmt, ...)
+{
+	char buf[1024];
+	va_list args;
+	va_start(args, fmt);
+	vsprintf(buf, fmt, args);
+	va_end(args);
+
+	int ret;
+	char *p = buf;
+	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_DBGPRINTF),
+	             "c" (1), "S" (&p));
+}
+
+/* Send an unformatted message to Kernel Output */
+void
+dbgputs(char *str)
+{
+	int ret;
+	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_DBGPRINTF),
+	             "c" (1), "S" (&str));
+
+}