summaryrefslogtreecommitdiffstats
path: root/arch/um/util
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/util')
-rw-r--r--arch/um/util/Makefile8
-rw-r--r--arch/um/util/mk_constants_kern.c28
-rw-r--r--arch/um/util/mk_constants_user.c28
-rw-r--r--arch/um/util/mk_task_kern.c17
-rw-r--r--arch/um/util/mk_task_user.c30
5 files changed, 111 insertions, 0 deletions
diff --git a/arch/um/util/Makefile b/arch/um/util/Makefile
new file mode 100644
index 00000000000..e2ab71209f3
--- /dev/null
+++ b/arch/um/util/Makefile
@@ -0,0 +1,8 @@
+hostprogs-y := mk_task mk_constants
+always := $(hostprogs-y)
+
+mk_task-objs := mk_task_user.o mk_task_kern.o
+mk_constants-objs := mk_constants_user.o mk_constants_kern.o
+
+HOSTCFLAGS_mk_task_kern.o := $(CFLAGS) $(CPPFLAGS)
+HOSTCFLAGS_mk_constants_kern.o := $(CFLAGS) $(CPPFLAGS)
diff --git a/arch/um/util/mk_constants_kern.c b/arch/um/util/mk_constants_kern.c
new file mode 100644
index 00000000000..cdcb1232a1e
--- /dev/null
+++ b/arch/um/util/mk_constants_kern.c
@@ -0,0 +1,28 @@
+#include "linux/kernel.h"
+#include "linux/stringify.h"
+#include "linux/time.h"
+#include "asm/page.h"
+
+extern void print_head(void);
+extern void print_constant_str(char *name, char *value);
+extern void print_constant_int(char *name, int value);
+extern void print_tail(void);
+
+int main(int argc, char **argv)
+{
+ print_head();
+ print_constant_int("UM_KERN_PAGE_SIZE", PAGE_SIZE);
+
+ print_constant_str("UM_KERN_EMERG", KERN_EMERG);
+ print_constant_str("UM_KERN_ALERT", KERN_ALERT);
+ print_constant_str("UM_KERN_CRIT", KERN_CRIT);
+ print_constant_str("UM_KERN_ERR", KERN_ERR);
+ print_constant_str("UM_KERN_WARNING", KERN_WARNING);
+ print_constant_str("UM_KERN_NOTICE", KERN_NOTICE);
+ print_constant_str("UM_KERN_INFO", KERN_INFO);
+ print_constant_str("UM_KERN_DEBUG", KERN_DEBUG);
+
+ print_constant_int("UM_NSEC_PER_SEC", NSEC_PER_SEC);
+ print_tail();
+ return(0);
+}
diff --git a/arch/um/util/mk_constants_user.c b/arch/um/util/mk_constants_user.c
new file mode 100644
index 00000000000..8f4d7e50be7
--- /dev/null
+++ b/arch/um/util/mk_constants_user.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+void print_head(void)
+{
+ printf("/*\n");
+ printf(" * Generated by mk_constants\n");
+ printf(" */\n");
+ printf("\n");
+ printf("#ifndef __UM_CONSTANTS_H\n");
+ printf("#define __UM_CONSTANTS_H\n");
+ printf("\n");
+}
+
+void print_constant_str(char *name, char *value)
+{
+ printf("#define %s \"%s\"\n", name, value);
+}
+
+void print_constant_int(char *name, int value)
+{
+ printf("#define %s %d\n", name, value);
+}
+
+void print_tail(void)
+{
+ printf("\n");
+ printf("#endif\n");
+}
diff --git a/arch/um/util/mk_task_kern.c b/arch/um/util/mk_task_kern.c
new file mode 100644
index 00000000000..c218103315e
--- /dev/null
+++ b/arch/um/util/mk_task_kern.c
@@ -0,0 +1,17 @@
+#include "linux/sched.h"
+#include "linux/stddef.h"
+
+extern void print(char *name, char *type, int offset);
+extern void print_ptr(char *name, char *type, int offset);
+extern void print_head(void);
+extern void print_tail(void);
+
+int main(int argc, char **argv)
+{
+ print_head();
+ print_ptr("TASK_REGS", "union uml_pt_regs",
+ offsetof(struct task_struct, thread.regs));
+ print("TASK_PID", "int", offsetof(struct task_struct, pid));
+ print_tail();
+ return(0);
+}
diff --git a/arch/um/util/mk_task_user.c b/arch/um/util/mk_task_user.c
new file mode 100644
index 00000000000..9db849f3f3a
--- /dev/null
+++ b/arch/um/util/mk_task_user.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+
+void print(char *name, char *type, int offset)
+{
+ printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
+ offset);
+}
+
+void print_ptr(char *name, char *type, int offset)
+{
+ printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type,
+ offset);
+}
+
+void print_head(void)
+{
+ printf("/*\n");
+ printf(" * Generated by mk_task\n");
+ printf(" */\n");
+ printf("\n");
+ printf("#ifndef __TASK_H\n");
+ printf("#define __TASK_H\n");
+ printf("\n");
+}
+
+void print_tail(void)
+{
+ printf("\n");
+ printf("#endif\n");
+}