- Timestamp:
- May 28, 2015, 3:34:23 PM (9 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r573 r580 9 9 10 10 # Parameters definition 11 ARCH ?= ../tsar-trunk-svn-2013/platforms/tsar_generic_iob 12 X_SIZE ?= 1 13 Y_SIZE ?= 1 11 #ARCH ?= ../tsar-trunk-svn-2013/platforms/tsar_generic_iob 12 ARCH ?= ../../../tsar/platforms/tsar_generic_iob 13 X_SIZE ?= 2 14 Y_SIZE ?= 2 14 15 NB_PROCS ?= 4 15 NB_TTYS ?= 216 FBF_WIDTH ?= 25617 IOC_TYPE ?= BDV18 APP ?= transpose19 20 21 .PHONY: map.bin 16 NB_TTYS ?= 1 17 FBF_WIDTH ?= 128 18 IOC_TYPE ?= HBA 19 APP ?= ocean 20 21 22 .PHONY: map.bin build clean 22 23 23 24 ### FAT parameters definition for Disk image … … 26 27 ### sector_per_cluster = 8 27 28 ### partition sectors = 524832 29 30 BUILD_DIRS = boot \ 31 classif \ 32 common \ 33 convol \ 34 coproc \ 35 dhrystone \ 36 display \ 37 drivers \ 38 fat32 \ 39 gameoflife\ 40 hello \ 41 kernel \ 42 libs/math \ 43 ocean \ 44 pgcd \ 45 router \ 46 sort \ 47 transpose 28 48 29 49 ### Objects to be linked for the drivers library … … 75 95 build/boot/boot_entry.o 76 96 97 MATH_OBJ = build/libs/math/e_pow.o \ 98 build/libs/math/e_rem_pio2.o \ 99 build/libs/math/k_cos.o \ 100 build/libs/math/k_rem_pio2.o \ 101 build/libs/math/k_sin.o \ 102 build/libs/math/s_copysign.o \ 103 build/libs/math/s_fabs.o \ 104 build/libs/math/s_finite.o \ 105 build/libs/math/s_floor.o \ 106 build/libs/math/s_isnan.o \ 107 build/libs/math/sqrt.o \ 108 build/libs/math/s_rint.o \ 109 build/libs/math/s_scalbn.o \ 110 build/libs/math/s_sin.o 111 # build/libs/math/e_sqrt.o \ 112 77 113 ### Objects to be linked for display.elf 78 114 DISPLAY_OBJS = build/display/main.o \ … … 144 180 build/libs/stdio.o 145 181 182 183 ### Objects to be linked for ocean.elf 184 OCEAN_OBJS = build/libs/stdio.o \ 185 build/libs/malloc.o \ 186 build/libs/stdlib.o \ 187 build/libs/user_sqt_lock.o\ 188 build/libs/user_lock.o \ 189 build/libs/user_barrier.o \ 190 build/libs/libmath.a 191 192 146 193 CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g -O2 \ 147 194 -fno-delete-null-pointer-checks … … 162 209 DISK_IMAGE := hdd/virt_hdd.dmg 163 210 164 all: $(DISK_IMAGE)\211 all: build \ 165 212 map.bin \ 166 213 hard_config.h \ … … 179 226 build/classif/classif.elf \ 180 227 build/coproc/coproc.elf \ 181 182 mdir -/ -b -i $(DISK_IMAGE) ::/ 183 184 ### copy the files generated by the virtual prototype on 185 ### the virtual disk "home" directory to the giet_vm home directory 186 extract: 187 mcopy -o -i $(DISK_IMAGE) ::/home . 228 build/ocean/ocean.elf \ 229 $(DISK_IMAGE) 230 ### Copy always all files into disk image 231 mcopy -o -i $(DISK_IMAGE) build/kernel/kernel.elf ::/build/kernel 232 mcopy -o -i $(DISK_IMAGE) build/display/display.elf ::/build/display 233 mcopy -o -i $(DISK_IMAGE) build/hello/hello.elf ::/build/hello 234 mcopy -o -i $(DISK_IMAGE) build/pgcd/pgcd.elf ::/build/pgcd 235 mcopy -o -i $(DISK_IMAGE) build/router/router.elf ::/build/router 236 mcopy -o -i $(DISK_IMAGE) build/dhrystone/dhrystone.elf ::/build/dhrystone 237 mcopy -o -i $(DISK_IMAGE) build/gameoflife/gameoflife.elf ::/build/gameoflife 238 mcopy -o -i $(DISK_IMAGE) build/sort/sort.elf ::/build/sort 239 mcopy -o -i $(DISK_IMAGE) build/transpose/transpose.elf ::/build/transpose 240 mcopy -o -i $(DISK_IMAGE) build/convol/convol.elf ::/build/convol 241 mcopy -o -i $(DISK_IMAGE) build/classif/classif.elf ::/build/classif 242 mcopy -o -i $(DISK_IMAGE) build/coproc/coproc.elf ::/build/coproc 243 mcopy -o -i $(DISK_IMAGE) build/ocean/ocean.elf ::/build/ocean 244 mcopy -o -i $(DISK_IMAGE) applications/transpose/images.raw ::/misc 245 mcopy -o -i $(DISK_IMAGE) applications/convol/philips_image.raw ::/misc 246 mcopy -o -i $(DISK_IMAGE) map.bin ::/ 247 ### Copy bootloader into sector 2 of disk image 248 dd if=build/boot/boot.elf of=$(DISK_IMAGE) seek=2 conv=notrunc 249 ### Checking root directory 250 mdir -/ -b -i $(DISK_IMAGE) ::/ 251 252 253 build: 254 mkdir -p build 255 (cd build && mkdir -p $(BUILD_DIRS)) 188 256 189 257 ### Disk image generation (no files in this step) … … 197 265 mv temp.dmg $(DISK_IMAGE) 198 266 mmd -o -i $(DISK_IMAGE) ::/build 267 mmd -o -i $(DISK_IMAGE) ::/build/ocean 199 268 mmd -o -i $(DISK_IMAGE) ::/misc 200 269 mmd -o -i $(DISK_IMAGE) ::/home … … 452 521 $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< 453 522 523 build/libs/user_sqt_lock.o: giet_libs/user_sqt_lock.c \ 524 giet_libs/user_sqt_lock.h \ 525 giet_libs/user_lock.h \ 526 hard_config.h \ 527 giet_config.h 528 $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< 529 530 build/libs/libmath.a: $(MATH_OBJ) 531 $(AR) -rcs $@ $^ 532 533 build/libs/math/%.o: giet_libs/math/%.c giet_libs/math/math_private.h giet_libs/math.h 534 $(CC) $(CFLAGS) $(USER_INCLUDE) -c -o $@ $< 535 454 536 ######################################## 455 537 ### display application compilation … … 460 542 mcopy -o -i $(DISK_IMAGE) $@ ::/build/display 461 543 462 build/display/main.o: applications/display/main.c 544 build/display/main.o: applications/display/main.c hard_config.h 463 545 $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< 464 546 … … 471 553 mcopy -o -i $(DISK_IMAGE) $@ ::/build/router 472 554 473 build/router/main.o: applications/router/main.c 555 build/router/main.o: applications/router/main.c hard_config.h 474 556 $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< 475 557 … … 482 564 mcopy -o -i $(DISK_IMAGE) $@ ::/build/hello 483 565 484 build/hello/main.o: applications/hello/main.c 566 build/hello/main.o: applications/hello/main.c hard_config.h 485 567 $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< 486 568 … … 493 575 mcopy -o -i $(DISK_IMAGE) $@ ::/build/pgcd 494 576 495 build/pgcd/main.o: applications/pgcd/main.c 577 build/pgcd/main.o: applications/pgcd/main.c hard_config.h 496 578 $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< 497 579 … … 515 597 mcopy -o -i $(DISK_IMAGE) $@ ::/build/dhrystone 516 598 517 build/dhrystone/dhry_1.o: applications/dhrystone/dhry_1.c 599 build/dhrystone/dhry_1.o: applications/dhrystone/dhry_1.c hard_config.h 518 600 $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< 519 601 520 build/dhrystone/dhry_2.o: applications/dhrystone/dhry_2.c 602 build/dhrystone/dhry_2.o: applications/dhrystone/dhry_2.c hard_config.h 521 603 $(CC) $(USER_INCLUDE) $(CFLAGS) -c -o $@ $< 522 604 … … 575 657 build/coproc/main.o: applications/coproc/main.c 576 658 $(CC) $(USER_INCLUDE) $(CFLAGS) -O0 -c -o $@ $< 659 660 ######################################## 661 ### ocean compilation 662 build/ocean/ocean.elf: applications/ocean/ocean.elf 663 mv $< $@ 664 $(DU) -D $@ > $@.txt 665 666 applications/ocean/ocean.elf: $(OCEAN_OBJS) 667 cd applications/ocean/ && $(MAKE) 577 668 578 669 ######################################## … … 581 672 rm -f *.o *.elf *.bin *.txt core 582 673 rm -f hard_config.h giet_vsegs.ld map.bin map.xml 583 rm -rf build/boot/* 584 rm -rf build/fat32/* 585 rm -rf build/common/* 586 rm -rf build/drivers/* 587 rm -rf build/kernel/* 588 rm -rf build/reset/* 589 rm -rf build/libs/* 590 rm -rf build/pgcd/* 591 rm -rf build/hello/* 592 rm -rf build/display/* 593 rm -rf build/router/* 594 rm -rf build/gameoflife/* 595 rm -rf build/dhrystone/* 596 rm -rf build/sort/* 597 rm -rf build/transpose/* 598 rm -rf build/convol/* 599 rm -rf build/classif/* 600 rm -rf build/coproc/* 674 rm -rf build/ 675 cd applications/ocean && $(MAKE) clean -
soft/giet_vm/giet_libs/stdio.c
r558 r580 142 142 { 143 143 int ret; // return value from the syscall 144 enum TModifiers {NO_MOD, L_MOD, LL_MOD} modifiers; 144 145 145 146 printf_text: … … 164 165 { 165 166 format++; 167 modifiers = NO_MOD; 166 168 goto printf_arguments; 167 169 } … … 173 175 174 176 { 175 char buf[ 20];177 char buf[30]; 176 178 char * pbuf; 177 179 unsigned int len = 0; 178 180 static const char HexaTab[] = "0123456789ABCDEF"; 179 181 unsigned int i; 182 183 /* Ignored fields : width and precision */ 184 for (; *format >= '0' && *format <= '9'; format++); 180 185 181 186 switch (*format++) 182 187 { 188 case ('%'): 183 189 case ('c'): /* char conversion */ 184 190 { 185 191 int val = va_arg( *args, int ); 192 if (modifiers != NO_MOD) goto return_error; //Modifiers have no meaning 193 186 194 len = 1; 187 195 buf[0] = val; … … 189 197 break; 190 198 } 191 case ('d'): /* 32 bitsdecimal signed integer */199 case ('d'): /* decimal signed integer */ 192 200 { 193 201 int val = va_arg( *args, int ); 202 203 if (modifiers == LL_MOD) goto return_error; //64 bits not supported 204 194 205 if (val < 0) 195 206 { … … 211 222 break; 212 223 } 213 case ('u'): /* 32 bitsdecimal unsigned integer */224 case ('u'): /* decimal unsigned integer */ 214 225 { 215 unsigned int val = va_arg( *args, unsigned int ); 216 for(i = 0; i < 10; i++) 217 { 218 buf[9 - i] = HexaTab[val % 10]; 219 if (!(val /= 10)) break; 220 } 221 len = i + 1; 222 pbuf = &buf[9 - i]; 223 break; 226 if (modifiers != LL_MOD) //32 bits integer 227 { 228 unsigned int val = va_arg( *args, unsigned int ); 229 for(i = 0; i < 10; i++) 230 { 231 buf[9 - i] = HexaTab[val % 10]; 232 if (!(val /= 10)) break; 233 } 234 len = i + 1; 235 pbuf = &buf[9 - i]; 236 break; 237 } 238 //64 bits : base 10 unsupported : continue to hexa 224 239 } 225 case ('x'): /* 32 bits hexadecimal integer */ 240 case ('x'): 241 case ('X'): /* hexadecimal integer */ 226 242 { 227 unsigned int val = va_arg( *args, unsigned int ); 228 ret = sys_call(SYSCALL_TTY_WRITE, 229 (unsigned int)"0x", 230 2, 231 channel, 232 0); 233 if (ret != 2) goto return_error; 234 for(i = 0; i < 8; i++) 235 { 236 buf[7 - i] = HexaTab[val % 16]; 237 if (!(val /= 16)) break; 238 } 239 len = i + 1; 240 pbuf = &buf[7 - i]; 241 break; 242 } 243 case ('l'): /* 64 bits hexadecimal unsigned */ 244 { 245 unsigned long long val = va_arg( *args, unsigned long long ); 243 unsigned long long val; 244 int imax; 245 246 if (modifiers == LL_MOD) //64 bits 247 { 248 val = va_arg( *args, unsigned long long); 249 250 if (*(format-1) == 'u' && (!(val & 0xFFFFFFFF00000000))) //if asked to print in base 10, can do only if it fits in 32 bits 251 { 252 unsigned int uintv = (unsigned int) val; 253 254 for(i = 0; i < 10; i++) 255 { 256 buf[9 - i] = HexaTab[uintv % 10]; 257 if (!(uintv /= 10)) break; 258 } 259 len = i + 1; 260 pbuf = &buf[9 - i]; 261 break; 262 } 263 264 imax = 16; 265 } 266 else //32 bits 267 { 268 val = va_arg( *args, unsigned int); 269 imax = 8; 270 } 271 246 272 ret = sys_call(SYSCALL_TTY_WRITE, 247 273 (unsigned int)"0x", … … 250 276 0); 251 277 if (ret != 2) goto return_error; 252 for(i = 0; i < 16; i++) 253 { 254 buf[15 - i] = HexaTab[val % 16]; 278 279 for(i = 0; i < imax; i++) 280 { 281 buf[(imax-1) - i] = HexaTab[val % 16]; 255 282 if (!(val /= 16)) break; 256 283 } 257 284 len = i + 1; 258 pbuf = &buf[ 15- i];285 pbuf = &buf[(imax-1) - i]; 259 286 break; 260 287 } … … 262 289 { 263 290 char* str = va_arg( *args, char* ); 291 292 if (modifiers != NO_MOD) goto return_error; //Modifiers have no meaning 293 264 294 while (str[len]) 265 295 { … … 269 299 break; 270 300 } 301 case ('e'): 302 case ('f'): 303 case ('g'): /* IEEE754 64 bits */ 304 { 305 306 double vald = va_arg( *args, double); 307 308 unsigned long long 309 val = *(unsigned long long*)&vald, //get ieee754 without conversion 310 digits = val & 0xFFFFFFFFFFFFF; //get mantissa 311 312 unsigned int 313 base = (unsigned int)((val & 0x7FF0000000000000) >> 52), //get exposant 314 intp = (unsigned int)vald, //get integer part of the float 315 decp; 316 317 int isvalue = 0; 318 319 if (base == 0x7FF) //special value 320 { 321 if (digits & 0xFFFFFFFFFFFFF) 322 { 323 /* Not a Number */ 324 buf[0] = 'N'; 325 buf[1] = 'a'; 326 buf[2] = 'N'; 327 len = 3; 328 pbuf = buf; 329 } 330 else 331 { 332 /* inf */ 333 buf[0] = (val & 0x8000000000000000) ? '-' : '+'; 334 buf[1] = 'i'; 335 buf[2] = 'n'; 336 buf[3] = 'f'; 337 len = 4; 338 pbuf = buf; 339 } 340 break; 341 } 342 343 if (val & 0x8000000000000000) 344 { 345 /* negative */ 346 ret = sys_call(SYSCALL_TTY_WRITE, 347 (unsigned int)"-", 348 1, 349 channel, 350 0); 351 if (ret != 1) goto return_error; 352 vald = vald * -1; 353 } 354 else 355 { 356 /* positive */ 357 ret = sys_call(SYSCALL_TTY_WRITE, 358 (unsigned int)"+", 359 1, 360 channel, 361 0); 362 if (ret != 1) goto return_error; 363 } 364 365 if (vald > 0xFFFFFFFF) 366 { 367 /* overflow */ 368 buf[0] = 'B'; 369 buf[1] = 'I'; 370 buf[2] = 'G'; 371 len = 3; 372 pbuf = buf; 373 break; 374 } 375 376 vald -= (double)intp; 377 decp = (unsigned int)(vald * 100000000); 378 379 for(i = 0; i < 10; i++) 380 { 381 if ((!isvalue) && (intp % 10)) isvalue = 1; 382 buf[9 - i] = HexaTab[intp % 10]; 383 if (!(intp /= 10)) break; 384 } 385 pbuf = &buf[9 - i]; 386 len = i+11; 387 buf[10] = '.'; 388 389 for(i = 0; i < 9; i++) 390 { 391 if ((!isvalue) && (decp % 10)) isvalue = 1; 392 buf[19 - i] = HexaTab[decp % 10]; 393 decp /= 10; 394 } 395 396 if (!isvalue) 397 { 398 if (vald != 0) 399 { 400 /* underflow */ 401 buf[0] = 'T'; 402 buf[1] = 'I'; 403 buf[2] = 'N'; 404 buf[3] = 'Y'; 405 len = 4; 406 pbuf = buf; 407 } 408 } 409 410 break; 411 } 412 case ('l'): 413 switch (modifiers) 414 { 415 case NO_MOD: 416 modifiers = L_MOD; 417 goto printf_arguments; 418 419 case L_MOD: 420 modifiers = LL_MOD; 421 goto printf_arguments; 422 423 default: 424 goto return_error; 425 } 426 427 /* Ignored fields : width and precision */ 428 case ('.'): goto printf_arguments; 429 271 430 default: 272 431 goto return_error; -
soft/giet_vm/giet_libs/stdlib.c
r382 r580 9 9 10 10 /////////////////////////////////////////////////////////////////////////////////// 11 int atoi(c har *str)11 int atoi(const char *str) 12 12 /////////////////////////////////////////////////////////////////////////////////// 13 13 { … … 30 30 return sign*res; 31 31 } 32 33 /////////////////////////////////////////////////////////////////////////////////// 34 double atof(const char *str) 35 /////////////////////////////////////////////////////////////////////////////////// 36 { 37 const char *pstr = str; 38 double res = 0; 39 double exp = 0.1; 40 short sign = 1; 41 short dec = 0; 42 43 while (*pstr != '\0') 44 { 45 if (*pstr == '-') 46 { 47 if (str != pstr) break; 48 sign = -1; 49 } 32 50 51 else if (*pstr == '.') 52 { 53 if (dec) break; 54 dec = 1; 55 } 56 57 else if (*pstr >= '0' && *pstr <= '9') 58 { 59 if (dec) 60 { 61 res = res + ((*pstr - '0')*exp); 62 exp = exp / 10; 63 } 64 else 65 { 66 res = (res * 10) + (*pstr - '0'); 67 } 68 } 69 70 else 71 { 72 break; 73 } 74 pstr++; 75 } 76 return sign * res; 77 } 78 33 79 //////////////////////////////////////////////////////////////////////////////////////// 34 80 void * memcpy(void *_dst, const void * _src, unsigned int size) -
soft/giet_vm/giet_libs/stdlib.h
r382 r580 13 13 // For a negative value, the first character must be a '-' (minus) character. 14 14 //////////////////////////////////////////////////////////////////////////////////////// 15 int atoi ( char * str ); 15 int atoi ( const char * str ); 16 17 //////////////////////////////////////////////////////////////////////////////////////// 18 // This function translate a character string to a double. 19 // For a negative value, the first character must be a '-' (minus) character. 20 //////////////////////////////////////////////////////////////////////////////////////// 21 double atof ( const char * str ); 16 22 17 23 //////////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_libs/user_barrier.c
r541 r580 214 214 // compute SQT levels 215 215 unsigned int levels; 216 unsigned int side;217 216 unsigned int z = (x_size > y_size) ? x_size : y_size; 218 217 levels = (z < 2) ? 1 : (z < 3) ? 2 : (z < 5) ? 3 : (z < 9) ? 4 : 5; 218 219 #if GIET_DEBUG_USER_BARRIER 220 unsigned int side; 219 221 side = (z < 2) ? 1 : (z < 3) ? 2 : (z < 5) ? 4 : (z < 9) ? 8 : 16; 220 221 #if GIET_DEBUG_USER_BARRIER222 222 giet_shr_printf("\n[DEBUG USER BARRIER] sqt_nodes allocation\n" 223 223 " x_size = %d / y_size = %d / levels = %d / side = %d\n", … … 286 286 giet_proc_xyp( &px, &py, &pl ); 287 287 giet_shr_printf("\n[DEBUG USER BARRIER] P[%d,%d,%d] decrement SQT barrier node %x :\n" 288 " level = %d / arity = %d / sense = %d / count = %d\n",288 " level = %d / parent = %x / arity = %d / sense = %d / count = %d\n", 289 289 px , py , pl , (unsigned int)node , 290 node->level , node-> arity , node->sense , node->count );290 node->level , node->parent, node->arity , node->sense , node->count ); 291 291 #endif 292 292 293 293 // compute expected sense value 294 294 unsigned int expected; 295 295 296 if ( node->sense == 0) expected = 1; 296 297 else expected = 0; … … 312 313 : "r" (pcount) 313 314 : "$2", "$8", "$9", "memory" ); 314 315 315 316 if ( count == 1 ) // last task 316 317 { 317 318 // decrement the parent node if the current node is not the root 318 if ( node->parent != NULL ) 319 if ( node->parent != NULL ) { 319 320 sqt_barrier_decrement( node->parent ); 321 } 320 322 321 323 // reset the current node … … 355 357 unsigned int lpid; 356 358 giet_proc_xyp( &x, &y, &lpid ); 359 #if GIET_DEBUG_USER_BARRIER 360 giet_shr_printf("[DEBUG SQT USER BARRIER] proc[%d,%d,%d] enters sqt_barrier_wait(). vaddr=%x. node=%x\n", 361 x, y, lpid, barrier, barrier->node[x][y][0] ); 362 #endif 357 363 358 364 // recursively decrement count from bottom to root -
soft/giet_vm/giet_python/genmap
r565 r580 134 134 help = 'map the "coproc" application for the GietVM' ) 135 135 136 parser.add_option( '--ocean', action = 'store_true', dest = 'ocean', 137 default = False, 138 help = 'map the "ocean" application for the GietVM' ) 139 136 140 ################################################################################### 137 141 # Get command line arguments … … 167 171 map_gameoflife = options.gameoflife # map "gameoflife" application if True 168 172 map_coproc = options.coproc # map "coproc" application if True 173 map_ocean = options.ocean # map "ocean" application if True 169 174 170 175 ################################################################################### … … 230 235 print '[genmap] application "coproc" will be loaded' 231 236 237 if ( map_ocean ): 238 app = __import__( 'ocean' ) 239 app.ocean( mapping ) 240 print '[genmap] application "ocean" will be loaded' 241 232 242 ################################################################################### 233 243 # Generate xml file if required.
Note: See TracChangeset
for help on using the changeset viewer.