int main(void) { unsigned char string[256]; struct md5_ctx ctx; unsigned int size; int ret; #ifdef REPEAT do { #else print_string("This is the emulated program. Will try to calculate MD5...\n"); #endif md5_init(&ctx); /* pass the string address above */ #ifdef TEST #define STR "A long text to hash, and hash, and hash and hash..." size = sizeof(STR)-1; memcpy(string, STR, size); md5_update(&ctx, size, string); md5_digest(&ctx, 16, string); return 0; #else ret = SYSCALL2(USER_SYSCALL(1), (unsigned int)string, sizeof(string)); if (ret > 0) { size = ret; md5_update(&ctx, size, string); md5_digest(&ctx, 16, string); #ifndef REPEAT ret = SYSCALL2(USER_SYSCALL(2), (unsigned int)string, 16); if (ret == 0) return 0; #endif } #endif #ifdef REPEAT } while(SYSCALL1(USER_SYSCALL(0),0)==0); #endif return 1; }
int uname(struct utsname *name) { if (!name) return -1; int err = SYSCALL2(SC_UNAME, (uint32_t)name, L_uname); if (!err) { return 0; } return -1; }
int open(const char *pathname, int flags) { return (int)SYSCALL2(SYSCALL_OPEN, pathname, flags); }
char *getcwd(char *buffer, size_t count) { return (char*)SYSCALL2(SC_GETCWD, (uint32_t)buffer, count); }
s64 ThreadCreate(thread_fnc fnc, void* param) { SYSCALL2(SYS_THREADCREATE, fnc, param); }