Index: uspace/lib/c/arch/mips32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32/Makefile.inc	(revision e74b24f3342648875f8cb8c32a63b5062cb9a903)
+++ uspace/lib/c/arch/mips32/Makefile.inc	(revision 4b334fd67169af5de794ce1053c6124e2ea71cd4)
@@ -37,3 +37,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/mips32/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/context_offset.h	(revision e74b24f3342648875f8cb8c32a63b5062cb9a903)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips32/include/arch/context_offset.h
Index: uspace/lib/c/arch/mips32/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril.h	(revision e74b24f3342648875f8cb8c32a63b5062cb9a903)
+++ uspace/lib/c/arch/mips32/include/libarch/fibril.h	(revision 4b334fd67169af5de794ce1053c6124e2ea71cd4)
@@ -38,4 +38,5 @@
 
 #include <sys/types.h>
+#include <libarch/fibril_context.h>
 #include <libarch/stack.h>
 #include <align.h>
@@ -56,34 +57,4 @@
 	} while (0)
 
-typedef struct  {
-	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;
-	uint32_t tls; /* Thread local storage(=k1) */
-
-	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;
-
 static inline uintptr_t context_get_fp(context_t *ctx)
 {
Index: uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag	(revision 4b334fd67169af5de794ce1053c6124e2ea71cd4)
+++ uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag	(revision 4b334fd67169af5de794ce1053c6124e2ea71cd4)
@@ -0,0 +1,138 @@
+# 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 : <sys/types.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/src/fibril.S
===================================================================
--- uspace/lib/c/arch/mips32/src/fibril.S	(revision e74b24f3342648875f8cb8c32a63b5062cb9a903)
+++ uspace/lib/c/arch/mips32/src/fibril.S	(revision 4b334fd67169af5de794ce1053c6124e2ea71cd4)
@@ -32,5 +32,5 @@
 .set noreorder
 
-#include <libarch/context_offset.h>
+#include <libarch/fibril_context.h>
 
 .global context_save
@@ -38,5 +38,54 @@
 
 context_save:
-	CONTEXT_SAVE_ARCH_CORE $a0
+	sw $s0, CONTEXT_OFFSET_S0($a0)
+	sw $s1, CONTEXT_OFFSET_S1($a0)
+	sw $s2, CONTEXT_OFFSET_S2($a0)
+	sw $s3, CONTEXT_OFFSET_S3($a0)
+	sw $s4, CONTEXT_OFFSET_S4($a0)
+	sw $s5, CONTEXT_OFFSET_S5($a0)
+	sw $s6, CONTEXT_OFFSET_S6($a0)
+	sw $s7, CONTEXT_OFFSET_S7($a0)
+	sw $s8, CONTEXT_OFFSET_S8($a0)
+	sw $gp, CONTEXT_OFFSET_GP($a0)
+	
+	sw $k1, CONTEXT_OFFSET_TLS($a0)
+	
+#ifdef CONFIG_FPU
+	mfc1 $t0, $20
+	sw $t0, CONTEXT_OFFSET_F20($a0)
+	
+	mfc1 $t0, $21
+	sw $t0, CONTEXT_OFFSET_F21($a0)
+	
+	mfc1 $t0, $22
+	sw $t0, CONTEXT_OFFSET_F22($a0)
+	
+	mfc1 $t0, $23
+	sw $t0, CONTEXT_OFFSET_F23($a0)
+	
+	mfc1 $t0, $24
+	sw $t0, CONTEXT_OFFSET_F24($a0)
+	
+	mfc1 $t0, $25
+	sw $t0, CONTEXT_OFFSET_F25($a0)
+	
+	mfc1 $t0, $26
+	sw $t0, CONTEXT_OFFSET_F26($a0)
+	
+	mfc1 $t0, $27
+	sw $t0, CONTEXT_OFFSET_F27($a0)
+	
+	mfc1 $t0, $28
+	sw $t0, CONTEXT_OFFSET_F28($a0)
+	
+	mfc1 $t0, $29
+	sw $t0, CONTEXT_OFFSET_F29($a0)
+	
+	mfc1 $t0, $30
+	sw $t0, CONTEXT_OFFSET_F30($a0)
+#endif /* CONFIG_FPU */
+	
+	sw $ra, CONTEXT_OFFSET_PC($a0)
+	sw $sp, CONTEXT_OFFSET_SP($a0)
 	
 	# context_save returns 1
@@ -45,5 +94,53 @@
 
 context_restore:
-	CONTEXT_RESTORE_ARCH_CORE $a0
+	lw $s0, CONTEXT_OFFSET_S0($a0)
+	lw $s1, CONTEXT_OFFSET_S1($a0)
+	lw $s2, CONTEXT_OFFSET_S2($a0)
+	lw $s3, CONTEXT_OFFSET_S3($a0)
+	lw $s4, CONTEXT_OFFSET_S4($a0)
+	lw $s5, CONTEXT_OFFSET_S5($a0)
+	lw $s6, CONTEXT_OFFSET_S6($a0)
+	lw $s7, CONTEXT_OFFSET_S7($a0)
+	lw $s8, CONTEXT_OFFSET_S8($a0)
+	lw $gp, CONTEXT_OFFSET_GP($a0)
+	lw $k1, CONTEXT_OFFSET_TLS($a0)
+	
+#ifdef CONFIG_FPU
+	lw $t0, CONTEXT_OFFSET_F20($a0)
+	mtc1 $t0, $20
+	
+	lw $t0, CONTEXT_OFFSET_F21($a0)
+	mtc1 $t0, $21
+	
+	lw $t0, CONTEXT_OFFSET_F22($a0)
+	mtc1 $t0, $22
+	
+	lw $t0, CONTEXT_OFFSET_F23($a0)
+	mtc1 $t0, $23
+	
+	lw $t0, CONTEXT_OFFSET_F24($a0)
+	mtc1 $t0, $24
+	
+	lw $t0, CONTEXT_OFFSET_F25($a0)
+	mtc1 $t0, $25
+	
+	lw $t0, CONTEXT_OFFSET_F26($a0)
+	mtc1 $t0, $26
+	
+	lw $t0, CONTEXT_OFFSET_F27($a0)
+	mtc1 $t0, $27
+	
+	lw $t0, CONTEXT_OFFSET_F28($a0)
+	mtc1 $t0, $28
+	
+	lw $t0, CONTEXT_OFFSET_F29($a0)
+	mtc1 $t0, $29
+	
+	lw $t0, CONTEXT_OFFSET_F30($a0)
+	mtc1 $t0, $30
+#endif /* CONFIG_FPU */
+	
+	lw $ra, CONTEXT_OFFSET_PC($a0)
+	lw $sp, CONTEXT_OFFSET_SP($a0)
 	
 	# Just for the jump into first function,
Index: uspace/lib/c/arch/mips32eb/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32eb/Makefile.inc	(revision e74b24f3342648875f8cb8c32a63b5062cb9a903)
+++ uspace/lib/c/arch/mips32eb/Makefile.inc	(revision 4b334fd67169af5de794ce1053c6124e2ea71cd4)
@@ -37,3 +37,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
+ARCH_AUTOGENS_AG = \
+	arch/$(UARCH)/include/libarch/fibril_context.ag
+
 .PRECIOUS: arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/mips32eb/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/context_offset.h	(revision e74b24f3342648875f8cb8c32a63b5062cb9a903)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../mips32/include/libarch/context_offset.h
