Changeset 768 for soft/giet_vm/applications/shell
- Timestamp:
- Jan 20, 2016, 10:15:22 AM (9 years ago)
- Location:
- soft/giet_vm/applications/shell
- Files:
-
- 2 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 -
soft/giet_vm/applications/shell/shell.py
r712 r768 34 34 heap_size = 0x00001000 # 4 Kbytes 35 35 36 mmap_base = 0x70000000 37 mmap_size = 0x10000000 # 256 Mbytes (unmapped) 38 36 39 # create vspace 37 40 vspace = mapping.addVspace( name = 'shell', startname = 'shell_data' , active = True ) … … 57 60 mapping.addVseg( vspace, 'shell_heap', heap_base, heap_size, 58 61 'C_WU', vtype = 'BUFFER', x = xmap , y = ymap , pseg = 'RAM', 62 local = False ) 63 64 # mmap vseg 65 mapping.addVseg( vspace, 'shell_mmap', mmap_base, mmap_size, 66 'C_WU', vtype = 'MMAP', x = xmap , y = ymap , pseg = 'RAM', 59 67 local = False ) 60 68
Note: See TracChangeset
for help on using the changeset viewer.