Index: .gitignore
===================================================================
--- .gitignore	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ .gitignore	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -9,12 +9,10 @@
 *.so.*
 *.d
-*.ag.probe.s
-*.ag.probe.c
 *.pyc
+*.check.c
 tag
 tags
 common.h.new
 deps.mk
-Makefile.ag.depend
 /Makefile.config
 /Makefile.common
@@ -46,33 +44,11 @@
 boot/image.raw
 kernel/arch/amd64/_link.ld
-kernel/arch/amd64/include/arch/boot/memmap_struct.h
-kernel/arch/amd64/include/arch/common.h
-kernel/arch/amd64/include/arch/context_struct.h
-kernel/arch/amd64/include/arch/istate_struct.h
-kernel/arch/amd64/include/arch/kseg_struct.h
 kernel/arch/arm32/_link.ld
-kernel/arch/arm32/include/arch/context_struct.h
-kernel/arch/arm32/include/arch/istate_struct.h
 kernel/arch/ia32/_link.ld
-kernel/arch/ia32/include/arch/boot/memmap_struct.h
-kernel/arch/ia32/include/arch/context_struct.h
-kernel/arch/ia32/include/arch/istate_struct.h
 kernel/arch/ia64/_link.ld
-kernel/arch/ia64/include/arch/context_struct.h
-kernel/arch/ia64/include/arch/istate_struct.h
 kernel/arch/mips32/_link.ld
-kernel/arch/mips32/include/arch/context_struct.h
-kernel/arch/mips32/include/arch/fpu_context_struct.h
-kernel/arch/mips32/include/arch/istate_struct.h
 kernel/arch/ppc32/_link.ld
-kernel/arch/ppc32/include/arch/context_struct.h
-kernel/arch/ppc32/include/arch/fpu_context_struct.h
-kernel/arch/ppc32/include/arch/istate_struct.h
 kernel/arch/sparc64/_link.ld
-kernel/arch/sparc64/include/arch/context_struct.h
-kernel/arch/sparc64/include/arch/istate_struct.h
 kernel/arch/abs32le/_link.ld
-kernel/genarch/include/genarch/multiboot/multiboot_info_struct.h
-kernel/genarch/include/genarch/multiboot/multiboot_memmap_struct.h
 kernel/generic/src/debug/real_map.bin
 kernel/kernel.bin
@@ -344,49 +320,32 @@
 uspace/lib/c/arch/amd64/_link-shlib.ld
 uspace/lib/c/arch/amd64/_link.ld
-uspace/lib/c/arch/amd64/include/libarch/common.h
-uspace/lib/c/arch/amd64/include/libarch/fibril_context.h
-uspace/lib/c/arch/amd64/include/libarch/istate_struct.h
 uspace/lib/c/arch/arm32/_link-dlexe.ld
 uspace/lib/c/arch/arm32/_link-loader.ld
 uspace/lib/c/arch/arm32/_link-shlib.ld
 uspace/lib/c/arch/arm32/_link.ld
-uspace/lib/c/arch/arm32/include/libarch/fibril_context.h
-uspace/lib/c/arch/arm32/include/libarch/istate_struct.h
 uspace/lib/c/arch/ia32/_link-dlexe.ld
 uspace/lib/c/arch/ia32/_link-loader.ld
 uspace/lib/c/arch/ia32/_link-shlib.ld
 uspace/lib/c/arch/ia32/_link.ld
-uspace/lib/c/arch/ia32/include/libarch/fibril_context.h
-uspace/lib/c/arch/ia32/include/libarch/istate_struct.h
 uspace/lib/c/arch/ia64/_link-dlexe.ld
 uspace/lib/c/arch/ia64/_link-loader.ld
 uspace/lib/c/arch/ia64/_link-shlib.ld
 uspace/lib/c/arch/ia64/_link.ld
-uspace/lib/c/arch/ia64/include/libarch/fibril_context.h
-uspace/lib/c/arch/ia64/include/libarch/istate_struct.h
 uspace/lib/c/arch/mips32/_link-dlexe.ld
 uspace/lib/c/arch/mips32/_link-loader.ld
 uspace/lib/c/arch/mips32/_link-shlib.ld
 uspace/lib/c/arch/mips32/_link.ld
-uspace/lib/c/arch/mips32/include/libarch/fibril_context.h
-uspace/lib/c/arch/mips32/include/libarch/istate_struct.h
 uspace/lib/c/arch/mips32eb/_link-dlexe.ld
 uspace/lib/c/arch/mips32eb/_link-loader.ld
 uspace/lib/c/arch/mips32eb/_link-shlib.ld
 uspace/lib/c/arch/mips32eb/_link.ld
-uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.h
-uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.h
 uspace/lib/c/arch/ppc32/_link-dlexe.ld
 uspace/lib/c/arch/ppc32/_link-loader.ld
 uspace/lib/c/arch/ppc32/_link-shlib.ld
 uspace/lib/c/arch/ppc32/_link.ld
-uspace/lib/c/arch/ppc32/include/libarch/fibril_context.h
-uspace/lib/c/arch/ppc32/include/libarch/istate_struct.h
 uspace/lib/c/arch/sparc64/_link-dlexe.ld
 uspace/lib/c/arch/sparc64/_link-loader.ld
 uspace/lib/c/arch/sparc64/_link-shlib.ld
 uspace/lib/c/arch/sparc64/_link.ld
-uspace/lib/c/arch/sparc64/include/libarch/fibril_context.h
-uspace/lib/c/arch/sparc64/include/libarch/istate_struct.h
 uspace/lib/c/arch/abs32le/_link-dlexe.ld
 uspace/lib/c/arch/abs32le/_link-loader.ld
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/Makefile	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -48,5 +48,5 @@
 #
 
-AGDEPEND = Makefile.ag.depend
+AUTOCHECK = $(realpath $(ROOT_PATH)/tools/autocheck.awk)
 RAW = kernel.raw
 BIN = kernel.bin
@@ -73,4 +73,5 @@
 
 .PHONY: all clean autogen_clean depend
+.DELETE_ON_ERROR:
 
 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BIN) $(DISASM)
@@ -132,5 +133,4 @@
 -include arch/$(KARCH)/Makefile.inc
 -include genarch/Makefile.inc
--include $(AGDEPEND)
 
 ## The at-sign
@@ -346,4 +346,7 @@
 endif
 
+ARCH_SOURCES += $(ARCH_AUTOCHECK_HEADERS:%.h=%.check.c)
+GENARCH_SOURCES += $(GENARCH_AUTOCHECK_HEADERS:%.h=%.check.c)
+
 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
@@ -354,15 +357,4 @@
 GENARCH_DEPENDS := $(addsuffix .d,$(basename $(GENARCH_SOURCES)))
 
-GENARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(GENARCH_AUTOGENS_AG)))
-GENARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(GENARCH_AUTOGENS_AG)))
-GENARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(GENARCH_AUTOGENS_AG)))
-
-ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG)))
-ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG)))
-ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG)))
-
-AUTOGENS_H := $(ARCH_AUTOGENS_H) $(GENARCH_AUTOGENS_H)
-AUTOGENS_AG := $(ARCH_AUTOGENS_AG) $(GENARCH_AUTOGENS_AG)
-
 AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
 LD_CFLAGS := $(addprefix -Xlinker ,$(LFLAGS))
@@ -399,19 +391,17 @@
 endif
 
-$(LINK): $(LINK).in | depend
+$(LINK): $(LINK).in
 	$(CC) $(DEFS) $(CFLAGS) -D__ASSEMBLER__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
 
-%.h: %.ag
-	$(AUTOGEN) probe $< >$<.probe.c
-	$(CC_AUTOGEN) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
-	$(AUTOGEN) generate $< <$<.probe.s >$@
-
-%.o: %.S | depend
+%.check.c: %.h $(AUTOCHECK)
+	cd $(<D) && $(AUTOCHECK) $(<F) > $(@F)
+
+%.o: %.S
 	$(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS)
 
-%.o: %.s | depend
+%.o: %.s
 	$(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS)
 
-%.o: %.c | depend
+%.o: %.c
 	$(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) $(if $(findstring $<,$(INSTRUMENTED_SOURCES)),$(INSTRUMENTATION))
 
