source: trunk/libs/newlib/src/libgloss/sparc_leon/asm-leon/leon3.h @ 487

Last change on this file since 487 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2011 Aeroflex Gaisler
3 *
4 * BSD license:
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25
26#ifndef _INCLUDE_LEON3_h
27#define _INCLUDE_LEON3_h
28
29#ifndef __ASSEMBLER__
30
31#ifdef __cplusplus
32extern "C"
33{
34#endif
35
36#define ASI_LEON3_CACHEMISS 1
37#define ASI_LEON3_SYSCTRL   0x02
38#define ASI_LEON3_DFLUSH    0x11
39
40#define ASI_LEON3_SYSCTRL_ICFG          0x08
41#define ASI_LEON3_SYSCTRL_DCFG          0x0c
42#define ASI_LEON3_SYSCTRL_CFG_SNOOPING (1<<27)
43#define ASI_LEON3_SYSCTRL_CFG_SSIZE(c) (1<<((c>>20)&0xf))
44
45
46  extern __inline__ unsigned long sparc_leon23_get_psr (void)
47  {
48    unsigned int retval;
49    __asm__ __volatile__ ("rd %%psr, %0\n\t":"=r" (retval):);
50      return (retval);
51  }
52
53  extern __inline__ unsigned long sparc_leon23_get_psr_version (void)
54  {
55    unsigned int psr = sparc_leon23_get_psr ();
56    return (psr >> 24) & 0xf;
57  }
58#define LEON_ISLEON2 (sparc_leon23_get_psr_version() == 2 || sparc_leon23_get_psr_version() == 0)
59#define LEON_ISLEON3 (sparc_leon23_get_psr_version() == 3)
60
61  extern __inline__ unsigned long sparc_leon3_get_dcachecfg (void)
62  {
63    unsigned int retval;
64    __asm__
65      __volatile__ ("lda [%1] %2, %0\n\t":"=r" (retval):"r"
66                    (ASI_LEON3_SYSCTRL_DCFG), "i" (ASI_LEON3_SYSCTRL));
67    return (retval);
68  }
69
70  extern __inline__ void sparc_leon3_enable_snooping (void)
71  {
72    /*enable snooping */
73    __asm__ volatile ("lda [%%g0] 2, %%l1\n\t"
74                      "set 0x800000, %%l2\n\t"
75                      "or  %%l2, %%l1, %%l2\n\t"
76                      "sta %%l2, [%%g0] 2\n\t":::"l1", "l2");
77  };
78
79  extern __inline__ void sparc_leon3_disable_cache (void)
80  {
81    /*asi 2 */
82    __asm__ volatile ("lda [%%g0] 2, %%l1\n\t"
83                      "set 0x00000f, %%l2\n\t"
84                      "andn  %%l2, %%l1, %%l2\n\t"
85                      "sta %%l2, [%%g0] 2\n\t":::"l1", "l2");
86  };
87
88
89
90  extern __inline__ void sparc_leon3_dcache_flush (void)
91  {
92    __asm__ __volatile__ (" flush ");   //iflush
93    __asm__
94      __volatile__ ("sta %%g0, [%%g0] %0\n\t"::"i"
95                    (ASI_LEON3_DFLUSH):"memory");
96  };
97
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif /* !ASM */
104
105
106#endif /* !_INCLUDE_LEON3_h */
107/* end of include file */
Note: See TracBrowser for help on using the repository browser.