Bin Meng | e1c1364 | 2019-07-18 00:34:34 -0700 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Xtensa |
| 4 | ====== |
Chris Zankel | de5e5ce | 2016-08-10 18:36:43 +0300 | [diff] [blame] | 5 | |
| 6 | Xtensa Architecture and Diamond Cores |
| 7 | ------------------------------------- |
| 8 | |
| 9 | Xtensa is a configurable processor architecture from Tensilica, Inc. |
| 10 | Diamond Cores are pre-configured instances available for license and |
| 11 | SoC cores in the same manner as ARM, MIPS, etc. |
| 12 | |
| 13 | Xtensa licensees create their own Xtensa cores with selected features |
| 14 | and custom instructions, registers and co-processors. The custom core |
| 15 | is configured with Tensilica tools and built with Tensilica's Xtensa |
| 16 | Processor Generator. |
| 17 | |
| 18 | There are an effectively infinite number of CPUs in the Xtensa |
| 19 | architecture family. It is, however, not feasible to support individual |
| 20 | Xtensa CPUs in U-Boot. Therefore, there is only a single 'xtensa' CPU |
| 21 | in the cpu tree of U-Boot. |
| 22 | |
| 23 | In the same manner as the Linux port to Xtensa, U-Boot adapts to an |
| 24 | individual Xtensa core configuration using a set of macros provided with |
| 25 | the particular core. This is part of what is known as the hardware |
| 26 | abstraction layer (HAL). For the purpose of U-Boot, the HAL consists only |
| 27 | of a few header files. These provide CPP macros that customize sources, |
| 28 | Makefiles, and the linker script. |
| 29 | |
| 30 | |
| 31 | Adding support for an additional processor configuration |
| 32 | -------------------------------------------------------- |
| 33 | |
| 34 | The header files for one particular processor configuration are inside |
| 35 | a variant-specific directory located in the arch/xtensa/include/asm |
| 36 | directory. The name of that directory starts with 'arch-' followed by |
| 37 | the name for the processor configuration, for example, arch-dc233c for |
| 38 | the Diamond DC233 processor. |
| 39 | |
Bin Meng | e1c1364 | 2019-07-18 00:34:34 -0700 | [diff] [blame] | 40 | core.h: |
| 41 | Definitions for the core itself. |
Chris Zankel | de5e5ce | 2016-08-10 18:36:43 +0300 | [diff] [blame] | 42 | |
| 43 | The following files are part of the overlay but not used by U-Boot. |
| 44 | |
Bin Meng | e1c1364 | 2019-07-18 00:34:34 -0700 | [diff] [blame] | 45 | tie.h: |
| 46 | Co-processors and custom extensions defined in the Tensilica Instruction |
| 47 | Extension (TIE) language. |
| 48 | tie-asm.h: |
| 49 | Assembly macros to access custom-defined registers and states. |
Chris Zankel | de5e5ce | 2016-08-10 18:36:43 +0300 | [diff] [blame] | 50 | |
| 51 | |
| 52 | Global Data Pointer, Exported Function Stubs, and the ABI |
| 53 | --------------------------------------------------------- |
| 54 | |
| 55 | To support standalone applications launched with the "go" command, |
| 56 | U-Boot provides a jump table of entrypoints to exported functions |
| 57 | (grep for EXPORT_FUNC). The implementation for Xtensa depends on |
| 58 | which ABI (or function calling convention) is used. |
| 59 | |
| 60 | Windowed ABI presents unique difficulties with the approach based on |
| 61 | keeping global data pointer in dedicated register. Because the register |
| 62 | window rotates during a call, there is no register that is constantly |
| 63 | available for the gd pointer. Therefore, on xtensa gd is a simple |
| 64 | global variable. Another difficulty arises from the requirement to have |
| 65 | an 'entry' at the beginning of a function, which rotates the register |
| 66 | file and reserves a stack frame. This is an integral part of the |
| 67 | windowed ABI implemented in hardware. It makes using a jump table to an |
| 68 | arbitrary (separately compiled) function a bit tricky. Use of a simple |
| 69 | wrapper is also very tedious due to the need to move all possible |
| 70 | register arguments and adjust the stack to handle arguments that cannot |
| 71 | be passed in registers. The most efficient approach is to have the jump |
| 72 | table perform the 'entry' so as to pretend it's the start of the real |
| 73 | function. This requires decoding the target function's 'entry' |
| 74 | instruction to determine the stack frame size, and adjusting the stack |
| 75 | pointer accordingly, then jumping into the target function just after |
| 76 | the 'entry'. Decoding depends on the processor's endianness so uses the |
| 77 | HAL. The implementation (12 instructions) is in examples/stubs.c. |
| 78 | |
| 79 | |
| 80 | Access to Invalid Memory Addresses |
| 81 | ---------------------------------- |
| 82 | |
| 83 | U-Boot does not check if memory addresses given as arguments to commands |
| 84 | such as "md" are valid. There are two possible types of invalid |
| 85 | addresses: an area of physical address space may not be mapped to RAM |
| 86 | or peripherals, or in the presence of MMU an area of virtual address |
| 87 | space may not be mapped to physical addresses. |
| 88 | |
| 89 | Accessing first type of invalid addresses may result in hardware lockup, |
| 90 | reading of meaningless data, written data being ignored or an exception, |
| 91 | depending on the CPU wiring to the system. Accessing second type of |
| 92 | invalid addresses always ends with an exception. |
| 93 | |
| 94 | U-Boot for Xtensa provides a special memory exception handler that |
| 95 | reports such access attempts and resets the board. |
| 96 | |
| 97 | |
Bin Meng | e1c1364 | 2019-07-18 00:34:34 -0700 | [diff] [blame] | 98 | .. Chris Zankel |
| 99 | .. Ross Morley |