CKeyboard Class Reference

#include <Keyboard.h>

Inheritance diagram for CKeyboard:

Inheritance graph
[legend]
Collaboration diagram for CKeyboard:

Collaboration graph
[legend]

Detailed Description

Emulated keyboard controller, keyboard and mouse.

Definition at line 64 of file Keyboard.h.


Public Member Functions

 CKeyboard (CConfigurator *cfg, CSystem *c)
 Constructor.
virtual ~CKeyboard ()
 Destructor.
virtual void check_state ()
 Check if threads are still running.
virtual void WriteMem (int index, u64 address, int dsize, u64 data)
virtual u64 ReadMem (int index, u64 address, int dsize)
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.
void execute ()
 Keyboard clock.
void gen_scancode (u32 key)
 Enqueue scancode for a keypress or key-release.
virtual void init ()
 Initialize the Keyboard device.
virtual void start_threads ()
virtual void stop_threads ()

Private Member Functions

u8 read_60 ()
 Read a byte from keyboard port 60.
void write_60 (u8 data)
 Write a byte to keyboard port 60.
u8 read_64 ()
 Read a byte from keyboard port 64.
void write_64 (u8 data)
 Write a byte to keyboard port 64.
void resetinternals (bool powerup)
 Reset keyboard internals.
void enQ (u8 scancode)
 Enqueue a byte (scancode) into the keyboard buffer.
void controller_enQ (u8 data, unsigned source)
 Enqueue a byte into one of the keyboard controller's output buffers.
void set_kbd_clock_enable (u8 value)
 Enable or disable the keyboard clock.
void set_aux_clock_enable (u8 value)
 Enable or disable the mouse clock.
void ctrl_to_kbd (u8 value)
 Send a byte from controller to keyboard.
void enQ_imm (u8 val)
 enqueue scancode in multibyte internal keyboard buffer
void ctrl_to_mouse (u8 value)
 Send a byte from controller to mouse.
bool mouse_enQ_packet (u8 b1, u8 b2, u8 b3, u8 b4)
 Put a (3/4 byte) mouse packet into the mouse buffer.
void mouse_enQ (u8 mouse_data)
 Put a byte into the mouse buffer.
unsigned periodic ()
 Determine what IRQ's need to be asserted.
void create_mouse_packet (bool force_enq)
 Create a mouse packet and send it to the controller if needed.

Private Attributes

Poco::ThreadmyThread
bool StopThread
struct CKeyboard::SKb_state state

Data Structures

struct  SKb_state
 The state structure contains all elements that need to be saved to the statefile. More...

Constructor & Destructor Documentation

CKeyboard::CKeyboard ( CConfigurator cfg,
CSystem c 
)

Constructor.

Definition at line 75 of file Keyboard.cpp.

References FAILURE, and theKeyboard.

CKeyboard::~CKeyboard (  )  [virtual]

Destructor.

Definition at line 175 of file Keyboard.cpp.

References stop_threads().


Member Function Documentation

void CKeyboard::check_state (  )  [virtual]

Check if threads are still running.

Reimplemented from CSystemComponent.

Definition at line 1829 of file Keyboard.cpp.

References FAILURE, Poco::Thread::isRunning(), and myThread.

void CKeyboard::WriteMem ( int  index,
u64  address,
int  dsize,
u64  data 
) [virtual]

Reimplemented from CSystemComponent.

Definition at line 190 of file Keyboard.cpp.

References FAILURE, write_60(), and write_64().

u64 CKeyboard::ReadMem ( int  index,
u64  address,
int  dsize 
) [virtual]

Reimplemented from CSystemComponent.

Definition at line 180 of file Keyboard.cpp.

References FAILURE, read_60(), and read_64().

int CKeyboard::SaveState ( FILE *  f  )  [virtual]

Save state to a Virtual Machine State file.

Implements CSystemComponent.

Definition at line 1865 of file Keyboard.cpp.

References kb_magic1, kb_magic2, and state.

int CKeyboard::RestoreState ( FILE *  f  )  [virtual]

Restore state from a Virtual Machine State file.

Implements CSystemComponent.

Definition at line 1880 of file Keyboard.cpp.

