Skip to content

Commit

Permalink
revert simple start-up
Browse files Browse the repository at this point in the history
gard UART int
NO_QNX definition
  • Loading branch information
miyazakh committed Jan 29, 2025
1 parent 456a6f8 commit b70987f
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 7 deletions.
3 changes: 2 additions & 1 deletion config/examples/raspi3.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ SIGN?=RSA4096
HASH?=SHA3
DEBUG?=1
VTOR?=1
NO_XIP?=1
SPMATH?=1
IMAGE_HEADER_SIZE?=1024
PKA?=1
WOLFTPM?=0
DEBUG_UART?=0
NO_XIP?=1
NO_QNX?=1
WOLFBOOT_SECTOR_SIZE=0x400
WOLFBOOT_NO_PARTITIONS=1
WOLFBOOT_LOAD_ADDRESS?=0x3080000
Expand Down
7 changes: 4 additions & 3 deletions hal/raspi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static inline void delay(int32_t count)
asm volatile("nop");
}
}
#if defined(DEBUG_UART)
/**
* write message to mailbox
*/
Expand Down Expand Up @@ -213,7 +214,7 @@ void uart_init()
/* enable UART0 transfer & receive*/
*UART0_CR = (1 << 0) | (1 << 8) | (1 << 9);
}

#endif
void* hal_get_primary_address(void)
{
return (void*)&kernel_addr;
Expand Down Expand Up @@ -300,7 +301,7 @@ void hal_init(void)
"0123456789abcdef";
wolfBoot_set_encrypt_key((uint8_t *)enc_key,(uint8_t *)(enc_key + 32));
#endif

#if defined(DEBUG_UART)
uart_init();

/* length of the message */
Expand Down Expand Up @@ -341,7 +342,7 @@ void hal_init(void)
wolfBoot_printf("\n M2MC clock : %d Hz", getclocks(13));
wolfBoot_printf("\n PIXEL_BVB clock : %d Hz\n", getclocks(14));
#endif

#endif
}

void hal_prepare_boot(void)
Expand Down
28 changes: 28 additions & 0 deletions hal/raspi3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* raspi3.h
*
* Copyright (C) 2025 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/

#ifndef _RASPI3_H_
#define _RASPI3_H_

#define USE_BUILTIN_STARTUP
#define USE_SIMPLE_STARTUP

#endif /* _RASPI3_H_ */
4 changes: 3 additions & 1 deletion options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ endif
ifeq ($(NO_XIP),1)
CFLAGS+=-D"NO_XIP"
endif

ifeq ($(NO_QNX),1)
CFLAGS+=-D"NO_QNX"
endif

ifeq ($(ALLOW_DOWNGRADE),1)
CFLAGS+= -D"ALLOW_DOWNGRADE"
Expand Down
2 changes: 1 addition & 1 deletion src/boot_aarch64.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* boot_aarch64.c
*
* Copyright (C) 2024 wolfSSL Inc.
* Copyright (C) 2025 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
Expand Down
54 changes: 53 additions & 1 deletion src/boot_aarch64_start.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "hal/nxp_ls1028a.h"
#endif

#ifdef TARGET_raspi3
#include "hal/raspi3.h"
#endif

/* GICv2 Register Offsets */
#ifndef GICD_BASE
#define GICD_BASE 0xF9010000
Expand Down Expand Up @@ -1028,7 +1032,55 @@ FPUStatus:
.skip 1

.align 8

#elif defined(USE_SIMPLE_STARTUP)
.section ".boot"
.global _vector_table
_vector_table:
mov x21, x0 // read ATAG/FDT address

4: ldr x1, =_vector_table // get start of .text in x1
// Read current EL
mrs x0, CurrentEL
and x0, x0, #0x0C

// EL == 3?
cmp x0, #12
bne 2f
3: mrs x2, scr_el3
orr x2, x2, 0x0F // scr_el3 |= NS|IRQ|FIQ|EA
msr scr_el3, x2

msr cptr_el3, xzr // enable FP/SIMD

// EL == 1?
2: cmp x0, #4
beq 1f

// EL == 2?
mov x2, #3 << 20
msr cptr_el2, x2 /* Enable FP/SIMD */
b 0f

1: mov x0, #3 << 20
msr cpacr_el1, x0 // Enable FP/SIMD for EL1
msr sp_el1, x1

/* Suspend slave CPUs */
0: mrs x3, mpidr_el1 // read MPIDR_EL1
and x3, x3, #3 // CPUID = MPIDR_EL1 & 0x03
cbz x3, 8f // if 0, branch forward
7: wfi // infinite sleep
b 7b

8: mov sp, x1 // set stack pointer
bl boot_entry_C // boot_entry_C never returns
b 7b // go to sleep anyhow in case.
#if 0
.section ".boot"
.global _vector_table
_vector_table:
bl boot_entry_C // boot_entry_C never returns
#endif
#endif /* !USE_BUILTIN_STARTUP */


Expand Down

0 comments on commit b70987f

Please sign in to comment.