Mirror of CollapseOS
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

38 行
1.3KB

  1. #pragma once
  2. #include "emul.h"
  3. /* Emulates the behavior of an AT28 EEPROM. When reading, behaves like regular
  4. * RAM. When writing, be in "writing mode" for 10ms. If we assume 8MHz, that
  5. * means 80k t-states tracked from the CPU.
  6. *
  7. * While we're in programming mode, reading the written address will emulate
  8. * the "polling mode" of the AT28, that is, each read toggles IO/6.
  9. *
  10. * If another write happens before we're done writing or if we read from another
  11. * address, writing fails (both the new write and the old one) and nothing is
  12. * written to memory.
  13. */
  14. typedef struct {
  15. // CPU reference needed to keep track of time
  16. Z80Context *cpu;
  17. // only range startoffset:size is used
  18. byte mem[LEN16BIT];
  19. // offset at which the EEPROM begins
  20. ushort startoffset;
  21. // EEPROM size
  22. ushort size;
  23. // t-state stamp of the active writing operation. 0 means none.
  24. unsigned int wrstamp;
  25. // address being written to
  26. ushort wraddr;
  27. // byte being written
  28. byte wrval;
  29. // last polled value. Next polling will yield this value with 6th bit
  30. // toggled.
  31. byte pollval;
  32. } AT28;
  33. void at28_init(AT28 *at28, Z80Context *cpu, ushort startoffset, ushort size);
  34. byte at28_mem_read(AT28 *at28, ushort addr);
  35. void at28_mem_write(AT28 *at28, ushort addr, byte val);