-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_lib.h
More file actions
48 lines (38 loc) · 1.11 KB
/
Copy pathbasic_lib.h
File metadata and controls
48 lines (38 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <stdint.h>
#ifndef NULL
#define NULL ((void *)0)
#endif
void zero_mem(void *addr, uint64_t size);
void copy_mem(void *target, void *source, uintptr_t size);
int bit_scan(uint64_t value);
uintptr_t bitmap_find_first_zero(uint8_t *bitmap, uintptr_t len);
#define DEBUG_SERIAL_PORT 0x3f8
#define PRINTF(fmt, ...) serial_print(fmt, ##__VA_ARGS__)
void serial_print(const char *fmt, ...);
static inline void bitmap_set_bit(uint8_t *bits, uint32_t index)
{
bits[index / 8] |= 1 << (index % 8);
}
static inline void bitmap_clear_bit(uint8_t *bits, uint32_t index)
{
bits[index / 8] &= ~(1 << (index % 8));
}
static inline int bitmap_get_bit(uint8_t *bits, uint32_t index)
{
return (bits[index / 8] >> (index % 8)) & 1;
}
#define PANIC() \
{ \
for (;;) \
; \
}
#define ASSERT(expression) \
{ \
if (!(expression)) \
{ \
PRINTF("Assertion failed:" \
" " #expression "\n"); \
PANIC() \
} \
}