summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorGirisankar Paulraj <gpaulraj@in.ibm.com>2016-06-07 11:29:24 -0500
committerSachin Gupta <sgupta2m@in.ibm.com>2016-09-26 03:13:38 -0400
commit1a6b96d18a539bbe6875f97a7f3ee4da32b47d34 (patch)
treedeb8e09481df4be967ee44a495a1f9101615c0ad /src/import
parent89743d490acc89397145c6bf47e959a61ae6098d (diff)
downloadtalos-sbe-1a6b96d18a539bbe6875f97a7f3ee4da32b47d34.tar.gz
talos-sbe-1a6b96d18a539bbe6875f97a7f3ee4da32b47d34.zip
Adding tor_append_ring API
declared tor_append_ring API. Added new image magic parameter for cme and spge tor_get_ring function for supporting tor_append_ring API. Added new return code for tor_append_ring. Added code for tor_append_ring function. TOR starting address. Earlier it was referred from starting ring section starting address Change-Id: I8c6ba853b0386cd0aea46cec177c6af0bc0755e1 Original-Change-Id: Ia07dc52dc3fe9e8d2c9acc67c7822357e559f45c Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/25454 Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: GIRISANKAR PAULRAJ <gpaulraj@in.ibm.com> Reviewed-by: Claus M. Olsen <cmolsen@us.ibm.com> Reviewed-by: Prachi Gupta <pragupta@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/30261 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'src/import')
-rw-r--r--src/import/chips/p9/utils/imageProcs/p9_tor.C472
-rw-r--r--src/import/chips/p9/utils/imageProcs/p9_tor.H390
2 files changed, 626 insertions, 236 deletions
diff --git a/src/import/chips/p9/utils/imageProcs/p9_tor.C b/src/import/chips/p9/utils/imageProcs/p9_tor.C
index 91470851..c96b859b 100644
--- a/src/import/chips/p9/utils/imageProcs/p9_tor.C
+++ b/src/import/chips/p9/utils/imageProcs/p9_tor.C
@@ -74,13 +74,12 @@ const char* ringVariantName[] = { "Base",
/// extract RS4 extract from HW image
///
//////////////////////////////////////////////////////////////////////////////////
-int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
+int get_ring_from_sbe_image ( void* i_ringSection, // Image pointer
uint64_t i_magic, // Image Magic Number
RingID i_ringId, // Unique ring I
uint16_t i_ddLevel, // DD level details
RingType_t& io_RingType, // 0: Common 1: Instance
- RingVariant_t
- i_RingVariant, // Base, cache contained, Risk level, Override and Overlay
+ RingVariant_t i_RingVariant, // Base, cache contained, Risk level, Override and Overlay
uint8_t& io_instanceId, // chiplet Instance id indo
RingBlockType_t i_RingBlockType, // 0: single ring, 1: ddLevel block
void** io_ringBlockPtr, // RS4 Container data or block data
@@ -93,14 +92,14 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
uint16_t chiplet_offset = 0;
uint32_t next_ring_offset = 0;
uint32_t ringSize = 0;
- int temp = i_ddLevel >> 2;
+ int temp = i_ddLevel >> 2; // converting byte to word counter
uint32_t* deltaRingRS4_4B;
uint32_t sbe_offset = 0;
RingVariantOrder* ring_variant_order = NULL;
if (i_magic == P9_XIP_MAGIC_HW)
{
- sbe_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ sbe_offset = *((uint32_t*)i_ringSection + temp); //DD level offset index
temp = htobe32(sbe_offset);
}
else if (i_magic == P9_XIP_MAGIC_SEEPROM)
@@ -280,20 +279,20 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
|| (i_RingVariant == OVERRIDE && i_magic == P9_XIP_MAGIC_SEEPROM)))
{
strcpy(o_ringName, RING_PROPERTIES[i_ringId].iv_name);
- int var = l * 8 + i_ddLevel + temp;
- int temp1 = var / 4;
- ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ int var = l * sizeof(TorPpeBlock_t) + i_ddLevel + temp;
+ int temp1 = var / sizeof(uint32_t);
+ ring_offset = *((uint32_t*)i_ringSection + temp1);
ring_offset = htobe32(ring_offset);
var = ring_offset + i_ddLevel + temp;
- temp1 = var / 2 + local;
- chiplet_offset = *((uint16_t*)i_ringSectionPtr + temp1);
+ temp1 = var / sizeof(uint16_t) + local;
+ chiplet_offset = *((uint16_t*)i_ringSection + temp1);
chiplet_offset = htobe16(chiplet_offset);
- if(i_RingBlockType == SINGLE_RING)
+ if(i_RingBlockType == GET_SINGLE_RING)
{
- var = ring_offset + (chiplet_offset - 8) + i_ddLevel + temp;
- temp1 = var / 4;
- next_ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ var = ring_offset + (chiplet_offset - sizeof(TorPpeBlock_t)) + i_ddLevel + temp;
+ temp1 = var / sizeof(uint32_t);
+ next_ring_offset = *((uint32_t*)i_ringSection + temp1);
next_ring_offset = htobe32(next_ring_offset);
ringSize = next_ring_offset;
io_RingType = COMMON;
@@ -314,7 +313,7 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
}
// Copying single ring into ring block pointer
- memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSectionPtr + var,
+ memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSection + var,
(size_t)ringSize);
io_ringBlockSize = ringSize;
io_instanceId = (ring_id_list_common + i)->instanceIdMin;
@@ -339,7 +338,7 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
{
deltaRingRS4_4B = (uint32_t*)(*io_ringBlockPtr);
- for (uint32_t m = 0; m < ringSize / 4; m++)
+ for (uint32_t m = 0; m < ringSize / sizeof(uint32_t); m++)
{
MY_INF("compressed data %d --- %08x \t", m, htobe32(deltaRingRS4_4B[m]));
}
@@ -356,6 +355,19 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
return IMGBUILD_TGR_RING_NOT_FOUND;
}
}
+ else if(i_RingBlockType == PUT_SINGLE_RING)
+ {
+ if(chiplet_offset)
+ {
+ MY_INF("Ring container is already present in the ring section \n");
+ return IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION;
+ }
+
+ io_ringBlockSize = var + (local * RING_OFFSET_SIZE);
+ memcpy( (uint8_t*)(*io_ringBlockPtr), &var,
+ sizeof(uint16_t));
+ return IMGBUILD_TGR_RING_FOUND;
+ }
}
local++;
@@ -386,20 +398,20 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
if( i == io_instanceId && i_RingVariant == ring_variant_order->variant[k] )
{
strcpy(o_ringName, RING_PROPERTIES[i_ringId].iv_name);
- uint32_t var = l * 8 + i_ddLevel + temp + 4;
- int temp1 = var / 4;
- ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ uint32_t var = l * sizeof(TorPpeBlock_t) + i_ddLevel + temp + CPLT_OFFSET_SIZE;
+ int temp1 = var / sizeof(uint32_t);
+ ring_offset = *((uint32_t*)i_ringSection + temp1);
ring_offset = htobe32(ring_offset);
var = ring_offset + i_ddLevel + temp;
- temp1 = var / 2 + local;
- chiplet_offset = *((uint16_t*)i_ringSectionPtr + temp1);
+ temp1 = var / sizeof(uint16_t) + local;
+ chiplet_offset = *((uint16_t*)i_ringSection + temp1);
chiplet_offset = htobe16(chiplet_offset);
- if(i_RingBlockType == SINGLE_RING)
+ if(i_RingBlockType == GET_SINGLE_RING)
{
- var = ring_offset + (chiplet_offset - 8) + i_ddLevel + temp;
- temp1 = var / 4;
- next_ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ var = ring_offset + (chiplet_offset - sizeof(TorPpeBlock_t)) + i_ddLevel + temp;
+ temp1 = var / sizeof(uint32_t);
+ next_ring_offset = *((uint32_t*)i_ringSection + temp1);
next_ring_offset = htobe32(next_ring_offset);
ringSize = next_ring_offset;
io_RingType = INSTANCE;
@@ -419,7 +431,7 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
o_ringName);
}
- memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSectionPtr + var,
+ memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSection + var,
(size_t)ringSize);
io_ringBlockSize = ringSize;
@@ -441,7 +453,7 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
{
deltaRingRS4_4B = (uint32_t*)(*io_ringBlockPtr);
- for (uint32_t m = 0; m < ringSize / 4; m++)
+ for (uint32_t m = 0; m < ringSize / sizeof(uint32_t); m++)
{
MY_INF("compressed data %d --- %08x \t",
m, htobe32(deltaRingRS4_4B[m]));
@@ -459,6 +471,19 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
return IMGBUILD_TGR_RING_NOT_FOUND;
}
}
+ else if(i_RingBlockType == PUT_SINGLE_RING)
+ {
+ if(chiplet_offset)
+ {
+ MY_INF("Ring container is already present in the ring section \n");
+ return IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION;
+ }
+
+ io_ringBlockSize = var + (local * RING_OFFSET_SIZE);
+ memcpy( (uint8_t*)(*io_ringBlockPtr), &var,
+ sizeof(uint16_t));
+ return IMGBUILD_TGR_RING_FOUND;
+ }
}
}
@@ -486,19 +511,17 @@ int get_ring_from_sbe_image ( void* i_ringSectionPtr, // Image pointer
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-int get_ring_from_sgpe_image ( void*
- i_ringSectionPtr, // Image pointer
+int get_ring_from_sgpe_image ( void* i_ringSection, // Image pointer
+ uint64_t i_magic, // Image Magic Number
RingID i_ringId, // Unique ring I
uint16_t i_ddLevel, // DD level details
RingType_t& io_RingType, // 0: Common 1: Instance
- RingVariant_t
- i_RingVariant, // Variant -> Base, cache contained, Risk level,
+ RingVariant_t i_RingVariant, // Variant -> Base, cache contained, Risk level,
// Override and Overlay
uint8_t& io_instanceId, // required Instance
RingBlockType_t i_RingBlockType, // 0: single ring, 1: ddLevel block
void** io_ringBlockPtr, // RS4 Container data or block data
- uint32_t&
- io_ringBlockSize, // size of data copied into ring block pointer
+ uint32_t& io_ringBlockSize, // size of data copied into ring block pointer
char* o_ringName, // Name of ring
uint32_t i_dbgl) // Debug option
{
@@ -506,9 +529,9 @@ int get_ring_from_sgpe_image ( void*
uint16_t chiplet_offset = 0;
uint32_t next_ring_offset = 0;
uint32_t ringSize = 0;
- int temp = (i_ddLevel >> 2) + 4;
+ int temp = (i_ddLevel >> 2) + 4; // converting byte to word counter
uint32_t* deltaRingRS4_4B;
- uint32_t spge_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ uint32_t spge_offset = *((uint32_t*)i_ringSection + temp);
temp = htobe32(spge_offset);
GenRingIdList* ring_id_list_common = NULL;
GenRingIdList* ring_id_list_instance = NULL;
@@ -533,19 +556,19 @@ int get_ring_from_sgpe_image ( void*
{
strcpy(o_ringName, RING_PROPERTIES[i_ringId].iv_name);
int var = 0 + i_ddLevel + temp;
- int temp1 = var / 4;
- ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ int temp1 = var / sizeof(uint32_t);
+ ring_offset = *((uint32_t*)i_ringSection + temp1);
ring_offset = htobe32(ring_offset);
var = ring_offset + i_ddLevel + temp;
- temp1 = var / 2 + local;
- chiplet_offset = *((uint16_t*)i_ringSectionPtr + temp1);
+ temp1 = var / sizeof(uint16_t) + local;
+ chiplet_offset = *((uint16_t*)i_ringSection + temp1);
chiplet_offset = htobe16(chiplet_offset);
- if (i_RingBlockType == SINGLE_RING)
+ if (i_RingBlockType == GET_SINGLE_RING)
{
- var = ring_offset + (chiplet_offset - 8) + i_ddLevel + temp;
- temp1 = var / 4;
- next_ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ var = ring_offset + (chiplet_offset - sizeof(TorPpeBlock_t)) + i_ddLevel + temp;
+ temp1 = var / sizeof(uint32_t);
+ next_ring_offset = *((uint32_t*)i_ringSection + temp1);
next_ring_offset = htobe32(next_ring_offset);
ringSize = next_ring_offset;
io_RingType = COMMON;
@@ -566,7 +589,7 @@ int get_ring_from_sgpe_image ( void*
}
// Copying ring data into io buffer
- memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSectionPtr + var,
+ memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSection + var,
(size_t)ringSize);
io_ringBlockSize = ringSize;
io_instanceId = (ring_id_list_common + i)->instanceIdMin;
@@ -590,7 +613,7 @@ int get_ring_from_sgpe_image ( void*
{
deltaRingRS4_4B = (uint32_t*)(*io_ringBlockPtr);
- for (uint32_t m = 0; m < ringSize / 4; m++)
+ for (uint32_t m = 0; m < ringSize / sizeof(uint32_t); m++)
{
MY_INF("compressed data %d --- %08x \t", m, htobe32(deltaRingRS4_4B[m]));
}
@@ -607,6 +630,19 @@ int get_ring_from_sgpe_image ( void*
return IMGBUILD_TGR_RING_NOT_FOUND;
}
}
+ else if(i_RingBlockType == PUT_SINGLE_RING)
+ {
+ if(chiplet_offset)
+ {
+ MY_INF("Ring container is already present in the ring section \n");
+ return IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION;
+ }
+
+ io_ringBlockSize = var + (local * RING_OFFSET_SIZE);
+ memcpy( (uint8_t*)(*io_ringBlockPtr), &var,
+ sizeof(uint16_t));
+ return IMGBUILD_TGR_RING_FOUND;
+ }
}
local++;
@@ -640,20 +676,20 @@ int get_ring_from_sgpe_image ( void*
if( i == io_instanceId && k == i_RingVariant )
{
strcpy(o_ringName, RING_PROPERTIES[i_ringId].iv_name);
- uint32_t var = 4 + i_ddLevel + temp;
- int temp1 = var / 4;
- ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ uint32_t var = CPLT_OFFSET_SIZE + i_ddLevel + temp;
+ int temp1 = var / sizeof(uint32_t);
+ ring_offset = *((uint32_t*)i_ringSection + temp1);
ring_offset = htobe32(ring_offset);
var = ring_offset + i_ddLevel + temp;
- temp1 = var / 2 + local;
- chiplet_offset = *((uint16_t*)i_ringSectionPtr + temp1);
+ temp1 = var / sizeof(uint16_t) + local;
+ chiplet_offset = *((uint16_t*)i_ringSection + temp1);
chiplet_offset = htobe16(chiplet_offset);
- if (i_RingBlockType == SINGLE_RING)
+ if (i_RingBlockType == GET_SINGLE_RING)
{
- var = ring_offset + (chiplet_offset - 8) + i_ddLevel + temp;
- temp1 = var / 4;
- next_ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ var = ring_offset + (chiplet_offset - sizeof(TorPpeBlock_t)) + i_ddLevel + temp;
+ temp1 = var / sizeof(uint32_t);
+ next_ring_offset = *((uint32_t*)i_ringSection + temp1);
next_ring_offset = htobe32(next_ring_offset);
ringSize = next_ring_offset;
io_RingType = INSTANCE;
@@ -674,7 +710,7 @@ int get_ring_from_sgpe_image ( void*
}
// Copying ring data into io_buffer
- memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSectionPtr + var,
+ memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSection + var,
(size_t)ringSize);
io_ringBlockSize = ringSize;
@@ -696,7 +732,7 @@ int get_ring_from_sgpe_image ( void*
{
deltaRingRS4_4B = (uint32_t*)(*io_ringBlockPtr);
- for (uint32_t m = 0; m < ringSize / 4; m++)
+ for (uint32_t m = 0; m < ringSize / sizeof(uint32_t); m++)
{
MY_INF("compressed data %d --- %08x \t", m, htobe32(deltaRingRS4_4B[m]));
}
@@ -713,6 +749,19 @@ int get_ring_from_sgpe_image ( void*
return IMGBUILD_TGR_RING_NOT_FOUND;
}
}
+ else if(i_RingBlockType == PUT_SINGLE_RING)
+ {
+ if(chiplet_offset)
+ {
+ MY_INF("Ring container is already present in the ring section \n");
+ return IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION;
+ }
+
+ io_ringBlockSize = var + (local * RING_OFFSET_SIZE);
+ memcpy( (uint8_t*)(*io_ringBlockPtr), &var,
+ sizeof(uint16_t));
+ return IMGBUILD_TGR_RING_FOUND;
+ }
}
}
else
@@ -739,17 +788,17 @@ int get_ring_from_sgpe_image ( void*
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int get_ring_from_cme_image ( void*
- i_ringSectionPtr, // Image pointer
+ i_ringSection, // Image pointer
+ uint64_t i_magic, // Image Magic Number
RingID i_ringId, // Unique ring I
uint16_t i_ddLevel, // DD level details
RingType_t& io_RingType, // 0: Common 1: Instance
- RingVariant_t
- i_RingVariant, // Variant -> Base, cache contained, Risk level, Override and Overlay
+ RingVariant_t i_RingVariant, // Variant -> Base, cache contained, Risk level,
+ // Override and Overlay
uint8_t& io_instanceId, // required Instance
RingBlockType_t i_RingBlockType, // 0: single ring, 1: ddLevel block
void** io_ringBlockPtr, // RS4 Container data or block data
- uint32_t&
- io_ringBlockSize, // size of data copied into ring block pointer
+ uint32_t& io_ringBlockSize, // size of data copied into ring block pointer
char* o_ringName, // Name of ring
uint32_t i_dbgl) // Debug option
{
@@ -757,10 +806,10 @@ int get_ring_from_cme_image ( void*
uint16_t chiplet_offset = 0;
uint32_t next_ring_offset = 0;
uint32_t ringSize = 0;
- int temp = (i_ddLevel >> 2) + 2;
+ int temp = (i_ddLevel >> 2) + 2; // converting byte to word counter
uint32_t* deltaRingRS4_4B;
- uint32_t spge_offset = *((uint32_t*)i_ringSectionPtr + temp);
- temp = htobe32(spge_offset);
+ uint32_t cme_offset = *((uint32_t*)i_ringSection + temp);
+ temp = htobe32(cme_offset);
GenRingIdList* ring_id_list_common = NULL;
GenRingIdList* ring_id_list_instance = NULL;
uint8_t iv_num_variant = (uint8_t)sizeof(EC::RingVariants) / sizeof(uint16_t);
@@ -784,19 +833,19 @@ int get_ring_from_cme_image ( void*
{
strcpy(o_ringName, RING_PROPERTIES[i_ringId].iv_name);
int var = 0 + i_ddLevel + temp;
- int temp1 = var / 4;
- ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ int temp1 = var / sizeof(uint32_t);
+ ring_offset = *((uint32_t*)i_ringSection + temp1);
ring_offset = htobe32(ring_offset);
var = ring_offset + i_ddLevel + temp;
- temp1 = var / 2 + local;
- chiplet_offset = *((uint16_t*)i_ringSectionPtr + temp1);
+ temp1 = var / sizeof(uint16_t) + local;
+ chiplet_offset = *((uint16_t*)i_ringSection + temp1);
chiplet_offset = htobe16(chiplet_offset);
- if (i_RingBlockType == SINGLE_RING)
+ if (i_RingBlockType == GET_SINGLE_RING)
{
- var = ring_offset + (chiplet_offset - 8) + i_ddLevel + temp;
- temp1 = var / 4;
- next_ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ var = ring_offset + (chiplet_offset - sizeof(TorPpeBlock_t)) + i_ddLevel + temp;
+ temp1 = var / sizeof(uint32_t);
+ next_ring_offset = *((uint32_t*)i_ringSection + temp1);
next_ring_offset = htobe32(next_ring_offset);
ringSize = next_ring_offset;
io_RingType = COMMON;
@@ -817,7 +866,7 @@ int get_ring_from_cme_image ( void*
}
// Copying ring data into io_buffer
- memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSectionPtr + var,
+ memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSection + var,
(size_t)ringSize);
io_ringBlockSize = ringSize;
io_instanceId = (ring_id_list_common + i)->instanceIdMin;
@@ -841,7 +890,7 @@ int get_ring_from_cme_image ( void*
{
deltaRingRS4_4B = (uint32_t*)(*io_ringBlockPtr);
- for (uint32_t m = 0; m < ringSize / 4; m++)
+ for (uint32_t m = 0; m < ringSize / sizeof(uint32_t); m++)
{
MY_INF("compressed data %d --- %08x \t", m, htobe32(deltaRingRS4_4B[m]));
}
@@ -858,6 +907,19 @@ int get_ring_from_cme_image ( void*
return IMGBUILD_TGR_RING_NOT_FOUND;
}
}
+ else if(i_RingBlockType == PUT_SINGLE_RING)
+ {
+ if(chiplet_offset)
+ {
+ MY_INF("Ring container is already present in the ring section \n");
+ return IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION;
+ }
+
+ io_ringBlockSize = var + (local * RING_OFFSET_SIZE);
+ memcpy( (uint8_t*)(*io_ringBlockPtr), &var,
+ sizeof(uint16_t));
+ return IMGBUILD_TGR_RING_FOUND;
+ }
}
local++;
@@ -893,20 +955,20 @@ int get_ring_from_cme_image ( void*
if( i == io_instanceId && k == i_RingVariant )
{
strcpy(o_ringName, RING_PROPERTIES[i_ringId].iv_name);
- uint32_t var = z * 4 + i_ddLevel + temp + 4;
- int temp1 = var / 4;
- ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ uint32_t var = z * CPLT_OFFSET_SIZE + i_ddLevel + temp + CPLT_OFFSET_SIZE;
+ int temp1 = var / CPLT_OFFSET_SIZE;
+ ring_offset = *((uint32_t*)i_ringSection + temp1);
ring_offset = htobe32(ring_offset);
var = ring_offset + i_ddLevel + temp;
- temp1 = var / 2 + local;
- chiplet_offset = *((uint16_t*)i_ringSectionPtr + temp1);
+ temp1 = var / sizeof(uint16_t) + local;
+ chiplet_offset = *((uint16_t*)i_ringSection + temp1);
chiplet_offset = htobe16(chiplet_offset);
- if (i_RingBlockType == SINGLE_RING)
+ if (i_RingBlockType == GET_SINGLE_RING)
{
- var = ring_offset + (chiplet_offset - 8) + i_ddLevel + temp;
- temp1 = var / 4;
- next_ring_offset = *((uint32_t*)i_ringSectionPtr + temp1);
+ var = ring_offset + (chiplet_offset - sizeof(TorPpeBlock_t)) + i_ddLevel + temp;
+ temp1 = var / sizeof(uint32_t);
+ next_ring_offset = *((uint32_t*)i_ringSection + temp1);
next_ring_offset = htobe32(next_ring_offset);
ringSize = next_ring_offset;
io_RingType = INSTANCE;
@@ -929,7 +991,7 @@ int get_ring_from_cme_image ( void*
}
// Copying ring data into io_buffer
- memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSectionPtr + var,
+ memcpy( (uint8_t*)(*io_ringBlockPtr), (uint8_t*)i_ringSection + var,
(size_t)ringSize);
io_ringBlockSize = ringSize;
@@ -951,7 +1013,7 @@ int get_ring_from_cme_image ( void*
{
deltaRingRS4_4B = (uint32_t*)(*io_ringBlockPtr);
- for (uint32_t m = 0; m < ringSize / 4; m++)
+ for (uint32_t m = 0; m < ringSize / sizeof(uint32_t); m++)
{
MY_INF("compressed data %d --- %08x \t", m, htobe32(deltaRingRS4_4B[m]));
}
@@ -968,6 +1030,19 @@ int get_ring_from_cme_image ( void*
return IMGBUILD_TGR_RING_NOT_FOUND;
}
}
+ else if(i_RingBlockType == PUT_SINGLE_RING)
+ {
+ if(chiplet_offset)
+ {
+ MY_INF("Ring container is already present in the ring section \n");
+ return IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION;
+ }
+
+ io_ringBlockSize = var + (local * RING_OFFSET_SIZE);
+ memcpy( (uint8_t*)(*io_ringBlockPtr), &var,
+ sizeof(uint16_t));
+ return IMGBUILD_TGR_RING_FOUND;
+ }
}
}
else
@@ -994,7 +1069,7 @@ int get_ring_from_cme_image ( void*
//////////////////////////////////////////////////////////////////////////////////////////
int tor_access_ring( void*
- i_ringSectionPtr, // Ring address Ptr any of .rings, .overrides and .overlays.
+ i_ringSection, // Ring address Ptr any of .rings, .overrides and .overlays.
uint64_t i_magic, // Image Magic Number
RingID i_ringId, // Unique ring ID
uint16_t i_ddLevel, // DD level info
@@ -1009,6 +1084,7 @@ int tor_access_ring( void*
uint32_t i_dbgl) // Debug option
{
int rc = 0;
+ TorPpeBlock_t l_TorPpeBlock;
if(i_dbgl > 1)
{
@@ -1027,7 +1103,7 @@ int tor_access_ring( void*
if (i_magic == P9_XIP_MAGIC_HW)
{
uint8_t dd_check = 0;
- ddLevelCount = *((uint32_t*)i_ringSectionPtr + 0);
+ ddLevelCount = *((uint32_t*)i_ringSection + 0);
ddLevelCount = htobe32(ddLevelCount);
if(i_dbgl > 1)
@@ -1038,7 +1114,7 @@ int tor_access_ring( void*
for (uint8_t i = 0; i < ddLevelCount; i++)
{
local = 2;
- ddLevelOffset = *((uint32_t*)i_ringSectionPtr + local);
+ ddLevelOffset = *((uint32_t*)i_ringSection + local);
temp = htobe32(ddLevelOffset) >> 24 & 0x000000FF;
ddLevelOffset = htobe32(ddLevelOffset) & 0x00FFFFFF;
@@ -1050,12 +1126,12 @@ int tor_access_ring( void*
if ( temp == i_ddLevel)
{
- ddLevelOffset = *((uint32_t*)i_ringSectionPtr + local);
+ ddLevelOffset = *((uint32_t*)i_ringSection + local);
ddLevelOffset = ddLevelOffset & 0xFFFFFF00;
ddLevelOffset = htobe32(ddLevelOffset);
- ddLevelOffset = ddLevelOffset + 8;
+ ddLevelOffset = ddLevelOffset + sizeof(TorNumDdLevels_t);
local = local + 1;
- temp1 = *((uint32_t*)i_ringSectionPtr + local);
+ temp1 = *((uint32_t*)i_ringSection + local);
temp1 = htobe32(temp1);
dd_check = 1;
break;
@@ -1082,13 +1158,13 @@ int tor_access_ring( void*
"SGPE rings not populated on SEEPROM image \n");
return IMGBUILD_TGR_IMAGE_DOES_NOT_SUPPORT_SGPE;
}
- else if (i_RingBlockType == DD_LEVEL_RINGS)
+ else if (i_RingBlockType == GET_DD_LEVEL_RINGS)
{
MY_INF("Ambiguity on input PARMS for calling SEEPROM Ring copy API. \n "\
" DD level ring copy are not supported \n");
return IMGBUILD_TGR_IMAGE_DOES_NOT_SUPPORT_DD_LEVEL;
}
- else if (i_RingBlockType == PPE_LEVEL_RINGS )
+ else if (i_RingBlockType == GET_PPE_LEVEL_RINGS )
{
MY_INF("Ambiguity on input PARMS for calling SEEPROM Ring copy API. \n "\
" PPE level ring copy are not supported \n");
@@ -1100,8 +1176,13 @@ int tor_access_ring( void*
temp1 = 0;
}
}
+ else
+ {
+ MY_INF("Ambiguity on input PARMS are not supported \n");
+ return IMGBUILD_TGR_AMBIGUOUS_API_PARMS;
+ }
- if(i_RingBlockType == DD_LEVEL_RINGS) // DD_LEVEL_COPY
+ if(i_RingBlockType == GET_DD_LEVEL_RINGS) // DD_LEVEL_COPY
{
if (io_ringBlockSize < temp1)
@@ -1112,7 +1193,7 @@ int tor_access_ring( void*
}
memcpy( (uint8_t*)(*io_ringBlockPtr),
- (uint8_t*)i_ringSectionPtr + ddLevelOffset, (size_t)temp1);
+ (uint8_t*)i_ringSection + ddLevelOffset, (size_t)temp1);
if(i_dbgl > 1)
{
@@ -1124,7 +1205,7 @@ int tor_access_ring( void*
return IMGBUILD_TGR_RING_BLOCKS_FOUND;
}
- else if (i_RingBlockType == PPE_LEVEL_RINGS)
+ else if (i_RingBlockType == GET_PPE_LEVEL_RINGS)
{
uint32_t l_ppe_offset = 0;
uint32_t l_ppe_size = 0;
@@ -1138,9 +1219,9 @@ int tor_access_ring( void*
MY_INF( "TOR_ACCESS_RING(6): SBE PPE_LEVEL_RING COPY called ... \n");
}
- l_ppe_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_ppe_offset = *((uint32_t*)i_ringSection + temp);
l_ppe_offset = htobe32(l_ppe_offset);
- l_ppe_size = *((uint32_t*)i_ringSectionPtr + temp + 1 );
+ l_ppe_size = *((uint32_t*)i_ringSection + temp + 1 );
l_ppe_size = htobe32(l_ppe_size);
}
else if (i_PpeType == CME)
@@ -1152,24 +1233,24 @@ int tor_access_ring( void*
MY_INF( "TOR_ACCESS_RING(7): CME PPE_LEVEL_RING COPY called... \n");
}
- l_ppe_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_ppe_offset = *((uint32_t*)i_ringSection + temp);
l_ppe_offset = htobe32(l_ppe_offset);
- l_ppe_size = *((uint32_t*)i_ringSectionPtr + temp + 1 );
+ l_ppe_size = *((uint32_t*)i_ringSection + temp + 1 );
l_ppe_size = htobe32(l_ppe_size);
}
else if (i_PpeType == SGPE)
{
- int temp = (ddLevelOffset >> 2) + 4;
+ int temp = (ddLevelOffset >> 2) + sizeof(uint32_t);
if(i_dbgl > 1)
{
MY_INF( "TOR_ACCESS_RING(8): SPGE PPE_LEVEL_RING COPY called... \n");
}
- l_ppe_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_ppe_offset = *((uint32_t*)i_ringSection + temp);
l_ppe_offset = htobe32(l_ppe_offset);
- l_ppe_size = *((uint32_t*)i_ringSectionPtr + temp + 1 );
+ l_ppe_size = *((uint32_t*)i_ringSection + temp + 1 );
l_ppe_size = htobe32(l_ppe_size);
}
@@ -1181,12 +1262,12 @@ int tor_access_ring( void*
}
memcpy( (uint8_t*)(*io_ringBlockPtr),
- (uint8_t*)i_ringSectionPtr + l_ppe_offset + ddLevelOffset,
+ (uint8_t*)i_ringSection + l_ppe_offset + ddLevelOffset,
(size_t)l_ppe_size);
io_ringBlockSize = l_ppe_size;
return IMGBUILD_TGR_RING_BLOCKS_FOUND;
}
- else if (i_RingBlockType == CPLT_LEVEL_RINGS)
+ else if (i_RingBlockType == GET_CPLT_LEVEL_RINGS)
{
if(i_dbgl > 1)
{
@@ -1311,7 +1392,7 @@ int tor_access_ring( void*
if (i_magic == P9_XIP_MAGIC_HW)
{
- l_cplt_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_cplt_offset = *((uint32_t*)i_ringSection + temp);
}
else
{
@@ -1326,7 +1407,7 @@ int tor_access_ring( void*
l_cplt_offset = htobe32(l_cplt_offset);
uint32_t l_ppe_cplt_offset = l_cplt_offset;
temp = temp + 2;
- l_ppe_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_ppe_offset = *((uint32_t*)i_ringSection + temp);
l_ppe_offset = htobe32(l_ppe_offset);
temp1 = l_cplt_offset;
@@ -1338,7 +1419,7 @@ int tor_access_ring( void*
if (io_RingType == COMMON)
{
- temp = l_cplt_offset + ddLevelOffset + (l_sbeTorId * 8);
+ temp = l_cplt_offset + ddLevelOffset + (l_sbeTorId * sizeof(TorPpeBlock_t));
l_word = temp >> 2;
temp = l_cplt_offset + ddLevelOffset;
@@ -1350,7 +1431,9 @@ int tor_access_ring( void*
}
else
{
- temp = l_cplt_offset + ddLevelOffset + (l_sbeTorId * 8) + 4;
+ temp = l_cplt_offset + ddLevelOffset
+ + (l_sbeTorId * sizeof(TorPpeBlock_t))
+ + sizeof(l_TorPpeBlock.TorPpeTypeOffset);
l_word = temp >> 2;
temp = l_cplt_offset + ddLevelOffset;
@@ -1361,7 +1444,7 @@ int tor_access_ring( void*
}
}
- l_cplt_offset = *((uint32_t*)i_ringSectionPtr + l_word);
+ l_cplt_offset = *((uint32_t*)i_ringSection + l_word);
l_cplt_offset = htobe32(l_cplt_offset);
l_word++;
@@ -1370,7 +1453,7 @@ int tor_access_ring( void*
MY_INF("SBE(5):Offset 0x%08x size 0x%08x \n", l_cplt_offset, l_ppe_offset);
}
- l_cplt_size = *((uint32_t*)i_ringSectionPtr + l_word );
+ l_cplt_size = *((uint32_t*)i_ringSection + l_word );
l_cplt_size = htobe32(l_cplt_size);
if(l_sbeTorId == EC_CPLT && io_RingType == INSTANCE)
@@ -1467,9 +1550,9 @@ int tor_access_ring( void*
MY_INF("Not valid chiplet ID\n");
}
- temp = (ddLevelOffset >> 2) + 2;
+ temp = (ddLevelOffset >> 2) + (sizeof(TorPpeBlock_t) >> 2);
int l_word;
- l_cplt_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_cplt_offset = *((uint32_t*)i_ringSection + temp);
if(i_dbgl > 1)
{
@@ -1479,7 +1562,7 @@ int tor_access_ring( void*
l_cplt_offset = htobe32(l_cplt_offset);
uint32_t l_ppe_cplt_offset = l_cplt_offset;
temp = temp + 2;
- l_ppe_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_ppe_offset = *((uint32_t*)i_ringSection + temp);
l_ppe_offset = htobe32(l_ppe_offset);
temp1 = l_cplt_offset;
@@ -1493,7 +1576,6 @@ int tor_access_ring( void*
{
temp = l_cplt_offset + ddLevelOffset;
l_word = temp >> 2;
- temp = l_cplt_offset + ddLevelOffset;
if(i_dbgl > 1)
{
@@ -1503,7 +1585,9 @@ int tor_access_ring( void*
}
else
{
- temp = l_cplt_offset + ddLevelOffset + (l_cmeTorId * 4) + 4;
+ temp = l_cplt_offset + ddLevelOffset
+ + (l_cmeTorId * sizeof(l_TorPpeBlock.TorPpeTypeOffset))
+ + sizeof(l_TorPpeBlock.TorPpeTypeOffset);
l_word = temp >> 2;
temp = l_cplt_offset + ddLevelOffset;
@@ -1514,7 +1598,7 @@ int tor_access_ring( void*
}
}
- l_cplt_offset = *((uint32_t*)i_ringSectionPtr + l_word);
+ l_cplt_offset = *((uint32_t*)i_ringSection + l_word);
l_cplt_offset = htobe32(l_cplt_offset);
l_word++;
@@ -1523,7 +1607,7 @@ int tor_access_ring( void*
MY_INF("CME(5):Offset 0x%08x size 0x%08x \n", l_cplt_offset, l_ppe_offset);
}
- l_cplt_size = *((uint32_t*)i_ringSectionPtr + l_word );
+ l_cplt_size = *((uint32_t*)i_ringSection + l_word );
l_cplt_size = htobe32(l_cplt_size);
if(l_cmeTorId == CME11_CPLT && io_RingType == INSTANCE)
@@ -1546,9 +1630,9 @@ int tor_access_ring( void*
else if (i_PpeType == SGPE)
{
- temp = (ddLevelOffset >> 2) + 4;
+ temp = (ddLevelOffset >> 2) + (2 * (sizeof(TorPpeBlock_t) >> 2));
int l_word;
- l_cplt_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_cplt_offset = *((uint32_t*)i_ringSection + temp);
if(i_dbgl > 1)
{
@@ -1558,7 +1642,7 @@ int tor_access_ring( void*
l_cplt_offset = htobe32(l_cplt_offset);
temp = temp + 1;
- l_ppe_offset = *((uint32_t*)i_ringSectionPtr + temp);
+ l_ppe_offset = *((uint32_t*)i_ringSection + temp);
l_ppe_offset = htobe32(l_ppe_offset);
temp1 = l_cplt_offset;
@@ -1572,7 +1656,6 @@ int tor_access_ring( void*
{
temp = l_cplt_offset + ddLevelOffset;
l_word = temp >> 2;
- temp = l_cplt_offset + ddLevelOffset;
if(i_dbgl > 1)
{
@@ -1582,7 +1665,8 @@ int tor_access_ring( void*
}
else
{
- temp = l_cplt_offset + ddLevelOffset + 4;
+ temp = l_cplt_offset + ddLevelOffset
+ + sizeof(l_TorPpeBlock.TorPpeBlockSize);
l_word = temp >> 2;
temp = l_cplt_offset + ddLevelOffset;
@@ -1593,10 +1677,10 @@ int tor_access_ring( void*
}
}
- l_cplt_offset = *((uint32_t*)i_ringSectionPtr + l_word);
+ l_cplt_offset = *((uint32_t*)i_ringSection + l_word);
l_cplt_offset = htobe32(l_cplt_offset);
l_word++;
- l_cplt_size = *((uint32_t*)i_ringSectionPtr + l_word );
+ l_cplt_size = *((uint32_t*)i_ringSection + l_word );
l_cplt_size = htobe32(l_cplt_size);
if( io_RingType == INSTANCE)
@@ -1626,7 +1710,7 @@ int tor_access_ring( void*
memcpy( (uint8_t*)(*io_ringBlockPtr),
- (uint8_t*)i_ringSectionPtr + l_cplt_offset + temp1,
+ (uint8_t*)i_ringSection + l_cplt_offset + temp1,
(size_t)l_cplt_size);
io_ringBlockSize = l_cplt_size;
return IMGBUILD_TGR_RING_BLOCKS_FOUND;
@@ -1635,7 +1719,7 @@ int tor_access_ring( void*
{
if(i_PpeType == SBE)
{
- rc = get_ring_from_sbe_image ( i_ringSectionPtr,
+ rc = get_ring_from_sbe_image ( i_ringSection,
i_magic,
i_ringId,
ddLevelOffset,
@@ -1660,6 +1744,11 @@ int tor_access_ring( void*
io_instanceId );
return rc;
}
+ else if ( rc == IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION)
+ {
+ MY_INF("\t After SBE single ring call, Ring container is available in the image \n");
+ return rc;
+ }
if(i_dbgl > 1)
{
@@ -1669,7 +1758,8 @@ int tor_access_ring( void*
}
else if (i_PpeType == CME)
{
- rc = get_ring_from_cme_image ( i_ringSectionPtr,
+ rc = get_ring_from_cme_image ( i_ringSection,
+ i_magic,
i_ringId,
ddLevelOffset,
io_RingType,
@@ -1693,6 +1783,11 @@ int tor_access_ring( void*
io_instanceId );
return rc;
}
+ else if ( rc == IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION)
+ {
+ MY_INF("\t After SBE single ring call, Ring container is available in the image \n");
+ return rc;
+ }
if(i_dbgl > 1)
{
@@ -1702,7 +1797,8 @@ int tor_access_ring( void*
}
else if (i_PpeType == SGPE)
{
- rc = get_ring_from_sgpe_image ( i_ringSectionPtr,
+ rc = get_ring_from_sgpe_image ( i_ringSection,
+ i_magic,
i_ringId,
ddLevelOffset,
io_RingType,
@@ -1726,6 +1822,11 @@ int tor_access_ring( void*
io_instanceId );
return rc;
}
+ else if ( rc == IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION)
+ {
+ MY_INF("\t After SBE single ring call, Ring container is available in the image \n");
+ return rc;
+ }
if(i_dbgl > 1)
{
@@ -1744,8 +1845,7 @@ int tor_access_ring( void*
// Pulling single ring from ring section of HW image
/////////////////////////////////////////////////////////////////////////////////////
-int tor_get_single_ring ( void*
- i_ringSectionPt, // ring section pointer
+int tor_get_single_ring ( void* i_ringSection, // ring section pointer
uint16_t i_ddLevel, // DD level info
RingID i_ringId, // Ring ID info
PpeType_t i_PpeType, // ppe Type info
@@ -1769,7 +1869,7 @@ int tor_get_single_ring ( void*
}
rc = tor_access_ring(
- i_ringSectionPt,
+ i_ringSection,
P9_XIP_MAGIC_HW,
i_ringId,
i_ddLevel,
@@ -1777,7 +1877,7 @@ int tor_get_single_ring ( void*
l_ringType,
i_RingVariant,
l_instanceId,
- SINGLE_RING,
+ GET_SINGLE_RING,
io_ringBlockPtr,
io_ringBlockSize,
i_ringName,
@@ -1796,7 +1896,7 @@ int tor_get_single_ring ( void*
///////////////////////////////////////////////////////////////////////////////////////
-int tor_get_block_of_rings ( void* i_ringSectionPt,
+int tor_get_block_of_rings ( void* i_ringSection,
uint16_t i_ddLevel,
PpeType_t i_PpeType,
RingType_t i_RingType,
@@ -1819,7 +1919,7 @@ int tor_get_block_of_rings ( void* i_ringSectionPt,
if(l_ringType == ALLRING && i_PpeType != NUM_PPE_TYPES)
{
//ppe level copy
- rc = tor_access_ring( i_ringSectionPt,
+ rc = tor_access_ring( i_ringSection,
P9_XIP_MAGIC_HW,
P9_NUM_RINGS,
i_ddLevel,
@@ -1827,7 +1927,7 @@ int tor_get_block_of_rings ( void* i_ringSectionPt,
l_ringType,
i_RingVariant,
l_instanceId,
- PPE_LEVEL_RINGS,
+ GET_PPE_LEVEL_RINGS,
io_ringBlockPtr,
io_ringBlockSize,
i_ringName,
@@ -1837,7 +1937,7 @@ int tor_get_block_of_rings ( void* i_ringSectionPt,
else if (l_ringType == ALLRING && i_PpeType == NUM_PPE_TYPES)
{
//dd level Copy
- rc = tor_access_ring( i_ringSectionPt,
+ rc = tor_access_ring( i_ringSection,
P9_XIP_MAGIC_HW,
P9_NUM_RINGS,
i_ddLevel,
@@ -1845,7 +1945,7 @@ int tor_get_block_of_rings ( void* i_ringSectionPt,
l_ringType,
i_RingVariant,
l_instanceId,
- DD_LEVEL_RINGS,
+ GET_DD_LEVEL_RINGS,
io_ringBlockPtr,
io_ringBlockSize,
i_ringName,
@@ -1854,7 +1954,7 @@ int tor_get_block_of_rings ( void* i_ringSectionPt,
else if(l_ringType == COMMON || l_ringType == INSTANCE)
{
// Chiplet level copy
- rc = tor_access_ring( i_ringSectionPt,
+ rc = tor_access_ring( i_ringSection,
P9_XIP_MAGIC_HW,
P9_NUM_RINGS,
i_ddLevel,
@@ -1862,7 +1962,7 @@ int tor_get_block_of_rings ( void* i_ringSectionPt,
l_ringType,
i_RingVariant,
l_instanceId,
- CPLT_LEVEL_RINGS,
+ GET_CPLT_LEVEL_RINGS,
io_ringBlockPtr,
io_ringBlockSize,
i_ringName,
@@ -1882,4 +1982,96 @@ int tor_get_block_of_rings ( void* i_ringSectionPt,
return rc;
}
+
+////////////////////////////////////////////////////////////////////////////////////////
+// TOR_APPEND_RING api appends ring into ring section
+///////////////////////////////////////////////////////////////////////////////////////
+
+int tor_append_ring( void* i_ringSection, // Ring address Ptr any of .rings and .overrides
+ uint32_t& io_ringSectionSize, // Max size of ring section buffer
+ void* i_ringBuffer, // Ring work buffer
+ const uint32_t i_ringBufferSize, // Max size of ring work buffer
+ RingID i_ringId, // Unique ring ID
+ PpeType_t i_PpeType, // PPE type - SBE, CME or SGPE
+ RingType_t i_RingType, // 0: Common 1: Instance
+ RingVariant_t i_RingVariant, // Base, Cache etc
+ uint8_t i_instanceId, // chiplet instance ID
+ void* i_rs4Container, // Addr of rs4 ring container data
+ uint32_t i_dbgl )
+{
+ uint32_t rc = 0;
+ uint32_t dbgl = 2;
+ char i_ringName[25];
+ uint16_t l_ringTypeBuf = 0;
+ uint16_t* l_ringTypeStart = &l_ringTypeBuf;
+ uint8_t l_instanceId = i_instanceId;
+ RingType_t l_RingType = i_RingType;
+ uint32_t l_ringBlockSize;
+ uint16_t l_ringOffsetAddr16;
+ uint64_t l_magic;
+ uint32_t l_torOffsetSlot;
+
+ if(i_PpeType == SBE) // Assign i_magic variant as SBE image
+ {
+ l_magic = P9_XIP_MAGIC_SEEPROM;
+ }
+ else if (i_PpeType == CME ) // Assign i_magic variant as CME image
+ {
+ l_magic = P9_XIP_MAGIC_CME;
+ }
+ else if(i_PpeType == SGPE ) // Assign i_magic variant as SGPE image
+ {
+ l_magic = P9_XIP_MAGIC_SGPE;
+ }
+ else
+ {
+ MY_ERR("TOR_APPEND_RING(2): Unsupported ppe type \n");
+ return IMGBUILD_TGR_AMBIGUOUS_API_PARMS;
+ }
+
+ rc = tor_access_ring( i_ringSection,
+ l_magic,
+ i_ringId,
+ 0x00,
+ i_PpeType,
+ l_RingType,
+ i_RingVariant,
+ l_instanceId,
+ PUT_SINGLE_RING,
+ (void**)&l_ringTypeStart, // On return, contains absolute offset addr where RingType starts in TOR
+ l_torOffsetSlot, // On return, contains absolute offset addr where TOR offset slot is located
+ i_ringName,
+ i_dbgl);
+
+ if (rc)
+ {
+ MY_ERR("\tTOR_APPEND_RING(3): Failure on tor_access_ring function call ...\n");
+ return rc;
+ }
+
+ if(dbgl > 1)
+ {
+ MY_INF(" TOR_APPEND_RING(4): Ring offset address %d \n",
+ l_torOffsetSlot );
+ }
+
+ // Current ring offset address contains old rs4 image starting address.
+ // When tor_append_ring gets new RS4 ring data. It is appended at end of the
+ // .rings section and new ring pointer location is updated at ring offset address
+ l_ringOffsetAddr16 = *l_ringTypeStart;
+ l_ringOffsetAddr16 = io_ringSectionSize - l_ringOffsetAddr16;
+ l_ringOffsetAddr16 = htobe16(l_ringOffsetAddr16 + sizeof(RingLayout_t));
+ memcpy( (uint8_t*)i_ringSection + l_torOffsetSlot, &l_ringOffsetAddr16,
+ sizeof(l_ringOffsetAddr16));
+
+ // Attaching RS4 image at end of the ring section
+ // reading first 4 byte of rs4_container which carries size of ring container
+ // memcpy appends rs4_container at end of the .rings section.
+ l_ringBlockSize = ((RingLayout_t*)i_rs4Container)->sizeOfThis;
+ l_ringBlockSize = htobe32(l_ringBlockSize);
+ memcpy( (uint8_t*)i_ringSection + io_ringSectionSize, (uint8_t*)i_rs4Container,
+ (size_t)l_ringBlockSize);
+ io_ringSectionSize += l_ringBlockSize;
+ return IMGBUILD_TGR_TOR_PUT_RING_DONE;
+}
};
diff --git a/src/import/chips/p9/utils/imageProcs/p9_tor.H b/src/import/chips/p9/utils/imageProcs/p9_tor.H
index 2e87091f..78ce7e8b 100644
--- a/src/import/chips/p9/utils/imageProcs/p9_tor.H
+++ b/src/import/chips/p9/utils/imageProcs/p9_tor.H
@@ -37,16 +37,9 @@ typedef struct
{
uint32_t sizeOfThis;
uint16_t sizeOfCmsk;
- uint16_t sizeOfMeta; // Exact size of meta data. Arbitrary size. Not null terminated.
+ uint16_t sizeOfMeta; // Exact size of meta data. Arbitrary size. Not null terminated
} RingLayout_t;
-
-//
-// Temporary define until in TOR header by Giri.
-//
-//
-// Temporary define until in TOR header by Giri.
-//
typedef struct
{
uint32_t TorNumDdLevels;
@@ -68,9 +61,10 @@ typedef struct
#define IMGBUILD_TGR_RING_FOUND 0
#define IMGBUILD_TGR_RING_BLOCKS_FOUND 0
-#define IMGBUILD_TGR_RING_NOT_FOUND 1 // Ring is not found in HW image.
-#define IMGBUILD_TGR_INVALID_RING_ID 2 // Ring is invalid or mismatch.
-#define IMGBUILD_TGR_AMBIGUOUS_API_PARMS 3 // Ring search in HW iamge got ambiguous condition.
+#define IMGBUILD_TGR_TOR_PUT_RING_DONE 0
+#define IMGBUILD_TGR_RING_NOT_FOUND 1 // Ring is not found in HW image
+#define IMGBUILD_TGR_INVALID_RING_ID 2 // Ring is invalid or mismatch
+#define IMGBUILD_TGR_AMBIGUOUS_API_PARMS 3 // Ring search in HW iamge got ambiguous condition
#define IMGBUILD_TGR_SECTION_NOT_FOUND 4
#define IMGBUILD_TGR_DD_LVL_INFO_NOT_FOUND 5
#define IMGBUILD_TGR_OP_BUFFER_INVALID 6
@@ -80,19 +74,20 @@ typedef struct
#define IMGBUILD_TGR_IMAGE_DOES_NOT_SUPPORT_SGPE 11
#define IMGBUILD_TGR_IMAGE_DOES_NOT_SUPPORT_DD_LEVEL 12
#define IMGBUILD_TGR_IMAGE_DOES_NOT_SUPPORT_PPE_LEVEL 13
+#define IMGBUILD_TGR_RING_AVAILABLE_IN_RINGSECTION 14 // Ring container is already available in ring section
extern const char* ringVariantName[];
extern const char* ppeTypeName[];
-typedef enum
-RingBlockType // Different options to extract data using tor_access_ring API
+typedef enum RingBlockType // Different options to extract data using tor_access_ring API
{
- SINGLE_RING = 0x00,
- DD_LEVEL_RINGS = 0x01,
- PPE_LEVEL_RINGS = 0x02,
- CPLT_LEVEL_RINGS = 0x03
+ GET_SINGLE_RING = 0x00,
+ GET_DD_LEVEL_RINGS = 0x01,
+ GET_PPE_LEVEL_RINGS = 0x02,
+ GET_CPLT_LEVEL_RINGS = 0x03,
+ PUT_SINGLE_RING = 0x04
} RingBlockType_t;
@@ -161,91 +156,294 @@ typedef enum CmeTorId
CME11_CPLT = 11,
CME_NOOF_CHIPLETS = 12
} CmeTorId_t;
+
+typedef enum TorOffsetSize
+{
+ RING_OFFSET_SIZE = 2,
+ CPLT_OFFSET_SIZE = 4
+} TorOffsetSize_t;
+
///
/// ****************************************************************************
/// Function declares.
/// ****************************************************************************
///
+/// Traverse on TOR structure and copies data in granular up to DD type,
+/// ppe type, ring type, RS4 ring container and ring address
+///
+/// \param[in] i_ringSection A pointer to a Ring section binary image.
+/// It contains details of p9 Ring, which is used for scanning operation.
+/// TOR API supports two type of binary image. 1) HW image format and 2)
+/// SEEPROM image format binary
+///
+/// \param[in] i_magic A uint64_t variable to indicate XIP image format
+/// ring section passed
+///
+/// \param[in] i_ringId A enum to indicate unique ID for the ring
+///
+/// \param[in] i_ddLevel A variable to indicate chip DD level. TOR API
+/// uses DD level to extract single ring or block of rings from hw_image
+///
+/// \param[in] i_PpeType A enum to indicate ppe type. They are SBE, CME
+/// and SGPE. It is used to decode TOR structure
+///
+/// \param[in/out] io_RingType A enum and passed by reference. Acts as input
+/// paramfor extracting block of rings copy under Chiplet level. Acts as
+/// outputparam to indicate type of single ring copied is whether common or
+/// instance specific ring
+///
+/// \param[in] i_RingVariant A enum to indicate which variant type of
+/// requested for single ring extract. There are three major types. They are
+/// base, Cache contained and Risk level ring
+///
+/// \param[in/out] io_instanceId A variable to indicate chiplet instance ID.
+/// It returns Chiplet instance ID while doing get single ring operation
+///
+/// \param[in] i_RingVariant A enum to indicate type of operation performed
+/// by TOR API Option:
+/// GET_SINGLE_RING indicates to extract single ring container.
+/// GET_DD_LEVEL_RINGS indicates to extract specific DD level TOR and rings
+/// GET_PPE_LEVEL_RINGS indcates to extract specific PPE level TOR and rings
+/// GET_CPLT_LEVEL_RINGS indciates to extract specific chiplet ring type
+/// TOR and rings
+/// PUT_SINGLE_RING indicates to extract ring absolute memory addres for
+/// ringType start and ringTorSlot location
+///
+/// \param[in/out] io_ringBlockPtr A void pointer to pointer. Returns data
+/// which copied during extract ring operation and returns tor absolute address
+/// where RingType offset slot is located while PUT_SINGLE_RING call.
+/// Note:- Caller's responsibility for free() to avoid memory leak
+///
+/// \param[in/out] io_ringBlockSize A variable. Returns size of data copied
+/// into io_ringBlockPtr and returns absolute offset where ring RS4 starts in
+/// TOR during PUT_SINGLE_RING call
+///
+/// \param[out] o_ringName A string. Returns name of ring ID in characters
+///
+/// \param[in] - i_debug is debug statment params. Supports 0 to 3.
+///
+/// This API traverse TOR structure of .ringSection from HW image or SBE image
+/// and the following n number of operation based on the call.
+///
+/// GET_SINGLE_RING (\a i_ringVariant) - traverse on \a i_ringSection buffer
+/// based on the following input param \a i_magic which gives details of image
+/// type, \a i_ringId which gives ring info, \a i_ddLevel which gives dd spec
+/// (Used only for HW image/optional for other image) i_ppeType which gives ppe
+/// type info, \a i_ringVarint gives ring variant info and \a io_instance which
+/// gives chiplet instance specific while accessing instance specific ring and
+/// returns chiplet number while accessing common ring. On return,
+/// \a io_ringBlockPtr contains RS4 container \a io_RingType contains which
+/// ring type of ring requested and \a io_ringBlockSize contains size of the
+/// data copied into io_ringBlockPtr. \a o_ringName returns ring string name.
+///
+/// GET_DD_LEVEL_RINGS (\a i_ringVariant) - traverse on \a i_ringSection
+/// buffer based on the following input param \a i_magic which gives details
+/// of image type and \a i_ddLevel which gives dd spec(Used only for HW image
+/// /optional for other image) On return, \a io_ringBlockPtr contains DD level
+/// specific ring section and \a io_ringBlockSize contains size of the data
+/// copied into io_ringBlockPtr. \a Other params are optional.
+/// This ringVariant works on HW image.
+///
+/// GET_PPE_LEVEL_RINGS (\a i_ringVariant) - traverse on \a i_ringSection
+/// buffer based on the following input param \a i_magic which gives the detail
+/// of image type, i_ppeType which gives ppe type info and \a i_ddLevel which
+/// gives dd spec(Used only for HW image/optional for other image) On return,
+/// \a io_ringBlockPtr contains PPE type specific ring section and
+/// \a io_ringBlockSize contains size of the data copied into io_ringBlockPtr.
+/// \a Other params are optional. This ringVariant works on HW image.
+///
+/// GET_CPLT_LEVEL_RINGS (\a i_ringVariant) - traverse on \a i_ringSection
+/// buffer based on the following input param \a i_magic which gives the detail
+/// of image type, i_ppeType which gives ppe type info, \a i_ddLevel which gives
+/// dd spec(Used only for HW image/optional for other image) and \a io_RingType
+/// which gives ring type info. On return, \a io_ringBlockPtr contains chiplet
+/// specific ring type ring section and \a io_ringBlockSize contains size of
+/// the data copied into io_ringBlockPtr. \a Other params are optional.
+///
+/// PUT_SINGLE_RING (\a i_ringVariant) - traverse on \a i_ringSection buffer
+/// based on the following input param \a i_magic which gives detail of image
+/// type, \a i_ringId which gives ring info, \a i_ddLevel which gives dd spec
+/// (Used only for HW image/optional for other image), i_ppeType which gives
+/// ppe type info, \a i_ringVarint gives ring variant info and \a io_instance
+/// which gives chiplet instance specific while accessing instance specific
+/// ring and returns chiplet number while accessing common ring. On return,
+/// \a io_ringBlockPtr contains absolute memory address of ring type of
+/// requested ring and \a io_ringBlockSize contains of absolute memory addres
+/// of ringTor slot copied into io_ringBlockPtr \a o_ringName returns ring
+/// string name
+///
+/// \retval 0 Success
+///
+/// \retval non-0 See \ref TOR API RETURN errors
+int tor_access_ring( void* i_ringSection, // Ring address Ptr any of .rings, .overrides and .overlays.
+ uint64_t i_magic, // Image Magic Number
+ RingID i_ringId, // Unique ring ID
+ uint16_t i_ddLevel, // DD level info
+ PpeType_t i_PpeType, // PPE type : SBE, CME, etc
+ RingType_t& io_RingType, // 0: Common 1: Instance
+ RingVariant_t i_RingVariant, // Base, Cache etc
+ uint8_t& io_instanceId, // chiplet instance ID
+ RingBlockType_t i_RingBlockType, // 0: single ring, 1: ring block
+ void** io_ringBlockPtr, // Addr of ring buffer
+ uint32_t& io_ringBlockSize, // size of ring data
+ char* o_ringName, // Ring name
+ uint32_t i_dbgl = 0 ); // Debug option
-int get_ring_from_sbe_image ( void*
- i_ringSectionPtr, // Image pointer
- uint64_t i_magic, // Image Magic Number
- RingID i_ringId, // Unique ring ID
- uint16_t i_ddLevel, // DD level details
- RingType_t& io_RingType, // 0: Common 1: Instance
- RingVariant_t i_RingVariant, // Base, cache contained, Risk level,
- // Override and Overlay
- uint8_t& io_instanceId, // required Instance
- RingBlockType_t RingBlockType, // 0: single ring, 1: ddLevel block
- void** io_ringBlockPtr, // RS4 Container data or block data
- uint32_t& io_ringBlockSize, // size of data copied into ring block pointer
- char* o_ringName, // Name of ring
- uint32_t dbgl); // Debug option
-
-int get_ring_from_sgpe_image ( void*
- i_ringSectionPtr, // Image pointer
- RingID i_ringId, // Unique ring ID
- uint16_t i_ddLevel, // DD level details
- RingType_t& io_RingType, // 0: Common 1: Instance
- RingVariant_t i_RingVariant, // Base, cache contained, Risk level,
- // Override and Overlay
- uint8_t& io_instanceId, // required Instance
- RingBlockType_t RingBlockType, // 0: single ring, 1: ddLevel block
- void** io_ringBlockPtr, // RS4 Container data or block data
- uint32_t& io_ringBlockSize, // size of data copied into ring block pointer
- char* o_ringName, // Name of ring
- uint32_t dbgl); // Debug option
-
-int get_ring_from_cme_image ( void* i_ringSectionPtr, // Image pointer
- RingID i_ringId, // Unique ring ID
- uint16_t i_ddLevel, // DD level details
- RingType_t& io_RingType, // 0: Common 1: Instance
- RingVariant_t i_RingVariant, // Base, cache contained, Risk level,
- // Override and Overlay
- uint8_t& io_instanceId, // required Instance
- RingBlockType_t RingBlockType, // 0: single ring, 1: ddLevel block
- void** io_ringBlockPtr, // RS4 Container data or block data
- uint32_t& io_ringBlockSize, // size of data copied into ring block pointer
- char* o_ringName, // Name of ring
- uint32_t dbgl); // Debug option
-
-int tor_access_ring( void*
- i_ringSectionPtr, // Ring address Ptr any of .rings, .overrides and .overlays.
- uint64_t i_magic, // Image Magic Number
- RingID i_ringId, // Unique ring ID
- uint16_t i_ddLevel, // DD level info
- PpeType_t i_PpeType, // PPE type : SBE, CME, etc
- RingType_t& io_RingType, // 0: Common 1: Instance
- RingVariant_t i_RingVariant, // Base, Cache etc
- uint8_t& io_instanceId, // chiplet instance ID
- RingBlockType_t i_RingBlockType, // 0: single ring, 1: ring block
- void** io_ringBlockPtr, // Addr of ring buffer
- uint32_t& io_ringBlockSize, // size of ring data
- char* o_ringName, // Ring name
- uint32_t i_dbgl = 0); // Debug option
-
-int tor_get_single_ring ( void*
- i_ringSectionPt, // Ring address Ptr any of .rings, .overrides and .overlays.
- uint16_t i_ddLevel, // DD level info
- RingID i_ringId, // Unique ring ID
- PpeType_t i_PpeType, // ppe Type
- RingVariant_t i_RingVariant, // Base, cache contained, etc
- uint8_t i_instanceId, // Chiplet Instance ID
- void** io_ringBlockPtr, // Addr of ring buffer
- uint32_t& io_ringBlockSize, // size of ring data
- uint32_t i_dbgl = 0); // Debug option
-
-int tor_get_block_of_rings ( void*
- i_ringSectionPt, // Ring address Ptr any of .rings, .overrides and .overlays.
- uint16_t i_ddLevel, // DD level
- PpeType_t i_PpeType, // ppe Type
- RingType_t i_RingType, // Common Or Instance
- RingVariant_t i_RingVariant, // base,cache,etc
- uint8_t i_instanceId, // Chiplet Instance ID
- void** io_ringBlockPtr, // Addr of ring buffer
- uint32_t& io_ringBlockSize, // size of ring data
- uint32_t i_dbgl = 0); // Debug option
-};
+/// Traverse on TOR structure and copies RS4 ring container data for ring
+/// variant
+///
+/// \param[in] i_ringSection A pointer to a Ring section binary image.
+/// It contain details of p9 Ring which is used for scanning operation.
+/// TOR API supports HW image format only
+///
+/// \param[in] i_ringId A enum to indicate unique ID for the ring
+///
+/// \param[in] i_ddLevel A variable to indicate chip DD level. TOR API
+/// uses DD level to extract single ring or block of rings on hw_image.
+///
+/// \param[in] i_PpeType A enum to indicate ppe type.
+/// They are SBE, CME and SGPE. It is used to decode TOR structure
+///
+/// \param[in] i_RingVariant A enum to indicate which variant type of
+/// requested for get single ring operation There are three major types.
+/// They are base, Cache contained and Risk level ring
+///
+/// \param[in] io_instanceId A variable to indicate chiplet instance ID
+///
+/// \param[in/out] io_ringBlockPtr A void point to pointer. Returns data
+/// which copied during extract ring operation
+/// Note- Caller's responsibility for free() to avoid memory leak
+///
+/// \param[in/out] io_ringBlockSize A variable. Returns size of data copied
+/// into io_ringBlockPtr
+///
+/// \param[in] - i_debug is debug statment params. Supports 0 to 3.
+///
+/// This API contains wrapper on top of tor_access_ring API to support get
+/// single ring container from .ring section and customizes for
+/// get_single_ring parameter.
+///
+/// \retval 0 Success
+///
+/// \retval non-0 See \ref TOR API RETURN errors
+int tor_get_single_ring ( void* i_ringSection,
+ uint16_t i_ddLevel,
+ RingID i_ringId,
+ PpeType_t i_PpeType,
+ RingVariant_t i_RingVariant,
+ uint8_t i_instanceId,
+ void** io_ringBlockPtr,
+ uint32_t& io_ringBlockSize,
+ uint32_t i_dbgl = 0 ); // Debug option
+/// Traverse on TOR structure and copies data in block level up to DD type,
+/// ppe type and ring type
+///
+/// \param[in] i_ringSection A pointer to a Ring section binary image.
+/// It contains details of p9 Ring which is used for scanning operation.
+/// API supports HW image format only
+///
+/// \param[in] i_ddLevel A variable to indicate chip DD level. TOR API
+/// uses DD level to extract single ring or block of rings on hw_image
+///
+/// \param[in] i_PpeType A enum to indicate ppe type passed.
+/// they are SBE, CME and SGPE. It is used to decode TOR structure
+/// TOR API uses Ppe type to extract single ring or block of rings
+/// on either hw_image or SBE image
+///
+/// \param[in] i_RingType A enum and passed by reference. Acts as
+/// input param for extracting block of rings copy under Chiplet level
+///
+/// \param[in] i_RingVariant A enum to indicate which variant type of
+/// requested for single ring extract. There are three major types.
+/// They are base, Cache contained and Risk level ring
+///
+/// \param[in] i_instanceId A variable to indicate chiplet instance ID
+///
+/// \param[in/out] io_ringBlockPtr A void point to pointer. Returns data
+/// which copied block of rings. Note: Caller's responsibility for free()
+/// to avoid memory leak
+//
+/// \param[in/out] io_ringBlockSize A variable. Returns size of data
+/// copied into io_ringBlockPtr
+///
+/// \param[in] - i_debug is debug statment params. Supports 0 to 3.
+///
+/// This API contains wrapper on top of tor_access_ring API and supports
+/// to copy block of rings in DD level, ppe level and ringType level.
+///
+/// \retval 0 Success
+///
+/// \retval non-0 See \ref TOR API RETURN errors
+int tor_get_block_of_rings ( void* i_ringSection,
+ uint16_t i_ddLevel,
+ PpeType_t i_PpeType,
+ RingType_t i_RingType,
+ RingVariant_t i_RingVariant,
+ uint8_t i_instanceId,
+ void** io_ringBlockPtr,
+ uint32_t& io_ringBlockSize,
+ uint32_t i_dbgl = 0 );
+
+/// Traverse on TOR structure and copies absolute memory address of Ringtype
+/// offset addres and TOR offset slot address
+///
+/// \param[in] i_ringSection A pointer to a Ring section binary image.
+/// It contains details of p9 Ring which is used for scanning operation.
+/// TOR API supports SEEPROM image format.
+///
+/// \param[in/out] io_ringSectionSize A value to indicate actual size of
+/// i_ringSection data passed in as input On return, updated size of section.
+/// Note: Caller manages this buffer and must make sure the RS4 ring fits
+/// before making this call
+///
+/// \param[in] i_ringBuffer A pointer to a ring work buffer, which is used
+/// for scanning operation purpose
+///
+/// \param[in] i_ringBufferSize A constant value to indicate size of
+/// ringBuffer data passed in
+///
+/// \param[in] i_ringId A enum to indicate unique ID for the ring
+///
+/// \param[in] i_PpeType A enum to indicate ppe type. They are SBE,
+/// CME and SGPE. It is used to decode TOR structure
+///
+/// \param[in] i_RingType A enum to indicate ring type of ring whether
+/// common or instance specific ring
+///
+/// \param[in] i_RingVariant A enum and used as input param to indicate
+/// which variant type of requested for single ring extract
+///
+/// \param[in] i_instanceId A variable to indicate chiplet instance ID
+///
+/// \param[in] i_rs4_container A void pointer. Contains RS4 compressed ring
+/// data which eventually attached into void image pointer i_ringSection
+///
+/// \param[in] - i_debug is debug statment params. Supports 0 to 3.
+///
+/// This API contains wrapper on tor_access_ring to get \a io_ringBlockPtr
+/// contains absolute memory address of ring type start address of the ring
+/// \a io_ringBlockSize contains absolute memory address of ringTorslot. Then
+/// appends new rs4 ring container at the end of ring section and updates new
+/// ring offset address on ring offset location. the slot must be empty. If there
+/// is non-zero content in the slot, the API will fail catastrophically. Do not
+/// "insert" or "replace" rings at ring section.
+///
+/// \retval 0 Success
+///
+/// \retval non-0 See \ref TOR API RETURN errors
+int tor_append_ring( void* i_ringSection,
+ uint32_t& io_ringSectionSize,
+ void* i_ringBuffer,
+ const uint32_t i_ringBufferSize,
+ RingID i_ringId,
+ PpeType_t i_ppeType,
+ RingType_t i_RingType,
+ RingVariant_t i_RingVariant,
+ uint8_t i_instanceId,
+ void* i_rs4Container,
+ uint32_t i_dbgl = 0 );
+};
#endif //_P9_TOR_H_
+
OpenPOWER on IntegriCloud