sh: Various nommu fixes.
authorYoshinori Sato <ysato@users.sourceforge.jp>
Wed, 27 Sep 2006 08:21:02 +0000 (17:21 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Wed, 27 Sep 2006 08:21:02 +0000 (17:21 +0900)
This fixes up some of the various outstanding nommu bugs on
SH.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/boot/compressed/Makefile
arch/sh/mm/init.c
arch/sh/mm/pg-nommu.c
include/asm-sh/addrspace.h
include/asm-sh/flat.h
include/asm-sh/mmu.h
include/asm-sh/page.h
include/asm-sh/uaccess.h

index 7074267c01b75e8a4040bff27721a294b6f6736f..903470429cb455b73bc965e983d8af980880dcc8 100644 (file)
@@ -21,11 +21,17 @@ endif
 CONFIG_PAGE_OFFSET     ?= 0x80000000
 CONFIG_MEMORY_START     ?= 0x0c000000
 CONFIG_BOOT_LINK_OFFSET ?= 0x00800000
-IMAGE_OFFSET := $(shell printf "0x%8x" $$[$(CONFIG_PAGE_OFFSET)+$(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)])
+
+IMAGE_OFFSET   := $(shell printf "0x%8x" $$[$(CONFIG_PAGE_OFFSET)  + \
+                                            $(CONFIG_MEMORY_START) + \
+                                            $(CONFIG_BOOT_LINK_OFFSET)])
+
+LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 
 LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup -T $(obj)/../../kernel/vmlinux.lds
 
-$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE
+
+$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
        $(call if_changed,ld)
        @:
 
index d1a979eab6568316b3053045df31d9b2ce56e3dc..2c6dc3d8df2cdd4c76400590683a89f1d89c81c2 100644 (file)
@@ -248,8 +248,13 @@ void __init mem_init(void)
         * Setup wrappers for copy/clear_page(), these will get overridden
         * later in the boot process if a better method is available.
         */
+#ifdef CONFIG_MMU
        copy_page = copy_page_slow;
        clear_page = clear_page_slow;
+#else
+       copy_page = copy_page_nommu;
+       clear_page = clear_page_nommu;
+#endif
 
        /* this will put all low memory onto the freelists */
        totalram_pages += free_all_bootmem_node(NODE_DATA(0));
index 8f9165a4e333a32181c6cc4b678d2e4eacc42d7e..d15221beaa161ab555cb6b481268651d56570a4f 100644 (file)
 #include <linux/string.h>
 #include <asm/page.h>
 
-static void copy_page_nommu(void *to, void *from)
+void copy_page_nommu(void *to, void *from)
 {
        memcpy(to, from, PAGE_SIZE);
 }
 
-static void clear_page_nommu(void *to)
+void clear_page_nommu(void *to)
 {
        memset(to, 0, PAGE_SIZE);
 }
 
-static int __init pg_nommu_init(void)
+__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n)
 {
-       copy_page = copy_page_nommu;
-       clear_page = clear_page_nommu;
-
+       memcpy(to, from, n);
        return 0;
 }
 
-subsys_initcall(pg_nommu_init);
-
+__kernel_size_t __clear_user(void *to, __kernel_size_t n)
+{
+       memset(to, 0, n);
+       return 0;
+}
index 720afc11c2caf7c4e95d7943894337ef25ec154d..4207368267b187dcbe05dd5dfea39c7ee700121e 100644 (file)
 #include <asm/cpu/addrspace.h>
 
 /* Memory segments (32bit Privileged mode addresses)  */
+#ifdef CONFIG_MMU
 #define P0SEG          0x00000000
 #define P1SEG          0x80000000
 #define P2SEG          0xa0000000
 #define P3SEG          0xc0000000
 #define P4SEG          0xe0000000
+#else
+#define P0SEG          0x00000000
+#define P1SEG          0x00000000
+#define P2SEG          0x20000000
+#define P3SEG          0x40000000
+#define P4SEG          0x80000000
+#endif
 
 /* Returns the privileged segment base of a given address  */
 #define PXSEG(a)       (((unsigned long)(a)) & 0xe0000000)
index f29072e1c87e97e8ab3227d09f67cee4c0b22d68..0d5cc04ab005db06809770d4b551c4475382569e 100644 (file)
@@ -13,7 +13,7 @@
 #define __ASM_SH_FLAT_H
 
 #define        flat_stack_align(sp)                    /* nothing needed */
-#define        flat_argvp_envp_on_stack()              1
+#define        flat_argvp_envp_on_stack()              0
 #define        flat_old_ram_flag(flags)                (flags)
 #define        flat_reloc_valid(reloc, size)           ((reloc) <= (size))
 #define        flat_get_addr_from_rp(rp, relval, flags)        get_unaligned(rp)
index ec09589fa6ca5e53c786b2bc38c3e29a1e63a037..6383dc84501ed0f610a06d2988969885935e94b0 100644 (file)
@@ -3,19 +3,8 @@
 
 #if !defined(CONFIG_MMU)
 
-struct mm_rblock_struct {
-       int     size;
-       int     refcount;
-       void    *kblock;
-};
-
-struct mm_tblock_struct {
-       struct mm_rblock_struct *rblock;
-       struct mm_tblock_struct *next;
-};
-
 typedef struct {
-       struct mm_tblock_struct tblock;
+       struct vm_list_struct   *vmlist;
        unsigned long           end_brk;
 } mm_context_t;
 
index 1b3cfd165a66752b1c5b8dc957cc011858f5f35e..e9135532d00c91181070646c99ebdaf39e42fdaf 100644 (file)
 extern void (*clear_page)(void *to);
 extern void (*copy_page)(void *to, void *from);
 
+#ifdef CONFIG_MMU
 extern void clear_page_slow(void *to);
 extern void copy_page_slow(void *to, void *from);
+#else
+extern void clear_page_nommu(void *to);
+extern void copy_page_nommu(void *to, void *from);
+#endif
 
 #if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
        defined(CONFIG_SH7705_CACHE_32KB))
index 6c0014dd2ef7cd5bbee74562019f626f8eea9936..5c3b00c2f10727a45cf29ef4103e8030b0325a8b 100644 (file)
@@ -168,6 +168,7 @@ do {                                                                \
        __gu_err;                                               \
 })
 
+#ifdef CONFIG_MMU
 #define __get_user_check(x,ptr,size)                           \
 ({                                                             \
        long __gu_err, __gu_val;                                \
@@ -257,6 +258,18 @@ __asm__("stc       r7_bank, %1\n\t"                \
        : "r" (addr)                            \
        : "t");                                 \
 })
+#else /* CONFIG_MMU */
+#define __get_user_check(x,ptr,size)                                   \
+({                                                                     \
+       long __gu_err, __gu_val;                                        \
+       if (__access_ok((unsigned long)(ptr), (size))) {                \
+               __get_user_size(__gu_val, (ptr), (size), __gu_err);     \
+               (x) = (__typeof__(*(ptr)))__gu_val;                     \
+       } else                                                          \
+               __gu_err = -EFAULT;                                     \
+       __gu_err;                                                       \
+})
+#endif
 
 #define __get_user_asm(x, addr, err, insn) \
 ({ \