summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-02-04 16:21:10 +0100
committerRichard Braun <rbraun@sceen.net>2017-02-04 16:21:10 +0100
commit7a00044da882d30b1dea8757c7f6a1ccaa9ee08d (patch)
tree9e342eca8a673ac9b0982c3e4bda22ff5158690e
parentd09b913612712c7d58e5ee3ee20703cce63ad0b0 (diff)
kern/types: split into module-specific type headers
Using a single header for all types causing inclusion circular dependencies isn't very elegant and doesn't scale.
-rw-r--r--Makefrag.am4
-rw-r--r--arch/x86/machine/acpimp.c2
-rw-r--r--arch/x86/machine/biosmem.c2
-rw-r--r--arch/x86/machine/biosmem.h2
-rw-r--r--arch/x86/machine/pmap.c2
-rw-r--r--arch/x86/machine/pmap.h2
-rw-r--r--arch/x86/machine/strace.c2
-rw-r--r--kern/condition.c1
-rw-r--r--kern/condition.h5
-rw-r--r--kern/condition_types.h (renamed from kern/types.h)34
-rw-r--r--kern/mutex.c1
-rw-r--r--kern/mutex.h2
-rw-r--r--kern/mutex_i.h2
-rw-r--r--kern/mutex_types.h33
-rw-r--r--kern/spinlock.h2
-rw-r--r--kern/spinlock_i.h2
-rw-r--r--kern/spinlock_types.h28
-rw-r--r--kern/thread.h6
-rw-r--r--kern/thread_i.h3
-rw-r--r--vm/vm_kmem.c2
-rw-r--r--vm/vm_kmem.h2
-rw-r--r--vm/vm_page.c2
-rw-r--r--vm/vm_page.h2
23 files changed, 95 insertions, 48 deletions
diff --git a/Makefrag.am b/Makefrag.am
index 519f40c0..c52381e2 100644
--- a/Makefrag.am
+++ b/Makefrag.am
@@ -7,6 +7,7 @@ x15_SOURCES += \
kern/bitmap_i.h \
kern/condition.c \
kern/condition.h \
+ kern/condition_types.h \
kern/config.h \
kern/cpumap.c \
kern/cpumap.h \
@@ -30,6 +31,7 @@ x15_SOURCES += \
kern/mutex.c \
kern/mutex.h \
kern/mutex_i.h \
+ kern/mutex_types.h \
kern/panic.c \
kern/panic.h \
kern/param.h \
@@ -45,6 +47,7 @@ x15_SOURCES += \
kern/rdxtree_i.h \
kern/spinlock.h \
kern/spinlock_i.h \
+ kern/spinlock_types.h \
kern/sprintf.c \
kern/sprintf.h \
kern/sref.c \
@@ -59,7 +62,6 @@ x15_SOURCES += \
kern/thread.c \
kern/thread.h \
kern/thread_i.h \
- kern/types.h \
kern/work.c \
kern/work.h \
kern/xcall.c \
diff --git a/arch/x86/machine/acpimp.c b/arch/x86/machine/acpimp.c
index e88e7650..ef93bc43 100644
--- a/arch/x86/machine/acpimp.c
+++ b/arch/x86/machine/acpimp.c
@@ -24,12 +24,12 @@
#include <kern/stddef.h>
#include <kern/stdint.h>
#include <kern/string.h>
-#include <kern/types.h>
#include <machine/acpimp.h>
#include <machine/biosmem.h>
#include <machine/cpu.h>
#include <machine/io.h>
#include <machine/lapic.h>
+#include <machine/types.h>
#include <vm/vm_kmem.h>
/*
diff --git a/arch/x86/machine/biosmem.c b/arch/x86/machine/biosmem.c
index 539ea3ac..6e6410cf 100644
--- a/arch/x86/machine/biosmem.c
+++ b/arch/x86/machine/biosmem.c
@@ -26,11 +26,11 @@
#include <kern/stddef.h>
#include <kern/stdint.h>
#include <kern/string.h>
-#include <kern/types.h>
#include <machine/biosmem.h>
#include <machine/boot.h>
#include <machine/cpu.h>
#include <machine/multiboot.h>
+#include <machine/types.h>
#include <vm/vm_kmem.h>
#include <vm/vm_page.h>
diff --git a/arch/x86/machine/biosmem.h b/arch/x86/machine/biosmem.h
index a8b78e8a..19ec2cda 100644
--- a/arch/x86/machine/biosmem.h
+++ b/arch/x86/machine/biosmem.h
@@ -20,8 +20,8 @@
#include <stdbool.h>
-#include <kern/types.h>
#include <machine/multiboot.h>
+#include <machine/types.h>
/*
* Address where the address of the Extended BIOS Data Area segment can be
diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c
index 888445b0..ea49856e 100644
--- a/arch/x86/machine/pmap.c
+++ b/arch/x86/machine/pmap.c
@@ -36,13 +36,13 @@
#include <kern/stddef.h>
#include <kern/string.h>
#include <kern/thread.h>
-#include <kern/types.h>
#include <machine/biosmem.h>
#include <machine/boot.h>
#include <machine/cpu.h>
#include <machine/lapic.h>
#include <machine/pmap.h>
#include <machine/trap.h>
+#include <machine/types.h>
#include <vm/vm_kmem.h>
#include <vm/vm_page.h>
#include <vm/vm_prot.h>
diff --git a/arch/x86/machine/pmap.h b/arch/x86/machine/pmap.h
index 772eaf08..1806a6fb 100644
--- a/arch/x86/machine/pmap.h
+++ b/arch/x86/machine/pmap.h
@@ -101,9 +101,9 @@
#include <kern/mutex.h>
#include <kern/stdint.h>
#include <kern/thread.h>
-#include <kern/types.h>
#include <machine/cpu.h>
#include <machine/trap.h>
+#include <machine/types.h>
/*
* Mapping creation flags.
diff --git a/arch/x86/machine/strace.c b/arch/x86/machine/strace.c
index 80849acf..e65efb08 100644
--- a/arch/x86/machine/strace.c
+++ b/arch/x86/machine/strace.c
@@ -21,11 +21,11 @@
#include <kern/printk.h>
#include <kern/stddef.h>
#include <kern/string.h>
-#include <kern/types.h>
#include <machine/elf.h>
#include <machine/multiboot.h>
#include <machine/pmap.h>
#include <machine/strace.h>
+#include <machine/types.h>
#include <vm/vm_kmem.h>
#ifdef __LP64__
diff --git a/kern/condition.c b/kern/condition.c
index 2c233df0..7d83f47d 100644
--- a/kern/condition.c
+++ b/kern/condition.c
@@ -30,7 +30,6 @@
#include <kern/spinlock.h>
#include <kern/stddef.h>
#include <kern/thread.h>
-#include <kern/types.h>
void
condition_wait(struct condition *condition, struct mutex *mutex)
diff --git a/kern/condition.h b/kern/condition.h
index 3de39be2..4e7f7f0f 100644
--- a/kern/condition.h
+++ b/kern/condition.h
@@ -21,13 +21,10 @@
#ifndef _KERN_CONDITION_H
#define _KERN_CONDITION_H
+#include <kern/condition_types.h>
#include <kern/list.h>
-#include <kern/mutex.h>
#include <kern/spinlock.h>
#include <kern/stddef.h>
-#include <kern/types.h>
-
-struct condition;
static inline void
condition_init(struct condition *condition)
diff --git a/kern/types.h b/kern/condition_types.h
index fa13ef7a..9f68bf44 100644
--- a/kern/types.h
+++ b/kern/condition_types.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2014 Richard Braun.
+ * Copyright (c) 2017 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -13,33 +13,17 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Isolated type definition used to avoid inclusion circular dependencies.
*/
-#ifndef _KERN_TYPES_H
-#define _KERN_TYPES_H
-
-#include <machine/types.h>
-
-/*
- * Forward declarations.
- */
-struct task;
-
-/*
- * Types defined here to avoid inclusion loops.
- */
+#ifndef _KERN_CONDITION_TYPES_H
+#define _KERN_CONDITION_TYPES_H
#include <kern/list.h>
-
-struct spinlock {
- unsigned int locked;
-};
-
-struct mutex {
- unsigned int state;
- struct spinlock lock;
- struct list waiters;
-};
+#include <kern/mutex_types.h>
+#include <kern/spinlock_types.h>
struct condition {
struct spinlock lock;
@@ -47,4 +31,4 @@ struct condition {
struct list waiters;
};
-#endif /* _KERN_TYPES_H */
+#endif /* _KERN_CONDITION_TYPES_H */
diff --git a/kern/mutex.c b/kern/mutex.c
index 3c76f50c..58e24513 100644
--- a/kern/mutex.c
+++ b/kern/mutex.c
@@ -19,7 +19,6 @@
#include <kern/mutex_i.h>
#include <kern/spinlock.h>
#include <kern/thread.h>
-#include <kern/types.h>
void
mutex_lock_slow(struct mutex *mutex)
diff --git a/kern/mutex.h b/kern/mutex.h
index a36ed17e..5ea8061e 100644
--- a/kern/mutex.h
+++ b/kern/mutex.h
@@ -26,8 +26,8 @@
#include <kern/assert.h>
#include <kern/list.h>
#include <kern/mutex_i.h>
+#include <kern/mutex_types.h>
#include <kern/spinlock.h>
-#include <kern/types.h>
struct mutex;
diff --git a/kern/mutex_i.h b/kern/mutex_i.h
index b09f8cdd..aaaf7cad 100644
--- a/kern/mutex_i.h
+++ b/kern/mutex_i.h
@@ -20,8 +20,8 @@
#include <kern/assert.h>
#include <kern/list.h>
+#include <kern/mutex_types.h>
#include <kern/thread.h>
-#include <kern/types.h>
#include <machine/atomic.h>
#define MUTEX_UNLOCKED 0
diff --git a/kern/mutex_types.h b/kern/mutex_types.h
new file mode 100644
index 00000000..4f99b400
--- /dev/null
+++ b/kern/mutex_types.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Richard Braun.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Isolated type definition used to avoid inclusion circular dependencies.
+ */
+
+#ifndef _KERN_MUTEX_TYPES_H
+#define _KERN_MUTEX_TYPES_H
+
+#include <kern/list.h>
+#include <kern/spinlock_types.h>
+
+struct mutex {
+ unsigned int state;
+ struct spinlock lock;
+ struct list waiters;
+};
+
+#endif /* _KERN_MUTEX_TYPES_H */
diff --git a/kern/spinlock.h b/kern/spinlock.h
index f63c4e0b..a9e82bc7 100644
--- a/kern/spinlock.h
+++ b/kern/spinlock.h
@@ -26,8 +26,8 @@
#include <kern/assert.h>
#include <kern/macros.h>
#include <kern/spinlock_i.h>
+#include <kern/spinlock_types.h>
#include <kern/thread.h>
-#include <kern/types.h>
#include <machine/cpu.h>
struct spinlock;
diff --git a/kern/spinlock_i.h b/kern/spinlock_i.h
index ed851099..6f7f4a6c 100644
--- a/kern/spinlock_i.h
+++ b/kern/spinlock_i.h
@@ -19,7 +19,7 @@
#define _KERN_SPINLOCK_I_H
#include <kern/assert.h>
-#include <kern/types.h>
+#include <kern/spinlock_types.h>
#include <machine/atomic.h>
#include <machine/cpu.h>
diff --git a/kern/spinlock_types.h b/kern/spinlock_types.h
new file mode 100644
index 00000000..f5a03866
--- /dev/null
+++ b/kern/spinlock_types.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Richard Braun.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Isolated type definition used to avoid inclusion circular dependencies.
+ */
+
+#ifndef _KERN_SPINLOCK_TYPES_H
+#define _KERN_SPINLOCK_TYPES_H
+
+struct spinlock {
+ unsigned int locked;
+};
+
+#endif /* _KERN_SPINLOCK_TYPES_H */
diff --git a/kern/thread.h b/kern/thread.h
index 14fd8669..074963de 100644
--- a/kern/thread.h
+++ b/kern/thread.h
@@ -36,10 +36,14 @@
#include <kern/assert.h>
#include <kern/cpumap.h>
#include <kern/macros.h>
-#include <kern/types.h>
#include <machine/tcb.h>
/*
+ * Forward declaration
+ */
+struct spinlock;
+
+/*
* Thread structure.
*/
struct thread;
diff --git a/kern/thread_i.h b/kern/thread_i.h
index 752eb944..6d9bc501 100644
--- a/kern/thread_i.h
+++ b/kern/thread_i.h
@@ -18,11 +18,12 @@
#ifndef _KERN_THREAD_I_H
#define _KERN_THREAD_I_H
+#include <kern/condition_types.h>
#include <kern/cpumap.h>
#include <kern/list.h>
#include <kern/macros.h>
+#include <kern/mutex_types.h>
#include <kern/param.h>
-#include <kern/types.h>
#include <machine/atomic.h>
#include <machine/tcb.h>
diff --git a/vm/vm_kmem.c b/vm/vm_kmem.c
index 58a4f39e..9a767e08 100644
--- a/vm/vm_kmem.c
+++ b/vm/vm_kmem.c
@@ -25,8 +25,8 @@
#include <kern/param.h>
#include <kern/stddef.h>
#include <kern/stdint.h>
-#include <kern/types.h>
#include <machine/pmap.h>
+#include <machine/types.h>
#include <vm/vm_adv.h>
#include <vm/vm_inherit.h>
#include <vm/vm_kmem.h>
diff --git a/vm/vm_kmem.h b/vm/vm_kmem.h
index a5e5e6d0..eafb4183 100644
--- a/vm/vm_kmem.h
+++ b/vm/vm_kmem.h
@@ -18,8 +18,8 @@
#ifndef _VM_VM_KMEM_H
#define _VM_VM_KMEM_H
-#include <kern/types.h>
#include <kern/stdint.h>
+#include <machine/types.h>
/*
* The kernel space is required not to start at address 0, which is used to
diff --git a/vm/vm_page.c b/vm/vm_page.c
index d1d6349c..487e4624 100644
--- a/vm/vm_page.c
+++ b/vm/vm_page.c
@@ -44,9 +44,9 @@
#include <kern/stdint.h>
#include <kern/string.h>
#include <kern/thread.h>
-#include <kern/types.h>
#include <machine/cpu.h>
#include <machine/pmap.h>
+#include <machine/types.h>
#include <vm/vm_page.h>
#define DEBUG 0
diff --git a/vm/vm_page.h b/vm/vm_page.h
index 71fb43a1..cd4dab10 100644
--- a/vm/vm_page.h
+++ b/vm/vm_page.h
@@ -28,8 +28,8 @@
#include <kern/param.h>
#include <kern/stddef.h>
#include <kern/stdint.h>
-#include <kern/types.h>
#include <machine/pmap.h>
+#include <machine/types.h>
/*
* Address/page conversion and rounding macros (not inline functions to