i8254.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef __I8254_H
  2. #define __I8254_H
  3. #include "iodev.h"
  4. struct kvm_kpit_channel_state {
  5. u32 count; /* can be 65536 */
  6. u16 latched_count;
  7. u8 count_latched;
  8. u8 status_latched;
  9. u8 status;
  10. u8 read_state;
  11. u8 write_state;
  12. u8 write_latch;
  13. u8 rw_mode;
  14. u8 mode;
  15. u8 bcd; /* not supported */
  16. u8 gate; /* timer start */
  17. ktime_t count_load_time;
  18. };
  19. struct kvm_kpit_state {
  20. struct kvm_kpit_channel_state channels[3];
  21. u32 flags;
  22. struct kvm_timer pit_timer;
  23. bool is_periodic;
  24. u32 speaker_data_on;
  25. struct mutex lock;
  26. struct kvm_pit *pit;
  27. spinlock_t inject_lock;
  28. unsigned long irq_ack;
  29. struct kvm_irq_ack_notifier irq_ack_notifier;
  30. };
  31. struct kvm_pit {
  32. struct kvm_io_device dev;
  33. struct kvm_io_device speaker_dev;
  34. struct kvm *kvm;
  35. struct kvm_kpit_state pit_state;
  36. int irq_source_id;
  37. struct kvm_irq_mask_notifier mask_notifier;
  38. struct workqueue_struct *wq;
  39. struct work_struct expired;
  40. };
  41. #define KVM_PIT_BASE_ADDRESS 0x40
  42. #define KVM_SPEAKER_BASE_ADDRESS 0x61
  43. #define KVM_PIT_MEM_LENGTH 4
  44. #define KVM_PIT_FREQ 1193181
  45. #define KVM_MAX_PIT_INTR_INTERVAL HZ / 100
  46. #define KVM_PIT_CHANNEL_MASK 0x3
  47. void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val, int hpet_legacy_start);
  48. struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags);
  49. void kvm_free_pit(struct kvm *kvm);
  50. void kvm_pit_reset(struct kvm_pit *pit);
  51. #endif