// Returns false on EOI or error bool pop () { m_cur_char = readOne (); if (!eoi() && !error()) m_cur_loc.feed (m_cur_char); return !error() && !eoi(); }
void irq15_handler(interrupt_error_code n __attribute__((unused))) { eoi(IRQ_MASTER); eoi(IRQ_SLAVE); irq_handler current_irq_handler; aref(irq_handler_table,15,current_irq_handler); (*current_irq_handler)(); }
/// Saves current token for remainder void save_token() { ++m_curr_token; if( !eoi() ) m_token_size = ::strlen( m_argv[m_curr_token] ); }
/// Returns current token in the input cstring current_token() { if( eoi() ) return cstring(); return cstring( m_argv[m_curr_token], m_token_size ); }
static void speedo_dpc(void *arg) { struct dev *dev = (struct dev *) arg; struct nic *sp = (struct nic *) dev->privdata; speedo_interrupt(dev); eoi(sp->irq); }
//============================================================================== int main() { std::string input(u8"Hallo äöüß\n¡Bye! ✿➂➿♫"); typedef boost::spirit::line_pos_iterator<std::string::const_iterator> source_iterator; typedef boost::u8_to_u32_iterator<source_iterator> iterator_type; source_iterator soi(input.begin()), eoi(input.end()); iterator_type first(soi), last(eoi); qi::rule<iterator_type, std::u32string()> string_u32 = +encoding::graph; qi::rule<iterator_type, std::string()> string = string_u32 [qi::_val = to_utf8_(qi::_1)]; std::vector<boost::iterator_range<iterator_type> > ast; // note the trick with `raw` to expose the iterators bool result = qi::phrase_parse(first, last, *qi::raw[ string ], encoding::space, ast); if (result) { for (auto const& range : ast) { source_iterator base_b(range.begin().base()), base_e(range.end().base()); auto lbound = get_line_start(soi, base_b); // RAW access to the base iterators: std::cout << "Fragment: '" << std::string(base_b, base_e) << "'\t" << "raw: L" << get_line(base_b) << ":" << get_column(lbound, base_b, /*tabs:*/4) << "-L" << get_line(base_e) << ":" << get_column(lbound, base_e, /*tabs:*/4); // "cooked" access: auto line = get_current_line(lbound, base_b, eoi); // std::cout << "Line: '" << line << "'\n"; // iterator_type is an alias for u8_to_u32_iterator<...> size_t cur_pos = 0, start_pos = 0, end_pos = 0; for(iterator_type it = line.begin(), _eol = line.end(); ; ++it, ++cur_pos) { if (it.base() == base_b) start_pos = cur_pos; if (it.base() == base_e) end_pos = cur_pos; if (it == _eol) break; } std::cout << "\t// in u32 code _units_: positions " << start_pos << "-" << end_pos << "\n"; } std::cout << "\n"; } else { std::cout << "Failure" << std::endl; } if (first!=last) { std::cout << "Remaining: '" << std::string(first, last) << "'\n"; } }
/// Commit current token and iterate to next one void next_token() { if( !eoi() ) { for( std::size_t i = m_curr_token; i < m_argc-1; ++i ) m_argv[i] = m_argv[i + 1]; --m_argc; m_token_size = ::strlen( m_argv[m_curr_token] ); } }
static int serial_handler(struct context *ctxt, void *arg) { struct serial_port *sp = (struct serial_port *) arg; unsigned char iir; unsigned char lsr; int boguscnt = ISR_LIMIT; while (1) { lsr = inp((unsigned short) (sp->iobase + UART_LSR)); // If receiver ready drain FIFO if (lsr & LSR_RXRDY) serial_receive(sp); // If transmitter ready send next bytes from tx queue if (lsr & LSR_TXRDY) serial_transmit(sp); // Get interrupt identification register iir = inp((unsigned short) (sp->iobase + UART_IIR)); //kprintf("[sisr %d %x]", sp->irq, iir); if (iir & IIR_NOPEND) break; switch (iir & IIR_IMASK) { case IIR_MLSC: // Modem status changed sp->msr = inp((unsigned short) (sp->iobase + UART_MSR)); sp->mlsc = 1; break; case IIR_RLS: // Line status changed sp->linestatus |= (lsr & (LSR_OE | LSR_PE | LSR_FE | LSR_BI)); sp->rls = 1; break; } if (--boguscnt < 0) { kprintf("serial: Too much work at interrupt, iir=0x%02x\n", iir); break; } } // Set OUT2 to enable interrupts outp(sp->iobase + UART_MCR, sp->mcr); queue_irq_dpc(&sp->dpc, serial_dpc, sp); eoi(sp->irq); return 0; }
void timerCallback() { count++; if (count == 1000/50) { unsigned long now ; char buffer[200]; count = 0; rdtscl(now); itoa(now, buffer,10); videocpy(0,22,buffer); strcat(buffer, " "); } eoi(master); }
void cdriver_t() { static int rescheduler = 0; richiesta *p; if(des_timer) des_timer->dattesa--; while(des_timer && des_timer->dattesa == 0) { p = des_timer; des_timer = p->pric; // inserisci il processo nella coda dei pronti p->proc->stato = PRONTO; inserimento_coda(pronti, p->proc); // ripulisci memoria delete p; } if(!esecuzione) log_message("PANIC ESECUZIONE 0"); esecuzione->tick++; if(esecuzione->sig_mask) handlesignals(); if(++rescheduler > RESCHEDULER) { // update the scheduling adjusting the priorities of all processed rescheduler = 0; esecuzione->tickTotal += esecuzione->tick; inserimento_coda(pronti,esecuzione); reschedule(); schedulatore(); } else if(esecuzione->tick > QUANTUM) { inserimento_coda(pronti,esecuzione); schedulatore(); } eoi(master); }
int mymain(void) { unsigned int code=0; unsigned char head=0, tail=0; unsigned char scanCode=0, asciiCode=0; disableKey(); if(firstTime==1) { initHeadTail(); initTab(); firstTime=0; } scanCode=getScanCode(); asciiCode=lookupAscii(scanCode); if(asciiCode==0) { /* not printable */ if(scanCode==0x1D) { /* check if ctrl is pressed or not */ isCtrlDown=1; } else if(scanCode==0x9d) { isCtrlDown=0; } } if(scanCode>=0x3b && scanCode<=0x3e && isCtrlDown==1) { setActiveShell((scanCode-0x3b)+1); } code= scanCode; code<<=8; code|=asciiCode; head=getHead(); tail=getTail(); if(!((tail+2)==head || (head==0x1e && tail==0x3c)) ) { /* not full */ setKeyCode(code); if(tail==0x3C) { setTail(0x1e); } else { setTail(tail+2); } } enableKey(); eoi(ss,sp); }
void shouldBeEnd() { if(d_count!=0) errorh(__LINE__); if(!eoi()) errorh(__LINE__); if(d_should_extra) vShouldBeEnd(); };