References kb_magic1, kb_magic2, and state.

void CKeyboard::run ( void   )  [virtual]

Thread entry point.

Implements Poco::Runnable.

Definition at line 1838 of file Keyboard.cpp.

References Poco::Exception::displayText(), execute(), Poco::Thread::sleep(), and StopThread.

void CKeyboard::execute (  ) 

Keyboard clock.

Handle events on a clocked basis.

Do the following:

  • Let the GUI (if available) handle any pending events.
  • Check if interrupts need to be asserted.
  • Assert interrupts as needed.

Definition at line 1806 of file Keyboard.cpp.

References periodic(), CAliM1543C::pic_interrupt(), and theAli.

Referenced by read_60(), run(), write_60(), and write_64().

void CKeyboard::gen_scancode ( u32  key  ) 

void CKeyboard::init (  )  [virtual]

Initialize the Keyboard device.

Reimplemented from CSystemComponent.

Definition at line 85 of file Keyboard.cpp.

References CKeyboard::SKb_state::allow_irq1, CKeyboard::SKb_state::allow_irq12, CKeyboard::SKb_state::aux_clock_enabled, CKeyboard::SKb_state::aux_output_buffer, CKeyboard::SKb_state::SAli_kbdc_status::auxb, CKeyboard::SKb_state::bat_in_progress, CKeyboard::SKb_state::SAli_mib::buffer, BX_KBD_CONTROLLER_QSIZE, BX_MOUSE_BUFF_SIZE, CKeyboard::SKb_state::SAli_kbdc_status::c_d, CKeyboard::SKb_state::SAli_mouse::captured, CSystemComponent::cSystem, CKeyboard::SKb_state::SAli_mouse::delayed_dx, CKeyboard::SKb_state::SAli_mouse::delayed_dy, CKeyboard::SKb_state::SAli_mouse::delayed_dz, CKeyboard::SKb_state::SAli_mouse::enable, CKeyboard::SKb_state::expecting_mouse_parameter, CKeyboard::SKb_state::expecting_port60h, CConfigurator::get_bool_value(), CKeyboard::SKb_state::SAli_mib::head, CKeyboard::SKb_state::SAli_mouse::im_mode, CKeyboard::SKb_state::SAli_mouse::im_request, CKeyboard::SKb_state::SAli_kbdc_status::inpb, CKeyboard::SKb_state::irq12_requested, CKeyboard::SKb_state::irq1_requested, CKeyboard::SKb_state::kbd_clock_enabled, CKeyboard::SKb_state::kbd_controller_Q, CKeyboard::SKb_state::kbd_controller_Qsize, CKeyboard::SKb_state::kbd_controller_Qsource, CKeyboard::SKb_state::kbd_internal_buffer, CKeyboard::SKb_state::kbd_output_buffer, CKeyboard::SKb_state::SAli_kbdc_status::keyl, CKeyboard::SKb_state::last_comm, CKeyboard::SKb_state::SAli_kbdib::led_status, CKeyboard::SKb_state::SAli_mouse::mode, CKeyboard::SKb_state::mouse, CKeyboard::SKb_state::mouse_internal_buffer, MOUSE_MODE_RESET, CSystemComponent::myCfg, myThread, CKeyboard::SKb_state::SAli_mib::num_elements, CKeyboard::SKb_state::SAli_kbdc_status::outb, CKeyboard::SKb_state::SAli_kbdc_status::pare, CSystem::RegisterMemory(), resetinternals(), CKeyboard::SKb_state::SAli_mouse::resolution_cpmm, CKeyboard::SKb_state::SAli_mouse::sample_rate, CKeyboard::SKb_state::SAli_mouse::scaling, CKeyboard::SKb_state::scancodes_translate, CKeyboard::SKb_state::SAli_kbdib::scanning_enabled, state, CKeyboard::SKb_state::status, CKeyboard::SKb_state::SAli_kbdc_status::sysf, CKeyboard::SKb_state::SAli_kbdc_status::tim, CKeyboard::SKb_state::timer_pending, and U64.

void CKeyboard::start_threads (  )  [virtual]

Reimplemented from CSystemComponent.

