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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-alpha/] [system.h] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1632 jcastillo
#ifndef __ALPHA_SYSTEM_H
2
#define __ALPHA_SYSTEM_H
3
 
4
#include <asm/pal.h>    /* for backwards compatibility... */
5
 
6
/*
7
 * System defines.. Note that this is included both from .c and .S
8
 * files, so it does only defines, not any C code.
9
 */
10
 
11
/*
12
 * We leave one page for the initial stack page, and one page for
13
 * the initial process structure. Also, the console eats 3 MB for
14
 * the initial bootloader (one of which we can reclaim later).
15
 * With a few other pages for various reasons, we'll use an initial
16
 * load address of 0xfffffc0000310000UL
17
 */
18
#define BOOT_PCB        0x20000000
19
#define BOOT_ADDR       0x20000000
20
/* Remove when official MILO sources have ELF support: */
21
#define BOOT_SIZE       (16*1024)
22
 
23
#define KERNEL_START    0xfffffc0000300000
24
#define SWAPPER_PGD     0xfffffc0000300000
25
#define INIT_STACK      0xfffffc0000302000
26
#define EMPTY_PGT       0xfffffc0000304000
27
#define EMPTY_PGE       0xfffffc0000308000
28
#define ZERO_PGE        0xfffffc000030A000
29
 
30
#define START_ADDR      0xfffffc0000310000
31
/* Remove when official MILO sources have ELF support: */
32
#define START_SIZE      (2*1024*1024)
33
 
34
#ifndef __ASSEMBLY__
35
 
36
/*
37
 * This is the logout header that should be common to all platforms
38
 * (assuming they are running OSF/1 PALcode, I guess).
39
 */
40
struct el_common {
41
        unsigned int    size;           /* size in bytes of logout area */
42
        int             sbz1    : 31;   /* should be zero */
43
        char            retry   :  1;   /* retry flag */
44
        unsigned int    proc_offset;    /* processor-specific offset */
45
        unsigned int    sys_offset;     /* system-specific offset */
46
        unsigned long   code;           /* machine check code */
47
};
48
 
49
extern void wrent(void *, unsigned long);
50
extern void wrkgp(unsigned long);
51
extern void wrusp(unsigned long);
52
extern unsigned long rdusp(void);
53
extern unsigned long rdmces (void);
54
extern void wrmces (unsigned long);
55
extern unsigned long whami(void);
56
extern void wripir(unsigned long);
57
 
58
#define halt() __asm__ __volatile__ ("call_pal %0" : : "i" (PAL_halt) : "memory")
59
 
60
#define switch_to(prev,next) do { \
61
        current_set[0] = next; \
62
        alpha_switch_to((unsigned long) &(next)->tss - 0xfffffc0000000000); \
63
} while (0)
64
 
65
extern void alpha_switch_to(unsigned long pctxp);
66
 
67
extern void imb(void);
68
 
69
#define mb() \
70
__asm__ __volatile__("mb": : :"memory")
71
 
72
#define draina() \
73
__asm__ __volatile__ ("call_pal %0" : : "i" (PAL_draina) : "memory")
74
 
75
#define getipl() \
76
({ unsigned long __old_ipl; \
77
__asm__ __volatile__( \
78
        "call_pal 54\n\t" \
79
        "bis $0,$0,%0" \
80
        : "=r" (__old_ipl) \
81
        : : "$0", "$1", "$16", "$22", "$23", "$24", "$25"); \
82
__old_ipl; })
83
 
84
#define setipl(__new_ipl) \
85
__asm__ __volatile__( \
86
        "bis %0,%0,$16\n\t" \
87
        "call_pal 53" \
88
        : : "r" (__new_ipl) \
89
        : "$0", "$1", "$16", "$22", "$23", "$24", "$25", "memory")
90
 
91
#define swpipl(__new_ipl) \
92
({ unsigned long __old_ipl; \
93
__asm__ __volatile__( \
94
        "bis %1,%1,$16\n\t" \
95
        "call_pal 53\n\t" \
96
        "bis $0,$0,%0" \
97
        : "=r" (__old_ipl) \
98
        : "r" (__new_ipl) \
99
        : "$0", "$1", "$16", "$22", "$23", "$24", "$25", "memory"); \
100
__old_ipl; })
101
 
102
#define cli()                   setipl(7)
103
#define sti()                   setipl(0)
104
#define save_flags(flags)       do { flags = getipl(); } while (0)
105
#define restore_flags(flags)    setipl(flags)
106
 
107
/*
108
 * TB routines..
109
 */
110
extern void tbi(long type, ...);
111
 
112
#define tbisi(x)        tbi(1,(x))
113
#define tbisd(x)        tbi(2,(x))
114
#define tbis(x)         tbi(3,(x))
115
#define tbiap()         tbi(-1)
116
#define tbia()          tbi(-2)
117
 
118
/*
119
 * Give prototypes to shut up gcc.
120
 */
121
extern __inline__ unsigned long xchg_u32 (volatile int * m, unsigned long val);
122
extern __inline__ unsigned long xchg_u64 (volatile long * m, unsigned long val);
123
 
124
extern __inline__ unsigned long xchg_u32(volatile int * m, unsigned long val)
125
{
126
        unsigned long dummy;
127
        __asm__ __volatile__(
128
                "\n1:\t"
129
                "ldl_l %0,%2\n\t"
130
                "bis %3,%3,%1\n\t"
131
                "stl_c %1,%2\n\t"
132
                "beq %1,1b\n"
133
                : "=&r" (val), "=&r" (dummy), "=m" (*m)
134
                : "r" (val), "m" (*m));
135
        return val;
136
}
137
 
138
extern __inline__ unsigned long xchg_u64(volatile long * m, unsigned long val)
139
{
140
        unsigned long dummy;
141
        __asm__ __volatile__(
142
                "\n1:\t"
143
                "ldq_l %0,%2\n\t"
144
                "bis %3,%3,%1\n\t"
145
                "stq_c %1,%2\n\t"
146
                "beq %1,1b\n"
147
                : "=&r" (val), "=&r" (dummy), "=m" (*m)
148
                : "r" (val), "m" (*m));
149
        return val;
150
}
151
 
152
#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
153
#define tas(ptr) (xchg((ptr),1))
154
 
155
/*
156
 * This function doesn't exist, so you'll get a linker error
157
 * if something tries to do an invalid xchg().
158
 *
159
 * This only works if the compiler isn't horribly bad at optimizing.
160
 * gcc-2.5.8 reportedly can't handle this, but as that doesn't work
161
 * too well on the alpha anyway..
162
 */
163
extern void __xchg_called_with_bad_pointer(void);
164
 
165
static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
166
{
167
        switch (size) {
168
                case 4:
169
                        return xchg_u32(ptr, x);
170
                case 8:
171
                        return xchg_u64(ptr, x);
172
        }
173
        __xchg_called_with_bad_pointer();
174
        return x;
175
}
176
 
177
#endif /* __ASSEMBLY__ */
178
 
179
#endif

powered by: WebSVN 2.1.0

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