Browse Source

fix driver install

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 2 weeks ago
parent
commit
7315652fb2
  1. 2
      Makefile
  2. 20
      bspStubs.c
  3. 2
      config.h
  4. 50
      vxbLfsLib.c
  5. 105
      vxbSm2130SpiDev.c
  6. 6
      vxbSm2130SpiDev.h

2
Makefile

@ -21,7 +21,7 @@ MACH_EXTRA += vxbArmGenIntCtlrV3.o vxbArmv7GenTimer.o vxbArmv7AuxTimer.o
vxbFtPcie.o vxbAhciStorage.o vxbFtGmacEnd.o vxbFtcan.o vxbPci.o \
vxbFtSdCtrl.o vxbFtI2c.o vxbYt8521Phy.o genericPhy.o vxbFtQspi.o\
vxbSp25SpiFlash.o vxbFtGpio.o vxbFtSpi.o vxbSm2130SpiDev.o \
usrStubs.o vxbLfsLib.o
bspStubs.o vxbLfsLib.o
ifneq ($(findstring bootrom,$(MAKECMDGOALS)),bootrom)
LIB_EXTRA = lib/libFtX100dcdrv.a

20
usrStubs.c → bspStubs.c

@ -12,24 +12,32 @@
#include <ipcom_sock.h>
#include <ipftps.h>
int usr_ipftps_authenticate_nopasswd(Ipftps_session *session, char *password)
int bsp_ipftps_authenticate_nopasswd(Ipftps_session *session, char *password)
{
printf("ftp passthor\r\n");
//printf("ftp passthor\r\n");
return 0;
}
#endif
#define VXWORKS_POS (0x400000)
#define USER_APP_PATH "/tffs0/UserApp.out"
int lfsLowRawWrite(unsigned long offset, const char *buffer, int size);
int loadUserApp()
int bspLoadUserApp()
{
SEGMENT_ID seg;
SYMBOL_DESC symDesc;
MODULE_ID module = ld(1, 0, "/tffs0/UserApp.out");
struct stat stbuf;
MODULE_ID module = ld(1, 0, USER_APP_PATH);
void (*appEntry)(void) = NULL;
if (stat(USER_APP_PATH, &stbuf) != 0) {
return -1;
}
(void)stbuf;
module = ld(1, 0, USER_APP_PATH);
if (module != NULL) {
/* flush text segment */
seg = moduleSegFirst(module);
@ -57,7 +65,7 @@ int loadUserApp()
#if defined(__DCC__)
void usrAppInit(void)
{
loadUserApp();
bspLoadUserApp();
}
#endif

2
config.h

@ -55,7 +55,7 @@ extern "C" {
/* ftpd */
/* #define INCLUDE_IPFTPS */
#define FTPS_AUTH_CALLBACK_HOOK usr_ipftps_authenticate_nopasswd
#define FTPS_AUTH_CALLBACK_HOOK bsp_ipftps_authenticate_nopasswd
#define TFFS_FLASH_MOUNT_POINTOT "/tffs0"
/* ARM PrimeCell SIO for VxBus */

50
vxbLfsLib.c

@ -60,8 +60,6 @@ struct __lfs_drv_ctrl {
UINT32 blkNum;
int lfsDrvNum;
lfsIosDrv lfsDrv;
FLASH_CHIP_ID mtd;
@ -71,6 +69,8 @@ struct __lfs_drv_ctrl {
lfs_t fsh;
};
LOCAL int __lfs_driver_node = -1;
/* {{{ lfsDevFuncs */
LOCAL void lfsDevInstInit(VXB_DEVICE_ID pDev)
{
@ -128,13 +128,6 @@ err:
pDev->pDrvCtrl = NULL;
}
LOCAL void lfsDevInstInit2(VXB_DEVICE_ID pDev)
{
lfsDrvCtrl *pDrvCtrl = (lfsDrvCtrl *)pDev->pDrvCtrl;
pDrvCtrl->lock = semBCreate(SEM_Q_FIFO, SEM_FULL);
}
/* {{{ lfs handler */
LOCAL LFS_FILE_DESC *lfsFuncOpen(lfsIosDrv *dev, const char *name, int flags, int mode)
{
@ -279,7 +272,7 @@ LOCAL int lfsFuncIoctl(LFS_FILE_DESC *pfd, int cmd, _Vx_ioctl_arg_t arg)
break;
}
dirp->dd_eof = FALSE;
dirp->dd_dirent.d_ino = pDrvCtrl->lfsDrvNum;
dirp->dd_dirent.d_ino = __lfs_driver_node;
strncpy(dirp->dd_dirent.d_name, info.name, _PARM_NAME_MAX + 1);
dirp->dd_dirent.d_name[_PARM_NAME_MAX - 1] = EOS;
break;
@ -442,6 +435,13 @@ LOCAL void lfsCfgInit(lfsDrvCtrl *drv, FLASH_CHIP_ID flash)
}
/* }}} */
LOCAL void lfsDevInstInit2(VXB_DEVICE_ID pDev)
{
lfsDrvCtrl *pDrvCtrl = (lfsDrvCtrl *)pDev->pDrvCtrl;
pDrvCtrl->lock = semBCreate(SEM_Q_FIFO, SEM_FULL);
}
LOCAL void lfsDevInstConnect(VXB_DEVICE_ID pDev)
{
lfsDrvCtrl *pDrvCtrl;
@ -450,6 +450,20 @@ LOCAL void lfsDevInstConnect(VXB_DEVICE_ID pDev)
pDrvCtrl = (lfsDrvCtrl *)pDev->pDrvCtrl;
if (__lfs_driver_node < 0) {
/* clang-format off */
__lfs_driver_node = iosDrvInstall(
(DRV_CREATE_PTR) lfsFuncOpen,
(DRV_REMOVE_PTR) lfsFuncRemove,
(DRV_OPEN_PTR) lfsFuncOpen,
(DRV_CLOSE_PTR) lfsFuncClose,
(DRV_READ_PTR) lfsFuncRead,
(DRV_WRITE_PTR) lfsFuncWrite,
(DRV_IOCTL_PTR) lfsFuncIoctl
);
/* clang-format on */
}
pFlashDev = vxbInstByNameFind((char *)pDrvCtrl->flashDrvName, pDrvCtrl->flashUnit);
if (!pFlashDev) {
return;
@ -462,20 +476,8 @@ LOCAL void lfsDevInstConnect(VXB_DEVICE_ID pDev)
pDrvCtrl->flashSize = pDrvCtrl->mtd->uChipSize - pDrvCtrl->flashOffset;
}
pDrvCtrl->blkNum = pDrvCtrl->flashSize / pDrvCtrl->mtd->uEraseSize;
/* clang-format off */
pDrvCtrl->lfsDrvNum = iosDrvInstall(
(DRV_CREATE_PTR) lfsFuncOpen,
(DRV_REMOVE_PTR) lfsFuncRemove,
(DRV_OPEN_PTR) lfsFuncOpen,
(DRV_CLOSE_PTR) lfsFuncClose,
(DRV_READ_PTR) lfsFuncRead,
(DRV_WRITE_PTR) lfsFuncWrite,
(DRV_IOCTL_PTR) lfsFuncIoctl
);
/* clang-format on */
if (pDrvCtrl->lfsDrvNum > 0) {
if (iosDevAdd(&pDrvCtrl->lfsDrv.devHdr, pDrvCtrl->mountPoint, pDrvCtrl->lfsDrvNum) == OK) {
if (__lfs_driver_node > 0) {
if (iosDevAdd(&pDrvCtrl->lfsDrv.devHdr, pDrvCtrl->mountPoint, __lfs_driver_node) == OK) {
pDrvCtrl->lfsDrv.pDrvCtrl = pDrvCtrl;
lfsCfgInit(pDrvCtrl, pDrvCtrl->mtd);
} else {

105
vxbSm2130SpiDev.c

@ -31,6 +31,8 @@ typedef struct _Sm2310_DEV_HANDLE {
SM2130_SPI_DEV *pDevCtrl;
} SM2310_DEV_HANDLE;
LOCAL int sm2130_driver_node = -1;
/* locals */
LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose);
LOCAL INT32 sm2130BusDevRead(VXB_DEVICE_ID pDev, UINT8 cmd);
@ -53,9 +55,9 @@ LOCAL struct drvBusFuncs sm2130SpiDevFuncs = {
/* Publish the methods for the resources controlled with this file */
/* clang-format off */
LOCAL struct vxbDeviceMethod sm2130SpiDevMethods[] = {
DEVMETHOD(busDevShow , sm2130SpiDevShow),
DEVMETHOD(vxbDrvUnlink, sm2130SpiDevInstUnlink),
{ 0, 0 }
DEVMETHOD(busDevShow , sm2130SpiDevShow),
DEVMETHOD(vxbDrvUnlink, sm2130SpiDevInstUnlink),
{ 0, 0 }
};
LOCAL struct vxbSpiRegister sm2130SpiDevRegister = {
@ -114,13 +116,14 @@ LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev)
pDrvCtrl->pDev = pDev;
pDev->pDrvCtrl = pDrvCtrl;
pDrvCtrl->drvNode = -1;
pDrvCtrl->devHandle = NULL;
pDrvCtrl->devName = SM2310_DEV_NAME;
snprintf(pDrvCtrl->name, sizeof (pDrvCtrl->name), "%s/%d", SM2130_DEV_NAME, pDev->unitNumber);
pDrvCtrl->devName = pDrvCtrl->name;
pHcf = (struct hcfDevice *)hcfDeviceGet(pDev);
if (pHcf) {
if (devResourceGet(pHcf, "devName", HCF_RES_STRING, (void *)&pDrvCtrl->devName) != OK) {
pDrvCtrl->devName = SM2310_DEV_NAME;
pDrvCtrl->devName = pDrvCtrl->name;
}
}
@ -130,35 +133,6 @@ LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev)
vxbNextUnitGet(pDev);
}
/*
*
* sm2130SpiDevInstInit2 - first level initialization routine of spi flash device
*
*
* RETURNS: N/A
*
* ERRNO: N/A
*/
LOCAL void sm2130SpiDevInstInit2(VXB_DEVICE_ID pDev)
{
SM2130_SPI_DEV *pDrvCtrl;
FUNCPTR pFunc;
/* Check for vaild parameter */
VXB_ASSERT_NONNULL_V(pDev);
pDrvCtrl = (SM2130_SPI_DEV *)pDev->pDrvCtrl;
/* Mutex semaphore is initialized and necessary at this point */
pDrvCtrl->muteSem = semMCreate(SPI_DEV_MUTEX_OPT);
pFunc = vxbDevMethodGet(vxbDevParent(pDev), (VXB_METHOD_ID)vxbSpiSpecialGet_desc);
/* Retrieve the SPI master special information */
if (pFunc != NULL)
(*pFunc)(vxbDevParent(pDev), &pDrvCtrl->specialInfo);
}
/* {{{ device driver api */
LOCAL SM2310_DEV_HANDLE *drv1553bOpen(SM2310_DEV_HANDLE *dev, const char *name, int flags, int mode)
{
@ -219,6 +193,35 @@ LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg)
}
/* }}} */
/*
*
* sm2130SpiDevInstInit2 - first level initialization routine of spi flash device
*
*
* RETURNS: N/A
*
* ERRNO: N/A
*/
LOCAL void sm2130SpiDevInstInit2(VXB_DEVICE_ID pDev)
{
SM2130_SPI_DEV *pDrvCtrl;
FUNCPTR pFunc;
/* Check for vaild parameter */
VXB_ASSERT_NONNULL_V(pDev);
pDrvCtrl = (SM2130_SPI_DEV *)pDev->pDrvCtrl;
/* Mutex semaphore is initialized and necessary at this point */
pDrvCtrl->muteSem = semMCreate(SPI_DEV_MUTEX_OPT);
pFunc = vxbDevMethodGet(vxbDevParent(pDev), (VXB_METHOD_ID)vxbSpiSpecialGet_desc);
/* Retrieve the SPI master special information */
if (pFunc != NULL)
(*pFunc)(vxbDevParent(pDev), &pDrvCtrl->specialInfo);
}
/*
* sm2130SpiDevInstConnect - third level initialization routine of spi flash
*
@ -238,10 +241,9 @@ LOCAL void sm2130SpiDevInstConnect(VXB_DEVICE_ID pDev)
pDrvCtrl = (SM2130_SPI_DEV *)pDev->pDrvCtrl;
(void)semTake(pDrvCtrl->muteSem, WAIT_FOREVER);
if (pDrvCtrl->drvNode < 0) {
if (sm2130_driver_node < 0) {
/* clang-format off */
pDrvCtrl->drvNode = iosDrvInstall(
sm2130_driver_node = iosDrvInstall(
(DRV_CREATE_PTR)drv1553bOpen ,
(DRV_REMOVE_PTR)NULL ,
(DRV_OPEN_PTR)drv1553bOpen ,
@ -250,23 +252,25 @@ LOCAL void sm2130SpiDevInstConnect(VXB_DEVICE_ID pDev)
(DRV_WRITE_PTR)NULL ,
(DRV_IOCTL_PTR)drv1553bIoctl);
/* clang-format on */
if (pDrvCtrl->drvNode > 0) {
dev = (SM2310_DEV_HANDLE *)hwMemAlloc(sizeof(SM2310_DEV_HANDLE));
if (dev) {
pDrvCtrl->refcount = 0;
selWakeupListInit(&dev->selList);
if (iosDevAdd(&dev->devHdr, pDrvCtrl->devName, pDrvCtrl->drvNode) == OK) {
pDrvCtrl->devHandle = dev;
dev->pDevCtrl = pDrvCtrl;
} else {
}
semTake(pDrvCtrl->muteSem, WAIT_FOREVER);
if (sm2130_driver_node > 0) {
dev = (SM2310_DEV_HANDLE *)hwMemAlloc(sizeof(SM2310_DEV_HANDLE));
if (dev) {
pDrvCtrl->refcount = 0;
selWakeupListInit(&dev->selList);
if (iosDevAdd(&dev->devHdr, pDrvCtrl->devName, sm2130_driver_node) == OK) {
pDrvCtrl->devHandle = dev;
dev->pDevCtrl = pDrvCtrl;
} else {
#ifndef _VXBUS_BASIC_HWMEMLIB
hwMemFree((char *)dev);
hwMemFree((char *)dev);
#endif /* _VXBUS_BASIC_HWMEMLIB */
}
}
}
}
(void)semGive(pDrvCtrl->muteSem);
semGive(pDrvCtrl->muteSem);
}
/*
@ -325,7 +329,6 @@ LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose)
printf(" speed: %u\n", pDrvCtrl->freq);
printf(" devName: %s\n", pDrvCtrl->devName);
printf(" devHandle: %p\n", pDrvCtrl->devHandle);
printf(" drvNode: %d\n", pDrvCtrl->drvNode);
printf(" refCount: %d\n", pDrvCtrl->refcount);
}

6
vxbSm2130SpiDev.h

@ -3,7 +3,9 @@
#define SPI_DEV_SM2130 "SM2130"
#define SM2310_DEV_NAME "/sm2130"
#define SM2130_DEV_NAME "/sm2130"
#define __SM2130__IOC_MAGIC ('S' << 16)
#define FIO_WR (1)
#define FIO_RD (2)
@ -22,13 +24,13 @@ typedef struct _spi_1553b_drv_ctrl {
int cs;
int mode;
char name[16];
unsigned int freq;
const char *devName;
int refcount;
int drvNode;
void *devHandle;
INT32 (*read)(VXB_DEVICE_ID pDev, UINT8 cmd);

Loading…
Cancel
Save