本文整理汇总了C++中rtdm_lock_get_irqsave函数的典型用法代码示例。如果您正苦于以下问题:C++ rtdm_lock_get_irqsave函数的具体用法?C++ rtdm_lock_get_irqsave怎么用?C++ rtdm_lock_get_irqsave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtdm_lock_get_irqsave函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_slot_job
static void do_slot_job(struct tdma_priv *tdma, struct tdma_slot *job,
rtdm_lockctx_t lockctx)
{
struct rtskb *rtskb;
if ((job->period != 1) &&
(tdma->current_cycle % job->period != job->phasing))
return;
rtdm_lock_put_irqrestore(&tdma->lock, lockctx);
/* wait for slot begin, then send one pending packet */
rtdm_task_sleep_abs(tdma->current_cycle_start + SLOT_JOB(job)->offset,
RTDM_TIMERMODE_REALTIME);
rtdm_lock_get_irqsave(&tdma->lock, lockctx);
rtskb = __rtskb_prio_dequeue(SLOT_JOB(job)->queue);
if (!rtskb)
return;
rtdm_lock_put_irqrestore(&tdma->lock, lockctx);
rtmac_xmit(rtskb);
rtdm_lock_get_irqsave(&tdma->lock, lockctx);
}
示例2: rt_loopback_xmit
/***
* rt_loopback_xmit - begin packet transmission
* @skb: packet to be sent
* @dev: network device to which packet is sent
*
*/
static int rt_loopback_xmit(struct rtskb *skb, struct rtnet_device *rtdev)
{
unsigned short hash;
struct rtpacket_type *pt_entry;
rtdm_lockctx_t context;
/* write transmission stamp - in case any protocol ever gets the idea to
ask the lookback device for this service... */
if (skb->xmit_stamp)
*skb->xmit_stamp = cpu_to_be64(rtdm_clock_read() + *skb->xmit_stamp);
/* make sure that critical fields are re-intialised */
skb->chain_end = skb;
/* parse the Ethernet header as usual */
skb->protocol = rt_eth_type_trans(skb, rtdev);
skb->nh.raw = skb->data;
rtdev_reference(rtdev);
rtcap_report_incoming(skb);
hash = ntohs(skb->protocol) & RTPACKET_HASH_KEY_MASK;
rtdm_lock_get_irqsave(&rt_packets_lock, context);
list_for_each_entry(pt_entry, &rt_packets[hash], list_entry)
if (pt_entry->type == skb->protocol) {
pt_entry->refcount++;
rtdm_lock_put_irqrestore(&rt_packets_lock, context);
pt_entry->handler(skb, pt_entry);
rtdm_lock_get_irqsave(&rt_packets_lock, context);
pt_entry->refcount--;
rtdm_lock_put_irqrestore(&rt_packets_lock, context);
goto out;
}
rtdm_lock_put_irqrestore(&rt_packets_lock, context);
/* don't warn if running in promiscuous mode (RTcap...?) */
if ((rtdev->flags & IFF_PROMISC) == 0)
rtdm_printk("RTnet: unknown layer-3 protocol\n");
kfree_rtskb(skb);
out:
rtdev_dereference(rtdev);
return 0;
}
示例3: tdma_worker
void tdma_worker(void *arg)
{
struct tdma_priv *tdma = (struct tdma_priv *)arg;
struct tdma_job *job;
rtdm_lockctx_t lockctx;
rtdm_event_wait(&tdma->worker_wakeup);
rtdm_lock_get_irqsave(&tdma->lock, lockctx);
job = tdma->first_job;
while (!test_bit(TDMA_FLAG_SHUTDOWN, &tdma->flags)) {
job->ref_count++;
switch (job->id) {
case WAIT_ON_SYNC:
rtdm_lock_put_irqrestore(&tdma->lock, lockctx);
rtdm_event_wait(&tdma->sync_event);
rtdm_lock_get_irqsave(&tdma->lock, lockctx);
break;
case XMIT_REQ_CAL:
job = do_request_cal_job(tdma, REQUEST_CAL_JOB(job), lockctx);
break;
#ifdef CONFIG_RTNET_TDMA_MASTER
case XMIT_SYNC:
do_xmit_sync_job(tdma, lockctx);
break;
case BACKUP_SYNC:
do_backup_sync_job(tdma, lockctx);
break;
case XMIT_RPL_CAL:
job = do_reply_cal_job(tdma, REPLY_CAL_JOB(job), lockctx);
break;
#endif /* CONFIG_RTNET_TDMA_MASTER */
default:
do_slot_job(tdma, SLOT_JOB(job), lockctx);
break;
}
job->ref_count--;
job = tdma->current_job =
list_entry(job->entry.next, struct tdma_job, entry);
}
rtdm_lock_put_irqrestore(&tdma->lock, lockctx);
}
示例4: do_xmit_sync_job
static void do_xmit_sync_job(struct tdma_priv *tdma, rtdm_lockctx_t lockctx)
{
rtdm_lock_put_irqrestore(&tdma->lock, lockctx);
/* wait for beginning of next cycle, then send sync */
rtdm_task_sleep_abs(tdma->current_cycle_start + tdma->cycle_period,
RTDM_TIMERMODE_REALTIME);
rtdm_lock_get_irqsave(&tdma->lock, lockctx);
tdma->current_cycle++;
tdma->current_cycle_start += tdma->cycle_period;
rtdm_lock_put_irqrestore(&tdma->lock, lockctx);
tdma_xmit_sync_frame(tdma);
rtdm_lock_get_irqsave(&tdma->lock, lockctx);
}
示例5: tims_clock_ioctl
int tims_clock_ioctl(rtdm_user_info_t *user_info, unsigned int request,
void *arg)
{
rtdm_lockctx_t lock_ctx;
nanosecs_rel_t result = 0;
switch(clock_sync_mode) {
case SYNC_RTNET:
sync_dev_ctx->ops->ioctl_rt(sync_dev_ctx, NULL,
RTMAC_RTIOC_TIMEOFFSET, &result);
break;
case SYNC_CAN_SLAVE:
case SYNC_SER_SLAVE:
rtdm_lock_get_irqsave(&sync_lock, lock_ctx);
result = clock_offset;
rtdm_lock_put_irqrestore(&sync_lock, lock_ctx);
break;
}
result += sync_delay;
if (request == TIMS_RTIOC_GETTIME)
result += rtdm_clock_read();
return rtdm_safe_copy_to_user(user_info, arg, &result, sizeof(result));
}
示例6: cfgChnSet
static int32_t cfgChnSet(
struct rtdm_dev_context * ctx,
enum xspiChn chn) {
struct devCtx * devCtx;
rtdm_lockctx_t lockCtx;
LOG_DBG("CFG: set current channel to %d", chn);
if (!CFG_ARG_IS_VALID(chn, XSPI_CHN_0, XSPI_CHN_3)) {
return (-EINVAL);
}
if (FALSE == portChnIsOnline(ctx->device, chn)) {
return (-EIDRM);
}
devCtx = getDevCtx(
ctx);
rtdm_lock_get_irqsave(&devCtx->lock, lockCtx);
devCtx->cfg.chn = chn;
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (0);
}
示例7: rt_packet_rcv
/***
* rt_packet_rcv
*/
int rt_packet_rcv(struct rtskb *skb, struct rtpacket_type *pt)
{
struct rtsocket *sock = (struct rtsocket *)(((u8 *)pt) -
((u8 *)&((struct rtsocket *)0)->prot.packet));
int ifindex = sock->prot.packet.ifindex;
void (*callback_func)(struct rtdm_dev_context *, void *);
void *callback_arg;
rtdm_lockctx_t context;
if (((ifindex != 0) && (ifindex != skb->rtdev->ifindex)) ||
(rtskb_acquire(skb, &sock->skb_pool) != 0))
kfree_rtskb(skb);
else {
rtdev_reference(skb->rtdev);
rtskb_queue_tail(&sock->incoming, skb);
rtdm_sem_up(&sock->pending_sem);
rtdm_lock_get_irqsave(&sock->param_lock, context);
callback_func = sock->callback_func;
callback_arg = sock->callback_arg;
rtdm_lock_put_irqrestore(&sock->param_lock, context);
if (callback_func)
callback_func(rt_socket_context(sock), callback_arg);
}
return 0;
}
示例8: cfgChnTransferModeSet
static int32_t cfgChnTransferModeSet(
struct rtdm_dev_context * ctx,
enum xspiTransferMode transferMode) {
struct devCtx * devCtx;
rtdm_lockctx_t lockCtx;
LOG_DBG("CFG: set transfer mode to %d", transferMode);
if (!CFG_ARG_IS_VALID(transferMode, XSPI_TRANSFER_MODE_TX_AND_RX, XSPI_TRANSFER_MODE_TX_ONLY)) {
return (-EINVAL);
}
devCtx = getDevCtx(
ctx);
rtdm_lock_get_irqsave(&devCtx->lock, lockCtx);
if (XSPI_ACTIVITY_RUNNIG == devCtx->actvCnt) {
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (-EAGAIN);
}
devCtx->chn[devCtx->cfg.chn].cfg.transferMode = transferMode;
lldChnTransferModeSet(
ctx->device,
devCtx->cfg.chn,
(uint32_t)transferMode);
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (0);
}
示例9: cfgChnPinLayoutSet
static int32_t cfgChnPinLayoutSet(
struct rtdm_dev_context * ctx,
enum xspiPinLayout pinLayout) {
struct devCtx * devCtx;
rtdm_lockctx_t lockCtx;
LOG_DBG("CFG: set pin layout to %d", pinLayout);
if (!CFG_ARG_IS_VALID(pinLayout, XSPI_PIN_LAYOUT_TX_RX, XSPI_PIN_LAYOUT_RX_TX)) {
return (-EINVAL);
}
devCtx = getDevCtx(
ctx);
rtdm_lock_get_irqsave(&devCtx->lock, lockCtx);
if (XSPI_ACTIVITY_RUNNIG == devCtx->actvCnt) {
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (-EAGAIN);
}
devCtx->chn[devCtx->cfg.chn].cfg.pinLayout = pinLayout;
lldChnPinLayoutSet(
ctx->device,
devCtx->cfg.chn,
(uint32_t)pinLayout);
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (0);
}
示例10: rt_udp_close
/***
* rt_udp_close
*/
int rt_udp_close(struct rtdm_dev_context *sockctx,
rtdm_user_info_t *user_info)
{
struct rtsocket *sock = (struct rtsocket *)&sockctx->dev_private;
struct rtskb *del;
int port;
rtdm_lockctx_t context;
rtdm_lock_get_irqsave(&udp_socket_base_lock, context);
sock->prot.inet.state = TCP_CLOSE;
if (sock->prot.inet.reg_index >= 0) {
port = sock->prot.inet.reg_index;
clear_bit(port % 32, &port_bitmap[port / 32]);
free_ports++;
sock->prot.inet.reg_index = -1;
}
rtdm_lock_put_irqrestore(&udp_socket_base_lock, context);
/* cleanup already collected fragments */
rt_ip_frag_invalidate_socket(sock);
/* free packets in incoming queue */
while ((del = rtskb_dequeue(&sock->incoming)) != NULL)
kfree_rtskb(del);
return rt_socket_cleanup(sockctx);
}
示例11: cfgInitialDelaySet
static int32_t cfgInitialDelaySet(
struct rtdm_dev_context * ctx,
enum xspiInitialDelay delay) {
struct devCtx * devCtx;
rtdm_lockctx_t lockCtx;
LOG_DBG("CFG: set initial delay to %d", delay);
if (!CFG_ARG_IS_VALID(delay, XSPI_INITIAL_DELAY_0, XSPI_INITIAL_DELAY_32)) {
return (-EINVAL);
}
devCtx = getDevCtx(
ctx);
rtdm_lock_get_irqsave(&devCtx->lock, lockCtx);
if (XSPI_ACTIVITY_RUNNIG == devCtx->actvCnt) {
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (-EAGAIN);
}
devCtx->cfg.delay = delay;
lldInitialDelaySet(
ctx->device,
(uint32_t)delay);
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (0);
}
示例12: rt_ip_route_del_host
/***
* rt_ip_route_del_host - deletes specified host route
*/
int rt_ip_route_del_host(u32 addr, struct rtnet_device *rtdev)
{
rtdm_lockctx_t context;
struct host_route *rt;
struct host_route **last_ptr;
unsigned int key;
key = ntohl(addr) & HOST_HASH_KEY_MASK;
last_ptr = &host_hash_tbl[key];
rtdm_lock_get_irqsave(&host_table_lock, context);
rt = host_hash_tbl[key];
while (rt != NULL) {
if ((rt->dest_host.ip == addr) &&
(!rtdev || (rt->dest_host.rtdev->local_ip == rtdev->local_ip))) {
*last_ptr = rt->next;
rt_free_host_route(rt);
rtdm_lock_put_irqrestore(&host_table_lock, context);
return 0;
}
last_ptr = &rt->next;
rt = rt->next;
}
rtdm_lock_put_irqrestore(&host_table_lock, context);
return -ENOENT;
}
示例13: cfgModeSet
static int32_t cfgModeSet(
struct rtdm_dev_context * ctx,
enum xspiMode mode) {
struct devCtx * devCtx;
rtdm_lockctx_t lockCtx;
LOG_DBG("CFG: set SPI mode to %d", mode);
if (!CFG_ARG_IS_VALID(mode, XSPI_MODE_MASTER, XSPI_MODE_SLAVE)) {
return (-EINVAL);
}
devCtx = getDevCtx(
ctx);
rtdm_lock_get_irqsave(&devCtx->lock, lockCtx);
if (XSPI_ACTIVITY_RUNNIG == devCtx->actvCnt) {
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (-EAGAIN);
}
devCtx->cfg.mode = mode;
cfgApply(
ctx);
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (0);
}
示例14: cfgChnCsPolaritySet
static int32_t cfgChnCsPolaritySet(
struct rtdm_dev_context * ctx,
enum xspiCsPolarity csPolarity) {
struct devCtx * devCtx;
rtdm_lockctx_t lockCtx;
LOG_DBG("CFG: set CS polarity to %d", csPolarity);
if (!CFG_ARG_IS_VALID(csPolarity, XSPI_CS_POLARITY_ACTIVE_HIGH, XSPI_CS_POLAROTY_ACTIVE_LOW)) {
return (-EINVAL);
}
devCtx = getDevCtx(
ctx);
rtdm_lock_get_irqsave(&devCtx->lock, lockCtx);
if (XSPI_ACTIVITY_RUNNIG == devCtx->actvCnt) {
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (-EAGAIN);
}
devCtx->chn[devCtx->cfg.chn].cfg.wordLength = csPolarity;
lldChnCsPolaritySet(
ctx->device,
devCtx->cfg.chn,
(uint32_t)csPolarity);
rtdm_lock_put_irqrestore(&devCtx->lock, lockCtx);
return (0);
}
示例15: rt_ip_route_get_host
/***
* rt_ip_route_get_host - check if specified host route is resolved
*/
int rt_ip_route_get_host(u32 addr, char *if_name, unsigned char *dev_addr,
struct rtnet_device *rtdev)
{
rtdm_lockctx_t context;
struct host_route *rt;
unsigned int key;
key = ntohl(addr) & HOST_HASH_KEY_MASK;
rtdm_lock_get_irqsave(&host_table_lock, context);
rt = host_hash_tbl[key];
while (rt != NULL) {
if ((rt->dest_host.ip == addr) &&
(!rtdev || rt->dest_host.rtdev->local_ip == rtdev->local_ip)) {
memcpy(dev_addr, rt->dest_host.dev_addr,
rt->dest_host.rtdev->addr_len);
strncpy(if_name, rt->dest_host.rtdev->name, IFNAMSIZ);
rtdm_lock_put_irqrestore(&host_table_lock, context);
return 0;
}
rt = rt->next;
}
rtdm_lock_put_irqrestore(&host_table_lock, context);
return -ENOENT;
}