[1] | 1 | /* |
---|
| 2 | * kernel_init.c - kernel parallel initialization |
---|
[127] | 3 | * |
---|
[23] | 4 | * Authors : Mohamed Lamine Karaoui (2015) |
---|
| 5 | * Alain Greiner (2016,2017) |
---|
[1] | 6 | * |
---|
| 7 | * Copyright (c) Sorbonne Universites |
---|
| 8 | * |
---|
| 9 | * This file is part of ALMOS-MKH. |
---|
| 10 | * |
---|
| 11 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 12 | * under the terms of the GNU General Public License as published by |
---|
| 13 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 14 | * |
---|
| 15 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 18 | * General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU General Public License |
---|
| 21 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 22 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 23 | */ |
---|
| 24 | |
---|
[14] | 25 | #include <kernel_config.h> |
---|
[1] | 26 | #include <errno.h> |
---|
| 27 | #include <hal_types.h> |
---|
| 28 | #include <hal_special.h> |
---|
| 29 | #include <hal_context.h> |
---|
[279] | 30 | #include <hal_irqmask.h> |
---|
[296] | 31 | #include <hal_ppm.h> |
---|
[14] | 32 | #include <barrier.h> |
---|
[1] | 33 | #include <remote_barrier.h> |
---|
[407] | 34 | #include <remote_fifo.h> |
---|
[1] | 35 | #include <core.h> |
---|
| 36 | #include <list.h> |
---|
[68] | 37 | #include <xlist.h> |
---|
[204] | 38 | #include <xhtab.h> |
---|
[1] | 39 | #include <thread.h> |
---|
| 40 | #include <scheduler.h> |
---|
| 41 | #include <kmem.h> |
---|
| 42 | #include <cluster.h> |
---|
| 43 | #include <string.h> |
---|
| 44 | #include <memcpy.h> |
---|
| 45 | #include <ppm.h> |
---|
| 46 | #include <page.h> |
---|
[5] | 47 | #include <chdev.h> |
---|
[1] | 48 | #include <boot_info.h> |
---|
| 49 | #include <dqdt.h> |
---|
| 50 | #include <dev_mmc.h> |
---|
[5] | 51 | #include <dev_dma.h> |
---|
| 52 | #include <dev_iob.h> |
---|
[1] | 53 | #include <dev_ioc.h> |
---|
[5] | 54 | #include <dev_txt.h> |
---|
[1] | 55 | #include <dev_pic.h> |
---|
| 56 | #include <printk.h> |
---|
| 57 | #include <vfs.h> |
---|
[23] | 58 | #include <devfs.h> |
---|
[68] | 59 | #include <mapper.h> |
---|
[1] | 60 | |
---|
[5] | 61 | #define KERNEL_INIT_SYNCHRO 0xA5A5B5B5 |
---|
[1] | 62 | |
---|
| 63 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[279] | 64 | // All the following global variables are replicated in all clusters. |
---|
[1] | 65 | // They are initialised by the kernel_init() function. |
---|
[14] | 66 | // |
---|
[127] | 67 | // WARNING : The section names have been defined to control the base addresses of the |
---|
[14] | 68 | // boot_info structure and the idle thread descriptors, through the kernel.ld script: |
---|
[127] | 69 | // - the boot_info structure is built by the bootloader, and used by kernel_init. |
---|
| 70 | // it must be the first object in the kdata segment. |
---|
[14] | 71 | // - the array of idle threads descriptors must be placed on the first page boundary after |
---|
| 72 | // the boot_info structure in the kdata segment. |
---|
[1] | 73 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 74 | |
---|
[5] | 75 | // This variable defines the local boot_info structure |
---|
| 76 | __attribute__((section(".kinfo"))) |
---|
[14] | 77 | boot_info_t boot_info; |
---|
[5] | 78 | |
---|
[14] | 79 | // This variable defines the "idle" threads descriptors array |
---|
| 80 | __attribute__((section(".kidle"))) |
---|
[381] | 81 | char idle_threads[CONFIG_THREAD_DESC_SIZE * |
---|
[14] | 82 | CONFIG_MAX_LOCAL_CORES] CONFIG_PPM_PAGE_ALIGNED; |
---|
| 83 | |
---|
[127] | 84 | // This variable defines the local cluster manager |
---|
[5] | 85 | __attribute__((section(".kdata"))) |
---|
[19] | 86 | cluster_t cluster_manager CONFIG_CACHE_LINE_ALIGNED; |
---|
[1] | 87 | |
---|
[407] | 88 | // This variable defines the TXT0 kernel terminal (TX only) |
---|
[188] | 89 | __attribute__((section(".kdata"))) |
---|
| 90 | chdev_t txt0_chdev CONFIG_CACHE_LINE_ALIGNED; |
---|
| 91 | |
---|
[14] | 92 | // This variables define the kernel process0 descriptor |
---|
[5] | 93 | __attribute__((section(".kdata"))) |
---|
[19] | 94 | process_t process_zero CONFIG_CACHE_LINE_ALIGNED; |
---|
[1] | 95 | |
---|
[14] | 96 | // This variable defines extended pointers on the distributed chdevs |
---|
[5] | 97 | __attribute__((section(".kdata"))) |
---|
[14] | 98 | chdev_directory_t chdev_dir CONFIG_CACHE_LINE_ALIGNED; |
---|
[1] | 99 | |
---|
[188] | 100 | // This variable contains the input IRQ indexes for the IOPIC controller |
---|
[5] | 101 | __attribute__((section(".kdata"))) |
---|
[246] | 102 | iopic_input_t iopic_input CONFIG_CACHE_LINE_ALIGNED; |
---|
[1] | 103 | |
---|
[188] | 104 | // This variable contains the input IRQ indexes for the LAPIC controller |
---|
[5] | 105 | __attribute__((section(".kdata"))) |
---|
[188] | 106 | lapic_input_t lapic_input CONFIG_CACHE_LINE_ALIGNED; |
---|
[1] | 107 | |
---|
[14] | 108 | // This variable defines the local cluster identifier |
---|
[5] | 109 | __attribute__((section(".kdata"))) |
---|
[14] | 110 | cxy_t local_cxy CONFIG_CACHE_LINE_ALIGNED; |
---|
[5] | 111 | |
---|
[127] | 112 | // This variable is used for CP0 cores synchronisation in kernel_init() |
---|
[5] | 113 | __attribute__((section(".kdata"))) |
---|
[14] | 114 | remote_barrier_t global_barrier CONFIG_CACHE_LINE_ALIGNED; |
---|
[1] | 115 | |
---|
[127] | 116 | // This variable is used for local cores synchronisation in kernel_init() |
---|
[14] | 117 | __attribute__((section(".kdata"))) |
---|
| 118 | barrier_t local_barrier CONFIG_CACHE_LINE_ALIGNED; |
---|
| 119 | |
---|
[127] | 120 | // This variable defines the array of supported File System contexts |
---|
[50] | 121 | __attribute__((section(".kdata"))) |
---|
| 122 | vfs_ctx_t fs_context[FS_TYPES_NR] CONFIG_CACHE_LINE_ALIGNED; |
---|
| 123 | |
---|
| 124 | |
---|
[408] | 125 | // TODO remove these debug variables used dans sys_read() |
---|
| 126 | |
---|
| 127 | #if CONFIG_READ_DEBUG |
---|
[407] | 128 | uint32_t enter_sys_read; |
---|
| 129 | uint32_t exit_sys_read; |
---|
| 130 | |
---|
| 131 | uint32_t enter_devfs_move; |
---|
| 132 | uint32_t exit_devfs_move; |
---|
| 133 | |
---|
| 134 | uint32_t enter_txt_read; |
---|
| 135 | uint32_t exit_txt_read; |
---|
| 136 | |
---|
| 137 | uint32_t enter_chdev_cmd; |
---|
| 138 | uint32_t exit_chdev_cmd; |
---|
| 139 | |
---|
| 140 | uint32_t enter_chdev_server; |
---|
| 141 | uint32_t exit_chdev_server; |
---|
| 142 | |
---|
| 143 | uint32_t enter_tty_cmd; |
---|
| 144 | uint32_t exit_tty_cmd; |
---|
| 145 | |
---|
| 146 | uint32_t enter_tty_isr; |
---|
| 147 | uint32_t exit_tty_isr; |
---|
| 148 | #endif |
---|
| 149 | |
---|
[1] | 150 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[5] | 151 | // This function displays the ALMOS_MKH banner. |
---|
[1] | 152 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[5] | 153 | static void print_banner( uint32_t nclusters , uint32_t ncores ) |
---|
[127] | 154 | { |
---|
[5] | 155 | printk("\n" |
---|
| 156 | " _ __ __ _____ ______ __ __ _ __ _ _ \n" |
---|
| 157 | " /\\ | | | \\ / | / ___ \\ / _____| | \\ / | | | / / | | | | \n" |
---|
| 158 | " / \\ | | | \\/ | | / \\ | | / | \\/ | | |/ / | | | | \n" |
---|
| 159 | " / /\\ \\ | | | |\\ /| | | | | | | |_____ ___ | |\\ /| | | / | |___| | \n" |
---|
| 160 | " / /__\\ \\ | | | | \\/ | | | | | | \\_____ \\ |___| | | \\/ | | | \\ | ___ | \n" |
---|
| 161 | " / ______ \\ | | | | | | | | | | | | | | | | | |\\ \\ | | | | \n" |
---|
| 162 | " / / \\ \\ | |____ | | | | | \\___/ | _____/ | | | | | | | \\ \\ | | | | \n" |
---|
| 163 | " /_/ \\_\\ |______| |_| |_| \\_____/ |______/ |_| |_| |_| \\_\\ |_| |_| \n" |
---|
| 164 | "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n" |
---|
[407] | 165 | "\n\n\t\t Version 0.0 / %d cluster(s) / %d core(s) per cluster / cycle %d\n\n", |
---|
| 166 | nclusters , ncores , hal_time_stamp() ); |
---|
[5] | 167 | } |
---|
[1] | 168 | |
---|
| 169 | |
---|
[5] | 170 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 171 | // This function initializes the TXT0 chdev descriptor, that is the "kernel terminal", |
---|
| 172 | // shared by all kernel instances for debug messages. |
---|
| 173 | // It is a global variable (replicated in all clusters), because this terminal is used |
---|
| 174 | // before the kmem allocator initialisation, but only the instance in cluster containing |
---|
| 175 | // the calling core is registered in the "chdev_dir" directory. |
---|
[127] | 176 | // As this TXT0 chdev supports only the TXT_SYNC_WRITE command, we don't create |
---|
| 177 | // a server thread, we don't allocate a WTI, and we don't initialize the waiting queue. |
---|
[5] | 178 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 179 | // @ info : pointer on the local boot-info structure. |
---|
| 180 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 181 | static void txt0_device_init( boot_info_t * info ) |
---|
| 182 | { |
---|
| 183 | boot_device_t * dev_tbl; // pointer on array of devices in boot_info |
---|
[127] | 184 | uint32_t dev_nr; // actual number of devices in this cluster |
---|
| 185 | xptr_t base; // remote pointer on segment base |
---|
| 186 | uint32_t func; // device functional index |
---|
[5] | 187 | uint32_t impl; // device implementation index |
---|
[127] | 188 | uint32_t i; // device index in dev_tbl |
---|
| 189 | uint32_t x; // X cluster coordinate |
---|
| 190 | uint32_t y; // Y cluster coordinate |
---|
[188] | 191 | uint32_t channels; // number of channels |
---|
[1] | 192 | |
---|
[5] | 193 | // get number of peripherals and base of devices array from boot_info |
---|
[127] | 194 | dev_nr = info->ext_dev_nr; |
---|
[5] | 195 | dev_tbl = info->ext_dev; |
---|
[1] | 196 | |
---|
[14] | 197 | // loop on external peripherals to find TXT device |
---|
[127] | 198 | for( i = 0 ; i < dev_nr ; i++ ) |
---|
| 199 | { |
---|
[5] | 200 | base = dev_tbl[i].base; |
---|
[188] | 201 | func = FUNC_FROM_TYPE( dev_tbl[i].type ); |
---|
| 202 | impl = IMPL_FROM_TYPE( dev_tbl[i].type ); |
---|
| 203 | channels = dev_tbl[i].channels; |
---|
[5] | 204 | |
---|
[127] | 205 | if (func == DEV_FUNC_TXT ) |
---|
[5] | 206 | { |
---|
[188] | 207 | assert( (channels > 0) , __FUNCTION__ , |
---|
| 208 | "numner of TXT channels cannot be 0\n"); |
---|
[5] | 209 | |
---|
[188] | 210 | // initializes TXT0 basic fields |
---|
| 211 | txt0_chdev.func = func; |
---|
| 212 | txt0_chdev.impl = impl; |
---|
| 213 | txt0_chdev.channel = 0; |
---|
| 214 | txt0_chdev.base = base; |
---|
| 215 | txt0_chdev.is_rx = false; |
---|
| 216 | |
---|
| 217 | // initializes lock |
---|
[14] | 218 | remote_spinlock_init( XPTR( local_cxy , &txt0_chdev.wait_lock ) ); |
---|
[188] | 219 | |
---|
| 220 | // TXT specific initialisation: |
---|
| 221 | // no server thread & no IRQ routing for channel 0 |
---|
| 222 | dev_txt_init( &txt0_chdev ); |
---|
[14] | 223 | |
---|
[188] | 224 | // register the TXT0 in all chdev_dir[x][y] structures |
---|
[5] | 225 | for( x = 0 ; x < info->x_size ; x++ ) |
---|
| 226 | { |
---|
| 227 | for( y = 0 ; y < info->y_size ; y++ ) |
---|
| 228 | { |
---|
| 229 | cxy_t cxy = (x<<info->y_width) + y; |
---|
[407] | 230 | hal_remote_swd( XPTR( cxy , &chdev_dir.txt_tx[0] ) , |
---|
[14] | 231 | XPTR( local_cxy , &txt0_chdev ) ); |
---|
[5] | 232 | } |
---|
| 233 | } |
---|
| 234 | } |
---|
[188] | 235 | } // end loop on devices |
---|
| 236 | } // end txt0_device_init() |
---|
[5] | 237 | |
---|
[1] | 238 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 239 | // This function allocates memory and initializes the chdev descriptors for the internal |
---|
| 240 | // peripherals contained in the local cluster, other than the LAPIC, as specified by |
---|
| 241 | // the boot_info, including the linking with the driver for the specified implementation. |
---|
| 242 | // The relevant entries in all copies of the devices directory are initialised. |
---|
[1] | 243 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 244 | // @ info : pointer on the local boot-info structure. |
---|
| 245 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[5] | 246 | static void internal_devices_init( boot_info_t * info ) |
---|
[1] | 247 | { |
---|
[188] | 248 | boot_device_t * dev_tbl; // pointer on array of internaldevices in boot_info |
---|
| 249 | uint32_t dev_nr; // actual number of devices in this cluster |
---|
| 250 | xptr_t base; // remote pointer on segment base |
---|
| 251 | uint32_t func; // device functionnal index |
---|
| 252 | uint32_t impl; // device implementation index |
---|
| 253 | uint32_t i; // device index in dev_tbl |
---|
| 254 | uint32_t x; // X cluster coordinate |
---|
| 255 | uint32_t y; // Y cluster coordinate |
---|
| 256 | uint32_t channels; // number of channels |
---|
| 257 | uint32_t channel; // channel index |
---|
| 258 | chdev_t * chdev_ptr; // local pointer on created chdev |
---|
[1] | 259 | |
---|
[188] | 260 | // get number of internal peripherals and base from boot_info |
---|
| 261 | dev_nr = info->int_dev_nr; |
---|
| 262 | dev_tbl = info->int_dev; |
---|
[1] | 263 | |
---|
[188] | 264 | // loop on internal peripherals |
---|
| 265 | for( i = 0 ; i < dev_nr ; i++ ) |
---|
| 266 | { |
---|
| 267 | base = dev_tbl[i].base; |
---|
| 268 | channels = dev_tbl[i].channels; |
---|
| 269 | func = FUNC_FROM_TYPE( dev_tbl[i].type ); |
---|
| 270 | impl = IMPL_FROM_TYPE( dev_tbl[i].type ); |
---|
[204] | 271 | |
---|
[188] | 272 | ////////////////////////// |
---|
| 273 | if( func == DEV_FUNC_MMC ) |
---|
[5] | 274 | { |
---|
[188] | 275 | assert( (channels == 1) , __FUNCTION__ , |
---|
| 276 | "MMC device must be single channel\n" ); |
---|
[1] | 277 | |
---|
[188] | 278 | // create chdev in local cluster |
---|
| 279 | chdev_ptr = chdev_create( func, |
---|
| 280 | impl, |
---|
| 281 | 0, // channel |
---|
| 282 | false, // direction |
---|
| 283 | base ); |
---|
[14] | 284 | |
---|
[188] | 285 | assert( (chdev_ptr != NULL) , __FUNCTION__ , |
---|
| 286 | "cannot allocate memory for MMC chdev\n" ); |
---|
| 287 | |
---|
| 288 | // make MMC specific initialisation |
---|
| 289 | dev_mmc_init( chdev_ptr ); |
---|
[1] | 290 | |
---|
[188] | 291 | // set the MMC field in all chdev_dir[x][y] structures |
---|
| 292 | for( x = 0 ; x < info->x_size ; x++ ) |
---|
[1] | 293 | { |
---|
[188] | 294 | for( y = 0 ; y < info->y_size ; y++ ) |
---|
| 295 | { |
---|
| 296 | cxy_t cxy = (x<<info->y_width) + y; |
---|
| 297 | hal_remote_swd( XPTR( cxy , &chdev_dir.mmc[local_cxy] ), |
---|
| 298 | XPTR( local_cxy , chdev_ptr ) ); |
---|
| 299 | } |
---|
[1] | 300 | } |
---|
[188] | 301 | |
---|
[407] | 302 | #if( CONFIG_KINIT_DEBUG & 0x1 ) |
---|
| 303 | if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) |
---|
| 304 | printk("\n[DBG] %s : created MMC in cluster %x / chdev = %x\n", |
---|
| 305 | __FUNCTION__ , local_cxy , chdev_ptr ); |
---|
[389] | 306 | #endif |
---|
[14] | 307 | } |
---|
[188] | 308 | /////////////////////////////// |
---|
| 309 | else if( func == DEV_FUNC_DMA ) |
---|
[127] | 310 | { |
---|
[188] | 311 | // create one chdev per channel in local cluster |
---|
| 312 | for( channel = 0 ; channel < channels ; channel++ ) |
---|
| 313 | { |
---|
| 314 | // create chdev[channel] in local cluster |
---|
| 315 | chdev_ptr = chdev_create( func, |
---|
| 316 | impl, |
---|
| 317 | channel, |
---|
| 318 | false, // direction |
---|
| 319 | base ); |
---|
[5] | 320 | |
---|
[188] | 321 | assert( (chdev_ptr != NULL) , __FUNCTION__ , |
---|
| 322 | "cannot allocate memory for DMA chdev" ); |
---|
| 323 | |
---|
| 324 | // make DMA specific initialisation |
---|
| 325 | dev_dma_init( chdev_ptr ); |
---|
[127] | 326 | |
---|
[188] | 327 | // initialize only the DMA[channel] field in the local chdev_dir[x][y] |
---|
| 328 | // structure because the DMA device is not remotely accessible. |
---|
| 329 | chdev_dir.dma[channel] = XPTR( local_cxy , chdev_ptr ); |
---|
[5] | 330 | |
---|
[407] | 331 | #if( CONFIG_KINIT_DEBUG & 0x1 ) |
---|
| 332 | if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) |
---|
| 333 | printk("\n[DBG] %s : created DMA[%d] in cluster %x / chdev = %x\n", |
---|
[389] | 334 | __FUNCTION__ , channel , local_cxy , chdev_ptr ); |
---|
| 335 | #endif |
---|
[188] | 336 | } |
---|
[14] | 337 | } |
---|
[127] | 338 | } |
---|
[5] | 339 | } // end internal_devices_init() |
---|
| 340 | |
---|
| 341 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 342 | // This function allocates memory and initializes the chdev descriptors for the |
---|
[408] | 343 | // external (shared) peripherals other than the IOPIC, as specified by the boot_info. |
---|
| 344 | // This includes the dynamic linking with the driver for the specified implementation. |
---|
[188] | 345 | // These chdev descriptors are distributed on all clusters, using a modulo on a global |
---|
[408] | 346 | // index, identically computed in all clusters. |
---|
| 347 | // This function is executed in all clusters by the CP0 core, that computes a global index |
---|
| 348 | // for all external chdevs. Each CP0 core creates only the chdevs that must be placed in |
---|
| 349 | // the local cluster, because the global index matches the local index. |
---|
[188] | 350 | // The relevant entries in all copies of the devices directory are initialised. |
---|
[5] | 351 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 352 | // @ info : pointer on the local boot-info structure. |
---|
| 353 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 354 | static void external_devices_init( boot_info_t * info ) |
---|
| 355 | { |
---|
[188] | 356 | boot_device_t * dev_tbl; // pointer on array of external devices in boot_info |
---|
| 357 | uint32_t dev_nr; // actual number of external devices |
---|
| 358 | xptr_t base; // remote pointer on segment base |
---|
[5] | 359 | uint32_t func; // device functionnal index |
---|
| 360 | uint32_t impl; // device implementation index |
---|
[188] | 361 | uint32_t i; // device index in dev_tbl |
---|
| 362 | uint32_t x; // X cluster coordinate |
---|
| 363 | uint32_t y; // Y cluster coordinate |
---|
| 364 | uint32_t channels; // number of channels |
---|
| 365 | uint32_t channel; // channel index |
---|
| 366 | uint32_t directions; // number of directions (1 or 2) |
---|
| 367 | uint32_t rx; // direction index (0 or 1) |
---|
| 368 | uint32_t first_channel; // used in loop on channels for TXT |
---|
[127] | 369 | chdev_t * chdev; // local pointer on one channel_device descriptor |
---|
[188] | 370 | uint32_t ext_chdev_gid; // global index of external chdev |
---|
[5] | 371 | |
---|
| 372 | // get number of peripherals and base of devices array from boot_info |
---|
[127] | 373 | dev_nr = info->ext_dev_nr; |
---|
[5] | 374 | dev_tbl = info->ext_dev; |
---|
| 375 | |
---|
[188] | 376 | // initializes global index (PIC is already placed in cluster 0 |
---|
| 377 | ext_chdev_gid = 1; |
---|
| 378 | |
---|
[5] | 379 | // loop on external peripherals |
---|
[127] | 380 | for( i = 0 ; i < dev_nr ; i++ ) |
---|
| 381 | { |
---|
[188] | 382 | base = dev_tbl[i].base; |
---|
| 383 | channels = dev_tbl[i].channels; |
---|
| 384 | func = FUNC_FROM_TYPE( dev_tbl[i].type ); |
---|
| 385 | impl = IMPL_FROM_TYPE( dev_tbl[i].type ); |
---|
[5] | 386 | |
---|
[407] | 387 | // There is one chdev per direction for NIC and for TXT |
---|
| 388 | if((func == DEV_FUNC_NIC) || (func == DEV_FUNC_TXT)) directions = 2; |
---|
| 389 | else directions = 1; |
---|
[5] | 390 | |
---|
| 391 | // The TXT0 chdev has already been created |
---|
| 392 | if (func == DEV_FUNC_TXT) first_channel = 1; |
---|
| 393 | else first_channel = 0; |
---|
| 394 | |
---|
[407] | 395 | // do nothing for ROM, that does not require a device descriptor. |
---|
[5] | 396 | if( func == DEV_FUNC_ROM ) continue; |
---|
| 397 | |
---|
[188] | 398 | // do nothing for PIC, that is already initialized |
---|
| 399 | if( func == DEV_FUNC_PIC ) continue; |
---|
[5] | 400 | |
---|
[188] | 401 | // check PIC device initialized |
---|
| 402 | assert( (chdev_dir.pic != XPTR_NULL ) , __FUNCTION__ , |
---|
| 403 | "PIC device must be initialized before other devices\n" ); |
---|
| 404 | |
---|
| 405 | // check external device functionnal type |
---|
| 406 | assert( ( (func == DEV_FUNC_IOB) || |
---|
| 407 | (func == DEV_FUNC_IOC) || |
---|
| 408 | (func == DEV_FUNC_TXT) || |
---|
| 409 | (func == DEV_FUNC_NIC) || |
---|
| 410 | (func == DEV_FUNC_FBF) ) , __FUNCTION__ , |
---|
| 411 | "undefined external peripheral type\n" ); |
---|
| 412 | |
---|
[127] | 413 | // loops on channels |
---|
[188] | 414 | for( channel = first_channel ; channel < channels ; channel++ ) |
---|
[127] | 415 | { |
---|
[5] | 416 | // loop on directions |
---|
[188] | 417 | for( rx = 0 ; rx < directions ; rx++ ) |
---|
[1] | 418 | { |
---|
[188] | 419 | // compute target cluster for chdev[func,channel,direction] |
---|
| 420 | uint32_t offset = ext_chdev_gid % ( info->x_size * info->y_size ); |
---|
[5] | 421 | uint32_t cx = offset / info->y_size; |
---|
| 422 | uint32_t cy = offset % info->y_size; |
---|
| 423 | uint32_t target_cxy = (cx<<info->y_width) + cy; |
---|
[1] | 424 | |
---|
[5] | 425 | // allocate and initialize a local chdev |
---|
[407] | 426 | // when local cluster matches target cluster |
---|
[5] | 427 | if( target_cxy == local_cxy ) |
---|
[1] | 428 | { |
---|
[5] | 429 | chdev = chdev_create( func, |
---|
| 430 | impl, |
---|
| 431 | channel, |
---|
[188] | 432 | rx, // direction |
---|
[5] | 433 | base ); |
---|
| 434 | |
---|
[127] | 435 | assert( (chdev != NULL), __FUNCTION__ , |
---|
[5] | 436 | "cannot allocate external device" ); |
---|
| 437 | |
---|
| 438 | // make device type specific initialisation |
---|
| 439 | if ( func == DEV_FUNC_IOB ) dev_iob_init( chdev ); |
---|
| 440 | else if( func == DEV_FUNC_IOC ) dev_ioc_init( chdev ); |
---|
| 441 | else if( func == DEV_FUNC_TXT ) dev_txt_init( chdev ); |
---|
| 442 | else if( func == DEV_FUNC_NIC ) dev_nic_init( chdev ); |
---|
[188] | 443 | else if( func == DEV_FUNC_FBF ) dev_fbf_init( chdev ); |
---|
[5] | 444 | |
---|
[127] | 445 | // all external (shared) devices are remotely accessible |
---|
[5] | 446 | // initialize the replicated chdev_dir[x][y] structures |
---|
[127] | 447 | // defining the extended pointers on chdev descriptors |
---|
| 448 | xptr_t * entry; |
---|
| 449 | |
---|
[188] | 450 | if(func==DEV_FUNC_IOB ) entry = &chdev_dir.iob; |
---|
| 451 | if(func==DEV_FUNC_IOC ) entry = &chdev_dir.ioc[channel]; |
---|
| 452 | if(func==DEV_FUNC_FBF ) entry = &chdev_dir.fbf[channel]; |
---|
[407] | 453 | if((func==DEV_FUNC_TXT) && (rx==0)) entry = &chdev_dir.txt_tx[channel]; |
---|
| 454 | if((func==DEV_FUNC_TXT) && (rx==1)) entry = &chdev_dir.txt_rx[channel]; |
---|
[188] | 455 | if((func==DEV_FUNC_NIC) && (rx==0)) entry = &chdev_dir.nic_tx[channel]; |
---|
| 456 | if((func==DEV_FUNC_NIC) && (rx==1)) entry = &chdev_dir.nic_rx[channel]; |
---|
[127] | 457 | |
---|
[1] | 458 | for( x = 0 ; x < info->x_size ; x++ ) |
---|
| 459 | { |
---|
| 460 | for( y = 0 ; y < info->y_size ; y++ ) |
---|
| 461 | { |
---|
| 462 | cxy_t cxy = (x<<info->y_width) + y; |
---|
[188] | 463 | hal_remote_swd( XPTR( cxy , entry ), |
---|
| 464 | XPTR( local_cxy , chdev ) ); |
---|
[5] | 465 | } |
---|
[1] | 466 | } |
---|
| 467 | |
---|
[407] | 468 | #if( CONFIG_KINIT_DEBUG & 0x1 ) |
---|
| 469 | if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) |
---|
| 470 | printk("\n[DBG] %s : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n", |
---|
| 471 | __FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev ); |
---|
[389] | 472 | #endif |
---|
[5] | 473 | } // end if match |
---|
| 474 | |
---|
[19] | 475 | // increment chdev global index (matching or not) |
---|
[188] | 476 | ext_chdev_gid++; |
---|
[5] | 477 | |
---|
| 478 | } // end loop on directions |
---|
| 479 | } // end loop on channels |
---|
[188] | 480 | } // end loop on devices |
---|
| 481 | } // end external_devices_init() |
---|
[5] | 482 | |
---|
[188] | 483 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 484 | // This function is called by CP0 in cluster 0 to allocate memory and initialize the PIC |
---|
[407] | 485 | // device, namely the informations attached to the external IOPIC controller, that |
---|
| 486 | // must be replicated in all clusters (struct iopic_input). |
---|
[188] | 487 | // This initialisation must be done before other devices initialisation because the IRQ |
---|
[407] | 488 | // routing infrastructure is required for both internal and external devices init. |
---|
[188] | 489 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 490 | // @ info : pointer on the local boot-info structure. |
---|
| 491 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 492 | static void iopic_init( boot_info_t * info ) |
---|
| 493 | { |
---|
| 494 | boot_device_t * dev_tbl; // pointer on boot_info external devices array |
---|
| 495 | uint32_t dev_nr; // actual number of external devices |
---|
| 496 | xptr_t base; // remote pointer on segment base |
---|
| 497 | uint32_t func; // device functionnal index |
---|
| 498 | uint32_t impl; // device implementation index |
---|
| 499 | uint32_t i; // device index in dev_tbl |
---|
| 500 | uint32_t x; // cluster X coordinate |
---|
| 501 | uint32_t y; // cluster Y coordinate |
---|
| 502 | bool_t found; // IOPIC found |
---|
| 503 | chdev_t * chdev; // pointer on PIC chdev descriptor |
---|
| 504 | |
---|
| 505 | // get number of external peripherals and base of array from boot_info |
---|
| 506 | dev_nr = info->ext_dev_nr; |
---|
| 507 | dev_tbl = info->ext_dev; |
---|
| 508 | |
---|
| 509 | // loop on external peripherals to get the IOPIC |
---|
| 510 | for( i = 0 , found = false ; i < dev_nr ; i++ ) |
---|
| 511 | { |
---|
| 512 | func = FUNC_FROM_TYPE( dev_tbl[i].type ); |
---|
| 513 | |
---|
[127] | 514 | if( func == DEV_FUNC_PIC ) |
---|
[1] | 515 | { |
---|
[188] | 516 | base = dev_tbl[i].base; |
---|
| 517 | impl = IMPL_FROM_TYPE( dev_tbl[i].type ); |
---|
| 518 | found = true; |
---|
| 519 | break; |
---|
| 520 | } |
---|
| 521 | } |
---|
[5] | 522 | |
---|
[188] | 523 | assert( found , __FUNCTION__ , "PIC device not found\n" ); |
---|
[1] | 524 | |
---|
[407] | 525 | // allocate and initialize the PIC chdev in cluster 0 |
---|
| 526 | chdev = chdev_create( DEV_FUNC_PIC, |
---|
[188] | 527 | impl, |
---|
| 528 | 0, // channel |
---|
| 529 | 0, // direction, |
---|
| 530 | base ); |
---|
[5] | 531 | |
---|
[188] | 532 | assert( (chdev != NULL), __FUNCTION__ , "no memory for PIC chdev\n" ); |
---|
[5] | 533 | |
---|
[188] | 534 | // make PIC device type specific initialisation |
---|
| 535 | dev_pic_init( chdev ); |
---|
[1] | 536 | |
---|
[407] | 537 | // register, in all clusters, the extended pointer |
---|
| 538 | // on PIC chdev in "chdev_dir" array |
---|
[188] | 539 | xptr_t * entry = &chdev_dir.pic; |
---|
| 540 | |
---|
| 541 | for( x = 0 ; x < info->x_size ; x++ ) |
---|
| 542 | { |
---|
| 543 | for( y = 0 ; y < info->y_size ; y++ ) |
---|
| 544 | { |
---|
| 545 | cxy_t cxy = (x<<info->y_width) + y; |
---|
| 546 | hal_remote_swd( XPTR( cxy , entry ) , |
---|
| 547 | XPTR( local_cxy , chdev ) ); |
---|
| 548 | } |
---|
| 549 | } |
---|
[1] | 550 | |
---|
[407] | 551 | // initialize, in all clusters, the "iopic_input" structure |
---|
[188] | 552 | // defining how external IRQs are connected to IOPIC |
---|
| 553 | |
---|
[407] | 554 | // register default value for unused inputs |
---|
| 555 | for( x = 0 ; x < info->x_size ; x++ ) |
---|
| 556 | { |
---|
| 557 | for( y = 0 ; y < info->y_size ; y++ ) |
---|
| 558 | { |
---|
| 559 | cxy_t cxy = (x<<info->y_width) + y; |
---|
| 560 | hal_remote_memset( XPTR( cxy , &iopic_input ) , 0xFF , sizeof(iopic_input_t) ); |
---|
| 561 | } |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | // register input IRQ index for valid inputs |
---|
| 565 | uint32_t id; // input IRQ index |
---|
| 566 | uint8_t valid; // input IRQ is connected |
---|
| 567 | uint32_t type; // source device type |
---|
| 568 | uint8_t channel; // source device channel |
---|
| 569 | uint8_t is_rx; // source device direction |
---|
| 570 | uint32_t * ptr; // local pointer on one field in iopic_input stucture |
---|
| 571 | |
---|
[188] | 572 | for( id = 0 ; id < CONFIG_MAX_EXTERNAL_IRQS ; id++ ) |
---|
| 573 | { |
---|
| 574 | valid = dev_tbl[i].irq[id].valid; |
---|
| 575 | type = dev_tbl[i].irq[id].dev_type; |
---|
| 576 | channel = dev_tbl[i].irq[id].channel; |
---|
| 577 | is_rx = dev_tbl[i].irq[id].is_rx; |
---|
[407] | 578 | func = FUNC_FROM_TYPE( type ); |
---|
[188] | 579 | |
---|
[407] | 580 | // get pointer on relevant field in iopic_input |
---|
| 581 | if( valid ) |
---|
[188] | 582 | { |
---|
[407] | 583 | if ( func == DEV_FUNC_IOC ) ptr = &iopic_input.ioc[channel]; |
---|
| 584 | else if((func == DEV_FUNC_TXT) && (is_rx == 0)) ptr = &iopic_input.txt_tx[channel]; |
---|
| 585 | else if((func == DEV_FUNC_TXT) && (is_rx != 0)) ptr = &iopic_input.txt_rx[channel]; |
---|
| 586 | else if((func == DEV_FUNC_NIC) && (is_rx == 0)) ptr = &iopic_input.nic_tx[channel]; |
---|
| 587 | else if((func == DEV_FUNC_NIC) && (is_rx != 0)) ptr = &iopic_input.nic_rx[channel]; |
---|
| 588 | else if( func == DEV_FUNC_IOB ) ptr = &iopic_input.iob; |
---|
| 589 | else panic( "illegal source device for IOPIC input" ); |
---|
[188] | 590 | |
---|
[407] | 591 | // set one entry in all "iopic_input" structures |
---|
| 592 | for( x = 0 ; x < info->x_size ; x++ ) |
---|
| 593 | { |
---|
| 594 | for( y = 0 ; y < info->y_size ; y++ ) |
---|
| 595 | { |
---|
| 596 | cxy_t cxy = (x<<info->y_width) + y; |
---|
| 597 | hal_remote_swd( XPTR( cxy , ptr ) , id ); |
---|
| 598 | } |
---|
| 599 | } |
---|
[188] | 600 | } |
---|
| 601 | } |
---|
| 602 | |
---|
[407] | 603 | #if( CONFIG_KINIT_DEBUG & 0x1 ) |
---|
| 604 | if( hal_time_stamp() > CONFIG_KINIT_DEBUG ) |
---|
| 605 | { |
---|
| 606 | printk("\n[DBG] %s created PIC chdev in cluster %x at cycle %d\n", |
---|
| 607 | __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() ); |
---|
| 608 | dev_pic_inputs_display(); |
---|
| 609 | } |
---|
[389] | 610 | #endif |
---|
[188] | 611 | |
---|
| 612 | } // end iopic_init() |
---|
| 613 | |
---|
[1] | 614 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 615 | // This function is called by all CP0s in all cluster to complete the PIC device |
---|
| 616 | // initialisation, namely the informations attached to the LAPIC controller. |
---|
| 617 | // This initialisation must be done after the IOPIC initialisation, but before other |
---|
| 618 | // devices initialisation because the IRQ routing infrastructure is required for both |
---|
| 619 | // internal and external devices initialisation. |
---|
| 620 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 621 | // @ info : pointer on the local boot-info structure. |
---|
| 622 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 623 | static void lapic_init( boot_info_t * info ) |
---|
| 624 | { |
---|
| 625 | boot_device_t * dev_tbl; // pointer on boot_info internal devices array |
---|
| 626 | uint32_t dev_nr; // number of internal devices |
---|
| 627 | uint32_t i; // device index in dev_tbl |
---|
| 628 | xptr_t base; // remote pointer on segment base |
---|
| 629 | uint32_t func; // device functionnal type in boot_info |
---|
| 630 | bool_t found; // LAPIC found |
---|
| 631 | |
---|
| 632 | // get number of internal peripherals and base |
---|
| 633 | dev_nr = info->int_dev_nr; |
---|
| 634 | dev_tbl = info->int_dev; |
---|
| 635 | |
---|
| 636 | // loop on internal peripherals to get the lapic device |
---|
| 637 | for( i = 0 , found = false ; i < dev_nr ; i++ ) |
---|
| 638 | { |
---|
| 639 | func = FUNC_FROM_TYPE( dev_tbl[i].type ); |
---|
| 640 | |
---|
| 641 | if( func == DEV_FUNC_ICU ) |
---|
| 642 | { |
---|
| 643 | base = dev_tbl[i].base; |
---|
| 644 | found = true; |
---|
| 645 | break; |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | // if the LAPIC controller is not defined in the boot_info, |
---|
| 650 | // we simply don't initialize the PIC extensions in the kernel, |
---|
| 651 | // making the assumption that the LAPIC related informations |
---|
| 652 | // are hidden in the hardware specific PIC driver. |
---|
| 653 | if( found ) |
---|
| 654 | { |
---|
| 655 | // initialise the PIC extensions for |
---|
| 656 | // the core descriptor and core manager extensions |
---|
| 657 | dev_pic_extend_init( (uint32_t *)GET_PTR( base ) ); |
---|
| 658 | |
---|
| 659 | // initialize the "lapic_input" structure |
---|
| 660 | // defining how internal IRQs are connected to LAPIC |
---|
| 661 | uint32_t id; |
---|
| 662 | uint8_t valid; |
---|
| 663 | uint8_t channel; |
---|
| 664 | uint32_t func; |
---|
| 665 | |
---|
| 666 | for( id = 0 ; id < CONFIG_MAX_INTERNAL_IRQS ; id++ ) |
---|
| 667 | { |
---|
| 668 | valid = dev_tbl[i].irq[id].valid; |
---|
| 669 | func = FUNC_FROM_TYPE( dev_tbl[i].irq[id].dev_type ); |
---|
| 670 | channel = dev_tbl[i].irq[id].channel; |
---|
| 671 | |
---|
| 672 | if( valid ) // only valid local IRQs are registered |
---|
| 673 | { |
---|
| 674 | if ( func == DEV_FUNC_MMC ) lapic_input.mmc = id; |
---|
| 675 | else if( func == DEV_FUNC_DMA ) lapic_input.dma[channel] = id; |
---|
| 676 | else assert( false , __FUNCTION__ , "illegal source device for LAPIC input" ); |
---|
| 677 | } |
---|
| 678 | } |
---|
| 679 | } |
---|
| 680 | } // end lapic_init() |
---|
| 681 | |
---|
| 682 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[14] | 683 | // This static function returns the identifiers of the calling core. |
---|
| 684 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 685 | // @ info : pointer on boot_info structure. |
---|
| 686 | // @ lid : [out] core local index in cluster. |
---|
| 687 | // @ cxy : [out] cluster identifier. |
---|
| 688 | // @ lid : [out] core global identifier (hardware). |
---|
| 689 | // @ return 0 if success / return EINVAL if not found. |
---|
| 690 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[23] | 691 | static error_t get_core_identifiers( boot_info_t * info, |
---|
| 692 | lid_t * lid, |
---|
[14] | 693 | cxy_t * cxy, |
---|
| 694 | gid_t * gid ) |
---|
| 695 | { |
---|
[127] | 696 | uint32_t i; |
---|
[14] | 697 | gid_t global_id; |
---|
[19] | 698 | |
---|
[14] | 699 | // get global identifier from hardware register |
---|
[127] | 700 | global_id = hal_get_gid(); |
---|
[14] | 701 | |
---|
| 702 | // makes an associative search in boot_info to get (cxy,lid) from global_id |
---|
| 703 | for( i = 0 ; i < info->cores_nr ; i++ ) |
---|
| 704 | { |
---|
| 705 | if( global_id == info->core[i].gid ) |
---|
| 706 | { |
---|
| 707 | *lid = info->core[i].lid; |
---|
| 708 | *cxy = info->core[i].cxy; |
---|
| 709 | *gid = global_id; |
---|
| 710 | return 0; |
---|
| 711 | } |
---|
| 712 | } |
---|
| 713 | return EINVAL; |
---|
[19] | 714 | } |
---|
[14] | 715 | |
---|
| 716 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
[1] | 717 | // This function is the entry point for the kernel initialisation. |
---|
[19] | 718 | // It is executed by all cores in all clusters, but only core[0], called CP0, |
---|
[14] | 719 | // initializes the shared resources such as the cluster manager, or the local peripherals. |
---|
[19] | 720 | // To comply with the multi-kernels paradigm, it accesses only local cluster memory, using |
---|
| 721 | // only information contained in the local boot_info_t structure, set by the bootloader. |
---|
[103] | 722 | // Only CP0 in cluster 0 print the log messages. |
---|
[1] | 723 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 724 | // @ info : pointer on the local boot-info structure. |
---|
| 725 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 726 | void kernel_init( boot_info_t * info ) |
---|
| 727 | { |
---|
[204] | 728 | lid_t core_lid = -1; // running core local index |
---|
| 729 | cxy_t core_cxy = -1; // running core cluster identifier |
---|
| 730 | gid_t core_gid; // running core hardware identifier |
---|
| 731 | cluster_t * cluster; // pointer on local cluster manager |
---|
| 732 | core_t * core; // pointer on running core descriptor |
---|
| 733 | thread_t * thread; // pointer on idle thread descriptor |
---|
| 734 | |
---|
| 735 | xptr_t vfs_root_inode_xp; // extended pointer on VFS root inode |
---|
| 736 | xptr_t devfs_dev_inode_xp; // extended pointer on DEVFS dev inode |
---|
| 737 | xptr_t devfs_external_inode_xp; // extended pointer on DEVFS external inode |
---|
| 738 | xptr_t devfs_internal_inode_xp; // extended pointer on DEVFS internal inode |
---|
| 739 | |
---|
[1] | 740 | error_t error; |
---|
[285] | 741 | reg_t status; // running core status register |
---|
[1] | 742 | |
---|
[188] | 743 | cxy_t io_cxy = info->io_cxy; |
---|
| 744 | |
---|
[381] | 745 | assert( (io_cxy == ((info->x_size - 1)<<(info->y_width)) + (info->y_size - 1)) , |
---|
| 746 | __FUNCTION__ , "illegal IO cluter identifier\n" ); |
---|
| 747 | |
---|
[188] | 748 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 749 | // STEP 0 : Each core get its core identifier from boot_info, and makes |
---|
| 750 | // a partial initialisation of its private idle thread descriptor. |
---|
| 751 | // CP0 initializes the "local_cxy" global variable. |
---|
| 752 | // CP0 in cluster IO initializes the TXT0 chdev to print log messages. |
---|
| 753 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 754 | |
---|
[23] | 755 | error = get_core_identifiers( info, |
---|
[14] | 756 | &core_lid, |
---|
| 757 | &core_cxy, |
---|
| 758 | &core_gid ); |
---|
[1] | 759 | |
---|
[127] | 760 | // CP0 initializes cluster identifier |
---|
[14] | 761 | if( core_lid == 0 ) local_cxy = info->cxy; |
---|
[1] | 762 | |
---|
[127] | 763 | // each core gets a pointer on its private idle thread descriptor |
---|
| 764 | thread = (thread_t *)( idle_threads + (core_lid * CONFIG_THREAD_DESC_SIZE) ); |
---|
[68] | 765 | |
---|
[127] | 766 | // each core registers this thread pointer in hardware register |
---|
[68] | 767 | hal_set_current_thread( thread ); |
---|
[71] | 768 | |
---|
[407] | 769 | // each core register core descriptor pointer in idle thread descriptor |
---|
| 770 | thread->core = &LOCAL_CLUSTER->core_tbl[core_lid]; |
---|
| 771 | |
---|
[409] | 772 | #if CONFIG_LOCKS_DEBUG |
---|
[124] | 773 | list_root_init( &thread->locks_root ); |
---|
[188] | 774 | xlist_root_init( XPTR( local_cxy , &thread->xlocks_root ) ); |
---|
[409] | 775 | #endif |
---|
[124] | 776 | |
---|
[188] | 777 | // CP0 in I/O cluster initialises TXT0 chdev descriptor |
---|
| 778 | if( (core_lid == 0) && (core_cxy == io_cxy) ) txt0_device_init( info ); |
---|
[14] | 779 | |
---|
| 780 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 781 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
[14] | 782 | (info->x_size * info->y_size) ); |
---|
| 783 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
| 784 | |
---|
[188] | 785 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 786 | kinit_dmsg("\n[DBG] %s : exit barrier 0 : TXT0 initialized / cycle %d\n", |
---|
[296] | 787 | __FUNCTION__, hal_time_stamp() ); |
---|
[14] | 788 | |
---|
[188] | 789 | ///////////////////////////////////////////////////////////////////////////// |
---|
[407] | 790 | // STEP 1 : all cores check core identifier. |
---|
[188] | 791 | // CP0 initializes the local cluster manager. |
---|
| 792 | // This includes the memory allocators. |
---|
| 793 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 794 | |
---|
| 795 | // all cores check identifiers |
---|
[14] | 796 | if( error ) |
---|
[1] | 797 | { |
---|
[393] | 798 | panic("illegal core identifiers gid = %x / cxy = %x / lid = %d", |
---|
| 799 | core_lid , core_cxy , core_lid ); |
---|
[1] | 800 | } |
---|
| 801 | |
---|
[188] | 802 | // CP0 initializes cluster manager |
---|
[14] | 803 | if( core_lid == 0 ) |
---|
[1] | 804 | { |
---|
| 805 | error = cluster_init( info ); |
---|
| 806 | |
---|
[14] | 807 | if( error ) |
---|
| 808 | { |
---|
[393] | 809 | panic("cannot initialise cluster %x", local_cxy ); |
---|
[14] | 810 | } |
---|
| 811 | } |
---|
[5] | 812 | |
---|
[14] | 813 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 814 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
[14] | 815 | (info->x_size * info->y_size) ); |
---|
| 816 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
| 817 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[1] | 818 | |
---|
[188] | 819 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 820 | kinit_dmsg("\n[DBG] %s : exit barrier 1 : clusters initialised / cycle %d\n", |
---|
[296] | 821 | __FUNCTION__, hal_time_stamp() ); |
---|
[1] | 822 | |
---|
[188] | 823 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[407] | 824 | // STEP 2 : CP0 initializes the process_zero descriptor. |
---|
[296] | 825 | // CP0 in cluster 0 initializes the IOPIC device. |
---|
[188] | 826 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 827 | |
---|
| 828 | // all cores get pointer on local cluster manager & core descriptor |
---|
[14] | 829 | cluster = &cluster_manager; |
---|
[127] | 830 | core = &cluster->core_tbl[core_lid]; |
---|
[1] | 831 | |
---|
[188] | 832 | // all CP0s initialize the process_zero descriptor |
---|
[408] | 833 | if( core_lid == 0 ) process_zero_init( &process_zero ); |
---|
[5] | 834 | |
---|
[188] | 835 | // CP0 in cluster 0 initializes the PIC chdev, |
---|
| 836 | if( (core_lid == 0) && (local_cxy == 0) ) iopic_init( info ); |
---|
| 837 | |
---|
| 838 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 839 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
| 840 | (info->x_size * info->y_size) ); |
---|
| 841 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
| 842 | //////////////////////////////////////////////////////////////////////////////// |
---|
[127] | 843 | |
---|
[188] | 844 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 845 | kinit_dmsg("\n[DBG] %s : exit barrier 2 : PIC initialised / cycle %d\n", |
---|
[296] | 846 | __FUNCTION__, hal_time_stamp() ); |
---|
[1] | 847 | |
---|
[188] | 848 | //////////////////////////////////////////////////////////////////////////////// |
---|
[407] | 849 | // STEP 3 : CP0 initializes the distibuted LAPIC descriptor. |
---|
| 850 | // CP0 initializes the internal chdev descriptors |
---|
| 851 | // CP0 initialize the local external chdev descriptors |
---|
[188] | 852 | //////////////////////////////////////////////////////////////////////////////// |
---|
[5] | 853 | |
---|
[279] | 854 | // all CP0s initialize their local LAPIC extension, |
---|
| 855 | if( core_lid == 0 ) lapic_init( info ); |
---|
| 856 | |
---|
[188] | 857 | // CP0 scan the internal (private) peripherals, |
---|
| 858 | // and allocates memory for the corresponding chdev descriptors. |
---|
| 859 | if( core_lid == 0 ) internal_devices_init( info ); |
---|
| 860 | |
---|
[1] | 861 | |
---|
[50] | 862 | // All CP0s contribute to initialise external peripheral chdev descriptors. |
---|
[14] | 863 | // Each CP0[cxy] scan the set of external (shared) peripherals (but the TXT0), |
---|
| 864 | // and allocates memory for the chdev descriptors that must be placed |
---|
[127] | 865 | // on the (cxy) cluster according to the global index value. |
---|
[188] | 866 | |
---|
[14] | 867 | if( core_lid == 0 ) external_devices_init( info ); |
---|
[1] | 868 | |
---|
[14] | 869 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 870 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
[14] | 871 | (info->x_size * info->y_size) ); |
---|
| 872 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
| 873 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[5] | 874 | |
---|
[188] | 875 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 876 | kinit_dmsg("\n[DBG] %s : exit barrier 3 : all chdev initialised / cycle %d\n", |
---|
[296] | 877 | __FUNCTION__, hal_time_stamp()); |
---|
[1] | 878 | |
---|
[188] | 879 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[279] | 880 | // STEP 4 : All cores enable IPI (Inter Procesor Interrupt), |
---|
| 881 | // Alh cores initialize IDLE thread. |
---|
[188] | 882 | // Only CP0 in cluster 0 creates the VFS root inode. |
---|
| 883 | // It access the boot device to initialize the file system context. |
---|
| 884 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 885 | |
---|
[406] | 886 | #if CONFIG_KINIT_DEBUG |
---|
[389] | 887 | chdev_dir_display(); |
---|
| 888 | #endif |
---|
[279] | 889 | |
---|
| 890 | // All cores enable the shared IPI channel |
---|
| 891 | dev_pic_enable_ipi(); |
---|
| 892 | hal_enable_irq( &status ); |
---|
| 893 | |
---|
[296] | 894 | // all cores initialize the idle thread descriptor |
---|
[14] | 895 | error = thread_kernel_init( thread, |
---|
[127] | 896 | THREAD_IDLE, |
---|
| 897 | &thread_idle_func, |
---|
[14] | 898 | NULL, |
---|
| 899 | core_lid ); |
---|
| 900 | if( error ) |
---|
[1] | 901 | { |
---|
[393] | 902 | panic("core[%x][%d] cannot initialize idle thread", |
---|
| 903 | local_cxy , core_lid ); |
---|
[1] | 904 | } |
---|
| 905 | |
---|
[296] | 906 | // all cores unblock idle thread, and register it in scheduler |
---|
| 907 | thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL ); |
---|
[103] | 908 | core->scheduler.idle = thread; |
---|
[1] | 909 | |
---|
[406] | 910 | #if CONFIG_KINIT_DEBUG |
---|
[407] | 911 | sched_display( core_lid ); |
---|
[389] | 912 | #endif |
---|
[14] | 913 | |
---|
[188] | 914 | // CPO in cluster 0 creates the VFS root |
---|
| 915 | if( (core_lid == 0) && (local_cxy == 0 ) ) |
---|
[14] | 916 | { |
---|
[188] | 917 | vfs_root_inode_xp = XPTR_NULL; |
---|
[23] | 918 | |
---|
[188] | 919 | // File System must be FATFS in this implementation, |
---|
| 920 | // but other File System can be introduced here |
---|
[23] | 921 | if( CONFIG_VFS_ROOT_IS_FATFS ) |
---|
| 922 | { |
---|
[389] | 923 | // 1. allocate memory for FATFS context in cluster 0 |
---|
[188] | 924 | fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc(); |
---|
| 925 | |
---|
[279] | 926 | assert( (fatfs_ctx != NULL) , __FUNCTION__ , |
---|
| 927 | "cannot create FATFS context in cluster 0\n" ); |
---|
[188] | 928 | |
---|
| 929 | // 2. access boot device to initialize FATFS context |
---|
| 930 | fatfs_ctx_init( fatfs_ctx ); |
---|
| 931 | |
---|
| 932 | // 3. get various informations from FATFS context |
---|
| 933 | uint32_t root_dir_cluster = fatfs_ctx->root_dir_cluster; |
---|
| 934 | uint32_t cluster_size = fatfs_ctx->bytes_per_sector * |
---|
| 935 | fatfs_ctx->sectors_per_cluster; |
---|
| 936 | uint32_t total_clusters = fatfs_ctx->fat_sectors_count << 7; |
---|
| 937 | |
---|
| 938 | // 4. create VFS root inode in cluster 0 |
---|
| 939 | error = vfs_inode_create( XPTR_NULL, // dentry_xp |
---|
| 940 | FS_TYPE_FATFS, // fs_type |
---|
| 941 | INODE_TYPE_DIR, // inode_type |
---|
| 942 | (void *)(intptr_t)root_dir_cluster, // extend |
---|
| 943 | 0, // attr |
---|
| 944 | 0, // rights |
---|
| 945 | 0, // uid |
---|
| 946 | 0, // gid |
---|
| 947 | &vfs_root_inode_xp ); // return |
---|
| 948 | |
---|
[279] | 949 | assert( (error == 0) , __FUNCTION__ , |
---|
| 950 | "cannot create VFS root inode\n" ); |
---|
[188] | 951 | |
---|
| 952 | // 5. initialize VFS context for FAT in cluster 0 |
---|
| 953 | vfs_ctx_init( FS_TYPE_FATFS, // file system type |
---|
| 954 | 0, // attributes |
---|
| 955 | total_clusters, |
---|
| 956 | cluster_size, |
---|
| 957 | vfs_root_inode_xp, // VFS root |
---|
| 958 | fatfs_ctx ); // extend |
---|
[389] | 959 | |
---|
| 960 | // 6. check initialisation |
---|
| 961 | vfs_ctx_t * vfs_ctx = &fs_context[FS_TYPE_FATFS]; |
---|
| 962 | assert( (((fatfs_ctx_t *)vfs_ctx->extend)->sectors_per_cluster == 8), |
---|
| 963 | __FUNCTION__ , "illegal value for FATFS context in cluster %x\n", local_cxy ); |
---|
[23] | 964 | } |
---|
| 965 | else |
---|
| 966 | { |
---|
[393] | 967 | panic("root FS must be FATFS"); |
---|
[23] | 968 | } |
---|
| 969 | |
---|
[389] | 970 | // register VFS root inode in process_zero descriptor of cluster 0 |
---|
[188] | 971 | process_zero.vfs_root_xp = vfs_root_inode_xp; |
---|
| 972 | process_zero.vfs_cwd_xp = vfs_root_inode_xp; |
---|
| 973 | } |
---|
| 974 | |
---|
| 975 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 976 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
| 977 | (info->x_size * info->y_size) ); |
---|
| 978 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
| 979 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 980 | |
---|
| 981 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 982 | kinit_dmsg("\n[DBG] %s : exit barrier 4 : VFS_root = %l in cluster 0 / cycle %d\n", |
---|
[296] | 983 | __FUNCTION__, vfs_root_inode_xp , hal_time_stamp()); |
---|
[188] | 984 | |
---|
| 985 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 986 | // STEP 5 : Other CP0s allocate memory for the selected FS context, |
---|
| 987 | // and initialise both the local FS context and the local VFS context |
---|
| 988 | // from values stored in cluster 0. |
---|
| 989 | // They get the VFS root inode extended pointer from cluster 0. |
---|
| 990 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 991 | |
---|
| 992 | if( (core_lid == 0) && (local_cxy != 0) ) |
---|
| 993 | { |
---|
| 994 | // File System must be FATFS in this implementation, |
---|
| 995 | // but other File System can be introduced here |
---|
| 996 | if( CONFIG_VFS_ROOT_IS_FATFS ) |
---|
[23] | 997 | { |
---|
[389] | 998 | // 1. allocate memory for local FATFS context |
---|
| 999 | fatfs_ctx_t * local_fatfs_ctx = fatfs_ctx_alloc(); |
---|
[188] | 1000 | |
---|
[389] | 1001 | assert( (local_fatfs_ctx != NULL) , __FUNCTION__ , |
---|
| 1002 | "cannot create FATFS context in cluster %x\n", local_cxy ); |
---|
[188] | 1003 | |
---|
[389] | 1004 | // 2. get local pointer on VFS context for FATFS |
---|
[188] | 1005 | vfs_ctx_t * vfs_ctx = &fs_context[FS_TYPE_FATFS]; |
---|
| 1006 | |
---|
[389] | 1007 | // 3. get local pointer on FATFS context in cluster 0 |
---|
| 1008 | fatfs_ctx_t * remote_fatfs_ctx = hal_remote_lpt( XPTR( 0 , &vfs_ctx->extend ) ); |
---|
| 1009 | |
---|
| 1010 | // 4. copy FATFS context from cluster 0 to local cluster |
---|
| 1011 | hal_remote_memcpy( XPTR( local_cxy , local_fatfs_ctx ), |
---|
| 1012 | XPTR( 0 , remote_fatfs_ctx ), sizeof(fatfs_ctx_t) ); |
---|
| 1013 | |
---|
| 1014 | // 5. copy VFS context from cluster 0 to local cluster |
---|
[188] | 1015 | hal_remote_memcpy( XPTR( local_cxy , vfs_ctx ), |
---|
[389] | 1016 | XPTR( 0 , vfs_ctx ), sizeof(vfs_ctx_t) ); |
---|
[188] | 1017 | |
---|
[389] | 1018 | // 6. update extend field in local copy of VFS context |
---|
| 1019 | vfs_ctx->extend = local_fatfs_ctx; |
---|
[188] | 1020 | |
---|
[389] | 1021 | // 7. check initialisation |
---|
| 1022 | assert( (((fatfs_ctx_t *)vfs_ctx->extend)->sectors_per_cluster == 8), |
---|
| 1023 | __FUNCTION__ , "illegal value for FATFS context in cluster %x\n", local_cxy ); |
---|
[23] | 1024 | } |
---|
| 1025 | |
---|
[188] | 1026 | // get extended pointer on VFS root inode from cluster 0 |
---|
[296] | 1027 | vfs_root_inode_xp = hal_remote_lwd( XPTR( 0 , &process_zero.vfs_root_xp ) ); |
---|
[101] | 1028 | |
---|
[188] | 1029 | // update local process_zero descriptor |
---|
| 1030 | process_zero.vfs_root_xp = vfs_root_inode_xp; |
---|
| 1031 | process_zero.vfs_cwd_xp = vfs_root_inode_xp; |
---|
[14] | 1032 | } |
---|
| 1033 | |
---|
[188] | 1034 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1035 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
| 1036 | (info->x_size * info->y_size) ); |
---|
| 1037 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
[204] | 1038 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[101] | 1039 | |
---|
[381] | 1040 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 1041 | kinit_dmsg("\n[DBG] %s : exit barrier 5 : VFS_root = %l in cluster IO / cycle %d\n", |
---|
[296] | 1042 | __FUNCTION__, vfs_root_inode_xp , hal_time_stamp() ); |
---|
[188] | 1043 | |
---|
| 1044 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1045 | // STEP 6 : CP0 in cluster IO makes the global DEVFS tree initialisation: |
---|
[204] | 1046 | // It creates the DEVFS directory "dev", and the DEVFS "external" |
---|
| 1047 | // directory in cluster IO and mount these inodes into VFS. |
---|
[188] | 1048 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1049 | |
---|
| 1050 | if( (core_lid == 0) && (local_cxy == io_cxy) ) |
---|
[1] | 1051 | { |
---|
[188] | 1052 | // create "dev" and "external" directories. |
---|
| 1053 | devfs_global_init( process_zero.vfs_root_xp, |
---|
[204] | 1054 | &devfs_dev_inode_xp, |
---|
[188] | 1055 | &devfs_external_inode_xp ); |
---|
| 1056 | |
---|
| 1057 | // creates the DEVFS context in cluster IO |
---|
| 1058 | devfs_ctx_t * devfs_ctx = devfs_ctx_alloc(); |
---|
| 1059 | |
---|
[279] | 1060 | assert( (devfs_ctx != NULL) , __FUNCTION__ , |
---|
| 1061 | "cannot create DEVFS context in cluster IO\n"); |
---|
[188] | 1062 | |
---|
| 1063 | // register DEVFS root and external directories |
---|
[204] | 1064 | devfs_ctx_init( devfs_ctx, devfs_dev_inode_xp, devfs_external_inode_xp ); |
---|
[188] | 1065 | } |
---|
| 1066 | |
---|
| 1067 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1068 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
| 1069 | (info->x_size * info->y_size) ); |
---|
| 1070 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
[204] | 1071 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 1072 | |
---|
[381] | 1073 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 1074 | kinit_dmsg("\n[DBG] %s : exit barrier 6 : dev_root = %l in cluster IO / cycle %d\n", |
---|
[296] | 1075 | __FUNCTION__, devfs_dev_inode_xp , hal_time_stamp() ); |
---|
[188] | 1076 | |
---|
| 1077 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1078 | // STEP 7 : All CP0s complete in parallel the DEVFS tree initialization. |
---|
| 1079 | // Each CP0 get the "dev" and "external" extended pointers from |
---|
[204] | 1080 | // values stored in cluster IO. |
---|
[337] | 1081 | // Then each CP0 in cluster(i) creates the DEVFS "internal directory, |
---|
[204] | 1082 | // and creates the pseudo-files for all chdevs in cluster (i). |
---|
[188] | 1083 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1084 | |
---|
| 1085 | if( core_lid == 0 ) |
---|
| 1086 | { |
---|
| 1087 | // get extended pointer on "extend" field of VFS context for DEVFS in cluster IO |
---|
| 1088 | xptr_t extend_xp = XPTR( io_cxy , &fs_context[FS_TYPE_DEVFS].extend ); |
---|
| 1089 | |
---|
| 1090 | // get pointer on DEVFS context in cluster IO |
---|
| 1091 | devfs_ctx_t * devfs_ctx = hal_remote_lpt( extend_xp ); |
---|
| 1092 | |
---|
[204] | 1093 | devfs_dev_inode_xp = hal_remote_lwd( XPTR( io_cxy , |
---|
| 1094 | &devfs_ctx->dev_inode_xp ) ); |
---|
| 1095 | devfs_external_inode_xp = hal_remote_lwd( XPTR( io_cxy , |
---|
| 1096 | &devfs_ctx->external_inode_xp ) ); |
---|
[188] | 1097 | |
---|
[204] | 1098 | // populate DEVFS in all clusters |
---|
| 1099 | devfs_local_init( devfs_dev_inode_xp, |
---|
| 1100 | devfs_external_inode_xp, |
---|
| 1101 | &devfs_internal_inode_xp ); |
---|
[188] | 1102 | } |
---|
| 1103 | |
---|
| 1104 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1105 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
| 1106 | (info->x_size * info->y_size) ); |
---|
| 1107 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
[204] | 1108 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 1109 | |
---|
| 1110 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 1111 | kinit_dmsg("\n[DBG] %s : exit barrier 7 : dev_root = %l in cluster 0 / cycle %d\n", |
---|
[296] | 1112 | __FUNCTION__, devfs_dev_inode_xp , hal_time_stamp() ); |
---|
[188] | 1113 | |
---|
| 1114 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[204] | 1115 | // STEP 8 : CP0 in I/O cluster creates the first user process (process_init) |
---|
[188] | 1116 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1117 | |
---|
| 1118 | if( (core_lid == 0) && (local_cxy == io_cxy) ) |
---|
| 1119 | { |
---|
[101] | 1120 | process_init_create(); |
---|
[188] | 1121 | } |
---|
[101] | 1122 | |
---|
[188] | 1123 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[381] | 1124 | if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), |
---|
[188] | 1125 | (info->x_size * info->y_size) ); |
---|
| 1126 | barrier_wait( &local_barrier , info->cores_nr ); |
---|
[204] | 1127 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[188] | 1128 | |
---|
[407] | 1129 | #if CONFIG_KINIT_DEBUG |
---|
| 1130 | sched_display( core_lid ); |
---|
| 1131 | #endif |
---|
| 1132 | |
---|
[188] | 1133 | if( (core_lid == 0) && (local_cxy == 0) ) |
---|
[407] | 1134 | kinit_dmsg("\n[DBG] %s : exit barrier 8 : process init created / cycle %d\n", |
---|
[296] | 1135 | __FUNCTION__ , hal_time_stamp() ); |
---|
[188] | 1136 | |
---|
| 1137 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1138 | // STEP 9 : CP0 in cluster 0 print banner |
---|
| 1139 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 1140 | |
---|
| 1141 | if( (core_lid == 0) && (local_cxy == io_cxy) ) |
---|
| 1142 | { |
---|
[5] | 1143 | print_banner( (info->x_size * info->y_size) , info->cores_nr ); |
---|
[68] | 1144 | |
---|
[406] | 1145 | #if CONFIG_KINIT_DEBUG |
---|
| 1146 | |
---|
[401] | 1147 | vfs_display( vfs_root_inode_xp ); |
---|
[406] | 1148 | |
---|
| 1149 | printk("\n\n***** memory fooprint for main kernel objects\n\n" |
---|
[68] | 1150 | " - thread descriptor : %d bytes\n" |
---|
| 1151 | " - process descriptor : %d bytes\n" |
---|
| 1152 | " - cluster manager : %d bytes\n" |
---|
| 1153 | " - chdev descriptor : %d bytes\n" |
---|
| 1154 | " - core descriptor : %d bytes\n" |
---|
| 1155 | " - scheduler : %d bytes\n" |
---|
| 1156 | " - rpc fifo : %d bytes\n" |
---|
| 1157 | " - page descriptor : %d bytes\n" |
---|
| 1158 | " - mapper root : %d bytes\n" |
---|
| 1159 | " - ppm manager : %d bytes\n" |
---|
| 1160 | " - kcm manager : %d bytes\n" |
---|
| 1161 | " - khm manager : %d bytes\n" |
---|
| 1162 | " - vmm manager : %d bytes\n" |
---|
| 1163 | " - gpt root : %d bytes\n" |
---|
| 1164 | " - list item : %d bytes\n" |
---|
| 1165 | " - xlist item : %d bytes\n" |
---|
| 1166 | " - spinlock : %d bytes\n" |
---|
| 1167 | " - remote spinlock : %d bytes\n" |
---|
| 1168 | " - rwlock : %d bytes\n" |
---|
| 1169 | " - remote rwlock : %d bytes\n", |
---|
[127] | 1170 | sizeof( thread_t ), |
---|
[68] | 1171 | sizeof( process_t ), |
---|
| 1172 | sizeof( cluster_t ), |
---|
| 1173 | sizeof( chdev_t ), |
---|
| 1174 | sizeof( core_t ), |
---|
| 1175 | sizeof( scheduler_t ), |
---|
[407] | 1176 | sizeof( remote_fifo_t ), |
---|
[68] | 1177 | sizeof( page_t ), |
---|
| 1178 | sizeof( mapper_t ), |
---|
| 1179 | sizeof( ppm_t ), |
---|
| 1180 | sizeof( kcm_t ), |
---|
| 1181 | sizeof( khm_t ), |
---|
| 1182 | sizeof( vmm_t ), |
---|
| 1183 | sizeof( gpt_t ), |
---|
| 1184 | sizeof( list_entry_t ), |
---|
| 1185 | sizeof( xlist_entry_t ), |
---|
| 1186 | sizeof( spinlock_t ), |
---|
| 1187 | sizeof( remote_spinlock_t ), |
---|
| 1188 | sizeof( rwlock_t ), |
---|
| 1189 | sizeof( remote_rwlock_t )); |
---|
[406] | 1190 | #endif |
---|
| 1191 | |
---|
[1] | 1192 | } |
---|
| 1193 | |
---|
[398] | 1194 | // each core activates its private TICK IRQ |
---|
| 1195 | dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD ); |
---|
[14] | 1196 | |
---|
[407] | 1197 | // each core jump to thread_idle_func |
---|
[50] | 1198 | thread_idle_func(); |
---|
[127] | 1199 | } |
---|
[14] | 1200 | |
---|