Index: kernel/arch/sparc64/include/arch/istate.h
===================================================================
--- kernel/arch/sparc64/include/arch/istate.h	(revision f72906c1ceb4b546d431ab8e9c41434425c1096f)
+++ kernel/arch/sparc64/include/arch/istate.h	(revision af0a2c7c1646c861334832d64f9f0977d0c2fada)
@@ -41,17 +41,13 @@
 #ifdef KERNEL
 
+#include <arch/istate_struct.h>
 #include <arch/regdef.h>
 
 #else /* KERNEL */
 
+#include <libarch/istate_struct.h>
 #include <libarch/regdef.h>
 
 #endif /* KERNEL */
-
-typedef struct istate {
-	uint64_t tnpc;
-	uint64_t tpc;
-	uint64_t tstate;
-} istate_t;
 
 NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
Index: kernel/arch/sparc64/include/arch/istate_struct.ag
===================================================================
--- kernel/arch/sparc64/include/arch/istate_struct.ag	(revision af0a2c7c1646c861334832d64f9f0977d0c2fada)
+++ kernel/arch/sparc64/include/arch/istate_struct.ag	(revision af0a2c7c1646c861334832d64f9f0977d0c2fada)
@@ -0,0 +1,57 @@
+# 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 : <sys/types.h>
+                }
+        ],
+
+        members : [
+                {
+                        name : tnpc,
+                        type : uint64_t
+                },
+                {
+                        name : tpc,
+                        type : uint64_t
+                },
+                {
+                        name : tstate,
+                        type : uint64_t
+                }
+        ]
+}
+
Index: kernel/arch/sparc64/include/arch/trap/trap_table.h
===================================================================
--- kernel/arch/sparc64/include/arch/trap/trap_table.h	(revision f72906c1ceb4b546d431ab8e9c41434425c1096f)
+++ kernel/arch/sparc64/include/arch/trap/trap_table.h	(revision af0a2c7c1646c861334832d64f9f0977d0c2fada)
@@ -37,4 +37,5 @@
 
 #include <arch/stack.h>
+#include <arch/istate_struct.h>
 
 #define TRAP_TABLE_ENTRY_COUNT	1024
@@ -42,7 +43,8 @@
 #define TRAP_TABLE_SIZE		(TRAP_TABLE_ENTRY_COUNT * TRAP_TABLE_ENTRY_SIZE)
 
+#define ISTATE_END_OFFSET(o)	((o) - ISTATE_SIZE)
+
 /*
- * The following needs to be in sync with the definition of the istate
- * structure. The one STACK_ITEM_SIZE is counted for space holding the 7th
+ * The one STACK_ITEM_SIZE is counted for space holding the 7th
  * argument to syscall_handler (i.e. syscall number) and the other
  * STACK_ITEM_SIZE is counted because of the required alignment.
@@ -50,17 +52,19 @@
 #define PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE \
     (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE + \
-    (2 * STACK_ITEM_SIZE) + (12 * 8))
-#define SAVED_TSTATE	-(1 * 8)
-#define SAVED_TPC	-(2 * 8)
-#define SAVED_TNPC	-(3 * 8)	/* <-- istate_t begins here */
-#define SAVED_Y		-(4 * 8)
-#define SAVED_I0	-(5 * 8)
-#define SAVED_I1	-(6 * 8)
-#define SAVED_I2	-(7 * 8)
-#define SAVED_I3	-(8 * 8)
-#define SAVED_I4	-(9 * 8)
-#define SAVED_I5	-(10 * 8)
-#define SAVED_I6	-(11 * 8)
-#define SAVED_I7	-(12 * 8)
+    (2 * STACK_ITEM_SIZE) + (ISTATE_SIZE + 9 * 8))
+/* <-- istate_t ends here */
+#define SAVED_TSTATE	ISTATE_END_OFFSET(ISTATE_OFFSET_TSTATE)	
+#define SAVED_TPC	ISTATE_END_OFFSET(ISTATE_OFFSET_TPC)
+#define SAVED_TNPC	ISTATE_END_OFFSET(ISTATE_OFFSET_TNPC)
+/* <-- istate_t begins here */
+#define SAVED_Y		-(1 * 8 + ISTATE_SIZE)
+#define SAVED_I0	-(2 * 8 + ISTATE_SIZE)
+#define SAVED_I1	-(3 * 8 + ISTATE_SIZE)
+#define SAVED_I2	-(4 * 8 + ISTATE_SIZE)
+#define SAVED_I3	-(5 * 8 + ISTATE_SIZE)
+#define SAVED_I4	-(6 * 8 + ISTATE_SIZE)
+#define SAVED_I5	-(7 * 8 + ISTATE_SIZE)
+#define SAVED_I6	-(8 * 8 + ISTATE_SIZE)
+#define SAVED_I7	-(9 * 8 + ISTATE_SIZE)
 
 #ifndef __ASM__
