Subversion Repositories HelenOS

Rev

Rev 3597 | Rev 3675 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3597 Rev 3623
1
/*
1
/*
2
 * Copyright (c) 2005 Jakub Vana
2
 * Copyright (c) 2005 Jakub Vana
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup ia64
29
/** @addtogroup ia64
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <arch.h>
35
#include <arch.h>
36
#include <arch/ski/ski.h>
36
#include <arch/ski/ski.h>
37
#include <arch/drivers/it.h>
37
#include <arch/drivers/it.h>
38
#include <arch/interrupt.h>
38
#include <arch/interrupt.h>
39
#include <arch/barrier.h>
39
#include <arch/barrier.h>
40
#include <arch/asm.h>
40
#include <arch/asm.h>
41
#include <arch/register.h>
41
#include <arch/register.h>
42
#include <arch/types.h>
42
#include <arch/types.h>
43
#include <arch/context.h>
43
#include <arch/context.h>
44
#include <arch/stack.h>
44
#include <arch/stack.h>
45
#include <arch/mm/page.h>
45
#include <arch/mm/page.h>
46
#include <mm/as.h>
46
#include <mm/as.h>
47
#include <config.h>
47
#include <config.h>
48
#include <userspace.h>
48
#include <userspace.h>
49
#include <console/console.h>
49
#include <console/console.h>
50
#include <proc/uarg.h>
50
#include <proc/uarg.h>
51
#include <syscall/syscall.h>
51
#include <syscall/syscall.h>
52
#include <ddi/irq.h>
52
#include <ddi/irq.h>
53
#include <ddi/device.h>
53
#include <ddi/device.h>
54
#include <arch/drivers/ega.h>
54
#include <arch/drivers/ega.h>
55
#include <arch/bootinfo.h>
55
#include <arch/bootinfo.h>
56
#include <genarch/kbd/i8042.h>
56
#include <genarch/kbd/i8042.h>
57
#include <genarch/kbd/ns16550.h>
57
#include <genarch/kbd/ns16550.h>
58
#include <smp/smp.h>
58
#include <smp/smp.h>
59
#include <smp/ipi.h>
59
#include <smp/ipi.h>
60
#include <arch/atomic.h>
60
#include <arch/atomic.h>
61
#include <panic.h>
61
#include <panic.h>
62
#include <print.h>
62
#include <print.h>
63
 
63
 
64
 
64
 
65
 
65
 
66
 
66
 
67
 
67
 
68
 
68
 
69
#ifdef CONFIG_SMP
69
#ifdef CONFIG_SMP
70
 
70
 
71
 
71
 
72
extern char cpu_by_id_eid_list[256][256];
72
extern char cpu_by_id_eid_list[256][256];
73
 
73
 
74
 
74
 
75
static void sapic_init(void)
75
static void sapic_init(void)
76
{
76
{
77
    bootinfo->sapic=(unative_t *)(PA2KA((unative_t)(bootinfo->sapic))|FW_OFFSET);
77
    bootinfo->sapic=(unative_t *)(PA2KA((unative_t)(bootinfo->sapic))|FW_OFFSET);
78
}
78
}
79
 
79
 
80
 
80
 
81
 
81
 
82
static void ipi_broadcast_arch_all(int ipi )
82
static void ipi_broadcast_arch_all(int ipi )
83
{
83
{
84
    int id,eid;
84
    int id,eid;
85
    int myid,myeid;
85
    int myid,myeid;
86
   
86
   
87
    myid=ia64_get_cpu_id();
87
    myid=ia64_get_cpu_id();
88
    myeid=ia64_get_cpu_eid();
88
    myeid=ia64_get_cpu_eid();
89
 
89
 
90
    printf("Not sending to ID:%d,EID:%d",myid,myeid);
-
 
91
   
90
   
92
    for(id=0;id<256;id++)
91
    for(id=0;id<256;id++)
93
        for(eid=0;eid<256;eid++)
92
        for(eid=0;eid<256;eid++)
94
            if((id!=myid) || (eid!=myeid))
93
            if((id!=myid) || (eid!=myeid))
95
                ipi_send_ipi(id,eid,ipi);
94
                ipi_send_ipi(id,eid,ipi);
96
}
95
}
97
 
96
 
98
void ipi_broadcast_arch(int ipi )
97
void ipi_broadcast_arch(int ipi )
99
{
98
{
100
    ipi_broadcast_arch_all(ipi);
99
    ipi_broadcast_arch_all(ipi);
101
}
100
}
102
 
101
 
103
 
102
 
104
void smp_init(void)
103
void smp_init(void)
105
{
104
{
106
    sapic_init();
105
    sapic_init();
107
    ipi_broadcast_arch_all(bootinfo->wakeup_intno);
106
    ipi_broadcast_arch_all(bootinfo->wakeup_intno);
108
    volatile long long brk;
107
    volatile long long brk;
109
        for(brk=0;brk<100LL*1024LL*1024LL;brk++); //wait a while before CPUs starts
108
        for(brk=0;brk<100LL*1024LL*1024LL;brk++); //wait a while before CPUs starts
110
 
109
 
111
    config.cpu_count=0;
110
    config.cpu_count=0;
112
    int id,eid;
111
    int id,eid;
113
   
112
   
114
    for(id=0;id<256;id++)
113
    for(id=0;id<256;id++)
115
        for(eid=0;eid<256;eid++)
114
        for(eid=0;eid<256;eid++)
116
                if(cpu_by_id_eid_list[id][eid]==1){
115
                if(cpu_by_id_eid_list[id][eid]==1){
117
                    config.cpu_count++;
116
                    config.cpu_count++;
118
                    printf("Found CPU ID:%d EDI:%d\n",id,eid);
-
 
119
                    cpu_by_id_eid_list[id][eid]=2;
117
                    cpu_by_id_eid_list[id][eid]=2;
120
 
118
 
121
            }
119
            }
122
}
120
}
123
 
121
 
124
 
122
 
125
void kmp(void *arg __attribute__((unused)))
123
void kmp(void *arg __attribute__((unused)))
126
{
124
{
127
    int id,eid;
125
    int id,eid;
128
    int myid,myeid;
126
    int myid,myeid;
129
   
127
   
130
    myid=ia64_get_cpu_id();
128
    myid=ia64_get_cpu_id();
131
    myeid=ia64_get_cpu_eid();
129
    myeid=ia64_get_cpu_eid();
132
 
130
 
133
    for(id=0;id<256;id++)
131
    for(id=0;id<256;id++)
134
        for(eid=0;eid<256;eid++)
132
        for(eid=0;eid<256;eid++)
135
                if((id!=myid) || (eid!=myeid))
133
                if((id!=myid) || (eid!=myeid))
136
                    if(cpu_by_id_eid_list[id][eid]!=0){
134
                    if(cpu_by_id_eid_list[id][eid]!=0){
137
                        if(cpu_by_id_eid_list[id][eid]==1){
135
                        if(cpu_by_id_eid_list[id][eid]==1){
138
                   
136
                   
139
                            //config.cpu_count++;
137
                            //config.cpu_count++;
140
                            //cpu_by_id_eid_list[id][eid]=2;
138
                            //cpu_by_id_eid_list[id][eid]=2;
141
                            printf("Found Late CPU ID:%d EDI:%d Not added to system!!!\n",id,eid);
139
                            printf("Found Late CPU ID:%d EDI:%d Not added to system!!!\n",id,eid);
142
                            continue;
140
                            continue;
143
                            }
141
                            }
144
                    cpu_by_id_eid_list[id][eid]=3;
142
                    cpu_by_id_eid_list[id][eid]=3;
145
                    /*
143
                    /*
146
                     * There may be just one AP being initialized at
144
                     * There may be just one AP being initialized at
147
                     * the time. After it comes completely up, it is
145
                     * the time. After it comes completely up, it is
148
                     * supposed to wake us up.
146
                     * supposed to wake us up.
149
                     */
147
                     */
150
                    if (waitq_sleep_timeout(&ap_completion_wq, 1000000,
148
                    if (waitq_sleep_timeout(&ap_completion_wq, 1000000,
151
                        SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) {
149
                        SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) {
152
                        printf("%s: waiting for cpu ID:%d EID:%d"
150
                        printf("%s: waiting for cpu ID:%d EID:%d"
153
                            "timed out\n", __FUNCTION__,
151
                            "timed out\n", __FUNCTION__,
154
                            id, eid);
152
                            id, eid);
155
                        }    
153
                        }    
156
       
154
       
157
                }
155
                }
158
}
156
}
159
#endif
157
#endif
160
 
158
 
161
 
159
 
162
/*This is just a hack for linking with assembler - may be removed in future*/
160
/*This is just a hack for linking with assembler - may be removed in future*/
163
#ifndef CONFIG_SMP
161
#ifndef CONFIG_SMP
164
void main_ap(void);
162
void main_ap(void);
165
void main_ap(void)
163
void main_ap(void)
166
{
164
{
167
    while(1);
165
    while(1);
168
}
166
}
169
 
167
 
170
#endif
168
#endif
171
 
169
 
172
/** @}
170
/** @}
173
 */
171
 */
174
 
172
 
175
 
173