Changeset 768 for soft/giet_vm/applications/shell/shell.c
- Timestamp:
- Jan 20, 2016, 10:15:22 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/shell/shell.c
r747 r768 314 314 } 315 315 316 unsigned int x,y,p; // processor coordinates316 unsigned int x,y,p; // processor coordinates 317 317 unsigned int fd; // file descriptor 318 318 fat_file_info_t info; // file info 319 319 unsigned int size; // buffer size (file_size + 1) 320 unsigned int len; // number of read bytes from file321 char* buf ;// temporary buffer320 unsigned int bytes; // number of bytes to be mapped 321 char* buf = NULL; // temporary buffer 322 322 323 323 // get processor coordinates … … 325 325 326 326 // open the file to display 327 fd = giet_fat_open( argv[1] , O_RDONLY);327 fd = giet_fat_open( argv[1] , 0 ); 328 328 if (fd < 0) 329 329 { … … 341 341 size = info.size; 342 342 343 // extend size to 4 Kbytes boundary if required 344 if ( (size+1) & 0xFFF) bytes = (size & 0xFFFFF000) + 0x1000; 345 else bytes = size + 1; 346 347 // map local buffer to Cache_file 348 buf = giet_fat_mmap( NULL, 349 bytes, 350 MAP_PROT_READ | MAP_PROT_WRITE, 351 MAP_SHARED, 352 fd, 353 0 ); 354 if ( buf == NULL ) 355 { 356 giet_tty_printf(" error : cannot map %s\n", argv[1] ); 357 goto exit; 358 } 359 360 /* 343 361 // allocate a temporary buffer for the file 344 362 heap_init( x , y ); … … 349 367 goto exit; 350 368 } 351 // load the file and set terminating '0'369 // load the file 352 370 len = giet_fat_read( fd , buf , size ); 353 371 if ( len != size ) … … 357 375 goto exit; 358 376 } 377 */ 378 // set terminating '0' 359 379 buf[size] = 0; 360 380 361 381 // display the file content 362 giet_tty_printf(" \n%s", buf );382 giet_tty_printf("%s", buf ); 363 383 364 384 exit: 365 385 if ( fd >= 0 ) giet_fat_close( fd ); 366 if ( buf != NULL ) free( buf);386 if ( buf != NULL ) giet_fat_munmap( buf , bytes ); 367 387 } 368 388
Note: See TracChangeset
for help on using the changeset viewer.