You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
1.0 KiB

void *memset(void *s, int c, unsigned int len)
{
unsigned char* p=s;
while(len--)
{
*p++ = (unsigned char)c;
}
return s;
}
void *memmove(void *dest, void *src, int n)
{
// Typecast src and dest addresses to (char *)
char *csrc = (char *)src;
char *cdest = (char *)dest;
// Copy contents of src[] to dest[]
for (int i = 0; i < n; i++)
cdest[i] = csrc[i];
return dest;
}
void *memcpy(void *dest, void *src, int n)
{
return memmove(dest, src, n);
}
extern unsigned int _sbss, _ebss, _sidata, _sdata, _edata;
static volatile int sisyphus = 0;
int main(void) {
// Increment a variable.
while (1) {
++sisyphus;
}
return 0;
}
// Startup logic; this is the application entry point.
void __attribute__((noreturn)) call_start_cpu0() {
// Clear BSS.
memset(&_sbss, 0, (&_ebss - &_sbss) * sizeof(_sbss));
// Copy initialized data.
memmove(&_sdata, &_sidata, (&_edata - &_sdata) * sizeof(_sdata));
// Done, branch to main
main();
// (Should never be reached)
while (1) {
}
}