#include <AliM1543C.h>


The ALi M1543C device provides i/o and glue logic support to the system: ISA, DMA, Interrupt, Timer, TOY Clock.
Documentation consulted:
Definition at line 148 of file AliM1543C.h.
Public Member Functions | |
| virtual int | SaveState (FILE *f) |
| Save state to a Virtual Machine State file. | |
| virtual int | RestoreState (FILE *f) |
| Restore state from a Virtual Machine State file. | |
| virtual void | run () |
| Thread entry point. | |
| virtual void | check_state () |
| Check if threads are still running. | |
| virtual void | WriteMem_Legacy (int index, u32 address, int dsize, u32 data) |
| Write (byte,word,longword) to one of the legacy ranges. | |
| virtual u32 | ReadMem_Legacy (int index, u32 address, int dsize) |
| Read (byte,word,longword) from one of the legacy ranges. | |
| void | do_pit_clock () |
| Handle all events that need to be handled on a clock-driven basis. | |
| CAliM1543C (CConfigurator *cfg, class CSystem *c, int pcibus, int pcidev) | |
| Constructor. | |
| virtual | ~CAliM1543C () |
| Destructor. | |
| void | pic_interrupt (int index, int intno) |
| Assert an interrupt on one of the programmable interrupt controllers. | |
| void | pic_deassert (int index, int intno) |
| De-assert an interrupt on one of the programmable interrupt controllers. | |
| void | init () |
| Initialize the Ali device. | |
| void | start_threads () |
| void | stop_threads () |
Private Member Functions | |
| u8 | reg_61_read () |
| Read port 61h (speaker/ miscellaneous). | |
| void | reg_61_write (u8 data) |
| Write port 61h (speaker/ miscellaneous). | |
| u8 | toy_read (u32 address) |
| Read time-of-year clock ports (70h-73h). | |
| void | toy_write (u32 address, u8 data) |
| Write time-of-year clock ports (70h-73h). | |
| u8 | pit_read (u32 address) |
| Read from the programmable interrupt timer ports (40h-43h). | |
| void | pit_write (u32 address, u8 data) |
| Write to the programmable interrupt timer ports (40h-43h). | |
| void | pit_clock () |
| Handle the PIT interrupt. | |
| u8 | pic_read (int index, u32 address) |
| Read a byte from one of the programmable interrupt controller's registers. | |
| void | pic_write (int index, u32 address, u8 data) |
| Write a byte to one of the programmable interrupt controller's registers. | |
| u8 | pic_read_vector () |
| Read the interrupt vector during a PCI IACK cycle. | |
| u8 | pic_read_edge_level (int index) |
| Read a byte from the edge/level register of one of the programmable interrupt controllers. | |
| void | pic_write_edge_level (int index, u8 data) |
| Write a byte to the edge/level register of one of the programmable interrupt controllers. | |
| u8 | lpt_read (u32 address) |
| Read a byte from one of the parallel port controller's registers. | |
| void | lpt_write (u32 address, u8 data) |
| Write a byte to one of the parallel port controller's registers. | |
| void | lpt_reset () |
| Parallel Port information: address 0 (R/W): data pins. | |
Private Attributes | |
| Poco::Thread * | myThread |
| CMutex * | myRegLock |
| bool | StopThread |
| struct CAliM1543C::SAli_state | state |
| FILE * | lpt |
Data Structures | |
| struct | SAli_state |
| The state structure contains all elements that need to be saved to the statefile. More... | |
| CAliM1543C::CAliM1543C | ( | CConfigurator * | cfg, | |
| class CSystem * | c, | |||
| int | pcibus, | |||
| int | pcidev | |||
| ) |
| CAliM1543C::~CAliM1543C | ( | ) | [virtual] |
| int CAliM1543C::SaveState | ( | FILE * | f | ) | [virtual] |
Save state to a Virtual Machine State file.
Reimplemented from CPCIDevice.
Definition at line 1188 of file AliM1543C.cpp.
References ali_magic1, ali_magic2, CSystemComponent::devid_string, CPCIDevice::SaveState(), and state.
| int CAliM1543C::RestoreState | ( | FILE * | f | ) | [virtual] |
Restore state from a Virtual Machine State file.
Reimplemented from CPCIDevice.
Definition at line 1207 of file AliM1543C.cpp.
References ali_magic1, ali_magic2, CSystemComponent::devid_string, CPCIDevice::RestoreState(), and state.
| void CAliM1543C::run | ( | void | ) | [virtual] |
Thread entry point.
Implements Poco::Runnable.
Definition at line 901 of file AliM1543C.cpp.
References Poco::Exception::displayText(), do_pit_clock(), Poco::Thread::sleep(), and StopThread.
| void CAliM1543C::check_state | ( | ) | [virtual] |
Check if threads are still running.
Reimplemented from CSystemComponent.
Definition at line 1399 of file AliM1543C.cpp.
References FAILURE, Poco::Thread::isRunning(), and myThread.
Write (byte,word,longword) to one of the legacy ranges.
Only byte-accesses are supported.
Ranges are:
Reimplemented from CPCIDevice.
Definition at line 503 of file AliM1543C.cpp.
References CSystemComponent::devid_string, FAILURE_4, lpt_write(), pic_write(), pic_write_edge_level(), pit_write(), reg_61_write(), and toy_write().
Read (byte,word,longword) from one of the legacy ranges.
Only byte-accesses are supported.
Ranges are:
Reimplemented from CPCIDevice.
Definition at line 460 of file AliM1543C.cpp.
References CSystemComponent::devid_string, FAILURE_4, lpt_read(), pic_read(), pic_read_edge_level(), pic_read_vector(), pit_read(), reg_61_read(), and toy_read().
| void CAliM1543C::do_pit_clock | ( | ) |
Handle all events that need to be handled on a clock-driven basis.
This is a slow-clocked device, which means this DoClock isn't called as often as the CPU's DoClock. Do the following:
Definition at line 932 of file AliM1543C.cpp.
References pit_clock(), and PIT_RATIO.
Referenced by run().
| void CAliM1543C::pic_interrupt | ( | int | index, | |
| int | intno | |||
| ) |
Assert an interrupt on one of the programmable interrupt controllers.
Definition at line 1124 of file AliM1543C.cpp.
References CSystemComponent::cSystem, DEBUG_EXPR, CSystem::interrupt(), CAliM1543C::SAli_state::pic_asserted, CAliM1543C::SAli_state::pic_mask, and state.
Referenced by CSerial::eval_interrupts(), CKeyboard::execute(), lpt_write(), pit_clock(), CAliM1543C_ide::raise_interrupt(), and CAliM1543C_ide::run().
| void CAliM1543C::pic_deassert | ( | int | index, | |
| int | intno | |||
| ) |
De-assert an interrupt on one of the programmable interrupt controllers.
Definition at line 1169 of file AliM1543C.cpp.
References CSystemComponent::cSystem, CSystem::interrupt(), CAliM1543C::SAli_state::pic_asserted, and state.
Referenced by CSerial::eval_interrupts(), CAliM1543C_ide::ide_command_read(), and CAliM1543C_ide::ide_command_write().
| void CAliM1543C::init | ( | ) | [virtual] |
Initialize the Ali device.
Reimplemented from CSystemComponent.
Definition at line 340 of file AliM1543C.cpp.
References CPCIDevice::add_function(), CPCIDevice::add_legacy_io(), ali_cfg_data, ali_cfg_mask, CSystemComponent::cSystem, CSystemComponent::devid_string, CConfigurator::get_bool_value(), CConfigurator::get_text_value(), lpt, lpt_reset(), CSystemComponent::myCfg, myRegLock, myThread, CAliM1543C::SAli_state::pic_asserted, CAliM1543C::SAli_state::pic_intvec, CAliM1543C::SAli_state::pic_mask, CAliM1543C::SAli_state::pic_mode, CAliM1543C::SAli_state::pit_counter, CAliM1543C::SAli_state::pit_status, CAliM1543C::SAli_state::reg_61, CSystem::RegisterMemory(), CPCIDevice::ResetPCI(), state, theVGA, CAliM1543C::SAli_state::toy_access_ports, CAliM1543C::SAli_state::toy_stored_data, and U64.
| void CAliM1543C::start_threads | ( | ) | [virtual] |
Reimplemented from CSystemComponent.
Definition at line 412 of file AliM1543C.cpp.
References Poco::Thread::getName(), myThread, Poco::Thread::start(), and StopThread.
| void CAliM1543C::stop_threads | ( | ) | [virtual] |
Reimplemented from CSystemComponent.
Definition at line 423 of file AliM1543C.cpp.
References Poco::Thread::getName(), Poco::Thread::join(), myThread, and StopThread.
Referenced by ~CAliM1543C().
| u8 CAliM1543C::reg_61_read | ( | ) | [private] |
Read port 61h (speaker/ miscellaneous).
BDW: This may need some expansion to help with timer delays. It looks like the 8254 flips bits on occasion, and the linux kernel (at least) uses do { count++; } while ((inb(0x61) & 0x20) == 0 && count < TIMEOUT_COUNT); to calibrate the cpu clock.
Every 1500 reads the bit gets flipped so maybe the timing will seem reasonable to the OS.
Definition at line 539 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::pit_status, CAliM1543C::SAli_state::reg_61, and state.
Referenced by ReadMem_Legacy().
| void CAliM1543C::reg_61_write | ( | u8 | data | ) | [private] |
Write port 61h (speaker/ miscellaneous).
Definition at line 564 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::reg_61, and state.
Referenced by WriteMem_Legacy().
Read time-of-year clock ports (70h-73h).
Definition at line 572 of file AliM1543C.cpp.
References state, and CAliM1543C::SAli_state::toy_access_ports.
Referenced by ReadMem_Legacy().
Write time-of-year clock ports (70h-73h).
On a write to port 0, recalculate clock values.
Definition at line 582 of file AliM1543C.cpp.
References IPus, state, CAliM1543C::SAli_state::toy_access_ports, and CAliM1543C::SAli_state::toy_stored_data.
Referenced by WriteMem_Legacy().
Read from the programmable interrupt timer ports (40h-43h).
BDW: Here's the PIT Traffic during SRM and Linux Startup:
SRM PIT Write: 3, 36 = counter 0, load lsb + msb, mode 3 PIT Write: 0, 00 PIT Write: 0, 00 = 65536 = 18.2 Hz = timer interrupt. PIT Write: 3, 54 = counter 1, msb only, mode 2 PIT Write: 1, 12 = 0x1200 = memory refresh? PIT Write: 3, b6 = counter 2, load lsb + msb, mode 3 PIT Write: 3, 00 PIT Write: 0, 00 PIT Write: 0, 00
Linux Startup PIT Write: 3, b0 = counter 2, load lsb+msb, mode 0 PIT Write: 2, a4 PIT Write: 2, ec = eca4 PIT Write: 3, 36 = counter 0, load lsb+msb, mode 3 PIT Write: 0, 00 PIT Write: 0, 00 = 65536 PIT Write: 3, b6 = counter 2, load lsb+msb, mode 3 PIT Write: 2, 31 PIT Write: 2, 13 = 1331
Definition at line 768 of file AliM1543C.cpp.
Referenced by ReadMem_Legacy().
Write to the programmable interrupt timer ports (40h-43h).
Definition at line 780 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::pit_counter, CAliM1543C::SAli_state::pit_mode, PIT_OFFSET_MAX, CAliM1543C::SAli_state::pit_status, and state.
Referenced by WriteMem_Legacy().
| void CAliM1543C::pit_clock | ( | ) | [private] |
Handle the PIT interrupt.
Definition at line 849 of file AliM1543C.cpp.
References pic_interrupt(), CAliM1543C::SAli_state::pit_counter, PIT_DEC, PIT_OFFSET_MAX, CAliM1543C::SAli_state::pit_status, and state.
Referenced by do_pit_clock().
Read a byte from one of the programmable interrupt controller's registers.
Definition at line 950 of file AliM1543C.cpp.
References LL, CAliM1543C::SAli_state::pic_mask, and state.
Referenced by ReadMem_Legacy().
Write a byte to one of the programmable interrupt controller's registers.
Definition at line 1020 of file AliM1543C.cpp.
References CSystemComponent::cSystem, CSystem::interrupt(), LL, CAliM1543C::SAli_state::pic_asserted, PIC_INIT_0, PIC_INIT_1, PIC_INIT_2, CAliM1543C::SAli_state::pic_intvec, CAliM1543C::SAli_state::pic_mask, CAliM1543C::SAli_state::pic_mode, PIC_STD, and state.
Referenced by WriteMem_Legacy().
| u8 CAliM1543C::pic_read_vector | ( | ) | [private] |
Read the interrupt vector during a PCI IACK cycle.
Definition at line 978 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::pic_asserted, CAliM1543C::SAli_state::pic_intvec, and state.
Referenced by ReadMem_Legacy().
| u8 CAliM1543C::pic_read_edge_level | ( | int | index | ) | [private] |
Read a byte from the edge/level register of one of the programmable interrupt controllers.
Definition at line 970 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::pic_edge_level, and state.
Referenced by ReadMem_Legacy().
| void CAliM1543C::pic_write_edge_level | ( | int | index, | |
| u8 | data | |||
| ) | [private] |
Write a byte to the edge/level register of one of the programmable interrupt controllers.
Definition at line 1114 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::pic_edge_level, and state.
Referenced by WriteMem_Legacy().
Read a byte from one of the parallel port controller's registers.
Definition at line 1310 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::lpt_control, CAliM1543C::SAli_state::lpt_data, CAliM1543C::SAli_state::lpt_status, and state.
Referenced by ReadMem_Legacy().
Write a byte to one of the parallel port controller's registers.
Definition at line 1348 of file AliM1543C.cpp.
References lpt, CAliM1543C::SAli_state::lpt_control, CAliM1543C::SAli_state::lpt_data, CAliM1543C::SAli_state::lpt_init, CAliM1543C::SAli_state::lpt_status, pic_interrupt(), and state.
Referenced by WriteMem_Legacy().
| void CAliM1543C::lpt_reset | ( | ) | [private] |
Parallel Port information: address 0 (R/W): data pins.
On read, the last byte written is returned.
address 1 (R): status register
1 0 0 0 0 0 00 <-- default ^ ^ ^ ^ ^ ^ ^ | | | | | | +- Undefined | | | | | +--- IRQ (undefined?) | | | | +----- printer has error condition | | | +------- printer is not selected. | | +--------- printer has paper (online) | +----------- printer is asserting 'ack' +------------- printer busy (active low).
address 2 (R/W): control register.
00 0 0 1 0 1 1 <-- default
^ ^ ^ ^ ^ ^ ^
| | | | | | +-- Strobe (active low)
| | | | | +---- Auto feed (active low)
| | | | +------ Initialize
| | | +-------- Select (active low)
| | +---------- Interrupt Control
| +------------ Bidirectional control (unimplemented)
+--------------- Unused
Definition at line 1299 of file AliM1543C.cpp.
References CAliM1543C::SAli_state::lpt_control, CAliM1543C::SAli_state::lpt_data, CAliM1543C::SAli_state::lpt_init, CAliM1543C::SAli_state::lpt_status, and state.
Referenced by init().
Poco::Thread* CAliM1543C::myThread [private] |
Definition at line 172 of file AliM1543C.h.
Referenced by check_state(), init(), start_threads(), and stop_threads().
CMutex* CAliM1543C::myRegLock [private] |
bool CAliM1543C::StopThread [private] |
Definition at line 174 of file AliM1543C.h.
Referenced by run(), start_threads(), and stop_threads().
struct CAliM1543C::SAli_state CAliM1543C::state [private] |
FILE* CAliM1543C::lpt [private] |