Added header containing kernel typedefs for sandbox programs

This commit is contained in:
2022-12-29 10:25:50 +00:00
parent 84efc44710
commit 02b3be636b
4 changed files with 19 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
SANDBOX_DIR_LIST := $(sort $(dir $(wildcard ./*/.))) SANDBOX_DIR_LIST := $(filter-out ./include/,$(sort $(dir $(wildcard ./*/.))))
all: all:
@for prog in $(SANDBOX_DIR_LIST); do \ @for prog in $(SANDBOX_DIR_LIST); do \

View File

@@ -0,0 +1,8 @@
#ifndef SOCKS_TYPES_H_
#define SOCKS_TYPES_H_
#include <stdint.h>
typedef uintptr_t phys_addr_t;
#endif

View File

@@ -3,7 +3,7 @@
#include <stddef.h> #include <stddef.h>
#include <limits.h> #include <limits.h>
#include <stdint.h> #include <socks/types.h>
#define MEMBLOCK_INIT_MEMORY_REGION_COUNT 128 #define MEMBLOCK_INIT_MEMORY_REGION_COUNT 128
#define MEMBLOCK_INIT_RESERVED_REGION_COUNT 128 #define MEMBLOCK_INIT_RESERVED_REGION_COUNT 128
@@ -37,9 +37,9 @@ typedef enum memblock_region_status {
typedef struct memblock_region { typedef struct memblock_region {
/* the address of the first byte that makes up the region */ /* the address of the first byte that makes up the region */
uintptr_t base; phys_addr_t base;
/* the address of the last byte that makes up the region */ /* the address of the last byte that makes up the region */
size_t limit; phys_addr_t limit;
} memblock_region_t; } memblock_region_t;
typedef struct memblock_type { typedef struct memblock_type {
@@ -56,21 +56,21 @@ typedef struct memblock {
typedef struct memblock_iter { typedef struct memblock_iter {
memblock_index_t idx; memblock_index_t idx;
uintptr_t base; phys_addr_t base;
size_t limit; phys_addr_t limit;
} memblock_iter_t; } memblock_iter_t;
extern memblock_t memblock; extern memblock_t memblock;
extern int __next_mem_range(memblock_iter_t *it); extern int __next_mem_range(memblock_iter_t *it);
extern int memblock_add(uintptr_t base, size_t size); extern int memblock_add(phys_addr_t base, size_t size);
extern int memblock_reserve(uintptr_t base, size_t size); extern int memblock_reserve(phys_addr_t base, size_t size);
extern uintptr_t memblock_alloc(size_t size); extern phys_addr_t memblock_alloc(size_t size);
extern void __next_memory_region(memblock_iter_t *it, \ extern void __next_memory_region(memblock_iter_t *it, \
memblock_type_t *type_a, memblock_type_t *type_b, memblock_type_t *type_a, memblock_type_t *type_b,
uintptr_t start, uintptr_t end); phys_addr_t start, phys_addr_t end);
#endif #endif

View File

@@ -3,7 +3,7 @@ BUILD_DIR := $(SANDBOX_BUILD_DIR)/$(SANDBOX_PROG_NAME)
SRC := $(wildcard *.c) SRC := $(wildcard *.c)
OBJ := $(addprefix $(BUILD_DIR)/,$(SRC:.c=.o)) OBJ := $(addprefix $(BUILD_DIR)/,$(SRC:.c=.o))
CFLAGS := -g CFLAGS := -g "-I$(SANDBOX_BASE_DIR)/include"
$(BUILD_DIR)/$(SANDBOX_PROG_NAME): $(OBJ) $(BUILD_DIR)/$(SANDBOX_PROG_NAME): $(OBJ)
@mkdir -p $(@D) @mkdir -p $(@D)