提交 349c1e46 编写于 作者: L laokz

QEMU arm platform: get 'bootargs' from flash; fix code style

Change-Id: I94175fa89a61f4f08d9f921203bedfc2dd9e53e4
上级 c70335c8
...@@ -37,6 +37,10 @@ LOCAL_INCLUDE := \ ...@@ -37,6 +37,10 @@ LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/fs/jffs2/include \ -I $(LITEOSTOPDIR)/fs/jffs2/include \
-I $(LITEOSTOPDIR)/../../device/hisilicon/drivers/include/mtd/common/include -I $(LITEOSTOPDIR)/../../device/hisilicon/drivers/include/mtd/common/include
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/arm_virt/config/cfiflash
endif
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS) LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE) include $(MODULE)
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
#include "mtd_common.h" #include "mtd_common.h"
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
#include "cfiflash.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
extern "C" { extern "C" {
...@@ -141,10 +145,9 @@ static VOID MtdNorParamAssign(partition_param *spinorParam, const struct MtdDev ...@@ -141,10 +145,9 @@ static VOID MtdNorParamAssign(partition_param *spinorParam, const struct MtdDev
spinorParam->blockname = SPIBLK_NAME; spinorParam->blockname = SPIBLK_NAME;
spinorParam->charname = SPICHR_NAME; spinorParam->charname = SPICHR_NAME;
#else #else
extern struct block_operations *GetCfiBlkOps(void);
spinorParam->flash_ops = GetCfiBlkOps(); spinorParam->flash_ops = GetCfiBlkOps();
spinorParam->char_ops = NULL; spinorParam->char_ops = NULL;
spinorParam->blockname = "/dev/cfiflash"; spinorParam->blockname = CFI_DRIVER;
spinorParam->charname = NULL; spinorParam->charname = NULL;
#endif #endif
spinorParam->partition_head = g_spinorPartitionHead; spinorParam->partition_head = g_spinorPartitionHead;
...@@ -163,7 +166,6 @@ static partition_param *MtdInitSpinorParam(partition_param *spinorParam) ...@@ -163,7 +166,6 @@ static partition_param *MtdInitSpinorParam(partition_param *spinorParam)
#ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 #ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
struct MtdDev *spinorMtd = GetMtd("spinor"); struct MtdDev *spinorMtd = GetMtd("spinor");
#else #else
extern struct MtdDev *GetCfiMtdDev(void);
struct MtdDev *spinorMtd = GetCfiMtdDev(); struct MtdDev *spinorMtd = GetCfiMtdDev();
#endif #endif
if (spinorMtd == NULL) { if (spinorMtd == NULL) {
......
...@@ -36,6 +36,10 @@ LOCAL_SRCS := $(wildcard los_rootfs.c) ...@@ -36,6 +36,10 @@ LOCAL_SRCS := $(wildcard los_rootfs.c)
LOCAL_INCLUDE := \ LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/common \ -I $(LITEOSTOPDIR)/kernel/common \
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/arm_virt/config/cfiflash
endif
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS) LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE) include $(MODULE)
......
...@@ -45,6 +45,13 @@ ...@@ -45,6 +45,13 @@
#include "mtd_list.h" #include "mtd_list.h"
#include "fs/path_cache.h" #include "fs/path_cache.h"
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
#include "mtd_partition.h"
#include "cfiflash.h"
#define DEV_STORAGE_PATH "/dev/cfiflash1"
#define SECOND_MTD_PART_NUM 1
#endif
#ifdef LOSCFG_STORAGE_SPINOR #ifdef LOSCFG_STORAGE_SPINOR
#define DEV_STORAGE_PATH "/dev/spinorblk2" #define DEV_STORAGE_PATH "/dev/spinorblk2"
#define SECOND_MTD_PART_NUM 2 #define SECOND_MTD_PART_NUM 2
...@@ -189,19 +196,21 @@ STATIC const CHAR *GetDevName(const CHAR *rootType, INT32 rootAddr, INT32 rootSi ...@@ -189,19 +196,21 @@ STATIC const CHAR *GetDevName(const CHAR *rootType, INT32 rootAddr, INT32 rootSi
#endif #endif
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 #ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
#define CFIFLASH_CAPACITY 64 * 1024 * 1024 if (strcmp(rootType, FLASH_TYPE) == 0) {
if (strcmp(rootType, "cfi-flash") == 0) {
INT32 ret; INT32 ret;
extern INT32 add_mtd_partition(const CHAR *type, UINT32 startAddr, UINT32 length, UINT32 partitionNum); if (rootAddr != CFIFLASH_ROOT_ADDR) {
ret = add_mtd_partition("cfi-flash", rootAddr, rootSize, 0); PRINT_ERR("Error rootAddr, must be %#0x!\n", CFIFLASH_ROOT_ADDR);
return NULL;
}
ret = add_mtd_partition(FLASH_TYPE, rootAddr, rootSize, 0);
if (ret != LOS_OK) { if (ret != LOS_OK) {
PRINT_ERR("Failed to add cfi-flash root partition!\n"); PRINT_ERR("Failed to add %s root partition!\n", FLASH_TYPE);
} else { } else {
rootDev = "/dev/cfiflash0"; rootDev = "/dev/cfiflash0";
ret = add_mtd_partition("cfi-flash", (rootAddr + rootSize), ret = add_mtd_partition(FLASH_TYPE, (rootAddr + rootSize),
CFIFLASH_CAPACITY - rootAddr - rootSize, 1); CFIFLASH_CAPACITY - rootAddr - rootSize, SECOND_MTD_PART_NUM);
if (ret != LOS_OK) { if (ret != LOS_OK) {
PRINT_ERR("Failed to add cfi-flash storage partition!\n"); PRINT_ERR("Failed to add %s storage partition!\n", FLASH_TYPE);
} }
} }
} else } else
...@@ -262,13 +271,17 @@ STATIC INT32 GetArgs(CHAR **args) ...@@ -262,13 +271,17 @@ STATIC INT32 GetArgs(CHAR **args)
} }
#endif #endif
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 #ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
/* struct MtdDev *mtd = GetCfiMtdDev();
* TODO: Implement method of fetching bootargs for if (mtd == NULL) {
* Qemu ARM virtual platform. If used without PRINT_ERR("Get CFI mtd failed!\n");
* bootloader it will pass DTB by default. goto ERROUT;
*/ }
(void)ret; g_alignSize = mtd->eraseSize;
cmdLine = "bootargs=root=cfi-flash fstype=jffs2 rootaddr=0xA00000 rootsize=27M"; ret = mtd->read(mtd, CFIFLASH_BOOTARGS_ADDR, COMMAND_LINE_SIZE, cmdLine);
if (ret != COMMAND_LINE_SIZE) {
PRINT_ERR("Read CFI command line failed!\n");
goto ERROUT;
}
#endif #endif
for (i = 0; i < COMMAND_LINE_SIZE; i += len + 1) { for (i = 0; i < COMMAND_LINE_SIZE; i += len + 1) {
...@@ -493,7 +506,7 @@ STATIC INT32 OsMountRootfsAndUserfs(const CHAR *rootDev, const CHAR *fsType) ...@@ -493,7 +506,7 @@ STATIC INT32 OsMountRootfsAndUserfs(const CHAR *rootDev, const CHAR *fsType)
PRINT_ERR("Failed to mount rootfs,rootDev %s, errno %d: %s\n", rootDev, err, strerror(err)); PRINT_ERR("Failed to mount rootfs,rootDev %s, errno %d: %s\n", rootDev, err, strerror(err));
return ret; return ret;
} }
#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) #if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
ret = mkdir("/storage", DEFAULT_STORAGE_MOUNT_DIR_MODE); ret = mkdir("/storage", DEFAULT_STORAGE_MOUNT_DIR_MODE);
if ((ret != LOS_OK) && ((err = get_errno()) != EEXIST)) { if ((ret != LOS_OK) && ((err = get_errno()) != EEXIST)) {
PRINT_ERR("Failed to reserve vnode /storage, errno %d: %s\n", err, strerror(err)); PRINT_ERR("Failed to reserve vnode /storage, errno %d: %s\n", err, strerror(err));
...@@ -504,19 +517,6 @@ STATIC INT32 OsMountRootfsAndUserfs(const CHAR *rootDev, const CHAR *fsType) ...@@ -504,19 +517,6 @@ STATIC INT32 OsMountRootfsAndUserfs(const CHAR *rootDev, const CHAR *fsType)
PRINT_ERR("Failed to mount /storage, errno %d: %s\n", err, strerror(err)); PRINT_ERR("Failed to mount /storage, errno %d: %s\n", err, strerror(err));
} }
} }
#endif
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
ret = mkdir("/storage", DEFAULT_STORAGE_MOUNT_DIR_MODE);
if (ret != LOS_OK) {
err = get_errno();
PRINT_ERR("Failed to reserve inode /storage, errno %d: %s\n", err, strerror(err));
} else {
ret = mount("/dev/cfiflash1", "/storage", fsType, 0, NULL);
if (ret != LOS_OK) {
err = get_errno();
PRINT_ERR("Failed to mount /storage, errno %d: %s\n", err, strerror(err));
}
}
#endif #endif
} }
return LOS_OK; return LOS_OK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册