yb_arm/app/src/pet_sm_mgt.s.c
2023-07-12 14:14:31 +08:00

61 lines
2.2 KiB
C

// +FHDR------------------------------------------------------------
// Copyright (c) 2020 PicocomTech.
// ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename : ecs_sm_mgt.c
// Author : xianfeng.du
// Created On : 2022-06-27
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------
#include "ucp_printf.h"
#include "mem_sections.h"
#include "ucp_utility.h"
#include "pet_sm_mgt.h"
#include "ospHeap.h"
PetSmLocalMgt_t gPetSmLocalMgt;
PetSmLocalMgt_t* get_pet_sm_local_mgt(void)
{
return (PetSmLocalMgt_t *)&gPetSmLocalMgt;
}
void pet_sm_alloc(void)
{
UCP_PRINT_LOG("start allocating pet share memory");
uint32_t i,j;
uint64_t length;
PetSmLocalMgt_t* pPetSmLocalMgt = get_pet_sm_local_mgt();
uint8_t* ptr = (uint8_t *)get_static_mem(PET_SM,(uint64_t *)&length);
MEM_SECTION_INFO* pMemSection = GetPetSramSection();
length = PET_SRAM_SIZE;
memSectionInit(pMemSection, (uint64_t)ptr, (uint32_t)length, pMemSection->memSectionName);
pPetSmLocalMgt->pHandshake = (UcpHandshake_t *)memSectionAlloc(pMemSection, sizeof(UcpHandshake_t), MEM_ALIGNED_4BYTES, "pHandshake");
pPetSmLocalMgt->pSyncInfo = (SyncInfo_t *)memSectionAlloc(pMemSection, sizeof(SyncInfo_t), MEM_ALIGNED_4BYTES, "pSyncInfo");
pPetSmLocalMgt->pBufIdxBase = (uint16_t *)memSectionAlloc(pMemSection, MAX_INSTANCE_NUM*UCP4008_TRAFFIC_MAX_NUM*MAX_M_BUFFER_NUM*sizeof(uint16_t), MEM_ALIGNED_4BYTES, "pBufIdxBase");
for (i = 0; i < MAX_INSTANCE_NUM; i++) {
for (j = 0; j < UCP4008_TRAFFIC_MAX_NUM; j++) {
pPetSmLocalMgt->pQueueCfg[i][j] = (MsgQueueCfg_t *)memSectionAlloc(pMemSection, sizeof(MsgQueueCfg_t), MEM_ALIGNED_4BYTES, "pQueueCfg");
}
}
for (i = 0; i < MAX_INSTANCE_NUM; i++) {
for (j = 0; j < UCP4008_TRAFFIC_MAX_NUM; j++) {
pPetSmLocalMgt->pDlQueue[i][j] = (MsgQueueCommonInfo_t *)memSectionAlloc(pMemSection, sizeof(MsgQueueCommonInfo_t), MEM_ALIGNED_64BYTES, "pDlQueue");
pPetSmLocalMgt->pUlQueue[i][j] = (MsgQueueCommonInfo_t *)memSectionAlloc(pMemSection, sizeof(MsgQueueCommonInfo_t), MEM_ALIGNED_64BYTES, "pUlQueue");
}
}
return;
}