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

Last change on this file since 675 was 669, checked in by alain, 4 years ago

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

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