From: adrien lebre <lebre.adrien@free.fr>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] i8254 - Cannot change Timer frequency
Date: Fri, 10 Oct 2008 18:54:56 +0200 [thread overview]
Message-ID: <1223657696.48ef88e0224fa@imp.free.fr> (raw)
Hi all,
I posted the following question on the QEMU general forum few weeks ago
(http://qemu-forum.ipi.fi/viewtopic.php?f=3&t=4638#p13814). Someone adviced me
to post it directly on the development mailing list. I already tried to look up
into the archive but I didn't find any answers. Since several people seems to be
concerned by this issue, I finally decided to do it.
Thanks in advance for your help.
Best Regards,
Adrien
PS: please find below the copy/paste from the QEMU forum.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
i8254 - Cannot change Timer frequency
by alebre on Wed Sep 17, 2008 4:26 pm
Hi all,
In the context of study, we have to develop a simple operating system from
scratch. To develop our ''kernel'' we are using QEMU.
For few days, we have fighted with the I8254 chip in order to create a timer for
our system.
Based on the code provided in the Simple OS
(http://sos.enix.org/lxr/source/hwcore/i8254.c), we are trying to change the
frequency.
Unfortunately, whatever the value of nb_tick, the frequency does not change.
Here, I just copied the related code. We tried by setting the nb_tick with
11931, 1193 and 119 directly in the following functions. Unfortunately, the time
frequency (according to the IRQ timer handler) is still the same .
Does anyone have an idea ?
Thanks in advance,
Adrien.
/** 82c54 clock frequency */
#define I8254_MAX_FREQ 1193180
/* Ports to communicate with the 82c54 */
#define I8254_TIMER0 0x40
#define I8254_TIMER1 0x41
#define I8254_TIMER2 0x42
#define I8254_CONTROL 0x43
...
int i8254_set_frequency(unsigned int freq){
unsigned int nb_tick;
if (freq <= 0)
return -255;
/* Compute counter value */
nb_tick = I8254_MAX_FREQ / freq;
/* Counter must be between 1 and 65536 */
if (nb_tick > 65536)
return -255;
if (nb_tick <= 0)
return -255;
/* The i8254 interprets 0 to mean counter == 65536, because 65536
cannot be coded on 16bits */
if (nb_tick == 65536)
nb_tick = 0;
/* We want to configure timer0, we want to send both LSB+MSB to set
timer0 freq (-> 0x30), and we configure timer0 in mode 2, ie as a
rate generator (-> 0x4) ==> 0x34 */
outb(0x34, I8254_CONTROL);
/* Send LSB of counter first */
outb((nb_tick & 0xFF), I8254_TIMER0);
/* Send MSB of counter */
outb((nb_tick >> 8) & 0xFF, I8254_TIMER0);
return 1;
}
Re: i8254 - Cannot change Timer frequency
by alebre on Wed Sep 17, 2008 4:37 pm
What is the behavior of QEMU with regard to such instructions ?
Does QEMU emulate the I8254 chip or does it simply forward the instruction to
the host OS ? In that case, the host OS could simply does not consider such an
instruction ?
Adrien, still looking for some explanations....
--
next reply other threads:[~2008-10-10 16:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-10 16:54 adrien lebre [this message]
2008-10-11 5:15 ` [Qemu-devel] i8254 - Cannot change Timer frequency Mulyadi Santosa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1223657696.48ef88e0224fa@imp.free.fr \
--to=lebre.adrien@free.fr \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).