From: Glauber Costa Subject: [PATCH 11/15] manipulate the gpe bits and send sci up the os. Date: Fri, 22 Feb 2008 18:34:35 -0300 Message-ID: <1203716079-4872-12-git-send-email-gcosta@redhat.com> References: <1203716079-4872-1-git-send-email-gcosta@redhat.com> <1203716079-4872-2-git-send-email-gcosta@redhat.com> <1203716079-4872-3-git-send-email-gcosta@redhat.com> <1203716079-4872-4-git-send-email-gcosta@redhat.com> <1203716079-4872-5-git-send-email-gcosta@redhat.com> <1203716079-4872-6-git-send-email-gcosta@redhat.com> <1203716079-4872-7-git-send-email-gcosta@redhat.com> <1203716079-4872-8-git-send-email-gcosta@redhat.com> <1203716079-4872-9-git-send-email-gcosta@redhat.com> <1203716079-4872-10-git-send-email-gcosta@redhat.com> <1203716079-4872-11-git-send-email-gcosta@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: marcelo@kvack.org, avi@qumranet.com, Glauber Costa , chrisw@sous-sol.org To: kvm-devel@lists.sourceforge.net Return-path: In-Reply-To: <1203716079-4872-11-git-send-email-gcosta@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Signed-off-by: Glauber Costa --- qemu/hw/acpi.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c index 60d3094..038e993 100644 --- a/qemu/hw/acpi.c +++ b/qemu/hw/acpi.c @@ -534,10 +534,13 @@ void qemu_system_powerdown(void) } #endif unsigned long gpe_base = 0xafe0; +unsigned long status_base = 0xaf00; struct gpe_regs { uint16_t sts; /* status */ uint16_t en; /* enabled */ + uint8_t up; + uint8_t down; }; static struct gpe_regs gpe; @@ -547,6 +550,13 @@ static uint32_t gpe_readb(void *opaque, uint32_t val = 0; struct gpe_regs *g = opaque; switch (addr) { + case 0xaf00: + val = g->up; + break; + case 0xaf01: + val = g->down; + break; + case 0xafe0: val = g->sts & 0xFF; break; @@ -573,6 +583,13 @@ static void gpe_writeb(void *opaque, uin { struct gpe_regs *g = opaque; switch (addr) { + case 0xaf00: + g->up = val; + break; + case 0xaf01: + g->down = val; + break; + case 0xafe0: g->sts = (g->sts & ~0xFFFF) | (val & 0xFFFF); break; @@ -601,9 +618,34 @@ void qemu_system_hot_add_init(char *cpu_ register_ioport_write(gpe_base, 4, 1, gpe_writeb, &gpe); register_ioport_read(gpe_base, 4, 1, gpe_readb, &gpe); + register_ioport_write(status_base, 4, 1, gpe_writeb, &gpe); + register_ioport_read(status_base, 4, 1, gpe_readb, &gpe); + model = cpu_model; } +static void enable_processor(struct gpe_regs *g, int cpu) +{ + g->sts |= 1; + g->en |= 1; + g->up |= (1 << cpu); +} + +static void disable_processor(struct gpe_regs *g, int cpu) +{ + g->sts |= 1; + g->en |= 1; + g->down |= (1 << cpu); +} + void qemu_system_cpu_hot_add(int cpu, int state) { + qemu_set_irq(pm_state->irq, 1); + gpe.up = 0; + gpe.down = 0; + if (state) + enable_processor(&gpe, cpu); + else + disable_processor(&gpe, cpu); + qemu_set_irq(pm_state->irq, 0); } -- 1.4.2 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/