代码拉取完成,页面将自动刷新
/*
*Copyright (c) 2024 Black Sesame Technologies
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/msg.h>
#include <sys/systemlog.h>
// #include <devctl.h>
#include <hw/timer_server.h>
#include <resmsg.h>
#include <irq.h>
#include <of.h>
#include <semaphore.h>
#include <listservice.h>
#include <sys/mman.h>
#include <hw/timer_server.h>
#include "include/timer_function.h"
timer_dev_t *dev;
void timer_message_handler(dispatch_context_t* ctp)
{
while(1)
{
int32_t dispatchRet= 0;
dispatchRet = dispatch_handler (ctp);
if (dispatchRet != 1)
{
printf("timer dispatch_handler failed\r\n");
}
}
}
int main(int argc, char *argv[])
{
pthread_t ptd1;
pthread_attr_t a;
int32_t dispatchRet;
int32_t resmgr_id = -1;
dev = (timer_dev_t *)malloc(sizeof(timer_dev_t));
timer_sem_init();
/* get opts */
bst_timer_getfuncs(&dev->funcs,sizeof(dev->funcs));
dev->node_name = argv[0];
dev->drv_info.pbase = strtol( argv[1], NULL, 16);
/* init first D list node */
dlist_init(drv_info_list);
/* creat default timer node */
for(int i=0; i<((sizeof(timer_node_map))/sizeof(timer_node_map_t));i++)
{
if (0 == strcmp(dev->node_name, (char *)timer_node_map[i].node_name))
{
strcpy(dev->name, timer_node_map[i].port_name);
dev->drv_info.channel = timer_node_map[i].channel;
dev->drv_info.intr_num = timer_node_map[i].irq;
break;
}
}
// dev->drv_info.mode = TIMERS_MODE_USER;
dev->dpp = dispatch_create();
(void)memset( &dev->resmgr_attr, 0, sizeof(dev->resmgr_attr));
dev->resmgr_attr.process_priority = 55;
dev->resmgr_attr.process_thread_num = 1;
dev->ioFunc.devctl = (void *)timer_server_io_devctl;
iofunc_func_init( _RESMGR_CONNECT_NFUNCS, &dev->connectFunc, _RESMGR_IO_NFUNCS, &dev->ioFunc);
/* set resource manager parameter*/
dispatchRet = 0;
dev->ctp = dispatch_context_alloc(dev->dpp);
/* establish a name in the pathname space */
resmgr_id = resmgr_attach( dev->dpp,
&dev->resmgr_attr,
dev->name,
_FTYPE_ANY,
0,
&dev->connectFunc,
&dev->ioFunc,
NULL);
dev->ctp->resmgr_context.id = resmgr_id;
Timer_attach(dev);
/* load dts message */
timer_dts_process(dev);
/* mmap vbase */
timer_mmap(dev);
dev->iid = InterruptAttach(dev->drv_info.intr_num, (void *)timer_intr_handler, dev, 0, 0);
dev->funcs.init(&dev->drv_info);
dev->funcs.timer_disable(&dev->drv_info);
pthread_attr_init(&a);
pthread_attr_setstacksize(&a, 4096*10);
struct sched_param s_param = {.sched_priority = 50 };
pthread_attr_setschedparam(&a, &s_param);
pthread_create(&ptd1, &a, (void *)timer_message_handler, dev->ctp);
pthread_detach(ptd1);
dm_startup(dev->name);
while(1)
{
usleep(100000);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。