StuBS
pit.cc File Reference
#include "machine/pit.h"
#include "machine/ioport.h"
#include "machine/core.h"
Include dependency graph for pit.cc:

Classes

struct  PIT::Control.__unnamed62__
 I/O-port bitmap for the NMI Status and Control Register. More...
 

Namespaces

namespace  PIT
 Abstraction of the historical Programmable Interval Timer (PIT).
 

Enumerations

enum  PIT::AccessMode {
  PIT::LATCH_COUNT_VALUE = 0 ,
  PIT::LOW_BYTE_ONLY = 1 ,
  PIT::HIGH_BYTE_ONLY = 2 ,
  PIT::LOW_AND_HIGH_BYTE = 3
}
 Access mode. More...
 
enum  PIT::OperatingMode {
  PIT::INTERRUPT_ON_TERMINAL_COUNT = 0 ,
  PIT::PROGRAMMABLE_ONE_SHOT = 1 ,
  PIT::RATE_GENERATOR = 2 ,
  PIT::SQUARE_WAVE_GENERATOR = 3 ,
  PIT::SOFTWARE_TRIGGERED_STROBE = 4 ,
  PIT::HARDWARE_TRIGGERED_STROBE = 5
}
 Operating Mode. More...
 
enum  PIT::Format {
  PIT::BINARY = 0 ,
  PIT::BCD = 1
}
 data format More...
 

Functions

static IOPort PIT::data (0x40+CHANNEL)
 
bool PIT::set (uint16_t us)
 Start timer.
 
uint16_t PIT::get (void)
 Reads the current timer value.
 
bool PIT::isActive (void)
 Check if the timer is running.
 
bool PIT::waitForTimeout (void)
 (Active) waiting for timeout
 
bool PIT::delay (uint16_t us)
 Set the timer and wait for timeout.
 
void PIT::pcspeaker (uint32_t freq)
 Play a given frequency on the PC speaker.
 
void PIT::disable (void)
 Deactivate the timer.
 

Constants

const uint8_t PIT::CHANNEL = 2
 
static IOPort PIT::mode_register (0x43)
 
static IOPort PIT::controlRegister (0x61)
 
const uint64_t PIT::BASE_FREQUENCY = 1193182ULL
 

Class Documentation

◆ PIT::Control.__unnamed62__

struct PIT::Control.__unnamed62__

I/O-port bitmap for the NMI Status and Control Register.

Note
Over time, the meaning of the bits stored at I/O port 0x61 changed; don't get the structure confused with old documentation on the IBM PC XT platform.
See also
IntelĀ® I/O Controller Hub 7 (ICH7) Family, page 415
Class Members
uint8_t enable_timer_counter2: 1 If enabled, the interrupt state will be visible at status_timer_counter2.
uint8_t enable_speaker_data: 1 If set, speaker output is equal to status_timer_counter2.
uint8_t enable_pci_serr: 1 not important, do not modify
uint8_t enable_nmi_iochk: 1 not important, do not modify
uint8_t refresh_cycle_toggle: 1 not important, must be 0 on write
uint8_t status_timer_counter2: 1 will be set on timer expiration; must be 0 on write
uint8_t status_iochk_nmi_source: 1 not important, must be 0 on write
uint8_t status_serr_nmi_source: 1 not important, must be 0 on write