Changeset 590 for soft/giet_vm/giet_boot
- Timestamp:
- Jul 8, 2015, 4:00:08 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_boot/boot.c
r578 r590 132 132 //////////////////////////////////////////////////////////////////////////// 133 133 134 // FAT internal representation for boot code135 __attribute__((section(".kdata")))136 fat32_fs_t _fat __attribute__((aligned(512)));137 138 134 // Temporaty buffer used to load one complete .elf file 139 135 __attribute__((section(".kdata"))) 140 char _boot_elf_buffer[GIET_ELF_BUFFER_SIZE] __attribute__((aligned(512)));136 unsigned char _boot_elf_buffer[GIET_ELF_BUFFER_SIZE] __attribute__((aligned(64))); 141 137 142 138 // Physical memory allocators array (one per cluster) 143 139 __attribute__((section(".kdata"))) 144 140 pmem_alloc_t boot_pmem_alloc[X_SIZE][Y_SIZE]; 145 146 // Distributed kernel heap (one per cluster)147 // __attribute__((section(".kdata")))148 // kernel_heap_t kernel_heap[X_SIZE][Y_SIZE];149 141 150 142 // Schedulers virtual base addresses array (one per processor) … … 1336 1328 void boot_mapping_init() 1337 1329 { 1338 // open file "map.bin"1339 i nt fd_id = _fat_open( 0, "map.bin", 0 ); // no IRQ / no creation1340 1341 if ( fd_id == -1)1330 // load map.bin file into buffer 1331 if ( _fat_load_no_cache( "map.bin", 1332 SEG_BOOT_MAPPING_BASE, 1333 SEG_BOOT_MAPPING_SIZE ) ) 1342 1334 { 1343 1335 _printf("\n[BOOT ERROR] : map.bin file not found \n"); 1344 1336 _exit(); 1345 1337 } 1346 1347 #if BOOT_DEBUG_MAPPING1348 _printf("\n[BOOT] map.bin file successfully open at cycle %d\n",1349 _get_proctime() );1350 #endif1351 1352 // get "map.bin" file size (from fat) and check it1353 unsigned int size = _fat.fd[fd_id].file_size;1354 1355 if ( size > SEG_BOOT_MAPPING_SIZE )1356 {1357 _printf("\n[BOOT ERROR] : segment too small for map.bin file\n");1358 _exit();1359 }1360 1361 #if BOOT_DEBUG_MAPPING1362 _printf("\n[BOOT] map.bin buf_pbase = %x / buf_size = %x / file_size = %x\n",1363 SEG_BOOT_MAPPING_BASE , SEG_BOOT_MAPPING_SIZE , size );1364 #endif1365 1366 // load "map.bin" file into buffer1367 unsigned int nblocks = size >> 9;1368 unsigned int offset = size & 0x1FF;1369 if ( offset ) nblocks++;1370 1371 unsigned int ok = _fat_read( 0, // No IRQ1372 fd_id,1373 (unsigned int*)SEG_BOOT_MAPPING_BASE,1374 nblocks,1375 0 ); // offset1376 if ( ok == -1 )1377 {1378 _printf("\n[BOOT ERROR] : unable to load map.bin file \n");1379 _exit();1380 }1381 1382 #if BOOT_DEBUG_MAPPING1383 _printf("\n[BOOT] map.bin file successfully loaded at cycle %d\n", _get_proctime() );1384 #endif1385 1338 1386 1339 // check mapping signature, number of clusters, number of vspaces … … 1391 1344 (header->vspaces > GIET_NB_VSPACE_MAX) ) 1392 1345 { 1393 _printf("\n[BOOT ERROR] Illegal mapping signature:%x\n", header->signature );1346 _printf("\n[BOOT ERROR] Illegal mapping : signature = %x\n", header->signature ); 1394 1347 _exit(); 1395 1348 } … … 1401 1354 for ( line = 0 ; line < 8 ; line++ ) 1402 1355 { 1403 _printf(" | % x | %x | %x | %x | %x | %x | %x | %x|\n",1356 _printf(" | %X | %X | %X | %X | %X | %X | %X | %X |\n", 1404 1357 *(pointer + 0), 1405 1358 *(pointer + 1), … … 1415 1368 #endif 1416 1369 1417 #if BOOT_DEBUG_MAPPING1418 _printf("\n[BOOT] map.bin file checked at cycle %d\n", _get_proctime() );1419 #endif1420 1421 // close file "map.bin"1422 _fat_close( fd_id );1423 1424 1370 } // end boot_mapping_init() 1425 1371 … … 1517 1463 Elf32_Ehdr* elf_header_ptr = NULL; // avoid a warning 1518 1464 1519 int fd_id = 0; // avoid a warning 1520 1521 // only P[0,0,0] load file from FAT 1465 // only P[0,0,0] load file 1522 1466 if ( (cxy == 0) && (p == 0) ) 1523 1467 { 1524 // open .elf file 1525 fd_id = _fat_open( 0 , pathname , 0 ); // no IRQ / no creation 1526 1527 if ( fd_id < 0 ) 1528 { 1529 _printf("\n[BOOT ERROR] load_one_elf_file() : %s not found\n", 1530 pathname ); 1531 _exit(); 1532 } 1533 1534 // check buffer size versus file size 1535 if ( _fat.fd[fd_id].file_size > GIET_ELF_BUFFER_SIZE ) 1536 { 1537 _printf("\n[BOOT ERROR] in load_one_elf_file() : %s / size = %x " 1538 "larger than GIET_ELF_BUFFER_SIZE = %x\n", 1539 pathname , _fat.fd[fd_id].file_size , GIET_ELF_BUFFER_SIZE ); 1540 _exit(); 1541 } 1542 1543 // compute number of sectors 1544 unsigned int nbytes = _fat.fd[fd_id].file_size; 1545 unsigned int nsectors = nbytes>>9; 1546 if( nbytes & 0x1FF) nsectors++; 1547 1548 // load file to elf buffer 1549 if( _fat_read( 0, // no IRQ 1550 fd_id, 1551 _boot_elf_buffer, 1552 nsectors, 1553 0 ) != nsectors ) // offset 1554 { 1555 _printf("\n[BOOT ERROR] load_one_elf_file() : unexpected EOF for %s\n", 1556 pathname ); 1468 if ( _fat_load_no_cache( pathname, 1469 (unsigned int)_boot_elf_buffer, 1470 GIET_ELF_BUFFER_SIZE ) ) 1471 { 1472 _printf("\n[BOOT ERROR] in load_one_elf_file() : %s\n", pathname ); 1557 1473 _exit(); 1558 1474 } … … 1656 1572 { 1657 1573 _printf("\n[BOOT ERROR] in load_one_elf_file() : vseg %s " 1658 "is to small for loadable segment %x in file %s\n", 1659 vseg[vseg_id].name , seg_vaddr , pathname ); 1574 "is too small for segment %x\n" 1575 " file = %s / vseg_size = %x / seg_file_size = %x\n", 1576 vseg[vseg_id].name , seg_vaddr , pathname, 1577 seg_size , seg_filesz ); 1660 1578 _exit(); 1661 1579 } … … 1708 1626 ////////////////////////////////////////////// 1709 1627 1710 // only P[0,0,0] close the file1628 // only P[0,0,0] signals completion 1711 1629 if ( (cxy == 0) && (p == 0) ) 1712 1630 { 1713 // close .elf file1714 _fat_close( fd_id );1715 1716 1631 _printf("\n[BOOT] File %s loaded at cycle %d\n", 1717 1632 pathname , _get_proctime() ); … … 1885 1800 1886 1801 // initialises the FAT 1887 _fat_init( 0 ); // no IRQ1802 _fat_init( 0 ); // don't use Inode-Tree, Fat-Cache, etc. 1888 1803 1889 1804 _printf("\n[BOOT] FAT initialised at cycle %d\n", _get_proctime() );
Note: See TracChangeset
for help on using the changeset viewer.