Index: kernel/arch/mips32/include/arch/arch.h
===================================================================
--- kernel/arch/mips32/include/arch/arch.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/mips32/include/arch/arch.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
@@ -44,4 +44,8 @@
 extern size_t cpu_count;
 
+#if defined(MACHINE_lmalta) || defined(MACHINE_bmalta)
+extern size_t sdram_size;
+#endif
+
 typedef struct {
 	void *addr;
@@ -51,4 +55,7 @@
 
 typedef struct {
+#if defined(MACHINE_lmalta) || defined(MACHINE_bmalta)
+	uint32_t sdram_size;
+#endif
 	uint32_t cpumap;
 	size_t cnt;
Index: kernel/arch/mips32/include/arch/cp0.h
===================================================================
--- kernel/arch/mips32/include/arch/cp0.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/mips32/include/arch/cp0.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
@@ -45,4 +45,7 @@
 #define cp0_status_im_shift  8
 #define cp0_status_im_mask   0xff00
+
+#define cp0_cause_ip_shift  8
+#define cp0_cause_ip_mask   0xff00
 
 #define cp0_cause_excno(cause)   ((cause >> 2) & 0x1f)
Index: kernel/arch/mips32/include/arch/mach/malta/malta.h
===================================================================
--- kernel/arch/mips32/include/arch/mach/malta/malta.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
+++ kernel/arch/mips32/include/arch/mach/malta/malta.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013 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.
+ */
+
+/** @addtogroup mips32 
+ * @{
+ */
+/** @file
+ *  @brief MIPS Malta platform driver.
+ */
+
+#ifndef KERN_mips32_malta_H_
+#define KERN_mips32_malta_H_
+
+#include <arch/machine_func.h>
+
+extern struct mips32_machine_ops malta_machine_ops;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/mips32/include/arch/mach/msim/msim.h
===================================================================
--- kernel/arch/mips32/include/arch/mach/msim/msim.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
+++ kernel/arch/mips32/include/arch/mach/msim/msim.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013 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.
+ */
+
+/** @addtogroup mips32 
+ * @{
+ */
+/** @file
+ *  @brief msim platform driver.
+ */
+
+#ifndef KERN_mips32_msim_H_
+#define KERN_mips32_msim_H_
+
+#include <arch/machine_func.h>
+
+extern struct mips32_machine_ops msim_machine_ops;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/mips32/include/arch/machine_func.h
===================================================================
--- kernel/arch/mips32/include/arch/machine_func.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
+++ kernel/arch/mips32/include/arch/machine_func.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 Michal Kebrt
+ * Copyright (c) 2009 Vineeth Pillai
+ * Copyrithg (c) 2012 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.
+ */
+
+/** @addtogroup mips32
+ * @{
+ */
+/** @file
+ *  @brief Declarations of machine specific functions.
+ *
+ *  These functions allow us to support various kinds of mips32 machines
+ *  in a unified way.
+ */
+
+#ifndef KERN_mips32_MACHINE_FUNC_H_
+#define KERN_mips32_MACHINE_FUNC_H_
+
+#include <typedefs.h>
+
+struct mips32_machine_ops {
+	void (*machine_init)(void);
+	void (*machine_cpu_halt)(void);
+	void (*machine_get_memory_extents)(uintptr_t *, size_t *);
+	void (*machine_frame_init)(void);
+	void (*machine_output_init)(void);
+	void (*machine_input_init)(void);
+	const char *(*machine_get_platform_name)(void);
+};
+
+/** Pointer to mips32_machine_ops structure being used. */
+extern struct mips32_machine_ops *machine_ops;
+
+extern void machine_ops_init(void);
+
+extern void machine_init(void);
+extern void machine_cpu_halt(void);
+extern void machine_get_memory_extents(uintptr_t *, size_t *);
+extern void machine_frame_init(void);
+extern void machine_output_init(void);
+extern void machine_input_init(void);
+extern const char *machine_get_platform_name(void);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/mips32/include/arch/mm/tlb.h
===================================================================
--- kernel/arch/mips32/include/arch/mm/tlb.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/mips32/include/arch/mm/tlb.h	(revision 89f61bee11a0adf231dac8e1ce6dcc5502155514)
@@ -41,8 +41,15 @@
 #include <trace.h>
 
+#if defined(PROCESSOR_R4000)
 #define TLB_ENTRY_COUNT  48
+#define TLB_INDEX_BITS   6
+#elif defined(PROCESSOR_4Kc)
+#define TLB_ENTRY_COUNT  16
+#define TLB_INDEX_BITS   4
+#else
+#error Please define TLB_ENTRY_COUNT for the target processor.
+#endif
 
-#define TLB_WIRED               1
-#define TLB_KSTACK_WIRED_INDEX  0
+#define TLB_WIRED              	0 
 
 #define TLB_PAGE_MASK_4K    (0x000 << 13)
@@ -112,9 +119,9 @@
 #ifdef __BE__
 		unsigned p : 1;
-		unsigned : 25;
-		unsigned index : 6;
+		unsigned : 32 - TLB_INDEX_BITS - 1;
+		unsigned index : TLB_INDEX_BITS;
 #else
-		unsigned index : 6;
-		unsigned : 25;
+		unsigned index : TLB_INDEX_BITS;
+		unsigned : 32 - TLB_INDEX_BITS - 1;
 		unsigned p : 1;
 #endif
