static struct SectorCache * cache_fetch(uint_32 sector) { //printk("enter cache_fetch\n"); struct SectorCache *ptr = &cache[sector % NR_SEC_CACHE]; if (ptr->used == TRUE && ptr->sector == sector) { //printk("hit\n"); /* cache hit, do nothing */ } else { //printk("miss\n"); if (ptr->used == TRUE && ptr->dirty == TRUE) { /* write back */ ide_prepare(ptr->sector); do_write(&ptr->content); } /* issue a read command */ ide_prepare(sector); issue_read(); do_read(&ptr->content); ptr->used = TRUE; ptr->sector = sector; ptr->dirty = FALSE; } return ptr; }
void serial_com::handle_read( const boost::system::error_code& ec, std::size_t bytes_transferred){ if(!ec){ // std::cout << std::string(read_buffer,bytes_transferred) << " " << bytes_transferred << "\n"; if(data_handler) data_handler->handle_data(std::string(read_buffer,bytes_transferred)); issue_read(); }else if(data_handler){ data_handler->handle_data("\n*\n*Error in serial read\n*\n*\n"); } }
void disk_do_read(void *buf, uint32_t sector) { int i; ide_prepare(sector); issue_read(); waitdisk(); for (i = 0; i < 512 / sizeof(uint32_t); i ++) { *(((uint32_t*)buf) + i) = in_long(IDE_PORT_BASE); } }
serial_com( UM2ListenerApp* handler = nullptr ): io(), port(io, "/dev/ttyACM0"), is_shutting_down(false), io_thread(nullptr), data_handler( handler ) { port.set_option( boost::asio::serial_port::baud_rate( 115200 ) ); port.set_option( boost::asio::serial_port::flow_control( boost::asio::serial_port::flow_control::none ) ); port.set_option( boost::asio::serial_port::parity( boost::asio::serial_port::parity::none ) ); port.set_option( boost::asio::serial_port::stop_bits( boost::asio::serial_port::stop_bits::one ) ); port.set_option( boost::asio::serial_port::character_size( 8 ) ); io.post( [this](){issue_read();} ); io_thread = new std::thread( [this](){ io.run(); } ); }