From patchwork Wed Sep 9 15:42:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5q2m55SwID0/SVNPLTIwMjItSlA/Qj9JQnNrUWoxVFRHa2JLRUk9Pz0=?= X-Patchwork-Id: 33207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 5DE29B6F31 for ; Thu, 10 Sep 2009 02:22:26 +1000 (EST) Received: from localhost ([127.0.0.1]:48401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlPw7-0003Rj-42 for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 12:22:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlPJU-0008L2-R9 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:42:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlPJR-0008K2-PC for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:42:28 -0400 Received: from [199.232.76.173] (port=40554 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlPJR-0008Jt-JR for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:42:25 -0400 Received: from smtp-vip.mem.interq.net ([210.157.1.50]:21805 helo=smtp02.mem.internal-gmo) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlPJQ-0007ct-HQ for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:42:25 -0400 Received: (from root@localhost) by smtp02.mem.internal-gmo (8.13.8/8.12.6) id n89FgMA1026316 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 00:42:22 +0900 (JST) Received: from YOUR-BD18D6DD63.m1.interq.or.jp (ntymns034018.ymns.nt.ftth.ppp.infoweb.ne.jp [211.2.27.18]) by smtp02.mem.internal-gmo with ESMTP id n89FgMYb026312 for ; (me101664 for with PLAIN) Thu, 10 Sep 2009 00:42:22 +0900 (JST) Message-Id: <200909091542.AA00090@YOUR-BD18D6DD63.m1.interq.or.jp> From: t-takeda@m1.interq.or.jp (=?ISO-2022-JP?B?GyRCSXBFRBsoQg==?= =?ISO-2022-JP?B?IBskQj1TTGkbKEI=?=) Date: Thu, 10 Sep 2009 00:42:16 +0900 To: qemu-devel MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) Subject: [Qemu-devel] [PATCH 07/14] i8254: support NEC PC-9821 family X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch is to add NEC PC-9821 family i/o to i8254. diff -ur a/hw/i8254.c b/hw/i8254.c --- a/hw/i8254.c Tue Sep 8 21:26:50 2009 +++ b/hw/i8254.c Wed Sep 9 21:51:37 2009 @@ -58,6 +58,7 @@ }; static PITState pit_state; +static uint64_t pit_freq; static void pit_irq_timer_update(PITChannelState *s, int64_t current_time); @@ -66,7 +67,7 @@ uint64_t d; int counter; - d = muldiv64(qemu_get_clock(vm_clock) - s->count_load_time, PIT_FREQ, ticks_per_sec); + d = muldiv64(qemu_get_clock(vm_clock) - s->count_load_time, pit_freq, ticks_per_sec); switch(s->mode) { case 0: case 1: @@ -91,7 +92,7 @@ uint64_t d; int out; - d = muldiv64(current_time - s->count_load_time, PIT_FREQ, ticks_per_sec); + d = muldiv64(current_time - s->count_load_time, pit_freq, ticks_per_sec); switch(s->mode) { default: case 0: @@ -130,7 +131,7 @@ uint64_t d, next_time, base; int period2; - d = muldiv64(current_time - s->count_load_time, PIT_FREQ, ticks_per_sec); + d = muldiv64(current_time - s->count_load_time, pit_freq, ticks_per_sec); switch(s->mode) { default: case 0: @@ -166,9 +167,9 @@ break; } /* convert to timer units */ - next_time = s->count_load_time + muldiv64(next_time, ticks_per_sec, PIT_FREQ); + next_time = s->count_load_time + muldiv64(next_time, ticks_per_sec, pit_freq); /* fix potential rounding problems */ - /* XXX: better solution: use a clock at PIT_FREQ Hz */ + /* XXX: better solution: use a clock at pit_freq Hz */ if (next_time <= current_time) next_time = current_time + 1; return next_time; @@ -499,6 +500,8 @@ PITState *pit = &pit_state; PITChannelState *s; + pit_freq = PIT_FREQ; + s = &pit->channels[0]; /* the timer 0 is connected to an IRQ */ s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s); @@ -508,6 +511,47 @@ qemu_register_reset(pit_reset, pit); register_ioport_write(base, 4, 1, pit_ioport_write, pit); register_ioport_read(base, 3, 1, pit_ioport_read, pit); + + pit_reset(pit); + + return pit; +} + +/* NEC PC-98x1 */ + +static void pc98_pit_ioport_write(void *opaque, uint32_t addr, uint32_t val) +{ + pit_ioport_write(opaque, addr >> 1, val); +} + +static uint32_t pc98_pit_ioport_read(void *opaque, uint32_t addr) +{ + return pit_ioport_read(opaque, addr >> 1); +} + +PITState *pc98_pit_init(int base, qemu_irq irq) +{ + PITState *pit = &pit_state; + PITChannelState *s; + int i; + + pit_freq = PC98_PIT_FREQ; + + s = &pit->channels[0]; + /* the timer 0 is connected to an IRQ */ + s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s); + s->irq = irq; + + vmstate_register(base, &vmstate_pit, pit); + qemu_register_reset(pit_reset, pit); + for (i = 0; i < 4; i++) { + register_ioport_write(0x71 + (i << 1), 1, 1, pc98_pit_ioport_write, pit); + register_ioport_write(0x3fd9 + (i << 1), 1, 1, pc98_pit_ioport_write, pit); + } + for (i = 0; i < 3; i++) { + register_ioport_read(0x71 + (i << 1), 1, 1, pc98_pit_ioport_read, pit); + register_ioport_read(0x3fd9 + (i << 1), 1, 1, pc98_pit_ioport_read, pit); + } pit_reset(pit);