Index: kernel/arch/mips32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/context_struct.ag	(revision 3bacee1839e6f355100ab4ea86bb211e9ecf19ed)
+++ 	(revision )
@@ -1,97 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <typedefs.h>
-                }
-        ],
-
-        members : [
-                #
-                # Only save registers that must be preserved across function
-                # calls.
-                #
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-
-                {
-                        name : s0,
-                        type : uint32_t
-                },
-                {
-                        name : s1,
-                        type : uint32_t
-                },
-                {
-                        name : s2,
-                        type : uint32_t
-                },
-                {
-                        name : s3,
-                        type : uint32_t
-                },
-                {
-                        name : s4,
-                        type : uint32_t
-                },
-                {
-                        name : s5,
-                        type : uint32_t
-                },
-                {
-                        name : s6,
-                        type : uint32_t
-                },
-                {
-                        name : s7,
-                        type : uint32_t
-                },
-                {
-                        name : s8,
-                        type : uint32_t
-                },
-                {
-                        name : gp,
-                        type : uint32_t
-                },
-
-                {
-                        name : ipl,
-                        type : ipl_t
-                }
-        ]
-}
Index: kernel/arch/mips32/include/arch/context_struct.h
===================================================================
--- kernel/arch/mips32/include/arch/context_struct.h	(revision aa0c8b24160b1e5af03a3ef9039095a71bccfeb7)
+++ kernel/arch/mips32/include/arch/context_struct.h	(revision aa0c8b24160b1e5af03a3ef9039095a71bccfeb7)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KERN_ARCH_CONTEXT_STRUCT_H_
+#define KERN_ARCH_CONTEXT_STRUCT_H_
+
+#define CONTEXT_OFFSET_SP  0x00
+#define CONTEXT_OFFSET_PC  0x04
+#define CONTEXT_OFFSET_S0  0x08
+#define CONTEXT_OFFSET_S1  0x0c
+#define CONTEXT_OFFSET_S2  0x10
+#define CONTEXT_OFFSET_S3  0x14
+#define CONTEXT_OFFSET_S4  0x18
+#define CONTEXT_OFFSET_S5  0x1c
+#define CONTEXT_OFFSET_S6  0x20
+#define CONTEXT_OFFSET_S7  0x24
+#define CONTEXT_OFFSET_S8  0x28
+#define CONTEXT_OFFSET_GP  0x2c
+#define CONTEXT_OFFSET_IPL 0x30
+#define CONTEXT_SIZE       0x34
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+typedef struct context {
+	/* Only save registers that must be preserved across function calls. */
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t s0;
+	uint32_t s1;
+	uint32_t s2;
+	uint32_t s3;
+	uint32_t s4;
+	uint32_t s5;
+	uint32_t s6;
+	uint32_t s7;
+	uint32_t s8;
+	uint32_t gp;
+	ipl_t ipl;
+} context_t;
+
+#endif
+#endif
+
Index: kernel/arch/mips32/include/arch/fpu_context_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/fpu_context_struct.ag	(revision 3bacee1839e6f355100ab4ea86bb211e9ecf19ed)
+++ 	(revision )
@@ -1,49 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : fpu_context,
-
-        includes : [
-                {
-                        include : <typedefs.h>
-                }
-        ],
-
-        members : [
-                {
-                        name : dregs,
-                        type : sysarg_t,
-                        elements: 32
-                },
-                {
-                        name : cregs,
-                        type : sysarg_t,
-                        elements : 32
-                }
-        ]
-}
Index: kernel/arch/mips32/include/arch/fpu_context_struct.h
===================================================================
--- kernel/arch/mips32/include/arch/fpu_context_struct.h	(revision aa0c8b24160b1e5af03a3ef9039095a71bccfeb7)
+++ kernel/arch/mips32/include/arch/fpu_context_struct.h	(revision aa0c8b24160b1e5af03a3ef9039095a71bccfeb7)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KERN_ARCH_FPU_CONTEXT_STRUCT_H_
+#define KERN_ARCH_FPU_CONTEXT_STRUCT_H_
+
+#define FPU_CONTEXT_OFFSET_DREGS  0
+#define FPU_CONTEXT_OFFSET_CREGS  128
+#define FPU_CONTEXT_SIZE          256
+
+#define FPU_CONTEXT_SIZE_DREGS 128
+#define FPU_CONTEXT_SIZE_CREGS 128
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+typedef struct fpu_context {
+	sysarg_t dregs[32];
+	sysarg_t cregs[32];
+} fpu_context_t;
+
+#endif
+#endif
+
Index: kernel/arch/mips32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/istate_struct.ag	(revision 3bacee1839e6f355100ab4ea86bb211e9ecf19ed)
+++ 	(revision )
@@ -1,211 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : istate,
-
-        includes : [
-                {
-                        guard : KERNEL,
-                        include : <typedefs.h>
-                },
-                {
-                        negative-guard : KERNEL,
-                        include : <stddef.h>
-                },
-                {
-                        negative-guard : KERNEL,
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                #
-                # The first seven registers are arranged so that the istate structure
-                # can be used both for exception handlers and for the syscall handler.
-                #
-                {
-                        # arg1
-                        name : a0,
-                        type : uint32_t
-                },
-                {
-                        # arg2
-                        name : a1,
-                        type : uint32_t
-                },
-                {
-                        # arg3
-                        name : a2,
-                        type : uint32_t
-                },
-                {
-                        # arg4
-                        name : a3,
-                        type : uint32_t
-                },
-                {
-                        # arg5
-                        name : t0,
-                        type : uint32_t
-                },
-                {
-                        # arg6
-                        name : t1,
-                        type : uint32_t
-                },
-                {
-                        # arg7
-                        name : v0,
-                        type : uint32_t
-                },
-                {
-                        name : v1,
-                        type : uint32_t
-                },
-                {
-                        name : at,
-                        type : uint32_t
-                },
-                {
-                        name : t2,
-                        type : uint32_t
-                },
-                {
-                        name : t3,
-                        type : uint32_t
-                },
-                {
-                        name : t4,
-                        type : uint32_t
-                },
-                {
-                        name : t5,
-                        type : uint32_t
-                },
-                {
-                        name : t6,
-                        type : uint32_t
-                },
-                {
-                        name : t7,
-                        type : uint32_t
-                },
-                {
-                        name : s0,
-                        type : uint32_t
-                },
-                {
-                        name : s1,
-                        type : uint32_t
-                },
-                {
-                        name : s2,
-                        type : uint32_t
-                },
-                {
-                        name : s3,
-                        type : uint32_t
-                },
-                {
-                        name : s4,
-                        type : uint32_t
-                },
-                {
-                        name : s5,
-                        type : uint32_t
-                },
-                {
-                        name : s6,
-                        type : uint32_t
-                },
-                {
-                        name : s7,
-                        type : uint32_t
-                },
-                {
-                        name : t8,
-                        type : uint32_t
-                },
-                {
-                        name : t9,
-                        type : uint32_t
-                },
-                {
-                        name : kt0,
-                        type : uint32_t
-                },
-                {
-                        # We use it as thread-local pointer
-                        name : kt1,
-                        type : uint32_t
-                },
-                {
-                        name : gp,
-                        type : uint32_t
-                },
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : s8,
-                        type : uint32_t
-                },
-                {
-                        name : ra,
-                        type : uint32_t
-                },
-
-                {
-                        name : lo,
-                        type : uint32_t
-                },
-                {
-                        name : hi,
-                        type : uint32_t
-                },
-
-                {
-                        # cp0_status
-                        name : status,
-                        type : uint32_t
-                },
-                {
-                        # cp0_epc
-                        name : epc,
-                        type : uint32_t
-                },
-
-                {
-                        # to make sizeof(istate_t) a multiple of 8 */
-                        name : alignment,
-                        type : uint32_t
-                }
-
-        ]
-}
Index: kernel/arch/mips32/include/arch/istate_struct.h
===================================================================
--- kernel/arch/mips32/include/arch/istate_struct.h	(revision aa0c8b24160b1e5af03a3ef9039095a71bccfeb7)
+++ kernel/arch/mips32/include/arch/istate_struct.h	(revision aa0c8b24160b1e5af03a3ef9039095a71bccfeb7)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KERN_ARCH_ISTATE_STRUCT_H_
+#define KERN_ARCH_ISTATE_STRUCT_H_
+
+#define ISTATE_OFFSET_A0         0x00
+#define ISTATE_OFFSET_A1         0x04
+#define ISTATE_OFFSET_A2         0x08
+#define ISTATE_OFFSET_A3         0x0c
+#define ISTATE_OFFSET_T0         0x10
+#define ISTATE_OFFSET_T1         0x14
+#define ISTATE_OFFSET_V0         0x18
+#define ISTATE_OFFSET_V1         0x1c
+#define ISTATE_OFFSET_AT         0x20
+#define ISTATE_OFFSET_T2         0x24
+#define ISTATE_OFFSET_T3         0x28
+#define ISTATE_OFFSET_T4         0x2c
+#define ISTATE_OFFSET_T5         0x30
+#define ISTATE_OFFSET_T6         0x34
+#define ISTATE_OFFSET_T7         0x38
+#define ISTATE_OFFSET_S0         0x3c
+#define ISTATE_OFFSET_S1         0x40
+#define ISTATE_OFFSET_S2         0x44
+#define ISTATE_OFFSET_S3         0x48
+#define ISTATE_OFFSET_S4         0x4c
+#define ISTATE_OFFSET_S5         0x50
+#define ISTATE_OFFSET_S6         0x54
+#define ISTATE_OFFSET_S7         0x58
+#define ISTATE_OFFSET_T8         0x5c
+#define ISTATE_OFFSET_T9         0x60
+#define ISTATE_OFFSET_KT0        0x64
+#define ISTATE_OFFSET_KT1        0x68
+#define ISTATE_OFFSET_GP         0x6c
+#define ISTATE_OFFSET_SP         0x70
+#define ISTATE_OFFSET_S8         0x74
+#define ISTATE_OFFSET_RA         0x78
+#define ISTATE_OFFSET_LO         0x7c
+#define ISTATE_OFFSET_HI         0x80
+#define ISTATE_OFFSET_STATUS     0x84
+#define ISTATE_OFFSET_EPC        0x88
+#define ISTATE_OFFSET_ALIGNMENT  0x8c
+#define ISTATE_SIZE              0x90
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+#ifdef KERNEL
+#include <typedefs.h>
+#else
+#include <stddef.h>
+#endif
+
+typedef struct istate {
+	/*
+	 * The first seven registers are arranged so that the istate structure
+	 * can be used both for exception handlers and for the syscall handler.
+	 */
+
+	uint32_t a0;  // arg1
+	uint32_t a1;  // arg2
+	uint32_t a2;  // arg3
+	uint32_t a3;  // arg4
+	uint32_t t0;  // arg5
+	uint32_t t1;  // arg6
+	uint32_t v0;  // arg7
+	uint32_t v1;
+	uint32_t at;
+	uint32_t t2;
+	uint32_t t3;
+	uint32_t t4;
+	uint32_t t5;
+	uint32_t t6;
+	uint32_t t7;
+	uint32_t s0;
+	uint32_t s1;
+	uint32_t s2;
+	uint32_t s3;
+	uint32_t s4;
+	uint32_t s5;
+	uint32_t s6;
+	uint32_t s7;
+	uint32_t t8;
+	uint32_t t9;
+	uint32_t kt0;
+	/* We use it as thread-local pointer */
+	uint32_t kt1;
+	uint32_t gp;
+	uint32_t sp;
+	uint32_t s8;
+	uint32_t ra;
+	uint32_t lo;
+	uint32_t hi;
+	/* cp0_status */
+	uint32_t status;
+	/* cp0_epc */
+	uint32_t epc;
+	/* to make sizeof(istate_t) a multiple of 8 */
+	uint32_t alignment;
+} istate_t;
+
+#endif
+#endif
+
