First commit, Vystem v0.1
This commit is contained in:
12
shelter/lib/include/std/malloc.h
Normal file
12
shelter/lib/include/std/malloc.h
Normal file
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
#ifndef SH_LIB_MALLOC_H
|
||||
#define SH_LIB_MALLOC_H
|
||||
#include "std/status.h"
|
||||
#include "std/type.h"
|
||||
// Return last status
|
||||
SH_STATUS sh_malloc_get_last_status();
|
||||
// Allocate memory
|
||||
void* sh_malloc(sh_uint64 size);
|
||||
// Free memory
|
||||
void sh_free(void *ptr);
|
||||
#endif
|
||||
12
shelter/lib/include/std/mem.h
Normal file
12
shelter/lib/include/std/mem.h
Normal file
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
#ifndef SH_LIB_MEM_H
|
||||
#define SH_LIB_MEM_H
|
||||
#include "std/type.h"
|
||||
#include "std/status.h"
|
||||
// Memory comparaison function
|
||||
SH_STATUS sh_mem_compare(const void *a,const void *b,sh_uint64 size);
|
||||
// Memory copy function
|
||||
SH_STATUS sh_mem_copy(const void *destination,const void *source,sh_uint64 size);
|
||||
// Memory set function
|
||||
SH_STATUS sh_mem_set_8(sh_uint8 *ptr,const sh_uint8 byte,sh_uint64 count);
|
||||
#endif
|
||||
43
shelter/lib/include/std/status.h
Normal file
43
shelter/lib/include/std/status.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
#ifndef SH_LIB_STATUS_H
|
||||
#define SH_LIB_STATUS_H
|
||||
#include "std/type.h"
|
||||
typedef sh_int64 SH_STATUS;
|
||||
#define SH_STATUS_NEW_SLAB_ADDED -5LL
|
||||
#define SH_STATUS_VA_FULLY_MAPPED -4LL
|
||||
#define SH_STATUS_VA_PARTIALLY_MAPPED -3LL
|
||||
#define SH_STATUS_VA_NOT_MAPPED -2LL
|
||||
#define SH_STATUS_VA_MAPPED -1LL
|
||||
#define SH_STATUS_SUCCESS 0LL
|
||||
#define SH_STATUS_INVALID_PARAMETER 1LL
|
||||
#define SH_STATUS_MEM_NOT_EQUAL 2LL
|
||||
#define SH_STATUS_INVALID_SIGNATURE 3LL
|
||||
#define SH_STATUS_MMAP_BUFFER_OVERFLOW 4LL
|
||||
#define SH_STATUS_PMAP_NO_PAGES_SET 5LL
|
||||
#define SH_STATUS_PT_POOL_NO_BITMAP_INIT 6LL
|
||||
#define SH_STATUS_PT_POOL_NO_PAGE_SET 7LL
|
||||
#define SH_STATUS_OUT_OF_MEMORY 8LL
|
||||
#define SH_STATUS_INVALID_INTERNAL_PA 9LL
|
||||
#define SH_STATUS_KERNEL_PANIC 10LL
|
||||
#define SH_STATUS_PTP_FULL 11LL
|
||||
#define SH_STATUS_ERROR_VA_FULLY_MAPPED 12LL
|
||||
#define SH_STATUS_ERROR_VA_PARTIALLY_MAPPED 13LL
|
||||
#define SH_STATUS_ERROR_VA_NOT_MAPPED 14LL
|
||||
#define SH_STATUS_SLAB_ALLOCATOR_FULL 15LL
|
||||
#define SH_STATUS_NOT_FOUND 16LL
|
||||
#define SH_STATUS_RESCAN_NEEDED 17LL
|
||||
#define SH_STATUS_ERROR_NULLPTR_RETURNED 18LL
|
||||
#define SH_STATUS_ERROR_PEZ_INITIALIZED 19LL
|
||||
#define SH_STATUS_SLAB_SLOT_ALREADY_FREE 20LL
|
||||
#define SH_STATUS_TEST_FAILED 21LL
|
||||
#define SH_STATUS_PBA_FULL 22LL
|
||||
#define SH_STATUS_FOUND_CORRUPTED_SLAB 23LL
|
||||
#define SH_STATUS_PEZ_CORRUPTED 24LL
|
||||
#define SH_STATUS_PAGE_ALREADY_FREE 25LL
|
||||
#define SH_STATUS_TOO_MUCH_DATA 26LL
|
||||
#define SH_STATUS_HEAP_NOT_INITIALIZED 27LL
|
||||
// Return SH_TRUE if provided status is an error
|
||||
static inline sh_bool sh_status_error(SH_STATUS s) {
|
||||
return s>=SH_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
#endif
|
||||
7
shelter/lib/include/std/stdlib.h
Normal file
7
shelter/lib/include/std/stdlib.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
// This header is just here to include all standard header
|
||||
// If you are looking for printing functions, take a look at kernel/log.h
|
||||
#include "std/mem.h"
|
||||
#include "std/malloc.h"
|
||||
#include "std/status.h"
|
||||
#include "std/type.h"
|
||||
35
shelter/lib/include/std/type.h
Normal file
35
shelter/lib/include/std/type.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
#ifndef SH_LIB_TYPE_H
|
||||
#define SH_LIB_TYPE_H
|
||||
typedef signed char sh_int8;
|
||||
typedef unsigned char sh_uint8;
|
||||
typedef signed short sh_int16;
|
||||
typedef unsigned short sh_uint16;
|
||||
typedef signed int sh_int32;
|
||||
typedef unsigned int sh_uint32;
|
||||
typedef signed long long sh_int64;
|
||||
typedef unsigned long long sh_uint64;
|
||||
#define SH_INT8_MAX 127
|
||||
#define SH_INT8_MIN (-128)
|
||||
#define SH_UINT8_MAX 0xFF
|
||||
#define SH_INT16_MAX 32767
|
||||
#define SH_INT16_MIN (-32768)
|
||||
#define SH_UINT16_MAX 0xFFFF
|
||||
#define SH_INT32_MAX 2147483647
|
||||
#define SH_INT32_MIN (-2147483647-1)
|
||||
#define SH_UINT32_MAX 0xFFFFFFFFU
|
||||
#define SH_INT64_MAX 9223372036854775807LL
|
||||
#define SH_INT64_MIN (-9223372036854775807LL-1)
|
||||
#define SH_UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
|
||||
#define SH_NULLPTR ((void*)0)
|
||||
typedef sh_uint8 sh_bool;
|
||||
#define SH_TRUE ((sh_bool)1)
|
||||
#define SH_FALSE ((sh_bool)0)
|
||||
#define SH_DEFVALUE ((sh_uint64)0x446546614C547674)
|
||||
#define DEFAULT
|
||||
typedef sh_uint64 sh_iter64;
|
||||
typedef __builtin_va_list va_list;
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
#endif
|
||||
Reference in New Issue
Block a user