#ifndef __UTILS__ #define __UTILS__ #include "types.h" // General operations #define STR32(ADDR,VALUE) *((volatile unsigned int*) (ADDR))=(VALUE) #define LDR32(ADDR) (*((volatile unsigned int*) (ADDR))) // Registers operations #define REG_WRITE(ADDR,VALUE) STR32(ADDR,VALUE) #define REG_WRITE_XOR(ADDR,VALUE) STR32(ADDR+0x1000,VALUE) #define REG_WRITE_BITMAP_SET(ADDR,VALUE) STR32(ADDR+0x2000,VALUE) #define REG_WRITE_BITMAP_CLEAR(ADDR,VALUE) STR32(ADDR+0x3000,VALUE) #define REG_READ(ADDR) LDR32(ADDR) // Memory operations void memcpy(u8 *dst, u8 *src, u32 size); // TODO: Improve perf with 32bits memory transactions void memset(u8 *start, u8 value, u32 size); // TODO: Improve perf with 32bits memory transactions // Computations int modulo(int dividend, int divisor); // Assumes that both argument are positve (TODO improve this) // Strings (not these functions do not follow libc standards and are buggy) int strlen(char * cp); int wordlen(char *s); u8 strcmp(char *str1, char*str2); u8 strncmp(char *str1, char*str2, int n); #endif