Definition at line 149 of file Keyboard.cpp.

References Poco::Thread::getName(), myThread, Poco::Thread::start(), and StopThread.

void CKeyboard::stop_threads (  )  [virtual]

Reimplemented from CSystemComponent.

Definition at line 160 of file Keyboard.cpp.

References Poco::Thread::getName(), Poco::Thread::join(), myThread, and StopThread.

Referenced by ~CKeyboard().

u8 CKeyboard::read_60 (  )  [private]

void CKeyboard::write_60 ( u8  data  )  [private]

u8 CKeyboard::read_64 (  )  [private]

Read a byte from keyboard port 64.

The keyboard controller status register

The keyboard controller has an 8-bit status register. It can be inspected by the CPU by reading port 0x64. (Typically, it has the value 0x14: keyboard not locked, self-test completed.)

 +------+-----+------+------+-----+------+------+------+
 | PARE |       TIM | AUXB | KEYL | C/D | SYSF | INPB | OUTB |
 +------+-----+------+------+-----+------+------+------+

Bit 7: Parity error 0: OK. 1: Parity error with last byte.

Bit 6: Timeout 0: OK. 1: General timeout.

Bit 5: Auxiliary output buffer full Bit 0 tells whether a read from port 0x60 will be valid. If it is valid, this bit 5 tells what data will be read from port 0x60. 0: Keyboard data. 1: Mouse data.

Bit 4: Keyboard lock 0: Locked. 1: Not locked.

Bit 3: Command/Data 0: Last write to input buffer was data (written via port 0x60). 1: Last write to input buffer was a command (written via port 0x64). (This bit is also referred to as Address Line A2.)

Bit 2: System flag Set to 0 after power on reset. Set to 1 after successful completion of the keyboard controller self-test (Basic Assurance Test, BAT). Can also be set by command (see below).

Bit 1: Input buffer status 0: Input buffer empty, can be written. 1: Input buffer full, don't write yet.

Bit 0: Output buffer status 0: Output buffer empty, don't read yet. 1: Output buffer full, can be read. (Bit 5 tells whether the available data is from keyboard or mouse.) This bit is cleared when port 0x60 is read.

Definition at line 550 of file Keyboard.cpp.

References CKeyboard::SKb_state::SAli_kbdc_status::auxb, BX_DEBUG, CKeyboard::SKb_state::SAli_kbdc_status::c_d, CKeyboard::SKb_state::SAli_kbdc_status::inpb, CKeyboard::SKb_state::SAli_kbdc_status::keyl, CKeyboard::SKb_state::SAli_kbdc_status::outb, CKeyboard::SKb_state::SAli_kbdc_status::pare, state, CKeyboard::SKb_state::status, CKeyboard::SKb_state::SAli_kbdc_status::sysf, and CKeyboard::SKb_state::SAli_kbdc_status::tim.

Referenced by ReadMem().

void CKeyboard::write_64 ( u8  data  )  [private]

void CKeyboard::resetinternals ( bool  powerup  )  [private]

void CKeyboard::enQ ( u8  scancode  )  [private]

void CKeyboard::controller_enQ ( u8  data,
unsigned  source 
) [private]

void CKeyboard::set_kbd_clock_enable ( u8  value  )  [private]

void CKeyboard::set_aux_clock_enable ( u8  value  )  [private]

void CKeyboard::ctrl_to_kbd ( u8  value  )  [private]

void CKeyboard::enQ_imm ( u8  val  )  [private]

void CKeyboard::ctrl_to_mouse ( u8  value  )  [private]

bool CKeyboard::mouse_enQ_packet ( u8  b1,
u8  b2,
u8  b3,
u8  b4 
) [private]

void CKeyboard::mouse_enQ ( u8  mouse_data  )  [private]

unsigned CKeyboard::periodic (  )  [private]

void CKeyboard::create_mouse_packet ( bool  force_enq  )  [private]


Field Documentation

Definition at line 84 of file Keyboard.h.

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

bool CKeyboard::StopThread [private]

Definition at line 85 of file Keyboard.h.

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


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

SourceForge.net Logo
Project space on SourceForge.net