/*
 *  linux/include/asm/system.h
 *
 *  Copyright (C) 1991, 1992  Linus Torvalds
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file README.legal in the main directory of this archive
 * for more details.
 */

/*
 * 680x0 support added by Hamish Macdonald
 */

#ifndef _ASM_SYSTEM_H
#define _ASM_SYSTEM_H

#define sti() __asm__ __volatile__ ("andiw #0xf8ff,sr": : : "memory")
#define cli() __asm__ __volatile__ ("oriw  #0x0700,sr": : : "memory")
#define nop() __asm__ __volatile__ ("nop"::)

#define save_flags(x) \
__asm__ __volatile__("movew sr,%0":"=d" (x) : /* no input */ :"memory")

#define restore_flags(x) \
__asm__ __volatile__("movew %0,sr": /* no outputs */ :"d" (x) : "memory")

#define iret() __asm__ __volatile__ ("rte": : :"memory")

#define move_to_user_mode() \
    __asm__ __volatile__ ("movel sp,usp\n\t"     /* setup user sp       */ \
			  "movec %0,msp\n\t"     /* setup kernel sp     */ \
			  "andiw #0xdfff,sr"     /* return to user mode */ \
			  : /* no output */                                \
			  : "r" (current->kernel_stack_page + PAGE_SIZE))

static inline void clear_fpu(void) {
	unsigned long nilstate = 0;
	__asm__ __volatile__ ("frestore %0@" : : "a" (&nilstate));
}

#endif /* _ASM_SYSTEM_H */
