opuntiaOS - an operating system targeting x86 and ARMv7
1/*
2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors.
3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com>
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef _BOOT_LIBBOOT_MEM_MEM_H
10#define _BOOT_LIBBOOT_MEM_MEM_H
11
12#include <libboot/types.h>
13
14int strcmp(const char* a, const char* b);
15int strncmp(const char* a, const char* b, uint32_t num);
16size_t strlen(const char* s);
17void* memset(void* dest, uint8_t fll, uint32_t nbytes);
18void* memcpy(void* dest, const void* src, uint32_t nbytes);
19void* memccpy(void* dest, const void* src, uint8_t stop, uint32_t nbytes);
20void* memmove(void* dest, const void* src, uint32_t nbytes);
21int memcmp(const void* src1, const void* src2, uint32_t nbytes);
22
23static size_t align_size(size_t size, size_t align)
24{
25 if (size % align) {
26 size += align - (size % align);
27 }
28 return size;
29}
30
31static inline void* copy_after_kernel(size_t kbase, void* from, size_t size, size_t* kernel_size, size_t align)
32{
33 void* pp = (void*)(kbase + *kernel_size);
34 memcpy(pp, from, size);
35 *kernel_size += align_size(size, align);
36 return pp;
37}
38
39static inline void* paddr_to_vaddr(void* ptr, size_t pbase, size_t vbase)
40{
41 return (void*)((size_t)ptr - pbase + vbase);
42}
43
44#endif // _BOOT_LIBBOOT_MEM_MEM_H