Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261825AbTEBGGr (ORCPT ); Fri, 2 May 2003 02:06:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261845AbTEBGGq (ORCPT ); Fri, 2 May 2003 02:06:46 -0400 Received: from i235066.ppp.asahi-net.or.jp ([61.125.235.66]:52207 "EHLO mitou.ysato.zive.net") by vger.kernel.org with ESMTP id S261825AbTEBGFr (ORCPT ); Fri, 2 May 2003 02:05:47 -0400 Date: Fri, 02 May 2003 15:18:09 +0900 Message-ID: From: Yoshinori Sato To: Linus Torvalds Cc: linux-kernel Mailinglist Subject: [PATCH] H8/300 support update (2/4) User-Agent: Wanderlust/2.10.0 (Venus) SEMI/1.14.4 (Hosorogi) FLIM/1.14.4 (=?ISO-8859-4?Q?Kashiharajing=FE-mae?=) APEL/10.4 Emacs/21.2 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: multipart/mixed; boundary="Multipart_Fri_May__2_15:18:09_2003-1" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11562 Lines: 362 --Multipart_Fri_May__2_15:18:09_2003-1 Content-Type: text/plain; charset=US-ASCII include o fixed exception stack handling. o fixed context switch problem. o syscall6 add. -- Yoshinori Sato --Multipart_Fri_May__2_15:18:09_2003-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="linux-2.5.68-h8300-include.diff" Content-Transfer-Encoding: 7bit Index: include/asm-h8300/atomic.h =================================================================== RCS file: /var/lib/cvs/linux-2.5/include/asm-h8300/atomic.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- include/asm-h8300/atomic.h 21 Apr 2003 02:22:47 -0000 1.1.1.1 +++ include/asm-h8300/atomic.h 1 May 2003 13:43:46 -0000 1.2 @@ -101,7 +101,4 @@ #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() -#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0) -#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) - #endif /* __ARCH_H8300_ATOMIC __ */ Index: include/asm-h8300/bitops.h =================================================================== RCS file: /var/lib/cvs/linux-2.5/include/asm-h8300/bitops.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- include/asm-h8300/bitops.h 21 Apr 2003 02:22:47 -0000 1.1.1.1 +++ include/asm-h8300/bitops.h 25 Apr 2003 17:36:37 -0000 1.2 @@ -10,6 +10,7 @@ #include #include #include /* swab32 */ +#include #ifdef __KERNEL__ /* @@ -352,57 +353,45 @@ #define hweight16(x) generic_hweight16(x) #define hweight8(x) generic_hweight8(x) -extern __inline__ int ext2_set_bit(int nr, volatile void *addr) +extern __inline__ int ext2_set_bit(int nr, volatile void * addr) { - unsigned char *a = (unsigned char *) addr; - register unsigned short r __asm__("er0"); - a += nr >> 3; - __asm__("mov.l %1,er0\n\t" - "sub.w e0,e0\n\t" - "btst r0l,@%2\n\t" - "bset r0l,@%2\n\t" - "beq 1f\n\t" - "inc.w #1,e0\n" - "1:\n\t" - "mov.w e0,r0\n\t" - "sub.w e0,e0" - :"=r"(r):"r"(nr & 7),"r"(a)); - return r; + int mask, retval; + unsigned long flags; + volatile unsigned char *ADDR = (unsigned char *) addr; + + ADDR += nr >> 3; + mask = 1 << (nr & 0x07); + local_irq_save(flags); + retval = (mask & *ADDR) != 0; + *ADDR |= mask; + local_irq_restore(flags); + return retval; } -extern __inline__ int ext2_clear_bit(int nr, volatile void *addr) +extern __inline__ int ext2_clear_bit(int nr, volatile void * addr) { - unsigned char *a = (unsigned char *) addr; - register unsigned short r __asm__("er0"); - a += nr >> 3; - __asm__("mov.l %1,er0\n\t" - "sub.w e0,e0\n\t" - "btst r0l,@%2\n\t" - "bclr r0l,@%2\n\t" - "beq 1f\n\t" - "inc.w #1,e0\n" - "1:\n\t" - "mov.w e0,r0\n\t" - "sub.w e0,e0" - :"=r"(r):"r"(nr & 7),"r"(a)); - return r; + int mask, retval; + unsigned long flags; + volatile unsigned char *ADDR = (unsigned char *) addr; + + ADDR += nr >> 3; + mask = 1 << (nr & 0x07); + local_irq_save(flags); + retval = (mask & *ADDR) != 0; + *ADDR &= ~mask; + local_irq_restore(flags); + return retval; } -extern __inline__ int ext2_test_bit(int nr, volatile void *addr) +extern __inline__ int ext2_test_bit(int nr, const volatile void * addr) { - unsigned char *a = (unsigned char *) addr; - int ret; - a += nr >> 3; - __asm__("mov.l %1,er0\n\t" - "sub.l %0,%0\n\t" - "btst r0l,@%2\n\t" - "beq 1f\n\t" - "inc.l #1,%0\n" - "1:" - : "=r"(ret) :"r"(nr & 7),"r"(a):"er0","er1"); - return ret; -} + int mask; + const volatile unsigned char *ADDR = (const unsigned char *) addr; + ADDR += nr >> 3; + mask = 1 << (nr & 0x07); + return ((mask & *ADDR) != 0); +} #define ext2_find_first_zero_bit(addr, size) \ ext2_find_next_zero_bit((addr), (size), 0) Index: include/asm-h8300/pgtable.h =================================================================== RCS file: /var/lib/cvs/linux-2.5/include/asm-h8300/pgtable.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- include/asm-h8300/pgtable.h 21 Apr 2003 02:22:47 -0000 1.1.1.1 +++ include/asm-h8300/pgtable.h 25 Apr 2003 17:36:37 -0000 1.2 @@ -49,4 +49,11 @@ #define pgtable_cache_init() do { } while (0) #define io_remap_page_range remap_page_range +/* + * All 32bit addresses are effectively valid for vmalloc... + * Sort of meaningless for non-VM targets. + */ +#define VMALLOC_START 0 +#define VMALLOC_END 0xffffffff + #endif /* _H8300_PGTABLE_H */ Index: include/asm-h8300/processor.h =================================================================== RCS file: /var/lib/cvs/linux-2.5/include/asm-h8300/processor.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- include/asm-h8300/processor.h 21 Apr 2003 02:22:47 -0000 1.1.1.1 +++ include/asm-h8300/processor.h 25 Apr 2003 17:36:37 -0000 1.2 @@ -52,17 +52,16 @@ #define MCA_bus 0 struct thread_struct { - unsigned long ksp; /* kernel stack pointer */ - unsigned long usp; /* user stack pointer */ - unsigned short ccr; /* saved status register */ - unsigned long esp0; /* points to SR of stack frame */ - unsigned long vfork_ret; - unsigned long debugreg[8]; /* debug info */ -} __attribute__((aligned(2),packed)); + unsigned long ksp; /* kernel stack pointer */ + unsigned long usp; /* user stack pointer */ + unsigned long ccr; /* saved status register */ + unsigned long esp0; /* points to SR of stack frame */ + unsigned long debugreg[8]; /* debug info */ +}; #define INIT_THREAD { \ sizeof(init_stack) + (unsigned long) init_stack, 0, \ - PS_S, 0, 0, \ + PS_S, \ } /* @@ -73,9 +72,9 @@ */ #define start_thread(_regs, _pc, _usp) \ do { \ + set_fs(USER_DS); /* reads from user space */ \ (_regs)->pc = (_pc); \ (_regs)->ccr &= ~0x10; \ - *((unsigned long *)(_usp)-1) = _pc; \ wrusp((unsigned long)(_usp) - sizeof(unsigned long)*3); \ } while(0) Index: include/asm-h8300/ptrace.h =================================================================== RCS file: /var/lib/cvs/linux-2.5/include/asm-h8300/ptrace.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- include/asm-h8300/ptrace.h 21 Apr 2003 02:22:47 -0000 1.1.1.1 +++ include/asm-h8300/ptrace.h 25 Apr 2003 17:36:37 -0000 1.2 @@ -19,6 +19,10 @@ stack during a system call. */ struct pt_regs { + long retpc; + long er4; + long er5; + long er6; long er3; long er2; long er1; @@ -26,19 +30,11 @@ unsigned short ccr; long er0; long vector; +#if defined(CONFIG_CPU_H8S) + unsigned short exr; +#endif unsigned long pc; } __attribute__((aligned(2),packed)); - -/* - * This is the extended stack used by signal handlers and the context - * switcher: it's pushed after the normal "struct pt_regs". - */ -struct switch_stack { - unsigned long er6; - unsigned long er5; - unsigned long er4; - unsigned long retpc; -}; #define PTRACE_GETREGS 12 #define PTRACE_SETREGS 13 Index: include/asm-h8300/system.h =================================================================== RCS file: /var/lib/cvs/linux-2.5/include/asm-h8300/system.h,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- include/asm-h8300/system.h 21 Apr 2003 02:22:47 -0000 1.1.1.1 +++ include/asm-h8300/system.h 25 Apr 2003 17:36:37 -0000 1.3 @@ -36,17 +36,20 @@ * H8/300 Porting 2002/09/04 Yoshinori Sato */ asmlinkage void resume(void); -#define switch_to(prev,next,last) { \ - void *_last; \ - __asm__ __volatile__( \ - "mov.l %1, er0\n\t" \ - "mov.l %2, er1\n\t" \ - "jsr @_resume" \ - : "=r" (_last) \ - : "r" (&(prev->thread)), \ - "r" (&(next->thread)) \ - : "cc", "er0", "er1", "er2", "er3"); \ - (last) = _last; \ +#define switch_to(prev,next,last) { \ + void *_last; \ + __asm__ __volatile__( \ + "mov.l %1, er0\n\t" \ + "mov.l %2, er1\n\t" \ + "mov.l %3, er2\n\t" \ + "jsr @_resume\n\t" \ + "mov.l er2,%0\n\t" \ + : "=r" (_last) \ + : "r" (&(prev->thread)), \ + "r" (&(next->thread)), \ + "g" (prev) \ + : "cc", "er0", "er1", "er2", "er3"); \ + (last) = _last; \ } #if defined(__H8300H__) @@ -80,15 +83,15 @@ #define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc") /* For spinlocks etc */ -#define local_irq_disable() asm volatile ("orc #0x80,ccr") -#define local_irq_enable() asm volatile ("andc #0x7f,ccr") +#define local_irq_disable() __cli() +#define local_irq_enable() __sti() #define local_irq_save(x) ({ __save_flags(x); local_irq_disable(); }) #define local_irq_restore(x) __restore_flags(x) #define local_save_flags(x) __save_flags(x) /* * Force strict CPU ordering. - * Not really required on m68k... + * Not really required on H8... */ #define nop() asm volatile ("nop"::) #define mb() asm volatile ("" : : :"memory") Index: include/asm-h8300/unistd.h =================================================================== RCS file: /var/lib/cvs/linux-2.5/include/asm-h8300/unistd.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- include/asm-h8300/unistd.h 21 Apr 2003 02:22:47 -0000 1.1.1.1 +++ include/asm-h8300/unistd.h 1 May 2003 14:34:17 -0000 1.2 @@ -405,8 +405,39 @@ "g" ((long)b), \ "g" ((long)c), \ "g" ((long)d), \ - "g" ((long)e) \ - : "cc", "er1", "er2", "er3", "er4"); \ + "m" ((long)e) \ + : "cc", "er1", "er2", "er3", "er4", "er5"); \ + if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ + errno = -__res; \ + __res = -1; \ + } \ + return (type)__res; \ +} + +#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, \ + etype, e, ftype, f) \ +type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \ +{ \ + register long __res __asm__("er0"); \ + __asm__ __volatile__ ("mov.l er6,@-sp\n\t" \ + "mov.l %7, er6\n\t" \ + "mov.l %6, er5\n\t" \ + "mov.l %5, er4\n\t" \ + "mov.l %4, er3\n\t" \ + "mov.l %3, er2\n\t" \ + "mov.l %2, er1\n\t" \ + "mov.l %1, er0\n\t" \ + "trapa #0\n\t" \ + "mov.l @sp+,er6" \ + : "=r" (__res) \ + : "ir" (__NR_##name), \ + "g" ((long)a), \ + "g" ((long)b), \ + "g" ((long)c), \ + "g" ((long)d), \ + "m" ((long)e), \ + "m" ((long)e) \ + : "cc", "er1", "er2", "er3", "er4", "er5"); \ if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ errno = -__res; \ __res = -1; \ --Multipart_Fri_May__2_15:18:09_2003-1-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/