From 39f60018d18351d4db157cba2781286786e25eff Mon Sep 17 00:00:00 2001 From: Jyotheeswar Reddy Date: Tue, 17 Feb 2015 11:09:23 +0530 Subject: [PATCH] sw_apps:pmufw: Adding initial set of files for PMU Firmware App This initial version has the basic set of files required to build a basic firmware for PMU Microblaze in ZynqMP Signed-off-by: Jyotheeswar Reddy --- .../zynqmp_pmufw/data/zynqmp_pmufw.mss | 40 ++++ .../zynqmp_pmufw/data/zynqmp_pmufw.tcl | 87 +++++++++ lib/sw_apps/zynqmp_pmufw/src/lscript.ld | 172 ++++++++++++++++++ lib/sw_apps/zynqmp_pmufw/src/xpfw_main.c | 44 +++++ lib/sw_apps/zynqmp_pmufw/src/xpfw_start.S | 65 +++++++ 5 files changed, 408 insertions(+) create mode 100644 lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.mss create mode 100644 lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.tcl create mode 100644 lib/sw_apps/zynqmp_pmufw/src/lscript.ld create mode 100644 lib/sw_apps/zynqmp_pmufw/src/xpfw_main.c create mode 100644 lib/sw_apps/zynqmp_pmufw/src/xpfw_start.S diff --git a/lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.mss b/lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.mss new file mode 100644 index 00000000..496b42a5 --- /dev/null +++ b/lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.mss @@ -0,0 +1,40 @@ +#/****************************************************************************** +#* +#* Copyright (C) 2015 Xilinx, Inc. All rights reserved. +#* +#* Permission is hereby granted, free of charge, to any person obtaining a copy +#* of this software and associated documentation files (the "Software"), to deal +#* in the Software without restriction, including without limitation the rights +#* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#* copies of the Software, and to permit persons to whom the Software is +#* furnished to do so, subject to the following conditions: +#* +#* The above copyright notice and this permission notice shall be included in +#* all copies or substantial portions of the Software. +#* +#* Use of the Software is limited solely to applications: +#* (a) running on a Xilinx device, or +#* (b) that interact with a Xilinx device through a bus or interconnect. +#* +#* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +#* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +#* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +#* SOFTWARE. +#* +#* Except as contained in this notice, the name of the Xilinx shall not be used +#* in advertising or otherwise to promote the sale, use or other dealings in +#* this Software without prior written authorization from Xilinx. +#* +#******************************************************************************/ + +PARAMETER VERSION = 2.2.0 + + +BEGIN OS + PARAMETER OS_NAME = standalone + PARAMETER STDIN = * + PARAMETER STDOUT = * +END diff --git a/lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.tcl b/lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.tcl new file mode 100644 index 00000000..1bf86350 --- /dev/null +++ b/lib/sw_apps/zynqmp_pmufw/data/zynqmp_pmufw.tcl @@ -0,0 +1,87 @@ +#/****************************************************************************** +#* +#* Copyright (C) 2015 Xilinx, Inc. All rights reserved. +#* +#* Permission is hereby granted, free of charge, to any person obtaining a copy +#* of this software and associated documentation files (the "Software"), to deal +#* in the Software without restriction, including without limitation the rights +#* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#* copies of the Software, and to permit persons to whom the Software is +#* furnished to do so, subject to the following conditions: +#* +#* The above copyright notice and this permission notice shall be included in +#* all copies or substantial portions of the Software. +#* +#* Use of the Software is limited solely to applications: +#* (a) running on a Xilinx device, or +#* (b) that interact with a Xilinx device through a bus or interconnect. +#* +#* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +#* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +#* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +#* SOFTWARE. +#* +#* Except as contained in this notice, the name of the Xilinx shall not be used +#* in advertising or otherwise to promote the sale, use or other dealings in +#* this Software without prior written authorization from Xilinx. +#* +#******************************************************************************/ + +proc swapp_get_name {} { + return "ZynqMP PMU Firmware"; +} + +proc swapp_get_description {} { + return "Platform Management Unit Firmware for ZynqMP."; +} + +proc check_standalone_os {} { + set oslist [get_os]; + + if { [llength $oslist] != 1 } { + return 0; + } + set os [lindex $oslist 0]; + + if { $os != "standalone" } { + error "This application is supported only on the Standalone Board Support Package."; + } +} + +proc swapp_is_supported_sw {} { + return 1; +} + +proc swapp_is_supported_hw {} { + + # check processor type + set proc_instance [get_sw_processor]; + set hw_processor [get_property HW_INSTANCE $proc_instance] + + set proc_type [get_property IP_NAME [get_cells $hw_processor]]; + + if {($proc_type != "psu_microblaze") && ($proc_type != "microblaze")} { + error "This application is supported only for PMU Microblaze processor (psu_microblaze)."; + } + + return 1; +} + +proc get_stdout {} { + set os [get_os]; + set stdout [get_property CONFIG.STDOUT $os]; + return $stdout; +} + +proc swapp_generate {} { + # Nothing to be done here for now +} + +proc swapp_get_linker_constraints {} { + + # don't generate a linker script. PMU Firmware has its own linker script + return "lscript no"; +} diff --git a/lib/sw_apps/zynqmp_pmufw/src/lscript.ld b/lib/sw_apps/zynqmp_pmufw/src/lscript.ld new file mode 100644 index 00000000..b8fddd51 --- /dev/null +++ b/lib/sw_apps/zynqmp_pmufw/src/lscript.ld @@ -0,0 +1,172 @@ +/****************************************************************************** +* +* Copyright (C) 2015 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x1000; + +/* Define Memories in the system */ + +MEMORY +{ + /* This setting considers entire RAM. ROM entitiesare not considered */ + PMU_RAM : ORIGIN = 0xFFDC0000, LENGTH = 0x0001FF00 /* 128KB - _PERSISTENT256 */ +} + +/* Specify the default entry point to the program */ + +ENTRY(XPfw_Init) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors.reset 0xFFDC0000 : { + KEEP (*(.vectors.reset)) +} > PMU_RAM + +/* Only Reset vector is initialized. Other vectors are all zeros */ + +.vectors.sw_exception 0xFFDC0008 : { + FILL(0x00000000); + } > PMU_RAM + +.vectors.interrupt 0xFFDC0010 : { + FILL(0x00000000) +} > PMU_RAM + +.vectors.hw_exception 0xFFDC0020 : { + FILL(0x00000000) +} > PMU_RAM + +.text 0xFFDC0050: { + + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) +} > PMU_RAM + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > PMU_RAM + +.data : { + . = ALIGN(4); + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + __data_end = .; +} > PMU_RAM + +.sdata2 : { + . = ALIGN(8); + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + . = ALIGN(8); + __sdata2_end = .; +} > PMU_RAM + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > PMU_RAM + +.sdata : { + . = ALIGN(8); + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > PMU_RAM + +.sbss (NOLOAD) : { + . = ALIGN(4); + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + . = ALIGN(8); + __sbss_end = .; +} > PMU_RAM + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > PMU_RAM + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > PMU_RAM + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end = .; +} > PMU_RAM + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack definitions */ + +.stack (NOLOAD) : { + _stack_end = .; + . += _STACK_SIZE; + . = ALIGN(8); + _stack = .; + __stack = _stack; +} > PMU_RAM + +_end = .; +} diff --git a/lib/sw_apps/zynqmp_pmufw/src/xpfw_main.c b/lib/sw_apps/zynqmp_pmufw/src/xpfw_main.c new file mode 100644 index 00000000..dd208a45 --- /dev/null +++ b/lib/sw_apps/zynqmp_pmufw/src/xpfw_main.c @@ -0,0 +1,44 @@ +/****************************************************************************** +* +* Copyright (C) 2015 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ + +#include "xil_printf.h" +#include "xstatus.h" +#include "mb_interface.h" + +void XPfw_Main(void) +{ + xil_printf("PMU Firmware [Build: %s %s ] \r\n",__DATE__, __TIME__); + /* Put Microblaze to Sleep in an infinite loop */ + do{ + mb_sleep(); + } while(1); +} diff --git a/lib/sw_apps/zynqmp_pmufw/src/xpfw_start.S b/lib/sw_apps/zynqmp_pmufw/src/xpfw_start.S new file mode 100644 index 00000000..4454caa6 --- /dev/null +++ b/lib/sw_apps/zynqmp_pmufw/src/xpfw_start.S @@ -0,0 +1,65 @@ +/****************************************************************************** +* +* Copyright (C) 2015 Xilinx, Inc. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* Use of the Software is limited solely to applications: +* (a) running on a Xilinx device, or +* (b) that interact with a Xilinx device through a bus or interconnect. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Except as contained in this notice, the name of the Xilinx shall not be used +* in advertising or otherwise to promote the sale, use or other dealings in +* this Software without prior written authorization from Xilinx. +* +******************************************************************************/ + + .section .vectors.reset, "ax" + .align 2 +_vector_reset: + brai XPfw_Init + + /* FW StartUP Begins Here: Initialization of the Stack and Stack Protection. */ + .section .text + .globl XPfw_Init + .align 2 + .ent XPfw_Init + .type XPfw_Init, @function +XPfw_Init: + /* PMU Firmware does not reuse the ROM Stack. FW uses a separate stack of 4k (can be changed by user) */ + + /* Stack Initialization */ + addik r1, r0, _stack /* R1 is stack pointer, load Stack's highest address into SP. */ + addik r13, r0, _SDA_BASE_ /* The read-write small data anchor address */ + addik r2, r0, _SDA2_BASE_ /* The read-only small data anchor address */ + + + /* Stack Protection */ + addik r11, r0, _stack /* Load Stack's highest address into temp R11 */ + mts rshr, r11 /* Store Stack's highest address into STACK_HIGH_REGISTER */ + addik r11, r0, _stack_end /* Load Stack's lowest address into temp R11 */ + mts rslr, r11 /* Store Stack's lowest address into STACK_LOW_REGISTER */ + + /* Call Main */ + brlid r15, XPfw_Main + nop + /* Control never comes here */ + bri 0 + nop + .end XPfw_Init