@@ -440,20 +430,2 @@
 	$(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
 	$(GENMAP) $(MAP_PREV) $(DUMP) $@
-
-$(AUTOGENS_H): $(AGDEPEND)
-
-$(AGDEPEND): $(AUTOGENS_AG)
-	echo "# DO NOT EDIT" >$@
-	for g in $^; do \
-		h=`dirname $$g`/`basename $$g .ag`.h; \
-		for l in `$(AUTOGEN) depend $$g`; do \
-			echo "$$h: $$l" >>$@; \
-		done \
-	done
-
-depend: $(AUTOGENS_H)
-
-autogen_clean:
-	-rm $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
-	-rm $(GENARCH_AUTOGENS_H) $(GENARCH_AUTOGENS_PROBE_C) $(GENARCH_AUTOGENS_PROBE_S)
-	-rm $(AGDEPEND)
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/amd64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -85,7 +85,7 @@
 endif
 
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag \
-	arch/$(KARCH)/include/arch/kseg_struct.ag \
-	arch/$(KARCH)/include/arch/boot/memmap_struct.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(KARCH)/include/arch/istate_struct.h \
+	arch/$(KARCH)/include/arch/context_struct.h \
+	arch/$(KARCH)/include/arch/kseg_struct.h \
+	arch/$(KARCH)/include/arch/boot/memmap_struct.h
Index: rnel/arch/amd64/include/arch/boot/memmap_struct.ag
===================================================================
--- kernel/arch/amd64/include/arch/boot/memmap_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../ia32/include/arch/boot/memmap_struct.ag
Index: kernel/arch/amd64/include/arch/boot/memmap_struct.h
===================================================================
--- kernel/arch/amd64/include/arch/boot/memmap_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/amd64/include/arch/boot/memmap_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,48 @@
+/* Copyright (c) 2016 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_BOOT_MEMMAP_STRUCT_H_
+#define KERN_ARCH_BOOT_MEMMAP_STRUCT_H_
+
+#define E820MEMMAP_OFFSET_BASE_ADDRESS  0x00
+#define E820MEMMAP_OFFSET_SIZE          0x08
+#define E820MEMMAP_OFFSET_TYPE          0x10
+#define E820MEMMAP_SIZE                 0x14
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct e820memmap {
+	uint64_t base_address;
+	uint64_t size;
+	uint32_t type;
+} __attribute__((packed)) e820memmap_t;
+
+#endif
+#endif
+
Index: rnel/arch/amd64/include/arch/context_struct.ag
===================================================================
--- kernel/arch/amd64/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,87 +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 : [
-                #
-                # We include only registers that must be preserved
-                # during function call.
-                #
-
-                {
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        name : pc,
-                        type : uint64_t
-                },
-
-                {
-                        name : rbx,
-                        type : uint64_t
-                },
-                {
-                        name : rbp,
-                        type : uint64_t
-                },
-
-                {
-                        name : r12,
-                        type : uint64_t
-                },
-                {
-                        name : r13,
-                        type : uint64_t
-                },
-                {
-                        name : r14,
-                        type : uint64_t
-                },
-                {
-                        name : r15,
-                        type : uint64_t
-                },
-                {
-                        name : tp,
-                        type : uint64_t
-                },
-
-                {
-                        name : ipl,
-                        type : ipl_t
-                }
-        ]
-}
Index: kernel/arch/amd64/include/arch/context_struct.h
===================================================================
--- kernel/arch/amd64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/amd64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,65 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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   0x08
+#define CONTEXT_OFFSET_RBX  0x10
+#define CONTEXT_OFFSET_RBP  0x18
+#define CONTEXT_OFFSET_R12  0x20
+#define CONTEXT_OFFSET_R13  0x28
+#define CONTEXT_OFFSET_R14  0x30
+#define CONTEXT_OFFSET_R15  0x38
+#define CONTEXT_OFFSET_TP   0x40
+#define CONTEXT_OFFSET_IPL  0x48
+#define CONTEXT_SIZE        0x50
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+typedef struct context {
+	/* We include only registers that must be preserved
+	 * during function call.
+	 */
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t rbx;
+	uint64_t rbp;
+	uint64_t r12;
+	uint64_t r13;
+	uint64_t r14;
+	uint64_t r15;
+	uint64_t tp;
+	ipl_t ipl;
+} context_t;
+
+#endif
+#endif
+
Index: rnel/arch/amd64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/amd64/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,150 +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 : [
-                {
-                        name : rax,
-                        type : uint64_t
-                },
-                {
-                        name : rbx,
-                        type : uint64_t
-                },
-                {
-                        name : rcx,
-                        type : uint64_t
-                },
-                {
-                        name : rdx,
-                        type : uint64_t
-                },
-                {
-                        name : rsi,
-                        type : uint64_t
-                },
-                {
-                        name : rdi,
-                        type : uint64_t
-                },
-                {
-                        name : rbp,
-                        type : uint64_t
-                },
-                {
-                        name : r8,
-                        type : uint64_t
-                },
-                {
-                        name : r9,
-                        type : uint64_t
-                },
-                {
-                        name : r10,
-                        type : uint64_t
-                },
-                {
-                        name : r11,
-                        type : uint64_t
-                },
-                {
-                        name : r12,
-                        type : uint64_t
-                },
-                {
-                        name : r13,
-                        type : uint64_t
-                },
-                {
-                        name : r14,
-                        type : uint64_t
-                },
-                {
-                        name : r15,
-                        type : uint64_t
-                },
-                {
-                        # align rbp_frame on multiple of 16
-                        name : alignment,
-                        type : uint64_t
-                },
-                {
-                        # imitation of frame pointer linkage
-                        name : rbp_frame,
-                        type : uint64_t
-                },
-                {
-                        # imitation of frame address linkage
-                        name : rip_frame,
-                        type : uint64_t
-                },
-                {
-                        # real or fake error word
-                        name : error_word,
-                        type : uint64_t
-                },
-                {
-                        name : rip,
-                        type : uint64_t
-                },
-                {
-                        name : cs,
-                        type : uint64_t
-                },
-                {
-                        name : rflags,
-                        type : uint64_t
-                },
-                {
-                        # only if istate_t is from uspace
-                        name : rsp,
-                        type : uint64_t
-                },
-                {
-                        # only if istate_t is from uspace
-                        name : ss,
-                        type : uint64_t
-                }
-        ]
-}
Index: kernel/arch/amd64/include/arch/istate_struct.h
===================================================================
--- kernel/arch/amd64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/amd64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,96 @@
+/* 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_RAX         0x00
+#define ISTATE_OFFSET_RBX         0x08
+#define ISTATE_OFFSET_RCX         0x10
+#define ISTATE_OFFSET_RDX         0x18
+#define ISTATE_OFFSET_RSI         0x20
+#define ISTATE_OFFSET_RDI         0x28
+#define ISTATE_OFFSET_RBP         0x30
+#define ISTATE_OFFSET_R8          0x38
+#define ISTATE_OFFSET_R9          0x40
+#define ISTATE_OFFSET_R10         0x48
+#define ISTATE_OFFSET_R11         0x50
+#define ISTATE_OFFSET_R12         0x58
+#define ISTATE_OFFSET_R13         0x60
+#define ISTATE_OFFSET_R14         0x68
+#define ISTATE_OFFSET_R15         0x70
+#define ISTATE_OFFSET_ALIGNMENT   0x78
+#define ISTATE_OFFSET_RBP_FRAME   0x80
+#define ISTATE_OFFSET_RIP_FRAME   0x88
+#define ISTATE_OFFSET_ERROR_WORD  0x90
+#define ISTATE_OFFSET_RIP         0x98
+#define ISTATE_OFFSET_CS          0xa0
+#define ISTATE_OFFSET_RFLAGS      0xa8
+#define ISTATE_OFFSET_RSP         0xb0
+#define ISTATE_OFFSET_SS          0xb8
+#define ISTATE_SIZE               0xc0
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct istate {
+	uint64_t rax;
+	uint64_t rbx;
+	uint64_t rcx;
+	uint64_t rdx;
+	uint64_t rsi;
+	uint64_t rdi;
+	uint64_t rbp;
+	uint64_t r8;
+	uint64_t r9;
+	uint64_t r10;
+	uint64_t r11;
+	uint64_t r12;
+	uint64_t r13;
+	uint64_t r14;
+	uint64_t r15;
+	/* align rbp_frame on multiple of 16 */
+	uint64_t alignment;
+	/* imitation of frame pointer linkage */
+	uint64_t rbp_frame;
+	/* imitation of frame address linkage */
+	uint64_t rip_frame;
+	/* real or fake error word */
+	uint64_t error_word;
+	uint64_t rip;
+	uint64_t cs;
+	uint64_t rflags;
+	/* only if istate_t is from uspace */
+	uint64_t rsp;
+	/* only if istate_t is from uspace */
+	uint64_t ss;
+} istate_t;
+
+#endif
+#endif
+
Index: rnel/arch/amd64/include/arch/kseg_struct.ag
===================================================================
--- kernel/arch/amd64/include/arch/kseg_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,51 +1,0 @@
-# Copyright (c) 2016 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 : kseg,
-
-        includes : [
-                {
-                        include : <typedefs.h>
-                }
-        ],
-
-        members : [
-                {
-                        name : ustack_rsp,
-                        type : uint64_t
-                },
-                {
-                        name : kstack_rsp,
-                        type : uint64_t
-                },
-                {
-                        name : fsbase,
-                        type : uint64_t
-                }
-        ]
-}
Index: kernel/arch/amd64/include/arch/kseg_struct.h
===================================================================
--- kernel/arch/amd64/include/arch/kseg_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/amd64/include/arch/kseg_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,48 @@
+/* Copyright (c) 2016 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_KSEG_STRUCT_H_
+#define KERN_ARCH_KSEG_STRUCT_H_
+
+#define KSEG_OFFSET_USTACK_RSP  0x00
+#define KSEG_OFFSET_KSTACK_RSP  0x08
+#define KSEG_OFFSET_FSBASE      0x10
+#define KSEG_SIZE               0x18
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct kseg {
+	uint64_t ustack_rsp;
+	uint64_t kstack_rsp;
+	uint64_t fsbase;
+} kseg_t;
+
+#endif
+#endif
+
Index: kernel/arch/arm32/Makefile.inc
===================================================================
--- kernel/arch/arm32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/arm32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -96,7 +96,2 @@
 	ARCH_SOURCES += genarch/src/drivers/pl050/pl050.c
 endif
-
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag
-
Index: rnel/arch/arm32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/arm32/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,95 +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>
-                },
-        ],
-
-        #
-        # Thread context containing registers that must be preserved across
-        # function calls.
-        #
-        members : [
-                {
-                        name : cpu_mode,
-                        type : uint32_t
-                },
-                {
-                        name : sp,
-                        type : uintptr_t
-                },
-                {
-                        name : pc,
-                        type : uintptr_t
-                },
-
-                {
-                        name : r4,
-                        type : uint32_t
-                },
-                {
-                        name : r5,
-                        type : uint32_t
-                },
-                {
-                        name : r6,
-                        type : uint32_t
-                },
-                {
-                        name : r7,
-                        type : uint32_t
-                },
-                {
-                        name : r8,
-                        type : uint32_t
-                },
-                {
-                        name : r9,
-                        type : uint32_t
-                },
-                {
-                        name : r10,
-                        type : uint32_t
-                },
-                {
-                        # r11
-                        name : fp,
-                        type : uint32_t
-                },
-
-                {
-                        name : ipl,
-                        type : ipl_t
-                }
-        ]
-}
-
Index: kernel/arch/arm32/include/arch/context_struct.h
===================================================================
--- kernel/arch/arm32/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/arm32/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,56 @@
+/*
+ * 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_
+
+#include <typedefs.h>
+
+// XXX: This struct must match assembly code in src/context.S
+
+/* Thread context containing registers that must be preserved across
+ * function calls.
+ */
+typedef struct context {
+	uint32_t cpu_mode;
+	uintptr_t sp;
+	uintptr_t pc;
+	uint32_t r4;
+	uint32_t r5;
+	uint32_t r6;
+	uint32_t r7;
+	uint32_t r8;
+	uint32_t r9;
+	uint32_t r10;
+	/* r11 */
+	uint32_t fp;
+	ipl_t ipl;
+} context_t;
+
+#endif
+
Index: rnel/arch/arm32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/arm32/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,123 +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 : [
-                {
-                        name : dummy,
-                        type : uint32_t
-                },
-                {
-                        name : spsr,
-                        type : uint32_t
-                },
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : lr,
-                        type : uint32_t
-                },
-
-                {
-                        name : r0,
-                        type : uint32_t
-                },
-                {
-                        name : r1,
-                        type : uint32_t
-                },
-                {
-                        name : r2,
-                        type : uint32_t
-                },
-                {
-                        name : r3,
-                        type : uint32_t
-                },
-                {
-                        name : r4,
-                        type : uint32_t
-                },
-                {
-                        name : r5,
-                        type : uint32_t
-                },
-                {
-                        name : r6,
-                        type : uint32_t
-                },
-                {
-                        name : r7,
-                        type : uint32_t
-                },
-                {
-                        name : r8,
-                        type : uint32_t
-                },
-                {
-                        name : r9,
-                        type : uint32_t
-                },
-                {
-                        name : r10,
-                        type : uint32_t
-                },
-                {
-                        name : fp,
-                        type : uint32_t
-                },
-                {
-                        name : r12,
-                        type : uint32_t
-                },
-
-                {
-                        name : pc,
-                        type : uint32_t
-                }
-        ]
-}
-
Index: kernel/arch/arm32/include/arch/istate_struct.h
===================================================================
--- kernel/arch/arm32/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/arm32/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,58 @@
+/*
+ * 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_
+
+#include <stdint.h>
+
+// XXX: Must match assembly code in src/exc_handler.S
+
+typedef struct istate {
+	uint32_t dummy;
+	uint32_t spsr;
+	uint32_t sp;
+	uint32_t lr;
+	uint32_t r0;
+	uint32_t r1;
+	uint32_t r2;
+	uint32_t r3;
+	uint32_t r4;
+	uint32_t r5;
+	uint32_t r6;
+	uint32_t r7;
+	uint32_t r8;
+	uint32_t r9;
+	uint32_t r10;
+	uint32_t fp;
+	uint32_t r12;
+	uint32_t pc;
+} istate_t;
+
+#endif
+
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/ia32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -102,7 +102,7 @@
 	arch/$(KARCH)/src/syscall.c
 
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag \
-	arch/$(KARCH)/include/arch/boot/memmap_struct.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(KARCH)/include/arch/istate_struct.h \
+	arch/$(KARCH)/include/arch/context_struct.h \
+	arch/$(KARCH)/include/arch/boot/memmap_struct.h
 
Index: rnel/arch/ia32/include/arch/boot/memmap_struct.ag
===================================================================
--- kernel/arch/ia32/include/arch/boot/memmap_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,52 +1,0 @@
-# Copyright (c) 2016 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 : e820memmap,
-        packed : true,
-
-        includes : [
-                {
-                        include : <typedefs.h>
-                },
-        ],
-
-        members : [
-                {
-                        name : base_address,
-                        type : uint64_t
-                },
-                {
-                        name : size,
-                        type : uint64_t
-                },
-                {
-                        name : type,
-                        type : uint32_t
-                }
-        ]
-}
Index: kernel/arch/ia32/include/arch/boot/memmap_struct.h
===================================================================
--- kernel/arch/ia32/include/arch/boot/memmap_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ia32/include/arch/boot/memmap_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,49 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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_BOOT_MEMMAP_STRUCT_H_
+#define KERN_ARCH_BOOT_MEMMAP_STRUCT_H_
+
+#define E820MEMMAP_OFFSET_BASE_ADDRESS  0x00
+#define E820MEMMAP_OFFSET_SIZE          0x08
+#define E820MEMMAP_OFFSET_TYPE          0x10
+#define E820MEMMAP_SIZE                 0x14
+
+#define E820MEMMAP_SIZE_SIZE            0x08
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct e820memmap {
+	uint64_t base_address;
+	uint64_t size;
+	uint32_t type;
+} __attribute__((packed)) e820memmap_t;
+
+#endif
+#endif
Index: rnel/arch/ia32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/ia32/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,77 +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 : ebx,
-                        type : uint32_t
-                },
-                {
-                        name : esi,
-                        type : uint32_t
-                },
-                {
-                        name : edi,
-                        type : uint32_t
-                },
-                {
-                        name : ebp,
-                        type : uint32_t
-                },
-                {
-                        name : tp,
-                        type : uint32_t
-                },
-
-                {
-                        name : ipl,
-                        type : ipl_t
-                }
-        ]
-}
Index: kernel/arch/ia32/include/arch/context_struct.h
===================================================================
--- kernel/arch/ia32/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ia32/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,59 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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_EBX  0x08
+#define CONTEXT_OFFSET_ESI  0x0c
+#define CONTEXT_OFFSET_EDI  0x10
+#define CONTEXT_OFFSET_EBP  0x14
+#define CONTEXT_OFFSET_TP   0x18
+#define CONTEXT_OFFSET_IPL  0x1c
+#define CONTEXT_SIZE        0x20
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+/* Only save registers that must be preserved across function calls. */
+typedef struct context {
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t ebx;
+	uint32_t esi;
+	uint32_t edi;
+	uint32_t ebp;
+	uint32_t tp;
+	ipl_t ipl;
+} context_t;
+
+#endif
+#endif
+
Index: rnel/arch/ia32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/ia32/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,139 +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 strange order of the GPRs is given by the requirement to use the
-                # istate structure for both regular interrupts and exceptions as well
-                # as for syscall handlers which use this order as an optimization.
-                #
-
-                {
-                        name : edx,
-                        type : uint32_t
-                },
-                {
-                        name : ecx,
-                        type : uint32_t
-                },
-                {
-                        name : ebx,
-                        type : uint32_t
-                },
-                {
-                        name : esi,
-                        type : uint32_t
-                },
-                {
-                        name : edi,
-                        type : uint32_t
-                },
-                {
-                        name : ebp,
-                        type : uint32_t
-                },
-                {
-                        name : eax,
-                        type : uint32_t
-                },
-
-                {
-                        # imitation of frame pointer linkage
-                        name : ebp_frame,
-                        type : uint32_t
-                },
-                {
-                        # imitation of return address linkage
-                        name : eip_frame,
-                        type : uint32_t
-                },
-
-                {
-                        name : gs,
-                        type : uint32_t
-                },
-                {
-                        name : fs,
-                        type : uint32_t
-                },
-                {
-                        name : es,
-                        type : uint32_t
-                },
-                {
-                        name : ds,
-                        type : uint32_t
-                },
-
-                {
-                        # real or fake error word
-                        name : error_word,
-                        type : uint32_t
-                },
-                {
-                        name : eip,
-                        type : uint32_t
-                },
-                {
-                        name : cs,
-                        type : uint32_t
-                },
-                {
-                        name : eflags,
-                        type : uint32_t
-                },
-                {
-                        # only if istate_t is from uspace
-                        name : esp,
-                        type : uint32_t
-                },
-                {
-                        # only if istate_t is from uspace
-                        name : ss,
-                        type : uint32_t
-                }
-        ]
-}
Index: kernel/arch/ia32/include/arch/istate_struct.h
===================================================================
--- kernel/arch/ia32/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ia32/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,109 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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_EDX 0
+#define ISTATE_SIZE_EDX 4
+#define ISTATE_OFFSET_ECX 4
+#define ISTATE_SIZE_ECX 4
+#define ISTATE_OFFSET_EBX 8
+#define ISTATE_SIZE_EBX 4
+#define ISTATE_OFFSET_ESI 12
+#define ISTATE_SIZE_ESI 4
+#define ISTATE_OFFSET_EDI 16
+#define ISTATE_SIZE_EDI 4
+#define ISTATE_OFFSET_EBP 20
+#define ISTATE_SIZE_EBP 4
+#define ISTATE_OFFSET_EAX 24
+#define ISTATE_SIZE_EAX 4
+#define ISTATE_OFFSET_EBP_FRAME 28
+#define ISTATE_SIZE_EBP_FRAME 4
+#define ISTATE_OFFSET_EIP_FRAME 32
+#define ISTATE_SIZE_EIP_FRAME 4
+#define ISTATE_OFFSET_GS 36
+#define ISTATE_SIZE_GS 4
+#define ISTATE_OFFSET_FS 40
+#define ISTATE_SIZE_FS 4
+#define ISTATE_OFFSET_ES 44
+#define ISTATE_SIZE_ES 4
+#define ISTATE_OFFSET_DS 48
+#define ISTATE_SIZE_DS 4
+#define ISTATE_OFFSET_ERROR_WORD 52
+#define ISTATE_SIZE_ERROR_WORD 4
+#define ISTATE_OFFSET_EIP 56
+#define ISTATE_SIZE_EIP 4
+#define ISTATE_OFFSET_CS 60
+#define ISTATE_SIZE_CS 4
+#define ISTATE_OFFSET_EFLAGS 64
+#define ISTATE_SIZE_EFLAGS 4
+#define ISTATE_OFFSET_ESP 68
+#define ISTATE_SIZE_ESP 4
+#define ISTATE_OFFSET_SS 72
+#define ISTATE_SIZE_SS 4
+#define ISTATE_SIZE 76
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+/*
+ * The strange order of the GPRs is given by the requirement to use the
+ * istate structure for both regular interrupts and exceptions as well
+ * as for syscall handlers which use this order as an optimization.
+ */
+typedef struct istate {
+	uint32_t edx;
+	uint32_t ecx;
+	uint32_t ebx;
+	uint32_t esi;
+	uint32_t edi;
+	uint32_t ebp;
+	uint32_t eax;
+	/* imitation of frame pointer linkage */
+	uint32_t ebp_frame;
+	/* imitation of return address linkage */
+	uint32_t eip_frame;
+	uint32_t gs;
+	uint32_t fs;
+	uint32_t es;
+	uint32_t ds;
+	/* real or fake error word */
+	uint32_t error_word;
+	uint32_t eip;
+	uint32_t cs;
+	uint32_t eflags;
+	/* only if istate_t is from uspace */
+	uint32_t esp;
+	/* only if istate_t is from uspace */
+	uint32_t ss;
+} istate_t;
+
+#endif
+#endif
+
Index: kernel/arch/ia64/Makefile.inc
===================================================================
--- kernel/arch/ia64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/ia64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -72,6 +72,6 @@
 endif
 
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(KARCH)/include/arch/istate_struct.h \
+	arch/$(KARCH)/include/arch/context_struct.h
 
