From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LNXP5-00079O-Ae for qemu-devel@nongnu.org; Thu, 15 Jan 2009 13:57:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LNXP3-00079C-UZ for qemu-devel@nongnu.org; Thu, 15 Jan 2009 13:57:18 -0500 Received: from [199.232.76.173] (port=50663 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LNXP3-000799-R9 for qemu-devel@nongnu.org; Thu, 15 Jan 2009 13:57:17 -0500 Received: from savannah.gnu.org ([199.232.41.3]:35886 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LNXP3-0005JM-Dl for qemu-devel@nongnu.org; Thu, 15 Jan 2009 13:57:17 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LNXP2-0005C7-O0 for qemu-devel@nongnu.org; Thu, 15 Jan 2009 18:57:16 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LNXP2-0005Be-DE for qemu-devel@nongnu.org; Thu, 15 Jan 2009 18:57:16 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Thu, 15 Jan 2009 18:57:16 +0000 Subject: [Qemu-devel] [6313] cuda: improve date/time read/write Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6313 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6313 Author: aurel32 Date: 2009-01-15 18:57:15 +0000 (Thu, 15 Jan 2009) Log Message: ----------- cuda: improve date/time read/write - Allow date/time to be written - Use qemu_get_timedate() to initialize the clock Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/hw/cuda.c Modified: trunk/hw/cuda.c =================================================================== --- trunk/hw/cuda.c 2009-01-15 17:27:45 UTC (rev 6312) +++ trunk/hw/cuda.c 2009-01-15 18:57:15 UTC (rev 6313) @@ -131,6 +131,8 @@ CUDATimer timers[2]; + uint32_t tick_offset; + uint8_t last_b; /* last value of B register */ uint8_t last_acr; /* last value of B register */ @@ -510,7 +512,8 @@ const uint8_t *data, int len) { uint8_t obuf[16]; - int ti, autopoll; + int autopoll; + uint32_t ti; switch(data[0]) { case CUDA_AUTOPOLL: @@ -529,13 +532,19 @@ obuf[1] = data[1]; cuda_send_packet_to_host(s, obuf, 2); break; - case CUDA_GET_TIME: case CUDA_SET_TIME: - /* XXX: add time support ? */ - ti = time(NULL) + RTC_OFFSET; + ti = (((uint32_t)data[1]) << 24) + (((uint32_t)data[2]) << 16) + (((uint32_t)data[3]) << 8) + data[4]; + s->tick_offset = ti - (qemu_get_clock(vm_clock) / ticks_per_sec); obuf[0] = CUDA_PACKET; obuf[1] = 0; obuf[2] = 0; + cuda_send_packet_to_host(s, obuf, 3); + break; + case CUDA_GET_TIME: + ti = s->tick_offset + (qemu_get_clock(vm_clock) / ticks_per_sec); + obuf[0] = CUDA_PACKET; + obuf[1] = 0; + obuf[2] = 0; obuf[3] = ti >> 24; obuf[4] = ti >> 16; obuf[5] = ti >> 8; @@ -663,6 +672,7 @@ qemu_put_ubyte(f, s->autopoll); qemu_put_buffer(f, s->data_in, sizeof(s->data_in)); qemu_put_buffer(f, s->data_out, sizeof(s->data_out)); + qemu_put_be32s(f, &s->tick_offset); cuda_save_timer(f, &s->timers[0]); cuda_save_timer(f, &s->timers[1]); } @@ -700,6 +710,7 @@ s->autopoll = qemu_get_ubyte(f); qemu_get_buffer(f, s->data_in, sizeof(s->data_in)); qemu_get_buffer(f, s->data_out, sizeof(s->data_out)); + qemu_get_be32s(f, &s->tick_offset); cuda_load_timer(f, &s->timers[0]); cuda_load_timer(f, &s->timers[1]); @@ -735,6 +746,7 @@ void cuda_init (int *cuda_mem_index, qemu_irq irq) { + struct tm tm; CUDAState *s = &cuda_state; s->irq = irq; @@ -744,6 +756,9 @@ s->timers[1].index = 1; + qemu_get_timedate(&tm, RTC_OFFSET); + s->tick_offset = mktimegm(&tm); + s->adb_poll_timer = qemu_new_timer(vm_clock, cuda_adb_poll, s); *cuda_mem_index = cpu_register_io_memory(0, cuda_read, cuda_write, s); register_savevm("cuda", -1, 1, cuda_save, cuda_load, s);