CAliM1543C Class Reference

#include <AliM1543C.h>

Inheritance diagram for CAliM1543C:

Inheritance graph
[legend]
Collaboration diagram for CAliM1543C:

Collaboration graph
[legend]

Detailed Description

Emulated ISA part of the ALi M1543C chipset.

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::ThreadmyThread
CMutexmyRegLock
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...

Constructor & Destructor Documentation

CAliM1543C::CAliM1543C ( CConfigurator cfg,
class CSystem c,
int  pcibus,
int  pcidev 
)

Constructor.

Definition at line 330 of file AliM1543C.cpp.

References FAILURE, and theAli.

CAliM1543C::~CAliM1543C (  )  [virtual]

Destructor.

Definition at line 438 of file AliM1543C.cpp.

References lpt, and stop_threads().


Member Function Documentation

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.

void CAliM1543C::WriteMem_Legacy ( int  index,
u32  address,
int  dsize,
u32  data 
) [virtual]

Write (byte,word,longword) to one of the legacy ranges.

Only byte-accesses are supported.

Ranges are:

  • 1. I/O port 61h
  • 2. I/O ports 70h-73h (time-of-year clock)
  • 6. I/O ports 40h-43h (programmable interrupt timer)
  • 7. I/O ports 20h-21h (primary programmable interrupt controller)
  • 8. I/O ports a0h-a1h (secondary (cascaded) programmable interrupt controller)
  • 12. I/O ports 00h-0fh (primary DMA controller)
  • 13. I/O ports c0h-dfh (secondary DMA controller)
  • 20. PCI IACK address (interrupt vector)
  • 27. I/O ports 3bch-3bfh (parallel port)
  • 30. I/O ports 4d0h-4d1h (edge/level register of programmable interrupt controller)
  • 33. I/O ports 80h-8fh (DMA controller memory base low page register)
  • 34. I/O ports 480h-48fh (DMA controller memory base high page register)

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().

u32 CAliM1543C::ReadMem_Legacy ( int  index,
u32  address,
int  dsize 
) [virtual]

Read (byte,word,longword) from one of the legacy ranges.

Only byte-accesses are supported.

Ranges are:

  • 1. I/O port 61h
  • 2. I/O ports 70h-73h (time-of-year clock)
  • 6. I/O ports 40h-43h (programmable interrupt timer)
  • 7. I/O ports 20h-21h (primary programmable interrupt controller)
  • 8. I/O ports a0h-a1h (secondary (cascaded) programmable interrupt controller)
  • 20. PCI IACK address (interrupt vector)
  • 27. I/O ports 3bch-3bfh (parallel port)
  • 30. I/O ports 4d0h-4d1h (edge/level register of programmable interrupt controller)

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:

  • Handle PIT clock.

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 
)

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]

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().

u8 CAliM1543C::toy_read ( u32  address  )  [private]

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().

void CAliM1543C::toy_write ( u32  address,
u8  data 
) [private]

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().

u8 CAliM1543C::pit_read ( u32  address  )  [private]

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().

void CAliM1543C::pit_write ( u32  address,
u8  data 
) [private]

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.

  • counter 0 is the 18.2Hz time counter.
  • counter 1 is the ram refresh, we don't care.
  • counter 2 is the speaker and/or generic timer

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().

u8 CAliM1543C::pic_read ( int  index,
u32  address 
) [private]

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().

void CAliM1543C::pic_write ( int  index,
u32  address,
u8  data 
) [private]

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().

u8 CAliM1543C::lpt_read ( u32  address  )  [private]

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().

void CAliM1543C::lpt_write ( u32  address,
u8  data 
) [private]

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().


Field Documentation

Definition at line 172 of file AliM1543C.h.

Referenced by check_state(), init(), start_threads(), and stop_threads().

Definition at line 173 of file AliM1543C.h.

Referenced by init().

bool CAliM1543C::StopThread [private]

Definition at line 174 of file AliM1543C.h.

Referenced by run(), start_threads(), and stop_threads().

FILE* CAliM1543C::lpt [private]

Definition at line 232 of file AliM1543C.h.

Referenced by init(), lpt_write(), and ~CAliM1543C().


The documentation for this class was generated from the following files:

SourceForge.net Logo
Project space on SourceForge.net