Skip to content

Commit

Permalink
smap-ingame: make gp register usage optional
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jun 11, 2021
1 parent 407c176 commit bd8f602
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/network/smap-ingame/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ SMapLowLevelOutput(NetIF *pNetIF, PBuf *pOutput)
struct pbuf *pbuf;
static unsigned char FrameBuffer[MAX_FRAME_SIZE];

#if USE_GP_REGISTER
void *OldGP;

OldGP = SetModuleGP();
#endif

if (pOutput->next != NULL) {
TotalLength = 0;
Expand All @@ -70,7 +72,9 @@ SMapLowLevelOutput(NetIF *pNetIF, PBuf *pOutput)

SMAPSendPacket(buffer, TotalLength);

#if USE_GP_REGISTER
SetGP(OldGP);
#endif

return ERR_OK;
}
Expand All @@ -85,15 +89,19 @@ static err_t SMapOutput(NetIF *pNetIF, PBuf *pOutput, IPAddr *pIPAddr)
err_t result;
PBuf *pBuf;

#if USE_GP_REGISTER
void *OldGP;

OldGP = SetModuleGP();
#endif

pBuf = etharp_output(pNetIF, pIPAddr, pOutput);

result = pBuf != NULL ? SMapLowLevelOutput(pNetIF, pBuf) : ERR_OK;

#if USE_GP_REGISTER
SetGP(OldGP);
#endif

return result;
}
Expand All @@ -103,9 +111,11 @@ static err_t SMapOutput(NetIF *pNetIF, PBuf *pOutput, IPAddr *pIPAddr)
//Should be called at the beginning of the program to set up the network interface.
static err_t SMapIFInit(NetIF *pNetIF)
{
#if USE_GP_REGISTER
void *OldGP;

OldGP = SetModuleGP();
#endif

pNetIF->name[0] = IFNAME0;
pNetIF->name[1] = IFNAME1;
Expand All @@ -131,7 +141,9 @@ static err_t SMapIFInit(NetIF *pNetIF)
//Enable sending and receiving of data.
SMAPStart();

#if USE_GP_REGISTER
SetGP(OldGP);
#endif

return ERR_OK;
}
Expand Down
12 changes: 12 additions & 0 deletions modules/network/smap-ingame/smap.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,11 @@ static int Dev9IntrCb(int flag)
USE_SPD_REGS;
volatile u8 *smap_regbase, *emac3_regbase;

#if USE_GP_REGISTER
void *OldGP;

OldGP = SetModuleGP();
#endif

emac3_regbase = SmapDriverData.emac3_regbase;
smap_regbase = SmapDriverData.smap_regbase;
Expand All @@ -378,7 +380,9 @@ static int Dev9IntrCb(int flag)
}
}

#if USE_GP_REGISTER
SetGP(OldGP);
#endif

return 0;
}
Expand Down Expand Up @@ -418,9 +422,11 @@ int SMAPStart(void)
int result;
volatile u8 *emac3_regbase;

#if USE_GP_REGISTER
void *OldGP;

OldGP = SetModuleGP();
#endif

if (!SmapDriverData.SmapIsInitialized) {
emac3_regbase = SmapDriverData.emac3_regbase;
Expand All @@ -443,7 +449,9 @@ int SMAPStart(void)
SmapDriverData.NetDevStopFlag = 0;
}

#if USE_GP_REGISTER
SetGP(OldGP);
#endif

return 0;
}
Expand All @@ -452,9 +460,11 @@ void SMAPStop(void)
{
volatile u8 *emac3_regbase;

#if USE_GP_REGISTER
void *OldGP;

OldGP = SetModuleGP();
#endif
SmapDriverData.NetDevStopFlag = 1;

if (SmapDriverData.SmapIsInitialized) {
Expand All @@ -466,7 +476,9 @@ void SMAPStop(void)
SmapDriverData.SmapIsInitialized = 0;
}

#if USE_GP_REGISTER
SetGP(OldGP);
#endif
}

static int ParseSmapConfiguration(const char *cmd, unsigned int *configuration)
Expand Down

0 comments on commit bd8f602

Please sign in to comment.