uint64_t solo5_blk_sectors(void) { volatile struct ukvm_blkinfo info; outl(UKVM_PORT_BLKINFO, ukvm_ptr(&info)); cc_barrier(); return info.num_sectors; }
int solo5_blk_rw(void) { volatile struct ukvm_blkinfo info; outl(UKVM_PORT_BLKINFO, ukvm_ptr(&info)); cc_barrier(); return info.rw; }
char *solo5_net_mac_str(void) { volatile struct ukvm_netinfo info; outl(UKVM_PORT_NETINFO, ukvm_ptr(&info)); cc_barrier(); memcpy(mac_str, (void *)&info, 18); return mac_str; }
/* ukvm net interface */ int solo5_net_write_sync(uint8_t *data, int n) { volatile struct ukvm_netwrite wr; wr.data = data; wr.len = n; wr.ret = 0; outl(UKVM_PORT_NETWRITE, ukvm_ptr(&wr)); cc_barrier(); return wr.ret; }
/* ukvm block interface */ int solo5_blk_write_sync(uint64_t sec, uint8_t *data, int n) { volatile struct ukvm_blkwrite wr; wr.sector = sec; wr.data = data; wr.len = n; wr.ret = 0; outl(UKVM_PORT_BLKWRITE, ukvm_ptr(&wr)); cc_barrier(); return wr.ret; }
int solo5_net_read_sync(uint8_t *data, int *n) { volatile struct ukvm_netread rd; rd.data = data; rd.len = *n; rd.ret = 0; outl(UKVM_PORT_NETREAD, ukvm_ptr(&rd)); cc_barrier(); *n = rd.len; return rd.ret; }
void PacketPoolWait(void) { PktPool *my_pool = GetThreadPacketPool(); if (PacketPoolIsEmpty(my_pool)) { SCMutexLock(&my_pool->return_stack.mutex); SC_ATOMIC_ADD(my_pool->return_stack.sync_now, 1); SCCondWait(&my_pool->return_stack.cond, &my_pool->return_stack.mutex); SCMutexUnlock(&my_pool->return_stack.mutex); } while(PacketPoolIsEmpty(my_pool)) cc_barrier(); }
int solo5_blk_read_sync(uint64_t sec, uint8_t *data, int *n) { volatile struct ukvm_blkread rd; rd.sector = sec; rd.data = data; rd.len = *n; rd.ret = 0; outl(UKVM_PORT_BLKREAD, ukvm_ptr(&rd)); cc_barrier(); *n = rd.len; return rd.ret; }
solo5_result_t solo5_net_write(const uint8_t *buf, size_t size) { struct net_msg pkt; if (size > PACKET_SIZE) return SOLO5_R_EINVAL; memset(&pkt, 0, sizeof(struct net_msg)); cc_barrier(); pkt.length = size; memcpy(&pkt.data, buf, size); muen_channel_write(net_out, &pkt); return SOLO5_R_OK; }
enum muchannel_reader_result muen_channel_read( const struct muchannel * const channel, struct muchannel_reader *reader, void *element) { uint64_t epoch, pos, wc, wsc; enum muchannel_reader_result result; if (muen_channel_is_active(channel)) { if (reader->epoch == MUCHANNEL_NULL_EPOCH || has_epoch_changed(channel, reader)) return synchronize(channel, reader); serialized_copy(&channel->hdr.wc, &wc); if (reader->rc == wc) result = MUCHANNEL_NO_DATA; else if (wc - reader->rc > reader->elements) { result = MUCHANNEL_OVERRUN_DETECTED; } else { pos = reader->rc % reader->elements * reader->size; memcpy(element, channel->data + pos, reader->size); cc_barrier(); serialized_copy(&channel->hdr.wsc, &wsc); if (wsc - reader->rc > reader->elements) { result = MUCHANNEL_OVERRUN_DETECTED; } else { result = MUCHANNEL_SUCCESS; reader->rc++; } if (has_epoch_changed(channel, reader)) { result = MUCHANNEL_EPOCH_CHANGED; epoch = 0; serialized_copy(&epoch, &reader->epoch); } } } else { reader->epoch = MUCHANNEL_NULL_EPOCH; result = MUCHANNEL_INACTIVE; } return result; }
void muen_channel_deactivate(struct muchannel *channel) { channel->hdr.epoch = MUCHANNEL_NULL_EPOCH; cc_barrier(); }