[klibc] [WIP] klibc for m68k

Kyle McMartin kyle at mcmartin.ca
Mon Jan 30 18:46:13 PST 2006


m68k is the only debian arch still lacking a klibc port... So I started
working on this tonight, despite not knowing anything about the m68k.

Puzzling out the details, and disassembling things, I've at least
got a syscall.c that looks like it might work. I don't really have time
to do this bring up, but maybe someone else would like to finish the
work.

I guess this needs at least, setjmp/longjmp, crt0, and sysstub.ph
to be useful. If nobody steps up in the next little while, I'll see
what I can do. 

The usefulness of all this is very debatable, but might as well
have a complete set of ports.

Cheers,
	Kyle

diff --git a/klibc/arch/m68k/syscall.c b/klibc/arch/m68k/syscall.c
new file mode 100644
index 0000000..6706379
--- /dev/null
+++ b/klibc/arch/m68k/syscall.c
@@ -0,0 +1,31 @@
+/* klibc/arch/m68k/syscall.c
+ *
+ * Copyright (C) 2006, Kyle McMartin <kyle at parisc-linux.org>
+ *
+ */
+
+long
+m68k_syscall(long nr, long a0, long a1, long a2, long a3, long a4, long a5)
+{
+	long ret;
+	register long num __asm__("%d0") = nr;
+	register long arg0 __asm__("%d1") = a0;
+	register long arg1 __asm__("%d2") = a1;
+	register long arg2 __asm__("%d3") = a2;
+	register long arg3 __asm__("%d4") = a3;
+	register long arg4 __asm__("%d5") = a4;
+	register long arg5 __asm__("%a0") = a5;
+
+	__asm__ __volatile__ (
+		"trap #0\n\t"
+		"move,l %%d0,%0\n\t"
+		: "=g"(ret)
+		: : "cc", "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%a0");
+
+	if ((unsigned long)ret >= (unsigned long)(-125)) {
+		errno = -(ret);
+		ret = -1;
+	}
+
+	return ret;
+}



More information about the klibc mailing list