diff --git a/plat/common/arm/lcpu_start.S b/plat/common/arm/lcpu_start.S index 3768b335831093ac591ac1bdb9ed90291fcdd26f..3eab19e4bc7860c4bc8ee942fa72a7ab14778108 100644 --- a/plat/common/arm/lcpu_start.S +++ b/plat/common/arm/lcpu_start.S @@ -36,7 +36,10 @@ #include #include +.extern bootstrap_cpu_record .text + +#ifdef CONFIG_HAVE_SMP /* void _lcpu_start(lcpu_boot_args *bootargs) */ ENTRY(lcpu_start) /* save x0 */ @@ -69,3 +72,41 @@ ENTRY(lcpu_start) * not implemented */ br x9 END(lcpu_start) +#endif + +ENTRY(pick_bootstrap_cpu) + /* Only one cpu can continue executing as the primary core */ + ldr x1, =bootstrap_cpu_record + ldr x3, =BOOTSTRAP_CPU_FLAG_OFFSET + add x4, x1, x3 + +try_acquire_flag: + ldaxr w2, [x4] + cbz w2, set_bootstrap_flag + clrex + +hang: + /* If the cpus did not acquire the flag, hang here */ + wfe + +set_bootstrap_flag: + mov w3, #1 + /* Try to store 1 to the flag with release semantics */ + stlxr w2, w3, [x4] + /* Fail to set flag to 1, try again */ + cbnz x2, try_acquire_flag + + /* some core alreay acquire the flag, store its hardware ID + * But before that, convert it into format like aff3/aff2/aff1/aff0 + */ + mrs x2, mpidr_el1 + mov w3, w2 + and x3, x3, #MPIDR_AFF2_MASK|MPIDR_AFF1_MASK|MPIDR_AFF0_MASK + and x2, x2, #MPIDR_AFF3_MASK + orr x3, x3, x2, LSR #MPIDR_AFF3_SHIFT + ldr x2, =BOOTSTRAP_CPU_PHYSICAL_ID_OFFSET + add x4, x1, x2 + str x3, [x4] + + ret +END(pick_bootstrap_cpu) \ No newline at end of file diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk index 2362bbd2c7b87c3e6ec1727653d102c0b32d2d69..e955b3ed6700414a0333dd414b47a5244eb3a765 100644 --- a/plat/kvm/Makefile.uk +++ b/plat/kvm/Makefile.uk @@ -99,9 +99,9 @@ LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(UK_PLAT_COMMON_BASE)/arm/lcpu.c|arm64 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(UK_PLAT_COMMON_BASE)/arm/traps_arm64.c|isr LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(UK_PLAT_COMMON_BASE)/tls.c|common LIBKVMPLAT_SRCS-$(CONFIG_FPSIMD) += $(UK_PLAT_COMMON_BASE)/arm/fp_arm64.c|isr -ifeq ($(CONFIG_HAVE_SMP),y) +##ifeq ($(CONFIG_HAVE_SMP),y) LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(UK_PLAT_COMMON_BASE)/arm/lcpu_start.S -endif +##endif ifeq ($(CONFIG_KVM_VMM_QEMU),y) LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/qemu_bpt64.S|arm endif diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S index 5fdf65a75e12621ef63b8a8d37e04b7410fb1b48..3d4d93a49f857bcfa3cfefd9cf61697be2993d13 100644 --- a/plat/kvm/arm/entry64.S +++ b/plat/kvm/arm/entry64.S @@ -35,7 +35,7 @@ #include #include #include -#include +// #include #define BOOTSTACK_SIZE 4096 @@ -46,7 +46,7 @@ .space BOOTSTACK_SIZE lcpu_bootstack: -.extern bootstrap_cpu_record +//.extern bootstrap_cpu_record .extern lcpus .text ENTRY(_libkvmplat_entry) @@ -131,44 +131,48 @@ ENTRY(_libkvmplat_entry) /* Enable the mmu */ bl start_mmu - /* Only one cpu can continue executing as the primary core */ - ldr x1, =bootstrap_cpu_record - ldr x3, =BOOTSTRAP_CPU_FLAG_OFFSET - add x4, x1, x3 - -try_acquire_flag: - ldaxr w2, [x4] - cbz w2, set_bootstrap_flag - clrex - -hang: - /* If the cpus did not acquire the flag, hang here */ - wfe - -set_bootstrap_flag: - mov w3, #1 - /* Try to store 1 to the flag with release semantics */ - stlxr w2, w3, [x4] - /* Fail to set flag to 1, try again */ - cbnz x2, try_acquire_flag - - /* some core alreay acquire the flag, store its hardware ID - * But before that, convert it into format like aff3/aff2/aff1/aff0 - */ - mrs x2, mpidr_el1 - mov w3, w2 - and x3, x3, #MPIDR_AFF2_MASK|MPIDR_AFF1_MASK|MPIDR_AFF0_MASK - and x2, x2, #MPIDR_AFF3_MASK - orr x3, x3, x2, LSR #MPIDR_AFF3_SHIFT - ldr x2, =BOOTSTRAP_CPU_PHYSICAL_ID_OFFSET - add x4, x1, x2 - str x3, [x4] - /* If lcpus pointer not supported before lcpu_init() in setup.c, - * uk_pr_debug() will crash, so we support it manually for bootstrap cpu here. - */ + +// /* Only one cpu can continue executing as the primary core */ +// ldr x1, =bootstrap_cpu_record +// ldr x3, =BOOTSTRAP_CPU_FLAG_OFFSET +// add x4, x1, x3 + +//try_acquire_flag: +// ldaxr w2, [x4] +// cbz w2, set_bootstrap_flag +// clrex + +//hang: +// /* If the cpus did not acquire the flag, hang here */ +// wfe + +//set_bootstrap_flag: +// mov w3, #1 +// /* Try to store 1 to the flag with release semantics */ +// stlxr w2, w3, [x4] +// /* Fail to set flag to 1, try again */ +// cbnz x2, try_acquire_flag + +// /* some core alreay acquire the flag, store its hardware ID +// * But before that, convert it into format like aff3/aff2/aff1/aff0 +// */ +// mrs x2, mpidr_el1 +// mov w3, w2 +// and x3, x3, #MPIDR_AFF2_MASK|MPIDR_AFF1_MASK|MPIDR_AFF0_MASK +// and x2, x2, #MPIDR_AFF3_MASK +// orr x3, x3, x2, LSR #MPIDR_AFF3_SHIFT +// ldr x2, =BOOTSTRAP_CPU_PHYSICAL_ID_OFFSET +// add x4, x1, x2 +// str x3, [x4] +// /* If lcpus pointer not supported before lcpu_init() in setup.c, +// * uk_pr_debug() will crash, so we support it manually for bootstrap cpu here. +// */ +// */ + bl pick_bootstrap_cpu ldr x0, =lcpus msr tpidr_el1, x0 + /* Load dtb address to x0 as a parameter */ #if defined(CONFIG_KVM_BOOT_PROTO_LXBOOT) mov x0, x25 diff --git a/testPR.c b/testPR.c new file mode 100644 index 0000000000000000000000000000000000000000..d527c9bd5b28d291c25840069fac00e15950f2b9 --- /dev/null +++ b/testPR.c @@ -0,0 +1,7 @@ +#include +int main() +{ + // printf() 中字符串需要引号 + printf("Hello, Test!\n"); + return 0; +} \ No newline at end of file diff --git a/test_raspi.c b/test_raspi.c new file mode 100644 index 0000000000000000000000000000000000000000..8f144e27ca693f7cd4c8c53f2087225efc9d4b24 --- /dev/null +++ b/test_raspi.c @@ -0,0 +1,7 @@ +#include +int main() +{ + // printf() 中字符串需要引号 + printf("Hello, raspi-Test!\n"); + return 0; +} \ No newline at end of file