本文整理汇总了C++中readb函数的典型用法代码示例。如果您正苦于以下问题:C++ readb函数的具体用法?C++ readb怎么用?C++ readb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readb函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mac53c94_interrupt
static void mac53c94_interrupt(int irq, void *dev_id)
{
struct fsc_state *state = (struct fsc_state *) dev_id;
struct mac53c94_regs __iomem *regs = state->regs;
struct dbdma_regs __iomem *dma = state->dma;
struct scsi_cmnd *cmd = state->current_req;
int nb, stat, seq, intr;
static int mac53c94_errors;
/*
* Apparently, reading the interrupt register unlatches
* the status and sequence step registers.
*/
seq = readb(®s->seqstep);
stat = readb(®s->status);
intr = readb(®s->interrupt);
#if 0
printk(KERN_DEBUG "mac53c94_intr, intr=%x stat=%x seq=%x phase=%d\n",
intr, stat, seq, state->phase);
#endif
if (intr & INTR_RESET) {
/* SCSI bus was reset */
printk(KERN_INFO "external SCSI bus reset detected\n");
writeb(CMD_NOP, ®s->command);
writel(RUN << 16, &dma->control); /* stop dma */
cmd_done(state, DID_RESET << 16);
return;
}
if (intr & INTR_ILL_CMD) {
printk(KERN_ERR "53c94: invalid cmd, intr=%x stat=%x seq=%x phase=%d\n",
intr, stat, seq, state->phase);
cmd_done(state, DID_ERROR << 16);
return;
}
if (stat & STAT_ERROR) {
#if 0
/* XXX these seem to be harmless? */
printk("53c94: bad error, intr=%x stat=%x seq=%x phase=%d\n",
intr, stat, seq, state->phase);
#endif
++mac53c94_errors;
writeb(CMD_NOP + CMD_DMA_MODE, ®s->command);
}
if (cmd == 0) {
printk(KERN_DEBUG "53c94: interrupt with no command active?\n");
return;
}
if (stat & STAT_PARITY) {
printk(KERN_ERR "mac53c94: parity error\n");
cmd_done(state, DID_PARITY << 16);
return;
}
switch (state->phase) {
case selecting:
if (intr & INTR_DISCONNECT) {
/* selection timed out */
cmd_done(state, DID_BAD_TARGET << 16);
return;
}
if (intr != INTR_BUS_SERV + INTR_DONE) {
printk(KERN_DEBUG "got intr %x during selection\n", intr);
cmd_done(state, DID_ERROR << 16);
return;
}
if ((seq & SS_MASK) != SS_DONE) {
printk(KERN_DEBUG "seq step %x after command\n", seq);
cmd_done(state, DID_ERROR << 16);
return;
}
writeb(CMD_NOP, ®s->command);
/* set DMA controller going if any data to transfer */
if ((stat & (STAT_MSG|STAT_CD)) == 0
&& (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) {
nb = cmd->SCp.this_residual;
if (nb > 0xfff0)
nb = 0xfff0;
cmd->SCp.this_residual -= nb;
writeb(nb, ®s->count_lo);
writeb(nb >> 8, ®s->count_mid);
writeb(CMD_DMA_MODE + CMD_NOP, ®s->command);
writel(virt_to_phys(state->dma_cmds), &dma->cmdptr);
writel((RUN << 16) | RUN, &dma->control);
writeb(CMD_DMA_MODE + CMD_XFER_DATA, ®s->command);
state->phase = dataing;
break;
} else if ((stat & STAT_PHASE) == STAT_CD + STAT_IO) {
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:88,代码来源:mac53c94.c
示例2: ac_write
static ssize_t ac_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos)
{
unsigned int NumCard; /* Board number 1 -> 8 */
unsigned int IndexCard; /* Index board number 0 -> 7 */
unsigned char TicCard; /* Board TIC to send */
unsigned long flags; /* Current priority */
struct st_ram_io st_loc;
struct mailbox tmpmailbox;
#ifdef DEBUG
int c;
#endif
DECLARE_WAITQUEUE(wait, current);
if (count != sizeof(struct st_ram_io) + sizeof(struct mailbox)) {
static int warncount = 5;
if (warncount) {
printk(KERN_INFO "Hmmm. write() of Applicom card, length %zd != expected %zd\n",
count, sizeof(struct st_ram_io) + sizeof(struct mailbox));
warncount--;
}
return -EINVAL;
}
if(copy_from_user(&st_loc, buf, sizeof(struct st_ram_io)))
return -EFAULT;
if(copy_from_user(&tmpmailbox, &buf[sizeof(struct st_ram_io)],
sizeof(struct mailbox)))
return -EFAULT;
NumCard = st_loc.num_card; /* board number to send */
TicCard = st_loc.tic_des_from_pc; /* tic number to send */
IndexCard = NumCard - 1;
if((NumCard < 1) || (NumCard > MAX_BOARD) || !apbs[IndexCard].RamIO)
return -EINVAL;
#ifdef DEBUG
printk("Write to applicom card #%d. struct st_ram_io follows:",
IndexCard+1);
for (c = 0; c < sizeof(struct st_ram_io);) {
printk("\n%5.5X: %2.2X", c, ((unsigned char *) &st_loc)[c]);
for (c++; c % 8 && c < sizeof(struct st_ram_io); c++) {
printk(" %2.2X", ((unsigned char *) &st_loc)[c]);
}
}
printk("\nstruct mailbox follows:");
for (c = 0; c < sizeof(struct mailbox);) {
printk("\n%5.5X: %2.2X", c, ((unsigned char *) &tmpmailbox)[c]);
for (c++; c % 8 && c < sizeof(struct mailbox); c++) {
printk(" %2.2X", ((unsigned char *) &tmpmailbox)[c]);
}
}
printk("\n");
#endif
spin_lock_irqsave(&apbs[IndexCard].mutex, flags);
/* Test octet ready correct */
if(readb(apbs[IndexCard].RamIO + DATA_FROM_PC_READY) > 2) {
Dummy = readb(apbs[IndexCard].RamIO + VERS);
spin_unlock_irqrestore(&apbs[IndexCard].mutex, flags);
printk(KERN_WARNING "APPLICOM driver write error board %d, DataFromPcReady = %d\n",
IndexCard,(int)readb(apbs[IndexCard].RamIO + DATA_FROM_PC_READY));
DeviceErrorCount++;
return -EIO;
}
/* Place ourselves on the wait queue */
set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&apbs[IndexCard].FlagSleepSend, &wait);
/* Check whether the card is ready for us */
while (readb(apbs[IndexCard].RamIO + DATA_FROM_PC_READY) != 0) {
Dummy = readb(apbs[IndexCard].RamIO + VERS);
/* It's busy. Sleep. */
spin_unlock_irqrestore(&apbs[IndexCard].mutex, flags);
schedule();
if (signal_pending(current)) {
remove_wait_queue(&apbs[IndexCard].FlagSleepSend,
&wait);
return -EINTR;
}
spin_lock_irqsave(&apbs[IndexCard].mutex, flags);
set_current_state(TASK_INTERRUPTIBLE);
}
/* We may not have actually slept */
set_current_state(TASK_RUNNING);
remove_wait_queue(&apbs[IndexCard].FlagSleepSend, &wait);
writeb(1, apbs[IndexCard].RamIO + DATA_FROM_PC_READY);
//.........这里部分代码省略.........
开发者ID:rcplay,项目名称:snake-os,代码行数:101,代码来源:applicom.c
示例3: ac_interrupt
static irqreturn_t ac_interrupt(int vec, void *dev_instance, struct pt_regs *regs)
{
unsigned int i;
unsigned int FlagInt;
unsigned int LoopCount;
int handled = 0;
// printk("Applicom interrupt on IRQ %d occurred\n", vec);
LoopCount = 0;
do {
FlagInt = 0;
for (i = 0; i < MAX_BOARD; i++) {
/* Skip if this board doesn't exist */
if (!apbs[i].RamIO)
continue;
spin_lock(&apbs[i].mutex);
/* Skip if this board doesn't want attention */
if(readb(apbs[i].RamIO + RAM_IT_TO_PC) == 0) {
spin_unlock(&apbs[i].mutex);
continue;
}
handled = 1;
FlagInt = 1;
writeb(0, apbs[i].RamIO + RAM_IT_TO_PC);
if (readb(apbs[i].RamIO + DATA_TO_PC_READY) > 2) {
printk(KERN_WARNING "APPLICOM driver interrupt err board %d, DataToPcReady = %d\n",
i+1,(int)readb(apbs[i].RamIO + DATA_TO_PC_READY));
DeviceErrorCount++;
}
if((readb(apbs[i].RamIO + DATA_FROM_PC_READY) > 2) &&
(readb(apbs[i].RamIO + DATA_FROM_PC_READY) != 6)) {
printk(KERN_WARNING "APPLICOM driver interrupt err board %d, DataFromPcReady = %d\n",
i+1,(int)readb(apbs[i].RamIO + DATA_FROM_PC_READY));
DeviceErrorCount++;
}
if (readb(apbs[i].RamIO + DATA_TO_PC_READY) == 2) { /* mailbox sent by the card ? */
if (waitqueue_active(&FlagSleepRec)) {
wake_up_interruptible(&FlagSleepRec);
}
}
if (readb(apbs[i].RamIO + DATA_FROM_PC_READY) == 0) { /* ram i/o free for write by pc ? */
if (waitqueue_active(&apbs[i].FlagSleepSend)) { /* process sleep during read ? */
wake_up_interruptible(&apbs[i].FlagSleepSend);
}
}
Dummy = readb(apbs[i].RamIO + VERS);
if(readb(apbs[i].RamIO + RAM_IT_TO_PC)) {
/* There's another int waiting on this card */
spin_unlock(&apbs[i].mutex);
i--;
} else {
spin_unlock(&apbs[i].mutex);
}
}
if (FlagInt)
LoopCount = 0;
else
LoopCount++;
} while(LoopCount < 2);
return IRQ_RETVAL(handled);
}
开发者ID:rcplay,项目名称:snake-os,代码行数:73,代码来源:applicom.c
示例4: readisac
static inline u_char
readisac(void __iomem *adr, u_char off)
{
return readb(adr + ((off & 1) ? 0x2ff : 0x100) + off);
}
开发者ID:robacklin,项目名称:ts7800,代码行数:5,代码来源:teles0.c
示例5: riic_clear_set_bit
static inline void riic_clear_set_bit(struct riic_dev *riic, u8 clear, u8 set, u8 reg)
{
writeb((readb(riic->base + reg) & ~clear) | set, riic->base + reg);
}
开发者ID:avagin,项目名称:linux,代码行数:4,代码来源:i2c-riic.c
示例6: pcidev_ioctl
//.........这里部分代码省略.........
unsigned long address, value;
if (!access_ok(VERIFY_READ, (void *)arg, sizeof(struct pcidev_io_struct)))
return -EFAULT;
io = (struct pcidev_io_struct *)arg;
__get_user(address, &io->address);
__get_user(value, &io->value);
printk(KERN_DEBUG "pcidev: writing I/O port %#x\n", (int)address);
switch(cmd) {
case PCIDEV_IOCTL_WRITE_IO_BYTE:
outb(value, address);
break;
case PCIDEV_IOCTL_WRITE_IO_WORD:
outw(value, address);
break;
case PCIDEV_IOCTL_WRITE_IO_DWORD:
outl(value, address);
break;
}
ret = 0;
break;
}
case PCIDEV_IOCTL_READ_MEM_BYTE:
case PCIDEV_IOCTL_READ_MEM_WORD:
case PCIDEV_IOCTL_READ_MEM_DWORD: {
struct pcidev_io_struct *io;
unsigned long address, value = -1;
if (!access_ok(VERIFY_WRITE, (void *)arg, sizeof(struct pcidev_io_struct)))
return -EFAULT;
io = (struct pcidev_io_struct *)arg;
__get_user(address, &io->address);
printk(KERN_DEBUG "pcidev: reading memory %#x\n", (int)address);
switch(cmd) {
case PCIDEV_IOCTL_READ_MEM_BYTE:
value = readb((unsigned char *)address);
break;
case PCIDEV_IOCTL_READ_MEM_WORD:
value = readw((unsigned short *)address);
break;
case PCIDEV_IOCTL_READ_MEM_DWORD:
value = readl((unsigned int *)address);
break;
}
__put_user(value, &io->value);
ret = 0;
break;
}
case PCIDEV_IOCTL_WRITE_MEM_BYTE:
case PCIDEV_IOCTL_WRITE_MEM_WORD:
case PCIDEV_IOCTL_WRITE_MEM_DWORD: {
struct pcidev_io_struct *io;
unsigned long address, value;
if (!access_ok(VERIFY_READ, (void *)arg, sizeof(struct pcidev_io_struct)))
return -EFAULT;
io = (struct pcidev_io_struct *)arg;
__get_user(address, &io->address);
__get_user(value, &io->value);
printk(KERN_DEBUG "pcidev: writing memory %#x\n", (int)address);
switch(cmd) {
case PCIDEV_IOCTL_WRITE_MEM_BYTE:
writeb(value, (unsigned char *)address);
break;
case PCIDEV_IOCTL_WRITE_MEM_WORD:
writew(value, (unsigned short *)address);
break;
case PCIDEV_IOCTL_WRITE_MEM_DWORD:
writel(value, (unsigned int *)address);
开发者ID:KaSt,项目名称:BochsWatchOS,代码行数:67,代码来源:pcidev.c
示例7: ReadISAC
static u_char
ReadISAC(struct IsdnCardState *cs, u_char offset)
{
return (readb(cs->hw.isurf.isac + offset));
}
开发者ID:JBTech,项目名称:ralink_rt5350,代码行数:5,代码来源:isurf.c
示例8: osl_readb
uint8
osl_readb(volatile uint8 *r)
{
return (readb(r));
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:5,代码来源:linux_osl.c
示例9: nas100d_init
static void __init nas100d_init(void)
{
uint8_t __iomem *f;
int i;
ixp4xx_sys_init();
/* gpio 14 and 15 are _not_ clocks */
*IXP4XX_GPIO_GPCLKR = 0;
nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
nas100d_flash_resource.end =
IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
i2c_register_board_info(0, nas100d_i2c_board_info,
ARRAY_SIZE(nas100d_i2c_board_info));
/*
* This is only useful on a modified machine, but it is valuable
* to have it first in order to see debug messages, and so that
* it does *not* get removed if platform_add_devices fails!
*/
(void)platform_device_register(&nas100d_uart);
platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
pm_power_off = nas100d_power_off;
if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
IRQF_DISABLED | IRQF_TRIGGER_LOW,
"NAS100D reset button", NULL) < 0) {
printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
gpio_to_irq(NAS100D_RB_GPIO));
}
/* The power button on the Iomega NAS100d is on GPIO 14, but
* it cannot handle interrupts on that GPIO line. So we'll
* have to poll it with a kernel timer.
*/
/* Make sure that the power button GPIO is set up as an input */
gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
/* Set the initial value for the power button IRQ handler */
power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
/*
* Map in a portion of the flash and read the MAC address.
* Since it is stored in BE in the flash itself, we need to
* byteswap it if we're in LE mode.
*/
f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000);
if (f) {
for (i = 0; i < 6; i++)
#ifdef __ARMEB__
nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + i);
#else
nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + (i^3));
#endif
iounmap(f);
}
printk(KERN_INFO "NAS100D: Using MAC address %pM for port 0\n",
nas100d_plat_eth[0].hwaddr);
}
开发者ID:007Maximus007,项目名称:htc_kernel_desirec_cfs,代码行数:68,代码来源:nas100d-setup.c
示例10: eicon_isa_load
int
eicon_isa_load(eicon_isa_card *card, eicon_isa_codebuf *cb) {
eicon_isa_boot *boot;
int tmp;
int timeout;
int j;
eicon_isa_codebuf cbuf;
unsigned char *code;
unsigned char *p;
if (copy_from_user(&cbuf, cb, sizeof(eicon_isa_codebuf)))
return -EFAULT;
if (!(code = kmalloc(cbuf.firmware_len, GFP_KERNEL))) {
printk(KERN_WARNING "eicon_isa_load: Couldn't allocate code buffer\n");
return -ENOMEM;
}
if (copy_from_user(code, &cb->code, cbuf.firmware_len)) {
kfree(code);
return -EFAULT;
}
boot = &card->shmem->boot;
if ((!card->ivalid) && card->master) {
card->irqprobe = 1;
/* Check for valid IRQ */
if ((card->irq < 0) || (card->irq > 15) ||
(!((1 << card->irq) & eicon_isa_valid_irq[card->type & 0x0f]))) {
printk(KERN_WARNING "eicon_isa_load: illegal irq: %d\n", card->irq);
eicon_isa_release_shmem(card);
kfree(code);
return -EINVAL;
}
/* Register irq */
if (!request_irq(card->irq, &eicon_irq, 0, "Eicon ISA ISDN", card))
card->ivalid = 1;
else {
printk(KERN_WARNING "eicon_isa_load: irq %d already in use.\n",
card->irq);
eicon_isa_release_shmem(card);
kfree(code);
return -EBUSY;
}
}
tmp = readb(&boot->msize);
if (tmp != 8 && tmp != 16 && tmp != 24 &&
tmp != 32 && tmp != 48 && tmp != 60) {
printk(KERN_WARNING "eicon_isa_load: invalid memsize\n");
eicon_isa_release_shmem(card);
return -EIO;
}
eicon_isa_printpar(card);
/* Download firmware */
printk(KERN_INFO "%s %dkB, loading firmware ...\n",
eicon_ctype_name[card->type],
tmp * 16);
tmp = cbuf.firmware_len >> 8;
p = code;
while (tmp--) {
memcpy_toio(&boot->b, p, 256);
writeb(1, &boot->ctrl);
timeout = jiffies + HZ / 10;
while (time_before(jiffies, timeout)) {
if (readb(&boot->ctrl) == 0)
break;
SLEEP(2);
}
if (readb(&boot->ctrl)) {
printk(KERN_WARNING "eicon_isa_load: download timeout at 0x%x\n", p-code);
eicon_isa_release(card);
kfree(code);
return -EIO;
}
p += 256;
}
kfree(code);
/* Initialize firmware parameters */
memcpy_toio(&card->shmem->c[8], &cbuf.tei, 14);
memcpy_toio(&card->shmem->c[32], &cbuf.oad, 96);
memcpy_toio(&card->shmem->c[128], &cbuf.oad, 96);
/* Start firmware, wait for signature */
writeb(2, &boot->ctrl);
timeout = jiffies + (5*HZ);
while (time_before(jiffies, timeout)) {
if (readw(&boot->signature) == 0x4447)
break;
SLEEP(2);
}
if (readw(&boot->signature) != 0x4447) {
printk(KERN_WARNING "eicon_isa_load: firmware selftest failed %04x\n",
readw(&boot->signature));
eicon_isa_release(card);
return -EIO;
//.........这里部分代码省略.........
开发者ID:jameshilliard,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:101,代码来源:eicon_isa.c
示例11: rbtx4939_update_ioc_pen
static void __init rbtx4939_update_ioc_pen(void)
{
__u64 pcfg = ____raw_readq(&tx4939_ccfgptr->pcfg);
__u64 ccfg = ____raw_readq(&tx4939_ccfgptr->ccfg);
__u8 pe1 = readb(rbtx4939_pe1_addr);
__u8 pe2 = readb(rbtx4939_pe2_addr);
__u8 pe3 = readb(rbtx4939_pe3_addr);
if (pcfg & TX4939_PCFG_ATA0MODE)
pe1 |= RBTX4939_PE1_ATA(0);
else
pe1 &= ~RBTX4939_PE1_ATA(0);
if (pcfg & TX4939_PCFG_ATA1MODE) {
pe1 |= RBTX4939_PE1_ATA(1);
pe1 &= ~(RBTX4939_PE1_RMII(0) | RBTX4939_PE1_RMII(1));
} else {
pe1 &= ~RBTX4939_PE1_ATA(1);
if (pcfg & TX4939_PCFG_ET0MODE)
pe1 |= RBTX4939_PE1_RMII(0);
else
pe1 &= ~RBTX4939_PE1_RMII(0);
if (pcfg & TX4939_PCFG_ET1MODE)
pe1 |= RBTX4939_PE1_RMII(1);
else
pe1 &= ~RBTX4939_PE1_RMII(1);
}
if (ccfg & TX4939_CCFG_PTSEL)
pe3 &= ~(RBTX4939_PE3_VP | RBTX4939_PE3_VP_P |
RBTX4939_PE3_VP_S);
else {
__u64 vmode = pcfg &
(TX4939_PCFG_VSSMODE | TX4939_PCFG_VPSMODE);
if (vmode == 0)
pe3 &= ~(RBTX4939_PE3_VP | RBTX4939_PE3_VP_P |
RBTX4939_PE3_VP_S);
else if (vmode == TX4939_PCFG_VPSMODE) {
pe3 |= RBTX4939_PE3_VP_P;
pe3 &= ~(RBTX4939_PE3_VP | RBTX4939_PE3_VP_S);
} else if (vmode == TX4939_PCFG_VSSMODE) {
pe3 |= RBTX4939_PE3_VP | RBTX4939_PE3_VP_S;
pe3 &= ~RBTX4939_PE3_VP_P;
} else {
pe3 |= RBTX4939_PE3_VP | RBTX4939_PE3_VP_P;
pe3 &= ~RBTX4939_PE3_VP_S;
}
}
if (pcfg & TX4939_PCFG_SPIMODE) {
if (pcfg & TX4939_PCFG_SIO2MODE_GPIO)
pe2 &= ~(RBTX4939_PE2_SIO2 | RBTX4939_PE2_SIO0);
else {
if (pcfg & TX4939_PCFG_SIO2MODE_SIO2) {
pe2 |= RBTX4939_PE2_SIO2;
pe2 &= ~RBTX4939_PE2_SIO0;
} else {
pe2 |= RBTX4939_PE2_SIO0;
pe2 &= ~RBTX4939_PE2_SIO2;
}
}
if (pcfg & TX4939_PCFG_SIO3MODE)
pe2 |= RBTX4939_PE2_SIO3;
else
pe2 &= ~RBTX4939_PE2_SIO3;
pe2 &= ~RBTX4939_PE2_SPI;
} else {
pe2 |= RBTX4939_PE2_SPI;
pe2 &= ~(RBTX4939_PE2_SIO3 | RBTX4939_PE2_SIO2 |
RBTX4939_PE2_SIO0);
}
if ((pcfg & TX4939_PCFG_I2SMODE_MASK) == TX4939_PCFG_I2SMODE_GPIO)
pe2 |= RBTX4939_PE2_GPIO;
else
pe2 &= ~RBTX4939_PE2_GPIO;
writeb(pe1, rbtx4939_pe1_addr);
writeb(pe2, rbtx4939_pe2_addr);
writeb(pe3, rbtx4939_pe3_addr);
}
开发者ID:Herysutrisno,项目名称:mpc5200,代码行数:75,代码来源:setup.c
示例12: eicon_isa_bootload
int
eicon_isa_bootload(eicon_isa_card *card, eicon_isa_codebuf *cb) {
int tmp;
int timeout;
eicon_isa_codebuf cbuf;
unsigned char *code;
eicon_isa_boot *boot;
if (copy_from_user(&cbuf, cb, sizeof(eicon_isa_codebuf)))
return -EFAULT;
/* Allocate code-buffer and copy code from userspace */
if (cbuf.bootstrap_len > 1024) {
printk(KERN_WARNING "eicon_isa_boot: Invalid startup-code size %ld\n",
cbuf.bootstrap_len);
return -EINVAL;
}
if (!(code = kmalloc(cbuf.bootstrap_len, GFP_KERNEL))) {
printk(KERN_WARNING "eicon_isa_boot: Couldn't allocate code buffer\n");
return -ENOMEM;
}
if (copy_from_user(code, &cb->code, cbuf.bootstrap_len)) {
kfree(code);
return -EFAULT;
}
if (card->type == EICON_CTYPE_ISAPRI)
card->ramsize = RAMSIZE_P;
else
card->ramsize = RAMSIZE;
if (check_mem_region(card->physmem, card->ramsize)) {
printk(KERN_WARNING "eicon_isa_boot: memory at 0x%lx already in use.\n",
card->physmem);
kfree(code);
return -EBUSY;
}
request_mem_region(card->physmem, card->ramsize, "Eicon ISA ISDN");
card->shmem = (eicon_isa_shmem *) ioremap(card->physmem, card->ramsize);
#ifdef EICON_MCA_DEBUG
printk(KERN_INFO "eicon_isa_boot: card->ramsize = %d.\n", card->ramsize);
#endif
card->mvalid = 1;
switch(card->type) {
case EICON_CTYPE_S:
case EICON_CTYPE_SX:
case EICON_CTYPE_SCOM:
case EICON_CTYPE_QUADRO:
case EICON_CTYPE_ISABRI:
card->intack = (__u8 *)card->shmem + INTACK;
card->startcpu = (__u8 *)card->shmem + STARTCPU;
card->stopcpu = (__u8 *)card->shmem + STOPCPU;
break;
case EICON_CTYPE_S2M:
case EICON_CTYPE_ISAPRI:
card->intack = (__u8 *)card->shmem + INTACK_P;
card->startcpu = (__u8 *)card->shmem + STARTCPU_P;
card->stopcpu = (__u8 *)card->shmem + STOPCPU_P;
break;
default:
printk(KERN_WARNING "eicon_isa_boot: Invalid card type %d\n", card->type);
eicon_isa_release_shmem(card);
kfree(code);
return -EINVAL;
}
/* clear any pending irq's */
readb(card->intack);
#ifdef CONFIG_MCA
if (MCA_bus) {
if (card->type == EICON_CTYPE_SCOM) {
outb_p(0,card->io+1);
}
else {
printk(KERN_WARNING "eicon_isa_boot: Card type not supported yet.\n");
eicon_isa_release_shmem(card);
return -EINVAL;
};
#ifdef EICON_MCA_DEBUG
printk(KERN_INFO "eicon_isa_boot: card->io = %x.\n", card->io);
printk(KERN_INFO "eicon_isa_boot: card->irq = %d.\n", (int)card->irq);
#endif
}
#else
/* set reset-line active */
writeb(0, card->stopcpu);
#endif /* CONFIG_MCA */
/* clear irq-requests */
writeb(0, card->intack);
readb(card->intack);
/* Copy code into card */
memcpy_toio(&card->shmem->c, code, cbuf.bootstrap_len);
/* Check for properly loaded code */
if (!check_signature((unsigned long)&card->shmem->c, code, 1020)) {
printk(KERN_WARNING "eicon_isa_boot: Could not load startup-code\n");
eicon_isa_release_shmem(card);
//.........这里部分代码省略.........
开发者ID:jameshilliard,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:101,代码来源:eicon_isa.c
示例13: writew
if (!(status & STATUS_DRQ))
continue;
word = *addr | *(addr + 1) << 8;
writew(word, info->base + CUMANASCSI2_PSEUDODMA);
addr += 2;
length -= 2;
}
#else
printk ("PSEUDO_OUT???\n");
#endif
else {
if (transfer && (transfer & 255)) {
while (length >= 256) {
unsigned int status = readb(info->base + CUMANASCSI2_STATUS);
if (status & STATUS_INT)
return;
if (!(status & STATUS_DRQ))
continue;
readsw(info->base + CUMANASCSI2_PSEUDODMA,
addr, 256 >> 1);
addr += 256;
length -= 256;
}
}
while (length > 0) {
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:30,代码来源:cumana_2.c
示例14: samsung_init
static int __init samsung_init(void)
{
struct device *parent=NULL;
if (use_sabi && !dmi_check_system(samsung_sabi_dmi_table) && !force){
printk(KERN_ERR "Samsung-backlight is intended to work only with Samsung laptops.\n");
return -ENODEV;
}
if (!use_sabi && !dmi_check_system(samsung_dmi_table) && !force){
printk(KERN_ERR "Sorry, your laptop is not supported. Try use_sabi=1\n");
return -ENODEV;
}
if(use_sabi){
const char *test_str = "[email protected]";
int pos;
int index = 0;
void __iomem *base;
unsigned int ifaceP;
mutex_init(&sabi_mutex);
f0000_segment = ioremap(0xf0000, 0xffff);
if (!f0000_segment) {
printk(KERN_ERR "Samsung-backlight: Can't map the segment at 0xf0000\n");
return -EINVAL;
}
printk(KERN_INFO "Samsung-backlight: checking for SABI support.\n");
/* Try to find the signature "[email protected]" in memory to find the header */
base = f0000_segment;
for (pos = 0; pos < 0xffff; ++pos) {
char temp = readb(base + pos);
if (temp == test_str[index]) {
if (5 == index++)
break;
}
else {
index = 0;
}
}
if (pos == 0xffff) {
printk(KERN_INFO "Samsung-backlight: SABI is not supported\n");
iounmap(f0000_segment);
return -EINVAL;
}
sabi = (struct sabi_header __iomem *)(base + pos + 1);
printk(KERN_INFO "Samsung-backlight: SABI is supported (%x)\n", pos + 0xf0000 - 6);
if (debug) {
printk(KERN_DEBUG "SABI header:\n");
printk(KERN_DEBUG " SMI Port Number = 0x%04x\n", readw(&sabi->port));
printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n", readb(&sabi->iface_func));
printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n", readb(&sabi->en_mem));
printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n", readb(&sabi->re_mem));
printk(KERN_DEBUG " SABI data offset = 0x%04x\n", readw(&sabi->data_offset));
printk(KERN_DEBUG " SABI data segment = 0x%04x\n", readw(&sabi->data_segment));
printk(KERN_DEBUG " BIOS interface version = 0x%02x\n", readb(&sabi->bios_ifver));
printk(KERN_DEBUG " KBD Launcher string = 0x%02x\n", readb(&sabi->launcher_string));
}
/* Get a pointer to the SABI Interface */
ifaceP = (readw(&sabi->data_segment) & 0x0ffff) << 4;
ifaceP += readw(&sabi->data_offset) & 0x0ffff;
sabi_iface = (struct sabi_interface __iomem *)ioremap(ifaceP, 16);
if (!sabi_iface) {
printk(KERN_ERR "Samsung-backlight: Can't remap %x\n", ifaceP);
iounmap(f0000_segment);
return -EINVAL;
}
if (debug) {
printk(KERN_DEBUG "Samsung-backlight: SABI Interface = %p\n", sabi_iface);
}
}else{
/*
* The Samsung N120, N130, and NC10 use pci device id 0x27ae, while the
* NP-Q45 uses 0x2a02. Odds are we might need to add more to the
* list over time...
*/
int pcidevids[]={0x27ae,0x2a02,0x2a42,0xa011,0};
int i;
for(i=0, pci_device=NULL;pcidevids[i]>0 && pci_device==NULL;++i)
pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, pcidevids[i], NULL);
if (!pci_device)
return -ENODEV;
parent=&pci_device->dev;
}
/* create a backlight device to talk to this one */
#if LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,34)
backlight_device = backlight_device_register("samsung",
parent,
NULL, &backlight_ops,NULL);
#else
backlight_device = backlight_device_register("samsung",
parent,
NULL, &backlight_ops);
//.........这里部分代码省略.........
开发者ID:nieboe,项目名称:samsung-backlight,代码行数:101,代码来源:samsung-backlight.c
示例15: c101_run
static int __init c101_run(unsigned long irq, unsigned long winbase)
{
struct net_device *dev;
hdlc_device *hdlc;
card_t *card;
int result;
if (irq<3 || irq>15 || irq == 6) /* FIXME */ {
pr_err("invalid IRQ value\n");
return -ENODEV;
}
if (winbase < 0xC0000 || winbase > 0xDFFFF || (winbase & 0x3FFF) !=0) {
pr_err("invalid RAM value\n");
return -ENODEV;
}
card = kzalloc(sizeof(card_t), GFP_KERNEL);
if (card == NULL) {
pr_err("unable to allocate memory\n");
return -ENOBUFS;
}
card->dev = alloc_hdlcdev(card);
if (!card->dev) {
pr_err("unable to allocate memory\n");
kfree(card);
return -ENOBUFS;
}
if (request_irq(irq, sca_intr, 0, devname, card)) {
pr_err("could not allocate IRQ\n");
c101_destroy_card(card);
return -EBUSY;
}
card->irq = irq;
if (!request_mem_region(winbase, C101_MAPPED_RAM_SIZE, devname)) {
pr_err("could not request RAM window\n");
c101_destroy_card(card);
return -EBUSY;
}
card->phy_winbase = winbase;
card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE);
if (!card->win0base) {
pr_err("could not map I/O address\n");
c101_destroy_card(card);
return -EFAULT;
}
card->tx_ring_buffers = TX_RING_BUFFERS;
card->rx_ring_buffers = RX_RING_BUFFERS;
card->buff_offset = C101_WINDOW_SIZE; /* Bytes 1D00-1FFF reserved */
readb(card->win0base + C101_PAGE); /* Resets SCA? */
udelay(100);
writeb(0, card->win0base + C101_PAGE);
writeb(0, card->win0base + C101_DTR); /* Power-up for RAM? */
sca_init(card, 0);
dev = port_to_dev(card);
hdlc = dev_to_hdlc(dev);
spin_lock_init(&card->lock);
dev->irq = irq;
dev->mem_start = winbase;
dev->mem_end = winbase + C101_MAPPED_RAM_SIZE - 1;
dev->tx_queue_len = 50;
dev->netdev_ops = &c101_ops;
hdlc->attach = sca_attach;
hdlc->xmit = sca_xmit;
card->settings.clock_type = CLOCK_EXT;
result = register_hdlc_device(dev);
if (result) {
pr_warn("unable to register hdlc device\n");
c101_destroy_card(card);
return result;
}
sca_init_port(card); /* Set up C101 memory */
set_carrier(card);
netdev_info(dev, "Moxa C101 on IRQ%u, using %u TX + %u RX packets rings\n",
card->irq, card->tx_ring_buffers, card->rx_ring_buffers);
*new_card = card;
new_card = &card->next_card;
return 0;
}
开发者ID:303750856,项目名称:linux-3.1,代码行数:91,代码来源:c101.c
示例16: sabi_exec_command
int sabi_exec_command(u8 command, u8 data, struct sabi_retval *sretval)
{
int retval = 0;
mutex_lock(&sabi_mutex);
/* enable memory to be able to write to it */
outb(readb(&sabi->en_mem), readw(&sabi->port));
/* write out the command */
writew(0x5843, &sabi_iface->mainfunc);
writew(command, &sabi_iface->subfunc);
writeb(0, &sabi_iface->complete);
writeb(data, &sabi_iface->retval[0]);
outb(readb(&sabi->iface_func), readw(&sabi->port));
/* sleep for a bit to let the command complete */
msleep(10);
/* write protect memory to make it safe */
outb(readb(&sabi->re_mem), readw(&sabi->port));
/* see if the command actually succeeded */
if (readb(&sabi_iface->complete) == 0xaa &&
readb(&sabi_iface->retval[0]) != 0xff) {
if (sretval) {
sretval->retval[0] = readb(&sabi_iface->retval[0]);
sretval->retval[1] = readb(&sabi_iface->retval[1]);
sretval->retval[2] = readb(&sabi_iface->retval[2]);
sretval->retval[3] = readb(&sabi_iface->retval[3]);
}
}
else {
/* Something bad happened, so report it and error out */
printk(KERN_WARNING "SABI command 0x%02x failed with completion flag 0x%02x and output 0x%02x\n",
command, readb(&sabi_iface->complete),
readb(&sabi_iface->retval[0]));
retval = -EINVAL;
}
mutex_unlock(&sabi_mutex);
return retval;
}
开发者ID:nieboe,项目名称:samsung-backlight,代码行数:42,代码来源:samsung-backlight.c
示例17: bgpio_read8
static unsigned long bgpio_read8(void __iomem *reg)
{
return readb(reg);
}
开发者ID:BharathKrish,项目名称:HybridMem,代码行数:4,代码来源:gpio-generic.c
示例18: os_readb
HPT_U8 os_readb (void *addr) { return readb(addr); }
开发者ID:AdamJacobMuller,项目名称:rr62x,代码行数:1,代码来源:os_linux.c
示例19: ReadISAR
static u_char
ReadISAR(struct IsdnCardState *cs, int mode, u_char offset)
{
return(readb(cs->hw.isurf.isar + offset));
}
开发者ID:JBTech,项目名称:ralink_rt5350,代码行数:5,代码来源:isurf.c
示例20: rtc_read
static noinline uint8_t
rtc_read(enum ds1511reg reg)
{
return readb(ds1511_base + (reg * reg_spacing));
}
开发者ID:03199618,项目名称:linux,代码行数:5,代码来源:rtc-ds1511.c
注:本文中的readb函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论