本文整理汇总了C++中restore_flags函数的典型用法代码示例。如果您正苦于以下问题:C++ restore_flags函数的具体用法?C++ restore_flags怎么用?C++ restore_flags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了restore_flags函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOCOMX_open
static int LOCOMX_open(struct net_device *dev)
{
struct comx_channel *ch = netdev_priv(dev);
struct locomx_data *hw = ch->HW_privdata;
struct proc_dir_entry *procfile = ch->procdir->subdir;
unsigned long flags;
int ret;
if (!dev->base_addr || !dev->irq) {
return -ENODEV;
}
if (!request_region(dev->base_addr, hw->io_extent, dev->name)) {
return -EAGAIN;
}
hw->board.chanA.ctrlio=dev->base_addr + 5;
hw->board.chanA.dataio=dev->base_addr + 7;
hw->board.irq=dev->irq;
hw->board.chanA.netdevice=dev;
hw->board.chanA.dev=&hw->board;
hw->board.name=dev->name;
hw->board.chanA.txdma=TX_DMA;
hw->board.chanA.rxdma=RX_DMA;
hw->board.chanA.irqs=&z8530_nop;
hw->board.chanB.irqs=&z8530_nop;
if(request_irq(dev->irq, z8530_interrupt, SA_INTERRUPT,
dev->name, &hw->board)) {
printk(KERN_ERR "%s: unable to obtain irq %d\n", dev->name,
dev->irq);
ret=-EAGAIN;
goto irq_fail;
}
if(request_dma(TX_DMA,"LoCOMX (TX)")) {
printk(KERN_ERR "%s: unable to obtain TX DMA (DMA channel %d)\n",
dev->name, TX_DMA);
ret=-EAGAIN;
goto dma1_fail;
}
if(request_dma(RX_DMA,"LoCOMX (RX)")) {
printk(KERN_ERR "%s: unable to obtain RX DMA (DMA channel %d)\n",
dev->name, RX_DMA);
ret=-EAGAIN;
goto dma2_fail;
}
save_flags(flags);
cli();
if(z8530_init(&hw->board)!=0)
{
printk(KERN_ERR "%s: Z8530 device not found.\n",dev->name);
ret=-ENODEV;
goto z8530_fail;
}
hw->board.chanA.dcdcheck=CTS;
z8530_channel_load(&hw->board.chanA, z8530_hdlc_kilostream_85230);
z8530_channel_load(&hw->board.chanA, z8530_locomx);
z8530_channel_load(&hw->board.chanB, z8530_dead_port);
z8530_describe(&hw->board, "I/O", dev->base_addr);
if((ret=z8530_sync_dma_open(dev, &hw->board.chanA))!=0) {
goto z8530_fail;
}
restore_flags(flags);
hw->board.active=1;
hw->board.chanA.rx_function=locomx_rx;
ch->init_status |= HW_OPEN;
if (hw->board.chanA.status & DCD) {
ch->line_status |= LINE_UP;
} else {
ch->line_status &= ~LINE_UP;
}
comx_status(dev, ch->line_status);
init_timer(&hw->status_timer);
hw->status_timer.function=locomx_status_timerfun;
hw->status_timer.data=(unsigned long)dev;
hw->status_timer.expires=jiffies + ch->lineup_delay * HZ;
add_timer(&hw->status_timer);
for (; procfile ; procfile = procfile->next) {
if (strcmp(procfile->name, FILENAME_IO) == 0 ||
strcmp(procfile->name, FILENAME_IRQ) == 0) {
procfile->mode = S_IFREG | 0444;
}
}
return 0;
//.........这里部分代码省略.........
示例2: nm256_startRecording
static void
nm256_startRecording (struct nm256_info *card, char *buffer, u32 amt)
{
u32 endpos;
int enableEngine = 0;
u32 ringsize = card->recordBufferSize;
unsigned long flags;
if (amt > (ringsize / 2)) {
/*
* Of course this won't actually work right, because the
* caller is going to assume we will give what we got asked
* for.
*/
printk (KERN_ERR "NM256: Read request too large: %d\n", amt);
amt = ringsize / 2;
}
if (amt < 8) {
printk (KERN_ERR "NM256: Read request too small; %d\n", amt);
return;
}
save_flags (flags);
cli ();
/*
* If we're not currently recording, set up the start and end registers
* for the recording engine.
*/
if (! card->recording) {
card->recording = 1;
if (nm256_grabInterrupt (card) == 0) {
card->curRecPos = 0;
nm256_setInfo (card->dev_for_record, card);
nm256_writePort32 (card, 2, NM_RBUFFER_START, card->abuf2);
nm256_writePort32 (card, 2, NM_RBUFFER_END,
card->abuf2 + ringsize);
nm256_writePort32 (card, 2, NM_RBUFFER_CURRP,
card->abuf2 + card->curRecPos);
enableEngine = 1;
}
else {
/* Not sure what else to do here. */
restore_flags (flags);
return;
}
}
/*
* If we happen to go past the end of the buffer a bit (due to a
* delayed interrupt) it's OK. So might as well set the watermark
* right at the end of the data we want.
*/
endpos = card->abuf2 + ((card->curRecPos + amt) % ringsize);
card->recBuf = buffer;
card->requestedRecAmt = amt;
nm256_writePort32 (card, 2, NM_RBUFFER_WMARK, endpos);
/* Enable recording engine and interrupts. */
if (enableEngine)
nm256_writePort8 (card, 2, NM_RECORD_ENABLE_REG,
NM_RECORD_ENABLE_FLAG | NM_RECORD_FREERUN);
restore_flags (flags);
}
示例3: isdn_divert_icall
int isdn_divert_icall(isdn_ctrl *ic)
{ int retval = 0;
int flags;
struct call_struc *cs = NULL;
struct deflect_struc *dv;
char *p,*p1;
u_char accept;
/* first check the internal deflection table */
for (dv = table_head; dv ; dv = dv->next )
{ /* scan table */
if (((dv->rule.callopt == 1) && (ic->command == ISDN_STAT_ICALLW)) ||
((dv->rule.callopt == 2) && (ic->command == ISDN_STAT_ICALL)))
continue; /* call option check */
if (!(dv->rule.drvid & (1L << ic->driver)))
continue; /* driver not matching */
if ((dv->rule.si1) && (dv->rule.si1 != ic->parm.setup.si1))
continue; /* si1 not matching */
if ((dv->rule.si2) && (dv->rule.si2 != ic->parm.setup.si2))
continue; /* si2 not matching */
p = dv->rule.my_msn;
p1 = ic->parm.setup.eazmsn;
accept = 0;
while (*p)
{ /* complete compare */
if (*p == '-')
{ accept = 1; /* call accepted */
break;
}
if (*p++ != *p1++)
break; /* not accepted */
if ((!*p) && (!*p1))
accept = 1;
} /* complete compare */
if (!accept) continue; /* not accepted */
if ((strcmp(dv->rule.caller,"0")) || (ic->parm.setup.phone[0]))
{ p = dv->rule.caller;
p1 = ic->parm.setup.phone;
accept = 0;
while (*p)
{ /* complete compare */
if (*p == '-')
{ accept = 1; /* call accepted */
break;
}
if (*p++ != *p1++)
break; /* not accepted */
if ((!*p) && (!*p1))
accept = 1;
} /* complete compare */
if (!accept) continue; /* not accepted */
}
switch (dv->rule.action)
{ case DEFLECT_IGNORE:
return(0);
break;
case DEFLECT_ALERT:
case DEFLECT_PROCEED:
case DEFLECT_REPORT:
case DEFLECT_REJECT:
if (dv->rule.action == DEFLECT_PROCEED)
if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime)))
return(0); /* no external deflection needed */
if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
return(0); /* no memory */
init_timer(&cs->timer);
cs->info[0] = '\0';
cs->timer.function = deflect_timer_expire;
cs->timer.data = (ulong) cs; /* pointer to own structure */
cs->ics = *ic; /* copy incoming data */
if (!cs->ics.parm.setup.phone[0]) strcpy(cs->ics.parm.setup.phone,"0");
if (!cs->ics.parm.setup.eazmsn[0]) strcpy(cs->ics.parm.setup.eazmsn,"0");
cs->ics.parm.setup.screen = dv->rule.screen;
if (dv->rule.waittime)
cs->timer.expires = jiffies + (HZ * dv->rule.waittime);
else
if (dv->rule.action == DEFLECT_PROCEED)
cs->timer.expires = jiffies + (HZ * extern_wait_max);
else
cs->timer.expires = 0;
cs->akt_state = dv->rule.action;
save_flags(flags);
cli();
cs->divert_id = next_id++; /* new sequence number */
restore_flags(flags);
cs->prev = NULL;
if (cs->akt_state == DEFLECT_ALERT)
{ strcpy(cs->deflect_dest,dv->rule.to_nr);
if (!cs->timer.expires)
{ strcpy(ic->parm.setup.eazmsn,"Testtext direct");
ic->parm.setup.screen = dv->rule.screen;
strcpy(ic->parm.setup.phone,dv->rule.to_nr);
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
retval = 5;
//.........这里部分代码省略.........
示例4: isdnloop_polldchan
/*
* Poll a virtual cards message queue.
* If there are new status-replies from the card, copy them to
* ringbuffer for reading on /dev/isdnctrl and call
* isdnloop_parse_status() for processing them. Watch for special
* Firmware bootmessage and parse it, to get the D-Channel protocol.
* If there are B-Channels open, initiate a timer-callback to
* isdnloop_pollbchan().
* This routine is called periodically via timer interrupt.
*
* Parameter:
* data = pointer to card struct
*/
static void
isdnloop_polldchan(unsigned long data)
{
isdnloop_card *card = (isdnloop_card *) data;
struct sk_buff *skb;
int avail;
int left;
u_char c;
int ch;
unsigned long flags;
u_char *p;
isdn_ctrl cmd;
if ((skb = skb_dequeue(&card->dqueue)))
avail = skb->len;
else
avail = 0;
for (left = avail; left > 0; left--) {
c = *skb->data;
skb_pull(skb, 1);
isdnloop_putmsg(card, c);
card->imsg[card->iptr] = c;
if (card->iptr < 59)
card->iptr++;
if (!skb->len) {
avail++;
isdnloop_putmsg(card, '\n');
card->imsg[card->iptr] = 0;
card->iptr = 0;
if (card->imsg[0] == '0' && card->imsg[1] >= '0' &&
card->imsg[1] <= '2' && card->imsg[2] == ';') {
ch = (card->imsg[1] - '0') - 1;
p = &card->imsg[3];
isdnloop_parse_status(p, ch, card);
} else {
p = card->imsg;
if (!strncmp(p, "DRV1.", 5)) {
printk(KERN_INFO "isdnloop: (%s) %s\n", CID, p);
if (!strncmp(p + 7, "TC", 2)) {
card->ptype = ISDN_PTYPE_1TR6;
card->interface.features |= ISDN_FEATURE_P_1TR6;
printk(KERN_INFO
"isdnloop: (%s) 1TR6-Protocol loaded and running\n", CID);
}
if (!strncmp(p + 7, "EC", 2)) {
card->ptype = ISDN_PTYPE_EURO;
card->interface.features |= ISDN_FEATURE_P_EURO;
printk(KERN_INFO
"isdnloop: (%s) Euro-Protocol loaded and running\n", CID);
}
continue;
}
}
}
}
if (avail) {
cmd.command = ISDN_STAT_STAVAIL;
cmd.driver = card->myid;
cmd.arg = avail;
card->interface.statcallb(&cmd);
}
if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE))
if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) {
/* schedule b-channel polling */
card->flags |= ISDNLOOP_FLAGS_RBTIMER;
save_flags(flags);
cli();
del_timer(&card->rb_timer);
card->rb_timer.function = isdnloop_pollbchan;
card->rb_timer.data = (unsigned long) card;
card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
add_timer(&card->rb_timer);
restore_flags(flags);
}
/* schedule again */
save_flags(flags);
cli();
card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD;
add_timer(&card->st_timer);
restore_flags(flags);
}
示例5: ip_msqhst_procinfo
static int ip_msqhst_procinfo(char *buffer, char **start, off_t offset,
int length, int unused)
{
off_t pos=0, begin;
struct ip_masq *ms;
unsigned long flags;
char temp[129];
int idx = 0;
int len=0;
if (offset < 128)
{
#ifdef CONFIG_IP_MASQUERADE_ICMP
sprintf(temp,
"Prc FromIP FPrt ToIP TPrt Masq Init-seq Delta PDelta Expires (free=%d,%d,%d)",
ip_masq_free_ports[0], ip_masq_free_ports[1], ip_masq_free_ports[2]);
#else /* !defined(CONFIG_IP_MASQUERADE_ICMP) */
sprintf(temp,
"Prc FromIP FPrt ToIP TPrt Masq Init-seq Delta PDelta Expires (free=%d,%d)",
ip_masq_free_ports[0], ip_masq_free_ports[1]);
#endif /* CONFIG_IP_MASQUERADE_ICMP */
len = sprintf(buffer, "%-127s\n", temp);
}
pos = 128;
save_flags(flags);
cli();
for(idx = 0; idx < IP_MASQ_TAB_SIZE; idx++)
for(ms = ip_masq_m_tab[idx]; ms ; ms = ms->m_link)
{
int timer_active;
pos += 128;
if (pos <= offset)
continue;
timer_active = del_timer(&ms->timer);
if (!timer_active)
ms->timer.expires = jiffies;
sprintf(temp,"%s %08lX:%04X %08lX:%04X %04X %08X %6d %6d %7lu",
masq_proto_name(ms->protocol),
ntohl(ms->saddr), ntohs(ms->sport),
ntohl(ms->daddr), ntohs(ms->dport),
ntohs(ms->mport),
ms->out_seq.init_seq,
ms->out_seq.delta,
ms->out_seq.previous_delta,
ms->timer.expires-jiffies);
if (timer_active)
add_timer(&ms->timer);
len += sprintf(buffer+len, "%-127s\n", temp);
if(len >= length)
goto done;
}
done:
restore_flags(flags);
begin = len - (pos - offset);
*start = buffer + begin;
len -= begin;
if(len>length)
len = length;
return len;
}
示例6: ip_masq_new_enh
struct ip_masq * ip_masq_new_enh(struct device *dev, int proto, __u32 saddr, __u16 sport, __u32 daddr, __u16 dport, unsigned mflags, __u16 matchport)
{
struct ip_masq *ms, *mst;
int ports_tried, *free_ports_p;
unsigned long flags;
static int n_fails = 0;
free_ports_p = &ip_masq_free_ports[masq_proto_num(proto)];
if (*free_ports_p == 0) {
if (++n_fails < 5)
printk("ip_masq_new(proto=%s): no free ports.\n",
masq_proto_name(proto));
return NULL;
}
ms = (struct ip_masq *) kmalloc(sizeof(struct ip_masq), GFP_ATOMIC);
if (ms == NULL) {
if (++n_fails < 5)
printk("ip_masq_new(proto=%s): no memory available.\n",
masq_proto_name(proto));
return NULL;
}
memset(ms, 0, sizeof(*ms));
init_timer(&ms->timer);
ms->timer.data = (unsigned long)ms;
ms->timer.function = masq_expire;
ms->protocol = proto;
ms->saddr = saddr;
ms->sport = sport;
ms->daddr = daddr;
ms->dport = dport;
ms->flags = mflags;
ms->app_data = NULL;
ms->control = NULL;
if (proto == IPPROTO_UDP && !matchport)
ms->flags |= IP_MASQ_F_NO_DADDR;
/* get masq address from rif */
ms->maddr = dev->pa_addr;
/*
* Setup new entry as not replied yet.
* This flag will allow masq. addr (ms->maddr)
* to follow forwarding interface address.
*/
ms->flags |= IP_MASQ_F_NO_REPLY;
for (ports_tried = 0;
(*free_ports_p && (ports_tried <= (PORT_MASQ_END - PORT_MASQ_BEGIN)));
ports_tried++){
save_flags(flags);
cli();
/*
* Try the next available port number
*/
if (!matchport || ports_tried)
ms->mport = htons(masq_port++);
else
ms->mport = matchport;
if (masq_port==PORT_MASQ_END) masq_port = PORT_MASQ_BEGIN;
restore_flags(flags);
/*
* lookup to find out if this port is used.
*/
mst = ip_masq_getbym(proto, ms->maddr, ms->mport);
if (mst == NULL || matchport) {
save_flags(flags);
cli();
if (*free_ports_p == 0) {
restore_flags(flags);
break;
}
(*free_ports_p)--;
ip_masq_hash(ms);
restore_flags(flags);
if (proto != IPPROTO_ICMP)
ip_masq_bind_app(ms);
n_fails = 0;
return ms;
}
}
if (++n_fails < 5)
printk("ip_masq_new(proto=%s): could not get free masq entry (free=%d).\n",
masq_proto_name(ms->protocol), *free_ports_p);
kfree_s(ms, sizeof(*ms));
return NULL;
}
示例7: fdc_command
/* Output a cmd_len long command string to the FDC.
* The FDC should be ready to receive a new command or
* an error (EBUSY or ETIME) will occur.
*/
int fdc_command(const __u8 * cmd_data, int cmd_len)
{
int result = 0;
unsigned long flags;
int count = cmd_len;
int retry = 0;
#ifdef TESTING
static unsigned int last_time;
unsigned int time;
#endif
TRACE_FUN(ft_t_any);
fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
spin_lock_irqsave(&fdc_io_lock, flags);
if (!in_interrupt())
/* Yes, I know, too much comments inside this function
* ...
*
* Yet another bug in the original driver. All that
* havoc is caused by the fact that the isr() sends
* itself a command to the floppy tape driver (pause,
* micro step pause). Now, the problem is that
* commands are transmitted via the fdc_seek
* command. But: the fdc performs seeks in the
* background i.e. it doesn't signal busy while
* sending the step pulses to the drive. Therefore the
* non-interrupt level driver has no chance to tell
* whether the isr() just has issued a seek. Therefore
* we HAVE TO have a look at the ft_hide_interrupt
* flag: it signals the non-interrupt level part of
* the driver that it has to wait for the fdc until it
* has completet seeking.
*
* THIS WAS PRESUMABLY THE REASON FOR ALL THAT
* "fdc_read timeout" errors, I HOPE :-)
*/
if (ft_hide_interrupt) {
restore_flags(flags);
TRACE(ft_t_info,
"Waiting for the isr() completing fdc_seek()");
if (fdc_interrupt_wait(2 * FT_SECOND) < 0) {
TRACE(ft_t_warn,
"Warning: timeout waiting for isr() seek to complete");
}
if (ft_hide_interrupt || !ft_seek_completed) {
/* There cannot be another
* interrupt. The isr() only stops
* the tape and the next interrupt
* won't come until we have send our
* command to the drive.
*/
TRACE_ABORT(-EIO, ft_t_bug,
"BUG? isr() is still seeking?\n"
KERN_INFO "hide: %d\n"
KERN_INFO "seek: %d",
ft_hide_interrupt,
ft_seek_completed);
}
fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
spin_lock_irqsave(&fdc_io_lock, flags);
}
fdc_status = inb(fdc.msr);
if ((fdc_status & FDC_DATA_READY_MASK) != FDC_DATA_IN_READY) {
spin_unlock_irqrestore(&fdc_io_lock, flags);
TRACE_ABORT(-EBUSY, ft_t_err, "fdc not ready");
}
fdc_mode = *cmd_data; /* used by isr */
#ifdef TESTING
if (fdc_mode == FDC_SEEK) {
time = ftape_timediff(last_time, ftape_timestamp());
if (time < 6000) {
TRACE(ft_t_bug,"Warning: short timeout between seek commands: %d",
time);
}
}
#endif
if (!in_interrupt()) {
/* shouldn't be cleared if called from isr
*/
ft_interrupt_seen = 0;
}
while (count) {
result = fdc_write(*cmd_data);
if (result < 0) {
TRACE(ft_t_fdc_dma,
"fdc_mode = %02x, status = %02x at index %d",
(int) fdc_mode, (int) fdc_status,
cmd_len - count);
if (++retry <= 3) {
TRACE(ft_t_warn, "fdc_write timeout, retry");
} else {
TRACE(ft_t_err, "fdc_write timeout, fatal");
/* recover ??? */
break;
}
//.........这里部分代码省略.........
示例8: atari_free_irq
void atari_free_irq(unsigned int irq, void *dev_id)
{
unsigned long flags;
int vector;
irq_node_t **list, *node;
if (!IS_VALID_INTNO(irq)) {
printk("%s: Unknown irq %d\n", __FUNCTION__, irq);
return;
}
vector = IRQ_SOURCE_TO_VECTOR(irq);
if (vectors[vector] == bad_interrupt)
goto not_found;
save_flags(flags);
cli();
if (irq_handler[irq].handler != atari_call_irq_list) {
/* It's the only handler for the interrupt */
if (irq_handler[irq].dev_id != dev_id) {
restore_flags(flags);
goto not_found;
}
irq_handler[irq].handler = NULL;
irq_handler[irq].dev_id = NULL;
irq_param[irq].devname = NULL;
vectors[vector] = bad_interrupt;
/* If MFP int, also disable it */
atari_disable_irq(irq);
atari_turnoff_irq(irq);
restore_flags(flags);
return;
}
/* The interrupt is chained, find the irq on the list */
for(list = (irq_node_t **)&irq_handler[irq].dev_id; *list; list = &(*list)->next) {
if ((*list)->dev_id == dev_id) break;
}
if (!*list) {
restore_flags(flags);
goto not_found;
}
(*list)->handler = NULL; /* Mark it as free for reallocation */
*list = (*list)->next;
/* If there's now only one handler, unchain the interrupt, i.e. plug in
* the handler directly again and omit atari_call_irq_list */
node = (irq_node_t *)irq_handler[irq].dev_id;
if (node && !node->next) {
irq_handler[irq].handler = node->handler;
irq_handler[irq].dev_id = node->dev_id;
irq_param[irq].devname = node->devname;
node->handler = NULL; /* Mark it as free for reallocation */
}
restore_flags(flags);
return;
not_found:
printk("%s: tried to remove invalid irq\n", __FUNCTION__);
return;
}
示例9: atari_request_irq
int atari_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
unsigned long flags, const char *devname, void *dev_id)
{
int vector;
unsigned long oflags = flags;
/*
* The following is a hack to make some PCI card drivers work,
* which set the SA_SHIRQ flag.
*/
flags &= ~SA_SHIRQ;
if (flags == SA_INTERRUPT) {
printk ("%s: SA_INTERRUPT changed to IRQ_TYPE_SLOW for %s\n",
__FUNCTION__, devname);
flags = IRQ_TYPE_SLOW;
}
if (flags < IRQ_TYPE_SLOW || flags > IRQ_TYPE_PRIO) {
printk ("%s: Bad irq type 0x%lx <0x%lx> requested from %s\n",
__FUNCTION__, flags, oflags, devname);
return -EINVAL;
}
if (!IS_VALID_INTNO(irq)) {
printk ("%s: Unknown irq %d requested from %s\n",
__FUNCTION__, irq, devname);
return -ENXIO;
}
vector = IRQ_SOURCE_TO_VECTOR(irq);
/*
* Check type/source combination: slow ints are (currently)
* only possible for MFP-interrupts.
*/
if (flags == IRQ_TYPE_SLOW &&
(irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE)) {
printk ("%s: Slow irq requested for non-MFP source %d from %s\n",
__FUNCTION__, irq, devname);
return -EINVAL;
}
if (vectors[vector] == bad_interrupt) {
/* int has no handler yet */
irq_handler[irq].handler = handler;
irq_handler[irq].dev_id = dev_id;
irq_param[irq].flags = flags;
irq_param[irq].devname = devname;
vectors[vector] =
(flags == IRQ_TYPE_SLOW) ? slow_handlers[irq-STMFP_SOURCE_BASE] :
(flags == IRQ_TYPE_FAST) ? atari_fast_irq_handler :
atari_prio_irq_handler;
/* If MFP int, also enable and umask it */
atari_turnon_irq(irq);
atari_enable_irq(irq);
return 0;
}
else if (irq_param[irq].flags == flags) {
/* old handler is of same type -> handlers can be chained */
irq_node_t *node;
unsigned long flags;
save_flags(flags);
cli();
if (irq_handler[irq].handler != atari_call_irq_list) {
/* Only one handler yet, make a node for this first one */
if (!(node = new_irq_node()))
return -ENOMEM;
node->handler = irq_handler[irq].handler;
node->dev_id = irq_handler[irq].dev_id;
node->devname = irq_param[irq].devname;
node->next = NULL;
irq_handler[irq].handler = atari_call_irq_list;
irq_handler[irq].dev_id = node;
irq_param[irq].devname = "chained";
}
if (!(node = new_irq_node()))
return -ENOMEM;
node->handler = handler;
node->dev_id = dev_id;
node->devname = devname;
/* new handlers are put in front of the queue */
node->next = irq_handler[irq].dev_id;
irq_handler[irq].dev_id = node;
restore_flags(flags);
return 0;
} else {
printk ("%s: Irq %d allocated by other type int (call from %s)\n",
__FUNCTION__, irq, devname);
return -EBUSY;
}
}
示例10: ambauart_change_speed
static void ambauart_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
{
u_int lcr, old_ier, fcr=0;
unsigned long flags;
#if DEBUG
printk("ambauart_set_cflag(0x%x) called\n", cflag);
#endif
//printk("ambauart_change_speed\n");
/* byte size and parity */
switch (cflag & CSIZE) {
case CS5: lcr = KS8695_UART_LINEC_WLEN5; break;
case CS6: lcr = KS8695_UART_LINEC_WLEN6; break;
case CS7: lcr = KS8695_UART_LINEC_WLEN7; break;
default: lcr = KS8695_UART_LINEC_WLEN8; break; // CS8
}
if (cflag & CSTOPB)
lcr |= KS8695_UART_LINEC_STP2;
if (cflag & PARENB) {
lcr |= KS8695_UART_LINEC_PEN;
if (!(cflag & PARODD))
lcr |= KS8695_UART_LINEC_EPS;
}
if (port->fifosize > 1)
fcr = KS8695_UART_FIFO_TRIG04 | KS8695_UART_FIFO_TXRST | KS8695_UART_FIFO_RXRST | KS8695_UART_FIFO_FEN;
port->read_status_mask = KS8695_UART_LINES_OE;
if (iflag & INPCK)
port->read_status_mask |= (KS8695_UART_LINES_FE | KS8695_UART_LINES_PE);
if (iflag & (BRKINT | PARMRK))
port->read_status_mask |= KS8695_UART_LINES_BE;
/*
* Characters to ignore
*/
port->ignore_status_mask = 0;
if (iflag & IGNPAR)
port->ignore_status_mask |= (KS8695_UART_LINES_FE | KS8695_UART_LINES_PE);
if (iflag & IGNBRK) {
port->ignore_status_mask |= KS8695_UART_LINES_BE;
/*
* If we're ignoring parity and break indicators,
* ignore overruns too (for real raw support).
*/
if (iflag & IGNPAR)
port->ignore_status_mask |= KS8695_UART_LINES_OE;
}
/*
* Ignore all characters if CREAD is not set.
*/
if ((cflag & CREAD) == 0)
port->ignore_status_mask |= UART_DUMMY_LSR_RX;
/* first, disable everything */
save_flags(flags); cli();
old_ier = UART_GET_IER(port);
UART_PUT_IER(port, old_ier & 0xFFFFF0FF);
old_ier &= ~KS8695_INT_ENABLE_MODEM;
if ((port->flags & ASYNC_HARDPPS_CD) ||
(cflag & CRTSCTS) || !(cflag & CLOCAL))
old_ier |= KS8695_INT_ENABLE_MODEM;
/* Set baud rate */
// UART_PUT_BRDR(port, port->uartclk / quot);
UART_PUT_BRDR(port, 0x28B);
UART_PUT_LCR(port, lcr);
UART_PUT_FCR(port, fcr);
UART_PUT_IER(port, old_ier & 0xFFFFFEFF);
restore_flags(flags);
}
示例11: cf_command
int cf_command(int drvid, int mode,
u_char proc, char *msn,
u_char service, char *fwd_nr, ulong *procid)
{ int retval,msnlen,flags;
int fwd_len;
char *p,*ielenp,tmp[60];
struct call_struc *cs;
if (strchr(msn,'.')) return(-EINVAL); /* subaddress not allowed in msn */
if ((proc & 0x7F) > 2) return(-EINVAL);
proc &= 3;
p = tmp;
*p++ = 0x30; /* enumeration */
ielenp = p++; /* remember total length position */
*p++ = 0xa; /* proc tag */
*p++ = 1; /* length */
*p++ = proc & 0x7F; /* procedure to de/activate/interrogate */
*p++ = 0xa; /* service tag */
*p++ = 1; /* length */
*p++ = service; /* service to handle */
if (mode == 1)
{ if (!*fwd_nr) return(-EINVAL); /* destination missing */
if (strchr(fwd_nr,'.')) return(-EINVAL); /* subaddress not allowed */
fwd_len = strlen(fwd_nr);
*p++ = 0x30; /* number enumeration */
*p++ = fwd_len + 2; /* complete forward to len */
*p++ = 0x80; /* fwd to nr */
*p++ = fwd_len; /* length of number */
strcpy(p,fwd_nr); /* copy number */
p += fwd_len; /* pointer beyond fwd */
} /* activate */
msnlen = strlen(msn);
*p++ = 0x80; /* msn number */
if (msnlen > 1)
{ *p++ = msnlen; /* length */
strcpy(p,msn);
p += msnlen;
}
else *p++ = 0;
*ielenp = p - ielenp - 1; /* set total IE length */
/* allocate mem for information struct */
if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
return(-ENOMEM); /* no memory */
init_timer(&cs->timer);
cs->info[0] = '\0';
cs->timer.function = deflect_timer_expire;
cs->timer.data = (ulong) cs; /* pointer to own structure */
cs->ics.driver = drvid;
cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */
cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */
cs->ics.parm.dss1_io.proc = (mode == 1) ? 7: (mode == 2) ? 11:8; /* operation */
cs->ics.parm.dss1_io.timeout = 4000; /* from ETS 300 207-1 */
cs->ics.parm.dss1_io.datalen = p - tmp; /* total len */
cs->ics.parm.dss1_io.data = tmp; /* start of buffer */
save_flags(flags);
cli();
cs->ics.parm.dss1_io.ll_id = next_id++; /* id for callback */
restore_flags(flags);
*procid = cs->ics.parm.dss1_io.ll_id;
sprintf(cs->info,"%d 0x%lx %s%s 0 %s %0x %d%s%s\n",
(!mode ) ? DIVERT_DEACTIVATE : (mode == 1) ? DIVERT_ACTIVATE : DIVERT_REPORT,
cs->ics.parm.dss1_io.ll_id,
(mode != 2) ? "" : "0 ",
divert_if.drv_to_name(cs->ics.driver),
msn,
service & 0xFF,
proc,
(mode != 1) ? "" : " 0 ",
(mode != 1) ? "" : fwd_nr);
retval = divert_if.ll_cmd(&cs->ics); /* excute command */
if (!retval)
{ cs->prev = NULL;
save_flags(flags);
cli();
cs->next = divert_head;
divert_head = cs;
restore_flags(flags);
}
else
kfree(cs);
return(retval);
} /* cf_command */
示例12: ip_fw_masquerade
int ip_fw_masquerade(struct sk_buff **skb_ptr, struct device *dev)
{
struct sk_buff *skb=*skb_ptr;
struct iphdr *iph = skb->h.iph;
__u16 *portptr;
struct ip_masq *ms;
int size;
unsigned long timeout;
/*
* We can only masquerade protocols with ports...
* [TODO]
* We may need to consider masq-ing some ICMP related to masq-ed protocols
*/
if (iph->protocol==IPPROTO_ICMP)
return (ip_fw_masq_icmp(skb_ptr,dev));
if (iph->protocol!=IPPROTO_UDP && iph->protocol!=IPPROTO_TCP)
return -1;
/*
* Now hunt the list to see if we have an old entry
*/
portptr = (__u16 *)&(((char *)iph)[iph->ihl*4]);
#ifdef DEBUG_CONFIG_IP_MASQUERADE
printk("Outgoing %s %lX:%X -> %lX:%X\n",
masq_proto_name(iph->protocol),
ntohl(iph->saddr), ntohs(portptr[0]),
ntohl(iph->daddr), ntohs(portptr[1]));
#endif
ms = ip_masq_out_get(iph);
if (ms!=NULL) {
ip_masq_set_expire(ms,0);
/*
* If sysctl !=0 and no pkt has been received yet
* in this tunnel and routing iface address has changed...
* "You are welcome, diald".
*/
if ( sysctl_ip_dynaddr && ms->flags & IP_MASQ_F_NO_REPLY && dev->pa_addr != ms->maddr) {
unsigned long flags;
if (sysctl_ip_dynaddr > 1) {
printk(KERN_INFO "ip_fw_masquerade(): change maddr from %s",
in_ntoa(ms->maddr));
printk(" to %s\n", in_ntoa(dev->pa_addr));
}
save_flags(flags);
cli();
ip_masq_unhash(ms);
ms->maddr = dev->pa_addr;
ip_masq_hash(ms);
restore_flags(flags);
}
/*
* Set sport if not defined yet (e.g. ftp PASV). Because
* masq entries are hashed on sport, unhash with old value
* and hash with new.
*/
if ( ms->flags & IP_MASQ_F_NO_SPORT && ms->protocol == IPPROTO_TCP ) {
unsigned long flags;
ms->flags &= ~IP_MASQ_F_NO_SPORT;
save_flags(flags);
cli();
ip_masq_unhash(ms);
ms->sport = portptr[0];
ip_masq_hash(ms); /* hash on new sport */
restore_flags(flags);
#ifdef DEBUG_CONFIG_IP_MASQUERADE
printk("ip_fw_masquerade(): filled sport=%d\n",
ntohs(ms->sport));
#endif
}
}
#ifdef CONFIG_IP_MASQUERADE_IPAUTOFW
/* update any ipautofw entries .. */
ip_autofw_update_out(iph->saddr, iph->daddr, portptr[1],
iph->protocol);
#endif /* CONFIG_IP_MASQUERADE_IPAUTOFW */
/*
* Nope, not found, create a new entry for it
*/
if (ms==NULL)
{
#ifdef CONFIG_IP_MASQUERADE_IPAUTOFW
/* if the source port is supposed to match the masq port, then
make it so */
if (ip_autofw_check_direct(portptr[1],iph->protocol))
ms = ip_masq_new_enh(dev, iph->protocol,
iph->saddr, portptr[0],
iph->daddr, portptr[1],
0,
portptr[0]);
else
#endif /* CONFIG_IP_MASQUERADE_IPAUTOFW */
//.........这里部分代码省略.........
示例13: deflect_extern_action
int deflect_extern_action(u_char cmd, ulong callid, char *to_nr)
{ struct call_struc *cs;
isdn_ctrl ic;
int flags;
int i;
if ((cmd & 0x7F) > 2) return(-EINVAL); /* invalid command */
cs = divert_head; /* start of parameter list */
while (cs)
{ if (cs->divert_id == callid) break; /* found */
cs = cs->next;
} /* search entry */
if (!cs) return(-EINVAL); /* invalid callid */
ic.driver = cs->ics.driver;
ic.arg = cs->ics.arg;
i = -EINVAL;
if (cs->akt_state == DEFLECT_AUTODEL) return(i); /* no valid call */
switch (cmd & 0x7F)
{ case 0: /* hangup */
del_timer(&cs->timer);
ic.command = ISDN_CMD_HANGUP;
i = divert_if.ll_cmd(&ic);
save_flags(flags);
cli();
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
add_timer(&cs->timer);
restore_flags(flags);
break;
case 1: /* alert */
if (cs->akt_state == DEFLECT_ALERT) return(0);
cmd &= 0x7F; /* never wait */
del_timer(&cs->timer);
ic.command = ISDN_CMD_ALERT;
if ((i = divert_if.ll_cmd(&ic)))
{ save_flags(flags);
cli();
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
add_timer(&cs->timer);
restore_flags(flags);
}
else
cs->akt_state = DEFLECT_ALERT;
break;
case 2: /* redir */
del_timer(&cs->timer);
strcpy(cs->ics.parm.setup.phone, to_nr);
strcpy(cs->ics.parm.setup.eazmsn, "Testtext manual");
ic.command = ISDN_CMD_REDIR;
if ((i = divert_if.ll_cmd(&ic)))
{ save_flags(flags);
cli();
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
add_timer(&cs->timer);
restore_flags(flags);
}
else
cs->akt_state = DEFLECT_ALERT;
break;
} /* switch */
return(i);
} /* deflect_extern_action */
示例14: ip_fw_masq_icmp
int ip_fw_masq_icmp(struct sk_buff **skb_p, struct device *dev)
{
struct sk_buff *skb = *skb_p;
struct iphdr *iph = skb->h.iph;
struct icmphdr *icmph = (struct icmphdr *)((char *)iph + (iph->ihl<<2));
struct iphdr *ciph; /* The ip header contained within the ICMP */
__u16 *pptr; /* port numbers from TCP/UDP contained header */
struct ip_masq *ms;
unsigned short len = ntohs(iph->tot_len) - (iph->ihl * 4);
#ifdef DEBUG_CONFIG_IP_MASQUERADE_ICMP
printk("Incoming forward ICMP (%d,%d) %lX -> %lX\n",
icmph->type, ntohs(icmp_id(icmph)),
ntohl(iph->saddr), ntohl(iph->daddr));
#endif
#ifdef CONFIG_IP_MASQUERADE_ICMP
if ((icmph->type == ICMP_ECHO ) ||
(icmph->type == ICMP_TIMESTAMP ) ||
(icmph->type == ICMP_INFO_REQUEST ) ||
(icmph->type == ICMP_ADDRESS )) {
#ifdef DEBUG_CONFIG_IP_MASQUERADE_ICMP
printk("MASQ: icmp request rcv %lX->%lX id %d type %d\n",
ntohl(iph->saddr),
ntohl(iph->daddr),
ntohs(icmp_id(icmph)),
icmph->type);
#endif
ms = ip_masq_out_get_2(iph->protocol,
iph->saddr,
icmp_id(icmph),
iph->daddr,
icmp_hv_req(icmph));
if (ms == NULL) {
ms = ip_masq_new(dev,
iph->protocol,
iph->saddr,
icmp_id(icmph),
iph->daddr,
icmp_hv_req(icmph),
0);
if (ms == NULL)
return (-1);
#ifdef DEBUG_CONFIG_IP_MASQUERADE_ICMP
printk("MASQ: Create new icmp entry\n");
#endif
}
ip_masq_set_expire(ms, 0);
/* Rewrite source address */
/*
* If sysctl !=0 and no pkt has been received yet
* in this tunnel and routing iface address has changed...
* "You are welcome, diald".
*/
if ( sysctl_ip_dynaddr && ms->flags & IP_MASQ_F_NO_REPLY && dev->pa_addr != ms->maddr) {
unsigned long flags;
#ifdef DEBUG_CONFIG_IP_MASQUERADE
printk(KERN_INFO "ip_fw_masq_icmp(): change masq.addr %s",
in_ntoa(ms->maddr));
printk("-> %s\n", in_ntoa(dev->pa_addr));
#endif
save_flags(flags);
cli();
ip_masq_unhash(ms);
ms->maddr = dev->pa_addr;
ip_masq_hash(ms);
restore_flags(flags);
}
iph->saddr = ms->maddr;
ip_send_check(iph);
/* Rewrite port (id) */
(icmph->un).echo.id = ms->mport;
icmph->checksum = 0;
icmph->checksum = ip_compute_csum((unsigned char *)icmph, len);
ip_masq_set_expire(ms, MASQUERADE_EXPIRE_ICMP);
#ifdef DEBUG_CONFIG_IP_MASQUERADE_ICMP
printk("MASQ: icmp request rwt %lX->%lX id %d type %d\n",
ntohl(iph->saddr),
ntohl(iph->daddr),
ntohs(icmp_id(icmph)),
icmph->type);
#endif
return (1);
}
#endif
/*
* Work through seeing if this is for us.
* These checks are supposed to be in an order that
* means easy things are checked first to speed up
* processing.... however this means that some
* packets will manage to get a long way down this
* stack and then be rejected, but thats life
*/
if ((icmph->type != ICMP_DEST_UNREACH) &&
(icmph->type != ICMP_SOURCE_QUENCH) &&
(icmph->type != ICMP_TIME_EXCEEDED))
return 0;
//.........这里部分代码省略.........
示例15: prot_stat_callback
int prot_stat_callback(isdn_ctrl *ic)
{ struct call_struc *cs, *cs1;
int i,flags;
cs = divert_head; /* start of list */
cs1 = NULL;
while (cs)
{ if (ic->driver == cs->ics.driver)
{ switch (cs->ics.arg)
{ case DSS1_CMD_INVOKE:
if ((cs->ics.parm.dss1_io.ll_id == ic->parm.dss1_io.ll_id) &&
(cs->ics.parm.dss1_io.hl_id == ic->parm.dss1_io.hl_id))
{ switch (ic->arg)
{ case DSS1_STAT_INVOKE_ERR:
sprintf(cs->info,"128 0x%lx 0x%x\n",
ic->parm.dss1_io.ll_id,
ic->parm.dss1_io.timeout);
put_info_buffer(cs->info);
break;
case DSS1_STAT_INVOKE_RES:
switch (cs->ics.parm.dss1_io.proc)
{ case 7:
case 8:
put_info_buffer(cs->info);
break;
case 11:
i = interrogate_success(ic,cs);
if (i)
sprintf(cs->info,"%d 0x%lx %d\n",DIVERT_REPORT,
ic->parm.dss1_io.ll_id,i);
put_info_buffer(cs->info);
break;
default:
printk(KERN_WARNING "dss1_divert: unknown proc %d\n",cs->ics.parm.dss1_io.proc);
break;
}
break;
default:
printk(KERN_WARNING "dss1_divert unknown invoke answer %lx\n",ic->arg);
break;
}
cs1 = cs; /* remember structure */
cs = NULL;
continue; /* abort search */
} /* id found */
break;
case DSS1_CMD_INVOKE_ABORT:
printk(KERN_WARNING "dss1_divert unhandled invoke abort\n");
break;
default:
printk(KERN_WARNING "dss1_divert unknown cmd 0x%lx\n",cs->ics.arg);
break;
} /* switch ics.arg */
cs = cs->next;
} /* driver ok */
}
if (!cs1)
{ printk(KERN_WARNING "dss1_divert unhandled process\n");
return(0);
}
if (cs1->ics.driver == -1)
{ save_flags(flags);
cli();
del_timer(&cs1->timer);
if (cs1->prev)
cs1->prev->next = cs1->next; /* forward link */
else
divert_head = cs1->next;
if (cs1->next)
cs1->next->prev = cs1->prev; /* back link */
restore_flags(flags);
kfree(cs1);
}
return(0);
} /* prot_stat_callback */