Changeset 657 for trunk/kernel/kern/kernel_init.c
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/kernel_init.c
r651 r657 3 3 * 4 4 * Authors : Mohamed Lamine Karaoui (2015) 5 * Alain Greiner (2016,2017,2018,2019 )5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) Sorbonne Universites … … 136 136 "VMM_STACK", // 3 137 137 "VMM_MMAP", // 4 138 " VFS_CTX",// 5139 "K CM_STATE", // 6140 " KHM_STATE",// 7141 "HTAB_STATE", // 8 142 138 "KCM_STATE", // 5 139 "KHM_STATE", // 6 140 "HTAB_STATE", // 7 141 142 "VFS_CTX", // 8 143 143 "PPM_FREE", // 9 144 144 "THREAD_JOIN", // 10 … … 172 172 "VFS_MAIN", // 34 173 173 "FATFS_FAT", // 35 174 "FBF_WINDOWS", // 36 174 175 }; 175 176 … … 874 875 // @ cxy : [out] cluster identifier. 875 876 // @ lid : [out] core global identifier (hardware). 876 // @ return 0 if success / return EINVALif not found.877 // @ return 0 if success / return -1 if not found. 877 878 /////////////////////////////////////////////////////////////////////////////////////////// 878 879 static error_t __attribute__ ((noinline)) get_core_identifiers( boot_info_t * info, … … 898 899 } 899 900 } 900 return EINVAL; 901 } 902 903 904 905 906 907 ///////////////////////////////// 908 // kleenex debug function 909 ///////////////////////////////// 910 void display_fat( uint32_t step ) 911 { 912 fatfs_ctx_t * fatfs_ctx = fs_context[FS_TYPE_FATFS].extend; 913 if( fatfs_ctx != NULL ) 914 { 915 printk("\n[%s] step %d at cycle %d\n", __FUNCTION__, step, (uint32_t)hal_get_cycles() ); 916 xptr_t mapper_xp = fatfs_ctx->fat_mapper_xp; 917 mapper_display_page( mapper_xp , 0 , 128 ); 918 } 919 else 920 { 921 printk("\n[%s] step %d : fatfs context not initialized\n", __FUNCTION__, step ); 922 } 901 return -1; 923 902 } 924 903 … … 949 928 xptr_t devfs_dev_inode_xp; // extended pointer on DEVFS dev inode 950 929 xptr_t devfs_external_inode_xp; // extended pointer on DEVFS external inode 951 xptr_t devfs_internal_inode_xp; // extended pointer on DEVFS internal inode952 930 953 931 error_t error; … … 1139 1117 #endif 1140 1118 1141 #if ( DEBUG_KERNEL_INIT & 1 )1119 #if CONFIG_INSTRUMENTATION_CHDEVS 1142 1120 if( (core_lid == 0) & (local_cxy == 0) ) 1143 1121 chdev_dir_display(); … … 1145 1123 1146 1124 ///////////////////////////////////////////////////////////////////////////////// 1147 // STEP 6 : all cores enable IPI (Inter Procesor Interrupt), 1148 // all cores unblock the idle thread, and register it in scheduler. 1149 // core[0] in cluster[0] creates the VFS root inode. 1150 // It access the boot device to initialize the file system context. 1125 // STEP 6 : All cores enable IPI (Inter Procesor Interrupt), 1126 // All cores unblock the idle thread, and register it in scheduler. 1127 // The core[0] in cluster defined by the CONFIG_VFS_ROOT_CXY parameter, 1128 // access the IOC device to initialize the VFS for the FS identified 1129 // by the CONFIG_VFS_ROOT_IS_*** parameter. It does the following 1130 // actions in the VFS_ROOT cluster : 1131 // 1. allocate and initialize the selected FS context, 1132 // 2. create and initializes the VFS root inodes, 1133 // 3. initialize the VFS context for FATFS (in fs_context[] array), 1134 // 4. create the <.> and <..> dentries in VFS root directory, 1135 // 5. register the VFS root inode in process_zero descriptor, 1136 // 6. allocate the DEVFS context, 1137 // 7. initialize the VFS context for DEVFS (in fs_context[] array), 1138 // 8. create the <dev> and <external> inodes, 1139 // 9. initialize the DEVFS context. 1151 1140 ///////////////////////////////////////////////////////////////////////////////// 1152 1141 … … 1159 1148 core->scheduler.idle = thread; 1160 1149 1161 // core[O] in cluster[0]creates the VFS root1162 if( (core_lid == 0) && (local_cxy == 0) )1150 // core[O] in VFS_ROOT cluster creates the VFS root 1151 if( (core_lid == 0) && (local_cxy == CONFIG_VFS_ROOT_CXY ) ) 1163 1152 { 1164 vfs_root_inode_xp = XPTR_NULL;1165 1166 1153 // Only FATFS is supported yet, 1167 // other File System can be introduced here1154 // TODO other File System can be introduced below 1168 1155 if( CONFIG_VFS_ROOT_IS_FATFS ) 1169 1156 { 1170 // 1. allocate memory for FATFS context in cluster 01171 fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();1172 1173 if( fatfs_ctx ==NULL )1157 // 1. allocate memory and initialize FATFS context in VFS_ROOT cluster 1158 xptr_t fatfs_ctx_xp = fatfs_ctx_alloc( CONFIG_VFS_ROOT_CXY ); 1159 1160 if( fatfs_ctx_xp == XPTR_NULL ) 1174 1161 { 1175 printk("\n[PANIC] in %s : cannot create FATFS context in cluster 0\n",1176 __FUNCTION__ );1162 printk("\n[PANIC] in %s : cannot allocate FATFS context in cluster %x\n", 1163 __FUNCTION__ , CONFIG_VFS_ROOT_CXY ); 1177 1164 hal_core_sleep(); 1178 1165 } 1179 1166 1180 // 2. access boot device to initialize FATFS context 1181 fatfs_ctx_init( fatfs_ctx ); 1182 1183 // 3. get various informations from FATFS context 1184 uint32_t root_dir_cluster = fatfs_ctx->root_dir_cluster; 1185 uint32_t cluster_size = fatfs_ctx->bytes_per_sector * 1186 fatfs_ctx->sectors_per_cluster; 1187 uint32_t total_clusters = fatfs_ctx->fat_sectors_count << 7; 1188 1189 // 4. create VFS root inode in cluster 0 1190 error = vfs_inode_create( FS_TYPE_FATFS, // fs_type 1191 0, // attr 1192 0, // rights 1193 0, // uid 1194 0, // gid 1195 &vfs_root_inode_xp ); // return 1167 // initialise FATFS context in VFS_ROOT cluster from IOC device (boot_record) 1168 error = fatfs_ctx_init( fatfs_ctx_xp ); 1169 1196 1170 if( error ) 1197 1171 { 1198 printk("\n[PANIC] in %s : cannot create VFS root inode in cluster 0\n",1199 __FUNCTION__ );1172 printk("\n[PANIC] in %s : cannot initialize FATFS context in cluster %x\n", 1173 __FUNCTION__ , CONFIG_VFS_ROOT_CXY ); 1200 1174 hal_core_sleep(); 1201 1175 } 1202 1176 1203 // 5. update FATFS root inode "type" and "extend" fields 1204 cxy_t vfs_root_cxy = GET_CXY( vfs_root_inode_xp ); 1205 vfs_inode_t * vfs_root_ptr = GET_PTR( vfs_root_inode_xp ); 1206 hal_remote_s32( XPTR( vfs_root_cxy , &vfs_root_ptr->type ), INODE_TYPE_DIR ); 1207 hal_remote_spt( XPTR( vfs_root_cxy , &vfs_root_ptr->extend ), 1177 #if( DEBUG_KERNEL_INIT & 1 ) 1178 printk("\n[%s] initialized FATFS context in cluster %x\n", 1179 __FUNCTION__, CONFIG_VFS_ROOT_CXY ); 1180 #endif 1181 1182 // get various informations from FATFS context 1183 fatfs_ctx_t * fatfs_ctx_ptr = GET_PTR( fatfs_ctx_xp ); 1184 1185 uint32_t root_dir_cluster = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY, 1186 &fatfs_ctx_ptr->root_dir_cluster ) ); 1187 1188 uint32_t bytes_per_sector = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY, 1189 &fatfs_ctx_ptr->bytes_per_sector ) ); 1190 1191 uint32_t sectors_per_cluster = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY, 1192 &fatfs_ctx_ptr->sectors_per_cluster ) ); 1193 1194 uint32_t cluster_size = bytes_per_sector * sectors_per_cluster; 1195 1196 uint32_t fat_sectors_count = hal_remote_l32( XPTR( CONFIG_VFS_ROOT_CXY, 1197 &fatfs_ctx_ptr->fat_sectors_count ) ) << 7; 1198 1199 uint32_t total_clusters = fat_sectors_count << 7; 1200 1201 // 2. create VFS root inode in VFS_ROOT cluster 1202 // TODO define attr, rights, uid, gid 1203 error = vfs_inode_create( CONFIG_VFS_ROOT_CXY, // target cluster 1204 FS_TYPE_FATFS, // fs_type 1205 0, // attr 1206 0, // rights 1207 0, // uid 1208 0, // gid 1209 &vfs_root_inode_xp ); // return 1210 if( error ) 1211 { 1212 printk("\n[PANIC] in %s : cannot create VFS root inode in cluster %x\n", 1213 __FUNCTION__ , CONFIG_VFS_ROOT_CXY ); 1214 hal_core_sleep(); 1215 } 1216 1217 #if( DEBUG_KERNEL_INIT & 1 ) 1218 vfs_inode_t * root_inode = GET_PTR( vfs_root_inode_xp ); 1219 printk("\n[%s] created </> root inode %x in cluster %x / ctx %x\n", 1220 __FUNCTION__, root_inode, CONFIG_VFS_ROOT_CXY, root_inode->ctx ); 1221 #endif 1222 1223 // update FATFS root inode "type" and "extend" fields 1224 vfs_inode_t * vfs_root_inode_ptr = GET_PTR( vfs_root_inode_xp ); 1225 1226 hal_remote_s32( XPTR( CONFIG_VFS_ROOT_CXY , &vfs_root_inode_ptr->type ), 1227 INODE_TYPE_DIR ); 1228 1229 hal_remote_spt( XPTR( CONFIG_VFS_ROOT_CXY , &vfs_root_inode_ptr->extend ), 1208 1230 (void*)(intptr_t)root_dir_cluster ); 1209 1231 1210 // 6. initialize the generic VFS context for FATFS 1211 vfs_ctx_init( FS_TYPE_FATFS, // fs type 1212 0, // attributes: unused 1213 total_clusters, // number of clusters 1214 cluster_size, // bytes 1215 vfs_root_inode_xp, // VFS root 1216 fatfs_ctx ); // extend 1232 // 3. initialize the VFS context for FATFS in VFS_ROOT cluster 1233 vfs_ctx_init( CONFIG_VFS_ROOT_CXY, // target cluster 1234 FS_TYPE_FATFS, // fs type 1235 total_clusters, // number of clusters 1236 cluster_size, // bytes 1237 vfs_root_inode_xp, // VFS root 1238 fatfs_ctx_ptr ); // extend 1239 1240 #if( DEBUG_KERNEL_INIT & 1 ) 1241 vfs_ctx_t * vfs_for_fatfs_ctx = &fs_context[FS_TYPE_FATFS]; 1242 printk("\n[%s] initialized VFS_for_FATFS context in cluster %x / ctx %x / fs_type %d\n", 1243 __FUNCTION__, CONFIG_VFS_ROOT_CXY, vfs_for_fatfs_ctx, vfs_for_fatfs_ctx->type ); 1244 #endif 1217 1245 } 1218 1246 else 1219 1247 { 1220 printk("\n[PANIC] in %s : unsupported VFS type in cluster 0\n",1221 __FUNCTION__ );1248 printk("\n[PANIC] in %s : unsupported VFS type in cluster %x\n", 1249 __FUNCTION__ , CONFIG_VFS_ROOT_CXY ); 1222 1250 hal_core_sleep(); 1223 1251 } 1224 1252 1225 // create the <.> and <..> dentries in VFS root directory1253 // 4. create the <.> and <..> dentries in VFS root directory 1226 1254 // the VFS root parent inode is the VFS root inode itself 1227 1255 vfs_add_special_dentries( vfs_root_inode_xp, 1228 1256 vfs_root_inode_xp ); 1229 1257 1230 // register VFS root inode in process_zero descriptor of cluster 0 1231 process_zero.vfs_root_xp = vfs_root_inode_xp; 1232 process_zero.cwd_xp = vfs_root_inode_xp; 1258 // 5. register VFS root inode in target cluster process_zero descriptor 1259 hal_remote_s64( XPTR( CONFIG_VFS_ROOT_CXY , &process_zero.vfs_root_xp ), 1260 vfs_root_inode_xp ); 1261 hal_remote_s64( XPTR( CONFIG_VFS_ROOT_CXY , &process_zero.cwd_xp ), 1262 vfs_root_inode_xp ); 1263 1264 // 6. allocate memory for DEVFS context in VFS_ROOT cluster 1265 xptr_t devfs_ctx_xp = devfs_ctx_alloc( CONFIG_VFS_ROOT_CXY ); 1266 1267 if( devfs_ctx_xp == XPTR_NULL ) 1268 { 1269 printk("\n[PANIC] in %s : cannot create DEVFS context in cluster %x\n", 1270 __FUNCTION__ , CONFIG_VFS_ROOT_CXY ); 1271 hal_core_sleep(); 1272 } 1273 1274 // 7. initialize the VFS context for DEVFS in VFS_ROOT cluster 1275 vfs_ctx_init( CONFIG_VFS_ROOT_CXY, // target cluster 1276 FS_TYPE_DEVFS, // fs type 1277 0, // total_clusters: unused 1278 0, // cluster_size: unused 1279 vfs_root_inode_xp, // VFS root 1280 GET_PTR( devfs_ctx_xp ) ); // extend 1281 1282 #if( DEBUG_KERNEL_INIT & 1 ) 1283 vfs_ctx_t * vfs_for_devfs_ctx = &fs_context[FS_TYPE_DEVFS]; 1284 printk("\n[%s] initialized VFS_for_DEVFS context in cluster %x / ctx %x / fs_type %d\n", 1285 __FUNCTION__, CONFIG_VFS_ROOT_CXY, vfs_for_devfs_ctx, vfs_for_devfs_ctx->type ); 1286 #endif 1287 1288 // 8. create "dev" and "external" inodes (directories) 1289 devfs_global_init( vfs_root_inode_xp, 1290 &devfs_dev_inode_xp, 1291 &devfs_external_inode_xp ); 1292 1293 // 9. initializes DEVFS context in VFS_ROOT cluster 1294 devfs_ctx_init( devfs_ctx_xp, 1295 devfs_dev_inode_xp, 1296 devfs_external_inode_xp ); 1233 1297 } 1234 1298 … … 1240 1304 1241 1305 #if DEBUG_KERNEL_INIT 1242 if( (core_lid == 0) & (local_cxy == 0) ) 1243 printk("\n[%s] exit barrier 6 : VFS root (%x,%x) in cluster 0 / cycle %d\n", 1244 __FUNCTION__, GET_CXY(process_zero.vfs_root_xp), 1245 GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() ); 1246 #endif 1247 1248 ///////////////////////////////////////////////////////////////////////////////// 1249 // STEP 7 : In all other clusters than cluster[0], the core[0] allocates memory 1250 // for the selected FS context, and initialise the local FS context and 1251 // the local VFS context from values stored in cluster 0. 1252 // They get the VFS root inode extended pointer from cluster 0. 1253 ///////////////////////////////////////////////////////////////////////////////// 1254 1255 if( (core_lid == 0) && (local_cxy != 0) ) 1306 if( (core_lid == 0) & (local_cxy == CONFIG_VFS_ROOT_CXY) ) 1307 printk("\n[%s] exit barrier 6 : VFS root inode (%x) created in cluster (%x) / cycle %d\n", 1308 __FUNCTION__, GET_CXY(vfs_root_inode_xp), 1309 GET_PTR(vfs_root_inode_xp), (uint32_t)hal_get_cycles() ); 1310 #endif 1311 1312 ///////////////////////////////////////////////////////////////////////////////// 1313 // STEP 7 : In all clusters other than the VFS_ROOT cluster, the core[0] makes 1314 // the following local actions to complete the VFS initialisation : 1315 // 1. allocate a local context for the selected FS extension, 1316 // 2. copy FS context from VFS_ROOT cluster to local cluster, 1317 // 3. copy VFS_for_FATFS context from VFS_ROOT cluster to local cluster, 1318 // 4. allocate a local context for the DEVFS extension, 1319 // 5. copy DEVFS context from VFS_ROOT cluster to local cluster, 1320 // 6. update the local "root_inode_xp" field in process_zero. 1321 ///////////////////////////////////////////////////////////////////////////////// 1322 1323 if( (core_lid == 0) && (local_cxy != CONFIG_VFS_ROOT_CXY) ) 1256 1324 { 1257 // File System must be FATFS in this implementation,1258 // but other File System can be introduced here1325 // only FATFS is supported yet 1326 // TODO other File System can be introduced below 1259 1327 if( CONFIG_VFS_ROOT_IS_FATFS ) 1260 1328 { 1261 // 1. allocate memory for local FATFS context 1262 fatfs_ctx_t * local_fatfs_ctx = fatfs_ctx_alloc(); 1263 1264 // check memory 1265 if( local_fatfs_ctx == NULL ) 1329 // 1. allocate a local FATFS context extension 1330 xptr_t local_fatfs_ctx_xp = fatfs_ctx_alloc( local_cxy ); 1331 1332 if( local_fatfs_ctx_xp == XPTR_NULL ) 1266 1333 { 1267 1334 printk("\n[PANIC] in %s : cannot create FATFS context in cluster %x\n", … … 1270 1337 } 1271 1338 1272 // 2. get local pointer on VFS context for FATFS 1273 vfs_ctx_t * vfs_ctx = &fs_context[FS_TYPE_FATFS]; 1274 1275 // 3. get local pointer on FATFS context in cluster 0 1276 fatfs_ctx_t * remote_fatfs_ctx = hal_remote_lpt( XPTR( 0 , &vfs_ctx->extend ) ); 1277 1278 // 4. copy FATFS context from cluster 0 to local cluster 1279 hal_remote_memcpy( XPTR( local_cxy , local_fatfs_ctx ), 1280 XPTR( 0 , remote_fatfs_ctx ), sizeof(fatfs_ctx_t) ); 1281 1282 // 5. copy VFS context from cluster 0 to local cluster 1283 hal_remote_memcpy( XPTR( local_cxy , vfs_ctx ), 1284 XPTR( 0 , vfs_ctx ), sizeof(vfs_ctx_t) ); 1285 1286 // 6. update extend field in local copy of VFS context 1287 vfs_ctx->extend = local_fatfs_ctx; 1288 1289 if( ((fatfs_ctx_t *)vfs_ctx->extend)->sectors_per_cluster != 8 ) 1290 { 1291 printk("\n[PANIC] in %s : illegal FATFS context in cluster %x\n", 1292 __FUNCTION__ , local_cxy ); 1293 hal_core_sleep(); 1294 } 1295 } 1296 1297 // get extended pointer on VFS root inode from cluster 0 1298 vfs_root_inode_xp = hal_remote_l64( XPTR( 0 , &process_zero.vfs_root_xp ) ); 1299 1300 // update local process_zero descriptor 1339 // get local pointer on VFS_for_FATFS context (same in all clusters) 1340 vfs_ctx_t * vfs_fat_ctx_ptr = &fs_context[FS_TYPE_FATFS]; 1341 1342 // build extended pointer on VFS_for_FATFS "extend" field in VFS_ROOT cluster 1343 xptr_t fatfs_extend_xp = XPTR( CONFIG_VFS_ROOT_CXY , &vfs_fat_ctx_ptr->extend ); 1344 1345 // get local pointer on FATFS context in VFS_ROOT cluster 1346 fatfs_ctx_t * remote_fatfs_ctx_ptr = hal_remote_lpt( fatfs_extend_xp ); 1347 1348 // build extended pointer on FATFS context in VFS_ROOT cluster 1349 xptr_t remote_fatfs_ctx_xp = XPTR( CONFIG_VFS_ROOT_CXY , remote_fatfs_ctx_ptr ); 1350 1351 // 2. copy FATFS context from VFS_ROOT cluster to local cluster 1352 hal_remote_memcpy( local_fatfs_ctx_xp, 1353 remote_fatfs_ctx_xp, 1354 sizeof(fatfs_ctx_t) ); 1355 1356 // build extended pointer on remote VFS_for_FATFS context 1357 xptr_t remote_vfs_ctx_xp = XPTR( CONFIG_VFS_ROOT_CXY , vfs_fat_ctx_ptr ); 1358 1359 // build extended pointer on local VFS_for_FATFS context 1360 xptr_t local_vfs_ctx_xp = XPTR( local_cxy , vfs_fat_ctx_ptr ); 1361 1362 // 3. copy VFS_for_FATFS context from VFS_ROOT cluster to local cluster 1363 hal_remote_memcpy( local_vfs_ctx_xp, 1364 remote_vfs_ctx_xp, 1365 sizeof(vfs_ctx_t) ); 1366 1367 // update "extend" field in local VFS_for_FATFS context 1368 vfs_fat_ctx_ptr->extend = GET_PTR( local_fatfs_ctx_xp ); 1369 1370 // check local FATFS and VFS context copies 1371 assert( (((fatfs_ctx_t *)vfs_fat_ctx_ptr->extend)->sectors_per_cluster == 8), 1372 "illegal FATFS context in cluster %x\n", local_cxy ); 1373 1374 } 1375 else 1376 { 1377 printk("\n[PANIC] in %s : unsupported VFS type in cluster %x\n", 1378 __FUNCTION__ , local_cxy ); 1379 hal_core_sleep(); 1380 } 1381 1382 // 4. allocate a local DEVFS context extension, 1383 xptr_t local_devfs_ctx_xp = devfs_ctx_alloc( local_cxy ); 1384 1385 // get local pointer on VFS_for_DEVFS context (same in all clusters) 1386 vfs_ctx_t * vfs_dev_ctx_ptr = &fs_context[FS_TYPE_DEVFS]; 1387 1388 // build extended pointer on VFS_for_DEVFS extend field in VFS_ROOT cluster 1389 xptr_t remote_extend_xp = XPTR( CONFIG_VFS_ROOT_CXY , &vfs_dev_ctx_ptr->extend ); 1390 1391 // get local pointer on DEVFS context in VFS_ROOT cluster 1392 devfs_ctx_t * remote_devfs_ctx_ptr = hal_remote_lpt( remote_extend_xp ); 1393 1394 // build extended pointer on FATFS context in VFS_ROOT cluster 1395 xptr_t remote_devfs_ctx_xp = XPTR( CONFIG_VFS_ROOT_CXY , remote_devfs_ctx_ptr ); 1396 1397 // 5. copy DEVFS context from VFS_ROOT cluster to local cluster 1398 hal_remote_memcpy( local_devfs_ctx_xp, 1399 remote_devfs_ctx_xp, 1400 sizeof(devfs_ctx_t) ); 1401 1402 // update "extend" field in local VFS_for_DEVFS context 1403 vfs_dev_ctx_ptr->extend = GET_PTR( local_devfs_ctx_xp ); 1404 1405 // get extended pointer on VFS root inode from VFS_ROOT cluster 1406 vfs_root_inode_xp = hal_remote_l64( XPTR( CONFIG_VFS_ROOT_CXY, 1407 &process_zero.vfs_root_xp ) ); 1408 1409 // 6. update local process_zero descriptor 1301 1410 process_zero.vfs_root_xp = vfs_root_inode_xp; 1302 1411 process_zero.cwd_xp = vfs_root_inode_xp; … … 1310 1419 1311 1420 #if DEBUG_KERNEL_INIT 1312 if( (core_lid == 0) & (local_cxy == 1) ) 1313 printk("\n[%s] exit barrier 7 : VFS root (%x,%x) in cluster 1 / cycle %d\n", 1314 __FUNCTION__, GET_CXY(process_zero.vfs_root_xp), 1315 GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() ); 1316 #endif 1317 1318 ///////////////////////////////////////////////////////////////////////////////// 1319 // STEP 8 : core[0] in cluster 0 makes the global DEVFS initialisation: 1320 // It initializes the DEVFS context, and creates the DEVFS 1321 // "dev" and "external" inodes in cluster 0. 1322 ///////////////////////////////////////////////////////////////////////////////// 1323 1324 if( (core_lid == 0) && (local_cxy == 0) ) 1421 if( (core_lid == 0) & (local_cxy == 0) ) 1422 printk("\n[%s] exit barrier 7 : VFS & DEVFS contexts replicated in all clusters / cycle %d\n", 1423 __FUNCTION__ , (uint32_t)hal_get_cycles() ); 1424 #endif 1425 1426 ///////////////////////////////////////////////////////////////////////////////// 1427 // STEP 8 : In all clusters in parallel, core[0] completes DEVFS initialization. 1428 // Each core[0] creates the local DEVFS "internal" directory, 1429 // and creates the pseudo-files for chdevs placed in local cluster. 1430 ///////////////////////////////////////////////////////////////////////////////// 1431 1432 if( core_lid == 0 ) 1325 1433 { 1326 // 1. allocate memory for DEVFS context extension in cluster 0 1327 devfs_ctx_t * devfs_ctx = devfs_ctx_alloc(); 1328 1329 if( devfs_ctx == NULL ) 1330 { 1331 printk("\n[PANIC] in %s : cannot create DEVFS context in cluster 0\n", 1332 __FUNCTION__ , local_cxy ); 1333 hal_core_sleep(); 1334 } 1335 1336 // 2. initialize the DEVFS entry in the vfs_context[] array 1337 vfs_ctx_init( FS_TYPE_DEVFS, // fs type 1338 0, // attributes: unused 1339 0, // total_clusters: unused 1340 0, // cluster_size: unused 1341 vfs_root_inode_xp, // VFS root 1342 devfs_ctx ); // extend 1343 1344 // 3. create "dev" and "external" inodes (directories) 1345 devfs_global_init( process_zero.vfs_root_xp, 1346 &devfs_dev_inode_xp, 1347 &devfs_external_inode_xp ); 1348 1349 // 4. initializes DEVFS context extension 1350 devfs_ctx_init( devfs_ctx, 1351 devfs_dev_inode_xp, 1352 devfs_external_inode_xp ); 1353 } 1434 // get local pointer on local DEVFS context 1435 devfs_ctx_t * ctx = fs_context[FS_TYPE_DEVFS].extend; 1436 1437 // populate DEVFS in all clusters 1438 devfs_local_init( ctx->dev_inode_xp, 1439 ctx->external_inode_xp ); 1440 } 1354 1441 1355 1442 ///////////////////////////////////////////////////////////////////////////////// … … 1361 1448 #if DEBUG_KERNEL_INIT 1362 1449 if( (core_lid == 0) & (local_cxy == 0) ) 1363 printk("\n[%s] exit barrier 8 : DEVFS root initialized in cluster 0 / cycle %d\n", 1364 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1365 #endif 1366 1367 ///////////////////////////////////////////////////////////////////////////////// 1368 // STEP 9 : In all clusters in parallel, core[0] completes DEVFS initialization. 1369 // Each core[0] get the "dev" and "external" extended pointers from 1370 // values stored in cluster(0), creates the DEVFS "internal" directory, 1371 // and creates the pseudo-files for all chdevs in local cluster. 1372 ///////////////////////////////////////////////////////////////////////////////// 1373 1374 if( core_lid == 0 ) 1375 { 1376 // get extended pointer on "extend" field of VFS context for DEVFS in cluster 0 1377 xptr_t extend_xp = XPTR( 0 , &fs_context[FS_TYPE_DEVFS].extend ); 1378 1379 // get pointer on DEVFS context in cluster 0 1380 devfs_ctx_t * devfs_ctx = hal_remote_lpt( extend_xp ); 1381 1382 devfs_dev_inode_xp = hal_remote_l64( XPTR( 0 , &devfs_ctx->dev_inode_xp ) ); 1383 devfs_external_inode_xp = hal_remote_l64( XPTR( 0 , &devfs_ctx->external_inode_xp ) ); 1384 1385 // populate DEVFS in all clusters 1386 devfs_local_init( devfs_dev_inode_xp, 1387 devfs_external_inode_xp, 1388 &devfs_internal_inode_xp ); 1389 } 1390 1391 ///////////////////////////////////////////////////////////////////////////////// 1392 if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 1393 (info->x_size * info->y_size) ); 1394 barrier_wait( &local_barrier , info->cores_nr ); 1395 ///////////////////////////////////////////////////////////////////////////////// 1396 1397 #if DEBUG_KERNEL_INIT 1398 if( (core_lid == 0) & (local_cxy == 0) ) 1399 printk("\n[%s] exit barrier 9 : DEVFS initialized in cluster 0 / cycle %d\n", 1450 printk("\n[%s] exit barrier 8 : DEVFS initialized in all clusters / cycle %d\n", 1400 1451 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1401 1452 #endif … … 1407 1458 1408 1459 ///////////////////////////////////////////////////////////////////////////////// 1409 // STEP 10: core[0] in cluster 0 creates the first user process (process_init).1410 // This include the first userprocess VMM (GPT and VSL) creation.1411 // 1460 // STEP 9 : core[0] in cluster 0 creates the first user process (process_init). 1461 // This include the process VMM (GPT and VSL) creation. 1462 // Finally, it prints the ALMOS-MKH banner. 1412 1463 ///////////////////////////////////////////////////////////////////////////////// 1413 1464 … … 1419 1470 #if DEBUG_KERNEL_INIT 1420 1471 if( (core_lid == 0) & (local_cxy == 0) ) 1421 printk("\n[%s] exit barrier 10: process_init created in cluster 0 / cycle %d\n",1472 printk("\n[%s] exit barrier 9 : process_init created in cluster 0 / cycle %d\n", 1422 1473 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1423 1474 #endif
Note: See TracChangeset
for help on using the changeset viewer.