uint16_t msix_t::setup_vector(uint8_t cpu, uint8_t intr) { // find free table entry uint16_t vec; for (vec = 0; vec < this->vectors(); vec++) { // read data register auto reg = get_entry(vec, ENT_MSG_DATA); if ((mm_read(reg) & 0xff) == 0) break; } assert (vec != this->vectors()); // use free table entry INFO2("MSI-X vector %u pointing to cpu %u intr %u", vec, cpu, intr); // mask entry mask_entry(vec); mm_write(get_entry(vec, ENT_MSG_ADDR), msix_addr_single_cpu(cpu)); mm_write(get_entry(vec, ENT_MSG_UPPER), 0x0); mm_write(get_entry(vec, ENT_MSG_DATA), msix_data_single_vector(intr)); // unmask entry unmask_entry(vec); // return it return vec; }
int main (int argc, char **argv) { struct mm_msg m; while (mm_read(0, &m)) { if (m.type == MM_NOTEON || m.type == MM_NOTEOFF) { assert(m.arg1 >= 0x00 && m.arg1 <= 0x7F); m.arg1 = T[m.arg1]; } mm_write(1, &m); } return 0; }
void msix_t::reset_pba_bit(size_t vec) { auto chunk = vec / 32; auto bit = vec & 31; auto reg = get_pba(chunk); mm_write(reg, mm_read(reg) & ~(1 << bit)); }
int main (int argc, char **argv) { struct timespec next; E("clock_gettime", clock_gettime(CLK, &next)); close(0); // we don't use stdin if (argc>=2) bpm = atol(argv[1]); struct timespec diff=timediff(bpm); struct mm_msg m = {MM_CLOCK, 0, 0, 0}; for (;;) { mm_write(1, &m); addto(&next, &diff); if (clock_nanosleep(CLK, TIMER_ABSTIME, &next, NULL)) err(1,"clock_nanosleep"); } return 0; }
void writefile () { if (!activevents) errx(1,"Internal error"); E("write", write(1, header, sizeof(header))); struct timeval lastime = events[0].time; int remain = activevents; for (ME* cur = events; remain; remain--, cur++) { write_variable_length_quantity(dtime(lastime, cur->time)); lastime = cur->time; mm_write(1, &cur->m); } E("write", write(1, trailer, sizeof(trailer))); off_t ending_offset; E("lseek", (ending_offset = lseek(1, 0, SEEK_CUR))); E("lseek", lseek(1, 18, SEEK_SET)); write_four_byte_int(ending_offset - sizeof(header), 1); }
void msix_t::zero_entry(size_t vec) { auto reg = get_entry(vec, ENT_MSG_DATA); mm_write(reg, mm_read(reg) & ~0xff); }
void msix_t::unmask_entry(size_t vec) { auto reg = get_entry(vec, ENT_VECTOR_CTL); mm_write(reg, mm_read(reg) & ~MSIX_ENTRY_CTL_MASK); }