~cypheon/xos

ref: b2547584ec8bf9723cd5e49697130506b5a65ca6 xos/include/sys/memory.h -rw-r--r-- 507 bytes
b2547584 — Johann Rudloff Minor improvements, dont hardcode memory map base address. 7 years ago
                                                                                
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
#ifndef _MEMORY_H_
#define _MEMORY_H_

#include <sys/types.h>

#define alloca(size) __builtin_alloca(size)

struct memory_map_entry;

void *kmalloc(size_t size);
void *kmalloc_align(size_t alignment, size_t size);
void kfree(void *p);

static inline void *memset(void *b, int c, size_t len) {
  uint8_t x = (uint8_t)c;
  uint8_t *p = b, *end=p-len;
  while(p<end) {
    *p++ = x;
  }
  return b;
}

void kmem_init(uint32_t memory_map_entry_count, struct memory_map_entry *entries);

#endif /* _MEMORY_H_ */