📄 c.m4.mipsy
字号:
dnl BARRIER implementations.dnl ----------------------------------------------------------------------dnl -----------------------------dnl SLOW BARRIER MACROSdnldnl This barrier works fine, since LOCK (the field itself) is never modifieddnl backdoor. This other information can be done in this way just fine.dnl -----------------------------define(_SLOWBARDEC, ` struct $1_BARRIER_TYP { LOCKDEC(lock) volatile int count; volatile int spin; volatile int inuse; } $1;')define(_SLOWBARINIT, `{ LOCKINIT($1.lock) $1.count = 0; $1.spin = 1; $1.inuse = 0;}')define(_SLOWBARRIER, `{ SYNC_OP CommAreaPtr->BarEnter(); while ($1.inuse) ; LOCK($1.lock) if ($1.count++ < ($2 - 1)) { UNLOCK($1.lock) while($1.spin) ; LOCK($1.lock) } else { $1.inuse = 1; $1.spin = 0; } if (--$1.count == 0) { $1.spin = 1; $1.inuse = 0; } UNLOCK($1.lock) CommAreaPtr->BarExit();}')dnl -----------------------------dnl REAL BARRIER MACROSdnldnl -----------------------------define(_REALBARDEC, ` struct $1_BARRIER_TYP { long long _pad1[(SOLO_CACHE_LINE_SIZE/sizeof(long long))-1]; unsigned int count; unsigned int prefetch_loc; int _pad2[(SOLO_CACHE_LINE_SIZE/sizeof(int))-1]; unsigned int generationNumber; int _pad3[(SOLO_CACHE_LINE_SIZE/sizeof(int))-1]; } $1;')define(_REALBARINIT, `{ $1.count = 0; $1.generationNumber = 0;}')define(_REALBARRIER, `_Barrier(&$1.count,$2);')define(BARDEC, `#ifdef SLOW_BARRIER _SLOWBARDEC($1)#else _REALBARDEC($1)#endif ')define(BARINIT, `#ifdef SLOW_BARRIER _SLOWBARINIT($1)#else _REALBARINIT($1)#endif ')define(BARRIER, `#ifdef SLOW_BARRIER _SLOWBARRIER($1,$2)#else _REALBARRIER($1,$2)#endif ')dnl -----------------------------dnl PREFETCH MACROSdnldefine(PREFETCH, `_Prefetch($1);')define(PREFETCHX, `_PrefetchX($1);')dnl -----------------------------dnl PLACEMENT MACROSdnldefine(sys_place_range, `CommAreaPtr->PlaceRange((unsigned)($1), (unsigned)($2), (unsigned)($3));')define(SYS_PLACE_RANGE, `{sys_place_range($1, $2, $3);}')dnl -----------------------------dnl MALLOC MACROSdnldnl renamed functions:define(G_MALLOC, `malloc($1);')define(P_MALLOC, `$1 = G_MALLOC($2); CommAreaPtr->PlaceRange((unsigned)($1), (unsigned)($1) + (unsigned)($2), CommAreaPtr->GetCPUNum())');dnl -----------------------------dnl PAUSE stuffdnl -----------------------------define(PAUSEDEC, `struct $1_PAUSE_STRUCT { LOCKDEC(lock) volatile int flag;} $1;')define(PAUSEINIT, `{ $1.flag = 0; LOCKINIT($1.lock)}');define(CLEARPAUSE, ` $1.flag = 0;');define(SETPAUSE, `{ LOCK($1.lock) $1.flag = 1; UNLOCK($1.lock)}');define(WAITPAUSE, `{ while (($1.flag) == 0);}');dnl -----------------------------dnl MSG/IO MAPPING MACROSdnl -----------------------------define(IO_MAP, `CommAreaPtr->IOMap((unsigned) $1,$2);')dnl Usage: IO_MAP(VA, PA);dnl VA that is passed can be used in the future directly to access thednl requested PA range. Be sure VA goes in page aligned!!dnl PA BETTER BE long long, or WATCH OUT!!dnl NOTE: 6/96 IOMapAccelerated isn't yet implemented in the CommArea vectordefine(IO_MAP_ACCELERATED, `CommAreaPtr->IOMapAccelerated((unsigned) $1,$2);')dnl Usage: IO_MAP_ACCELERATED(VA, PA);dnl VA that is passed can be used in the future directly to access thednl requested PA range. Be sure VA goes in page aligned!!dnl PA BETTER BE long long, or WATCH OUT!!define(IO_MAP_GENERAL, `CommAreaPtr->IOMapGeneral((unsigned) $1,$2,$3);')dnl JH: This allows all the parameters to be set from the application level,dnl to let me set a range of functions without specific macros for each.dnl This effectively obsoletes the macros above, but I'll keep them fordnl backward compatbility.dnl Usage: IO_MAP(VA, details, PA);dnl dnl details == IO_MAP_UNCACHED | IO_MAP_ACCELERATED | spacednl where UNCACHED and ACCELERATED are flags present as appropriatednldnl Be sure VA goes in page aligned!!dnl PA BETTER BE long long, or WATCH OUT!!define(MSG_SPACE, `((void *) ((int)($1) | 0x80000000))')dnldnl This is an expression macro...to use it, you'd say:dnl *(MSG_SPACE_FLAG(pointer)) = valuednl to issue an uncached write in the message space for a particulardnl VA. This dynamically creates a mapping, if required.dnl **********************************************************************dnl FIXTHIS: functions below here are poorly or incorrectly implementeddnl **********************************************************************define(WAIT_FOR_END, ` if (_in_solo_mode) { int active; active = CommAreaPtr->ActiveProcs(); while (active != (_num_procs - ($1))) { active = CommAreaPtr->ActiveProcs(); } } else { CommAreaPtr->WaitForEnd(1); }')define(ENDLAB, 1000)define(AUG_STACK, 0)define(ST_LOG, `;')dnl **********************************************************************dnl FIXTHIS: functions below here are not currently provideddnl **********************************************************************dnl define(AUG_ON, dnl `define(`AUG_STACK',incr(AUG_STACK))ifelse(AUG_STACK,1,`@@aug_ON@@')ifelse(AUG_STACK,0,`dnl #ifdef AUGdnl aug_on_();dnl #endifdnl ')')dnl define(AUG_OFF, `define(`AUG_STACK',eval(AUG_STACK-1))ifelse(AUG_STACK,-1,`dnl #ifdef AUGdnl aug_off_();dnl #endifdnl ')')dnl dnl define(AUG_DELAY, `{AUG_OFF SYS_THREAD_PTR->clock+=($1);AUG_ON}')dnl define(DECVAR, `struct $1TYP{sys_mon_t mon;$4}$1[ifelse($3,,1,$3)];')dnl define(GET_PID_F, `(SYS_THREAD_PTR->user_pid)')dnl dnl dnl dnl define(NU_MALLOC_F, `sim_malloc($1,$2,__LINE__,__FILE__)')dnl define(NU_MALLOC, `NU_MALLOC_F($1,$2);')dnl define(ST_LOG, `{AUG_OFF sim_sync_event($1,ifelse($2,,-1,(int)($2)),ifelse($3,,-1,(int)($3)),ifelse($4,,-1,(int)($4)),ifelse($5,,-1,(int)($5)),__LINE__,__FILE__);AUG_ON}')dnl dnl define(G_MALLOC_F, `NU_MALLOC_F($1,PAGE_GENERIC)')dnl define(G_FREE, `NU_FREE($1)')dnl dnl dnl define(GET_HOME, `{int sys_r,sys_a=(int)($2);dnl ST_LOG(ST_GET_PAGETYPE,&sys_r,sys_a)($1)=sys_r;}')dnl dnl dnl define(NU_FREE, `{int sys_a=(int)($1);ST_LOG(ST_GFREE,sys_a)}')dnl define(SET_HOME, `{int sys_a=(int)&($1),sys_b=(int)($2);dnl ST_LOG(ST_SET_PAGETYPE,sys_a,sys_b)}')dnl dnl define(MONINIT, `{unsigned sys_i;int sys_b=(int)($2);dnl for(sys_i=0;sys_i<(ifelse($3,,1,$3));sys_i++){int sys_a=(int)&(($1)[sys_i]);dnl ST_LOG(ST_MONINIT,sys_a,sys_b)}}')dnl define(MENTER, `{int sys_a=(int)&(($1)[ifelse($2,,0,$2)]);dnl ST_LOG(ST_MENTER,sys_a)}')dnl define(DELAY, `{int sys_a=(int)&(($1)[ifelse($3,,0,$3)]),sys_b=(int)(ifelse($2,,0,$2));dnl ST_LOG(ST_DELAY,sys_a,sys_b)}')dnl define(CONTINUE, `{int sys_a=(int)&(($1)[ifelse($3,,0,$3)]),sys_b=(int)(ifelse($2,,0,$2));dnl ST_LOG(ST_CONTINUE,sys_a,sys_b)if(sys_t())goto `L'ENDLAB;}')dnl define(MEXIT, `{int sys_a=(int)&(($1)[ifelse($2,,0,$2)]);dnl ST_LOG(ST_MEXIT,sys_a)`L'ENDLAB:define(`ENDLAB',incr(ENDLAB));}')dnl dnl define(SEMDEC, `sys_sem_t ($1)[ifelse($2,,1,$2)];')dnl define(SEMINIT, `{unsigned sys_k;int sys_a,sys_b=(int)($2);dnl for(sys_k=0;sys_k<(ifelse($3,,1,$3));sys_k++){dnl sys_a=(int)&(($1)[sys_k]);ST_LOG(ST_SEM_INIT,sys_a,sys_b)}}')dnl define(SEMP, `{int sys_a=(int)&(($1)[ifelse($2,,0,$2)]);dnl ST_LOG(ST_SEM_OP,sys_a,-1)}')dnl define(SEMV, `{int sys_a=(int)&(($1)[ifelse($2,,0,$2)]);dnl ST_LOG(ST_SEM_OP,sys_a,1)}')dnl dnl define(GSDEC, `sys_gs_t ($1)[ifelse($2,,1,$2)];')dnl define(GSINIT, `{unsigned sys_k;dnl for(sys_k=0;sys_k<(ifelse($2,,1,$2));sys_k++){dnl int sys_a=(int)&(($1)[sys_k]);ST_LOG(ST_GS_INIT,sys_a)}}')dnl define(GETSUB, `{dnl int sys_a=(int)&(($1)[ifelse($5,,0,$5)]),sys_b=(int)&($2),sys_c=(int)($3),sys_d=(int)($4);dnl ST_LOG(ST_GS_ENTER,sys_a,sys_b,sys_c,sys_d)}')dnl define(WEAKGETSUB, `{dnl int sys_a=(int)&(($1)[ifelse($4,,0,$4)]),sys_b=(int)&($2),sys_c=(int)($3);dnl ST_LOG(ST_GS_EXIT,sys_a,sys_b,sys_c)}')dnl dnl dnl dnl define(NLOCKDEC, `LOCKDEC($1,$2)')dnl define(NLOCKINIT, `LOCKINIT($1,$2)')dnl define(NLOCK, `LOCK($1,$2)')dnl define(NUNLOCK, `UNLOCK($1,$2)')dnl divert(0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -