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

Last change on this file since 662 was 662, checked in by alain, 3 years ago

Introduce the ksocket.h & ksocket.c files in kernel/kern.

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