-
Notifications
You must be signed in to change notification settings - Fork 18
Added hal address space interface #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| 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 { | ||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
3 changes: 2 additions & 1 deletion
3
src/lib/hal/arch/riscv/memory_region.c → src/kernel/hal/arch/riscv/memory_region.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
|
|
||
|
|
||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.