mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-18 16:08:53 +09:00
![Alexey Brodkin](/assets/img/avatar_default.png)
Even if ARC core might handle unaligned access to data this hardware feature by default is disabled. But GCC starting from 8.1.0 unconditionally uses it for ARC HS cores. Which leads to quite strange and fatal run-time failures like the one below if HW is not configured properly: | hsdk# sf probe | Misaligned data access exception @ 0xbff794d4 | ECR: 0x000d0000 | RET: 0xbff794d4 | BLINK: 0xbff79644 | STAT32: 0x00000800 | GP: 0x1003e000 r25: 0xbfd58f08 | BTA: 0xbff794a4 SP: 0xbfd58cd4 FP: 0xbfd58ef0 | LPS: 0xbff90240 LPE: 0xbff90244 LPC: 0x00000000 | r00: 0x00000000 r01: 0x00000003 r02: 0x000026bf | r03: 0x00000000 r04: 0x00000100 r05: 0x00000000 | r06: 0x00000001 r07: 0x00000000 r08: 0x1dcd6500 | r09: 0x00000000 r10: 0x00200000 r11: 0x00000000 | r12: 0x1b3d4440 r13: 0xbff9eca4 r14: 0xbfd59d68 | r15: 0xbfd60cd0 r16: 0x00000000 r17: 0x00000000 | r18: 0xbff9ed14 r19: 0xbfd59c78 r20: 0xbfd58d40 | r21: 0xbfd58d44 r22: 0x00000000 r23: 0x00000000 | r24: 0xbfd59ba8 | Resetting CPU ... Now we're checking for __ARC_UNALIGNED__ define emitted by the compiler if it's going to use unaligned access and then we force-enable it in hardware too. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
125 lines
2.9 KiB
ArmAsm
125 lines
2.9 KiB
ArmAsm
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
|
|
*/
|
|
|
|
#include <asm-offsets.h>
|
|
#include <config.h>
|
|
#include <linux/linkage.h>
|
|
#include <asm/arcregs.h>
|
|
|
|
ENTRY(_start)
|
|
/* Setup interrupt vector base that matches "__text_start" */
|
|
sr __ivt_start, [ARC_AUX_INTR_VEC_BASE]
|
|
|
|
; Disable/enable I-cache according to configuration
|
|
lr r5, [ARC_BCR_IC_BUILD]
|
|
breq r5, 0, 1f ; I$ doesn't exist
|
|
lr r5, [ARC_AUX_IC_CTRL]
|
|
#ifndef CONFIG_SYS_ICACHE_OFF
|
|
bclr r5, r5, 0 ; 0 - Enable, 1 is Disable
|
|
#else
|
|
bset r5, r5, 0 ; I$ exists, but is not used
|
|
#endif
|
|
sr r5, [ARC_AUX_IC_CTRL]
|
|
|
|
mov r5, 1
|
|
sr r5, [ARC_AUX_IC_IVIC]
|
|
; As per ARC HS databook (see chapter 5.3.3.2)
|
|
; it is required to add 3 NOPs after each write to IC_IVIC.
|
|
nop
|
|
nop
|
|
nop
|
|
|
|
1:
|
|
; Disable/enable D-cache according to configuration
|
|
lr r5, [ARC_BCR_DC_BUILD]
|
|
breq r5, 0, 1f ; D$ doesn't exist
|
|
lr r5, [ARC_AUX_DC_CTRL]
|
|
bclr r5, r5, 6 ; Invalidate (discard w/o wback)
|
|
#ifndef CONFIG_SYS_DCACHE_OFF
|
|
bclr r5, r5, 0 ; Enable (+Inv)
|
|
#else
|
|
bset r5, r5, 0 ; Disable (+Inv)
|
|
#endif
|
|
sr r5, [ARC_AUX_DC_CTRL]
|
|
|
|
mov r5, 1
|
|
sr r5, [ARC_AUX_DC_IVDC]
|
|
|
|
|
|
1:
|
|
#ifdef CONFIG_ISA_ARCV2
|
|
; Disable System-Level Cache (SLC)
|
|
lr r5, [ARC_BCR_SLC]
|
|
breq r5, 0, 1f ; SLC doesn't exist
|
|
lr r5, [ARC_AUX_SLC_CTRL]
|
|
bclr r5, r5, 6 ; Invalidate (discard w/o wback)
|
|
bclr r5, r5, 0 ; Enable (+Inv)
|
|
sr r5, [ARC_AUX_SLC_CTRL]
|
|
|
|
1:
|
|
#endif
|
|
|
|
#ifdef __ARC_UNALIGNED__
|
|
/*
|
|
* Enable handling of unaligned access in the CPU as by default
|
|
* this HW feature is disabled while GCC starting from 8.1.0
|
|
* unconditionally uses it for ARC HS cores.
|
|
*/
|
|
flag 1 << STATUS_AD_BIT
|
|
#endif
|
|
|
|
/* Establish C runtime stack and frame */
|
|
mov %sp, CONFIG_SYS_INIT_SP_ADDR
|
|
mov %fp, %sp
|
|
|
|
/* Allocate reserved area from current top of stack */
|
|
mov %r0, %sp
|
|
bl board_init_f_alloc_reserve
|
|
/* Set stack below reserved area, adjust frame pointer accordingly */
|
|
mov %sp, %r0
|
|
mov %fp, %sp
|
|
|
|
/* Initialize reserved area - note: r0 already contains address */
|
|
bl board_init_f_init_reserve
|
|
|
|
#ifdef CONFIG_DEBUG_UART
|
|
/* Earliest point to set up early debug uart */
|
|
bl debug_uart_init
|
|
#endif
|
|
|
|
/* Zero the one and only argument of "board_init_f" */
|
|
mov_s %r0, 0
|
|
bl board_init_f
|
|
|
|
/* We only get here if relocation is disabled by GD_FLG_SKIP_RELOC */
|
|
/* Make sure we don't lose GD overwritten by zero new GD */
|
|
mov %r0, %r25
|
|
mov %r1, 0
|
|
bl board_init_r
|
|
ENDPROC(_start)
|
|
|
|
/*
|
|
* void board_init_f_r_trampoline(stack-pointer address)
|
|
*
|
|
* This "function" does not return, instead it continues in RAM
|
|
* after relocating the monitor code.
|
|
*
|
|
* r0 = new stack-pointer
|
|
*/
|
|
ENTRY(board_init_f_r_trampoline)
|
|
/* Set up the stack- and frame-pointers */
|
|
mov %sp, %r0
|
|
mov %fp, %sp
|
|
|
|
/* Update position of intterupt vector table */
|
|
lr %r0, [ARC_AUX_INTR_VEC_BASE]
|
|
ld %r1, [%r25, GD_RELOC_OFF]
|
|
add %r0, %r0, %r1
|
|
sr %r0, [ARC_AUX_INTR_VEC_BASE]
|
|
|
|
/* Re-enter U-Boot by calling board_init_f_r */
|
|
j board_init_f_r
|
|
ENDPROC(board_init_f_r_trampoline)
|