Initializing the PIT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I'm trying to initialize the PIT such that it will call my designated ISR. Listed down is my code. The problem is that my ISR is only being called once and then never again. What I'm trying to reach is a timer interrupt to be called at a 100Hz rate. Can eny one point me to what I'm doing wrong? What am I missing here?

The CODE:
-----------------
#define HZ 100
#define LATCH (1193180/HZ) /* 1193180Hz (1.19MHz) is the device input clock */


/*
 * Initializing PIT (System Clock)
 * Further information can be found at:
 * http://www.mega-tokyo.com/osfaq2/index.php/PIT
 * or pit.txt
 */
static void init_pit(void) {
  outb_p(0x34, 0x43);
  outb_p(LATCH & 0xFF, 0x40);
  outb_p(LATCH >> 8, 0x40);
}

#define _set_gate(gate_addr,type,dpl,addr) \
__asm__ ("movw %%dx,%%ax\n\t" \
    "movw %0,%%dx\n\t" \
    "movl %%eax,%1\n\t" \
    "movl %%edx,%2" \
    : \
    : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
    "o" (*((char *) (gate_addr))), \
    "o" (*(4+(char *) (gate_addr))), \
    "d" ((char *) (addr)),"a" (0x00080000))

#define set_intr_gate(n,addr) \
    _set_gate(&_idt[n],14,0,addr)


static int inter_count = 0;
void interrupt_hdlr() {
  k_clrscr();
  str_printk("interrupt ");     /* print given string to screen */
  int_printk(inter_count++);  /* print given integer to screen */
 
  /*iret();*/
}

int k_main() {

  str_printk("Starting the kernel...\n");  /* print given string to screen */
  init_pit();
  set_intr_gate(0x20,&interrupt_hdlr); /* 0x20 is mapped to IRQ 0 which is connected to the output chanel of the PIT */
  outb(0x20,0x21);
  sti();
 
  while(1)
    ;
 
  return 0;
}



What I would like to see is a count of the times my interrupt_hdlr() ISR was called.

Any suggestions?

--
Respectfully yours,

Doron Bleiberg
Tel-Aviv, Israel
Mobile: +972-54-7916711
E-Mail: kernel.doron@xxxxxxxxx

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux