Browse Source

add loadUserApp()

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 2 weeks ago
parent
commit
c67c890ea3
  1. 1
      20bsp.cdf
  2. 1
      config.h
  3. 13
      sysLib.c
  4. 36
      usrStubs.c
  5. 16
      vxbLfsLib.c

1
20bsp.cdf

@ -15,6 +15,7 @@ Bsp ft20004_km02 {
ENDIAN little ENDIAN little
MP_OPTIONS SMP MP_OPTIONS SMP
REQUIRES INCLUDE_KERNEL \ REQUIRES INCLUDE_KERNEL \
INCLUDE_LOADER \
DRV_ARM_GEN_SYS_TIMER \ DRV_ARM_GEN_SYS_TIMER \
DRV_ARM_GICV3 \ DRV_ARM_GICV3 \
INCLUDE_IPFTPS \ INCLUDE_IPFTPS \

1
config.h

@ -292,6 +292,7 @@ extern "C" {
#define INCLUDE_ISR_OBJECTS #define INCLUDE_ISR_OBJECTS
#define USER_APPL_INIT (loadUserApp())
#ifdef __cplusplus #ifdef __cplusplus
} }

13
sysLib.c

@ -408,7 +408,18 @@ LOCAL void armGenGetFreq(void)
_WRS_ASM("MRC p15, 0, %0, c14, c0, 0" : "=r"(genTimerFreq)); _WRS_ASM("MRC p15, 0, %0, c14, c0, 0" : "=r"(genTimerFreq));
} }
#else #else
__asm volatile UINT32 __inline__GetCntFreq(void){ !"r0" mrc p15, 0, r0, c14, c0, 0 } /* clang-format off */
__asm volatile UINT32 __macro__GetCntFreq (void)
{
! "r0"
mrc p15, 0, r0, c14, c0, 0
}
LOCAL UINT32 __inline__GetCntFreq (void)
{
return __macro__GetCntFreq();
}
/* clang-format on */
LOCAL UINT32 armGenGetFreq(void) LOCAL UINT32 armGenGetFreq(void)
{ {

36
usrStubs.c

@ -1,6 +1,10 @@
#include <vxWorks.h> #include <vxWorks.h>
#include <vsbConfig.h> #include <vsbConfig.h>
#include <stdio.h> #include <stdio.h>
#include <moduleLib.h>
#include <usrLib.h>
#include <cacheLib.h>
#include <sysSymTbl.h>
#include "config.h" #include "config.h"
#if defined(INCLUDE_IPFTPS) #if defined(INCLUDE_IPFTPS)
#include <ipcom_sysvar.h> #include <ipcom_sysvar.h>
@ -15,10 +19,40 @@ int usr_ipftps_authenticate_nopasswd(Ipftps_session *session, char *password)
#endif #endif
int loadUserApp()
{
SEGMENT_ID seg;
SYMBOL_DESC symDesc;
MODULE_ID module = ld(1, 0, "/tffs0/UserApp.out");
void (*appEntry)(void) = NULL;
if (module != NULL) {
/* flush text segment */
seg = moduleSegFirst(module);
while (seg) {
if (seg->type == SEGMENT_TEXT) {
/* printf("flush: %p, size: 0x%x\r\n", seg->address, seg->size); */
cacheFlush(DATA_CACHE, seg->address, seg->size);
}
seg = moduleSegNext(seg);
}
memset(&symDesc, 0, sizeof symDesc);
symDesc.mask = SYM_FIND_BY_NAME;
symDesc.name = "AppEntry";
if (symFind(sysSymTbl, &symDesc) == OK) {
appEntry = (void (*)(void))(symDesc.value);
printf("AppEntry: %p\r\n", appEntry);
appEntry();
}
}
return 0;
}
#if defined(__DCC__) #if defined(__DCC__)
void usrAppInit(void) void usrAppInit(void)
{ {
printf("appInited\r\n"); loadUserApp();
} }
#endif #endif

16
vxbLfsLib.c

@ -245,6 +245,7 @@ LOCAL int lfsFuncIoctl(LFS_FILE_DESC *pfd, int cmd, _Vx_ioctl_arg_t arg)
int ret = OK; int ret = OK;
const char *name; const char *name;
DIR *dirp; DIR *dirp;
size_t offset;
struct lfs_info info; struct lfs_info info;
lfsDrvCtrl *pDrvCtrl = pfd->ctrl; lfsDrvCtrl *pDrvCtrl = pfd->ctrl;
@ -282,6 +283,15 @@ LOCAL int lfsFuncIoctl(LFS_FILE_DESC *pfd, int cmd, _Vx_ioctl_arg_t arg)
strncpy(dirp->dd_dirent.d_name, info.name, _PARM_NAME_MAX + 1); strncpy(dirp->dd_dirent.d_name, info.name, _PARM_NAME_MAX + 1);
dirp->dd_dirent.d_name[_PARM_NAME_MAX - 1] = EOS; dirp->dd_dirent.d_name[_PARM_NAME_MAX - 1] = EOS;
break; break;
case FIOSEEK:
if (pfd->isDir) {
errnoSet(EINVAL);
ret = ERROR;
break;
}
offset = (size_t)arg;
lfs_file_seek(&pDrvCtrl->fsh, &pfd->u.file, offset, LFS_SEEK_SET);
break;
case FIOUNLINK: case FIOUNLINK:
name = (const char *)arg; name = (const char *)arg;
ret = lfs_remove(&pDrvCtrl->fsh, name); ret = lfs_remove(&pDrvCtrl->fsh, name);
@ -290,8 +300,8 @@ LOCAL int lfsFuncIoctl(LFS_FILE_DESC *pfd, int cmd, _Vx_ioctl_arg_t arg)
ret = OK; ret = OK;
break; break;
default: default:
printf("unsupport ioctl: %d\n", cmd); printf("lfs unsupport ioctl: %d\n", cmd);
errnoSet(EINVAL); errnoSet(ENOTSUP);
ret = ERROR; ret = ERROR;
break; break;
} }
@ -355,7 +365,7 @@ LOCAL int lfsFlashProg(const struct lfs_config *cfg, lfs_block_t block, lfs_off_
lfsDrvCtrl *pDrvCtrl = cfg->context; lfsDrvCtrl *pDrvCtrl = cfg->context;
UINT8 *buffers[2]; UINT8 *buffers[2];
buffers[0] = buffer; buffers[0] = (void *)buffer;
buffers[1] = NULL; buffers[1] = NULL;
pos = pDrvCtrl->flashOffset + block * cfg->block_size + off; pos = pDrvCtrl->flashOffset + block * cfg->block_size + off;

Loading…
Cancel
Save