dos3d

diff src/timer.c @ 23:f2c2e45e8edd

reverted the mistaken push from the deepstone branch
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Sep 2013 18:22:11 +0300
parents 00d84ab1ef26
children
line diff
     1.1 --- a/src/timer.c	Sat Sep 21 18:18:31 2013 +0300
     1.2 +++ b/src/timer.c	Sat Sep 21 18:22:11 2013 +0300
     1.3 @@ -17,9 +17,7 @@
     1.4  */
     1.5  #include <stdio.h>
     1.6  #include <stdlib.h>
     1.7 -#include <conio.h>
     1.8  #include <dos.h>
     1.9 -#include <i86.h>
    1.10  #include "pit8254.h"
    1.11  
    1.12  #define PIT_TIMER_INTR	8
    1.13 @@ -31,10 +29,9 @@
    1.14  
    1.15  static void set_timer_reload(int reload_val);
    1.16  static void cleanup(void);
    1.17 -static void __interrupt __far timer_irq();
    1.18 -static void __interrupt __far dos_timer_intr();
    1.19 -
    1.20 -static void (__interrupt __far *prev_timer_intr)();
    1.21 +static void interrupt dos_timer_intr();
    1.22 +static void interrupt timer_irq();
    1.23 +static void interrupt (*prev_timer_intr)();
    1.24  
    1.25  static unsigned long ticks;
    1.26  static unsigned long tick_interval, ticks_per_dos_intr;
    1.27 @@ -42,8 +39,8 @@
    1.28  
    1.29  void init_timer(int res_hz)
    1.30  {
    1.31 -	_disable();
    1.32  
    1.33 +	disable();
    1.34  	if(res_hz > 0) {
    1.35  		int reload_val = DIV_ROUND(OSC_FREQ_HZ, res_hz);
    1.36  		set_timer_reload(reload_val);
    1.37 @@ -52,16 +49,16 @@
    1.38  		ticks_per_dos_intr = DIV_ROUND(65535L, reload_val);
    1.39  
    1.40  		inum = PIT_TIMER_INTR;
    1.41 -		prev_timer_intr = _dos_getvect(inum);
    1.42 -		_dos_setvect(inum, timer_irq);
    1.43 +		prev_timer_intr = getvect(inum);
    1.44 +		setvect(inum, timer_irq);
    1.45  	} else {
    1.46  		tick_interval = 55;
    1.47  
    1.48  		inum = DOS_TIMER_INTR;
    1.49 -		prev_timer_intr = _dos_getvect(inum);
    1.50 -		_dos_setvect(inum, dos_timer_intr);
    1.51 +		prev_timer_intr = getvect(inum);
    1.52 +		setvect(inum, dos_timer_intr);
    1.53  	}
    1.54 -	_enable();
    1.55 +	enable();
    1.56  
    1.57  	atexit(cleanup);
    1.58  }
    1.59 @@ -72,15 +69,15 @@
    1.60  		return; /* init hasn't ran, there's nothing to cleanup */
    1.61  	}
    1.62  
    1.63 -	_disable();
    1.64 +	disable();
    1.65  	if(inum == PIT_TIMER_INTR) {
    1.66  		/* restore the original timer frequency */
    1.67  		set_timer_reload(65535);
    1.68  	}
    1.69  
    1.70  	/* restore the original interrupt handler */
    1.71 -	_dos_setvect(inum, prev_timer_intr);
    1.72 -	_enable();
    1.73 +	setvect(inum, prev_timer_intr);
    1.74 +	enable();
    1.75  }
    1.76  
    1.77  void reset_timer(void)
    1.78 @@ -95,15 +92,15 @@
    1.79  
    1.80  static void set_timer_reload(int reload_val)
    1.81  {
    1.82 -	outp(PORT_CMD, CMD_CHAN0 | CMD_ACCESS_BOTH | CMD_OP_SQWAVE);
    1.83 -	outp(PORT_DATA0, reload_val & 0xff);
    1.84 -	outp(PORT_DATA0, (reload_val >> 8) & 0xff);
    1.85 +	outportb(PORT_CMD, CMD_CHAN0 | CMD_ACCESS_BOTH | CMD_OP_SQWAVE);
    1.86 +	outportb(PORT_DATA0, reload_val & 0xff);
    1.87 +	outportb(PORT_DATA0, (reload_val >> 8) & 0xff);
    1.88  }
    1.89  
    1.90 -static void __interrupt __far dos_timer_intr()
    1.91 +static void interrupt dos_timer_intr()
    1.92  {
    1.93  	ticks++;
    1.94 -	_chain_intr(prev_timer_intr);	/* DOES NOT RETURN */
    1.95 +	prev_timer_intr();
    1.96  }
    1.97  
    1.98  /* first PIC command port */
    1.99 @@ -111,7 +108,7 @@
   1.100  /* end of interrupt control word */
   1.101  #define OCW2_EOI	(1 << 5)
   1.102  
   1.103 -static void __interrupt __far timer_irq()
   1.104 +static void interrupt timer_irq()
   1.105  {
   1.106  	static unsigned long dos_ticks;
   1.107  
   1.108 @@ -121,11 +118,10 @@
   1.109  		/* I suppose the dos irq handler does the EOI so I shouldn't
   1.110  		 * do it if I am to call the previous function
   1.111  		 */
   1.112 +		prev_timer_intr();
   1.113  		dos_ticks = 0;
   1.114 -		_chain_intr(prev_timer_intr);	/* XXX DOES NOT RETURN */
   1.115 -		return;	/* just for clarity */
   1.116 +	} else {
   1.117 +		/* send EOI to the PIC */
   1.118 +		outportb(PIC1_CMD, OCW2_EOI);
   1.119  	}
   1.120 -
   1.121 -	/* send EOI to the PIC */
   1.122 -	outp(PIC1_CMD, OCW2_EOI);
   1.123  }