source: trunk/libs/newlib/src/libgloss/sparc_leon/busscan.S @ 621

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

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

File size: 3.6 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!unsigned int ahbslv_scan(register unsigned int vendor,register unsigned int driver) {
27!  register unsigned int conf, mbar,i, *confp;
28!  register unsigned int cfg_area = (unsigned int ) (LEON3_IO_AREA | LEON3_CONF_AREA | LEON3_AHB_SLAVE_CONF_AREA);
29!  for (i = 0; i < LEON3_AHB_SLAVES; i++)
30!  {
31!    confp = (unsigned int*)(cfg_area + (i * LEON3_AHB_CONF_WORDS * 4));
32!    conf = *confp;
33!    //mbar = *(unsigned int*)(i * LEON3_AHB_CONF_WORDS+ (4 * 4));
34!    if ((amba_vendor(conf) == vendor) && (amba_device(conf) == driver)) {
35!      return (unsigned int)confp;
36!    }
37!  }
38!  return 0;
39!}
40
41                 
42        .section        ".text"
43        .global  ahbslv_scan   
44        .align 4
45       
46ahbslv_scan:
47        mov     %o0, %g1
48        mov     -2048, %o5
49        mov     0, %o3
50        sll     %o3, 5, %o0
51.LL11:
52        add     %o5, %o0, %o4
53        ld      [%o5+%o0], %o2
54        srl     %o2, 24, %o0
55        cmp     %o0, %g1
56        bne,a   .LL10
57        add     %o3, 1, %o3
58        srl     %o2, 12, %o0
59        and     %o0, 4095, %o0
60        cmp     %o0, %o1
61        be      .LL1
62        mov     %o4, %o2
63        add     %o3, 1, %o3
64.LL10:
65        cmp     %o3, 7
66        bleu,a  .LL11
67        sll     %o3, 5, %o0
68        mov     0, %o2
69.LL1:
70        retl
71        mov     %o2, %o0
72
73
74!unsigned int apbslv_scan(register unsigned int base,register unsigned int vendor, register unsigned int driver) {
75!  register unsigned int conf, mbar,i, *confp;
76!  for (i = 0; i < LEON3_APB_SLAVES; i++)
77!  {
78!    confp = (unsigned int*)(base + (i * LEON3_APB_CONF_WORDS * 4));
79!    conf = *confp;
80!    //mbar = *(unsigned int*)(i * LEON3_AHB_CONF_WORDS+ (4 * 4));
81!    if ((amba_vendor(conf) == vendor) && (amba_device(conf) == driver)) {
82!      return (unsigned int)confp;
83!    }
84!  }
85!  return 0;
86!}
87
88
89        .section        ".text"
90        .align 4
91        .global  apbslv_scan
92       
93apbslv_scan:
94        mov     %o0, %g1
95        mov     0, %o4
96        sll     %o4, 3, %o0
97.LL22:
98        add     %g1, %o0, %o5
99        ld      [%g1+%o0], %o3
100        srl     %o3, 24, %o0
101        cmp     %o0, %o1
102        bne,a   .LL21
103        add     %o4, 1, %o4
104        srl     %o3, 12, %o0
105        and     %o0, 4095, %o0
106        cmp     %o0, %o2
107        be      .LL12
108        mov     %o5, %o3
109        add     %o4, 1, %o4
110.LL21:
111        cmp     %o4, 15
112        bleu,a  .LL22
113        sll     %o4, 3, %o0
114        mov     0, %o3
115.LL12:
116        retl
117        mov     %o3, %o0
118
119
120
121!unsigned int getbase(register unsigned int *mbar,register unsigned int iobase) {
122!  register unsigned int conf = mbar[1];
123!  return ((iobase & 0xfff00000) |
124!          ((conf & 0xfff00000)>> 12)) & (((conf & 0x0000fff0) <<4) | 0xfff00000);
125
126!}
127       
128         
129        .section        ".text"
130        .align 4
131        .global  iobar_getbase
132
133iobar_getbase:
134        ld      [%o0+4], %o2
135        sethi   %hi(-1048576), %o3
136        and     %o1, %o3, %o1
137        and     %o2, %o3, %o0
138        srl     %o0, 12, %o0
139        or      %o1, %o0, %o1
140        sethi   %hi(64512), %o0
141        or      %o0, 1008, %o0
142        and     %o2, %o0, %o2
143        sll     %o2, 4, %o2
144        or      %o2, %o3, %o2
145        and     %o1, %o2, %o1
146        retl
147        mov     %o1, %o0
148       
Note: See TracBrowser for help on using the repository browser.