Add memset

This commit is contained in:
TuxSH 2017-05-19 22:45:00 +02:00
parent 9f12a47cfc
commit 6ccc0f0538
3 changed files with 13 additions and 8 deletions

View File

@ -33,7 +33,6 @@
#include "crypto.h" #include "crypto.h"
#include "fmt.h" #include "fmt.h"
#include "memory.h" #include "memory.h"
#include "i2c.h"
extern CfgData configData; extern CfgData configData;
extern ConfigurationStatus needConfig; extern ConfigurationStatus needConfig;
@ -64,16 +63,12 @@ void main(int argc, char **argv)
for(; i < 41; i++) for(; i < 41; i++)
launchedPath[i] = 0; launchedPath[i] = 0;
for(u32 i = 0; i < 8; i++) memset(launchedFirmTidLow, 0, 16);
launchedFirmTidLow[i] = 0;
break; break;
} }
case 2: //Firmlaunch case 2: //Firmlaunch
{ {
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
while(true);
u32 i; u32 i;
u16 *p = (u16 *)argv[0]; u16 *p = (u16 *)argv[0];
for(i = 0; i < 40 && launchedPath[i] != 0; i++) for(i = 0; i < 40 && launchedPath[i] != 0; i++)

View File

@ -36,6 +36,15 @@ void memcpy(void *dest, const void *src, u32 size)
destc[i] = srcc[i]; destc[i] = srcc[i];
} }
void *memset(void *dest, u32 value, u32 size)
{
u8 *destc = (u8 *)dest;
for(u32 i = 0; i < size; i++) destc[i] = (u8)value;
return dest;
}
void memset32(void *dest, u32 filler, u32 size) void memset32(void *dest, u32 filler, u32 size)
{ {
u32 *dest32 = (u32 *)dest; u32 *dest32 = (u32 *)dest;

View File

@ -30,6 +30,7 @@
#include "types.h" #include "types.h"
void memcpy(void *dest, const void *src, u32 size); void memcpy(void *dest, const void *src, u32 size);
void *memset(void *dest, u32 value, u32 size) __attribute__((used));
void memset32(void *dest, u32 filler, u32 size); void memset32(void *dest, u32 filler, u32 size);
int memcmp(const void *buf1, const void *buf2, u32 size); int memcmp(const void *buf1, const void *buf2, u32 size);
u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize); u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize);