OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-m68k/] [system.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _M68K_SYSTEM_H
2
#define _M68K_SYSTEM_H
3
 
4
#include <linux/config.h> /* get configuration macros */
5
#include <linux/linkage.h>
6
#include <asm/segment.h>
7
 
8
extern inline unsigned long rdusp(void) {
9
        unsigned long usp;
10
 
11
        __asm__ __volatile__("movec %/usp,%0"
12
                             : "=d" (usp));
13
        return usp;
14
}
15
 
16
extern inline void wrusp(unsigned long usp) {
17
        __asm__ __volatile__("movec %0,%/usp"
18
                             :
19
                             : "d" (usp));
20
}
21
 
22
/*
23
 * switch_to(n) should switch tasks to task ptr, first checking that
24
 * ptr isn't the current task, in which case it does nothing.  This
25
 * also clears the TS-flag if the task we switched to has used the
26
 * math co-processor latest.
27
 */
28
/*
29
 * switch_to() saves the extra registers, that are not saved
30
 * automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and
31
 * a0-a1. Some of these are used by schedule() and its predecessors
32
 * and so we might get see unexpected behaviors when a task returns
33
 * with unexpected register values.
34
 *
35
 * syscall stores these registers itself and none of them are used
36
 * by syscall after the function in the syscall has been called.
37
 *
38
 * Beware that resume now expects *next to be in d1 and the offset of
39
 * tss to be in a1. This saves a few instructions as we no longer have
40
 * to push them onto the stack and read them back right after.
41
 *
42
 * 02/17/96 - Jes Sorensen (jds@kom.auc.dk)
43
 */
44
asmlinkage void resume(void);
45
#define switch_to(prev,next) { \
46
  register int k __asm__ ("a1") = (int)&((struct task_struct *)0)->tss; \
47
  register int n __asm__ ("d1") = (int)next; \
48
  __asm__ __volatile__("jbsr " SYMBOL_NAME_STR(resume) "\n\t" \
49
                       : : "a" (k), "d" (n) \
50
                       : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1"); \
51
}
52
 
53
#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
54
#define tas(ptr) (xchg((ptr),1))
55
 
56
struct __xchg_dummy { unsigned long a[100]; };
57
#define __xg(x) ((volatile struct __xchg_dummy *)(x))
58
 
59
#if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA) && !defined(CONFIG_MAC)
60
/* block out HSYNC on the atari */
61
#define sti() __asm__ __volatile__ ("andiw #0xfbff,%/sr": : : "memory")
62
#else /* portable version */
63
#define sti() __asm__ __volatile__ ("andiw #0xf8ff,%/sr": : : "memory")
64
#endif /* machine compilation types */ 
65
#define cli() __asm__ __volatile__ ("oriw  #0x0700,%/sr": : : "memory")
66
#define nop() __asm__ __volatile__ ("nop"::)
67
#define mb()  __asm__ __volatile__ (""   : : :"memory")
68
 
69
#define save_flags(x) \
70
__asm__ __volatile__("movew %/sr,%0":"=d" (x) : /* no input */ :"memory")
71
 
72
#define restore_flags(x) \
73
__asm__ __volatile__("movew %0,%/sr": /* no outputs */ :"d" (x) : "memory")
74
 
75
#define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc")
76
 
77
#if 1
78
static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
79
{
80
  unsigned long tmp, flags;
81
 
82
  save_flags(flags);
83
  cli();
84
 
85
  switch (size) {
86
  case 1:
87
    __asm__ __volatile__
88
    ("moveb %2,%0\n\t"
89
     "moveb %1,%2"
90
    : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
91
    break;
92
  case 2:
93
    __asm__ __volatile__
94
    ("movew %2,%0\n\t"
95
     "movew %1,%2"
96
    : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
97
    break;
98
  case 4:
99
    __asm__ __volatile__
100
    ("movel %2,%0\n\t"
101
     "movel %1,%2"
102
    : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
103
    break;
104
  }
105
  restore_flags(flags);
106
  return tmp;
107
}
108
#else
109
static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
110
{
111
        switch (size) {
112
            case 1:
113
                __asm__ __volatile__
114
                        ("moveb %2,%0\n\t"
115
                         "1:\n\t"
116
                         "casb %0,%1,%2\n\t"
117
                         "jne 1b"
118
                         : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
119
                break;
120
            case 2:
121
                __asm__ __volatile__
122
                        ("movew %2,%0\n\t"
123
                         "1:\n\t"
124
                         "casw %0,%1,%2\n\t"
125
                         "jne 1b"
126
                         : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
127
                break;
128
            case 4:
129
                __asm__ __volatile__
130
                        ("movel %2,%0\n\t"
131
                         "1:\n\t"
132
                         "casl %0,%1,%2\n\t"
133
                         "jne 1b"
134
                         : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
135
                break;
136
        }
137
        return x;
138
}
139
#endif
140
 
141
#endif /* _M68K_SYSTEM_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.