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 "fmt.h"
#include "memory.h"
#include "i2c.h"
extern CfgData configData;
extern ConfigurationStatus needConfig;
@ -64,16 +63,12 @@ void main(int argc, char **argv)
for(; i < 41; i++)
launchedPath[i] = 0;
for(u32 i = 0; i < 8; i++)
launchedFirmTidLow[i] = 0;
memset(launchedFirmTidLow, 0, 16);
break;
}
case 2: //Firmlaunch
{
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
while(true);
u32 i;
u16 *p = (u16 *)argv[0];
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];
}
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)
{
u32 *dest32 = (u32 *)dest;
@ -80,4 +89,4 @@ u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize)
}
return NULL;
}
}

View File

@ -30,6 +30,7 @@
#include "types.h"
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);
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);