2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2006-03-07 01:03:16 +03:00
|
|
|
//
|
2012-04-01 22:53:16 +04:00
|
|
|
// Copyright (C) 2002-2012 The Bochs Project
|
2006-03-07 01:03:16 +03:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2009-02-08 00:05:31 +03:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2006-03-07 01:03:16 +03:00
|
|
|
|
|
|
|
#ifndef BX_DEVICES_IOAPIC_H
|
|
|
|
#define BX_DEVICES_IOAPIC_H
|
|
|
|
|
2009-11-20 17:58:48 +03:00
|
|
|
#if BX_SUPPORT_APIC
|
|
|
|
|
2010-03-27 12:56:30 +03:00
|
|
|
typedef Bit32u apic_dest_t; /* same definition in apic.h */
|
|
|
|
|
|
|
|
extern int apic_bus_deliver_lowest_priority(Bit8u vector, apic_dest_t dest, bx_bool trig_mode, bx_bool broadcast);
|
|
|
|
extern int apic_bus_deliver_interrupt(Bit8u vector, apic_dest_t dest, Bit8u delivery_mode, bx_bool logical_dest, bx_bool level, bx_bool trig_mode);
|
2009-02-21 01:00:42 +03:00
|
|
|
extern int apic_bus_broadcast_interrupt(Bit8u vector, Bit8u delivery_mode, bx_bool trig_mode, int exclude_cpu);
|
2004-10-16 23:34:17 +04:00
|
|
|
|
2005-12-13 23:27:23 +03:00
|
|
|
#define BX_IOAPIC_NUM_PINS (0x18)
|
|
|
|
|
|
|
|
// use the same version as 82093 IOAPIC (0x00170011)
|
|
|
|
#define BX_IOAPIC_VERSION_ID (((BX_IOAPIC_NUM_PINS - 1) << 16) | 0x11)
|
2001-05-23 11:48:11 +04:00
|
|
|
|
|
|
|
class bx_io_redirect_entry_t {
|
2005-12-13 23:27:23 +03:00
|
|
|
Bit32u hi, lo;
|
|
|
|
|
2001-05-23 11:48:11 +04:00
|
|
|
public:
|
2005-12-13 23:27:23 +03:00
|
|
|
bx_io_redirect_entry_t(): hi(0), lo(0x10000) {}
|
|
|
|
|
2010-05-14 16:10:00 +04:00
|
|
|
Bit8u destination() const { return (Bit8u)(hi >> 24); }
|
2006-02-24 12:46:10 +03:00
|
|
|
bx_bool is_masked() const { return (bx_bool)((lo >> 16) & 1); }
|
|
|
|
Bit8u trigger_mode() const { return (Bit8u)((lo >> 15) & 1); }
|
|
|
|
bx_bool remote_irr() const { return (bx_bool)((lo >> 14) & 1); }
|
|
|
|
Bit8u pin_polarity() const { return (Bit8u)((lo >> 13) & 1); }
|
|
|
|
bx_bool delivery_status() const { return (bx_bool)((lo >> 12) & 1); }
|
|
|
|
Bit8u destination_mode() const { return (Bit8u)((lo >> 11) & 1); }
|
|
|
|
Bit8u delivery_mode() const { return (Bit8u)((lo >> 8) & 7); }
|
|
|
|
Bit8u vector() const { return (Bit8u)(lo & 0xff); }
|
|
|
|
|
|
|
|
void set_delivery_status() { lo |= (1<<12); }
|
|
|
|
void clear_delivery_status() { lo &= ~(1<<12); }
|
|
|
|
void set_remote_irr() { lo |= (1<<14); }
|
|
|
|
void clear_remote_irr() { lo &= ~(1<<14); }
|
2008-01-27 01:24:03 +03:00
|
|
|
|
2006-02-24 12:46:10 +03:00
|
|
|
Bit32u get_lo_part () const { return lo; }
|
|
|
|
Bit32u get_hi_part () const { return hi; }
|
|
|
|
void set_lo_part (Bit32u val_lo_part) {
|
|
|
|
// keep high 32 bits of value, replace low 32, ignore R/O bits
|
|
|
|
lo = val_lo_part & 0xffffafff;
|
2001-05-23 11:48:11 +04:00
|
|
|
}
|
2008-01-27 01:24:03 +03:00
|
|
|
void set_hi_part (Bit32u val_hi_part) {
|
2001-05-23 11:48:11 +04:00
|
|
|
// keep low 32 bits of value, replace high 32
|
2006-02-24 12:46:10 +03:00
|
|
|
hi = val_hi_part;
|
2001-05-23 11:48:11 +04:00
|
|
|
}
|
2006-05-27 19:54:49 +04:00
|
|
|
void sprintf_self(char *buf);
|
|
|
|
void register_state(bx_param_c *parent);
|
2001-05-23 11:48:11 +04:00
|
|
|
};
|
|
|
|
|
2010-02-28 17:52:17 +03:00
|
|
|
class bx_ioapic_c : public bx_ioapic_stub_c {
|
2009-02-22 13:44:50 +03:00
|
|
|
public:
|
|
|
|
bx_ioapic_c();
|
|
|
|
virtual ~bx_ioapic_c() {}
|
|
|
|
virtual void init();
|
|
|
|
virtual void reset(unsigned type);
|
|
|
|
virtual void register_state(void);
|
2012-04-01 22:53:16 +04:00
|
|
|
#if BX_DEBUGGER
|
2012-04-23 21:06:19 +04:00
|
|
|
virtual void debug_dump(int argc, char **argv);
|
2012-04-01 22:53:16 +04:00
|
|
|
#endif
|
2009-02-22 13:44:50 +03:00
|
|
|
|
|
|
|
virtual void receive_eoi(Bit8u vector);
|
|
|
|
virtual void set_irq_level(Bit8u int_in, bx_bool level);
|
|
|
|
|
|
|
|
Bit32u read_aligned(bx_phy_address address);
|
|
|
|
void write_aligned(bx_phy_address address, Bit32u data);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bx_phy_address get_base(void) const { return base_addr; }
|
|
|
|
void set_id(Bit32u new_id) { id = new_id; }
|
|
|
|
Bit32u get_id() const { return id; }
|
|
|
|
|
|
|
|
void service_ioapic(void);
|
|
|
|
|
2009-02-19 01:25:04 +03:00
|
|
|
bx_phy_address base_addr;
|
|
|
|
Bit32u id;
|
|
|
|
|
2001-05-23 11:48:11 +04:00
|
|
|
Bit32u ioregsel; // selects between various registers
|
2006-01-08 15:01:25 +03:00
|
|
|
Bit32u intin;
|
2001-05-23 11:48:11 +04:00
|
|
|
// interrupt request bitmask, not visible from the outside. Bits in the
|
|
|
|
// irr are set when trigger_irq is called, and cleared when the interrupt
|
|
|
|
// is delivered to the processor. If an interrupt is masked, the irr
|
|
|
|
// will still be set but delivery will not occur until it is unmasked.
|
|
|
|
// It's not clear if this is how the real device works.
|
|
|
|
Bit32u irr;
|
2005-12-13 23:27:23 +03:00
|
|
|
|
2001-05-23 11:48:11 +04:00
|
|
|
bx_io_redirect_entry_t ioredtbl[BX_IOAPIC_NUM_PINS]; // table of redirections
|
|
|
|
};
|
2006-03-07 01:03:16 +03:00
|
|
|
|
|
|
|
#endif
|
2009-11-20 17:58:48 +03:00
|
|
|
|
|
|
|
#endif
|