Add file-backed implementation to allow users to assign an OTP image file to machine. If '-boot otp-file=filename' is specified, OTP device uses otp image file instead of fuse array. In order to keep data up-to-date due to unexpected crash or CTRL+a-x, every read/write to OTP memory involves file open, mmap and close operation to the image file.
Add write-once feature to block second write operation to the OTP memory. Only keep the 'written' state for non-control register range from 0x38 to 16KB. Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/riscv: sifive_u: Add file-backed OTP. softmmu/vl: add otp-file to boot option hw/riscv: sifive_u: Add write-once protection. hw/riscv/sifive_u_otp.c | 122 ++++++++++++++++++++++++++++++-- include/hw/riscv/sifive_u_otp.h | 3 + qemu-options.hx | 3 +- softmmu/vl.c | 6 +- 4 files changed, 128 insertions(+), 6 deletions(-) -- 2.17.1