Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: initconfig.c | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | /* | |
24 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | |
25 | * Use is subject to license terms. | |
26 | */ | |
27 | #pragma ident "@(#)initconfig.c 1.6 06/09/24 SMI" | |
28 | ||
29 | #include <sys/types.h> | |
30 | #include <errno.h> | |
31 | #include <stdlib.h> | |
32 | #include <unistd.h> | |
33 | #include <stdio.h> | |
34 | ||
35 | #include <assert.h> | |
36 | ||
37 | #include "basics.h" | |
38 | #include "allocate.h" | |
39 | #include "simcore.h" | |
40 | #include "config.h" | |
41 | #include "options.h" | |
42 | #include "fileutil.h" | |
43 | #include "lexer.h" | |
44 | ||
45 | ||
46 | ||
47 | ||
48 | /* | |
49 | * The parser is the first pass through the configuration. | |
50 | * This is the second pass, and builds all the support data | |
51 | * structures and virtual function pointers that the simulator | |
52 | * is going to require. | |
53 | */ | |
54 | ||
55 | ||
56 | ||
57 | static void init_system(system_t * systemp); | |
58 | static void init_domain(domain_t * domain); | |
59 | ||
60 | ||
61 | ||
62 | /* | |
63 | * This function initializes the simualtor configuration | |
64 | * parse the config and state files. | |
65 | */ | |
66 | ||
67 | void init_config() | |
68 | { | |
69 | int idx; | |
70 | ||
71 | DBG( printf("init_config()\n"); ); | |
72 | ||
73 | /* Initialise the systems within this config | |
74 | */ | |
75 | for (idx=0; idx<target_config.systems.count; idx++) { | |
76 | system_t * systemp; | |
77 | ||
78 | systemp = LIST_ENTRY( target_config.systems, idx ); | |
79 | ||
80 | DBG( printf("init system %d : \"%s\"\n", idx, systemp->namep); ); | |
81 | ||
82 | init_system(systemp); | |
83 | } | |
84 | } | |
85 | ||
86 | ||
87 | ||
88 | ||
89 | ||
90 | ||
91 | ||
92 | /* | |
93 | * Initialise the components of a given system, then | |
94 | * the appropriate info for itself. | |
95 | */ | |
96 | ||
97 | void init_system(system_t * systemp) | |
98 | { | |
99 | int idx; | |
100 | ||
101 | /* | |
102 | * init the service_processor (if there is one) | |
103 | */ | |
104 | if (simstatus.sp.mode) { | |
105 | systemp->service_procp->dev_typep->init_dev(NULL); | |
106 | } | |
107 | ||
108 | /* | |
109 | * init each domain | |
110 | */ | |
111 | for (idx=0; idx<systemp->domains.count; idx++) { | |
112 | domain_t * domainp; | |
113 | ||
114 | domainp = LIST_ENTRY( systemp->domains, idx ); | |
115 | ||
116 | DBG( printf("init_system: domain %d\n", | |
117 | domainp->idx); ); | |
118 | ||
119 | init_domain(domainp); | |
120 | ||
121 | } | |
122 | } | |
123 | ||
124 | ||
125 | ||
126 | /* | |
127 | * OK, initialise the components of a domain - | |
128 | * IO/mem devices, and CPUs. | |
129 | */ | |
130 | ||
131 | void init_domain(domain_t * domainp) | |
132 | { | |
133 | config_dev_t * config_devp; | |
134 | int idx; | |
135 | ||
136 | for (idx=0; idx<domainp->procs.count; idx++) { | |
137 | proc_type_t * proc_typep; | |
138 | config_proc_t * config_procp; | |
139 | ||
140 | config_procp = LIST_ENTRY( domainp->procs, idx ); | |
141 | proc_typep = config_procp->proc_typep; | |
142 | ||
143 | assert( proc_typep->proc_magic == CPU_MAGIC ); | |
144 | ||
145 | DBG( printf("init_domain: proc %d : %s\n", | |
146 | config_procp->proc_id, proc_typep->proc_type_namep); ); | |
147 | ||
148 | /* based on the proc type we call the proc-dependent init */ | |
149 | proc_typep->init_proc(domainp, config_procp); | |
150 | } | |
151 | ||
152 | ||
153 | config_devp = domainp->device.listp; | |
154 | for (idx=0; idx<domainp->device.count; idx++) { | |
155 | dev_type_t * dev_typep; | |
156 | ||
157 | dev_typep = config_devp->dev_typep; | |
158 | ||
159 | DBG( printf("init_domain: device %d : %s : 0x%llx + 0x%llx\n", | |
160 | config_devp->device_id, dev_typep->dev_type_namep, | |
161 | config_devp->addrp->baseaddr, | |
162 | config_devp->addrp->topaddr - config_devp->addrp->baseaddr); ); | |
163 | ||
164 | assert( dev_typep->dev_magic == DEV_MAGIC ); | |
165 | ||
166 | dev_typep->init_dev(config_devp); | |
167 | ||
168 | config_devp = config_devp->nextp; | |
169 | } | |
170 | } | |
171 | ||
172 | ||
173 | ||
174 |