共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年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
分享汽车通信和多媒体总线结构被打赏20分 | |
【我踩过的那些坑】结构堵孔导致的喇叭无声问题被打赏50分 | |
NUCLEO-U083RC学习历程38+串口通过队列的方式输出两个字符串被打赏20分 | |
【我踩过的那些坑】分享一下调试一款AD芯片的遇到的“坑”被打赏50分 | |
电流检测模块MAX4080S被打赏10分 | |
【我踩过的那些坑】calloc和malloc错误使用导致跑飞问题排查被打赏50分 | |
分享电控悬架的结构与工作原理(一)被打赏20分 | |
多组DCTODC电源方案被打赏50分 | |
【我踩过的那些坑】STM32cubeMX软件的使用过程中的“坑”被打赏50分 | |
新手必看!C语言精华知识:表驱动法被打赏50分 |