mirror of
https://gitee.com/Vancouver2017/luban-lite.git
synced 2025-12-16 17:18:56 +00:00
v1.1.1
This commit is contained in:
@@ -605,7 +605,7 @@ static s32 get_mem_buf_cmd_read_output_data(struct upg_cmd *cmd, u8 *buf,
|
||||
|
||||
if (cmd->state == CMD_STATE_RESP) {
|
||||
memlen = (u32)(long)cmd->priv;
|
||||
mem = aicos_malloc_align(0, memlen, ARCH_DMA_MINALIGN);
|
||||
mem = aicupg_malloc_align(memlen, ARCH_DMA_MINALIGN);
|
||||
/*
|
||||
* Enter read RESP state, to make it simple, HOST should read
|
||||
* RESP in one read operation.
|
||||
@@ -669,7 +669,7 @@ static s32 free_mem_buf_cmd_write_input_data(struct upg_cmd *cmd, u8 *buf,
|
||||
memcpy(&addr, buf, 4);
|
||||
clen += 4;
|
||||
|
||||
aicos_free_align(0, (void *)(long)addr);
|
||||
aicupg_free_align((void *)(long)addr);
|
||||
cmd_state_set_next(cmd, CMD_STATE_RESP);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ s32 mmc_fwc_sparse_fill(struct aicupg_mmc_priv *priv, struct aic_partition *part
|
||||
u32 *fill_buf, fill_buf_num_blks, fill_blks = 0;
|
||||
int i, j;
|
||||
|
||||
fill_buf = (u32 *)aicos_malloc_align(0, ROUNDUP(SPARSE_FILLBUF_SIZE, CACHE_LINE_SIZE), CACHE_LINE_SIZE);
|
||||
fill_buf = (u32 *)aicupg_malloc_align(ROUNDUP(SPARSE_FILLBUF_SIZE, CACHE_LINE_SIZE), CACHE_LINE_SIZE);
|
||||
if (!fill_buf) {
|
||||
pr_err("Malloc failed for: CHUNK_TYPE_FILL\n");
|
||||
return 0;
|
||||
@@ -193,7 +193,7 @@ s32 mmc_fwc_sparse_fill(struct aicupg_mmc_priv *priv, struct aic_partition *part
|
||||
}
|
||||
|
||||
out:
|
||||
aicos_free_align(0, fill_buf);
|
||||
aicupg_free_align(fill_buf);
|
||||
return fill_blks;
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ s32 mmc_fwc_raw_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
long n;
|
||||
u32 clen = 0, calc_len = 0;
|
||||
|
||||
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
|
||||
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
|
||||
if (!rdbuf) {
|
||||
pr_err("Error: malloc buffer failed.\n");
|
||||
return 0;
|
||||
@@ -468,7 +468,7 @@ s32 mmc_fwc_raw_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
|
||||
out:
|
||||
if (rdbuf)
|
||||
aicos_free_align(0, rdbuf);
|
||||
aicupg_free_align(rdbuf);
|
||||
return clen;
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ s32 nand_fwc_uffs_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
int total_len = 0, remain_offset = 0;
|
||||
u8 *wbuf = NULL, *pbuf = NULL;
|
||||
|
||||
wbuf = aicos_malloc_align(0, ROUNDUP(len, fwc->block_size), CACHE_LINE_SIZE);
|
||||
wbuf = aicupg_malloc_align(ROUNDUP(len, fwc->block_size), CACHE_LINE_SIZE);
|
||||
if (!wbuf) {
|
||||
pr_err("malloc failed.\n");
|
||||
return 0;
|
||||
@@ -293,13 +293,13 @@ s32 nand_fwc_uffs_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
|
||||
|
||||
fwc->calc_partition_crc = fwc->meta.crc;
|
||||
aicos_free_align(0, wbuf);
|
||||
aicupg_free_align(wbuf);
|
||||
|
||||
return len;
|
||||
|
||||
out:
|
||||
if (wbuf)
|
||||
aicos_free_align(0, wbuf);
|
||||
aicupg_free_align(wbuf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ s32 nand_fwc_mtd_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
int i, ret = 0, calc_len = 0;
|
||||
u8 *rdbuf, *buf_to_write, *buf_to_read;
|
||||
|
||||
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
|
||||
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
|
||||
if (!rdbuf) {
|
||||
pr_err("Error: malloc buffer failed.\n");
|
||||
return 0;
|
||||
@@ -431,11 +431,11 @@ s32 nand_fwc_mtd_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
|
||||
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
|
||||
|
||||
aicos_free_align(0, rdbuf);
|
||||
aicupg_free_align(rdbuf);
|
||||
return len;
|
||||
out:
|
||||
if (rdbuf)
|
||||
aicos_free_align(0, rdbuf);
|
||||
aicupg_free_align(rdbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ s32 nand_fwc_nftl_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
int i, calc_len = 0, ret = 0;
|
||||
u8 *rdbuf;
|
||||
|
||||
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
|
||||
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
|
||||
if (!rdbuf) {
|
||||
pr_err("Error: malloc buffer failed.\n");
|
||||
return 0;
|
||||
@@ -514,11 +514,11 @@ s32 nand_fwc_nftl_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
|
||||
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
|
||||
(void)ret;
|
||||
aicos_free_align(0, rdbuf);
|
||||
aicupg_free_align(rdbuf);
|
||||
return len;
|
||||
out:
|
||||
if (rdbuf)
|
||||
aicos_free_align(0, rdbuf);
|
||||
aicupg_free_align(rdbuf);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -567,6 +567,9 @@ void nand_fwc_data_end(struct fwc_info *fwc)
|
||||
if (!priv)
|
||||
return;
|
||||
|
||||
if (priv->spl_flag)
|
||||
nand_fwc_spl_end(priv);
|
||||
|
||||
#ifdef AIC_NFTL_SUPPORT
|
||||
struct nftl_api_handler_t *nftl_handler;
|
||||
for (int i = 0; i < MAX_DUPLICATED_PART; i++) {
|
||||
|
||||
@@ -683,6 +683,17 @@ s32 nand_fwc_spl_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
return len;
|
||||
}
|
||||
|
||||
s32 nand_fwc_spl_end(struct aicupg_nand_priv *priv)
|
||||
{
|
||||
struct aicupg_nand_spl *spl;
|
||||
|
||||
spl = &g_nand_spl;
|
||||
if (spl->image_buf)
|
||||
free(spl->image_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nand_spl_get_candidate_blocks(u32 *blks, u32 size)
|
||||
{
|
||||
if (!blks || size < SPL_CANDIDATE_BLOCK_NUM) {
|
||||
|
||||
@@ -87,6 +87,7 @@ s32 nand_fwc_spl_reserve_blocks(struct aicupg_nand_priv *priv);
|
||||
s32 nand_fwc_spl_prepare(struct aicupg_nand_priv *priv, u32 datasiz,
|
||||
u32 blksiz);
|
||||
s32 nand_fwc_spl_write(struct fwc_info *fwc, u8 *buf, s32 len);
|
||||
s32 nand_fwc_spl_end(struct aicupg_nand_priv *priv);
|
||||
int nand_spl_get_candidate_blocks(u32 *blks, u32 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -137,7 +137,7 @@ s32 nor_fwc_data_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
int i, calc_len = 0, ret = 0;
|
||||
u8 *rdbuf;
|
||||
|
||||
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
|
||||
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
|
||||
if (!rdbuf) {
|
||||
pr_err("Error: malloc buffer failed.\n");
|
||||
return 0;
|
||||
@@ -201,12 +201,12 @@ s32 nor_fwc_data_write(struct fwc_info *fwc, u8 *buf, s32 len)
|
||||
fwc->trans_size += len;
|
||||
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
|
||||
|
||||
aicos_free_align(0, rdbuf);
|
||||
aicupg_free_align(rdbuf);
|
||||
return len;
|
||||
|
||||
out:
|
||||
if (rdbuf)
|
||||
aicos_free_align(0, rdbuf);
|
||||
aicupg_free_align(rdbuf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -59,10 +59,10 @@ s32 trans_layer_rw_proc(struct phy_data_rw *rw, u8 *buffer, u32 len)
|
||||
|
||||
if (!trans_pkt_buf) {
|
||||
trans_pkt_siz = TRANS_DATA_BUFF_MAX_SIZE;
|
||||
trans_pkt_buf = aicos_malloc_align(0, trans_pkt_siz, CACHE_LINE_SIZE);
|
||||
trans_pkt_buf = aicupg_malloc_align(trans_pkt_siz, CACHE_LINE_SIZE);
|
||||
if (!trans_pkt_buf) {
|
||||
trans_pkt_siz = TRANS_DATA_BUFF_MIN_SIZE;
|
||||
trans_pkt_buf = aicos_malloc_align(0, trans_pkt_siz, CACHE_LINE_SIZE);
|
||||
trans_pkt_buf = aicupg_malloc_align(trans_pkt_siz, CACHE_LINE_SIZE);
|
||||
if (!trans_pkt_buf) {
|
||||
pr_err("malloc trans pkt buf(%u) failed.\n", trans_pkt_siz);
|
||||
return -1;
|
||||
|
||||
@@ -33,21 +33,21 @@ static void *upg_fat_malloc_align(struct fwc_info *fwc, u32 *size, size_t align)
|
||||
switch (*size) {
|
||||
case DATA_WRITE_ONCE_MAX_SIZE:
|
||||
*size = ALIGN_DOWN(DATA_WRITE_ONCE_MAX_SIZE, fwc->block_size);
|
||||
ptr = aicos_malloc_align(0, *size, align);
|
||||
ptr = aicupg_malloc_align(*size, align);
|
||||
if (ptr)
|
||||
break;
|
||||
case DATA_WRITE_ONCE_MID_SIZE:
|
||||
*size = ALIGN_DOWN(DATA_WRITE_ONCE_MID_SIZE, fwc->block_size);
|
||||
ptr = aicos_malloc_align(0, *size, align);
|
||||
ptr = aicupg_malloc_align(*size, align);
|
||||
if (ptr)
|
||||
break;
|
||||
case DATA_WRITE_ONCE_MIN_SIZE:
|
||||
*size = ALIGN_DOWN(DATA_WRITE_ONCE_MIN_SIZE, fwc->block_size);
|
||||
ptr = aicos_malloc_align(0, *size, align);
|
||||
ptr = aicupg_malloc_align(*size, align);
|
||||
if (ptr)
|
||||
break;
|
||||
default:
|
||||
ptr = aicos_malloc_align(0, *size, align);
|
||||
ptr = aicupg_malloc_align(*size, align);
|
||||
if (ptr)
|
||||
break;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ static void *upg_fat_malloc_align(struct fwc_info *fwc, u32 *size, size_t align)
|
||||
|
||||
static void upg_fat_free_align(void *mem)
|
||||
{
|
||||
aicos_free_align(0, mem);
|
||||
aicupg_free_align(mem);
|
||||
}
|
||||
|
||||
#define FRAME_LIST_SIZE 4096
|
||||
@@ -73,7 +73,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta)
|
||||
|
||||
fwc = NULL;
|
||||
buf = NULL;
|
||||
fwc = aicos_malloc_align(0, sizeof(struct fwc_info), FRAME_LIST_SIZE);
|
||||
fwc = aicupg_malloc_align(sizeof(struct fwc_info), FRAME_LIST_SIZE);
|
||||
if (!fwc) {
|
||||
pr_err("Error: malloc fwc failed.\n");
|
||||
ret = -1;
|
||||
@@ -91,7 +91,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta)
|
||||
media_data_write_start(fwc);
|
||||
|
||||
/*config write size once*/
|
||||
if (config_ram_size <= 0x100000)
|
||||
if (config_ram_size <= 0x400000)
|
||||
write_once_size = DATA_WRITE_ONCE_MIN_SIZE;
|
||||
else
|
||||
write_once_size = DATA_WRITE_ONCE_MAX_SIZE;
|
||||
@@ -151,7 +151,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta)
|
||||
(total_len * 1000000 / start_us) / 1024 % 1024);
|
||||
|
||||
upg_fat_free_align(buf);
|
||||
aicos_free_align(0, fwc);
|
||||
aicupg_free_align(fwc);
|
||||
|
||||
return total_len;
|
||||
err:
|
||||
@@ -159,7 +159,7 @@ err:
|
||||
if (buf)
|
||||
upg_fat_free_align(buf);
|
||||
if (fwc)
|
||||
aicos_free_align(0, fwc);
|
||||
aicupg_free_align(fwc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ s32 aicupg_fat_write(char *image_name, char *protection,
|
||||
u64 total_len = 0;
|
||||
|
||||
pmeta = NULL;
|
||||
pmeta = (struct fwc_meta *)aicos_malloc_align(0, header->meta_size, FRAME_LIST_SIZE);
|
||||
pmeta = (struct fwc_meta *)aicupg_malloc_align(header->meta_size, FRAME_LIST_SIZE);
|
||||
if (!pmeta) {
|
||||
pr_err("Error: malloc for meta failed.\n");
|
||||
ret = -1;
|
||||
@@ -231,10 +231,10 @@ s32 aicupg_fat_write(char *image_name, char *protection,
|
||||
(ulong)((total_len * 1000000 / start_us) / 1024 / 1024),
|
||||
(ulong)((total_len * 1000000 / start_us) / 1024 % 1024));
|
||||
|
||||
aicos_free_align(0, pmeta);
|
||||
aicupg_free_align(pmeta);
|
||||
return write_len;
|
||||
err:
|
||||
if (pmeta)
|
||||
aicos_free_align(0, pmeta);
|
||||
aicupg_free_align(pmeta);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ static int fat_direct_mmc_write_raw(struct aic_sdmc *host, char *fpath,
|
||||
|
||||
printf("Programming %s to 0x%x\n", fpath, doffset);
|
||||
printf("\t");
|
||||
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
soffset = 0;
|
||||
writecnt = 0;
|
||||
|
||||
@@ -62,7 +62,7 @@ static int fat_direct_mmc_write_raw(struct aic_sdmc *host, char *fpath,
|
||||
}
|
||||
|
||||
if (buf)
|
||||
aicos_free_align(0, buf);
|
||||
aicupg_free_align(buf);
|
||||
printf("\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath,
|
||||
|
||||
printf("Programming %s to 0x%x\n", fpath, doffset);
|
||||
printf("\t");
|
||||
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
soffset = 0;
|
||||
|
||||
dolen = MAX_WRITE_SIZE;
|
||||
@@ -149,8 +149,8 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath,
|
||||
|
||||
/* Read raw chunk data */
|
||||
if (chunk_data_sz > MAX_WRITE_SIZE) {
|
||||
aicos_free_align(0, buf);
|
||||
buf = aicos_malloc_align(0, chunk_data_sz, FRAME_LIST_SIZE);
|
||||
aicupg_free_align(buf);
|
||||
buf = aicupg_malloc_align(chunk_data_sz, FRAME_LIST_SIZE);
|
||||
p = buf;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath,
|
||||
|
||||
out:
|
||||
if (buf)
|
||||
aicos_free_align(0, buf);
|
||||
aicupg_free_align(buf);
|
||||
printf("\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ static int fat_direct_spinand_write_boot(char *fpath, struct mtd_dev *mtd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
soffset = 0;
|
||||
while (1) {
|
||||
actread = 0;
|
||||
@@ -91,7 +91,7 @@ static int fat_direct_spinand_write_boot(char *fpath, struct mtd_dev *mtd)
|
||||
}
|
||||
|
||||
if (buf)
|
||||
aicos_free_align(0, buf);
|
||||
aicupg_free_align(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ static int fat_direct_spinand_write_data(char *fpath, struct mtd_dev *mtd,
|
||||
u32 soffset;
|
||||
ulong dolen, actread, writecnt;
|
||||
|
||||
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
soffset = 0;
|
||||
writecnt = 0;
|
||||
|
||||
@@ -155,7 +155,7 @@ static int fat_direct_spinand_write_data(char *fpath, struct mtd_dev *mtd,
|
||||
}
|
||||
|
||||
if (buf)
|
||||
aicos_free_align(0, buf);
|
||||
aicupg_free_align(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ static int fat_direct_spinand_write_nftl(char *fpath, u32 doffset)
|
||||
goto out;
|
||||
}
|
||||
|
||||
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
if (!buf) {
|
||||
pr_err("Failed to malloc buffer.\n");
|
||||
ret = -1;
|
||||
@@ -255,7 +255,7 @@ static int fat_direct_spinand_write_nftl(char *fpath, u32 doffset)
|
||||
|
||||
out:
|
||||
if (buf)
|
||||
aicos_free_align(0, buf);
|
||||
aicupg_free_align(buf);
|
||||
if (nftl && nftl->nandt)
|
||||
aicos_free(MEM_CMA, nftl->nandt);
|
||||
if (nftl)
|
||||
|
||||
@@ -58,7 +58,7 @@ int fat_direct_write_spinor(u32 spi_id, char *fpath, u32 doffset)
|
||||
|
||||
printf("Programming %s to 0x%x\n", fpath, doffset);
|
||||
printf("\t");
|
||||
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
|
||||
soffset = 0;
|
||||
writecnt = 0;
|
||||
|
||||
@@ -103,7 +103,7 @@ int fat_direct_write_spinor(u32 spi_id, char *fpath, u32 doffset)
|
||||
}
|
||||
|
||||
if (buf)
|
||||
aicos_free_align(0, buf);
|
||||
aicupg_free_align(buf);
|
||||
printf("\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -451,3 +451,13 @@ void media_data_write_end(struct fwc_info *fwc)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void *aicupg_malloc_align(u32 size, size_t align)
|
||||
{
|
||||
return aicos_malloc_align(MEM_RESERVED, size, align);
|
||||
}
|
||||
|
||||
void aicupg_free_align(void *ptr)
|
||||
{
|
||||
aicos_free_align(MEM_RESERVED, ptr);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Wu Dehuang <dehuang.wu@artinchip.com>
|
||||
* Authors: Wu Dehuang <dehuang.wu@artinchip.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -487,8 +487,8 @@ static s32 exfat_search_file(struct fat_volume *vol, struct fat_file *file,
|
||||
/* Bingo */
|
||||
file->start_clus = first_cluster;
|
||||
file->size = data_len;
|
||||
pr_err("Start cluster: 0x%X\n", file->start_clus);
|
||||
pr_err("bootcfg file size: 0x%X\n", file->size);
|
||||
pr_debug("Start cluster: 0x%X\n", file->start_clus);
|
||||
pr_debug("bootcfg file size: 0x%X\n", file->size);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user