Index: rnel/arch/ia64/include/arch/context_struct.ag
===================================================================
--- kernel/arch/ia64/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,235 +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>
-                }
-        ],
-
-        #
-        # Only save registers that must be preserved across function calls.
-        #
-        members : [
-                #
-                # Application registers
-                #
-                {
-                        name : ar_pfs,
-                        type : uint64_t
-                },
-                {
-                        name : ar_unat_caller,
-                        type : uint64_t
-                },
-                {
-                        name : ar_unat_callee,
-                        type : uint64_t
-                },
-                {
-                        name : ar_rsc,
-                        type : uint64_t
-                },
-                {
-                        # ar_bsp
-                        name : bsp,
-                        type : uint64_t
-                },
-                {
-                        name : ar_rnat,
-                        type : uint64_t
-                },
-                {
-                        name : ar_lc,
-                        type : uint64_t
-                },
-
-
-                #
-                # General registers
-                #
-                {
-                        name : r1,
-                        type : uint64_t
-                },
-                {
-                        name : r4,
-                        type : uint64_t
-                },
-                {
-                        name : r5,
-                        type : uint64_t
-                },
-                {
-                        name : r6,
-                        type : uint64_t
-                },
-                {
-                        name : r7,
-                        type : uint64_t
-                },
-                {
-                        # r12
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        name : r13,
-                        type : uint64_t
-                },
-
-
-                #
-                # Branch registers
-                #
-                {
-                        # b0
-                        name : pc,
-                        type : uint64_t
-                },
-                {
-                        name : b1,
-                        type : uint64_t
-                },
-                {
-                        name : b2,
-                        type : uint64_t
-                },
-                {
-                        name : b3,
-                        type : uint64_t
-                },
-                {
-                        name : b4,
-                        type : uint64_t
-                },
-                {
-                        name : b5,
-                        type : uint64_t
-                },
-
-
-                #
-                # Predicate registers
-                #
-                {
-                        name : pr,
-                        type : uint64_t
-                },
-
-                {
-                        name : f2,
-                        type : uint128_t
-                },
-                {
-                        name : f3,
-                        type : uint128_t
-                },
-                {
-                        name : f4,
-                        type : uint128_t
-                },
-                {
-                        name : f5,
-                        type : uint128_t
-                },
-
-                {
-                        name : f16,
-                        type : uint128_t
-                },
-                {
-                        name : f17,
-                        type : uint128_t
-                },
-                {
-                        name : f18,
-                        type : uint128_t
-                },
-                {
-                        name : f19,
-                        type : uint128_t
-                },
-                {
-                        name : f20,
-                        type : uint128_t
-                },
-                {
-                        name : f21,
-                        type : uint128_t
-                },
-                {
-                        name : f22,
-                        type : uint128_t
-                },
-                {
-                        name : f23,
-                        type : uint128_t
-                },
-                {
-                        name : f24,
-                        type : uint128_t
-                },
-                {
-                        name : f25,
-                        type : uint128_t
-                },
-                {
-                        name : f26,
-                        type : uint128_t
-                },
-                {
-                        name : f27,
-                        type : uint128_t
-                },
-                {
-                        name : f28,
-                        type : uint128_t
-                },
-                {
-                        name : f29,
-                        type : uint128_t
-                },
-                {
-                        name : f30,
-                        type : uint128_t
-                },
-                {
-                        name : f31,
-                        type : uint128_t
-                },
-
-                {
-                        name : ipl,
-                        type: ipl_t
-                }
-        ]
-}
-
Index: kernel/arch/ia64/include/arch/context_struct.h
===================================================================
--- kernel/arch/ia64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ia64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,138 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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_AR_PFS          0x00
+#define CONTEXT_OFFSET_AR_UNAT_CALLER  0x08
+#define CONTEXT_OFFSET_AR_UNAT_CALLEE  0x10
+#define CONTEXT_OFFSET_AR_RSC          0x18
+#define CONTEXT_OFFSET_BSP             0x20
+#define CONTEXT_OFFSET_AR_RNAT         0x28
+#define CONTEXT_OFFSET_AR_LC           0x30
+#define CONTEXT_OFFSET_R1              0x38
+#define CONTEXT_OFFSET_R4              0x40
+#define CONTEXT_OFFSET_R5              0x48
+#define CONTEXT_OFFSET_R6              0x50
+#define CONTEXT_OFFSET_R7              0x58
+#define CONTEXT_OFFSET_SP              0x60
+#define CONTEXT_OFFSET_R13             0x68
+#define CONTEXT_OFFSET_PC              0x70
+#define CONTEXT_OFFSET_B1              0x78
+#define CONTEXT_OFFSET_B2              0x80
+#define CONTEXT_OFFSET_B3              0x88
+#define CONTEXT_OFFSET_B4              0x90
+#define CONTEXT_OFFSET_B5              0x98
+#define CONTEXT_OFFSET_PR              0xa0
+#define CONTEXT_OFFSET_F2              0xb0
+#define CONTEXT_OFFSET_F3              0xc0
+#define CONTEXT_OFFSET_F4              0xd0
+#define CONTEXT_OFFSET_F5              0xe0
+#define CONTEXT_OFFSET_F16             0xf0
+#define CONTEXT_OFFSET_F17             0x100
+#define CONTEXT_OFFSET_F18             0x110
+#define CONTEXT_OFFSET_F19             0x120
+#define CONTEXT_OFFSET_F20             0x130
+#define CONTEXT_OFFSET_F21             0x140
+#define CONTEXT_OFFSET_F22             0x150
+#define CONTEXT_OFFSET_F23             0x160
+#define CONTEXT_OFFSET_F24             0x170
+#define CONTEXT_OFFSET_F25             0x180
+#define CONTEXT_OFFSET_F26             0x190
+#define CONTEXT_OFFSET_F27             0x1a0
+#define CONTEXT_OFFSET_F28             0x1b0
+#define CONTEXT_OFFSET_F29             0x1c0
+#define CONTEXT_OFFSET_F30             0x1d0
+#define CONTEXT_OFFSET_F31             0x1e0
+#define CONTEXT_OFFSET_IPL             0x1f0
+#define CONTEXT_SIZE                   0x200
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+// Only save registers that must be preserved across function calls.
+typedef struct context {
+	// Application registers.
+	uint64_t ar_pfs;
+	uint64_t ar_unat_caller;
+	uint64_t ar_unat_callee;
+	uint64_t ar_rsc;
+	// ar_bsp
+	uint64_t bsp;
+	uint64_t ar_rnat;
+	uint64_t ar_lc;
+
+	// General registers.
+	uint64_t r1;
+	uint64_t r4;
+	uint64_t r5;
+	uint64_t r6;
+	uint64_t r7;
+	// r12
+	uint64_t sp;
+	uint64_t r13;
+
+	// Branch registers.
+	// b0
+	uint64_t pc;
+	uint64_t b1;
+	uint64_t b2;
+	uint64_t b3;
+	uint64_t b4;
+	uint64_t b5;
+
+	// Predicate registers.
+	uint64_t pr;
+	uint128_t f2;
+	uint128_t f3;
+	uint128_t f4;
+	uint128_t f5;
+	uint128_t f16;
+	uint128_t f17;
+	uint128_t f18;
+	uint128_t f19;
+	uint128_t f20;
+	uint128_t f21;
+	uint128_t f22;
+	uint128_t f23;
+	uint128_t f24;
+	uint128_t f25;
+	uint128_t f26;
+	uint128_t f27;
+	uint128_t f28;
+	uint128_t f29;
+	uint128_t f30;
+	uint128_t f31;
+
+	ipl_t ipl;
+} context_t;
+
+#endif /* __ASSEMBLER__ */
+#endif
+
Index: rnel/arch/ia64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/ia64/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,267 +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>
-                },
-                {
-                        guard : KERNEL,
-                        include : <arch/register.h>
-                },
-                {
-                        negative-guard : KERNEL,
-                        include : <stddef.h>
-                },
-                {
-                        negative-guard : KERNEL,
-                        include : <stdint.h>
-                },
-                {
-                        negative-guard : KERNEL,
-                        include : <libarch/register.h>
-                }
-        ],
-
-        members : [
-                {
-                        name : f2,
-                        type : uint128_t
-                },
-                {
-                        name : f3,
-                        type : uint128_t
-                },
-                {
-                        name : f4,
-                        type : uint128_t
-                },
-                {
-                        name : f5,
-                        type : uint128_t
-                },
-                {
-                        name : f6,
-                        type : uint128_t
-                },
-                {
-                        name : f7,
-                        type : uint128_t
-                },
-                {
-                        name : f8,
-                        type : uint128_t
-                },
-                {
-                        name : f9,
-                        type : uint128_t
-                },
-                {
-                        name : f10,
-                        type : uint128_t
-                },
-                {
-                        name : f11,
-                        type : uint128_t
-                },
-                {
-                        name : f12,
-                        type : uint128_t
-                },
-                {
-                        name : f13,
-                        type : uint128_t
-                },
-                {
-                        name : f14,
-                        type : uint128_t
-                },
-                {
-                        name : f15,
-                        type : uint128_t
-                },
-                {
-                        name : f16,
-                        type : uint128_t
-                },
-                {
-                        name : f17,
-                        type : uint128_t
-                },
-                {
-                        name : f18,
-                        type : uint128_t
-                },
-                {
-                        name : f19,
-                        type : uint128_t
-                },
-                {
-                        name : f20,
-                        type : uint128_t
-                },
-                {
-                        name : f21,
-                        type : uint128_t
-                },
-                {
-                        name : f22,
-                        type : uint128_t
-                },
-                {
-                        name : f23,
-                        type : uint128_t
-                },
-                {
-                        name : f24,
-                        type : uint128_t
-                },
-                {
-                        name : f25,
-                        type : uint128_t
-                },
-                {
-                        name : f26,
-                        type : uint128_t
-                },
-                {
-                        name : f27,
-                        type : uint128_t
-                },
-                {
-                        name : f28,
-                        type : uint128_t
-                },
-                {
-                        name : f29,
-                        type : uint128_t
-                },
-                {
-                        name : f30,
-                        type : uint128_t
-                },
-                {
-                        name : f31,
-                        type : uint128_t
-                },
-
-                {
-                        name : ar_bsp,
-                        type : uintptr_t
-                },
-                {
-                        name : ar_bspstore,
-                        type : uintptr_t
-                },
-                {
-                        name : ar_bspstore_new,
-                        type : uintptr_t
-                },
-                {
-                        name : ar_rnat,
-                        type : uint64_t
-                },
-                {
-                        name : ar_ifs,
-                        type : uint64_t
-                },
-                {
-                        name : ar_pfs,
-                        type : uint64_t
-                },
-                {
-                        name : ar_rsc,
-                        type : uint64_t
-                },
-                {
-                        name : cr_ifa,
-                        type : uintptr_t
-                },
-                {
-                        name : cr_isr,
-                        type : cr_isr_t
-                },
-                {
-                        name : cr_iipa,
-                        type : uintptr_t
-                },
-                {
-                        name : cr_ipsr,
-                        type : psr_t
-                },
-                {
-                        name : cr_iip,
-                        type : uintptr_t
-                },
-                {
-                        name : pr,
-                        type : uint64_t
-                },
-                {
-                        name : sp,
-                        type : uintptr_t
-                },
-
-                #
-                # The following variables are defined only for break_instruction
-                # handler.
-                #
-                {
-                        name : in0,
-                        type : uint64_t
-                },
-                {
-                        name : in1,
-                        type : uint64_t
-                },
-                {
-                        name : in2,
-                        type : uint64_t
-                },
-                {
-                        name : in3,
-                        type : uint64_t
-                },
-                {
-                        name : in4,
-                        type : uint64_t
-                },
-                {
-                        name : in5,
-                        type : uint64_t
-                },
-                {
-                        name : in6,
-                        type : uint64_t
-                }
-        ]
-}
-
Index: kernel/arch/ia64/include/arch/istate_struct.h
===================================================================
--- kernel/arch/ia64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ia64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,155 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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_F2                0x000
+#define ISTATE_OFFSET_F3                0x010
+#define ISTATE_OFFSET_F4                0x020
+#define ISTATE_OFFSET_F5                0x030
+#define ISTATE_OFFSET_F6                0x040
+#define ISTATE_OFFSET_F7                0x050
+#define ISTATE_OFFSET_F8                0x060
+#define ISTATE_OFFSET_F9                0x070
+#define ISTATE_OFFSET_F10               0x080
+#define ISTATE_OFFSET_F11               0x090
+#define ISTATE_OFFSET_F12               0x0a0
+#define ISTATE_OFFSET_F13               0x0b0
+#define ISTATE_OFFSET_F14               0x0c0
+#define ISTATE_OFFSET_F15               0x0d0
+#define ISTATE_OFFSET_F16               0x0e0
+#define ISTATE_OFFSET_F17               0x0f0
+#define ISTATE_OFFSET_F18               0x100
+#define ISTATE_OFFSET_F19               0x110
+#define ISTATE_OFFSET_F20               0x120
+#define ISTATE_OFFSET_F21               0x130
+#define ISTATE_OFFSET_F22               0x140
+#define ISTATE_OFFSET_F23               0x150
+#define ISTATE_OFFSET_F24               0x160
+#define ISTATE_OFFSET_F25               0x170
+#define ISTATE_OFFSET_F26               0x180
+#define ISTATE_OFFSET_F27               0x190
+#define ISTATE_OFFSET_F28               0x1a0
+#define ISTATE_OFFSET_F29               0x1b0
+#define ISTATE_OFFSET_F30               0x1c0
+#define ISTATE_OFFSET_F31               0x1d0
+#define ISTATE_OFFSET_AR_BSP            0x1e0
+#define ISTATE_OFFSET_AR_BSPSTORE       0x1e8
+#define ISTATE_OFFSET_AR_BSPSTORE_NEW   0x1f0
+#define ISTATE_OFFSET_AR_RNAT           0x1f8
+#define ISTATE_OFFSET_AR_IFS            0x200
+#define ISTATE_OFFSET_AR_PFS            0x208
+#define ISTATE_OFFSET_AR_RSC            0x210
+#define ISTATE_OFFSET_CR_IFA            0x218
+#define ISTATE_OFFSET_CR_ISR            0x220
+#define ISTATE_OFFSET_CR_IIPA           0x228
+#define ISTATE_OFFSET_CR_IPSR           0x230
+#define ISTATE_OFFSET_CR_IIP            0x238
+#define ISTATE_OFFSET_PR                0x240
+#define ISTATE_OFFSET_SP                0x248
+#define ISTATE_OFFSET_IN0               0x250
+#define ISTATE_OFFSET_IN1               0x258
+#define ISTATE_OFFSET_IN2               0x260
+#define ISTATE_OFFSET_IN3               0x268
+#define ISTATE_OFFSET_IN4               0x270
+#define ISTATE_OFFSET_IN5               0x278
+#define ISTATE_OFFSET_IN6               0x280
+#define ISTATE_SIZE                     0x290
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+#ifdef KERNEL
+#include <typedefs.h>
+#include <arch/register.h>
+#else
+#include <stddef.h>
+#include <libarch/register.h>
+#endif
+
+typedef struct istate {
+	uint128_t f2;
+	uint128_t f3;
+	uint128_t f4;
+	uint128_t f5;
+	uint128_t f6;
+	uint128_t f7;
+	uint128_t f8;
+	uint128_t f9;
+	uint128_t f10;
+	uint128_t f11;
+	uint128_t f12;
+	uint128_t f13;
+	uint128_t f14;
+	uint128_t f15;
+	uint128_t f16;
+	uint128_t f17;
+	uint128_t f18;
+	uint128_t f19;
+	uint128_t f20;
+	uint128_t f21;
+	uint128_t f22;
+	uint128_t f23;
+	uint128_t f24;
+	uint128_t f25;
+	uint128_t f26;
+	uint128_t f27;
+	uint128_t f28;
+	uint128_t f29;
+	uint128_t f30;
+	uint128_t f31;
+	uintptr_t ar_bsp;
+	uintptr_t ar_bspstore;
+	uintptr_t ar_bspstore_new;
+	uint64_t ar_rnat;
+	uint64_t ar_ifs;
+	uint64_t ar_pfs;
+	uint64_t ar_rsc;
+	uintptr_t cr_ifa;
+	cr_isr_t cr_isr;
+	uintptr_t cr_iipa;
+	psr_t cr_ipsr;
+	uintptr_t cr_iip;
+	uint64_t pr;
+	uintptr_t sp;
+
+	// The following variables are defined only for break_instruction
+	// handler.
+	uint64_t in0;
+	uint64_t in1;
+	uint64_t in2;
+	uint64_t in3;
+	uint64_t in4;
+	uint64_t in5;
+	uint64_t in6;
+} istate_t;
+
+#endif
+#endif
+
Index: kernel/arch/mips32/Makefile.inc
===================================================================
--- kernel/arch/mips32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/mips32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -88,6 +88,6 @@
 endif
 
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag \
-	arch/$(KARCH)/include/arch/fpu_context_struct.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(KARCH)/include/arch/istate_struct.h \
+	arch/$(KARCH)/include/arch/context_struct.h \
+	arch/$(KARCH)/include/arch/fpu_context_struct.h
Index: rnel/arch/mips32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(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 d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/mips32/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -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: rnel/arch/mips32/include/arch/fpu_context_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/fpu_context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(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 d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/mips32/include/arch/fpu_context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -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: rnel/arch/mips32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/mips32/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(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 d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/mips32/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -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
+
Index: kernel/arch/ppc32/Makefile.inc
===================================================================
--- kernel/arch/ppc32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/ppc32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -59,7 +59,7 @@
 	arch/$(KARCH)/src/drivers/pic.c
 
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag \
-	arch/$(KARCH)/include/arch/fpu_context_struct.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(KARCH)/include/arch/istate_struct.h \
+	arch/$(KARCH)/include/arch/context_struct.h \
+	arch/$(KARCH)/include/arch/fpu_context_struct.h
 
Index: rnel/arch/ppc32/include/arch/context_struct.ag
===================================================================
--- kernel/arch/ppc32/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,139 +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 : [
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-
-                {
-                        name : r2,
-                        type : uint32_t
-                },
-                {
-                        name : r13,
-                        type : uint32_t
-                },
-                {
-                        name : r14,
-                        type : uint32_t
-                },
-                {
-                        name : r15,
-                        type : uint32_t
-                },
-                {
-                        name : r16,
-                        type : uint32_t
-                },
-                {
-                        name : r17,
-                        type : uint32_t
-                },
-                {
-                        name : r18,
-                        type : uint32_t
-                },
-                {
-                        name : r19,
-                        type : uint32_t
-                },
-                {
-                        name : r20,
-                        type : uint32_t
-                },
-                {
-                        name : r21,
-                        type : uint32_t
-                },
-                {
-                        name : r22,
-                        type : uint32_t
-                },
-                {
-                        name : r23,
-                        type : uint32_t
-                },
-                {
-                        name : r24,
-                        type : uint32_t
-                },
-                {
-                        name : r25,
-                        type : uint32_t
-                },
-                {
-                        name : r26,
-                        type : uint32_t
-                },
-                {
-                        name : r27,
-                        type : uint32_t
-                },
-                {
-                        name : r28,
-                        type : uint32_t
-                },
-                {
-                        name : r29,
-                        type : uint32_t
-                },
-                {
-                        name : r30,
-                        type : uint32_t
-                },
-                {
-                        name : r31,
-                        type : uint32_t
-                },
-
-                {
-                        name : cr,
-                        type : uint32_t
-                },
-
-                {
-                        name : ipl,
-                        type : ipl_t
-                }
-        ]
-}
-
Index: kernel/arch/ppc32/include/arch/context_struct.h
===================================================================
--- kernel/arch/ppc32/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ppc32/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,91 @@
+/*
+ * 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_R2   0x08
+#define CONTEXT_OFFSET_R13  0x0c
+#define CONTEXT_OFFSET_R14  0x10
+#define CONTEXT_OFFSET_R15  0x14
+#define CONTEXT_OFFSET_R16  0x18
+#define CONTEXT_OFFSET_R17  0x1c
+#define CONTEXT_OFFSET_R18  0x20
+#define CONTEXT_OFFSET_R19  0x24
+#define CONTEXT_OFFSET_R20  0x28
+#define CONTEXT_OFFSET_R21  0x2c
+#define CONTEXT_OFFSET_R22  0x30
+#define CONTEXT_OFFSET_R23  0x34
+#define CONTEXT_OFFSET_R24  0x38
+#define CONTEXT_OFFSET_R25  0x3c
+#define CONTEXT_OFFSET_R26  0x40
+#define CONTEXT_OFFSET_R27  0x44
+#define CONTEXT_OFFSET_R28  0x48
+#define CONTEXT_OFFSET_R29  0x4c
+#define CONTEXT_OFFSET_R30  0x50
+#define CONTEXT_OFFSET_R31  0x54
+#define CONTEXT_OFFSET_CR   0x58
+#define CONTEXT_OFFSET_IPL  0x5c
+#define CONTEXT_SIZE        0x60
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+typedef struct context {
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t r2;
+	uint32_t r13;
+	uint32_t r14;
+	uint32_t r15;
+	uint32_t r16;
+	uint32_t r17;
+	uint32_t r18;
+	uint32_t r19;
+	uint32_t r20;
+	uint32_t r21;
+	uint32_t r22;
+	uint32_t r23;
+	uint32_t r24;
+	uint32_t r25;
+	uint32_t r26;
+	uint32_t r27;
+	uint32_t r28;
+	uint32_t r29;
+	uint32_t r30;
+	uint32_t r31;
+	uint32_t cr;
+	ipl_t ipl;
+} context_t;
+
+#endif
+#endif
+
Index: rnel/arch/ppc32/include/arch/fpu_context_struct.ag
===================================================================
--- kernel/arch/ppc32/include/arch/fpu_context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,173 +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 : fr0,
-                        type : uint64_t
-                },
-                {
-                        name : fr1,
-                        type : uint64_t
-                },
-                {
-                        name : fr2,
-                        type : uint64_t
-                },
-                {
-                        name : fr3,
-                        type : uint64_t
-                },
-                {
-                        name : fr4,
-                        type : uint64_t
-                },
-                {
-                        name : fr5,
-                        type : uint64_t
-                },
-                {
-                        name : fr6,
-                        type : uint64_t
-                },
-                {
-                        name : fr7,
-                        type : uint64_t
-                },
-                {
-                        name : fr8,
-                        type : uint64_t
-                },
-                {
-                        name : fr9,
-                        type : uint64_t
-                },
-                {
-                        name : fr10,
-                        type : uint64_t
-                },
-                {
-                        name : fr11,
-                        type : uint64_t
-                },
-                {
-                        name : fr12,
-                        type : uint64_t
-                },
-                {
-                        name : fr13,
-                        type : uint64_t
-                },
-                {
-                        name : fr14,
-                        type : uint64_t
-                },
-                {
-                        name : fr15,
-                        type : uint64_t
-                },
-                {
-                        name : fr16,
-                        type : uint64_t
-                },
-                {
-                        name : fr17,
-                        type : uint64_t
-                },
-                {
-                        name : fr18,
-                        type : uint64_t
-                },
-                {
-                        name : fr19,
-                        type : uint64_t
-                },
-                {
-                        name : fr20,
-                        type : uint64_t
-                },
-                {
-                        name : fr21,
-                        type : uint64_t
-                },
-                {
-                        name : fr22,
-                        type : uint64_t
-                },
-                {
-                        name : fr23,
-                        type : uint64_t
-                },
-                {
-                        name : fr24,
-                        type : uint64_t
-                },
-                {
-                        name : fr25,
-                        type : uint64_t
-                },
-                {
-                        name : fr26,
-                        type : uint64_t
-                },
-                {
-                        name : fr27,
-                        type : uint64_t
-                },
-                {
-                        name : fr28,
-                        type : uint64_t
-                },
-                {
-                        name : fr29,
-                        type : uint64_t
-                },
-                {
-                        name : fr30,
-                        type : uint64_t
-                },
-                {
-                        name : fr31,
-                        type : uint64_t
-                },
-                {
-                        name : fpscr,
-                        type : uint64_t
-                }
-
-        ]
-}
-
Index: kernel/arch/ppc32/include/arch/fpu_context_struct.h
===================================================================
--- kernel/arch/ppc32/include/arch/fpu_context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ppc32/include/arch/fpu_context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,109 @@
+/*
+ * 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_FR0    0x00
+#define FPU_CONTEXT_OFFSET_FR1    0x08
+#define FPU_CONTEXT_OFFSET_FR2    0x10
+#define FPU_CONTEXT_OFFSET_FR3    0x18
+#define FPU_CONTEXT_OFFSET_FR4    0x20
+#define FPU_CONTEXT_OFFSET_FR5    0x28
+#define FPU_CONTEXT_OFFSET_FR6    0x30
+#define FPU_CONTEXT_OFFSET_FR7    0x38
+#define FPU_CONTEXT_OFFSET_FR8    0x40
+#define FPU_CONTEXT_OFFSET_FR9    0x48
+#define FPU_CONTEXT_OFFSET_FR10   0x50
+#define FPU_CONTEXT_OFFSET_FR11   0x58
+#define FPU_CONTEXT_OFFSET_FR12   0x60
+#define FPU_CONTEXT_OFFSET_FR13   0x68
+#define FPU_CONTEXT_OFFSET_FR14   0x70
+#define FPU_CONTEXT_OFFSET_FR15   0x78
+#define FPU_CONTEXT_OFFSET_FR16   0x80
+#define FPU_CONTEXT_OFFSET_FR17   0x88
+#define FPU_CONTEXT_OFFSET_FR18   0x90
+#define FPU_CONTEXT_OFFSET_FR19   0x98
+#define FPU_CONTEXT_OFFSET_FR20   0xa0
+#define FPU_CONTEXT_OFFSET_FR21   0xa8
+#define FPU_CONTEXT_OFFSET_FR22   0xb0
+#define FPU_CONTEXT_OFFSET_FR23   0xb8
+#define FPU_CONTEXT_OFFSET_FR24   0xc0
+#define FPU_CONTEXT_OFFSET_FR25   0xc8
+#define FPU_CONTEXT_OFFSET_FR26   0xd0
+#define FPU_CONTEXT_OFFSET_FR27   0xd8
+#define FPU_CONTEXT_OFFSET_FR28   0xe0
+#define FPU_CONTEXT_OFFSET_FR29   0xe8
+#define FPU_CONTEXT_OFFSET_FR30   0xf0
+#define FPU_CONTEXT_OFFSET_FR31   0xf8
+#define FPU_CONTEXT_OFFSET_FPSCR  0x100
+#define FPU_CONTEXT_SIZE          0x108
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+typedef struct fpu_context {
+	uint64_t fr0;
+	uint64_t fr1;
+	uint64_t fr2;
+	uint64_t fr3;
+	uint64_t fr4;
+	uint64_t fr5;
+	uint64_t fr6;
+	uint64_t fr7;
+	uint64_t fr8;
+	uint64_t fr9;
+	uint64_t fr10;
+	uint64_t fr11;
+	uint64_t fr12;
+	uint64_t fr13;
+	uint64_t fr14;
+	uint64_t fr15;
+	uint64_t fr16;
+	uint64_t fr17;
+	uint64_t fr18;
+	uint64_t fr19;
+	uint64_t fr20;
+	uint64_t fr21;
+	uint64_t fr22;
+	uint64_t fr23;
+	uint64_t fr24;
+	uint64_t fr25;
+	uint64_t fr26;
+	uint64_t fr27;
+	uint64_t fr28;
+	uint64_t fr29;
+	uint64_t fr30;
+	uint64_t fr31;
+	uint64_t fpscr;
+} fpu_context_t;
+
+#endif
+#endif
+
Index: rnel/arch/ppc32/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/ppc32/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,216 +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 : [
-                {
-                        # imitation of frame pointer linkage
-                        name : sp_frame,
-                        type : uint32_t
-                },
-                {
-                        # imitation of return adress linkage
-                        name : lr_frame,
-                        type : uint32_t
-                },
-                {
-                        name : r0,
-                        type : uint32_t
-                },
-                {
-                        name : r2,
-                        type : uint32_t
-                },
-                {
-                        name : r3,
-                        type : uint32_t
-                },
-                {
-                        name : r4,
-                        type : uint32_t
-                },
-                {
-                        name : r5,
-                        type : uint32_t
-                },
-                {
-                        name : r6,
-                        type : uint32_t
-                },
-                {
-                        name : r7,
-                        type : uint32_t
-                },
-                {
-                        name : r8,
-                        type : uint32_t
-                },
-                {
-                        name : r9,
-                        type : uint32_t
-                },
-                {
-                        name : r10,
-                        type : uint32_t
-                },
-                {
-                        name : r11,
-                        type : uint32_t
-                },
-                {
-                        name : r13,
-                        type : uint32_t
-                },
-                {
-                        name : r14,
-                        type : uint32_t
-                },
-                {
-                        name : r15,
-                        type : uint32_t
-                },
-                {
-                        name : r16,
-                        type : uint32_t
-                },
-                {
-                        name : r17,
-                        type : uint32_t
-                },
-                {
-                        name : r18,
-                        type : uint32_t
-                },
-                {
-                        name : r19,
-                        type : uint32_t
-                },
-                {
-                        name : r20,
-                        type : uint32_t
-                },
-                {
-                        name : r21,
-                        type : uint32_t
-                },
-                {
-                        name : r22,
-                        type : uint32_t
-                },
-                {
-                        name : r23,
-                        type : uint32_t
-                },
-                {
-                        name : r24,
-                        type : uint32_t
-                },
-                {
-                        name : r25,
-                        type : uint32_t
-                },
-                {
-                        name : r26,
-                        type : uint32_t
-                },
-                {
-                        name : r27,
-                        type : uint32_t
-                },
-                {
-                        name : r28,
-                        type : uint32_t
-                },
-                {
-                        name : r29,
-                        type : uint32_t
-                },
-                {
-                        name : r30,
-                        type : uint32_t
-                },
-                {
-                        name : r31,
-                        type : uint32_t
-                },
-                {
-                        name : cr,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-                {
-                        name : srr1,
-                        type : uint32_t
-                },
-                {
-                        name : lr,
-                        type : uint32_t
-                },
-                {
-                        name : ctr,
-                        type : uint32_t
-                },
-                {
-                        name : xer,
-                        type : uint32_t
-                },
-                {
-                        name : dar,
-                        type : uint32_t
-                },
-                {
-                        name : r12,
-                        type : uint32_t
-                },
-                {
-                        name : sp,
-                        type : uint32_t
-                }
-
-        ]
-}
-
Index: kernel/arch/ppc32/include/arch/istate_struct.h
===================================================================
--- kernel/arch/ppc32/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/ppc32/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,133 @@
+/*
+ * 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_SP_FRAME  0x00
+#define ISTATE_OFFSET_LR_FRAME  0x04
+#define ISTATE_OFFSET_R0        0x08
+#define ISTATE_OFFSET_R2        0x0c
+#define ISTATE_OFFSET_R3        0x10
+#define ISTATE_OFFSET_R4        0x14
+#define ISTATE_OFFSET_R5        0x18
+#define ISTATE_OFFSET_R6        0x1c
+#define ISTATE_OFFSET_R7        0x20
+#define ISTATE_OFFSET_R8        0x24
+#define ISTATE_OFFSET_R9        0x28
+#define ISTATE_OFFSET_R10       0x2c
+#define ISTATE_OFFSET_R11       0x30
+#define ISTATE_OFFSET_R13       0x34
+#define ISTATE_OFFSET_R14       0x38
+#define ISTATE_OFFSET_R15       0x3c
+#define ISTATE_OFFSET_R16       0x40
+#define ISTATE_OFFSET_R17       0x44
+#define ISTATE_OFFSET_R18       0x48
+#define ISTATE_OFFSET_R19       0x4c
+#define ISTATE_OFFSET_R20       0x50
+#define ISTATE_OFFSET_R21       0x54
+#define ISTATE_OFFSET_R22       0x58
+#define ISTATE_OFFSET_R23       0x5c
+#define ISTATE_OFFSET_R24       0x60
+#define ISTATE_OFFSET_R25       0x64
+#define ISTATE_OFFSET_R26       0x68
+#define ISTATE_OFFSET_R27       0x6c
+#define ISTATE_OFFSET_R28       0x70
+#define ISTATE_OFFSET_R29       0x74
+#define ISTATE_OFFSET_R30       0x78
+#define ISTATE_OFFSET_R31       0x7c
+#define ISTATE_OFFSET_CR        0x80
+#define ISTATE_OFFSET_PC        0x84
+#define ISTATE_OFFSET_SRR1      0x88
+#define ISTATE_OFFSET_LR        0x8c
+#define ISTATE_OFFSET_CTR       0x90
+#define ISTATE_OFFSET_XER       0x94
+#define ISTATE_OFFSET_DAR       0x98
+#define ISTATE_OFFSET_R12       0x9c
+#define ISTATE_OFFSET_SP        0xa0
+#define ISTATE_SIZE             0xa4
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+#ifdef KERNEL
+#include <typedefs.h>
+#else
+#include <stddef.h>
+#endif
+
+typedef struct istate {
+	/* imitation of frame pointer linkage */
+	uint32_t sp_frame;
+	/* imitation of return adress linkage */
+	uint32_t lr_frame;
+	uint32_t r0;
+	uint32_t r2;
+	uint32_t r3;
+	uint32_t r4;
+	uint32_t r5;
+	uint32_t r6;
+	uint32_t r7;
+	uint32_t r8;
+	uint32_t r9;
+	uint32_t r10;
+	uint32_t r11;
+	uint32_t r13;
+	uint32_t r14;
+	uint32_t r15;
+	uint32_t r16;
+	uint32_t r17;
+	uint32_t r18;
+	uint32_t r19;
+	uint32_t r20;
+	uint32_t r21;
+	uint32_t r22;
+	uint32_t r23;
+	uint32_t r24;
+	uint32_t r25;
+	uint32_t r26;
+	uint32_t r27;
+	uint32_t r28;
+	uint32_t r29;
+	uint32_t r30;
+	uint32_t r31;
+	uint32_t cr;
+	uint32_t pc;
+	uint32_t srr1;
+	uint32_t lr;
+	uint32_t ctr;
+	uint32_t xer;
+	uint32_t dar;
+	uint32_t r12;
+	uint32_t sp;
+} istate_t;
+
+#endif
+#endif
+
Index: kernel/arch/riscv64/Makefile.inc
===================================================================
--- kernel/arch/riscv64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/riscv64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -54,5 +54,5 @@
 	arch/$(KARCH)/src/mm/tlb.c
 
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(KARCH)/include/arch/istate_struct.h \
+	arch/$(KARCH)/include/arch/context_struct.h
Index: rnel/arch/riscv64/include/arch/context_struct.ag
===================================================================
--- kernel/arch/riscv64/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,115 +1,0 @@
-#
-# Copyright (c) 2016 Martin Decky
-# 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 : uint64_t
-                },
-                {
-                        name : pc,
-                        type : uint64_t
-                },
-
-                {
-                        name : gp,
-                        type : uint64_t
-                },
-                {
-                        name : tp,
-                        type : uint64_t
-                },
-                {
-                        name : s0,
-                        type : uint64_t
-                },
-                {
-                        name : s1,
-                        type : uint64_t
-                },
-                {
-                        name : s2,
-                        type : uint64_t
-                },
-                {
-                        name : s3,
-                        type : uint64_t
-                },
-                {
-                        name : s4,
-                        type : uint64_t
-                },
-                {
-                        name : s5,
-                        type : uint64_t
-                },
-                {
-                        name : s6,
-                        type : uint64_t
-                },
-                {
-                        name : s7,
-                        type : uint64_t
-                },
-                {
-                        name : s8,
-                        type : uint64_t
-                },
-                {
-                        name : s9,
-                        type : uint64_t
-                },
-                {
-                        name : s10,
-                        type : uint64_t
-                },
-                {
-                        name : s11,
-                        type : uint64_t
-                },
-
-                {
-                        name : ipl,
-                        type : ipl_t
-                }
-        ]
-}
Index: kernel/arch/riscv64/include/arch/context_struct.h
===================================================================
--- kernel/arch/riscv64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/riscv64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2016 Martin Decky
+ * 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   0x08
+#define CONTEXT_OFFSET_GP   0x10
+#define CONTEXT_OFFSET_TP   0x18
+#define CONTEXT_OFFSET_S0   0x20
+#define CONTEXT_OFFSET_S1   0x28
+#define CONTEXT_OFFSET_S2   0x30
+#define CONTEXT_OFFSET_S3   0x38
+#define CONTEXT_OFFSET_S4   0x40
+#define CONTEXT_OFFSET_S5   0x48
+#define CONTEXT_OFFSET_S6   0x50
+#define CONTEXT_OFFSET_S7   0x58
+#define CONTEXT_OFFSET_S8   0x60
+#define CONTEXT_OFFSET_S9   0x68
+#define CONTEXT_OFFSET_S10  0x70
+#define CONTEXT_OFFSET_S11  0x78
+#define CONTEXT_OFFSET_IPL  0x80
+#define CONTEXT_SIZE        0x88
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+typedef struct context {
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t gp;
+	uint64_t tp;
+	uint64_t s0;
+	uint64_t s1;
+	uint64_t s2;
+	uint64_t s3;
+	uint64_t s4;
+	uint64_t s5;
+	uint64_t s6;
+	uint64_t s7;
+	uint64_t s8;
+	uint64_t s9;
+	uint64_t s10;
+	uint64_t s11;
+	ipl_t ipl;
+} context_t;
+
+#endif
+#endif
+
Index: rnel/arch/riscv64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/riscv64/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,181 +1,0 @@
-#
-# Copyright (c) 2016 Martin Decky
-# 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 : [
-                {
-                        name : zero,
-                        type : uint64_t
-                },
-                {
-                        name : ra,
-                        type : uint64_t
-                },
-                {
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        name : x3,
-                        type : uint64_t
-                },
-                {
-                        name : x4,
-                        type : uint64_t
-                },
-                {
-                        name : x5,
-                        type : uint64_t
-                },
-                {
-                        name : x6,
-                        type : uint64_t
-                },
-                {
-                        name : x7,
-                        type : uint64_t
-                },
-                {
-                        name : x8,
-                        type : uint64_t
-                },
-                {
-                        name : x9,
-                        type : uint64_t
-                },
-                {
-                        name : x10,
-                        type : uint64_t
-                },
-                {
-                        name : x11,
-                        type : uint64_t
-                },
-                {
-                        name : x12,
-                        type : uint64_t
-                },
-                {
-                        name : x13,
-                        type : uint64_t
-                },
-                {
-                        name : x14,
-                        type : uint64_t
-                },
-                {
-                        name : x15,
-                        type : uint64_t
-                },
-                {
-                        name : x16,
-                        type : uint64_t
-                },
-                {
-                        name : x17,
-                        type : uint64_t
-                },
-                {
-                        name : x18,
-                        type : uint64_t
-                },
-                {
-                        name : x19,
-                        type : uint64_t
-                },
-                {
-                        name : x20,
-                        type : uint64_t
-                },
-                {
-                        name : x21,
-                        type : uint64_t
-                },
-                {
-                        name : x22,
-                        type : uint64_t
-                },
-                {
-                        name : x23,
-                        type : uint64_t
-                },
-                {
-                        name : x24,
-                        type : uint64_t
-                },
-                {
-                        name : x25,
-                        type : uint64_t
-                },
-                {
-                        name : x26,
-                        type : uint64_t
-                },
-                {
-                        name : x27,
-                        type : uint64_t
-                },
-                {
-                        name : x28,
-                        type : uint64_t
-                },
-                {
-                        name : x29,
-                        type : uint64_t
-                },
-                {
-                        name : x30,
-                        type : uint64_t
-                },
-                {
-                        name : x31,
-                        type : uint64_t
-                },
-                {
-                        name : pc,
-                        type : uint64_t
-                },
-        ]
-}
Index: kernel/arch/riscv64/include/arch/istate_struct.h
===================================================================
--- kernel/arch/riscv64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/riscv64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2016 Martin Decky
+ * 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_ZERO  0x00
+#define ISTATE_OFFSET_RA    0x08
+#define ISTATE_OFFSET_SP    0x10
+#define ISTATE_OFFSET_X3    0x18
+#define ISTATE_OFFSET_X4    0x20
+#define ISTATE_OFFSET_X5    0x28
+#define ISTATE_OFFSET_X6    0x30
+#define ISTATE_OFFSET_X7    0x38
+#define ISTATE_OFFSET_X8    0x40
+#define ISTATE_OFFSET_X9    0x48
+#define ISTATE_OFFSET_X10   0x50
+#define ISTATE_OFFSET_X11   0x58
+#define ISTATE_OFFSET_X12   0x60
+#define ISTATE_OFFSET_X13   0x68
+#define ISTATE_OFFSET_X14   0x70
+#define ISTATE_OFFSET_X15   0x78
+#define ISTATE_OFFSET_X16   0x80
+#define ISTATE_OFFSET_X17   0x88
+#define ISTATE_OFFSET_X18   0x90
+#define ISTATE_OFFSET_X19   0x98
+#define ISTATE_OFFSET_X20   0xa0
+#define ISTATE_OFFSET_X21   0xa8
+#define ISTATE_OFFSET_X22   0xb0
+#define ISTATE_OFFSET_X23   0xb8
+#define ISTATE_OFFSET_X24   0xc0
+#define ISTATE_OFFSET_X25   0xc8
+#define ISTATE_OFFSET_X26   0xd0
+#define ISTATE_OFFSET_X27   0xd8
+#define ISTATE_OFFSET_X28   0xe0
+#define ISTATE_OFFSET_X29   0xe8
+#define ISTATE_OFFSET_X30   0xf0
+#define ISTATE_OFFSET_X31   0xf8
+#define ISTATE_OFFSET_PC    0x100
+#define ISTATE_SIZE         0x108
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+#ifdef KERNEL
+#include <typedefs.h>
+#else
+#include <stddef.h>
+#endif
+
+typedef struct istate {
+	uint64_t zero;
+	uint64_t ra;
+	uint64_t sp;
+	uint64_t x3;
+	uint64_t x4;
+	uint64_t x5;
+	uint64_t x6;
+	uint64_t x7;
+	uint64_t x8;
+	uint64_t x9;
+	uint64_t x10;
+	uint64_t x11;
+	uint64_t x12;
+	uint64_t x13;
+	uint64_t x14;
+	uint64_t x15;
+	uint64_t x16;
+	uint64_t x17;
+	uint64_t x18;
+	uint64_t x19;
+	uint64_t x20;
+	uint64_t x21;
+	uint64_t x22;
+	uint64_t x23;
+	uint64_t x24;
+	uint64_t x25;
+	uint64_t x26;
+	uint64_t x27;
+	uint64_t x28;
+	uint64_t x29;
+	uint64_t x30;
+	uint64_t x31;
+	uint64_t pc;
+} istate_t;
+
+#endif
+#endif
+
Index: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/arch/sparc64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -110,6 +110,6 @@
 endif
 
