共1条
1/1 1 跳转至页
psos下驱动程序的开发(老站转)

target
工程师
来自:
发表总数:16
查看 短消息 电子邮件 引用 回复
--------------------------------------------------------------------------------
向pSOS+ I/O设备驱动表里加载驱动程序须编辑工作路径下的drv_conf.c这个文件.该文件包含一个SetUpDrivers ()函数的调用. SetUpDrivers ()函数的调用InstallDrivers()向I/O表里添加设备驱动程序.在SetUpDrivers ()函数里增加InstallDrivers()可以实现设备驱动程序的添加工作.函数原形如下所示:
SetUpDrivers: installs drivers in PsosIO table via a call to InstallDriver and then calls driver setup function if needed. NOTE: If the driver is to be part of the Network Interface then it should be placed in the SetUpNI function.
1.UCHAR *SetUpDrivers(UCHAR *FreeMemPtr)
INPUT: FreeMemPtr = A pointer to unused memory that can be used to allocate space for a driver.
NOTE: Be sure to advance FreeMemPtr if memory is allocates!
RETURNS: The new address of free memory after the drivers have allocated space.
NOTE: This function does many precompile checks so errors can be found during compile-time rather then at run- time.
2. InstallDriver( unsigned short major_number , /* device major number */
void (*dev_init)( ), /* device init procedure */
void (*dev_open)( ), /* device open procedure */
void (*dev_close)( ), /* device close procedure */
void (*dev_read)( ), /* device read procedure */
void (*dev_write)( ), /* device write procedure */
void (*dev_ioctl)( ), /* device control procedure */
unsigned long rsvd1, /* reserved it should be zero
unsigned short rsvd2,
unsigned short flags, /* flags =IO_AUTOINIT */
)
NOTE: If set to IO_AUTOINIT pSOS will automatically call the drivers initialization function. The SC_AUTOINIT #define which is set in sys_conf.h can be used to set this element.
InstallDriver() does not return a value. InstallDriver() assumes SC_DEVMAX is defined in sys_conf.h and is useful only before pSOS+ has been initialized.
If you are adding a driver that needs to be initialized before either pSOS+ is initialized or the driver's init function is called, then you can call a setup function (that you create) for the driver (for example, see the CnslSetup call for the serial device driver). If your initialization function needs to allocate memory, you may pass it the FreeMemPtr. The function should return a new FreeMemPtr which points to the end of the memory it has allocated.
/*
#if (defined(BSP_NEW_SERIAL) && !(BSP_NEW_SERIAL) && (BSP_SERIAL))
extern UCHAR *CnslSetup(UCHAR *FreeMem, ULONG defbaud, USHORT defcons);
#endif
*/
When adding code to install a new driver, it is a good idea to add precompile checks so errors can be found during compile-time rather then at run-time. Precompile checks are used, for example, in the code that installs the pSOSystem serial device driver below.
网络接口的增加与增加PSOS设备驱动程序基本相同.drv_conf.h包含SetUpNi( )函数的调用,该函数调用InstallNi( )在PNA+ 最初的接口表里加载每一个网络接口.函数原形如图所示:
UCHAR *SetUpNI(UCHAR *FreeMemPtr)
SetUpNI: Set up Network Interfaces for pNA+
INPUT: FreeMemPtr = A pointer to unused memory that can be used to allocate space for a driver. NOTE: Be sure to advance FreeMemPtr if memory is allocates!
RETURNS: The new address of free memory after the drivers have allocated space.
NOTES: This function does many precompile checks so errors can be found during compile-time rather then at run- time. Also, the Network Interface Table must be allocated before this function can be called. There cannot be more then NC_NNI entries in this table. NC_NNI is set in sys_conf.h. Before adding another interface, be sure to check sys_conf.h to see if NC_NNI is set to accommodate another one! See the pSOSystem Programmers Reference Manualfor more information. To add a Network driver to pSOSystem, call InstallNi(). This adds the Network Interface to the pNA+ Network Interface Table. */
InstallNi(
int (*entry)(), /* address of NI entry point */
int ipadd, /* IP address */
int mtu, /* maximum transmission length */
int hwalen, /* length of hardware address */
int flags, /* intErface flags */
int subnetaddr, /*subnet mask */
int dstipaddr /*destination ip address */
)
See pSOSystem Programmer`s Reference Manual, Configuration Tables Section, for more information about the Network Interface Table. InstallNi() does not return a value.
If you are adding a driver that needs to be initialized before either pSOS+ is initialized or the driver's init function is called, then you can call a setup function (that you create) for the driver (for example, see the CnslSetup call for the serial device driver). If your initialization function needs to allocate memory, you may pass it the FreeMemPtr. The function should return a new FreeMemPtr which points to the end of the memory it has allocated.
When adding code to install a new driver, it is a good idea to add precompile checks so errors can be found during compile-time rather then at run-time. Precompile checks are used, for example, in the code that installs the pSOSystem serial device driver below.
关键词: 驱动程序 开发 老站转 driver functi
共1条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【EEPW电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 |