optim struct for code.

This commit is contained in:
zhangzheng
2024-09-17 19:31:16 +08:00
parent 354abcd569
commit dc99604239
18 changed files with 47 additions and 41 deletions

View File

@@ -2,7 +2,7 @@
#include <types.h> #include <types.h>
#include <util.h> #include <util.h>
#include <arch.h> #include <arch.h>
#include <rbtree_mm.h> #include <mmu/rbtree_mm.h>
enum vpage_prot_attrs enum vpage_prot_attrs
{ {

View File

@@ -29,7 +29,8 @@ endif()
if (DEFINED CONFIG_MMU) if (DEFINED CONFIG_MMU)
if (CONFIG_MMU STREQUAL "y") if (CONFIG_MMU STREQUAL "y")
file(GLOB mm_src mm/*.c mm/*.S) file(GLOB mm_src mm/*.c mm/*.S)
list(APPEND deps ${mm_src}) file(GLOB mm_mmu_src mm/mmu/*.c mm/mmu/*.S)
list(APPEND deps ${mm_src} ${mm_mmu_src})
endif() endif()
endif() endif()
@@ -47,4 +48,5 @@ target_include_directories(
${CMAKE_SOURCE_DIR}/mkrtos_knl/inc/drv ${CMAKE_SOURCE_DIR}/mkrtos_knl/inc/drv
${CMAKE_SOURCE_DIR}/mkrtos_knl/knl/mm ${CMAKE_SOURCE_DIR}/mkrtos_knl/knl/mm
${CMAKE_SOURCE_DIR}/mkrtos_knl/knl/mm/mmu
) )

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#include <mln_rbtree.h> #include "mln_rbtree.h"
void rbtree_mm_init(mln_rbtree_t *root_rbtree); void rbtree_mm_init(mln_rbtree_t *root_rbtree);

View File

@@ -365,6 +365,7 @@ static void task_release_stage2(kobject_t *kobj)
obj_space_release(&tk->obj_space, tk->lim); obj_space_release(&tk->obj_space, tk->lim);
#if !IS_ENABLED(CONFIG_MMU)
if (tk->mm_space.mm_block) { if (tk->mm_space.mm_block) {
#if CONFIG_MK_MPU_CFG #if CONFIG_MK_MPU_CFG
mm_limit_free_align(tk->lim, tk->mm_space.mm_block, tk->mm_space.mm_block_size); mm_limit_free_align(tk->lim, tk->mm_space.mm_block, tk->mm_space.mm_block_size);
@@ -372,6 +373,7 @@ static void task_release_stage2(kobject_t *kobj)
mm_limit_free(tk->lim, tk->mm_space.mm_block); mm_limit_free(tk->lim, tk->mm_space.mm_block);
#endif #endif
} }
#endif
#if IS_ENABLED(CONFIG_BUDDY_SLAB) #if IS_ENABLED(CONFIG_BUDDY_SLAB)
mm_limit_free_slab(task_slab, tk->lim, tk); mm_limit_free_slab(task_slab, tk->lim, tk);
#else #else

View File

@@ -2,12 +2,12 @@
# export TOOLCHAIN=/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/bin/ # export TOOLCHAIN=/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/ # export TOOLCHAIN_LIB=/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/ # export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp # export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
# export TOOLCHAIN=/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/ # export TOOLCHAIN=/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp # export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/ export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/ export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
export BOARD=STM32F205 export BOARD=STM32F205
export CROSS_COMPILE_NAME=arm-none-eabi- export CROSS_COMPILE_NAME=arm-none-eabi-

View File

@@ -1,15 +1,9 @@
#!/bin/bash #!/bin/bash
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/ # export TOOLCHAIN=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1 # export TOOLCHAIN_LIB=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/lib/gcc/aarch64-none-elf/11.3.1
export TOOLCHAIN=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/ export TOOLCHAIN=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
export TOOLCHAIN_LIB=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/lib/gcc/aarch64-none-elf/11.3.1 export TOOLCHAIN_LIB=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
# export TOOLCHAIN=/home/zhangzheng/arm-gnu-toolchain-13.3.rel1-aarch64-aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/arm-gnu-toolchain-13.3.rel1-aarch64-aarch64-none-elf/lib/gcc/aarch64-none-elf/13.3.1
# export TOOLCHAIN=/home/mkrtos-smart/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/mkrtos-smart/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
# export TOOLCHAIN=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
export BOARD=aarch64_qemu export BOARD=aarch64_qemu
export CROSS_COMPILE_NAME=aarch64-none-elf- export CROSS_COMPILE_NAME=aarch64-none-elf-
if [ -z "$1" ]; then if [ -z "$1" ]; then

View File

@@ -38,3 +38,15 @@
#define IS_MODULE(option) __is_defined(option##_MODULE) #define IS_MODULE(option) __is_defined(option##_MODULE)
#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
/* Import a binary file */
#define IMPORT_BIN(sect, file, sym) asm (\
".section " #sect "\n" /* Change section */\
".balign 4\n" /* Word alignment */\
".global " #sym "\n" /* Export the object address */\
#sym ":\n" /* Define the object label */\
".incbin \"" file "\"\n" /* Import the file */\
".global _sizeof_" #sym "\n" /* Export the object size */\
".set _sizeof_" #sym ", . - " #sym "\n" /* Define the object size */\
".balign 4\n" /* Word alignment */\
".section \".text\"\n") /* Restore section */

View File

@@ -23,6 +23,8 @@ target_link_libraries(uvmm.elf
cjson cjson
${GCC_LIB_PATH}/libgcc.a ${GCC_LIB_PATH}/libgcc.a
) )
# configure_file(src/benos.bin ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/uvmm.elf.dir/src/benos.bin COPYONLY)
# configure_file(src/vm_benos.json ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/uvmm.elf.dir/src/vm_benos.json COPYONLY)
target_include_directories( target_include_directories(
uvmm.elf uvmm.elf
PUBLIC PUBLIC

Binary file not shown.

View File

@@ -1,13 +1,17 @@
#include <printf.h>
#include <unistd.h>
#include <u_types.h>
#include "guest_os.h" #include "guest_os.h"
#include "u_task.h" #include "u_task.h"
#include <stdio.h>
#include "uvmm_dev_man.h" #include "uvmm_dev_man.h"
extern umword_t os_bin; #include <printf.h>
extern umword_t os_bin_end; #include <stdio.h>
#include <u_types.h>
#include <unistd.h>
#include <u_util.h>
extern const char benos_bin[], _sizeof_benos_bin[];
extern const char benos_json[], _sizeof_benos_json[];
extern umword_t uvmm_dev_json; extern umword_t uvmm_dev_json;
static guest_os_t gos; static guest_os_t gos;
int main(int argc, char *args[]) int main(int argc, char *args[])
@@ -17,11 +21,10 @@ int main(int argc, char *args[])
uvmm_dev_simul_init(); uvmm_dev_simul_init();
mk_printf("guest os entry addr:[0x%lx 0x%lx]\n", &os_bin, &os_bin_end); mk_printf("guest os entry addr:[0x%lx 0x%lx]\n", benos_bin, benos_bin + (umword_t)_sizeof_benos_bin);
guest_os_create(&gos, (char *)&uvmm_dev_json, guest_os_create(&gos, (char *)benos_json,
0x20000000, &os_bin, &os_bin_end, 32 * 1024 * 1024); 0x20000000, (void*)benos_bin, (void*)(benos_bin + (umword_t)_sizeof_benos_bin), 32 * 1024 * 1024);
while (1) while (1) {
{
sleep(1); sleep(1);
} }
// mk_printf("print test0.\n"); // mk_printf("print test0.\n");
@@ -42,3 +45,7 @@ int main(int argc, char *args[])
// } // }
return 0; return 0;
} }
IMPORT_BIN(".rodata", "/home/mkrtos-real/mkrtos_user/server/uvmm/src/benos.bin", benos_bin);
IMPORT_BIN(".rodata", "/home/mkrtos-real/mkrtos_user/server/uvmm/src/vm_benos.json", benos_json);

View File

@@ -1,13 +0,0 @@
.global os_bin
.global os_bin_end
.global uvmm_dev_json
.global uvmm_dev_json_end
.align 12
os_bin:
.incbin "/Users/zhangzheng/mkrtos-real/benos/arch/arm64/boot/benos.bin"
os_bin_end:
.quad 0
uvmm_dev_json:
.incbin "/Users/zhangzheng/mkrtos-real/mkrtos_user/server/uvmm/src/vm_benos.json"
uvmm_dev_json_end:
.quad 0