-ARCH_AUTOGENS_AG = \
-	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(KARCH)/include/arch/istate_struct.h \
+	arch/$(KARCH)/include/arch/context_struct.h
 
Index: rnel/arch/sparc64/include/arch/context_struct.ag
===================================================================
--- kernel/arch/sparc64/include/arch/context_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,122 +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>
-                }
-        ],
-
-        #
-        # Save only registers that must be preserved across function calls.
-        #
-        members : [
-                {
-                        # %o6
-                        name : sp,
-                        type : uintptr_t
-                },
-                {
-                        # %o7
-                        name : pc,
-                        type : uintptr_t
-                },
-                {
-                        name : i0,
-                        type : uint64_t
-                },
-                {
-                        name : i1,
-                        type : uint64_t
-                },
-                {
-                        name : i2,
-                        type : uint64_t
-                },
-                {
-                        name : i3,
-                        type : uint64_t
-                },
-                {
-                        name : i4,
-                        type : uint64_t
-                },
-                {
-                        name : i5,
-                        type : uint64_t
-                },
-                {
-                        # %i6
-                        name : fp,
-                        type : uintptr_t
-                },
-                {
-                        name : i7,
-                        type : uintptr_t
-                },
-                {
-                        name : l0,
-                        type : uint64_t
-                },
-                {
-                        name : l1,
-                        type : uint64_t
-                },
-                {
-                        name : l2,
-                        type : uint64_t
-                },
-                {
-                        name : l3,
-                        type : uint64_t
-                },
-                {
-                        name : l4,
-                        type : uint64_t
-                },
-                {
-                        name : l5,
-                        type : uint64_t
-                },
-                {
-                        name : l6,
-                        type : uint64_t
-                },
-                {
-                        name : l7,
-                        type : uint64_t
-                },
-                {
-                        name : ipl,
-                        type : ipl_t
-                }
-        ]
-}
-
Index: kernel/arch/sparc64/include/arch/context_struct.h
===================================================================
--- kernel/arch/sparc64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/sparc64/include/arch/context_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,81 @@
+/*
+ * 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   0x08
+#define CONTEXT_OFFSET_I0   0x10
+#define CONTEXT_OFFSET_I1   0x18
+#define CONTEXT_OFFSET_I2   0x20
+#define CONTEXT_OFFSET_I3   0x28
+#define CONTEXT_OFFSET_I4   0x30
+#define CONTEXT_OFFSET_I5   0x38
+#define CONTEXT_OFFSET_FP   0x40
+#define CONTEXT_OFFSET_I7   0x48
+#define CONTEXT_OFFSET_L0   0x50
+#define CONTEXT_OFFSET_L1   0x58
+#define CONTEXT_OFFSET_L2   0x60
+#define CONTEXT_OFFSET_L3   0x68
+#define CONTEXT_OFFSET_L4   0x70
+#define CONTEXT_OFFSET_L5   0x78
+#define CONTEXT_OFFSET_L6   0x80
+#define CONTEXT_OFFSET_L7   0x88
+#define CONTEXT_OFFSET_IPL  0x90
+#define CONTEXT_SIZE        0x98
+
+#ifndef __ASSEMBLER__
+
+#include <typedefs.h>
+
+typedef struct context {
+	uintptr_t sp;  // %o6
+	uintptr_t pc;  // %o7
+	uint64_t i0;
+	uint64_t i1;
+	uint64_t i2;
+	uint64_t i3;
+	uint64_t i4;
+	uint64_t i5;
+	uintptr_t fp;  // %i6
+	uintptr_t i7;
+	uint64_t l0;
+	uint64_t l1;
+	uint64_t l2;
+	uint64_t l3;
+	uint64_t l4;
+	uint64_t l5;
+	uint64_t l6;
+	uint64_t l7;
+	ipl_t ipl;
+} context_t;
+
+#endif
+#endif
+
Index: rnel/arch/sparc64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/sparc64/include/arch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,204 +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 : [
-
-                #
-                # Window save area for locals and inputs. Required by ABI.
-                # Before using these, make sure that the corresponding register
-                # window has been spilled into memory, otherwise l0-l7 and
-                # i0-i7 will have undefined values.
-                #
-                {
-                        name : l0,
-                        type : uint64_t,
-                },
-                {
-                        name : l1,
-                        type : uint64_t,
-                },
-                {
-                        name : l2,
-                        type : uint64_t,
-                },
-                {
-                        name : l3,
-                        type : uint64_t,
-                },
-                {
-                        name : l4,
-                        type : uint64_t,
-                },
-                {
-                        name : l5,
-                        type : uint64_t,
-                },
-                {
-                        name : l6,
-                        type : uint64_t,
-                },
-                {
-                        name : l7,
-                        type : uint64_t,
-                },
-                {
-                        name : i0,
-                        type : uint64_t,
-                },
-                {
-                        name : i1,
-                        type : uint64_t,
-                },
-                {
-                        name : i2,
-                        type : uint64_t,
-                },
-                {
-                        name : i3,
-                        type : uint64_t,
-                },
-                {
-                        name : i4,
-                        type : uint64_t,
-                },
-                {
-                        name : i5,
-                        type : uint64_t,
-                },
-                {
-                        name : i6,
-                        type : uint64_t,
-                },
-                {
-                        name : i7,
-                        type : uint64_t,
-                },
-
-                #
-                # Six mandatory argument slots, required by the ABI, plus an
-                # optional argument slot for the 7th argument used by our
-                # syscalls. Since the preemptible handler is always passing
-                # integral arguments, undef_arg[0] - undef_arg[5] are always
-                # undefined.
-                #
-                {
-                        name : undef_arg,
-                        type : uint64_t,
-                        elements : 6,
-                },
-                {
-                        name : arg6,
-                        type : uint64_t,
-                },
-
-                #
-                # From this point onwards, the istate layout is not dicated by
-                # the ABI. The only requirement is the stack alignment.
-                #
-
-                {
-                        name : tnpc,
-                        type : uint64_t
-                },
-                {
-                        name : tpc,
-                        type : uint64_t
-                },
-                {
-                        name : tstate,
-                        type : uint64_t
-                },
-                {
-                        name : y,
-                        type : uint64_t,
-                },
-
-                #
-                # At the moment, these are defined only when needed by the
-                # preemptible handler, so consider them undefined for now.
-                #
-                {
-                        name : o0,
-                        type : uint64_t,
-                },
-                {
-                        name : o1,
-                        type : uint64_t,
-                },
-                {
-                        name : o2,
-                        type : uint64_t,
-                },
-                {
-                        name : o3,
-                        type : uint64_t,
-                },
-                {
-                        name : o4,
-                        type : uint64_t,
-                },
-                {
-                        name : o5,
-                        type : uint64_t,
-                },
-                {
-                        name : o6,
-                        type : uint64_t,
-                },
-                {
-                        name : o7,
-                        type : uint64_t,
-                },
-
-                #
-                # I/DTLB Tag Access register or zero for non-MMU traps.
-                #
-                {
-                        name : tlb_tag_access,
-                        type : uint64_t
-                }
-        ]
-}
-
Index: kernel/arch/sparc64/include/arch/istate_struct.h
===================================================================
--- kernel/arch/sparc64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/arch/sparc64/include/arch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,139 @@
+/*
+ * 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_L0              0x00
+#define ISTATE_OFFSET_L1              0x08
+#define ISTATE_OFFSET_L2              0x10
+#define ISTATE_OFFSET_L3              0x18
+#define ISTATE_OFFSET_L4              0x20
+#define ISTATE_OFFSET_L5              0x28
+#define ISTATE_OFFSET_L6              0x30
+#define ISTATE_OFFSET_L7              0x38
+#define ISTATE_OFFSET_I0              0x40
+#define ISTATE_OFFSET_I1              0x48
+#define ISTATE_OFFSET_I2              0x50
+#define ISTATE_OFFSET_I3              0x58
+#define ISTATE_OFFSET_I4              0x60
+#define ISTATE_OFFSET_I5              0x68
+#define ISTATE_OFFSET_I6              0x70
+#define ISTATE_OFFSET_I7              0x78
+#define ISTATE_OFFSET_UNDEF_ARG       0x80
+#define ISTATE_OFFSET_ARG6            0xb0
+#define ISTATE_OFFSET_TNPC            0xb8
+#define ISTATE_OFFSET_TPC             0xc0
+#define ISTATE_OFFSET_TSTATE          0xc8
+#define ISTATE_OFFSET_Y               0xd0
+#define ISTATE_OFFSET_O0              0xd8
+#define ISTATE_OFFSET_O1              0xe0
+#define ISTATE_OFFSET_O2              0xe8
+#define ISTATE_OFFSET_O3              0xf0
+#define ISTATE_OFFSET_O4              0xf8
+#define ISTATE_OFFSET_O5              0x100
+#define ISTATE_OFFSET_O6              0x108
+#define ISTATE_OFFSET_O7              0x110
+#define ISTATE_OFFSET_TLB_TAG_ACCESS  0x118
+#define ISTATE_SIZE                   0x120
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+#ifdef KERNEL
+#include <typedefs.h>
+#else
+#include <stddef.h>
+#endif
+
+typedef struct istate {
+	/*
+	 * Window save area for locals and inputs. Required by ABI.
+	 * Before using these, make sure that the corresponding register
+	 * window has been spilled into memory, otherwise l0-l7 and
+	 * i0-i7 will have undefined values.
+	 */
+	uint64_t l0;
+	uint64_t l1;
+	uint64_t l2;
+	uint64_t l3;
+	uint64_t l4;
+	uint64_t l5;
+	uint64_t l6;
+	uint64_t l7;
+	uint64_t i0;
+	uint64_t i1;
+	uint64_t i2;
+	uint64_t i3;
+	uint64_t i4;
+	uint64_t i5;
+	uint64_t i6;
+	uint64_t i7;
+
+	/*
+	 * Six mandatory argument slots, required by the ABI, plus an
+	 * optional argument slot for the 7th argument used by our
+	 * syscalls. Since the preemptible handler is always passing
+	 * integral arguments, undef_arg[0] - undef_arg[5] are always
+	 * undefined.
+	 */
+	uint64_t undef_arg[6];
+	uint64_t arg6;
+
+	/*
+	 * From this point onwards, the istate layout is not dicated by
+	 * the ABI. The only requirement is the stack alignment.
+	 */
+	uint64_t tnpc;
+	uint64_t tpc;
+	uint64_t tstate;
+	uint64_t y;
+
+	/*
+	 * At the moment, these are defined only when needed by the
+	 * preemptible handler, so consider them undefined for now.
+	 */
+	uint64_t o0;
+	uint64_t o1;
+	uint64_t o2;
+	uint64_t o3;
+	uint64_t o4;
+	uint64_t o5;
+	uint64_t o6;
+	uint64_t o7;
+
+	/*
+	 * I/DTLB Tag Access register or zero for non-MMU traps.
+	 */
+	uint64_t tlb_tag_access;
+} istate_t;
+
+#endif
+#endif
+
Index: kernel/genarch/Makefile.inc
===================================================================
--- kernel/genarch/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ kernel/genarch/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -172,7 +172,8 @@
 	genarch/src/multiboot/multiboot.c \
 	genarch/src/multiboot/multiboot2.c
