本文整理汇总了C++中outportb函数的典型用法代码示例。如果您正苦于以下问题:C++ outportb函数的具体用法?C++ outportb怎么用?C++ outportb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了outportb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nosound
void nosound() {
unsigned short tmp = (inportb(0x61) & 0xFC);
outportb(0x61, tmp);
}
示例2: outportb
byte huge *getdump (long *size,void (* func)(double))
/***********
* Describe : принять дамп памяти прибора в память ЭВМ
* Params : word *size - размер принятых данных (в байтах), меньше чем
* : размер выделенной памяти, так как он выровнен
* : на границу 1024 байта
* : PFV func - функция для отображения считывания, ей
* : передаем процент считанной информации
* Return : byte huge* - указатель на буфер, куда записаны данные
* Call : input,waitstart,setaddr,getKbyte,bioscom
***********/
{ /* i-текущий адрес */
unsigned long volume,i_long;
uint i=0,Imax=1024; /* Imax-макс. адрес */
byte empty,bufer[1024]; /* */
int err=0,rpt=0; /* */
byte huge *ppm=NULL,huge *cur=NULL; /* указатель на буфер */
// считываем базовый адрес порта
base_addr = *((unsigned far *)((unsigned far *)0x00400000L+connect_port));
if (base_addr==0) // СОМ1 в 40:00 СОМ2 в 42:00
{printf("\nCOM-%d is absent!",connect_port);
return 0;
}
// bioscom (0,SETTINGS,connect_port); /* инициализируем COM */
outportb (base_addr+3,0x83); // 8byt 1stop N
outportb (base_addr,12); // скорость обмена 115200/12=9600
outportb (base_addr+1,0);
outportb (base_addr+3,0x03); // конец установки скорости
empty = inportb (base_addr+4);
outportb (base_addr+4,0); // Запрет прерывания от порта
for (i_long=0L;i_long<Imax;i_long+=512L,cur=(byte huge *)cur+1024,i=(uint)i_long)
{
if (func!=NULL) /* */
func ((double)((double)i_long/(double)Imax)); /* рисуем прогресс */
sleep (1);
do /* */
{ /* */
setaddr(i); /* посылаем адрес начала */
err=waitstart(); /* ждем строки "STRT" */
if (err==0) /* если не ошибка то */
err=input(&empty); /* принимаем пустой байт */
if (err==0) /* если не ошибка и если */
if (i==0) /* первый Кбайт то */
err=getKbyte(bufer); /* принимаем в буфер */
else /* иначе */
{
err=getKbyte(cur); /* принимаем в назначение */
if (*bufer!=*ppm)
{
printf ("\n There is problem, count = %u",(uint)i);
abort ();
}
}
if (err != 0) /* если ошибка */
{ /* */
rpt++; /* число повторов */
if (rpt>REPEATS) /* */
{ /* */
if (ppm!=NULL) /* освобождаем память */
farfree ((byte far *)ppm); /* если выделена */
printf("\nCommunication ERROR %X",(unsigned)err);
return (NULL); /* возвращаем ошибка */
} /* */
} /* */
} /* */
while (err!=0); /* */
/* */
if (i==0) /* если первый Кбайт */
{ /* то */
Imax = (uint)bufer[8]+bufer[9]*256; /* вычисляем Imax */
*size = (long)Imax*2L; /* размер в байтах */
volume = (unsigned long)(*size)+1024; /* выделяем 128 Кбайт */
ppm=(byte huge*) farcalloc(volume,sizeof(byte));/* выделяем память */
cur = ppm;
if (ppm==NULL)
{
printf ("\n Imax = %u, size = %ld",Imax,(*size));
printf ("\n No enough memory! Function GETDUMP. ");
printf ("\n %ul bytes free. ",farcoreleft());
abort ();
}
reportmemory(getmaxx(),getmaxy()-textheight("X")-5);
memcpy ((byte *)ppm,bufer,1024); /* копируем из буфера */
} /* */
} /* */
if (func!=NULL) /* */
func ((double)1.0); /* рисуем прогресс */
return ((byte huge*) ppm); /* */
} /* */
示例3: nic_8019_rx
irqreturn_t nic_8019_rx(int irq, void *dev_id, struct pt_regs *regs)
{
u8 RxPageBeg, RxPageEnd;
u8 RxNextPage;
u8 RxStatus;
u16 *data,temp;
u16 i, RxLength,RxLen;
struct sk_buff *skb;
struct net_device *dev = (struct net_device *) dev_id;
struct nic_8019_priv *priv = (struct nic_8019_priv *) dev->priv;
TRACE("TX/RX Interupt!\n");
spin_lock(&priv->lock);
SetRegPage(0);
outportb(BNRY, rBNRY); //???
RxStatus = inportb(ISR);
if (RxStatus & 2) {
outportb(ISR, 0x2); //clr TX interupt
priv->stats.tx_packets++;
TRACE("transmit one packet complete!\n");
}
if (RxStatus & 1) {
TRACE("Receivex packet....\n");
outportb(ISR, 0x1); //clr Rx interupt
SetRegPage(1);
RxPageEnd = inportb(CURR);
SetRegPage(0);
RxPageBeg = rBNRY+1;
if(RxPageBeg>=RPSTOP)
RxPageBeg = RPSTART;
outportb(BaseAddr, 0x22); // stop remote dma
//outport(RSAR0, RxPageBeg<<8);
//outport(RBCR0, 256);
outportb(RSAR0, 0);
outportb(RSAR1, RxPageBeg);
outportb(RBCR0, 4);
outportb(RBCR1, 0);
outportb(BaseAddr, 0xa);
#ifdef RTL8019_OP_16
temp = inportw(RWPORT);
RxNextPage = temp>>8;
RxStatus = temp&0xff;
RxLength = inportw(RWPORT);
#else
RxStatus = inportb(RWPORT);
RxNextPage = inportb(RWPORT);
RxLength = inportb(RWPORT);
RxLength |= inportb(RWPORT)<<8;
#endif
TRACE("\nRxBeg = %x, RxEnd = %x, nextpage = %x, size = %i\n", RxPageBeg, RxPageEnd, RxNextPage, RxLength);
RxLength -= 4;
if (RxLength>ETH_FRAME_LEN) {
if (RxPageEnd==RPSTART)
rBNRY = RPSTOP-1;
else
rBNRY = RxPageEnd-1;
outportb(BNRY, rBNRY);
TRACE("RxLength more long than %x\n", ETH_FRAME_LEN);
return IRQ_HANDLED;
}
skb = dev_alloc_skb(RxLength+2);
if (!skb) {
TRACE("Rtl8019as eth: low on mem - packet dropped\n");
priv->stats.rx_dropped++;
return IRQ_HANDLED;
}
skb->dev = dev;
skb_reserve(skb, 2);
skb_put(skb, RxLength);
data = ( u16 *)skb->data;
// eth_copy_and_sum(skb, data, len, 0);
outportb(RSAR0, 4);
outportb(RSAR1, RxPageBeg);
outportb(RBCR0, RxLength);
outportb(RBCR1, RxLength>>8);
outportb(BaseAddr, 0xa);
#ifdef RTL8019_OP_16
i = 2;
data -= 2;
RxLen=(RxLength+1)/2;
#else
i = 4;
data -= 4;
RxLen=RxLength;
#endif
for(; RxLen--;) {
#ifdef RTL8019_OP_16
static const int cmp_val = 0x7f;
#else
static const int cmp_val = 0xff;
#endif
//.........这里部分代码省略.........
示例4: speaker_on
void speaker_on()
{
char val= inportb(SPEAKER_CTRL);
outportb(SPEAKER_CTRL, val | SPEAKER_ENABLE | TIMER2_ENABLE);
}
示例5: IRQ7ISR
void IRQ7ISR() {
SemPostISR(print_sid); // perform SemPostISR directly from here
outportb(0x20, 0x67); // 0x20 is PIC control, 0x67 dismisses IRQ 7
}
示例6: floppy_command
void floppy_command(uint8_t command)
{
floppy_wait();
outportb(FLOPPY_FIRST + DATA_FIFO, command);
}
示例7: main
//.........这里部分代码省略.........
}
if(!onlyTracks.empty())
{
size_t count = adl_trackCount(myDevice);
for(size_t track = 0; track < count; ++track)
adl_setTrackOptions(myDevice, track, ADLMIDI_TrackOption_Off);
std::fprintf(stdout, " - Only tracks:");
for(size_t i = 0, n = onlyTracks.size(); i < n; ++i)
{
size_t track = onlyTracks[i];
adl_setTrackOptions(myDevice, track, ADLMIDI_TrackOption_On);
std::fprintf(stdout, " %lu", (unsigned long)track);
}
std::fprintf(stdout, "\n");
}
std::fprintf(stdout, " - File [%s] opened!\n", musPath.c_str());
flushout(stdout);
#ifndef HARDWARE_OPL3
signal(SIGINT, sighandler);
signal(SIGTERM, sighandler);
# if !defined(_WIN32) && !defined(__WATCOMC__)
signal(SIGHUP, sighandler);
# endif
#else//HARDWARE_OPL3
static const unsigned NewTimerFreq = 209;
unsigned TimerPeriod = 0x1234DDul / NewTimerFreq;
#ifdef __DJGPP__
//disable();
outportb(0x43, 0x34);
outportb(0x40, TimerPeriod & 0xFF);
outportb(0x40, TimerPeriod >> 8);
//enable();
#endif//__DJGPP__
#ifdef __WATCOMC__
std::fprintf(stdout, " - Initializing BIOS timer...\n");
flushout(stdout);
//disable();
outp(0x43, 0x34);
outp(0x40, TimerPeriod & 0xFF);
outp(0x40, TimerPeriod >> 8);
//enable();
std::fprintf(stdout, " - Ok!\n");
flushout(stdout);
#endif//__WATCOMC__
unsigned long BIOStimer_begin = BIOStimer;
double tick_delay = 0.0;
#endif//HARDWARE_OPL3
double total = adl_totalTimeLength(myDevice);
#ifndef OUTPUT_WAVE_ONLY
double loopStart = adl_loopStartTime(myDevice);
double loopEnd = adl_loopEndTime(myDevice);
char totalHMS[25];
char loopStartHMS[25];
char loopEndHMS[25];
secondsToHMSM(total, totalHMS, 25);
if(loopStart >= 0.0 && loopEnd >= 0.0)
{
示例8: outportb
void Speaker::on(unsigned int pitch) //Enables the speaker and sets frequency
{
pit.init(pitch, 2);
outportb(0x61, (inportb(0x61) | 3));
}
示例9: kbdReset
//reset
void kbdReset()
{
outportb(ATKBD_DATA,0xF6);
inportb(ATKBD_DATA); // should be ACK
}
示例10: __wss_detect
static boolean __wss_detect()
{
/* First find the port number */
if (!wss.port) {
static unsigned int wss_ports[] =
{ 0x32c, 0x530, 0x604, 0xE80, 0xF40 };
int i;
for (i = 0; i < 5; i++) {
wss.port = wss_ports[i];
if (__wss_ping())
break;
}
if (i < 0) {
wss.port = 0;
return FALSE;
}
}
/* Now disable output */
wss_output(FALSE);
/* Detect the DMA channel */
if (!wss.dma) {
static int __dma[] = { 0, 1, 3 };
int i;
/* Enable playback IRQ */
__wss_regbit_set(WSSR_PIN_CTRL, WSSM_IRQ_ENABLE);
__wss_outreg(WSSR_IRQ_STATUS, WSSM_PLAYBACK_IRQ);
/* Start a short DMA transfer and check if DMA count is zero */
for (i = 0; i < 3; i++) {
unsigned int timer, status, freq = 44100;
wss.dma = __dma[i];
dma_disable(wss.dma);
dma_set_mode(wss.dma, DMA_MODE_WRITE);
dma_clear_ff(wss.dma);
dma_set_count(wss.dma, 10);
dma_enable(wss.dma);
/* Clear IRQ status */
outportb(WSS_STATUS, 0);
__wss_setformat(__wss_getrate(&freq));
__wss_outreg(WSSR_COUNT_LOW, 1);
__wss_outreg(WSSR_COUNT_HIGH, 0);
/* Tell codec to start transfer */
__wss_regbit_set(WSSR_IFACE_CTRL, WSSM_PLAYBACK_ENABLE);
_farsetsel(_dos_ds);
timer = _farnspeekl(0x46c);
while (_farnspeekl(0x46c) - timer <= 2)
if (dma_get_count(wss.dma) == 0)
break;
__wss_regbit_reset(WSSR_IFACE_CTRL, WSSM_PLAYBACK_ENABLE);
dma_disable(wss.dma);
/* Now check if DMA transfer count is zero and an IRQ is pending */
status = inportb(WSS_STATUS);
outportb(WSS_STATUS, 0);
if ((dma_get_count(wss.dma) == 0) && (status & WSSM_INT))
break;
wss.dma = 0;
}
if (!wss.dma)
return FALSE;
}
/* Now detect the IRQ number */
if (!wss.irq) {
unsigned int i, irqmask, freq = 5510;
unsigned long timer, delta = 0x7fffffff;
/* IRQ can be one of 2,3,5,7,10 */
irq_detect_start(0x04ac, __wss_irq_irqdetect);
dma_disable(wss.dma);
dma_set_mode(wss.dma, DMA_MODE_WRITE | DMA_MODE_AUTOINIT);
dma_clear_ff(wss.dma);
dma_set_count(wss.dma, 1);
dma_enable(wss.dma);
__wss_setformat(__wss_getrate(&freq));
/* Clear IRQ status */
outportb(WSS_STATUS, 0);
__wss_outreg(WSSR_COUNT_LOW, 0);
__wss_outreg(WSSR_COUNT_HIGH, 0);
/* Prepare timeout counter */
_farsetsel(_dos_ds);
timer = _farnspeekl(0x46c);
while (timer == _farnspeekl(0x46c));
timer = _farnspeekl(0x46c);
//.........这里部分代码省略.........
示例11: irq_ack
void irq_ack(size_t irq_no) {
if (irq_no >= 8) {
outportb(0xA0, 0x20);
}
outportb(0x20, 0x20);
}
示例12: init_rtl
int init_rtl(void) {
if (rtl_device_pci) {
debug_print(NOTICE, "Located an RTL 8139: 0x%x\n", rtl_device_pci);
uint16_t command_reg = pci_read_field(rtl_device_pci, PCI_COMMAND, 4);
debug_print(NOTICE, "COMMAND register before: 0x%4x\n", command_reg);
if (command_reg & (1 << 2)) {
debug_print(NOTICE, "Bus mastering already enabled.\n");
} else {
command_reg |= (1 << 2); /* bit 2 */
debug_print(NOTICE, "COMMAND register after: 0x%4x\n", command_reg);
pci_write_field(rtl_device_pci, PCI_COMMAND, 4, command_reg);
command_reg = pci_read_field(rtl_device_pci, PCI_COMMAND, 4);
debug_print(NOTICE, "COMMAND register after: 0x%4x\n", command_reg);
}
rtl_irq = pci_get_interrupt(rtl_device_pci);
debug_print(NOTICE, "Interrupt Line: %x\n", rtl_irq);
irq_install_handler(rtl_irq, rtl_irq_handler, "rtl8139");
uint32_t rtl_bar0 = pci_read_field(rtl_device_pci, PCI_BAR0, 4);
uint32_t rtl_bar1 = pci_read_field(rtl_device_pci, PCI_BAR1, 4);
debug_print(NOTICE, "BAR0: 0x%8x\n", rtl_bar0);
debug_print(NOTICE, "BAR1: 0x%8x\n", rtl_bar1);
rtl_iobase = 0x00000000;
if (rtl_bar0 & 0x00000001) {
rtl_iobase = rtl_bar0 & 0xFFFFFFFC;
} else {
debug_print(NOTICE, "This doesn't seem right! RTL8139 should be using an I/O BAR; this looks like a memory bar.");
}
debug_print(NOTICE, "RTL iobase: 0x%x\n", rtl_iobase);
rx_wait = list_create();
debug_print(NOTICE, "Determining mac address...\n");
for (int i = 0; i < 6; ++i) {
mac[i] = inports(rtl_iobase + RTL_PORT_MAC + i);
}
debug_print(NOTICE, "%2x:%2x:%2x:%2x:%2x:%2x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
debug_print(NOTICE, "Enabling RTL8139.\n");
outportb(rtl_iobase + RTL_PORT_CONFIG, 0x0);
debug_print(NOTICE, "Resetting RTL8139.\n");
outportb(rtl_iobase + RTL_PORT_CMD, 0x10);
while ((inportb(rtl_iobase + 0x37) & 0x10) != 0) { }
debug_print(NOTICE, "Done resetting RTL8139.\n");
for (int i = 0; i < 5; ++i) {
rtl_tx_buffer[i] = (void*)kvmalloc_p(0x1000, &rtl_tx_phys[i]);
for (int j = 0; j < 60; ++j) {
rtl_tx_buffer[i][j] = 0xF0;
}
}
rtl_rx_buffer = (uint8_t *)kvmalloc_p(0x3000, &rtl_rx_phys);
memset(rtl_rx_buffer, 0x00, 0x3000);
debug_print(NOTICE, "Buffers:\n");
debug_print(NOTICE, " rx 0x%x [phys 0x%x and 0x%x and 0x%x]\n", rtl_rx_buffer, rtl_rx_phys, map_to_physical((uintptr_t)rtl_rx_buffer + 0x1000), map_to_physical((uintptr_t)rtl_rx_buffer + 0x2000));
for (int i = 0; i < 5; ++i) {
debug_print(NOTICE, " tx 0x%x [phys 0x%x]\n", rtl_tx_buffer[i], rtl_tx_phys[i]);
}
debug_print(NOTICE, "Initializing receive buffer.\n");
outportl(rtl_iobase + RTL_PORT_RBSTART, rtl_rx_phys);
debug_print(NOTICE, "Enabling IRQs.\n");
outports(rtl_iobase + RTL_PORT_IMR,
0x8000 | /* PCI error */
0x4000 | /* PCS timeout */
0x40 | /* Rx FIFO over */
0x20 | /* Rx underrun */
0x10 | /* Rx overflow */
0x08 | /* Tx error */
0x04 | /* Tx okay */
0x02 | /* Rx error */
0x01 /* Rx okay */
); /* TOK, ROK */
debug_print(NOTICE, "Configuring transmit\n");
outportl(rtl_iobase + RTL_PORT_TCR,
0
);
debug_print(NOTICE, "Configuring receive buffer.\n");
outportl(rtl_iobase + RTL_PORT_RCR,
(0) | /* 8K receive */
0x08 | /* broadcast */
0x01 /* all physical */
);
debug_print(NOTICE, "Enabling receive and transmit.\n");
//.........这里部分代码省略.........
示例13: write_rtc
void write_rtc(Byte add, Byte value) {
disable();
outportb(RTC_ADDR_REG, add);
outportb(RTC_DATA_REG, value);
enable();
}
示例14: kbSendCommand
void kbSendCommand(unsigned char c) /*Sends a command to the keyboard*/
{
kbWaitForReady();
outportb(0x64,c);
}
示例15: writeChar2Bochs
void writeChar2Bochs( uint8 char2Write )
{
outportb( 0xE9, char2Write );
}