[SOS] frequence timer - QEMU

free mail lebre.adrien at free.fr
Mer 5 Nov 19:41:04 CET 2008


Salut,

J'ai posté sur les mailings list de Qemu (users et dev)

  Je ne suis pas parvenu à modifier la fréquence du timer PIC8254 en  
m'appuyant sur le bout de code que a été presenté dans SOS.
Je pense que le souci vient de Qemu. Je voulais savoir si quelqu'un a  
deja rencontré ce type de probleme ?

Merci par avance
Adrien,

Pour infos, j'ai poste sur les mailings lists users et dev de qemu. Je  
n'ai pas vraiment obtenu d'infos pour le moment :
http://lists.gnu.org/archive/html/qemu-devel/2008-10/msg00384.html

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....






Plus d'informations sur la liste de diffusion Sos