-GENARCH_AUTOGENS_AG += \
-	genarch/include/genarch/multiboot/multiboot_memmap_struct.ag \
-	genarch/include/genarch/multiboot/multiboot_info_struct.ag
+
+GENARCH_AUTOCHECK_HEADERS += \
+	genarch/include/genarch/multiboot/multiboot_memmap_struct.h \
+	genarch/include/genarch/multiboot/multiboot_info_struct.h
 endif
 
Index: rnel/genarch/include/genarch/multiboot/multiboot_info_struct.ag
===================================================================
--- kernel/genarch/include/genarch/multiboot/multiboot_info_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,81 +1,0 @@
-# Copyright (c) 2016 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 : multiboot_info,
-        packed : true,
-
-        includes : [
-                {
-                        include : <typedefs.h>
-                },
-        ],
-
-        members : [
-                {
-                        name : flags,
-                        type : uint32_t
-                },
-                {
-                        name : mem_lower,
-                        type : uint32_t
-                },
-                {
-                        name : mem_upper,
-                        type : uint32_t
-                },
-                {
-                        name : boot_device,
-                        type : uint32_t
-                },
-                {
-                        name : cmd_line,
-                        type : uint32_t
-                },
-                {
-                        name : mods_count,
-                        type : uint32_t
-                },
-                {
-                        name : mods_addr,
-                        type : uint32_t
-                },
-                {
-                        name : syms,
-                        type : uint32_t,
-                        elements : 4,
-                },
-                {
-                        name : mmap_length,
-                        type : uint32_t,
-                },
-                {
-                        name : mmap_addr,
-                        type : uint32_t,
-                }
-        ]
-}
Index: kernel/genarch/include/genarch/multiboot/multiboot_info_struct.h
===================================================================
--- kernel/genarch/include/genarch/multiboot/multiboot_info_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/genarch/include/genarch/multiboot/multiboot_info_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,61 @@
+/* Copyright (c) 2016 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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_MULTIBOOT_INFO_STRUCT_H_
+#define KERN_MULTIBOOT_INFO_STRUCT_H_
+
+#define MULTIBOOT_INFO_OFFSET_FLAGS        0x00
+#define MULTIBOOT_INFO_OFFSET_MEM_LOWER    0x04
+#define MULTIBOOT_INFO_OFFSET_MEM_UPPER    0x08
+#define MULTIBOOT_INFO_OFFSET_BOOT_DEVICE  0x0c
+#define MULTIBOOT_INFO_OFFSET_CMD_LINE     0x10
+#define MULTIBOOT_INFO_OFFSET_MODS_COUNT   0x14
+#define MULTIBOOT_INFO_OFFSET_MODS_ADDR    0x18
+#define MULTIBOOT_INFO_OFFSET_SYMS         0x1c
+#define MULTIBOOT_INFO_OFFSET_MMAP_LENGTH  0x2c
+#define MULTIBOOT_INFO_OFFSET_MMAP_ADDR    0x30
+#define MULTIBOOT_INFO_SIZE                0x34
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct multiboot_info {
+	uint32_t flags;
+	uint32_t mem_lower;
+	uint32_t mem_upper;
+	uint32_t boot_device;
+	uint32_t cmd_line;
+	uint32_t mods_count;
+	uint32_t mods_addr;
+	uint32_t syms[4];
+	uint32_t mmap_length;
+	uint32_t mmap_addr;
+} __attribute__((packed)) multiboot_info_t;
+
+#endif
+#endif
Index: rnel/genarch/include/genarch/multiboot/multiboot_memmap_struct.ag
===================================================================
--- kernel/genarch/include/genarch/multiboot/multiboot_memmap_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,52 +1,0 @@
-# Copyright (c) 2016 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 : multiboot_memmap,
-        packed : true,
-
-        includes : [
-                {
-                        include : <typedefs.h>
-                },
-                {
-                        include : <arch/boot/memmap_struct.h>,
-                        depends: arch/$(KARCH)/include/arch/boot/memmap_struct.h,
-                }
-        ],
-
-        members : [
-                {
-                        name : size,
-                        type : uint32_t
-                },
-                {
-                        name : mm_info,
-                        type : e820memmap_t
-                }
-        ]
-}
Index: kernel/genarch/include/genarch/multiboot/multiboot_memmap_struct.h
===================================================================
--- kernel/genarch/include/genarch/multiboot/multiboot_memmap_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ kernel/genarch/include/genarch/multiboot/multiboot_memmap_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,49 @@
+/* Copyright (c) 2016 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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_MULTIBOOT_MEMMAP_STRUCT_H_
+#define KERN_MULTIBOOT_MEMMAP_STRUCT_H_
+
+#include <arch/boot/memmap_struct.h>
+
+#define MULTIBOOT_MEMMAP_OFFSET_SIZE     0x00
+#define MULTIBOOT_MEMMAP_OFFSET_MM_INFO  0x04
+#define MULTIBOOT_MEMMAP_SIZE            0x18
+
+#define MULTIBOOT_MEMMAP_SIZE_SIZE       0x04
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct multiboot_memmap {
+	uint32_t size;
+	e820memmap_t mm_info;
+} __attribute__((packed)) multiboot_memmap_t;
+
+#endif
+#endif
Index: tools/autocheck.awk
===================================================================
--- tools/autocheck.awk	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ tools/autocheck.awk	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,38 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+	filename = ARGV[1]
+	print "// Generated file. Fix the included header if static assert fails."
+	print "#include \"" filename "\""
+}
+
+/}.*;/ {
+	pattern = "}( __attribute__\\(.*\\))? (" struct_name "_t)?;"
+	if ($0 !~ pattern) {
+		print("Bad struct ending: " $0) > "/dev/stderr"
+		exit 1
+	}
+	macro_name = toupper(struct_name) "_SIZE"
+	print "_Static_assert(" macro_name " == sizeof(struct " struct_name "), \"\");"
+	struct_name = ""
+}
+
+/;$/ {
+	if (struct_name != "") {
+		# Remove array subscript, if any.
+		sub("(\\[.*\\])?;", "", $0)
+		member = $NF
+
+		macro_name = toupper(struct_name) "_OFFSET_" toupper(member)
+		print "_Static_assert(" macro_name " == __builtin_offsetof(struct " struct_name ", " member "), \"\");"
+
+		macro_name = toupper(struct_name) "_SIZE_" toupper(member)
+		print "#ifdef " macro_name
+		print "_Static_assert(" macro_name " == sizeof(((struct " struct_name "){})." member "), \"\");"
+		print "#endif"
+	}
+}
+
+/^typedef struct .* \{/ {
+	struct_name = $3
+}
Index: ols/autogen.py
===================================================================
--- tools/autogen.py	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,184 +1,0 @@
-#!/usr/bin/env python
-#
-# 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.
-#
-
-import sys
-import yaml
-import re
-
-def usage():
-	print("%s - Automated structure and offsets generator" % sys.argv[0])
-	print("%s file.ag depend|probe|generate struct.ag" % sys.argv[0])
-	sys.exit()
-
-def depend(struct):
-	deps = ""
-	for include in struct['includes']:
-		if 'depends' in include.keys():
-			deps = deps + include['depends'] + "\n"
-	return deps.strip()
-
-def generate_includes(struct):
-	code = ""
-	for include in struct['includes']:
-		if 'guard' in include.keys():
-			code = code + "#ifdef %s\n" % include['guard']
-		if 'negative-guard' in include.keys():
-			code = code + "#ifndef %s\n" % include['negative-guard']
-		code = code + "#include %s\n" % include['include']
-		if 'guard' in include.keys():
-			code = code + "#endif\n"
-		if 'negative-guard' in include.keys():
-			code = code + "#endif\n"
-	return code.strip()
-
-def generate_struct(struct):
-	packed = ""
-	if ('packed' in struct.keys() and struct['packed']):
-		packed = "__attribute__ ((packed)) "
-	code = "typedef struct %s {\n" % struct['name']
-	for i in range(len(struct['members'])):
-		member = struct['members'][i]
-		if 'elements' in member.keys():
-			code = code + "\t%s %s[%d];\n" % (member['type'], member['name'], member['elements'])
-		else:
-			code = code + "\t%s %s;\n" % (member['type'], member['name'])
-	code = code + "} %s%s_t;" % (packed, struct['name'])
-	return code
-
-def generate_probes(struct):
-	code = ""
-	for i in range(len(struct['members'])):
-		member = struct['members'][i]
-		code = code + ("\temit_constant(%s_OFFSET_%s, offsetof(%s_t, %s));\n" %
-		    (struct['name'].upper(), member['name'].upper(), struct['name'],
-		    member['name']))
-		code = code + ("\temit_constant(%s_SIZE_%s, sizeof(((%s_t *) 0)->%s));\n" %
-		    (struct['name'].upper(), member['name'].upper(), struct['name'],
-		    member['name']))
-		if 'elements' in member.keys():
-			code = code + ("\temit_constant(%s_%s_ITEM_SIZE, sizeof(%s));\n" %
-			    (struct['name'].upper(), member['name'].upper(), member['type']))
-
-	return code
-
-def probe(struct):
-	name = struct['name']
-	typename = struct['name'] + "_t"
-
-	code = """
-%s
-
-#define str(s) #s
-#define emit_constant(n, v) \
-    asm volatile ("EMITTED_CONSTANT " str(n) \" = %%0\" :: \"i\" (v))
-#undef offsetof
-#define offsetof(t, m) ((size_t) &(((t *) 0)->m))
-
-%s
-
-extern int main(int, char *[]);
-
-int main(int argc, char *argv[])
-{
-%s
-	emit_constant(%s_SIZE, sizeof(%s));
-	return 0;
-}
-	""" % (generate_includes(struct), generate_struct(struct),
-	    generate_probes(struct), name.upper(), typename)
-
-	return code
-
-def generate_defines(pairs):
-	code = ""
-	for pair in pairs:
-		code = code + "#define %s %s\n" % (pair[0], pair[1])
-	return code.strip()
-
-def generate(struct, lines):
-	code = """
-/*****************************************************************************
- * AUTO-GENERATED FILE, DO NOT EDIT!!!
- * Generated by: tools/autogen.py
- * Generated from: %s
- *****************************************************************************/
-
-#ifndef AUTOGEN_%s_H
-#define AUTOGEN_%s_H
-
-#ifndef __ASSEMBLER__
-%s
-#endif
-
-%s
-
-#ifndef __ASSEMBLER__
-%s
-#endif
-
-#endif
-	""" % (sys.argv[2], struct['name'].upper(), struct['name'].upper(),
-	    generate_includes(struct), generate_defines(lines),
-	    generate_struct(struct))
-
-	return code
-
-def filter_pairs(lines):
-	pattern = re.compile("^\tEMITTED_CONSTANT ([A-Z_][A-Z0-9_]*) = (\$|#)?([0-9]+)$");
-	pairs = []
-	for line in lines:
-		res = pattern.match(line)
-		if res == None:
-			continue
-		pairs = pairs + [res.group(1, 3)]
-	return pairs
-
-
-def run():
-	if len(sys.argv) != 3:
-		usage()
-
-	with open(sys.argv[2], "rb") as fp:
-		struct = yaml.load(fp)
-
-	if sys.argv[1] == "depend":
-		deps = depend(struct)
-		print(deps)
-	elif sys.argv[1] == "probe":
-		code = probe(struct)
-		print(code)
-	elif sys.argv[1] == "generate":
-		lines = sys.stdin.readlines()
-		pairs = filter_pairs(lines)
-		code = generate(struct, pairs)
-		print(code)
-	else:
-		usage()
-
-run()
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ tools/autotool.py	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -681,6 +681,4 @@
 		sandbox_leave(owd)
 
-	common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))
-
 	create_makefile(MAKEFILE, common)
 	create_header(HEADER, macros)
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/Makefile	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -47,10 +47,9 @@
 -include arch/$(UARCH)/Makefile.inc
 
-ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG)))
-ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG)))
-ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG)))
-
-PRE_DEPEND += $(ARCH_AUTOGENS_H)
-EXTRA_CLEAN += $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
+ARCH_AUTOGENS_PROBE_C := $(ARCH_AUTOGENS_AG:%.ag.h=.ag.c)
+ARCH_AUTOGENS_PROBE_S := $(ARCH_AUTOGENS_AG:%.ag.h=.ag.s)
+
+PRE_DEPEND += $(ARCH_AUTOGENS_AG)
+EXTRA_CLEAN += $(ARCH_AUTOGENS_AG) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
 
 GENERIC_SOURCES = \
@@ -179,4 +178,6 @@
 endif
 
+ARCH_SOURCES += $(ARCH_AUTOCHECK_HEADERS:%.h=%.check.c)
+
 SOURCES = \
 	$(GENERIC_SOURCES) \
@@ -195,9 +196,4 @@
 include $(USPACE_PREFIX)/Makefile.common
 
-%.h: %.ag
-	$(AUTOGEN) probe $< >$<.probe.c
-	$(CC_AUTOGEN) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
-	$(AUTOGEN) generate $< <$<.probe.s >$@
-
 $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
 	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@
@@ -208,2 +204,7 @@
 $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
 	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DDLEXE -E -x c $< | grep -v "^\#" > $@
+
+AUTOCHECK = $(realpath $(ROOT_PATH)/tools/autocheck.awk)
+
+%.check.c: %.h $(AUTOCHECK)
+	cd $(<D) && $(AUTOCHECK) $(<F) > $(@F)
Index: uspace/lib/c/arch/amd64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/amd64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/amd64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/amd64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,86 +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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                },
-        ],
-
-        members : [
-                #
-                # We include only registers that must be preserved
-                # during function call.
-                #
-
-                {
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        name : pc,
-                        type : uint64_t
-                },
-
-                {
-                        name : rbx,
-                        type : uint64_t
-                },
-                {
-                        name : rbp,
-                        type : uint64_t
-                },
-
-                {
-                        name : r12,
-                        type : uint64_t
-                },
-                {
-                        name : r13,
-                        type : uint64_t
-                },
-                {
-                        name : r14,
-                        type : uint64_t
-                },
-                {
-                        name : r15,
-                        type : uint64_t
-                },
-
-                {
-                        name : tls,
-                        type : uint64_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/amd64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/amd64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,63 @@
+/* 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x08
+#define CONTEXT_OFFSET_RBX  0x10
+#define CONTEXT_OFFSET_RBP  0x18
+#define CONTEXT_OFFSET_R12  0x20
+#define CONTEXT_OFFSET_R13  0x28
+#define CONTEXT_OFFSET_R14  0x30
+#define CONTEXT_OFFSET_R15  0x38
+#define CONTEXT_OFFSET_TLS  0x40
+#define CONTEXT_SIZE        0x48
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct context {
+	/* We include only registers that must be preserved
+	 * during function call.
+	 */
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t rbx;
+	uint64_t rbp;
+	uint64_t r12;
+	uint64_t r13;
+	uint64_t r14;
+	uint64_t r15;
+	uint64_t tls;
+} context_t;
+
+#endif
+#endif
+
Index: pace/lib/c/arch/amd64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/amd64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/amd64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/amd64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/amd64/include/arch/istate_struct.h
Index: uspace/lib/c/arch/arm32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/arm32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/arm32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -38,8 +38,4 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
-
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
 
Index: pace/lib/c/arch/arm32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,92 +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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-       #
-       # Only registers preserved accross function calls are included. r9 is
-       # used to store a TLS address. -ffixed-r9 gcc forces gcc not to use this
-       # register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain
-       # TLS address.
-       #
-        members : [
-                {
-                        name : sp,
-                        type : uintptr_t
-                },
-                {
-                        name : pc,
-                        type : uintptr_t
-                },
-
-                {
-                        name : r4,
-                        type : uint32_t
-                },
-                {
-                        name : r5,
-                        type : uint32_t
-                },
-                {
-                        name : r6,
-                        type : uint32_t
-                },
-                {
-                        name : r7,
-                        type : uint32_t
-                },
-                {
-                        name : r8,
-                        type : uint32_t
-                },
-                {
-                        # r9
-                        name : tls,
-                        type : uint32_t
-                },
-                {
-                        name : r10,
-                        type : uint32_t
-                },
-                {
-                        # r11
-                        name : fp,
-                        type : uint32_t
-                }
-        ]
-}
-
Index: uspace/lib/c/arch/arm32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/arm32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,58 @@
+/* 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#include <stdint.h>
+
+/*
+ * Only registers preserved accross function calls are included. r9 is
+ * used to store a TLS address. -ffixed-r9 gcc forces gcc not to use this
+ * register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain
+ * TLS address.
+ */
+
+// XXX: This struct must match the assembly code in src/fibril.S
+
+typedef struct context {
+	uintptr_t sp;
+	uintptr_t pc;
+	uint32_t r4;
+	uint32_t r5;
+	uint32_t r6;
+	uint32_t r7;
+	uint32_t r8;
+	/* r9*/
+	uint32_t tls;
+	uint32_t r10;
+	/* r11 */
+	uint32_t fp;
+} context_t;
+
+#endif
+
Index: pace/lib/c/arch/arm32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/arm32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/arm32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/arm32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/arm32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/ia32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ia32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/ia32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -38,7 +38,6 @@
 	arch/$(UARCH)/src/rtld/reloc.c
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/ia32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,77 +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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                #
-                # We include only registers that must be preserved
-                # during function call.
-                #
-
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-
-                {
-                        name : ebx,
-                        type : uint32_t
-                },
-                {
-                        name : esi,
-                        type : uint32_t
-                },
-                {
-                        name : edi,
-                        type : uint32_t
-                },
-                {
-                        name : ebp,
-                        type : uint32_t
-                },
-
-                {
-                        name : tls,
-                        type : uint32_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/ia32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,57 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x04
+#define CONTEXT_OFFSET_EBX  0x08
+#define CONTEXT_OFFSET_ESI  0x0c
+#define CONTEXT_OFFSET_EDI  0x10
+#define CONTEXT_OFFSET_EBP  0x14
+#define CONTEXT_OFFSET_TLS  0x18
+#define CONTEXT_SIZE        0x1c
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+/* We include only registers that must be preserved during function call. */
+typedef struct context {
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t ebx;
+	uint32_t esi;
+	uint32_t edi;
+	uint32_t ebp;
+	uint32_t tls;
+} context_t;
+
+#endif
+#endif
+
Index: pace/lib/c/arch/ia32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ia32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ia32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ia32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/ia64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ia64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/ia64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -37,7 +37,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/ia64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,235 +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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        #
-        # Only save registers that must be preserved across function calls.
-        #
-        members : [
-                #
-                # Application registers
-                #
-                {
-                        name : ar_pfs,
-                        type : uint64_t
-                },
-                {
-                        name : ar_unat_caller,
-                        type : uint64_t
-                },
-                {
-                        name : ar_unat_callee,
-                        type : uint64_t
-                },
-                {
-                        name : ar_rsc,
-                        type : uint64_t
-                },
-                {
-                        # ar_bsp
-                        name : bsp,
-                        type : uint64_t
-                },
-                {
-                        name : ar_rnat,
-                        type : uint64_t
-                },
-                {
-                        name : ar_lc,
-                        type : uint64_t
-                },
-
-
-                #
-                # General registers
-                #
-                {
-                        name : r1,
-                        type : uint64_t
-                },
-                {
-                        name : r4,
-                        type : uint64_t
-                },
-                {
-                        name : r5,
-                        type : uint64_t
-                },
-                {
-                        name : r6,
-                        type : uint64_t
-                },
-                {
-                        name : r7,
-                        type : uint64_t
-                },
-                {
-                        # r12
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        # r13
-                        name : tp,
-                        type : uint64_t
-                },
-
-
-                #
-                # Branch registers
-                #
-                {
-                        # b0
-                        name : pc,
-                        type : uint64_t
-                },
-                {
-                        name : b1,
-                        type : uint64_t
-                },
-                {
-                        name : b2,
-                        type : uint64_t
-                },
-                {
-                        name : b3,
-                        type : uint64_t
-                },
-                {
-                        name : b4,
-                        type : uint64_t
-                },
-                {
-                        name : b5,
-                        type : uint64_t
-                },
-
-
-                #
-                # Predicate registers
-                #
-                {
-                        name : pr,
-                        type : uint64_t
-                },
-
-                {
-                        name : f2,
-                        type : uint128_t
-                },
-                {
-                        name : f3,
-                        type : uint128_t
-                },
-                {
-                        name : f4,
-                        type : uint128_t
-                },
-                {
-                        name : f5,
-                        type : uint128_t
-                },
-
-                {
-                        name : f16,
-                        type : uint128_t
-                },
-                {
-                        name : f17,
-                        type : uint128_t
-                },
-                {
-                        name : f18,
-                        type : uint128_t
-                },
-                {
-                        name : f19,
-                        type : uint128_t
-                },
-                {
-                        name : f20,
-                        type : uint128_t
-                },
-                {
-                        name : f21,
-                        type : uint128_t
-                },
-                {
-                        name : f22,
-                        type : uint128_t
-                },
-                {
-                        name : f23,
-                        type : uint128_t
-                },
-                {
-                        name : f24,
-                        type : uint128_t
-                },
-                {
-                        name : f25,
-                        type : uint128_t
-                },
-                {
-                        name : f26,
-                        type : uint128_t
-                },
-                {
-                        name : f27,
-                        type : uint128_t
-                },
-                {
-                        name : f28,
-                        type : uint128_t
-                },
-                {
-                        name : f29,
-                        type : uint128_t
-                },
-                {
-                        name : f30,
-                        type : uint128_t
-                },
-                {
-                        name : f31,
-                        type : uint128_t
-                }
-
-        ]
-}
-
Index: uspace/lib/c/arch/ia64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,136 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_AR_PFS          0x000
+#define CONTEXT_OFFSET_AR_UNAT_CALLER  0x008
+#define CONTEXT_OFFSET_AR_UNAT_CALLEE  0x010
+#define CONTEXT_OFFSET_AR_RSC          0x018
+#define CONTEXT_OFFSET_BSP             0x020
+#define CONTEXT_OFFSET_AR_RNAT         0x028
+#define CONTEXT_OFFSET_AR_LC           0x030
+#define CONTEXT_OFFSET_R1              0x038
+#define CONTEXT_OFFSET_R4              0x040
+#define CONTEXT_OFFSET_R5              0x048
+#define CONTEXT_OFFSET_R6              0x050
+#define CONTEXT_OFFSET_R7              0x058
+#define CONTEXT_OFFSET_SP              0x060
+#define CONTEXT_OFFSET_TP              0x068
+#define CONTEXT_OFFSET_PC              0x070
+#define CONTEXT_OFFSET_B1              0x078
+#define CONTEXT_OFFSET_B2              0x080
+#define CONTEXT_OFFSET_B3              0x088
+#define CONTEXT_OFFSET_B4              0x090
+#define CONTEXT_OFFSET_B5              0x098
+#define CONTEXT_OFFSET_PR              0x0a0
+#define CONTEXT_OFFSET_F2              0x0b0
+#define CONTEXT_OFFSET_F3              0x0c0
+#define CONTEXT_OFFSET_F4              0x0d0
+#define CONTEXT_OFFSET_F5              0x0e0
+#define CONTEXT_OFFSET_F16             0x0f0
+#define CONTEXT_OFFSET_F17             0x100
+#define CONTEXT_OFFSET_F18             0x110
+#define CONTEXT_OFFSET_F19             0x120
+#define CONTEXT_OFFSET_F20             0x130
+#define CONTEXT_OFFSET_F21             0x140
+#define CONTEXT_OFFSET_F22             0x150
+#define CONTEXT_OFFSET_F23             0x160
+#define CONTEXT_OFFSET_F24             0x170
+#define CONTEXT_OFFSET_F25             0x180
+#define CONTEXT_OFFSET_F26             0x190
+#define CONTEXT_OFFSET_F27             0x1a0
+#define CONTEXT_OFFSET_F28             0x1b0
+#define CONTEXT_OFFSET_F29             0x1c0
+#define CONTEXT_OFFSET_F30             0x1d0
+#define CONTEXT_OFFSET_F31             0x1e0
+#define CONTEXT_SIZE                   0x1f0
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+// Only save registers that must be preserved across function calls.
+typedef struct context {
+	// Application registers.
+	uint64_t ar_pfs;
+	uint64_t ar_unat_caller;
+	uint64_t ar_unat_callee;
+	uint64_t ar_rsc;
+	// ar_bsp
+	uint64_t bsp;
+	uint64_t ar_rnat;
+	uint64_t ar_lc;
+
+	// General registers.
+	uint64_t r1;
+	uint64_t r4;
+	uint64_t r5;
+	uint64_t r6;
+	uint64_t r7;
+	// r12
+	uint64_t sp;
+	// r13
+	uint64_t tp;
+
+	// Branch registers.
+	// b0
+	uint64_t pc;
+	uint64_t b1;
+	uint64_t b2;
+	uint64_t b3;
+	uint64_t b4;
+	uint64_t b5;
+
+	// Predicate registers.
+	uint64_t pr;
+	uint128_t f2;
+	uint128_t f3;
+	uint128_t f4;
+	uint128_t f5;
+	uint128_t f16;
+	uint128_t f17;
+	uint128_t f18;
+	uint128_t f19;
+	uint128_t f20;
+	uint128_t f21;
+	uint128_t f22;
+	uint128_t f23;
+	uint128_t f24;
+	uint128_t f25;
+	uint128_t f26;
+	uint128_t f27;
+	uint128_t f28;
+	uint128_t f29;
+	uint128_t f30;
+	uint128_t f31;
+} context_t;
+
+#endif  /* __ASSEMBLER__ */
+#endif
+
Index: pace/lib/c/arch/ia64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ia64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ia64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ia64/include/arch/istate_struct.h
Index: uspace/lib/c/arch/mips32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/mips32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/mips32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,141 +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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                {
-                        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
-                },
-                {
-                        # Thread local storage (k1)
-                        name : tls,
-                        type : uint32_t
-                },
-
-                {
-                        name : f20,
-                        type : uint32_t
-                },
-                {
-                        name : f21,
-                        type : uint32_t
-                },
-                {
-                        name : f22,
-                        type : uint32_t
-                },
-                {
-                        name : f23,
-                        type : uint32_t
-                },
-                {
-                        name : f24,
-                        type : uint32_t
-                },
-                {
-                        name : f25,
-                        type : uint32_t
-                },
-                {
-                        name : f26,
-                        type : uint32_t
-                },
-                {
-                        name : f27,
-                        type : uint32_t
-                },
-                {
-                        name : f28,
-                        type : uint32_t
-                },
-                {
-                        name : f29,
-                        type : uint32_t
-                },
-                {
-                        name : f30,
-                        type : uint32_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/mips32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,92 @@
+/* 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_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_TLS  0x30
+#define CONTEXT_OFFSET_F20  0x34
+#define CONTEXT_OFFSET_F21  0x38
+#define CONTEXT_OFFSET_F22  0x3c
+#define CONTEXT_OFFSET_F23  0x40
+#define CONTEXT_OFFSET_F24  0x44
+#define CONTEXT_OFFSET_F25  0x48
+#define CONTEXT_OFFSET_F26  0x4c
+#define CONTEXT_OFFSET_F27  0x50
+#define CONTEXT_OFFSET_F28  0x54
+#define CONTEXT_OFFSET_F29  0x58
+#define CONTEXT_OFFSET_F30  0x5c
+#define CONTEXT_SIZE        0x60
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct context {
+	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;
+	/* Thread local storage (k1) */
+	uint32_t tls;
+	uint32_t f20;
+	uint32_t f21;
+	uint32_t f22;
+	uint32_t f23;
+	uint32_t f24;
+	uint32_t f25;
+	uint32_t f26;
+	uint32_t f27;
+	uint32_t f28;
+	uint32_t f29;
+	uint32_t f30;
+} context_t;
+
+#endif
+#endif
+
Index: pace/lib/c/arch/mips32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/mips32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/mips32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/mips32eb/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32eb/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/mips32eb/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/mips32eb/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../mips32/include/libarch/fibril_context.ag
Index: uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/fibril_context.h
Index: pace/lib/c/arch/mips32eb/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../mips32/include/libarch/istate_struct.ag
Index: uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/istate_struct.h
Index: uspace/lib/c/arch/ppc32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ppc32/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/ppc32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/ppc32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,137 +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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-
-                {
-                        name : tls,
-                        type : uint32_t
-                },
-                {
-                        name : r13,
-                        type : uint32_t
-                },
-                {
-                        name : r14,
-                        type : uint32_t
-                },
-                {
-                        name : r15,
-                        type : uint32_t
-                },
-                {
-                        name : r16,
-                        type : uint32_t
-                },
-                {
-                        name : r17,
-                        type : uint32_t
-                },
-                {
-                        name : r18,
-                        type : uint32_t
-                },
-                {
-                        name : r19,
-                        type : uint32_t
-                },
-                {
-                        name : r20,
-                        type : uint32_t
-                },
-                {
-                        name : r21,
-                        type : uint32_t
-                },
-                {
-                        name : r22,
-                        type : uint32_t
-                },
-                {
-                        name : r23,
-                        type : uint32_t
-                },
-                {
-                        name : r24,
-                        type : uint32_t
-                },
-                {
-                        name : r25,
-                        type : uint32_t
-                },
-                {
-                        name : r26,
-                        type : uint32_t
-                },
-                {
-                        name : r27,
-                        type : uint32_t
-                },
-                {
-                        name : r28,
-                        type : uint32_t
-                },
-                {
-                        name : r29,
-                        type : uint32_t
-                },
-                {
-                        name : r30,
-                        type : uint32_t
-                },
-                {
-                        name : r31,
-                        type : uint32_t
-                },
-
-                {
-                        name : cr,
-                        type : uint32_t
-                }
-        ]
-}
-
Index: uspace/lib/c/arch/ppc32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ppc32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,89 @@
+/* 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x04
+#define CONTEXT_OFFSET_TLS  0x08
+#define CONTEXT_OFFSET_R13  0x0c
+#define CONTEXT_OFFSET_R14  0x10
+#define CONTEXT_OFFSET_R15  0x14
+#define CONTEXT_OFFSET_R16  0x18
+#define CONTEXT_OFFSET_R17  0x1c
+#define CONTEXT_OFFSET_R18  0x20
+#define CONTEXT_OFFSET_R19  0x24
+#define CONTEXT_OFFSET_R20  0x28
+#define CONTEXT_OFFSET_R21  0x2c
+#define CONTEXT_OFFSET_R22  0x30
+#define CONTEXT_OFFSET_R23  0x34
+#define CONTEXT_OFFSET_R24  0x38
+#define CONTEXT_OFFSET_R25  0x3c
+#define CONTEXT_OFFSET_R26  0x40
+#define CONTEXT_OFFSET_R27  0x44
+#define CONTEXT_OFFSET_R28  0x48
+#define CONTEXT_OFFSET_R29  0x4c
+#define CONTEXT_OFFSET_R30  0x50
+#define CONTEXT_OFFSET_R31  0x54
+#define CONTEXT_OFFSET_CR   0x58
+#define CONTEXT_SIZE        0x5c
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct context {
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t tls;
+	uint32_t r13;
+	uint32_t r14;
+	uint32_t r15;
+	uint32_t r16;
+	uint32_t r17;
+	uint32_t r18;
+	uint32_t r19;
+	uint32_t r20;
+	uint32_t r21;
+	uint32_t r22;
+	uint32_t r23;
+	uint32_t r24;
+	uint32_t r25;
+	uint32_t r26;
+	uint32_t r27;
+	uint32_t r28;
+	uint32_t r29;
+	uint32_t r30;
+	uint32_t r31;
+	uint32_t cr;
+} context_t;
+
+#endif
+#endif
+
Index: pace/lib/c/arch/ppc32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ppc32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ppc32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ppc32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ppc32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/riscv64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/riscv64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/riscv64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -35,7 +35,6 @@
 	arch/$(UARCH)/src/stacktrace.c
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/riscv64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,182 +1,0 @@
-#
-# Copyright (c) 2016 Martin Decky
-# 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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                #
-                # There is a room for optimization (we can store just those
-                # registers that must be preserved during ABI function call).
-                #
-
-                {
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        name : pc,
-                        type : uint64_t
-                },
-
-                {
-                        name : zero,
-                        type : uint64_t
-                },
-                {
-                        name : ra,
-                        type : uint64_t
-                },
-
-                {
-                        name : x3,
-                        type : uint64_t
-                },
-                {
-                        name : x4,
-                        type : uint64_t
-                },
-                {
-                        name : x5,
-                        type : uint64_t
-                },
-                {
-                        name : x6,
-                        type : uint64_t
-                },
-                {
-                        name : x7,
-                        type : uint64_t
-                },
-                {
-                        name : x8,
-                        type : uint64_t
-                },
-                {
-                        name : x9,
-                        type : uint64_t
-                },
-                {
-                        name : x10,
-                        type : uint64_t
-                },
-                {
-                        name : x11,
-                        type : uint64_t
-                },
-                {
-                        name : x12,
-                        type : uint64_t
-                },
-                {
-                        name : x13,
-                        type : uint64_t
-                },
-                {
-                        name : x14,
-                        type : uint64_t
-                },
-                {
-                        name : x15,
-                        type : uint64_t
-                },
-                {
-                        name : x16,
-                        type : uint64_t
-                },
-                {
-                        name : x17,
-                        type : uint64_t
-                },
-                {
-                        name : x18,
-                        type : uint64_t
-                },
-                {
-                        name : x19,
-                        type : uint64_t
-                },
-                {
-                        name : x20,
-                        type : uint64_t
-                },
-                {
-                        name : x21,
-                        type : uint64_t
-                },
-                {
-                        name : x22,
-                        type : uint64_t
-                },
-                {
-                        name : x23,
-                        type : uint64_t
-                },
-                {
-                        name : x24,
-                        type : uint64_t
-                },
-                {
-                        name : x25,
-                        type : uint64_t
-                },
-                {
-                        name : x26,
-                        type : uint64_t
-                },
-                {
-                        name : x27,
-                        type : uint64_t
-                },
-                {
-                        name : x28,
-                        type : uint64_t
-                },
-                {
-                        name : x29,
-                        type : uint64_t
-                },
-                {
-                        name : x30,
-                        type : uint64_t
-                },
-                {
-                        name : x31,
-                        type : uint64_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/riscv64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/riscv64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,114 @@
+/* Copyright (c) 2016 Martin Decky
+ * 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x08
+#define CONTEXT_OFFSET_ZERO 0x10
+#define CONTEXT_OFFSET_RA   0x18
+#define CONTEXT_OFFSET_X3   0x20
+#define CONTEXT_OFFSET_X4   0x28
+#define CONTEXT_OFFSET_X5   0x30
+#define CONTEXT_OFFSET_X6   0x38
+#define CONTEXT_OFFSET_X7   0x40
+#define CONTEXT_OFFSET_X8   0x48
+#define CONTEXT_OFFSET_X9   0x50
+#define CONTEXT_OFFSET_X10  0x58
+#define CONTEXT_OFFSET_X11  0x60
+#define CONTEXT_OFFSET_X12  0x68
+#define CONTEXT_OFFSET_X13  0x70
+#define CONTEXT_OFFSET_X14  0x78
+#define CONTEXT_OFFSET_X15  0x80
+#define CONTEXT_OFFSET_X16  0x88
+#define CONTEXT_OFFSET_X17  0x90
+#define CONTEXT_OFFSET_X18  0x98
+#define CONTEXT_OFFSET_X19  0xa0
+#define CONTEXT_OFFSET_X20  0xa8
+#define CONTEXT_OFFSET_X21  0xb0
+#define CONTEXT_OFFSET_X22  0xb8
+#define CONTEXT_OFFSET_X23  0xc0
+#define CONTEXT_OFFSET_X24  0xc8
+#define CONTEXT_OFFSET_X25  0xd0
+#define CONTEXT_OFFSET_X26  0xd8
+#define CONTEXT_OFFSET_X27  0xe0
+#define CONTEXT_OFFSET_X28  0xe8
+#define CONTEXT_OFFSET_X29  0xf0
+#define CONTEXT_OFFSET_X30  0xf8
+#define CONTEXT_OFFSET_X31  0x100
+#define CONTEXT_SIZE        0x108
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * There is a room for optimization (we can store just those
+ * registers that must be preserved during ABI function call).
+ */
+
+typedef struct context {
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t zero;
+	uint64_t ra;
+	uint64_t x3;
+	uint64_t x4;
+	uint64_t x5;
+	uint64_t x6;
+	uint64_t x7;
+	uint64_t x8;
+	uint64_t x9;
+	uint64_t x10;
+	uint64_t x11;
+	uint64_t x12;
+	uint64_t x13;
+	uint64_t x14;
+	uint64_t x15;
+	uint64_t x16;
+	uint64_t x17;
+	uint64_t x18;
+	uint64_t x19;
+	uint64_t x20;
+	uint64_t x21;
+	uint64_t x22;
+	uint64_t x23;
+	uint64_t x24;
+	uint64_t x25;
+	uint64_t x26;
+	uint64_t x27;
+	uint64_t x28;
+	uint64_t x29;
+	uint64_t x30;
+	uint64_t x31;
+} context_t;
+
+#endif
+#endif
+
Index: pace/lib/c/arch/riscv64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/riscv64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/riscv64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/riscv64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/riscv64/include/arch/istate_struct.h
Index: uspace/lib/c/arch/sparc64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/sparc64/Makefile.inc	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ uspace/lib/c/arch/sparc64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -35,7 +35,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: pace/lib/c/arch/sparc64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/fibril_context.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,126 +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 : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        #
-        # Save only registers that must be preserved across function calls.
-        #
-        members : [
-                {
-                        # %o6
-                        name : sp,
-                        type : uintptr_t
-                },
-                {
-                        # %o7
-                        name : pc,
-                        type : uintptr_t
-                },
-                {
-                        name : i0,
-                        type : uint64_t
-                },
-                {
-                        name : i1,
-                        type : uint64_t
-                },
-                {
-                        name : i2,
-                        type : uint64_t
-                },
-                {
-                        name : i3,
-                        type : uint64_t
-                },
-                {
-                        name : i4,
-                        type : uint64_t
-                },
-                {
-                        name : i5,
-                        type : uint64_t
-                },
-                {
-                        # %i6
-                        name : fp,
-                        type : uintptr_t
-                },
-                {
-                        name : i7,
-                        type : uintptr_t
-                },
-                {
-                        name : l0,
-                        type : uint64_t
-                },
-                {
-                        name : l1,
-                        type : uint64_t
-                },
-                {
-                        name : l2,
-                        type : uint64_t
-                },
-                {
-                        name : l3,
-                        type : uint64_t
-                },
-                {
-                        name : l4,
-                        type : uint64_t
-                },
-                {
-                        name : l5,
-                        type : uint64_t
-                },
-                {
-                        name : l6,
-                        type : uint64_t
-                },
-                {
-                        name : l7,
-                        type : uint64_t
-                },
-                {
-                        # %g7
-                        name : tp,
-                        type : uint64_t
-                }
-        ]
-}
-
Index: uspace/lib/c/arch/sparc64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/sparc64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,81 @@
+/* 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 LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP  0x00
+#define CONTEXT_OFFSET_PC  0x08
+#define CONTEXT_OFFSET_I0  0x10
+#define CONTEXT_OFFSET_I1  0x18
+#define CONTEXT_OFFSET_I2  0x20
+#define CONTEXT_OFFSET_I3  0x28
+#define CONTEXT_OFFSET_I4  0x30
+#define CONTEXT_OFFSET_I5  0x38
+#define CONTEXT_OFFSET_FP  0x40
+#define CONTEXT_OFFSET_I7  0x48
+#define CONTEXT_OFFSET_L0  0x50
+#define CONTEXT_OFFSET_L1  0x58
+#define CONTEXT_OFFSET_L2  0x60
+#define CONTEXT_OFFSET_L3  0x68
+#define CONTEXT_OFFSET_L4  0x70
+#define CONTEXT_OFFSET_L5  0x78
+#define CONTEXT_OFFSET_L6  0x80
+#define CONTEXT_OFFSET_L7  0x88
+#define CONTEXT_OFFSET_TP  0x90
+#define CONTEXT_SIZE       0x98
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct context {
+	uintptr_t sp;  // %o6
+	uintptr_t pc;  // %o7
+	uint64_t i0;
+	uint64_t i1;
+	uint64_t i2;
+	uint64_t i3;
+	uint64_t i4;
+	uint64_t i5;
+	uintptr_t fp;  // %i6
+	uintptr_t i7;
+	uint64_t l0;
+	uint64_t l1;
+	uint64_t l2;
+	uint64_t l3;
+	uint64_t l4;
+	uint64_t l5;
+	uint64_t l6;
+	uint64_t l7;
+	uint64_t tp;  // %g7
+} context_t;
+
+#endif
+#endif
+
Index: pace/lib/c/arch/sparc64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/istate_struct.ag	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/sparc64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/sparc64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/sparc64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/istate_struct.h
