diff options
author | Sunil.Kumar <skumar8j@in.ibm.com> | 2016-03-21 06:48:13 -0500 |
---|---|---|
committer | Jennifer A. Stofer <stofer@us.ibm.com> | 2016-03-30 09:57:58 -0400 |
commit | 97121668bcf802e6931ffe9304efa2a03e4fc249 (patch) | |
tree | c25f223da93b25068ec87397cab07a79b57a6514 /sbe | |
parent | 3396216e9e5a59ecc0bcab6df18fac6300e1cd9b (diff) | |
download | talos-sbe-97121668bcf802e6931ffe9304efa2a03e4fc249.tar.gz talos-sbe-97121668bcf802e6931ffe9304efa2a03e4fc249.zip |
OTPROM Loader Code
Change-Id: Ia2e99e0731a2ce6671f2e1eaef99915534937768
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22274
Tested-by: Jenkins Server
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Reviewed-by: SRINIVAS V. POLISETTY <srinivan@in.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Diffstat (limited to 'sbe')
-rw-r--r-- | sbe/image/Makefile | 19 | ||||
-rw-r--r-- | sbe/image/img_defs.mk | 1 | ||||
-rw-r--r-- | sbe/image/linkotprom.cmd | 20 | ||||
-rw-r--r-- | sbe/image/pm_otprom_loader.S | 155 | ||||
-rw-r--r-- | sbe/image/sbe_link.H | 7 | ||||
-rw-r--r-- | sbe/image/topfiles.mk | 3 |
6 files changed, 202 insertions, 3 deletions
diff --git a/sbe/image/Makefile b/sbe/image/Makefile index f42f82ed..b77563cf 100644 --- a/sbe/image/Makefile +++ b/sbe/image/Makefile @@ -129,10 +129,13 @@ LINK_OBJS += $(OBJS) $(GCCLIBS) # Loader Objects LOADER_OBJS := $(addprefix $(OBJDIR)/, $(BASE_LOADER_OBJECTS)) +#Otprom Loader Objects +OTPROM_LOADER_OBJS := $(addprefix $(OBJDIR)/, $(OTPROM_LOADER_OBJECTS)) LINK_SCRIPT_SEEPROM = $(addprefix $(OBJDIR)/, linkscriptseeprom) LINK_SCRIPT_SBE = $(addprefix $(OBJDIR)/, linkscriptsbe) LINK_SCRIPT_LOADER = $(addprefix $(OBJDIR)/, linkscriptloader) +LINK_SCRIPT_OTPROM = $(addprefix $(OBJDIR)/, linkscriptotprom) # ---- SEEPROM Image ------ # This removes all unecessary headers from the ELF executable @@ -178,6 +181,20 @@ $(OBJDIR)/$(IMAGE_SBE_NAME).out: pibMemAttrSet buildInfo $(OBJDIR)/base_sbe_fixe $(LINK_SCRIPT_SBE): linksbe.cmd $(CPP) -E -x c++ -I. -P $(DEFS) linksbe.cmd -o $(LINK_SCRIPT_SBE) +# ---- Otprom Image ------ +$(OBJDIR)/$(IMAGE_OTPROM_NAME).bin $(OBJDIR)/$(IMAGE_OTPROM_NAME).dis: $(OBJDIR)/$(IMAGE_OTPROM_NAME).out + $(OBJCOPY) -O binary $< $(OBJDIR)/$(IMAGE_OTPROM_NAME).bin `/usr/bin/nm $(OBJDIR)/$(IMAGE_OTPROM_NAME).out | grep "A _loader_end" | cut -d " " -f 1` + $(OBJDUMP) -S $< > $(OBJDIR)/$(IMAGE_OTPROM_NAME).dis + +#create a linked ELF executable +$(OBJDIR)/$(IMAGE_OTPROM_NAME).out: $(OTPROM_LOADER_OBJS) $(LINK_SCRIPT_OTPROM) + $(LD) -e base_loader -T$(LINK_SCRIPT_OTPROM) -Map $(OBJDIR)/$(IMAGE_OTPROM_NAME).map -Bstatic -o $(OBJDIR)/$(IMAGE_OTPROM_NAME).out $(OTPROM_LOADER_OBJS) + +# pass the link command file through the C preprocessor to evaluate macros and remove comments +$(LINK_SCRIPT_OTPROM): linkotprom.cmd + $(CPP) -I. -E -x c++ -P $(DEFS) linkotprom.cmd -o $(LINK_SCRIPT_OTPROM) + + # ---- Loader Image ------ $(OBJDIR)/$(IMAGE_LOADER_NAME).bin $(OBJDIR)/$(IMAGE_LOADER_NAME).dis: $(OBJDIR)/$(IMAGE_LOADER_NAME).out $(OBJCOPY) -O binary $< $(OBJDIR)/$(IMAGE_LOADER_NAME).bin --pad-to 0x`/usr/bin/nm $(OBJDIR)/$(IMAGE_LOADER_NAME).out | grep "A _loader_end" | cut -d " " -f 1` @@ -211,7 +228,7 @@ endif .PHONY: all normalize defaultset appendbase appendloader add_L1_LoaderAddr add_L2_LoaderAddr add_kernelAddr symbols appendoverrides -all: $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(OBJDIR)/$(IMAGE_SBE_NAME).bin $(OBJDIR)/$(IMAGE_LOADER_NAME).bin $(SBE_TOOLS) normalize defaultset $(OBJDIR)/fixed.bin appendbase appendloader appendoverrides add_L1_LoaderAddr add_L2_LoaderAddr add_kernelAddr symbols tracehash buildinfo +all: $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(OBJDIR)/$(IMAGE_SBE_NAME).bin $(OBJDIR)/$(IMAGE_LOADER_NAME).bin $(OBJDIR)/$(IMAGE_OTPROM_NAME).bin $(SBE_TOOLS) normalize defaultset $(OBJDIR)/fixed.bin appendbase appendloader add_L1_LoaderAddr add_L2_LoaderAddr add_kernelAddr symbols tracehash buildinfo buildinfo: $(P9_XIP_TOOL) $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(P9_XIP_TOOL) $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin set build_date `date +%Y%m%d` diff --git a/sbe/image/img_defs.mk b/sbe/image/img_defs.mk index a9669af8..1969e2fb 100644 --- a/sbe/image/img_defs.mk +++ b/sbe/image/img_defs.mk @@ -35,6 +35,7 @@ IMAGE_SEEPROM_NAME := sbe_seeprom IMAGE_SBE_NAME := sbe_pibmem IMAGE_LOADER_NAME := sbe_loader +IMAGE_OTPROM_NAME := sbe_otprom SBE_SYMBOLS_NAME := sbe.syms diff --git a/sbe/image/linkotprom.cmd b/sbe/image/linkotprom.cmd new file mode 100644 index 00000000..2d7324ac --- /dev/null +++ b/sbe/image/linkotprom.cmd @@ -0,0 +1,20 @@ + +// Need to do this so that elf32-powerpc is not modified! +#undef powerpc + +#include <sbe_link.H> + +OUTPUT_FORMAT(elf32-powerpc); + +MEMORY +{ + sram : ORIGIN = OTPROM_ORIGIN, LENGTH = OTPROM_BLOCK_SIZE +} + +SECTIONS +{ + . = OTPROM_ORIGIN; + .text . : { *(.text)} + . = OTPROM_FIXED_SIZE; + .fixed . : { *(.fixed)} +} diff --git a/sbe/image/pm_otprom_loader.S b/sbe/image/pm_otprom_loader.S new file mode 100644 index 00000000..f98d42cc --- /dev/null +++ b/sbe/image/pm_otprom_loader.S @@ -0,0 +1,155 @@ +# # include "pk.h" +.set r0 , 0 +.set r1 , 1 +.set r2 , 2 +.set r3 , 3 +.set r4 , 4 +.set r5 , 5 +.set r6 , 6 +.set r7 , 7 +.set r8 , 8 +.set d0 , 0 +.set d2 , 2 +.set d7 , 7 +.global __reserved +__reserved: +############################################################# +################## OTPROM location data contents ############ +# SBE Seeprom Config_0 18068 +# SBE Seeprom Config_1 18069 +# SBE Seeprom Config_2 1806A +# SBE Seeprom Config_3 1806B +# Magic number stored in OTP 1806C +# Reserved 1806D +# Reserved 1806E +# Reserved 1806F +# 0x0040 : otprom loader +############################################################# +_start: +lis r4 , 0x50 #dummy instruction +.org __reserved + 0x0040 +.macro .pm_otprom_fixed_system + .section .fixed, "a", @progbits +__seeprom0_config_reg: + .quad 0x80A91C7100000000 +__seeprom1_config_reg: + .quad 0x80AB1C7100001C71 +__seeprom2_config_reg: + .quad 0x80AD1C71000038E2 +__seeprom3_config_reg: + .quad 0x80AF1C7100005553 +__otprom_magic_num: + .quad 0x584950205345504D +__sbe_config_reg: + .quad 0x000A800060000000 + .endm +oos_start: #R4 --> A0000 R5 --> 5003F R6 --> C000_0818 + lis r4 , 0xA + ori r4 , r4 , 0x0 + stvd d0 , 1(r4) #Write reset reg . A0001 + lis r5 , 0x5 #Check the validity of scratch reg and then program the bit rate div + ori r5 , r5 , 0x0000 + lvd d2 , 0x3F(r5) #loads scratch_8 and updates R5 to scratch_1 + bb0wi r2 , 1 , oos_load_const_brd #checks if valid bit (bit1) is 1 if yes continue else branch + lvd d2 , 0x39(r5) + andis. r2 , r2 , 0xffff #delete last 2 bytes Confirmed first 2 bytes has Bit rate divisor + +oos_write_mode_reg: + lvd d0 , 6(r4) #D0 --> old mode reg and D2 --> has new brd + andi. r0 , r0 , 0xffff + or r0 , r0 , r2 + stvd d0 , 6(r4) #Store mode register + lis r6 , 0xc000 + ori r6 , r6, 0x0818 #Load clear address of local register FI2C_CFG + li r0 , 0xfff #Create the Clear mask + lis r1 , 0xf000 + stvd d0 , 0(r6) #write to clear register of local register + rlwinm r3, r2, 12 , 0 , 3 #First move last nibble to R3 0:3 + rlwinm r2, r2, 12 , 20, 31 #Store bit rate div in 20:35 location of local register 20:31 + stvd d2 , -8(r6) #Set register = C0000810 + b oos_write_mode_done + +oos_load_const_brd: + lis r2 , 0x6 #load constant BRD = 6 to first 2 bytes of R2 + b oos_write_mode_reg + +oos_write_mode_done: + +oos_force_stop_to_both_ports: + lis r0 , 0x8000 #load 0x80000000 for port busy register write + stvd d0 , 0xE(r4) #Write port busy register to clear + andi. r0 , r0 ,0 #stop_command = 0x1000_0020_0000_0000 + andi. r1 , r1 , 0 + oris r0 , r0 , 0x1000 + ori r0 , r0 , 0x0020 + stvd d0 , 0(r4) #Write control register with Stop command + +oos_poll_status_bit_0: + lvd d2 , 2(r4) #Read Status register + bb1wi r3 , 0xc , oos_poll_status_bit_0 + ori r0 , r0 , 0x0200 #stop_command = 0x1000_0220_0000_0000 + stvd d0 , 0(r4) #write control register with stop command to port 1 + +oos_poll_status_bit_1: + lvd d2 , 2(r4) + bb1wi r3 , 0xc , oos_poll_status_bit_1 + lis r0 , 0xd8a9 + ori r0 , r0 , 0x0090 #change the port number later after checking from the scratch register. Add the seeprom address pointer location by updating the R1 + andi. r1 , r1 , 0x0 #Chose address 0x0 of SEEPROM : 0xA8 + +oos_chk_port_num: + lvd d2 , 0x8(r5) #Read the port number from Selfboot control / status register :: + bb0wi r2 , 17 , oos_sel_prim_sprm #Check if backup seeprom select is '1' bit_17 according to Srinivas + ori r0 , r0 , 0x0200 #enable backup_sprm port + lvd d7, -24(r6) #load SBE_CONFIG local reg + oris r8 , r8 , 0x0200 #make bit 38 of sbe_config_reg bit '1'. (C0000800) + stvd d7, -24(r6) #Store SBE_CONFIG local reg + +oos_sel_prim_sprm: + stvd d0 , 0(r4) #write control register + +oos_poll_status_bit_2: + lvd d2 , 2(r4) #poll status reg + bb1wi r3 , 0xc , oos_poll_status_bit_2 + lvd d0 , 3(r4) #Read data reg to get magic number + +oss_load_constant_magic_num: #Magic number of seeprom = 0x584950205345504D + lis r2 , 0x5849 #load constant otprom magic number + ori r2 , r2 , 0x5020 + lis r3 , 0x5345 + ori r3 , r3, 0x504d + cmplwbc 0, 2, r0, r2, oos_cmp_magic_fail + cmplwbc 0, 2, r1, r3, oos_cmp_magic_fail + lis r4 , 0x0001 #OTPROM address = 0xZZZZ_YYYY PIB_addr (R4 = 18070) + ori r4 , r4 , 0x8068 + lis r5 , 0xc000 #local_reg_addr (R5 = C0000860) + ori r5 , r5 , 0x0860 + lvd d0 , 0(r4) + stvd d0 , 0(r5) #Seeprom_0 + lvd d0 , 1(r4) + stvd d0 , 32(r5) #Seeprom_1 + lvd d0 , 2(r4) + stvd d0 , 64(r5) #Seeprom_2 + lvd d0 , 3(r4) + stvd d0 , 96(r5) #Seeprom_3 + lvd d0 , 5(r4) #SBE Config + stvd d0 , -96(r5) + ##### Branch to SEEPROM ################### + lis r4 , 0x8000 #Go and fetch the branch address from 0x8000_0001 + ori r4 , r4 , 0x0008 + lvd d0 , 0(r4) + mtctr r1 + bctr #Branch to fetched address + ##### Branch to SEEPROM ################### + trap #FIXME hve to give branch to SEEPROM + +oos_cmp_magic_fail: + lis r5 , 0x5 #PIB_addr (R5 = 0x00050008) + ori r5 , r5 , 0x0000 + lvd d0 , 8(r5) + andi. r1 , r1 , 0xfff0 + ori r1 , r1 , 0x000e #59:63 : Error message : E = Magic number mismatch + stvd d0 ,8(r5) + trap + +.pm_otprom_fixed_system diff --git a/sbe/image/sbe_link.H b/sbe/image/sbe_link.H index 01fe04b9..46cc9f5c 100644 --- a/sbe/image/sbe_link.H +++ b/sbe/image/sbe_link.H @@ -18,10 +18,10 @@ /// interface is at local address 0x8000. SBE/IPL uses the PIB addressing /// mode, so the OTPROM image is linked at 0x40000 (the byte-address /// equivalent of 0x8000). -#define OTPROM_ORIGIN 0x40000 +#define OTPROM_ORIGIN 0xC0000 /// The amount of memory contained in each OTPROM macro -#define OTPROM_BLOCK_SIZE 4096 +#define OTPROM_BLOCK_SIZE 1024 /// The amount of memory reserved for OTPROM code /// @@ -69,5 +69,8 @@ /// The amount of space available in the PIBMEM, in bytes (96KB) #define PIBMEM_SIZE (96 * 1024) +/// The fixed section of Otprom +#define OTPROM_FIXED_SIZE (OTPROM_ORIGIN + 0x340) + #endif // __SBE_LINK_H diff --git a/sbe/image/topfiles.mk b/sbe/image/topfiles.mk index f94034ea..26c56c19 100644 --- a/sbe/image/topfiles.mk +++ b/sbe/image/topfiles.mk @@ -17,6 +17,9 @@ BASE-LOADER-S-SOURCES = base_loader_setup.S BASE_LOADER_OBJECTS = $(BASE-LOADER-C-SOURCES:.c=.o) $(BASE-LOADER-S-SOURCES:.S=.o) +OTPROM-LOADER-S-SOURCES = pm_otprom_loader.S +OTPROM_LOADER_OBJECTS = $(OTPROM-LOADER-S-SOURCES:.S=.o) + PPE_FAPI2_DIR_INCL = $(PPE_FAPI2_DIR)/include # generated by ppeParseAttributeInfo.pl GEN-PARSEATTRIBUTEINFO += $(PPE_FAPI2_DIR_INCL)/fapi2AttributeIds.H |