Changeset 442


Ignore:
Timestamp:
Nov 3, 2014, 11:29:19 AM (10 years ago)
Author:
alain
Message:

Removing the _printf() function in the boot code i
and in the drivers used by the boot code.

Location:
soft/giet_vm/giet_common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_common/pmem.c

    r408 r442  
    2424    if ( (base & 0x1FFFFF) || (size & 0x1FFFFF) )
    2525    {
    26         _printf("\n[GIET ERROR] in _pmem_alloc_init() : "
    27                 " pseg in cluster[%d][%d] not aligned on 2 Mbytes\n", x, y );
     26        _puts("\n[GIET ERROR] in _pmem_alloc_init() : pseg in cluster[");
     27        _putd( x );
     28        _puts(",");
     29        _putd( y );
     30        _puts("] not aligned on 2 Mbytes\n");
    2831        _exit();
    2932    }
     
    5861    if ( (bpi + n) > p->max_bppi )
    5962    {
    60         _printf("\n[GIET ERROR] in _get_big_ppn() : "
    61                 " not enough big physical pages in cluster[%d][%d]", x, y );
     63        _puts("\n[GIET ERROR] in _get_big_ppn() : not enough BPP in cluster[");
     64        _putd( x );
     65        _puts(",");
     66        _putd( y );
     67        _puts("]\n");
    6268        _exit();
    6369    }
     
    8591        if ( p->nxt_bppi + 1 > p->max_bppi )
    8692        {
    87             _printf("\n[GIET ERROR] in _get_small_ppn() : "
    88                     " not enough big physical pages in cluster[%d][%d]", x, y );
     93            _puts("\n[GIET ERROR] in _get_small_ppn() : not enough BPP in cluster[");
     94            _putd( x );
     95            _puts(",");
     96            _putd( y );
     97            _puts("]\n");
    8998            _exit();
    9099        }
  • soft/giet_vm/giet_common/utils.c

    r433 r442  
    1111///////////////////////////////////////////////////////////////////////////////////
    1212
     13#include <utils.h>
    1314#include <giet_config.h>
    1415#include <hard_config.h>
    1516#include <mapping_info.h>
    16 #include <utils.h>
     17#include <tty_driver.h>
    1718#include <ctx_handler.h>
    18 #include <tty_driver.h>
    19 #include <stdarg.h>
    2019
    2120// This global variable is allocated in the boot.c file or in kernel_init.c file
     
    172171////////////////////////////////////////////////////////////////////////////
    173172
    174 ////////////////////////////////////////////////////////////////////////////
     173///////////////////////////////////////////////////////
    175174unsigned int _physical_read( unsigned long long paddr )
    176175{
     
    198197    return value;
    199198}
    200 ////////////////////////////////////////////////////////////////////////////
     199////////////////////////////////////////////////
    201200void _physical_write( unsigned long long paddr,
    202201                      unsigned int       value )
     
    225224}
    226225
    227 ////////////////////////////////////////////////////////////////////////////
     226/////////////////////////////////////////////////////////////////
    228227unsigned long long _physical_read_ull( unsigned long long paddr )
    229228{
     
    256255}
    257256
    258 ////////////////////////////////////////////////////////////////////////////
     257///////////////////////////////////////////////////
    259258void _physical_write_ull( unsigned long long paddr,
    260259                          unsigned long long value )
     
    286285}
    287286
    288 ///////////////////////////////////////////////////////////////////////////////////
    289 // This function makes a memcpy from a source buffer to a destination buffer
    290 // using physical addresses, after a temporary DTLB de-activation.
    291 // source and destination buffers must be word aligned, and size must be
    292 // multiple of 4 bytes.
    293 ///////////////////////////////////////////////////////////////////////////////////
     287////////////////////////////////////////////////////
    294288void _physical_memcpy( unsigned long long dst_paddr,  // destination buffer paddr
    295289                       unsigned long long src_paddr,  // source buffer paddr
     
    299293    if ( (dst_paddr & 3) || (src_paddr & 3) || (size & 3) )
    300294    {
    301         _printf("\n[GIET ERROR] in _physical_memcpy() : buffer unaligned\n");
     295        _puts("\n[GIET ERROR] in _physical_memcpy() : buffer unaligned\n");
    302296        _exit();
    303297    }
     
    342336} // end _physical_memcpy()
    343337
    344 /////////////////////////////////////////////////////////////////////////////////
     338////////////////////////////////////////////////
    345339void _physical_memset( unsigned long long paddr,     // destination buffer paddr
    346340                       unsigned int       size,      // bytes
     
    350344    if ( (paddr & 3) || (size & 7) )
    351345    {
    352         _printf("\n[GIET ERROR] in _physical_memset() : buffer unaligned\n");
     346        _puts("\n[GIET ERROR] in _physical_memset() : buffer unaligned\n");
    353347        _exit();
    354348    }
     
    381375}  // _physical_memset()
    382376
    383 ///////////////////////////////////////////////////////////////////////////////////
     377///////////////////////////////////////////////
    384378void _io_extended_write( unsigned int*  vaddr,
    385379                         unsigned int   value )
     
    400394}
    401395
    402 ///////////////////////////////////////////////////////////////////////////////////
     396//////////////////////////////////////////////////////
    403397unsigned int _io_extended_read( unsigned int*  vaddr )
    404398{
     
    418412
    419413///////////////////////////////////////////////////////////////////////////////////
    420 //     Locks access functions
    421 ///////////////////////////////////////////////////////////////////////////////////
    422 
    423 ///////////////////////////////////////////////////////////////////////////////////
    424 void _get_lock(giet_lock_t* lock)
     414//                      Locks access functions
     415///////////////////////////////////////////////////////////////////////////////////
     416
     417///////////////////////////////////
     418void _get_lock( giet_lock_t* lock )
    425419{
    426420    register unsigned int* plock = &(lock->value);
     
    470464}
    471465
    472 ///////////////////////////////////////////////////////////////////////////////////
    473 void _release_lock(giet_lock_t* lock)
     466///////////////////////////////////////
     467void _release_lock( giet_lock_t* lock )
    474468{
    475469    asm volatile ( "sync\n" ::: "memory" );
     
    479473
    480474///////////////////////////////////////////////////////////////////////////////////
    481 //           Access functions to system terminal TTY0
    482 ///////////////////////////////////////////////////////////////////////////////////
    483 
    484 ///////////////////////////////////////////////////////////////////////////////////
    485 // Display "string" argument on TTY0.
    486 // It uses the low level access functions from TTY driver, using a busy waiting
    487 // policy if TTY buffer is full.
    488 // The exclusive access lock should be taken by the caller.
    489 ///////////////////////////////////////////////////////////////////////////////////
     475//           Access functions to kernel terminal TTY0
     476///////////////////////////////////////////////////////////////////////////////////
     477
     478//////////////////////////
    490479void _puts( char* string )
    491480{
     
    506495}
    507496
    508 ///////////////////////////////////////////////////////////////////////////////////
    509 // Display a 32 bits unsigned int as an hexadecimal string on TTY0.
    510 ///////////////////////////////////////////////////////////////////////////////////
     497//////////////////////////////
    511498void _putx( unsigned int val )
    512499{
     
    527514}
    528515
    529 ///////////////////////////////////////////////////////////////////////////////////
    530 // Display a 64 bits unsigned long as an hexadecimal string on TTY0.
    531 ///////////////////////////////////////////////////////////////////////////////////
     516////////////////////////////////////
    532517void _putl( unsigned long long val )
    533518{
     
    548533}
    549534
    550 ///////////////////////////////////////////////////////////////////////////////////
    551 // Display a 32 bits unsigned int as a decimal string on TTY0.
    552 ///////////////////////////////////////////////////////////////////////////////////
     535//////////////////////////////
    553536void _putd( unsigned int val )
    554537{
     
    576559}
    577560
    578 ///////////////////////////////////////////////////////////////////////////////////
    579 // Display a format on TTY0.
    580 // To provide an atomic display, this function takes the lock protecting
    581 // exclusive access to TTY0, entering a critical section until the lock
    582 // is released.
    583 // Only a limited number of formats are supported:
    584 //   - %d : 32 bits signed   decimal
    585 //   - %u : 32 bits unsigned decimal
    586 //   - %x : 32 bits unsigned hexa
    587 //   - %l : 64 bits unsigned hexa
    588 //   - %c : char
    589 //   - %s : string
    590 ///////////////////////////////////////////////////////////////////////////////////
    591 void _printf( char * format, ... )
    592 {
    593     va_list ap;
    594     va_start(ap, format);
    595     unsigned int save_sr;     // to save SR value in critical section
    596 
    597     // get TTY0 lock
    598     _tty_get_lock( 0, &save_sr );
    599 
    600 printf_text:
    601 
    602     while (*format)
    603     {
    604         unsigned int i;
    605         for (i = 0 ; format[i] && (format[i] != '%') ; i++);
    606         if (i)
    607         {
    608             if ( _tty_write( format, i, 0 ) != i ) goto return_error;
    609             format += i;
    610         }
    611         if (*format == '%')
    612         {
    613             format++;
    614             goto printf_arguments;
    615         }
    616     }
    617 
    618     // release TTY0 lock
    619     _tty_release_lock( 0, &save_sr );
    620 
    621     va_end(ap);
    622     return;
    623 
    624 printf_arguments:
    625 
    626     {
    627         char buf[20];
    628         char * pbuf;
    629         unsigned int len = 0;
    630         static const char HexaTab[] = "0123456789ABCDEF";
    631         unsigned int i;
    632 
    633         switch (*format++)
    634         {
    635             case ('c'):             /* char conversion */
    636             {
    637                 int val = va_arg( ap, int );
    638                 len = 1;
    639                 buf[0] = val;
    640                 pbuf = &buf[0];
    641                 break;
    642             }
    643             case ('d'):             /* 32 bits decimal signed  */
    644             {
    645                 int val = va_arg( ap, int );
    646                 if (val < 0)
    647                 {
    648                     val = -val;
    649                     if ( _tty_write( "-" , 1, 0 ) != 1 ) goto return_error;
    650                 }
    651                 for(i = 0; i < 10; i++)
    652                 {
    653                     buf[9 - i] = HexaTab[val % 10];
    654                     if (!(val /= 10)) break;
    655                 }
    656                 len =  i + 1;
    657                 pbuf = &buf[9 - i];
    658                 break;
    659             }
    660             case ('u'):             /* 32 bits decimal unsigned  */
    661             {
    662                 unsigned int val = va_arg( ap, unsigned int );
    663                 for(i = 0; i < 10; i++)
    664                 {
    665                     buf[9 - i] = HexaTab[val % 10];
    666                     if (!(val /= 10)) break;
    667                 }
    668                 len =  i + 1;
    669                 pbuf = &buf[9 - i];
    670                 break;
    671             }
    672             case ('x'):             /* 32 bits hexadecimal unsigned */
    673             {
    674                 unsigned int val = va_arg( ap, unsigned int );
    675                 if ( _tty_write( "0x" , 2, 0 ) != 2 ) goto return_error;
    676                 for(i = 0; i < 8; i++)
    677                 {
    678                     buf[7 - i] = HexaTab[val % 16];
    679                     if (!(val /= 16))  break;
    680                 }
    681                 len =  i + 1;
    682                 pbuf = &buf[7 - i];
    683                 break;
    684             }
    685             case ('l'):            /* 64 bits hexadecimal unsigned */
    686             {
    687                 unsigned long long val = va_arg( ap, unsigned long long );
    688                 if ( _tty_write( "0x" , 2, 0 ) != 2 ) goto return_error;
    689                 for(i = 0; i < 16; i++)
    690                 {
    691                     buf[15 - i] = HexaTab[val % 16];
    692                     if (!(val /= 16))  break;
    693                 }
    694                 len =  i + 1;
    695                 pbuf = &buf[15 - i];
    696                 break;
    697             }
    698             case ('s'):             /* string */
    699             {
    700                 char* str = va_arg( ap, char* );
    701                 while (str[len])
    702                 {
    703                     len++;
    704                 }
    705                 pbuf = str;
    706                 break;
    707             }
    708             default:
    709                 goto return_error;
    710         }
    711 
    712         if ( _tty_write( pbuf, len, 0 ) != len ) goto return_error;
    713        
    714         goto printf_text;
    715     }
    716 
    717 return_error:
    718 
    719     {
    720         unsigned int procid     = _get_procid();
    721         unsigned int x          = (procid >> (Y_WIDTH + P_WIDTH)) & ((1<<X_WIDTH)-1);
    722         unsigned int y          = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    723         unsigned int lpid       = procid & ((1<<P_WIDTH)-1);
    724 
    725         _puts("\n\n[GIET ERROR] in _printf() for processor[");
    726         _putd( x );
    727         _puts(",");
    728         _putd( y );
    729         _puts(",");
    730         _putd( lpid );
    731         _puts("]\n");
    732 
    733         // release TTY0 lock
    734         _tty_release_lock( 0, &save_sr );
    735 
    736         _exit();
    737     }
    738 }
    739 
    740 ///////////////////////////////////////////////////////////////////////////////////
    741 // Get a character from TTY0.
    742 ///////////////////////////////////////////////////////////////////////////////////
    743 void _getc( char*        byte )
     561/////////////////////////
     562void _getc( char*  byte )
    744563{
    745564    // test status register
     
    756575
    757576
    758 ////////////////////////////////////////////////////////////////////////////////////
     577///////////////////////////////////
    759578unsigned int _get_current_task_id()
    760579{
     
    762581    return (unsigned int) (psched->current);
    763582}
    764 ////////////////////////////////////////////////////////////////////////////////////
     583
     584////////////////////////////////////////////
    765585unsigned int _get_task_slot( unsigned int x,
    766586                             unsigned int y,
     
    772592    return psched->context[ltid][slot];
    773593}
    774 ////////////////////////////////////////////////////////////////////////////////////
     594
     595////////////////////////////////////
    775596void _set_task_slot( unsigned int x,
    776597                     unsigned int y,
     
    783604    psched->context[ltid][slot] = value;
    784605}
    785 ////////////////////////////////////////////////////////////////////////////////////
     606
     607///////////////////////////////////////////////////
    786608unsigned int _get_context_slot( unsigned int slot )
    787609{
     
    790612    return psched->context[task_id][slot];
    791613}
    792 ////////////////////////////////////////////////////////////////////////////////////
     614
     615///////////////////////////////////////////
    793616void _set_context_slot( unsigned int slot,
    794617                       unsigned int value )
     
    802625//      Access functions to mapping_info data structure
    803626/////////////////////////////////////////////////////////////////////////////
     627
     628////////////////////////////////////////////////////////////////
    804629mapping_cluster_t * _get_cluster_base(mapping_header_t * header)
    805630{
     
    807632            MAPPING_HEADER_SIZE);
    808633}
    809 /////////////////////////////////////////////////////////////////////////////
     634//////////////////////////////////////////////////////////
    810635mapping_pseg_t * _get_pseg_base(mapping_header_t * header)
    811636{
     
    814639            MAPPING_CLUSTER_SIZE * X_SIZE * Y_SIZE);
    815640}
    816 /////////////////////////////////////////////////////////////////////////////
     641//////////////////////////////////////////////////////////////
    817642mapping_vspace_t * _get_vspace_base(mapping_header_t * header)
    818643{
     
    822647            MAPPING_PSEG_SIZE * header->psegs);
    823648}
    824 /////////////////////////////////////////////////////////////////////////////
     649//////////////////////////////////////////////////////////
    825650mapping_vseg_t * _get_vseg_base(mapping_header_t * header)
    826651{
     
    831656            MAPPING_VSPACE_SIZE * header->vspaces);
    832657}
    833 /////////////////////////////////////////////////////////////////////////////
     658//////////////////////////////////////////////////////////
    834659mapping_vobj_t * _get_vobj_base(mapping_header_t * header)
    835660{
     
    841666            MAPPING_VSEG_SIZE * header->vsegs );
    842667}
    843 /////////////////////////////////////////////////////////////////////////////
     668//////////////////////////////////////////////////////////
    844669mapping_task_t * _get_task_base(mapping_header_t * header)
    845670{
     
    852677            MAPPING_VSEG_SIZE * header->vsegs);
    853678}
    854 /////////////////////////////////////////////////////////////////////////////
     679/////////////////////////////////////////////////////////
    855680mapping_proc_t *_get_proc_base(mapping_header_t * header)
    856681{
     
    864689            MAPPING_TASK_SIZE * header->tasks);
    865690}
    866 /////////////////////////////////////////////////////////////////////////////
     691///////////////////////////////////////////////////////
    867692mapping_irq_t *_get_irq_base(mapping_header_t * header)
    868693{
     
    877702            MAPPING_PROC_SIZE * header->procs);
    878703}
    879 /////////////////////////////////////////////////////////////////////////////
     704/////////////////////////////////////////////////////////////
    880705mapping_coproc_t *_get_coproc_base(mapping_header_t * header)
    881706{
     
    891716            MAPPING_IRQ_SIZE * header->irqs);
    892717}
    893 ///////////////////////////////////////////////////////////////////////////////////
     718///////////////////////////////////////////////////////////////
    894719mapping_cp_port_t *_get_cp_port_base(mapping_header_t * header)
    895720{
     
    906731            MAPPING_COPROC_SIZE * header->coprocs);
    907732}
    908 ///////////////////////////////////////////////////////////////////////////////////
     733/////////////////////////////////////////////////////////////
    909734mapping_periph_t *_get_periph_base(mapping_header_t * header)
    910735{
     
    924749
    925750///////////////////////////////////////////////////////////////////////////////////
    926 // Miscelaneous functions
    927 ///////////////////////////////////////////////////////////////////////////////////
    928 
    929 ///////////////////////////////////////////////////////////////////////////////////
    930 // This function implements a pseudo-random delay.
    931 // The val argument define approximately an exponentially increasing mean delay,
    932 // and should not be larger than 32.
    933 ///////////////////////////////////////////////////////////////////////////////////
     751//             Miscelaneous functions
     752///////////////////////////////////////////////////////////////////////////////////
     753
     754//////////////////////////////////////
     755__attribute__((noreturn)) void _exit()
     756{
     757    unsigned int procid     = _get_procid();
     758    unsigned int x          = (procid >> (Y_WIDTH + P_WIDTH)) & ((1<<X_WIDTH)-1);
     759    unsigned int y          = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
     760    unsigned int lpid       = procid & ((1<<P_WIDTH)-1);
     761
     762
     763    _puts("\n[GIET PANIC] processor[");
     764    _putd( x );
     765    _puts(",");
     766    _putd( y );
     767    _puts(",");
     768    _putd( lpid );
     769    _puts("] exit at cycle");
     770    _putd( _get_proctime() );
     771    _puts(" ...\n");
     772
     773    while (1) { asm volatile ("nop"); }
     774}
     775
     776/////////////////////////////////////
    934777void _random_wait( unsigned int val )
    935778{
     
    945788                  : "$3" );
    946789}
    947 //////////////////////////////////////////////////////////////////////////////////
    948 // This function implements an interactive break for debug.
    949 // Execution continue when typing any character on TTY0.
    950 // The "str" argument is supposed to indicate the break location.
    951 //////////////////////////////////////////////////////////////////////////////////
     790
     791///////////////////////////
    952792void _break( char* string )
    953793{
    954794    char byte;
    955795
    956     _printf("\n[GIET DEBUG] break from %s / continue ?\n", string );
     796    _puts("\n[GIET DEBUG] break from ");
     797    _puts( string );
     798    _puts(" / stoke any key to continue\n");
    957799    _getc( &byte );
    958800}
    959801
    960 //////////////////////////////////////////////////////////////////////////////////
    961 // Processor suicide: infinite loop 
    962 //////////////////////////////////////////////////////////////////////////////////
    963 __attribute__((noreturn))
    964 void _exit()
    965 {
    966     unsigned int procid     = _get_procid();
    967     unsigned int x          = (procid >> (Y_WIDTH + P_WIDTH)) & ((1<<X_WIDTH)-1);
    968     unsigned int y          = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    969     unsigned int lpid       = procid & ((1<<P_WIDTH)-1);
    970 
    971 
    972     _printf("\n[GIET PANIC] processor[%d,%d,%d] suicide...\n", x, y, lpid );
    973 
    974     while (1) { asm volatile ("nop"); }
    975 }
    976 ///////////////////////////////////////////////////////////////////////////////////
    977 // Compare two strings s1 & s2 (no more than n characters)
    978 ///////////////////////////////////////////////////////////////////////////////////
     802///////////////////////////////////////
    979803unsigned int _strncmp( const char * s1,
    980804                       const char * s2,
     
    990814}
    991815
    992 ///////////////////////////////////////////////////////////////////////////////////
    993 // Copy source string to dest string
    994 ///////////////////////////////////////////////////////////////////////////////////
     816/////////////////////////////////////////
    995817char* _strcpy( char* dest, char* source )
    996818{
     
    1003825}
    1004826
    1005 ///////////////////////////////////////////////////////////////////////////////////
    1006 // Invalidate all data cache lines corresponding to a memory
    1007 // buffer (identified by virtual base address and size).
    1008 ///////////////////////////////////////////////////////////////////////////////////
     827/////////////////////////////////////////////////////
    1009828void _dcache_buf_invalidate( unsigned int buf_vbase,
    1010829                             unsigned int buf_size )
     
    1028847    }
    1029848}
    1030 ///////////////////////////////////////////////////////////////////////////////////
    1031 // This function returns the information associated to a heap : vaddr and length.
    1032 // - If (x < X_SIZE) and (y < Y_SIZE), it return the heap associated to any task
    1033 // running in cluster(x,y).
    1034 // - Else, it return the heap associated to the calling task.
    1035 // It uses the global task index (CTX_GTID_ID, unique for each giet task) and the
    1036 // vspace index (CTX_VSID_ID), that are defined in the calling task context
    1037 // to find the vobj_id containing the heap.
    1038 // Return 0 if success. Return non zero if not found.
    1039 ///////////////////////////////////////////////////////////////////////////////////
    1040 unsigned int _heap_info( unsigned int* vaddr,
    1041                          unsigned int* length,
    1042                          unsigned int  x,
    1043                          unsigned int  y )
    1044 {
    1045     mapping_header_t * header  = (mapping_header_t *)SEG_BOOT_MAPPING_BASE;
    1046     mapping_task_t *   tasks   = _get_task_base(header);
    1047     mapping_vobj_t *   vobjs   = _get_vobj_base(header);
    1048     mapping_vspace_t * vspaces = _get_vspace_base(header);
    1049 
    1050     unsigned int task_id;
    1051     unsigned int vspace_id;
    1052     unsigned int vobj_id = 0xFFFFFFFF;
    1053 
    1054     // searching the heap vobj_id
    1055     if ( (x < X_SIZE) && (y < Y_SIZE) )  // searching a task in cluster(x,y)
    1056     {
    1057         // get vspace global index
    1058         vspace_id = _get_context_slot(CTX_VSID_ID);
    1059 
    1060         // scan all tasks in vspace
    1061         unsigned int min = vspaces[vspace_id].task_offset ;
    1062         unsigned int max = min + vspaces[vspace_id].tasks ;
    1063         for ( task_id = min ; task_id < max ; task_id++ )
    1064         {
    1065             if ( tasks[task_id].clusterid == (x * Y_SIZE + y) )
    1066             {
    1067                 vobj_id = tasks[task_id].heap_vobj_id;
    1068                 if ( vobj_id != 0xFFFFFFFF ) break;
    1069             }
    1070         }
    1071     }
    1072     else                                // searching in the calling task
    1073     {
    1074         task_id = _get_context_slot(CTX_GTID_ID);
    1075         vobj_id = tasks[task_id].heap_vobj_id;
    1076     }
    1077 
    1078     // analysing the vobj_id
    1079     if ( vobj_id != 0xFFFFFFFF )
    1080     {
    1081         *vaddr  = vobjs[vobj_id].vbase;
    1082         *length = vobjs[vobj_id].length;
    1083         return 0;
    1084     }
    1085     else
    1086     {
    1087         *vaddr = 0;
    1088         *length = 0;
    1089         return 1;
    1090     }
    1091 }  // end _heap_info()
     849
    1092850
    1093851
     
    1096854///////////////////////////////////////////////////////////////////////////////////
    1097855
    1098 ///////////////////////////////////////////////////////////////////////////////////
    1099 // Copy a source memory buffer content to a dest memory buffer (size bytes)
    1100 // Code taken from MutekH.
    1101 ///////////////////////////////////////////////////////////////////////////////////
     856////////////////////////////////
    1102857void* memcpy( void*        dest,     // dest buffer vbase
    1103858              const void*  source,   // source buffer vbase
     
    1127882    return dest;
    1128883}
    1129 //////////////////////////////////////////////////////////////////////////////////
    1130 // Fill a byte string with a byte value.
    1131 //////////////////////////////////////////////////////////////////////////////////
    1132 void * memset( void*        dest,
    1133                       int          value,
    1134                       unsigned int count )
     884
     885/////////////////////////////////
     886void * memset( void*        dst,
     887               int          value,
     888               unsigned int count )
    1135889{
    1136890    // word-by-word copy
    1137     unsigned int* idst = dest;
     891    unsigned int* idst = dst;
    1138892    unsigned int  data = (((unsigned char)value)      ) |
    1139893                         (((unsigned char)value) <<  8) |
     
    1151905   
    1152906    // byte-by-byte copy
    1153     unsigned char* cdst = dest;
     907    unsigned char* cdst = dst;
    1154908    while (count--)
    1155909    {
    1156910        *cdst++ = (unsigned char)value;
    1157911    }
    1158     return dest;
     912    return dst;
    1159913}
    1160914
  • soft/giet_vm/giet_common/utils.h

    r430 r442  
    1515
    1616#include <mapping_info.h>
    17 #include <giet_config.h>
    1817
    1918//////////////////////////////////////////////////////////////////////////////////
     
    4544
    4645///////////////////////////////////////////////////////////////////////////////////
    47 ///////////////////////////////////////////////////////////////////////////////////
    4846//     CP0 registers access functions
    4947///////////////////////////////////////////////////////////////////////////////////
    50 ///////////////////////////////////////////////////////////////////////////////////
    51 
    52 ///////////////////////////////////////////////////////////////////////////////////
    53 // Returns CP0_SCHED register content
    54 // (virtual base address of the processor scheduler)
    55 ///////////////////////////////////////////////////////////////////////////////////
     48
    5649extern unsigned int _get_sched(void);
    5750
    58 ///////////////////////////////////////////////////////////////////////////////////
    59 // Returns CP0_EPC register content.
    60 ///////////////////////////////////////////////////////////////////////////////////
    6151extern unsigned int _get_epc(void);
    6252
    63 ///////////////////////////////////////////////////////////////////////////////////
    64 // Returns CP0_BVAR register content.
    65 ///////////////////////////////////////////////////////////////////////////////////
    6653extern unsigned int _get_bvar(void);
    6754
    68 ///////////////////////////////////////////////////////////////////////////////////
    69 // Returns CP0_CR register content.
    70 ///////////////////////////////////////////////////////////////////////////////////
    7155extern unsigned int _get_cr(void);
    7256
    73 ///////////////////////////////////////////////////////////////////////////////////
    74 // Returns CP0_SR register content.
    75 ///////////////////////////////////////////////////////////////////////////////////
    7657extern unsigned int _get_sr(void);
    7758
    78 ///////////////////////////////////////////////////////////////////////////////////
    79 // Returns CP0_PROCID register content.
    80 // Processor identifier (12 bits)
    81 ///////////////////////////////////////////////////////////////////////////////////
    8259extern unsigned int _get_procid(void);
    8360
    84 ///////////////////////////////////////////////////////////////////////////////////
    85 // Returns CP0_TIME register content.
    86 // Processor local time (32 bits)
    87 ///////////////////////////////////////////////////////////////////////////////////
    8861extern unsigned int _get_proctime(void);
    8962
    90 ///////////////////////////////////////////////////////////////////////////////////
    91 // Save CP0_SR value to variable pointed by save_sr_ptr and disable IRQs.
    92 ///////////////////////////////////////////////////////////////////////////////////
    9363extern void         _it_disable( unsigned int* save_sr_ptr );
    9464
    95 ///////////////////////////////////////////////////////////////////////////////////
    96 // Restore CP0_SR register from variable pointed by save_sr_ptr.
    97 ///////////////////////////////////////////////////////////////////////////////////
    9865extern void         _it_restore( unsigned int* save_sr_ptr );
    9966
    100 ///////////////////////////////////////////////////////////////////////////////////
    101 // Set a new value in CP0_SCHED register.
    102 // (virtual base address of the processor scheduler)
    103 ///////////////////////////////////////////////////////////////////////////////////
    10467extern void         _set_sched(unsigned int value);
    10568
    106 ///////////////////////////////////////////////////////////////////////////////////
    107 // Set a new value in CP0_SR register.
    108 ///////////////////////////////////////////////////////////////////////////////////
    10969extern void         _set_sr(unsigned int value);
    11070
    111 
    112 ///////////////////////////////////////////////////////////////////////////////////
    11371///////////////////////////////////////////////////////////////////////////////////
    11472//     CP2 registers access functions
    11573///////////////////////////////////////////////////////////////////////////////////
    116 ///////////////////////////////////////////////////////////////////////////////////
    117 
    118 ///////////////////////////////////////////////////////////////////////////////////
    119 // Returns CP2_PTPR register value.
    120 // Page table physical base address for the running context.
    121 // Contains only the 27 MSB bits, right justified.
    122 ///////////////////////////////////////////////////////////////////////////////////
     74
    12375extern unsigned int _get_mmu_ptpr(void);
    12476
    125 ///////////////////////////////////////////////////////////////////////////////////
    126 // Returns CP2_MODE register value.
    127 // MMU current mode, defined by 4 bits, right justified: ITLB/DTLB/ICACHE/DCACHE
    128 ///////////////////////////////////////////////////////////////////////////////////
    12977extern unsigned int _get_mmu_mode(void);
    13078
    131 ///////////////////////////////////////////////////////////////////////////////////
    132 // Set a new value in CP2_PTPR register.
    133 ///////////////////////////////////////////////////////////////////////////////////
    13479extern void         _set_mmu_ptpr(unsigned int value);
    13580
    136 ///////////////////////////////////////////////////////////////////////////////////
    137 // Set a new value in CP2_MODE register.
    138 ///////////////////////////////////////////////////////////////////////////////////
    13981extern void         _set_mmu_mode(unsigned int value);
    14082
    141 ///////////////////////////////////////////////////////////////////////////////////
    142 // Set a value in  CP2_DCACHE_INVAL register.
    143 // It invalidates the data cache line, if the virtual address defined by the
    144 // value argument hit in DCACHE.
    145 ///////////////////////////////////////////////////////////////////////////////////
    14683extern void         _set_mmu_dcache_inval(unsigned int value);
    14784
    148 
    149 
    150 ///////////////////////////////////////////////////////////////////////////////////
    15185///////////////////////////////////////////////////////////////////////////////////
    15286//     Physical addressing functions
    15387///////////////////////////////////////////////////////////////////////////////////
    154 ///////////////////////////////////////////////////////////////////////////////////
    155 
    156 ////////////////////////////////////////////////////////////////////////////
    157 // This function makes a physical read access to a 32 bits word in memory,
    158 // after a temporary DTLB de-activation and paddr extension.
    159 ////////////////////////////////////////////////////////////////////////////
     88
    16089extern unsigned int _physical_read(  unsigned long long paddr );
    16190
    162 ////////////////////////////////////////////////////////////////////////////
    163 // This function makes a physical write access to a 32 bits word in memory,
    164 // after a temporary DTLB de-activation and paddr extension.
    165 ////////////////////////////////////////////////////////////////////////////
    16691extern void         _physical_write( unsigned long long paddr,
    16792                                     unsigned int       value );
    16893
    169 ////////////////////////////////////////////////////////////////////////////
    170 // This function makes a physical read access to a 64 bits word in memory,
    171 // after a temporary DTLB de-activation and paddr extension.
    172 ////////////////////////////////////////////////////////////////////////////
    17394extern unsigned long long _physical_read_ull(  unsigned long long paddr );
    17495
    175 ////////////////////////////////////////////////////////////////////////////
    176 // This function makes a physical write access to a 64 bits word in memory,
    177 // after a temporary DTLB de-activation and paddr extension.
    178 ////////////////////////////////////////////////////////////////////////////
    17996extern void               _physical_write_ull( unsigned long long paddr,
    18097                                               unsigned long long value );
    18198
    182 ///////////////////////////////////////////////////////////////////////////////////
    183 // This function makes a memcpy from a source buffer to a destination buffer,
    184 // using physical addresses, after a temporary DTLB de-activation.
    185 // The source and destination buffers must be word aligned, and size must be
    186 // multiple of 4 bytes.
    187 ///////////////////////////////////////////////////////////////////////////////////
    18899extern void         _physical_memcpy( unsigned long long dst_paddr,
    189100                                      unsigned long long src_paddr,
    190101                                      unsigned int       size );
    191102
    192 ///////////////////////////////////////////////////////////////////////////////////
    193 // This function set a data value in all words of a destination buffer,
    194 // using physical addresses, after a temporary DTLB de-activation.
    195 // The destination buffer must be word aligned, and size multiple of 4 bytes.
    196 ///////////////////////////////////////////////////////////////////////////////////
    197103extern void         _physical_memset( unsigned long long buf_paddr,
    198104                                      unsigned int       size,
    199105                                      unsigned int       data );
    200106
    201 ///////////////////////////////////////////////////////////////////////////////////
    202 // This function is used by several drivers (_xxx_get_register() function).
    203 // If the MMU is not activated, the virtual address is extended using
    204 // X_IO and Y_IO to reach the cluster_io.
    205 ///////////////////////////////////////////////////////////////////////////////////
    206107extern unsigned int _io_extended_read(  unsigned int* vaddr );
    207108
    208 ///////////////////////////////////////////////////////////////////////////////////
    209 // This function is used by all drivers (_xxx_set_register() function)
    210 // If the MMU is not activated, the virtual address is extended using
    211 // X_IO and Y_IO to reach the cluster_io.
    212 ///////////////////////////////////////////////////////////////////////////////////
    213109extern void         _io_extended_write( unsigned int* vaddr,
    214110                                        unsigned int  value );
    215111
    216112///////////////////////////////////////////////////////////////////////////////////
    217 //     Locks access functions
    218 ///////////////////////////////////////////////////////////////////////////////////
    219 
    220 
    221 ///////////////////////////////////////////////////////////////////////////////////
    222 // Takes a lock with a blocking ll/sc atomic access.
    223 // - When the cache coherence is granted by the hardware,
    224 //   the first read is a standard (cacheable) lw, as the local copy
    225 //   can be polled when the lock is already taken by another task, reducing
    226 //   trafic on the interconnect. When the lock is released by the owner task,
    227 //   the local copy is updated or invalidated by the coherence protocol.
    228 // - If there is no hardware cache coherence a random delay is introduced
    229 //   between two successive retry.
    230 ///////////////////////////////////////////////////////////////////////////////////
     113//      Locks access functions
     114///////////////////////////////////////////////////////////////////////////////////
     115
    231116extern void         _get_lock(giet_lock_t* lock);
    232117
    233 ///////////////////////////////////////////////////////////////////////////////////
    234 // Release a previouly taken lock.
    235 ///////////////////////////////////////////////////////////////////////////////////
    236118extern void         _release_lock(giet_lock_t* lock);
    237119
    238 
    239 ///////////////////////////////////////////////////////////////////////////////////
    240 //     TTY0 access functions
    241 ///////////////////////////////////////////////////////////////////////////////////
    242 
    243 extern void         _puts( char*        string );
     120///////////////////////////////////////////////////////////////////////////////////
     121//       Access functions to kernel terminal TTY0
     122///////////////////////////////////////////////////////////////////////////////////
     123
     124extern void         _puts( char*  string );
     125
    244126extern void         _putx( unsigned int val );
     127
     128extern void         _putl( unsigned long long val );
     129
    245130extern void         _putd( unsigned int val );
    246 extern void         _putl( unsigned long long val );
    247 
    248 extern void         _printf(char* format, ...);
    249 
    250 extern void         _getc( char*        byte );       
    251 
    252 
    253 ///////////////////////////////////////////////////////////////////////////////////
    254 //     Scheduler and task context access functions
    255 ///////////////////////////////////////////////////////////////////////////////////
    256 
    257 
    258 ///////////////////////////////////////////////////////////////////////////////////
    259 // Returns index of the currently running task from the processor scheduler.
    260 ///////////////////////////////////////////////////////////////////////////////////
     131
     132extern void         _getc( char* byte );       
     133
     134
     135///////////////////////////////////////////////////////////////////////////////////
     136//       Scheduler and task context access functions
     137///////////////////////////////////////////////////////////////////////////////////
     138
    261139extern unsigned int _get_current_task_id(void);
    262140
    263 ////////////////////////////////////////////////////////////////////////////////////
    264 // This function returns the content of a context slot
    265 // for a task identified by the ltid argument (local task index),
    266 // and a processor identified by the (x,y,p) arguments.
    267 ////////////////////////////////////////////////////////////////////////////////////
    268141extern unsigned int _get_task_slot( unsigned int x,
    269142                                    unsigned int y,
     
    272145                                    unsigned int slot );
    273146
    274 ////////////////////////////////////////////////////////////////////////////////////
    275 // This function updates the content of a context slot
    276 // for any task identified by the ltid argument (local task index),
    277 // and a processor identified by the (x,y,p) arguments.
    278 ////////////////////////////////////////////////////////////////////////////////////
    279147extern void         _set_task_slot( unsigned int x,
    280148                                    unsigned int y,
     
    284152                                    unsigned int value );
    285153
    286 ////////////////////////////////////////////////////////////////////////////////////
    287 // This function returns the content of a context slot for the running task.
    288 ////////////////////////////////////////////////////////////////////////////////////
    289154extern unsigned int _get_context_slot( unsigned int slot );
    290155
    291 ////////////////////////////////////////////////////////////////////////////////////
    292 // This function updates the content of a context slot for the running task.
    293 ////////////////////////////////////////////////////////////////////////////////////
    294156extern void         _set_context_slot( unsigned int slot,
    295157                                       unsigned int value );
     
    331193                                            unsigned int buf_size );
    332194
    333 extern unsigned int _heap_info( unsigned int* vaddr,
    334                                 unsigned int* length,
    335                                 unsigned int  x,
    336                                 unsigned int  y );
    337 
    338195///////////////////////////////////////////////////////////////////////////////////
    339196//     Required by GCC
    340197///////////////////////////////////////////////////////////////////////////////////
    341198
    342 extern void* memcpy( void* _dst,
    343                      const void* _src,
     199///////////////////////////////////////////////////////////////////////////////////
     200extern void* memcpy( void*        dst,
     201                     const void*  src,
    344202                     unsigned int size );
    345203
    346 extern void* memset( void* dst,
    347                      int s,
     204extern void* memset( void*        dst,
     205                     int          value,
    348206                     unsigned int count );
    349207
  • soft/giet_vm/giet_common/vmem.c

    r408 r442  
    3535    if ( (pte1 & PTE_V) == 0 )
    3636    {
    37         _printf("\n[VMEM ERROR] _v2p_translate() : pte1 unmapped\n");
     37        _puts("\n[VMEM ERROR] _v2p_translate() : pte1 unmapped\n");
    3838        _exit();
    3939    }
     
    8686        if ( (flags_value & PTE_V) == 0 )
    8787        {
    88             _printf("\n[VMEM ERROR] _v2p_translate() : pte2 unmapped\n");
     88            _puts("\n[VMEM ERROR] _v2p_translate() : pte2 unmapped\n");
    8989            _exit();
    9090        }
Note: See TracChangeset for help on using the changeset viewer.