From bbbc6bc992fbc018e2d1960a65088ffe70312256 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Mon, 14 Apr 2008 00:10:48 -0700 Subject: [PATCH] MIPS fixes based on suggestions from Jiang. --- datapath/linux-2.4/Makefile.in | 2 +- .../compat-2.4/include-mips/asm/atomic.h | 2 -- .../compat-2.4/include-mips/asm/barrier.h | 2 -- .../compat-2.4/include-mips/asm/break.h | 33 +++++++++++++++++++ .../compat-2.4/include-mips/asm/page.h | 17 ++++++++++ .../compat-2.4/include-mips/asm/system.h | 10 +++--- .../compat-2.4/include/linux/module.h | 1 + 7 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 datapath/linux-2.4/compat-2.4/include-mips/asm/break.h create mode 100644 datapath/linux-2.4/compat-2.4/include-mips/asm/page.h diff --git a/datapath/linux-2.4/Makefile.in b/datapath/linux-2.4/Makefile.in index c9308dca..25a53b37 100644 --- a/datapath/linux-2.4/Makefile.in +++ b/datapath/linux-2.4/Makefile.in @@ -38,7 +38,7 @@ SHARED_T_FILES = \ ../unit.c UNIT_CFILES = $(patsubst ../%,%, $(SHARED_T_FILES)) -kFILES = ../datapath.h \ +HFILES = ../datapath.h \ ../chain.h \ ../crc32.h \ ../flow.h \ diff --git a/datapath/linux-2.4/compat-2.4/include-mips/asm/atomic.h b/datapath/linux-2.4/compat-2.4/include-mips/asm/atomic.h index 735c6168..09802e57 100644 --- a/datapath/linux-2.4/compat-2.4/include-mips/asm/atomic.h +++ b/datapath/linux-2.4/compat-2.4/include-mips/asm/atomic.h @@ -4,8 +4,6 @@ #include_next #include -#error "Cribbed from linux-2.6/include/asm-mips but not tested." - #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n))) #endif /* asm/atomic.h */ diff --git a/datapath/linux-2.4/compat-2.4/include-mips/asm/barrier.h b/datapath/linux-2.4/compat-2.4/include-mips/asm/barrier.h index ae1d6460..8a515488 100644 --- a/datapath/linux-2.4/compat-2.4/include-mips/asm/barrier.h +++ b/datapath/linux-2.4/compat-2.4/include-mips/asm/barrier.h @@ -3,8 +3,6 @@ #include -#error "Cribbed from linux-2.6/include/asm-mips/barrier.h but untested." - /* Not sure whether these really need to be defined, but the conservative * choice seems to be to define them. */ #define CONFIG_WEAK_ORDERING 1 diff --git a/datapath/linux-2.4/compat-2.4/include-mips/asm/break.h b/datapath/linux-2.4/compat-2.4/include-mips/asm/break.h new file mode 100644 index 00000000..53b0641d --- /dev/null +++ b/datapath/linux-2.4/compat-2.4/include-mips/asm/break.h @@ -0,0 +1,33 @@ +#ifndef __ASM_MIPS_BREAK_H_WRAPPER +#define __ASM_MIPS_BREAK_H_WRAPPER 1 + +#include +#include_next + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25) + +/* + * The following break codes are or were in use for specific purposes in + * other MIPS operating systems. Linux/MIPS doesn't use all of them. The + * unused ones are here as placeholders; we might encounter them in + * non-Linux/MIPS object files or make use of them in the future. + */ +#define BRK_USERBP 0 /* User bp (used by debuggers) */ +#define BRK_KERNELBP 1 /* Break in the kernel */ +#define BRK_ABORT 2 /* Sometimes used by abort(3) to SIGIOT */ +#define BRK_BD_TAKEN 3 /* For bd slot emulation - not implemented */ +#define BRK_BD_NOTTAKEN 4 /* For bd slot emulation - not implemented */ +#define BRK_SSTEPBP 5 /* User bp (used by debuggers) */ +#define BRK_OVERFLOW 6 /* Overflow check */ +#define BRK_DIVZERO 7 /* Divide by zero check */ +#define BRK_RANGE 8 /* Range error check */ +#define BRK_STACKOVERFLOW 9 /* For Ada stackchecking */ +#define BRK_NORLD 10 /* No rld found - not used by Linux/MIPS */ +#define _BRK_THREADBP 11 /* For threads, user bp (used by debuggers) */ +#define BRK_MULOVF 1023 /* Multiply overflow */ +#define BRK_BUG 512 /* Used by BUG() */ + +#endif /* linux kernel < 2.4.25 */ + +#endif /* asm/break.h */ diff --git a/datapath/linux-2.4/compat-2.4/include-mips/asm/page.h b/datapath/linux-2.4/compat-2.4/include-mips/asm/page.h new file mode 100644 index 00000000..93a3dffc --- /dev/null +++ b/datapath/linux-2.4/compat-2.4/include-mips/asm/page.h @@ -0,0 +1,17 @@ +#ifndef __ASM_MIPS_PAGE_H_WRAPPER +#define __ASM_MIPS_PAGE_H_WRAPPER 1 + +#include +#include_next +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25) + +#define BUG() \ +do { \ + __asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \ +} while (0) + +#endif /* linux kernel < 2.4.25 */ + +#endif /* asm/page.h */ diff --git a/datapath/linux-2.4/compat-2.4/include-mips/asm/system.h b/datapath/linux-2.4/compat-2.4/include-mips/asm/system.h index c1b08154..815b8530 100644 --- a/datapath/linux-2.4/compat-2.4/include-mips/asm/system.h +++ b/datapath/linux-2.4/compat-2.4/include-mips/asm/system.h @@ -3,8 +3,6 @@ #include_next -#error "Cribbed from linux-2.6/include/asm-mips/system.h but untested." - #define __HAVE_ARCH_CMPXCHG 1 static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old, @@ -52,11 +50,11 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old, } else { unsigned long flags; - raw_local_irq_save(flags); + local_irq_save(flags); retval = *m; if (retval == old) *m = new; - raw_local_irq_restore(flags); /* implies memory barrier */ + local_irq_restore(flags); /* implies memory barrier */ } smp_llsc_mb(); @@ -158,11 +156,11 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old, } else { unsigned long flags; - raw_local_irq_save(flags); + local_irq_save(flags); retval = *m; if (retval == old) *m = new; - raw_local_irq_restore(flags); /* implies memory barrier */ + local_irq_restore(flags); /* implies memory barrier */ } smp_llsc_mb(); diff --git a/datapath/linux-2.4/compat-2.4/include/linux/module.h b/datapath/linux-2.4/compat-2.4/include/linux/module.h index 797a330a..8ba5b781 100644 --- a/datapath/linux-2.4/compat-2.4/include/linux/module.h +++ b/datapath/linux-2.4/compat-2.4/include/linux/module.h @@ -1,6 +1,7 @@ #ifndef __LINUX_MODULE_WRAPPER_H #define __LINUX_MODULE_WRAPPER_H 1 +#include #include_next static inline int try_module_get(struct module *module) -- 2.30.2