Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/example_dtree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SETUP_EXECUTABLE(example_dtree)

target_link_libraries(example_dtree PRIVATE device_tree_access Debug startup stdbigos)
target_link_libraries(example_dtree PRIVATE dt_access Debug startup stdbigos)

ADD_QEMU_TARGET(example_dtree)
5 changes: 0 additions & 5 deletions src/example_trap/CMakeLists.txt

This file was deleted.

78 changes: 0 additions & 78 deletions src/example_trap/entry.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/example_umode_concurrency/CMakeLists.txt

This file was deleted.

119 changes: 0 additions & 119 deletions src/example_umode_concurrency/entry.c

This file was deleted.

2 changes: 1 addition & 1 deletion src/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SETUP_EXECUTABLE(kernel)

target_compile_definitions(kernel PRIVATE $<IF:$<CONFIG:DEBUG>,__DEBUG__ __LOGLVL__=3, __LOGLVL__=1>)
target_link_libraries(kernel PRIVATE Debug stdbigos hal)
target_link_libraries(kernel PRIVATE Debug stdbigos dt_access)

target_link_options(kernel PRIVATE -static-pie -e kinit)

Expand Down
Empty file.
35 changes: 35 additions & 0 deletions src/kernel/address_space/address_space.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef KERNEL_ADDRESS_SPACE_ADDRESS_SPACE
#define KERNEL_ADDRESS_SPACE_ADDRESS_SPACE

#include "stdbigos/error.h"
#include "stdbigos/types.h"

typedef enum : u16 {
AS_FLAGS_READ = (1ull << 0),
Comment thread
frogrammer9 marked this conversation as resolved.
AS_FLAGS_WRITE = (1ull << 1),
AS_FLAGS_EXECUTE = (1ull << 2),
AS_FLAGS_MAPPED = (1ull << 3),
AS_FLAGS_GLOBAL = (1ull << 4),
AS_FLAGS_USER = (1ull << 5),
} address_space_region_flags_t;

typedef struct {
Comment thread
frogrammer9 marked this conversation as resolved.
address_space_region_flags_t flags;
void* addr;
size_t size;
} address_space_region_t;

typedef struct {
address_space_region_t* regions;
size_t regions_count;
bool does_manage_own_memory;
bool active;
} address_space_t;

error_t address_space_init();

error_t address_space_init_from_buffer(address_space_region_t* regions, size_t count);

error_t address_space_delegate_memory_management(void** addrOUT);

#endif // !KERNEL_ADDRESS_SPACE_ADDRESS_SPACE
1 change: 1 addition & 0 deletions src/kernel/hal/arch/riscv/address_space.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "hal/include/address_space.h"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <hal/memory_regions.h>
#include <stdbigos/error.h>

#include "hal/include/memory_regions.h"

typedef struct {
u32 idx;
bool is_in_resmem;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "trap.h"
#include "hal/include/trap.h"

#include <debug/debug_stdio.h>
#include <hal/trap.h>
#include <stdbigos/error.h>
#include <stdbigos/math.h>
#include <stdbigos/string.h>
Expand All @@ -10,6 +9,7 @@

#include "csr.h"
#include "csr_vals.h"
#include "trap.h"

extern void hal_riscv_trap_entry();
extern void hal_riscv_trap_restore(void*);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef HAL_ARCH_RISCV_TRAP_H
#define HAL_ARCH_RISCV_TRAP_H

#include <hal/trap.h>
#include <stdbigos/types.h>

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hal/hal.c → src/kernel/hal/hal.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <hal/hal.h>
#include "hal/include/hal.h"

#include "dt/dt.h"

Expand Down
File renamed without changes.
45 changes: 45 additions & 0 deletions src/kernel/hal/include/address_space.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef HAL_ADDRESS_SPACE
#define HAL_ADDRESS_SPACE

#include "stdbigos/error.h"
#include "stdbigos/memory_types.h"
#include "stdbigos/types.h"

typedef struct {
alignas(64) u8 data[32];
} hal_address_space_t;

typedef enum : u16 {
HAL_ASR_FLAGS_READ = (1ull << 0),
Comment thread
frogrammer9 marked this conversation as resolved.
HAL_ASR_FLAGS_WRITE = (1ull << 1),
HAL_ASR_FLAGS_EXECUTE = (1ull << 2),
} hal_address_region_flag_t;

typedef enum : u16 {
HAL_AS_GLOBAL = (1ull << 0),
HAL_AS_USER = (1ull << 1),
} hal_address_space_flag_t;

error_t hal_enable_virtual_address_spaces(hal_address_space_t* initial_as);

error_t hal_address_space_init(hal_address_space_t* as, hal_address_space_flag_t flags);

/**
* @brief Gets an array of available frame sizes
*
* Returns an array of available frame sizes in ascending order
*
* @param countOUT Pointer to a variable where the size of the array will be written to
* @returns Pointer to the first element of the array
* */
[[nodiscard]] [[gnu::nonnull]]
const u32* hal_get_available_frame_sizes(u32* countOUT);

error_t hal_address_space_set_active(hal_address_space_t* as);

error_t hal_address_space_map(hal_address_space_t as, uintptr_t vaddr, physical_memory_region_t pmem,
hal_address_region_flag_t flags);

error_t hal_address_space_unmap(hal_address_space_t as, uintptr_t vaddr, physical_memory_region_t* pmemOUT);

#endif // !HAL_ADDRESS_SPACE
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/kernel/memory_management/physical_memory/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdbigos/string.h>

#include "allocator.h"
#include "hal/memory_regions.h"
#include "hal/include/memory_regions.h"
#include "stdbigos/address.h"
#include "stdbigos/error.h"
#include "stdbigos/types.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
file(GLOB CHILDREN RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
foreach(CHILD ${CHILDREN})
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${CHILD})
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${CHILD} AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CHILD}/CMakeLists.txt)
add_subdirectory(${CHILD})
endif()
endforeach()
4 changes: 2 additions & 2 deletions src/lib/dt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SETUP_LIBRARY(device_tree_access)
SETUP_LIBRARY(dt_access)

target_link_libraries(device_tree_access
target_link_libraries(dt_access
PUBLIC stdbigos
PRIVATE Debug
)
7 changes: 0 additions & 7 deletions src/lib/hal/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/startup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ SETUP_LIBRARY(startup)

set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)

target_link_libraries(startup PRIVATE hal relocations stdbigos)
target_link_libraries(startup PRIVATE relocations stdbigos)
target_link_options(startup PUBLIC -static-pie -T ${LINKER_SCRIPT})
set_target_properties(startup PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
Loading
Loading