source: trunk/kernel/kern/kernel_init.c @ 659

Last change on this file since 659 was 657, checked in by alain, 5 years ago

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File size: 65.3 KB
RevLine 
[1]1/*
2 * kernel_init.c - kernel parallel initialization
[127]3 *
[23]4 * Authors :  Mohamed Lamine Karaoui (2015)
[657]5 *            Alain Greiner  (2016,2017,2018,2019,2020)
[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>
[457]27#include <hal_kernel_types.h>
[1]28#include <hal_special.h>
29#include <hal_context.h>
[279]30#include <hal_irqmask.h>
[564]31#include <hal_macros.h>
[296]32#include <hal_ppm.h>
[14]33#include <barrier.h>
[564]34#include <xbarrier.h>
[407]35#include <remote_fifo.h>
[1]36#include <core.h>
37#include <list.h>
[68]38#include <xlist.h>
[204]39#include <xhtab.h>
[1]40#include <thread.h>
41#include <scheduler.h>
42#include <kmem.h>
43#include <cluster.h>
44#include <string.h>
45#include <memcpy.h>
46#include <ppm.h>
47#include <page.h>
[5]48#include <chdev.h>
[1]49#include <boot_info.h>
50#include <dqdt.h>
51#include <dev_mmc.h>
[5]52#include <dev_dma.h>
53#include <dev_iob.h>
[1]54#include <dev_ioc.h>
[5]55#include <dev_txt.h>
[1]56#include <dev_pic.h>
57#include <printk.h>
58#include <vfs.h>
[23]59#include <devfs.h>
[68]60#include <mapper.h>
[1]61
62///////////////////////////////////////////////////////////////////////////////////////////
[279]63// All the following global variables are replicated in all clusters.
[1]64// They are initialised by the kernel_init() function.
[14]65//
[127]66// WARNING : The section names have been defined to control the base addresses of the
[14]67// boot_info structure and the idle thread descriptors, through the kernel.ld script:
[127]68// - the boot_info structure is built by the bootloader, and used by kernel_init.
69//   it must be the first object in the kdata segment.
[14]70// - the array of idle threads descriptors must be placed on the first page boundary after
71//   the boot_info structure in the kdata segment.
[1]72///////////////////////////////////////////////////////////////////////////////////////////
73
[5]74// This variable defines the local boot_info structure
75__attribute__((section(".kinfo")))
[14]76boot_info_t          boot_info;
[5]77
[14]78// This variable defines the "idle" threads descriptors array
79__attribute__((section(".kidle")))
[381]80char                 idle_threads[CONFIG_THREAD_DESC_SIZE *
[14]81                                   CONFIG_MAX_LOCAL_CORES]   CONFIG_PPM_PAGE_ALIGNED;
82
[127]83// This variable defines the local cluster manager
[5]84__attribute__((section(".kdata")))
[19]85cluster_t            cluster_manager                         CONFIG_CACHE_LINE_ALIGNED;
[1]86
[564]87// This variable defines the TXT_TX[0] chdev
[188]88__attribute__((section(".kdata")))
[564]89chdev_t              txt0_tx_chdev                           CONFIG_CACHE_LINE_ALIGNED;
[188]90
[564]91// This variable defines the TXT_RX[0] chdev
[539]92__attribute__((section(".kdata")))
[564]93chdev_t              txt0_rx_chdev                           CONFIG_CACHE_LINE_ALIGNED;
[539]94
[14]95// This variables define the kernel process0 descriptor
[5]96__attribute__((section(".kdata")))
[19]97process_t            process_zero                            CONFIG_CACHE_LINE_ALIGNED;
[1]98
[624]99// This variable defines a set of extended pointers on the distributed chdevs
[5]100__attribute__((section(".kdata")))
[14]101chdev_directory_t    chdev_dir                               CONFIG_CACHE_LINE_ALIGNED;
[1]102
[188]103// This variable contains the input IRQ indexes for the IOPIC controller
[5]104__attribute__((section(".kdata")))
[246]105iopic_input_t        iopic_input                             CONFIG_CACHE_LINE_ALIGNED;
[1]106
[188]107// This variable contains the input IRQ indexes for the LAPIC controller
[5]108__attribute__((section(".kdata")))
[188]109lapic_input_t        lapic_input                             CONFIG_CACHE_LINE_ALIGNED;
[1]110
[14]111// This variable defines the local cluster identifier
[5]112__attribute__((section(".kdata")))
[14]113cxy_t                local_cxy                               CONFIG_CACHE_LINE_ALIGNED;
[5]114
[623]115// This variable is used for core[0] cores synchronisation in kernel_init()
[5]116__attribute__((section(".kdata")))
[564]117xbarrier_t           global_barrier                          CONFIG_CACHE_LINE_ALIGNED;
[1]118
[127]119// This variable is used for local cores synchronisation in kernel_init()
[14]120__attribute__((section(".kdata")))
121barrier_t            local_barrier                           CONFIG_CACHE_LINE_ALIGNED;
122
[127]123// This variable defines the array of supported File System contexts
[50]124__attribute__((section(".kdata")))
125vfs_ctx_t            fs_context[FS_TYPES_NR]                 CONFIG_CACHE_LINE_ALIGNED;
126
[564]127// This array is used for debug, and describes the kernel locks usage,
128// It must be kept consistent with the defines in kernel_config.h file.
[624]129__attribute__((section(".kdata")))
[564]130char * lock_type_str[] =
131{
132    "unused_0",              //  0
[408]133
[564]134    "CLUSTER_KCM",           //  1
[632]135    "SCHED_STATE",           //  2
136    "VMM_STACK",             //  3
137    "VMM_MMAP",              //  4
[657]138    "KCM_STATE",             //  5
139    "KHM_STATE",             //  6
140    "HTAB_STATE",            //  7
[564]141
[657]142    "VFS_CTX",               //  8
[632]143    "PPM_FREE",              //  9
[564]144    "THREAD_JOIN",           // 10
[610]145    "XHTAB_STATE",           // 11
[564]146    "CHDEV_QUEUE",           // 12
147    "CHDEV_TXT0",            // 13
148    "CHDEV_TXTLIST",         // 14
149    "PAGE_STATE",            // 15
150    "MUTEX_STATE",           // 16
151    "CONDVAR_STATE",         // 17
152    "SEM_STATE",             // 18
[619]153    "PROCESS_CWD",           // 19
154    "BARRIER_STATE",         // 20
[564]155
156    "CLUSTER_PREFTBL",       // 21
[601]157
[564]158    "PPM_DIRTY",             // 22
159    "CLUSTER_LOCALS",        // 23
160    "CLUSTER_COPIES",        // 24
161    "PROCESS_CHILDREN",      // 25
162    "PROCESS_USERSYNC",      // 26
163    "PROCESS_FDARRAY",       // 27
[628]164    "PROCESS_DIR",           // 28
[640]165    "VMM_VSL",               // 29
[564]166
[611]167    "PROCESS_THTBL",         // 30
[564]168
[611]169    "MAPPER_STATE",          // 31
170    "VFS_SIZE",              // 32
171    "VFS_FILE",              // 33
[640]172    "VFS_MAIN",              // 34
173    "FATFS_FAT",             // 35
[657]174    "FBF_WINDOWS",           // 36
[564]175};       
176
[601]177// debug variables to analyse the sys_read() and sys_write() syscalls timing
[564]178
[438]179#if DEBUG_SYS_READ
[407]180uint32_t   enter_sys_read;
181uint32_t   exit_sys_read;
182
[435]183uint32_t   enter_devfs_read;
184uint32_t   exit_devfs_read;
[407]185
186uint32_t   enter_txt_read;
187uint32_t   exit_txt_read;
188
[435]189uint32_t   enter_chdev_cmd_read;
190uint32_t   exit_chdev_cmd_read;
[407]191
[435]192uint32_t   enter_chdev_server_read;
193uint32_t   exit_chdev_server_read;
[407]194
[435]195uint32_t   enter_tty_cmd_read;
196uint32_t   exit_tty_cmd_read;
[407]197
[435]198uint32_t   enter_tty_isr_read;
199uint32_t   exit_tty_isr_read;
[407]200#endif
201
[435]202// these debug variables are used to analyse the sys_write() syscall timing
203
[438]204#if DEBUG_SYS_WRITE   
[435]205uint32_t   enter_sys_write;
206uint32_t   exit_sys_write;
207
208uint32_t   enter_devfs_write;
209uint32_t   exit_devfs_write;
210
211uint32_t   enter_txt_write;
212uint32_t   exit_txt_write;
213
214uint32_t   enter_chdev_cmd_write;
215uint32_t   exit_chdev_cmd_write;
216
217uint32_t   enter_chdev_server_write;
218uint32_t   exit_chdev_server_write;
219
220uint32_t   enter_tty_cmd_write;
221uint32_t   exit_tty_cmd_write;
222
223uint32_t   enter_tty_isr_write;
224uint32_t   exit_tty_isr_write;
225#endif
226
[564]227// intrumentation variables : cumulated costs per syscall type in cluster
[624]228
229#if CONFIG_INSTRUMENTATION_SYSCALLS
230__attribute__((section(".kdata")))
[564]231uint32_t   syscalls_cumul_cost[SYSCALLS_NR];
232
[624]233__attribute__((section(".kdata")))
[564]234uint32_t   syscalls_occurences[SYSCALLS_NR];
[624]235#endif
[564]236
[1]237///////////////////////////////////////////////////////////////////////////////////////////
[5]238// This function displays the ALMOS_MKH banner.
[1]239///////////////////////////////////////////////////////////////////////////////////////////
[5]240static void print_banner( uint32_t nclusters , uint32_t ncores )
[127]241{
[5]242    printk("\n"
243           "                    _        __    __     _____     ______         __    __    _   __   _     _   \n"
244           "          /\\       | |      |  \\  /  |   / ___ \\   / _____|       |  \\  /  |  | | / /  | |   | |  \n"
245           "         /  \\      | |      |   \\/   |  | /   \\ | | /             |   \\/   |  | |/ /   | |   | |  \n"
246           "        / /\\ \\     | |      | |\\  /| |  | |   | | | |_____   ___  | |\\  /| |  |   /    | |___| |  \n"
247           "       / /__\\ \\    | |      | | \\/ | |  | |   | | \\_____  \\ |___| | | \\/ | |  |   \\    |  ___  |  \n"
248           "      / ______ \\   | |      | |    | |  | |   | |       | |       | |    | |  | |\\ \\   | |   | |  \n"
249           "     / /      \\ \\  | |____  | |    | |  | \\___/ |  _____/ |       | |    | |  | | \\ \\  | |   | |  \n"
250           "    /_/        \\_\\ |______| |_|    |_|   \\_____/  |______/        |_|    |_|  |_|  \\_\\ |_|   |_|  \n"
251           "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n"
[457]252           "\n\n\t\t %s / %d cluster(s) / %d core(s) per cluster\n\n",
[635]253           CONFIG_VERSION , nclusters , ncores );
[5]254}
[1]255
256
[5]257///////////////////////////////////////////////////////////////////////////////////////////
[564]258// This function initializes the TXT_TX[0] and TXT_RX[0] chdev descriptors, implementing
259// the "kernel terminal", shared by all kernel instances for debug messages.
260// These chdev are implemented as global variables (replicated in all clusters),
261// because this terminal is used before the kmem allocator initialisation, but only
262// the chdevs in cluster 0 are registered in the "chdev_dir" directory.
[127]263// As this TXT0 chdev supports only the TXT_SYNC_WRITE command, we don't create
264// a server thread, we don't allocate a WTI, and we don't initialize the waiting queue.
[564]265// Note: The TXT_RX[0] chdev is created, but is not used by ALMOS-MKH (september 2018).
[5]266///////////////////////////////////////////////////////////////////////////////////////////
267// @ info    : pointer on the local boot-info structure.
268///////////////////////////////////////////////////////////////////////////////////////////
[564]269static void __attribute__ ((noinline)) txt0_device_init( boot_info_t * info )
[5]270{
271    boot_device_t * dev_tbl;         // pointer on array of devices in boot_info
[127]272    uint32_t        dev_nr;          // actual number of devices in this cluster
273    xptr_t          base;            // remote pointer on segment base
274    uint32_t        func;            // device functional index
[5]275    uint32_t        impl;            // device implementation index
[127]276    uint32_t        i;               // device index in dev_tbl
277    uint32_t        x;               // X cluster coordinate
278    uint32_t        y;               // Y cluster coordinate
[1]279
[5]280    // get number of peripherals and base of devices array from boot_info
[127]281    dev_nr      = info->ext_dev_nr;
[5]282    dev_tbl     = info->ext_dev;
[1]283
[14]284    // loop on external peripherals to find TXT device
[127]285    for( i = 0 ; i < dev_nr ; i++ )
286    {
[5]287        base        = dev_tbl[i].base;
[188]288        func        = FUNC_FROM_TYPE( dev_tbl[i].type );
289        impl        = IMPL_FROM_TYPE( dev_tbl[i].type );
[5]290
[127]291        if (func == DEV_FUNC_TXT )
[5]292        {
[564]293            // initialize TXT_TX[0] chdev
294            txt0_tx_chdev.func    = func;
295            txt0_tx_chdev.impl    = impl;
296            txt0_tx_chdev.channel = 0;
297            txt0_tx_chdev.base    = base;
298            txt0_tx_chdev.is_rx   = false;
299            remote_busylock_init( XPTR( local_cxy , &txt0_tx_chdev.wait_lock ),
300                                  LOCK_CHDEV_TXT0 );
[188]301           
[564]302            // initialize TXT_RX[0] chdev
303            txt0_rx_chdev.func    = func;
304            txt0_rx_chdev.impl    = impl;
305            txt0_rx_chdev.channel = 0;
306            txt0_rx_chdev.base    = base;
307            txt0_rx_chdev.is_rx   = true;
308            remote_busylock_init( XPTR( local_cxy , &txt0_rx_chdev.wait_lock ),
309                                  LOCK_CHDEV_TXT0 );
310           
311            // make TXT specific initialisations
312            dev_txt_init( &txt0_tx_chdev );                 
313            dev_txt_init( &txt0_rx_chdev );
[14]314
[564]315            // register TXT_TX[0] & TXT_RX[0] in chdev_dir[x][y]
316            // for all valid clusters             
[5]317            for( x = 0 ; x < info->x_size ; x++ )
318            {
[564]319                for( y = 0 ; y < info->y_size ; y++ )
[5]320                {
[564]321                    cxy_t cxy = HAL_CXY_FROM_XY( x , y );
322
323                    if( cluster_is_active( cxy ) )
324                    {
325                        hal_remote_s64( XPTR( cxy , &chdev_dir.txt_tx[0] ) ,
326                                        XPTR( local_cxy , &txt0_tx_chdev ) );
327                        hal_remote_s64( XPTR( cxy , &chdev_dir.txt_rx[0] ) ,
328                                        XPTR( local_cxy , &txt0_rx_chdev ) );
[559]329                    }
[5]330                }
331            }
[564]332
333            hal_fence();
[5]334        }
[188]335        } // end loop on devices
336}  // end txt0_device_init()
[5]337
[1]338///////////////////////////////////////////////////////////////////////////////////////////
[188]339// This function allocates memory and initializes the chdev descriptors for the internal
340// peripherals contained in the local cluster, other than the LAPIC, as specified by
341// the boot_info, including the linking with the driver for the specified implementation.
342// The relevant entries in all copies of the devices directory are initialised.
[1]343///////////////////////////////////////////////////////////////////////////////////////////
344// @ info    : pointer on the local boot-info structure.
345///////////////////////////////////////////////////////////////////////////////////////////
[564]346static void __attribute__ ((noinline)) internal_devices_init( boot_info_t * info )
[1]347{
[188]348    boot_device_t * dev_tbl;         // pointer on array of internaldevices in boot_info
349        uint32_t        dev_nr;          // actual number of devices in this cluster
350        xptr_t          base;            // remote pointer on segment base
351    uint32_t        func;            // device functionnal index
352    uint32_t        impl;            // device implementation index
353        uint32_t        i;               // device index in dev_tbl
354        uint32_t        x;               // X cluster coordinate
355        uint32_t        y;               // Y cluster coordinate
356        uint32_t        channels;        // number of channels
357        uint32_t        channel;         // channel index
358        chdev_t       * chdev_ptr;       // local pointer on created chdev
[1]359
[188]360    // get number of internal peripherals and base from boot_info
361        dev_nr  = info->int_dev_nr;
362    dev_tbl = info->int_dev;
[1]363
[188]364    // loop on internal peripherals
365        for( i = 0 ; i < dev_nr ; i++ )
366        {
367        base        = dev_tbl[i].base;
368        channels    = dev_tbl[i].channels;
369        func        = FUNC_FROM_TYPE( dev_tbl[i].type );
370        impl        = IMPL_FROM_TYPE( dev_tbl[i].type );
[204]371 
[188]372        //////////////////////////
373        if( func == DEV_FUNC_MMC ) 
[5]374        {
[1]375
[564]376            // check channels
377            if( channels != 1 )
[580]378            {
379                printk("\n[PANIC] in %s : MMC device must be single channel\n",
380                __FUNCTION__ );
381                hal_core_sleep();
382            }
[564]383
[188]384            // create chdev in local cluster
385            chdev_ptr = chdev_create( func,
386                                      impl,
387                                      0,          // channel
388                                      false,      // direction
389                                      base );
[14]390
[564]391            // check memory
392            if( chdev_ptr == NULL )
[580]393            {
394                printk("\n[PANIC] in %s : cannot create MMC chdev\n",
395                __FUNCTION__ );
396                hal_core_sleep();
397            }
[188]398           
399            // make MMC specific initialisation
400            dev_mmc_init( chdev_ptr );
[1]401
[188]402            // set the MMC field in all chdev_dir[x][y] structures
403            for( x = 0 ; x < info->x_size ; x++ )
[1]404            {
[564]405                for( y = 0 ; y < info->y_size ; y++ )
[188]406                {
[564]407                    cxy_t cxy = HAL_CXY_FROM_XY( x , y );
408
409                    if( cluster_is_active( cxy ) )
410                    {
411                        hal_remote_s64( XPTR( cxy , &chdev_dir.mmc[local_cxy] ), 
[559]412                                        XPTR( local_cxy , chdev_ptr ) );
413                    }
[188]414                }
[1]415            }
[188]416
[438]417#if( DEBUG_KERNEL_INIT & 0x1 )
418if( hal_time_stamp() > DEBUG_KERNEL_INIT )
[601]419printk("\n[%s] : created MMC in cluster %x / chdev = %x\n",
[407]420__FUNCTION__ , local_cxy , chdev_ptr );
[389]421#endif
[14]422        }
[188]423        ///////////////////////////////
424        else if( func == DEV_FUNC_DMA )
[127]425        {
[188]426            // create one chdev per channel in local cluster
427            for( channel = 0 ; channel < channels ; channel++ )
428            {   
429                // create chdev[channel] in local cluster
430                chdev_ptr = chdev_create( func,
431                                          impl,
432                                          channel,
433                                          false,     // direction
434                                          base );
[5]435
[564]436                // check memory
437                if( chdev_ptr == NULL )
[580]438                {
439                    printk("\n[PANIC] in %s : cannot create DMA chdev\n",
440                    __FUNCTION__ );
441                    hal_core_sleep();
442                }
[564]443           
[188]444                // make DMA specific initialisation
445                dev_dma_init( chdev_ptr );     
[127]446
[188]447                // initialize only the DMA[channel] field in the local chdev_dir[x][y]
448                // structure because the DMA device is not remotely accessible.
449                chdev_dir.dma[channel] = XPTR( local_cxy , chdev_ptr );
[5]450
[438]451#if( DEBUG_KERNEL_INIT & 0x1 )
452if( hal_time_stamp() > DEBUG_KERNEL_INIT )
[601]453printk("\n[%s] : created DMA[%d] in cluster %x / chdev = %x\n",
[389]454__FUNCTION__ , channel , local_cxy , chdev_ptr );
455#endif
[188]456            }
[14]457        }
[127]458    }
[5]459}  // end internal_devices_init()
460
461///////////////////////////////////////////////////////////////////////////////////////////
[188]462// This function allocates memory and initializes the chdev descriptors for the 
[408]463// external (shared) peripherals other than the IOPIC, as specified by the boot_info.
464// This includes the dynamic linking with the driver for the specified implementation.
[188]465// These chdev descriptors are distributed on all clusters, using a modulo on a global
[408]466// index, identically computed in all clusters.
[623]467// This function is executed in all clusters by the core[0] core, that computes a global index
468// for all external chdevs. Each core[0] core creates only the chdevs that must be placed in
[408]469// the local cluster, because the global index matches the local index.
[188]470// The relevant entries in all copies of the devices directory are initialised.
[5]471///////////////////////////////////////////////////////////////////////////////////////////
472// @ info    : pointer on the local boot-info structure.
473///////////////////////////////////////////////////////////////////////////////////////////
474static void external_devices_init( boot_info_t * info )
475{
[188]476    boot_device_t * dev_tbl;         // pointer on array of external devices in boot_info
477        uint32_t        dev_nr;          // actual number of external devices
478        xptr_t          base;            // remote pointer on segment base
[5]479    uint32_t        func;            // device functionnal index
480    uint32_t        impl;            // device implementation index
[188]481        uint32_t        i;               // device index in dev_tbl
482        uint32_t        x;               // X cluster coordinate
483        uint32_t        y;               // Y cluster coordinate
484        uint32_t        channels;        // number of channels
485        uint32_t        channel;         // channel index
486        uint32_t        directions;      // number of directions (1 or 2)
487        uint32_t        rx;              // direction index (0 or 1)
[127]488    chdev_t       * chdev;           // local pointer on one channel_device descriptor
[188]489    uint32_t        ext_chdev_gid;   // global index of external chdev
[5]490
491    // get number of peripherals and base of devices array from boot_info
[127]492    dev_nr      = info->ext_dev_nr;
[5]493    dev_tbl     = info->ext_dev;
494
[188]495    // initializes global index (PIC is already placed in cluster 0
496    ext_chdev_gid = 1;
497
[5]498    // loop on external peripherals
[127]499    for( i = 0 ; i < dev_nr ; i++ )
500    {
[188]501        base     = dev_tbl[i].base;
502        channels = dev_tbl[i].channels;
503        func     = FUNC_FROM_TYPE( dev_tbl[i].type );
504        impl     = IMPL_FROM_TYPE( dev_tbl[i].type );
[5]505
[407]506        // There is one chdev per direction for NIC and for TXT
507        if((func == DEV_FUNC_NIC) || (func == DEV_FUNC_TXT)) directions = 2;
508        else                                                 directions = 1;
[5]509
[407]510        // do nothing for ROM, that does not require a device descriptor.
[5]511        if( func == DEV_FUNC_ROM ) continue;
512
[188]513        // do nothing for PIC, that is already initialized
514        if( func == DEV_FUNC_PIC ) continue;
[5]515
[188]516        // check PIC device initialized
[564]517        if( chdev_dir.pic == XPTR_NULL )
[580]518        {
519            printk("\n[PANIC] in %s : PIC device must be initialized first\n",
520            __FUNCTION__ );
521            hal_core_sleep();
522        }
[188]523
524        // check external device functionnal type
[564]525        if( (func != DEV_FUNC_IOB) && (func != DEV_FUNC_IOC) && (func != DEV_FUNC_TXT) &&
526            (func != DEV_FUNC_NIC) && (func != DEV_FUNC_FBF) )
[580]527        {
528            printk("\n[PANIC] in %s : undefined peripheral type\n",
529            __FUNCTION__ );
530            hal_core_sleep();
531        }
[188]532
[127]533        // loops on channels
[428]534        for( channel = 0 ; channel < channels ; channel++ )
[127]535        {
[5]536            // loop on directions
[188]537            for( rx = 0 ; rx < directions ; rx++ )
[1]538            {
[564]539                // skip TXT0 that has already been initialized
540                if( (func == DEV_FUNC_TXT) && (channel == 0) ) continue;
[428]541
[564]542                // all kernel instances compute the target cluster for all chdevs,
543                // computing the global index ext_chdev_gid[func,channel,direction]
544                cxy_t target_cxy;
545                while( 1 )
[536]546                {
[564]547                    uint32_t offset     = ext_chdev_gid % ( info->x_size * info->y_size );
548                    uint32_t x          = offset / info->y_size;
549                    uint32_t y          = offset % info->y_size;
[536]550
[564]551                    target_cxy = HAL_CXY_FROM_XY( x , y );
552
553                    // exit loop if target cluster is active
554                    if( cluster_is_active( target_cxy ) ) break;
555               
556                    // increment global index otherwise
557                    ext_chdev_gid++;
[550]558                }
559
[5]560                // allocate and initialize a local chdev
[407]561                // when local cluster matches target cluster
[5]562                if( target_cxy == local_cxy )
[1]563                {
[647]564
565#if( DEBUG_KERNEL_INIT & 0x3 )
566if( hal_time_stamp() > DEBUG_KERNEL_INIT )
567printk("\n[%s] : found chdev %s / channel = %d / rx = %d / cluster %x\n",
568__FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy );
569#endif
[5]570                    chdev = chdev_create( func,
571                                          impl,
572                                          channel,
[188]573                                          rx,          // direction
[5]574                                          base );
575
[564]576                    if( chdev == NULL )
[580]577                    {
578                        printk("\n[PANIC] in %s : cannot allocate chdev\n",
579                        __FUNCTION__ );
580                        hal_core_sleep();
581                    }
[5]582
583                    // make device type specific initialisation
584                    if     ( func == DEV_FUNC_IOB ) dev_iob_init( chdev );
585                    else if( func == DEV_FUNC_IOC ) dev_ioc_init( chdev );
586                    else if( func == DEV_FUNC_TXT ) dev_txt_init( chdev );
587                    else if( func == DEV_FUNC_NIC ) dev_nic_init( chdev );
[188]588                    else if( func == DEV_FUNC_FBF ) dev_fbf_init( chdev );
[5]589
[127]590                    // all external (shared) devices are remotely accessible
[5]591                    // initialize the replicated chdev_dir[x][y] structures
[127]592                    // defining the extended pointers on chdev descriptors
[633]593                    xptr_t * entry = NULL;
[127]594
[188]595                    if(func==DEV_FUNC_IOB             ) entry  = &chdev_dir.iob;
596                    if(func==DEV_FUNC_IOC             ) entry  = &chdev_dir.ioc[channel];
597                    if(func==DEV_FUNC_FBF             ) entry  = &chdev_dir.fbf[channel];
[407]598                    if((func==DEV_FUNC_TXT) && (rx==0)) entry  = &chdev_dir.txt_tx[channel];
599                    if((func==DEV_FUNC_TXT) && (rx==1)) entry  = &chdev_dir.txt_rx[channel];
[188]600                    if((func==DEV_FUNC_NIC) && (rx==0)) entry  = &chdev_dir.nic_tx[channel];
601                    if((func==DEV_FUNC_NIC) && (rx==1)) entry  = &chdev_dir.nic_rx[channel];
[127]602
[1]603                    for( x = 0 ; x < info->x_size ; x++ )
604                    {
[564]605                        for( y = 0 ; y < info->y_size ; y++ )
[1]606                        {
[564]607                            cxy_t cxy = HAL_CXY_FROM_XY( x , y );
608
[633]609                            if( cluster_is_active( cxy ) && ( entry != NULL ) )
[564]610                            {
611                                hal_remote_s64( XPTR( cxy , entry ),
[559]612                                                XPTR( local_cxy , chdev ) );
613                            }
[5]614                        }
[1]615                    }
616
[647]617#if( DEBUG_KERNEL_INIT & 0x3 )
[438]618if( hal_time_stamp() > DEBUG_KERNEL_INIT )
[647]619printk("\n[%s] : created chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
[407]620__FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev );
[389]621#endif
[5]622                }  // end if match
623
[19]624                // increment chdev global index (matching or not)
[188]625                ext_chdev_gid++;
[5]626
627            } // end loop on directions
628        }  // end loop on channels
[188]629        } // end loop on devices
630}  // end external_devices_init()
[5]631
[188]632///////////////////////////////////////////////////////////////////////////////////////////
[623]633// This function is called by core[0] in cluster 0 to allocate memory and initialize the PIC
[407]634// device, namely the informations attached to the external IOPIC controller, that
635// must be replicated in all clusters (struct iopic_input).
[188]636// This initialisation must be done before other devices initialisation because the IRQ
[407]637// routing infrastructure is required for both internal and external devices init.
[188]638///////////////////////////////////////////////////////////////////////////////////////////
639// @ info    : pointer on the local boot-info structure.
640///////////////////////////////////////////////////////////////////////////////////////////
[564]641static void __attribute__ ((noinline)) iopic_init( boot_info_t * info )
[188]642{
643    boot_device_t * dev_tbl;         // pointer on boot_info external devices array
644        uint32_t        dev_nr;          // actual number of external devices
645        xptr_t          base;            // remote pointer on segment base
646    uint32_t        func;            // device functionnal index
647    uint32_t        impl;            // device implementation index
648        uint32_t        i;               // device index in dev_tbl
649    uint32_t        x;               // cluster X coordinate
650    uint32_t        y;               // cluster Y coordinate
651    bool_t          found;           // IOPIC found
652        chdev_t       * chdev;           // pointer on PIC chdev descriptor
653
654    // get number of external peripherals and base of array from boot_info
655        dev_nr      = info->ext_dev_nr;
656    dev_tbl     = info->ext_dev;
657
[564]658    // avoid GCC warning
659    base        = XPTR_NULL;
660    impl        = 0;
661
[188]662    // loop on external peripherals to get the IOPIC 
663        for( i = 0 , found = false ; i < dev_nr ; i++ )
664        {
665        func = FUNC_FROM_TYPE( dev_tbl[i].type );
666
[127]667        if( func == DEV_FUNC_PIC )
[1]668        {
[188]669            base     = dev_tbl[i].base;
670            impl     = IMPL_FROM_TYPE( dev_tbl[i].type );
671            found    = true;
672            break;
673        }
674    }
[5]675
[564]676    // check PIC existence
677    if( found == false )
[580]678    {
679        printk("\n[PANIC] in %s : PIC device not found\n",
680        __FUNCTION__ );
681        hal_core_sleep();
682    }
[1]683
[407]684    // allocate and initialize the PIC chdev in cluster 0
685    chdev = chdev_create( DEV_FUNC_PIC,
[188]686                          impl,
687                          0,      // channel
688                          0,      // direction,
689                          base );
[5]690
[564]691    // check memory
692    if( chdev == NULL )
[580]693    {
694        printk("\n[PANIC] in %s : no memory for PIC chdev\n",
695        __FUNCTION__ );
696        hal_core_sleep();
697    }
[5]698
[188]699    // make PIC device type specific initialisation
700    dev_pic_init( chdev );
[1]701
[407]702    // register, in all clusters, the extended pointer
703    // on PIC chdev in "chdev_dir" array
[188]704    xptr_t * entry = &chdev_dir.pic;   
705               
706    for( x = 0 ; x < info->x_size ; x++ )
707    {
[564]708        for( y = 0 ; y < info->y_size ; y++ )
[188]709        {
[564]710            cxy_t cxy = HAL_CXY_FROM_XY( x , y );
711
712            if( cluster_is_active( cxy ) )
713            {
714                hal_remote_s64( XPTR( cxy , entry ) , 
[559]715                                XPTR( local_cxy , chdev ) );
716            }
[188]717        }
718    }
[1]719
[407]720    // initialize, in all clusters, the "iopic_input" structure
[188]721    // defining how external IRQs are connected to IOPIC
722
[407]723    // register default value for unused inputs
724    for( x = 0 ; x < info->x_size ; x++ )
725    {
[564]726        for( y = 0 ; y < info->y_size ; y++ )
[407]727        {
[564]728            cxy_t cxy = HAL_CXY_FROM_XY( x , y );
729
730            if( cluster_is_active( cxy ) )
731            {
732                hal_remote_memset( XPTR( cxy , &iopic_input ), 
733                                   0xFF , sizeof(iopic_input_t) );
[559]734            }
[407]735        }
736    }
737
738    // register input IRQ index for valid inputs
[577]739    uint32_t   id;             // input IRQ index
740    uint8_t    valid;          // input IRQ is connected
741    uint32_t   type;           // source device type
742    uint8_t    channel;        // source device channel
743    uint8_t    is_rx;          // source device direction
744    uint32_t * ptr = NULL;     // local pointer on one field in iopic_input stucture
[407]745
[188]746    for( id = 0 ; id < CONFIG_MAX_EXTERNAL_IRQS ; id++ )
747    {
748        valid   = dev_tbl[i].irq[id].valid;
749        type    = dev_tbl[i].irq[id].dev_type;
750        channel = dev_tbl[i].irq[id].channel;
751        is_rx   = dev_tbl[i].irq[id].is_rx;
[407]752        func    = FUNC_FROM_TYPE( type );
[188]753
[407]754        // get pointer on relevant field in iopic_input
755        if( valid )
[188]756        {
[407]757            if     ( func == DEV_FUNC_IOC )                 ptr = &iopic_input.ioc[channel]; 
758            else if((func == DEV_FUNC_TXT) && (is_rx == 0)) ptr = &iopic_input.txt_tx[channel];
759            else if((func == DEV_FUNC_TXT) && (is_rx != 0)) ptr = &iopic_input.txt_rx[channel];
[492]760            else if((func == DEV_FUNC_NIC) && (is_rx == 0)) ptr = &iopic_input.nic_tx[channel];
761            else if((func == DEV_FUNC_NIC) && (is_rx != 0)) ptr = &iopic_input.nic_rx[channel];
762            else if( func == DEV_FUNC_IOB )                 ptr = &iopic_input.iob;
[580]763            else
764            {
765                printk("\n[PANIC] in %s : illegal source device for IOPIC input\n",
766                __FUNCTION__ );
767                hal_core_sleep();
768            }
[188]769
[407]770            // set one entry in all "iopic_input" structures
771            for( x = 0 ; x < info->x_size ; x++ )
772            {
[564]773                for( y = 0 ; y < info->y_size ; y++ )
[407]774                {
[564]775                    cxy_t cxy = HAL_CXY_FROM_XY( x , y );
776
777                    if( cluster_is_active( cxy ) )
778                    {
779                        hal_remote_s64( XPTR( cxy , ptr ) , id ); 
[559]780                    }
[407]781                }
782            }
[188]783        }
784    } 
785
[438]786#if( DEBUG_KERNEL_INIT & 0x1 )
[601]787if( hal_time_stamp() > DEBUG_KERNEL_INIT )
[407]788{
[601]789    printk("\n[%s] created PIC chdev in cluster %x at cycle %d\n",
[407]790    __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() );
791    dev_pic_inputs_display();
792}
[389]793#endif
[188]794   
795}  // end iopic_init()
796
[1]797///////////////////////////////////////////////////////////////////////////////////////////
[623]798// This function is called by all core[0]s in all cluster to complete the PIC device
[188]799// initialisation, namely the informations attached to the LAPIC controller.
800// This initialisation must be done after the IOPIC initialisation, but before other
801// devices initialisation because the IRQ routing infrastructure is required for both
802// internal and external devices initialisation.
803///////////////////////////////////////////////////////////////////////////////////////////
804// @ info    : pointer on the local boot-info structure.
805///////////////////////////////////////////////////////////////////////////////////////////
[564]806static void __attribute__ ((noinline)) lapic_init( boot_info_t * info )
[188]807{
808    boot_device_t * dev_tbl;      // pointer on boot_info internal devices array
809    uint32_t        dev_nr;       // number of internal devices
810    uint32_t        i;            // device index in dev_tbl
811        xptr_t          base;         // remote pointer on segment base
812    uint32_t        func;         // device functionnal type in boot_info
813    bool_t          found;        // LAPIC found
814
815    // get number of internal peripherals and base
816        dev_nr      = info->int_dev_nr;
817    dev_tbl     = info->int_dev;
818
819    // loop on internal peripherals to get the lapic device
820        for( i = 0 , found = false ; i < dev_nr ; i++ )
821        {
822        func = FUNC_FROM_TYPE( dev_tbl[i].type );
823
824        if( func == DEV_FUNC_ICU )
825        {
826            base     = dev_tbl[i].base;
827            found    = true;
828            break;
829        }
830    }
831
832    // if the LAPIC controller is not defined in the boot_info,
833    // we simply don't initialize the PIC extensions in the kernel,
834    // making the assumption that the LAPIC related informations
835    // are hidden in the hardware specific PIC driver.
836    if( found )
837    {
838        // initialise the PIC extensions for
839        // the core descriptor and core manager extensions
840        dev_pic_extend_init( (uint32_t *)GET_PTR( base ) );
841
842        // initialize the "lapic_input" structure
843        // defining how internal IRQs are connected to LAPIC
844        uint32_t        id;
845        uint8_t         valid;
846        uint8_t         channel;
847        uint32_t        func;
848
849        for( id = 0 ; id < CONFIG_MAX_INTERNAL_IRQS ; id++ )
850        {
851            valid    = dev_tbl[i].irq[id].valid;
852            func     = FUNC_FROM_TYPE( dev_tbl[i].irq[id].dev_type );
853            channel  = dev_tbl[i].irq[id].channel;
854
855            if( valid ) // only valid local IRQs are registered
856            {
857                if     ( func == DEV_FUNC_MMC ) lapic_input.mmc = id;
858                else if( func == DEV_FUNC_DMA ) lapic_input.dma[channel] = id;
[580]859                else
860                {
861                    printk("\n[PANIC] in %s : illegal source device for LAPIC input\n",
862                    __FUNCTION__ );
863                    hal_core_sleep();
864                }
[188]865            }
866        }
867    }
868}  // end lapic_init()
869
870///////////////////////////////////////////////////////////////////////////////////////////
[14]871// This static function returns the identifiers of the calling core.
872///////////////////////////////////////////////////////////////////////////////////////////
873// @ info    : pointer on boot_info structure.
874// @ lid     : [out] core local index in cluster.
875// @ cxy     : [out] cluster identifier.
876// @ lid     : [out] core global identifier (hardware).
[657]877// @ return 0 if success / return -1 if not found.
[14]878///////////////////////////////////////////////////////////////////////////////////////////
[564]879static error_t __attribute__ ((noinline)) get_core_identifiers( boot_info_t * info,
880                                                                lid_t       * lid,
881                                                                cxy_t       * cxy,
882                                                                gid_t       * gid )
[14]883{
[127]884    uint32_t   i;
[14]885    gid_t      global_id;
[19]886
[14]887    // get global identifier from hardware register
[127]888    global_id = hal_get_gid();
[14]889
890    // makes an associative search in boot_info to get (cxy,lid) from global_id
891    for( i = 0 ; i < info->cores_nr ; i++ )
892    {
893        if( global_id == info->core[i].gid )
894        {
895            *lid = info->core[i].lid;
896            *cxy = info->core[i].cxy;
897            *gid = global_id;
898            return 0;
899        }
900    }
[657]901    return -1;
[19]902}
[14]903
[626]904
905
906
907
[14]908///////////////////////////////////////////////////////////////////////////////////////////
[1]909// This function is the entry point for the kernel initialisation.
[651]910// It is executed by all cores in all clusters, but only core[cxy][0] initializes
[623]911// the shared resources such as the cluster manager, or the local peripherals.
[19]912// To comply with the multi-kernels paradigm, it accesses only local cluster memory, using
913// only information contained in the local boot_info_t structure, set by the bootloader.
[623]914// Only core[0] in cluster 0 print the log messages.
[1]915///////////////////////////////////////////////////////////////////////////////////////////
916// @ info    : pointer on the local boot-info structure.
917///////////////////////////////////////////////////////////////////////////////////////////
918void kernel_init( boot_info_t * info )
919{
[204]920    lid_t        core_lid = -1;             // running core local index
921    cxy_t        core_cxy = -1;             // running core cluster identifier
922    gid_t        core_gid;                  // running core hardware identifier
923    cluster_t  * cluster;                   // pointer on local cluster manager
924    core_t     * core;                      // pointer on running core descriptor
925    thread_t   * thread;                    // pointer on idle thread descriptor
926
927    xptr_t       vfs_root_inode_xp;         // extended pointer on VFS root inode
928    xptr_t       devfs_dev_inode_xp;        // extended pointer on DEVFS dev inode   
929    xptr_t       devfs_external_inode_xp;   // extended pointer on DEVFS external inode       
930
[1]931    error_t      error;
[285]932    reg_t        status;                    // running core status register
[1]933
[188]934    /////////////////////////////////////////////////////////////////////////////////
[623]935    // STEP 1 : Each core get its core identifier from boot_info, and makes
[188]936    //          a partial initialisation of its private idle thread descriptor.
[623]937    //          core[0] initializes the "local_cxy" global variable.
938    //          core[0] in cluster[0] initializes the TXT0 chdev for log messages.
[188]939    /////////////////////////////////////////////////////////////////////////////////
940
[23]941    error = get_core_identifiers( info,
[14]942                                  &core_lid,
943                                  &core_cxy,
944                                  &core_gid );
[1]945
[623]946    // core[0] initialize cluster identifier
[14]947    if( core_lid == 0 ) local_cxy = info->cxy;
[1]948
[127]949    // each core gets a pointer on its private idle thread descriptor
950    thread = (thread_t *)( idle_threads + (core_lid * CONFIG_THREAD_DESC_SIZE) );
[68]951
[127]952    // each core registers this thread pointer in hardware register
[68]953    hal_set_current_thread( thread );
[71]954
[407]955    // each core register core descriptor pointer in idle thread descriptor
956    thread->core = &LOCAL_CLUSTER->core_tbl[core_lid];
957
[564]958    // each core initializes the idle thread locks counters
959    thread->busylocks = 0;
[124]960
[564]961#if DEBUG_BUSYLOCK
962    // each core initialise the idle thread list of busylocks
963    xlist_root_init( XPTR( local_cxy , &thread->busylocks_root ) );
964#endif
[14]965
[623]966    // core[0] initializes cluster info
[564]967    if( core_lid == 0 ) cluster_info_init( info );
968
[623]969    // core[0] in cluster[0] initialises TXT0 chdev descriptor
[564]970    if( (core_lid == 0) && (core_cxy == 0) ) txt0_device_init( info );
971
[623]972    // all cores check identifiers
973    if( error )
974    {
975        printk("\n[PANIC] in %s : illegal core : gid %x / cxy %x / lid %d",
976        __FUNCTION__, core_lid, core_cxy, core_lid );
977        hal_core_sleep();
978    }
979
[14]980    /////////////////////////////////////////////////////////////////////////////////
[564]981    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
982                                        (info->x_size * info->y_size) );
[14]983    barrier_wait( &local_barrier , info->cores_nr );
[437]984    /////////////////////////////////////////////////////////////////////////////////
[14]985
[438]986#if DEBUG_KERNEL_INIT
[583]987if( (core_lid ==  0) & (local_cxy == 0) ) 
[624]988printk("\n[%s] exit barrier 1 : TXT0 initialized / cycle %d\n",
[610]989__FUNCTION__, (uint32_t)hal_get_cycles() );
[437]990#endif
[14]991
[623]992    /////////////////////////////////////////////////////////////////////////////////
[637]993    // STEP 2 : core[0] initializes the cluster manager,
994    //          including the physical memory allocators.
[623]995    /////////////////////////////////////////////////////////////////////////////////
[188]996
[651]997    // core[0] initialises DQDT (only core[0][0] build the quad-tree)
[582]998    if( core_lid == 0 ) dqdt_init();
999   
[623]1000    // core[0] initialize other cluster manager complex structures
[14]1001    if( core_lid == 0 )
[1]1002    {
[564]1003        error = cluster_manager_init( info );
[1]1004
[14]1005        if( error )
[580]1006        {
1007             printk("\n[PANIC] in %s : cannot initialize cluster manager in cluster %x\n",
1008             __FUNCTION__, local_cxy );
1009             hal_core_sleep();
1010        }
[14]1011    }
[5]1012
[14]1013    /////////////////////////////////////////////////////////////////////////////////
[564]1014    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
1015                                        (info->x_size * info->y_size) );
[14]1016    barrier_wait( &local_barrier , info->cores_nr );
1017    /////////////////////////////////////////////////////////////////////////////////
[1]1018
[438]1019#if DEBUG_KERNEL_INIT
1020if( (core_lid ==  0) & (local_cxy == 0) ) 
[624]1021printk("\n[%s] exit barrier 2 : cluster manager initialized / cycle %d\n",
[610]1022__FUNCTION__, (uint32_t)hal_get_cycles() );
[437]1023#endif
[1]1024
[188]1025    /////////////////////////////////////////////////////////////////////////////////
[624]1026    // STEP 3 : all cores initialize the idle thread descriptor.
1027    //          core[0] initializes the process_zero descriptor,
[623]1028    //          including the kernel VMM (both GPT and VSL)
[188]1029    /////////////////////////////////////////////////////////////////////////////////
1030
1031    // all cores get pointer on local cluster manager & core descriptor
[14]1032    cluster = &cluster_manager;
[127]1033    core    = &cluster->core_tbl[core_lid];
[1]1034
[624]1035    // all cores update the register(s) defining the kernel
1036    // entry points for interrupts, exceptions and syscalls,
1037    // this must be done before VFS initialisation, because
1038    // kernel_init() uses RPCs requiring IPIs...
1039    hal_set_kentry();
1040
1041    // all cores initialize the idle thread descriptor
1042    thread_idle_init( thread,
1043                      THREAD_IDLE,
1044                      &thread_idle_func,
1045                      NULL,
1046                      core_lid );
1047
[623]1048    // core[0] initializes the process_zero descriptor,
1049    if( core_lid == 0 ) process_zero_create( &process_zero , info );
[5]1050
[623]1051    /////////////////////////////////////////////////////////////////////////////////
1052    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
1053                                        (info->x_size * info->y_size) );
1054    barrier_wait( &local_barrier , info->cores_nr );
1055    /////////////////////////////////////////////////////////////////////////////////
1056
1057#if DEBUG_KERNEL_INIT
1058if( (core_lid ==  0) & (local_cxy == 0) ) 
[624]1059printk("\n[%s] exit barrier 3 : kernel processs initialized / cycle %d\n",
[623]1060__FUNCTION__, (uint32_t)hal_get_cycles() );
1061#endif
1062
1063    /////////////////////////////////////////////////////////////////////////////////
1064    // STEP 4 : all cores initialize their private MMU
1065    //          core[0] in cluster 0 initializes the IOPIC device.
1066    /////////////////////////////////////////////////////////////////////////////////
1067
1068    // all cores initialise their MMU
1069    hal_mmu_init( &process_zero.vmm.gpt );
1070
1071    // core[0] in cluster[0] initializes the PIC chdev,
[188]1072    if( (core_lid == 0) && (local_cxy == 0) ) iopic_init( info );
1073   
1074    ////////////////////////////////////////////////////////////////////////////////
[564]1075    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
1076                                        (info->x_size * info->y_size) );
[188]1077    barrier_wait( &local_barrier , info->cores_nr );
1078    ////////////////////////////////////////////////////////////////////////////////
[127]1079
[438]1080#if DEBUG_KERNEL_INIT
1081if( (core_lid ==  0) & (local_cxy == 0) ) 
[624]1082printk("\n[%s] exit barrier 4 : MMU and IOPIC initialized / cycle %d\n",
[610]1083__FUNCTION__, (uint32_t)hal_get_cycles() );
[437]1084#endif
[1]1085
[188]1086    ////////////////////////////////////////////////////////////////////////////////
[637]1087    // STEP 5 : core[0] initialize the distibuted LAPIC descriptor.
1088    //          core[0] initialize the internal chdev descriptors
[623]1089    //          core[0] initialize the local external chdev descriptors
[188]1090    ////////////////////////////////////////////////////////////////////////////////
[5]1091
[623]1092    // all core[0]s initialize their local LAPIC extension,
[279]1093    if( core_lid == 0 ) lapic_init( info );
1094
[623]1095    // core[0] scan the internal (private) peripherals,
[188]1096    // and allocates memory for the corresponding chdev descriptors.
1097    if( core_lid == 0 ) internal_devices_init( info );
1098       
[1]1099
[623]1100    // All core[0]s contribute to initialise external peripheral chdev descriptors.
1101    // Each core[0][cxy] scan the set of external (shared) peripherals (but the TXT0),
[14]1102    // and allocates memory for the chdev descriptors that must be placed
[127]1103    // on the (cxy) cluster according to the global index value.
[188]1104
[14]1105    if( core_lid == 0 ) external_devices_init( info );
[1]1106
[14]1107    /////////////////////////////////////////////////////////////////////////////////
[564]1108    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
1109                                        (info->x_size * info->y_size) );
[14]1110    barrier_wait( &local_barrier , info->cores_nr );
1111    /////////////////////////////////////////////////////////////////////////////////
[5]1112
[438]1113#if DEBUG_KERNEL_INIT
1114if( (core_lid ==  0) & (local_cxy == 0) ) 
[624]1115printk("\n[%s] exit barrier 5 : chdevs initialised / cycle %d\n",
[610]1116__FUNCTION__, (uint32_t)hal_get_cycles() );
[437]1117#endif
[1]1118
[657]1119#if CONFIG_INSTRUMENTATION_CHDEVS
[443]1120if( (core_lid ==  0) & (local_cxy == 0) ) 
[437]1121chdev_dir_display();
1122#endif
1123   
[188]1124    /////////////////////////////////////////////////////////////////////////////////
[657]1125    // STEP 6 : All cores enable IPI (Inter Procesor Interrupt),
1126    //          All cores unblock the idle thread, and register it in scheduler.
1127    //          The core[0] in cluster defined by the CONFIG_VFS_ROOT_CXY parameter,
1128    //          access the IOC device to initialize the VFS for the FS identified
1129    //          by the CONFIG_VFS_ROOT_IS_*** parameter. It does the following
1130    //          actions in the VFS_ROOT cluster :
1131    //          1. allocate and initialize the selected FS context,
1132    //          2. create and initializes the VFS root inodes,
1133    //          3. initialize the VFS context for FATFS (in fs_context[] array),
1134    //          4. create the <.> and <..> dentries in VFS root directory,
1135    //          5. register the VFS root inode in process_zero descriptor,
1136    //          6. allocate the DEVFS context,
1137    //          7. initialize the VFS context for DEVFS (in fs_context[] array),
1138    //          8. create the <dev> and <external> inodes,
1139    //          9. initialize the DEVFS context.
[188]1140    /////////////////////////////////////////////////////////////////////////////////
1141
[564]1142    // All cores enable IPI
[279]1143    dev_pic_enable_ipi();
1144    hal_enable_irq( &status );
1145
[624]1146    // all cores unblock the idle thread, and register it in scheduler
[296]1147    thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
[103]1148    core->scheduler.idle = thread;
[1]1149
[657]1150    // core[O] in VFS_ROOT cluster creates the VFS root
1151    if( (core_lid ==  0) && (local_cxy == CONFIG_VFS_ROOT_CXY ) ) 
[14]1152    {
[614]1153        // Only FATFS is supported yet,
[657]1154        // TODO other File System can be introduced below
[23]1155        if( CONFIG_VFS_ROOT_IS_FATFS )
1156        {
[657]1157            // 1. allocate memory and initialize FATFS context in VFS_ROOT cluster
1158            xptr_t  fatfs_ctx_xp = fatfs_ctx_alloc( CONFIG_VFS_ROOT_CXY );
[188]1159
[657]1160            if( fatfs_ctx_xp == XPTR_NULL )
[580]1161            {
[657]1162                printk("\n[PANIC] in %s : cannot allocate FATFS context in cluster %x\n",
1163                __FUNCTION__ , CONFIG_VFS_ROOT_CXY );
[580]1164                hal_core_sleep();
1165            }
[188]1166
[657]1167            // initialise FATFS context in VFS_ROOT cluster from IOC device (boot_record)
1168            error = fatfs_ctx_init( fatfs_ctx_xp );
[626]1169
[657]1170            if( error )
1171            {
1172                printk("\n[PANIC] in %s : cannot initialize FATFS context in cluster %x\n",
1173                __FUNCTION__ , CONFIG_VFS_ROOT_CXY );
1174                hal_core_sleep();
1175            }
1176
1177#if( DEBUG_KERNEL_INIT & 1 )
1178printk("\n[%s] initialized FATFS context in cluster %x\n",
1179__FUNCTION__, CONFIG_VFS_ROOT_CXY );
1180#endif
1181   
1182            // get various informations from FATFS context
1183            fatfs_ctx_t * fatfs_ctx_ptr = GET_PTR( fatfs_ctx_xp );
1184
1185            uint32_t root_dir_cluster    = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY,
1186                                           &fatfs_ctx_ptr->root_dir_cluster ) );
1187
1188            uint32_t bytes_per_sector    = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY,
1189                                           &fatfs_ctx_ptr->bytes_per_sector ) );
[188]1190 
[657]1191            uint32_t sectors_per_cluster = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY,
1192                                           &fatfs_ctx_ptr->sectors_per_cluster ) );
1193 
1194            uint32_t cluster_size        = bytes_per_sector * sectors_per_cluster;
1195 
1196            uint32_t fat_sectors_count   = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY,
1197                                           &fatfs_ctx_ptr->fat_sectors_count ) ) << 7;
1198
1199            uint32_t total_clusters      = fat_sectors_count << 7;
1200 
1201            // 2. create VFS root inode in VFS_ROOT cluster
1202            // TODO define attr, rights, uid, gid
1203            error = vfs_inode_create( CONFIG_VFS_ROOT_CXY,          // target cluster
1204                                      FS_TYPE_FATFS,                // fs_type
1205                                      0,                            // attr
1206                                      0,                            // rights
1207                                      0,                            // uid
1208                                      0,                            // gid
1209                                      &vfs_root_inode_xp );         // return
[564]1210            if( error )
[580]1211            {
[657]1212                printk("\n[PANIC] in %s : cannot create VFS root inode in cluster %x\n",
1213                __FUNCTION__ , CONFIG_VFS_ROOT_CXY );
[580]1214                hal_core_sleep();
1215            }
[188]1216
[657]1217#if( DEBUG_KERNEL_INIT & 1 )
1218vfs_inode_t * root_inode = GET_PTR( vfs_root_inode_xp );
1219printk("\n[%s] created </> root inode %x in cluster %x / ctx %x\n",
1220__FUNCTION__, root_inode, CONFIG_VFS_ROOT_CXY, root_inode->ctx );
1221#endif
1222   
1223            // update FATFS root inode "type" and "extend" fields 
1224            vfs_inode_t * vfs_root_inode_ptr = GET_PTR( vfs_root_inode_xp );
1225
1226            hal_remote_s32( XPTR( CONFIG_VFS_ROOT_CXY , &vfs_root_inode_ptr->type ),
1227                            INODE_TYPE_DIR );
1228
1229            hal_remote_spt( XPTR( CONFIG_VFS_ROOT_CXY , &vfs_root_inode_ptr->extend ), 
[601]1230                            (void*)(intptr_t)root_dir_cluster );
[188]1231
[657]1232            // 3. initialize the VFS context for FATFS in VFS_ROOT cluster
1233            vfs_ctx_init( CONFIG_VFS_ROOT_CXY,                      // target cluster
1234                          FS_TYPE_FATFS,                            // fs type
1235                              total_clusters,                           // number of clusters
1236                              cluster_size,                             // bytes
1237                              vfs_root_inode_xp,                        // VFS root
1238                          fatfs_ctx_ptr );                          // extend
1239
1240#if( DEBUG_KERNEL_INIT & 1 )
1241vfs_ctx_t * vfs_for_fatfs_ctx =  &fs_context[FS_TYPE_FATFS];
1242printk("\n[%s] initialized VFS_for_FATFS context in cluster %x / ctx %x / fs_type %d\n",
1243__FUNCTION__, CONFIG_VFS_ROOT_CXY, vfs_for_fatfs_ctx, vfs_for_fatfs_ctx->type );
1244#endif
[23]1245        }
1246        else
1247        {
[657]1248            printk("\n[PANIC] in %s : unsupported VFS type in cluster %x\n",
1249            __FUNCTION__ , CONFIG_VFS_ROOT_CXY );
[580]1250            hal_core_sleep();
[23]1251        }
1252
[657]1253        // 4. create the <.> and <..> dentries in VFS root directory
[614]1254        // the VFS root parent inode is the VFS root inode itself
1255        vfs_add_special_dentries( vfs_root_inode_xp,
1256                                  vfs_root_inode_xp );
1257
[657]1258        // 5. register VFS root inode in target cluster process_zero descriptor
1259        hal_remote_s64( XPTR( CONFIG_VFS_ROOT_CXY , &process_zero.vfs_root_xp ),
1260                        vfs_root_inode_xp );
1261        hal_remote_s64( XPTR( CONFIG_VFS_ROOT_CXY , &process_zero.cwd_xp ),
1262                        vfs_root_inode_xp );
1263
1264        // 6. allocate memory for DEVFS context in VFS_ROOT cluster
1265        xptr_t devfs_ctx_xp = devfs_ctx_alloc( CONFIG_VFS_ROOT_CXY );
1266
1267        if( devfs_ctx_xp == XPTR_NULL )
1268        {
1269            printk("\n[PANIC] in %s : cannot create DEVFS context in cluster %x\n",
1270            __FUNCTION__ , CONFIG_VFS_ROOT_CXY );
1271            hal_core_sleep();
1272        }
1273
1274        // 7. initialize the VFS context for DEVFS in VFS_ROOT cluster
1275        vfs_ctx_init( CONFIG_VFS_ROOT_CXY,                          // target cluster
1276                      FS_TYPE_DEVFS,                                // fs type
1277                          0,                                            // total_clusters: unused
1278                          0,                                            // cluster_size: unused
1279                          vfs_root_inode_xp,                            // VFS root
1280                      GET_PTR( devfs_ctx_xp ) );                    // extend
1281
1282#if( DEBUG_KERNEL_INIT & 1 )
1283vfs_ctx_t * vfs_for_devfs_ctx =  &fs_context[FS_TYPE_DEVFS];
1284printk("\n[%s] initialized VFS_for_DEVFS context in cluster %x / ctx %x / fs_type %d\n",
1285__FUNCTION__, CONFIG_VFS_ROOT_CXY, vfs_for_devfs_ctx, vfs_for_devfs_ctx->type );
1286#endif
1287
1288        // 8. create "dev" and "external" inodes (directories)
1289        devfs_global_init( vfs_root_inode_xp,
1290                           &devfs_dev_inode_xp,
1291                           &devfs_external_inode_xp );
1292
1293        // 9. initializes DEVFS context in VFS_ROOT cluster
1294        devfs_ctx_init( devfs_ctx_xp,
1295                        devfs_dev_inode_xp,
1296                        devfs_external_inode_xp );
[188]1297    }
1298
1299    /////////////////////////////////////////////////////////////////////////////////
[564]1300    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
1301                                        (info->x_size * info->y_size) );
[188]1302    barrier_wait( &local_barrier , info->cores_nr );
1303    /////////////////////////////////////////////////////////////////////////////////
1304
[438]1305#if DEBUG_KERNEL_INIT
[657]1306if( (core_lid ==  0) & (local_cxy == CONFIG_VFS_ROOT_CXY) ) 
1307printk("\n[%s] exit barrier 6 : VFS root inode (%x) created in cluster (%x) / cycle %d\n",
1308__FUNCTION__, GET_CXY(vfs_root_inode_xp), 
1309GET_PTR(vfs_root_inode_xp), (uint32_t)hal_get_cycles() );
[437]1310#endif
[188]1311
1312    /////////////////////////////////////////////////////////////////////////////////
[657]1313    // STEP 7 : In all clusters other than the VFS_ROOT cluster, the core[0] makes
1314    //          the following local actions to complete the VFS initialisation :
1315    //          1. allocate a local context for the selected FS extension,
1316    //          2. copy FS context from VFS_ROOT cluster to local cluster,
1317    //          3. copy VFS_for_FATFS context from VFS_ROOT cluster to local cluster,
1318    //          4. allocate a local context for the DEVFS extension,
1319    //          5. copy DEVFS context from VFS_ROOT cluster to local cluster,
1320    //          6. update the local "root_inode_xp" field in process_zero.
[188]1321    /////////////////////////////////////////////////////////////////////////////////
1322
[657]1323    if( (core_lid ==  0) && (local_cxy != CONFIG_VFS_ROOT_CXY) ) 
[188]1324    {
[657]1325        // only FATFS is supported yet
1326        // TODO other File System can be introduced below
[188]1327        if( CONFIG_VFS_ROOT_IS_FATFS )
[23]1328        {
[657]1329            // 1. allocate a local FATFS context extension
1330            xptr_t local_fatfs_ctx_xp = fatfs_ctx_alloc( local_cxy );
[188]1331
[657]1332            if( local_fatfs_ctx_xp == XPTR_NULL )
[580]1333            {
1334                printk("\n[PANIC] in %s : cannot create FATFS context in cluster %x\n",
1335                __FUNCTION__ , local_cxy );
1336                hal_core_sleep();
1337            }
[188]1338
[657]1339            // get local pointer on VFS_for_FATFS context (same in all clusters)
1340            vfs_ctx_t * vfs_fat_ctx_ptr = &fs_context[FS_TYPE_FATFS];
[188]1341
[657]1342            // build extended pointer on VFS_for_FATFS "extend" field in VFS_ROOT cluster
1343            xptr_t fatfs_extend_xp = XPTR( CONFIG_VFS_ROOT_CXY , &vfs_fat_ctx_ptr->extend );
[389]1344
[657]1345            // get local pointer on FATFS context in VFS_ROOT cluster
1346            fatfs_ctx_t * remote_fatfs_ctx_ptr = hal_remote_lpt( fatfs_extend_xp );
[389]1347
[657]1348            // build extended pointer on FATFS context in VFS_ROOT cluster
1349            xptr_t remote_fatfs_ctx_xp = XPTR( CONFIG_VFS_ROOT_CXY , remote_fatfs_ctx_ptr );
[188]1350
[657]1351            // 2. copy FATFS context from VFS_ROOT cluster to local cluster
1352            hal_remote_memcpy( local_fatfs_ctx_xp,
1353                               remote_fatfs_ctx_xp,
1354                               sizeof(fatfs_ctx_t) );
[188]1355
[657]1356            // build extended pointer on remote VFS_for_FATFS context
1357            xptr_t remote_vfs_ctx_xp = XPTR( CONFIG_VFS_ROOT_CXY , vfs_fat_ctx_ptr );
[23]1358
[657]1359            // build extended pointer on local VFS_for_FATFS context
1360            xptr_t local_vfs_ctx_xp = XPTR( local_cxy , vfs_fat_ctx_ptr );
1361 
1362            // 3. copy VFS_for_FATFS context from VFS_ROOT cluster to local cluster
1363            hal_remote_memcpy( local_vfs_ctx_xp,
1364                               remote_vfs_ctx_xp,
1365                               sizeof(vfs_ctx_t) );
[101]1366
[657]1367            // update "extend" field in local VFS_for_FATFS context
1368            vfs_fat_ctx_ptr->extend = GET_PTR( local_fatfs_ctx_xp );
[14]1369
[657]1370// check local FATFS and VFS context copies
1371assert( (((fatfs_ctx_t *)vfs_fat_ctx_ptr->extend)->sectors_per_cluster == 8),
1372"illegal FATFS context in cluster %x\n", local_cxy );
[101]1373
[657]1374        }
1375        else
[580]1376        {
[657]1377            printk("\n[PANIC] in %s : unsupported VFS type in cluster %x\n",
[580]1378            __FUNCTION__ , local_cxy );
1379            hal_core_sleep();
1380        }
[564]1381
[657]1382        // 4. allocate a local DEVFS context extension,
1383        xptr_t local_devfs_ctx_xp = devfs_ctx_alloc( local_cxy );
[564]1384
[657]1385        // get local pointer on VFS_for_DEVFS context (same in all clusters)
1386        vfs_ctx_t * vfs_dev_ctx_ptr = &fs_context[FS_TYPE_DEVFS];
[188]1387
[657]1388        // build extended pointer on VFS_for_DEVFS extend field in VFS_ROOT cluster
1389        xptr_t remote_extend_xp = XPTR( CONFIG_VFS_ROOT_CXY , &vfs_dev_ctx_ptr->extend );
[188]1390
[657]1391        // get local pointer on DEVFS context in VFS_ROOT cluster
1392        devfs_ctx_t * remote_devfs_ctx_ptr = hal_remote_lpt( remote_extend_xp );
1393
1394        // build extended pointer on FATFS context in VFS_ROOT cluster
1395        xptr_t remote_devfs_ctx_xp = XPTR( CONFIG_VFS_ROOT_CXY , remote_devfs_ctx_ptr );
1396
1397        // 5. copy DEVFS context from VFS_ROOT cluster to local cluster
1398        hal_remote_memcpy( local_devfs_ctx_xp,
1399                           remote_devfs_ctx_xp,
1400                           sizeof(devfs_ctx_t) );
1401
1402        // update "extend" field in local VFS_for_DEVFS context
1403        vfs_dev_ctx_ptr->extend = GET_PTR( local_devfs_ctx_xp );
1404
1405        // get extended pointer on VFS root inode from VFS_ROOT cluster
1406        vfs_root_inode_xp = hal_remote_l64( XPTR( CONFIG_VFS_ROOT_CXY,
1407                                                  &process_zero.vfs_root_xp ) );
1408
1409        // 6. update local process_zero descriptor
1410        process_zero.vfs_root_xp = vfs_root_inode_xp;
1411        process_zero.cwd_xp      = vfs_root_inode_xp;
1412    }
1413
[188]1414    /////////////////////////////////////////////////////////////////////////////////
[564]1415    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
1416                                        (info->x_size * info->y_size) );
[188]1417    barrier_wait( &local_barrier , info->cores_nr );
[204]1418    /////////////////////////////////////////////////////////////////////////////////
[188]1419
[438]1420#if DEBUG_KERNEL_INIT
1421if( (core_lid ==  0) & (local_cxy == 0) ) 
[657]1422printk("\n[%s] exit barrier 7 : VFS & DEVFS contexts replicated in all clusters / cycle %d\n",
1423__FUNCTION__ , (uint32_t)hal_get_cycles() );
[437]1424#endif
[188]1425
1426    /////////////////////////////////////////////////////////////////////////////////
[657]1427    // STEP 8 : In all clusters in parallel, core[0] completes DEVFS initialization.
1428    //          Each core[0] creates the local DEVFS "internal" directory,
1429    //          and creates the pseudo-files for chdevs placed in local cluster.
[188]1430    /////////////////////////////////////////////////////////////////////////////////
1431
1432    if( core_lid == 0 )
1433    {
[657]1434        // get local pointer on local DEVFS context
1435        devfs_ctx_t * ctx = fs_context[FS_TYPE_DEVFS].extend;
[188]1436
[204]1437        // populate DEVFS in all clusters
[657]1438        devfs_local_init( ctx->dev_inode_xp,
1439                          ctx->external_inode_xp );
[188]1440    }
1441
1442    /////////////////////////////////////////////////////////////////////////////////
[564]1443    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 
1444                                        (info->x_size * info->y_size) );
[188]1445    barrier_wait( &local_barrier , info->cores_nr );
[204]1446    /////////////////////////////////////////////////////////////////////////////////
[188]1447
[438]1448#if DEBUG_KERNEL_INIT
1449if( (core_lid ==  0) & (local_cxy == 0) ) 
[657]1450printk("\n[%s] exit barrier 8 : DEVFS initialized in all clusters / cycle %d\n",
[610]1451__FUNCTION__, (uint32_t)hal_get_cycles() );
[437]1452#endif
[188]1453
[623]1454#if( DEBUG_KERNEL_INIT & 1 )
1455if( (core_lid ==  0) & (local_cxy == 0) ) 
1456vfs_display( vfs_root_inode_xp );
1457#endif
1458
[188]1459    /////////////////////////////////////////////////////////////////////////////////
[657]1460    // STEP 9 : core[0] in cluster 0 creates the first user process (process_init).
1461    //          This include the process VMM (GPT and VSL) creation.
1462    //          Finally, it prints the ALMOS-MKH banner.
[188]1463    /////////////////////////////////////////////////////////////////////////////////
1464
[457]1465    if( (core_lid == 0) && (local_cxy == 0) ) 
[188]1466    {
[428]1467       process_init_create();
[188]1468    }
[101]1469
[624]1470#if DEBUG_KERNEL_INIT
1471if( (core_lid ==  0) & (local_cxy == 0) ) 
[657]1472printk("\n[%s] exit barrier 9 : process_init created in cluster 0 / cycle %d\n",
[624]1473__FUNCTION__, (uint32_t)hal_get_cycles() );
1474#endif
1475
[564]1476    if( (core_lid == 0) && (local_cxy == 0) ) 
[188]1477    {
[5]1478        print_banner( (info->x_size * info->y_size) , info->cores_nr );
[623]1479    }
[68]1480
[635]1481#if CONFIG_INSTRUMENTATION_FOOTPRINT
[623]1482if( (core_lid ==  0) & (local_cxy == 0) ) 
[437]1483printk("\n\n***** memory fooprint for main kernel objects\n\n"
[68]1484                   " - thread descriptor  : %d bytes\n"
1485                   " - process descriptor : %d bytes\n"
1486                   " - cluster manager    : %d bytes\n"
1487                   " - chdev descriptor   : %d bytes\n"
1488                   " - core descriptor    : %d bytes\n"
1489                   " - scheduler          : %d bytes\n"
1490                   " - rpc fifo           : %d bytes\n"
1491                   " - page descriptor    : %d bytes\n"
[635]1492                   " - mapper descriptor  : %d bytes\n"
1493                   " - vseg descriptor    : %d bytes\n"
[68]1494                   " - ppm manager        : %d bytes\n"
1495                   " - kcm manager        : %d bytes\n"
1496                   " - khm manager        : %d bytes\n"
1497                   " - vmm manager        : %d bytes\n"
[635]1498                   " - vfs inode          : %d bytes\n"
1499                   " - vfs dentry         : %d bytes\n"
1500                   " - vfs file           : %d bytes\n"
1501                   " - vfs context        : %d bytes\n"
1502                   " - xhtab root         : %d bytes\n"
[68]1503                   " - list item          : %d bytes\n"
1504                   " - xlist item         : %d bytes\n"
[564]1505                   " - busylock           : %d bytes\n"
1506                   " - remote busylock    : %d bytes\n"
1507                   " - queuelock          : %d bytes\n"
1508                   " - remote queuelock   : %d bytes\n"
[68]1509                   " - rwlock             : %d bytes\n"
1510                   " - remote rwlock      : %d bytes\n",
[564]1511                   sizeof( thread_t           ),
1512                   sizeof( process_t          ),
1513                   sizeof( cluster_t          ),
1514                   sizeof( chdev_t            ),
1515                   sizeof( core_t             ),
1516                   sizeof( scheduler_t        ),
1517                   sizeof( remote_fifo_t      ),
1518                   sizeof( page_t             ),
1519                   sizeof( mapper_t           ),
[635]1520                   sizeof( vseg_t             ),
[564]1521                   sizeof( ppm_t              ),
1522                   sizeof( kcm_t              ),
1523                   sizeof( khm_t              ),
1524                   sizeof( vmm_t              ),
[635]1525                   sizeof( vfs_inode_t        ),
1526                   sizeof( vfs_dentry_t       ),
1527                   sizeof( vfs_file_t         ),
1528                   sizeof( vfs_ctx_t          ),
1529                   sizeof( xhtab_t            ),
[564]1530                   sizeof( list_entry_t       ),
1531                   sizeof( xlist_entry_t      ),
1532                   sizeof( busylock_t         ),
1533                   sizeof( remote_busylock_t  ),
1534                   sizeof( queuelock_t        ),
1535                   sizeof( remote_queuelock_t ),
1536                   sizeof( rwlock_t           ),
1537                   sizeof( remote_rwlock_t    ));
[406]1538#endif
1539
[398]1540    // each core activates its private TICK IRQ
1541    dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD );
[14]1542
[610]1543    /////////////////////////////////////////////////////////////////////////////////
1544    if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ),
1545                                        (info->x_size * info->y_size) );
1546    barrier_wait( &local_barrier , info->cores_nr );
1547    /////////////////////////////////////////////////////////////////////////////////
1548
[635]1549#if DEBUG_KERNEL_INIT
[610]1550thread_t * this = CURRENT_THREAD;
1551printk("\n[%s] : thread[%x,%x] on core[%x,%d] jumps to thread_idle_func() / cycle %d\n",
1552__FUNCTION__ , this->process->pid, this->trdid,
1553local_cxy, core_lid, (uint32_t)hal_get_cycles() );
[440]1554#endif
1555
[407]1556    // each core jump to thread_idle_func
[50]1557    thread_idle_func();
[14]1558
[610]1559}  // end kernel_init()
1560
Note: See TracBrowser for help on using the repository browser.