MMIOWrite is equivalent to Write, but returns an error if the write cannot be implemented by writing to the address set by EnableMMIO. This is primarily useful for testing.
(val uint64)
| 101 | // implemented by writing to the address set by EnableMMIO. This is primarily |
| 102 | // useful for testing. |
| 103 | func (ev Eventfd) MMIOWrite(val uint64) error { |
| 104 | var buf [sizeofUint64]byte |
| 105 | hostarch.ByteOrder.PutUint64(buf[:], val) |
| 106 | if ev.mmioAddr == 0 { |
| 107 | return fmt.Errorf("no MMIO address set") |
| 108 | } |
| 109 | if !ev.mmioCtrl.Enabled() { |
| 110 | return fmt.Errorf("MMIO is temporarily disabled") |
| 111 | } |
| 112 | _, err := safecopy.CopyOut(ev.mmioPtr(), buf[:]) |
| 113 | return err |
| 114 | } |
| 115 | |
| 116 | // Wait blocks until eventfd is non-zero (i.e. someone calls Notify or Write). |
| 117 | func (ev Eventfd) Wait() error { |