| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef __LIB_H__ |
| 6 |
#define __LIB_H__ |
| 7 |
|
| 8 |
#include <types.h> |
| 9 |
|
| 10 |
|
| 11 |
size_t ulzman(const void *src, size_t srcn, void *dst, size_t dstn); |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
void ram_check(uintptr_t start); |
| 16 |
int ram_check_nodie(uintptr_t start); |
| 17 |
int ram_check_noprint_nodie(uintptr_t start); |
| 18 |
void quick_ram_check_or_die(uintptr_t dst); |
| 19 |
|
| 20 |
|
| 21 |
int primitive_memtest(uintptr_t base, uintptr_t size); |
| 22 |
|
| 23 |
|
| 24 |
int checkstack(void *top_of_stack, int core); |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
void hexdump(const void *memory, size_t length); |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
size_t hexstrtobin(const char *str, uint8_t *buf, size_t len); |
| 47 |
|
| 48 |
|
| 49 |
static inline int popcnt(u32 x) { return __builtin_popcount(x); } |
| 50 |
|
| 51 |
static inline int clz(u32 x) { return x ? __builtin_clz(x) : sizeof(x) * 8; } |
| 52 |
|
| 53 |
static inline int log2(u32 x) { return sizeof(x) * 8 - clz(x) - 1; } |
| 54 |
|
| 55 |
static inline int __ffs(u32 x) { return log2(x & (u32)(-(s32)x)); } |
| 56 |
|
| 57 |
static inline int __fls(u32 x) { return log2(x); } |
| 58 |
|
| 59 |
|
| 60 |
static inline int log2_ceil(u32 x) { return (x == 0) ? -1 : log2(x - 1) + 1; } |
| 61 |
|
| 62 |
static inline int popcnt64(u64 x) { return __builtin_popcountll(x); } |
| 63 |
static inline int clz64(u64 x) { return x ? __builtin_clzll(x) : sizeof(x) * 8; } |
| 64 |
static inline int log2_64(u64 x) { return sizeof(x) * 8 - clz64(x) - 1; } |
| 65 |
static inline int __ffs64(u64 x) { return log2_64(x & (u64)(-(s64)x)); } |
| 66 |
static inline int __fls64(u64 x) { return log2_64(x); } |
| 67 |
|
| 68 |
#endif |