Ejemplo n.º 1
0
void __grab_int_ctrl_break( void )
{
    if( __old_int_ctrl_break == 0 ) {
#if defined(__WINDOWS_386__)
        __old_int_ctrl_break = _dos_getvect( CTRL_BRK_VEC );
        TinySetVect( CTRL_BRK_VEC, (void (_WCNEAR *)(void))__int_ctrl_break_handler );
#elif defined( __386__ )
        if( _IsPharLap() ) {
            __old_int_ctrl_break = pharlap_rm_getvect( CTRL_BRK_VEC );
            __old_pm_int_ctrl_break = pharlap_pm_getvect( CTRL_BRK_VEC );
            pharlap_setvect( CTRL_BRK_VEC, (pfun) (void (_WCNEAR *)(void))__int_ctrl_break_handler );
        } else if( __DPMI_hosted() == 1 ) {
            DPMILockLinearRegion((long)__int_ctrl_break_handler,
                ((long)__restore_int23 - (long)__int_ctrl_break_handler));
            __old_int_ctrl_break = DPMIGetRealModeInterruptVector( CTRL_BRK_VEC );
            __old_pm_int_ctrl_break = DPMIGetPMInterruptVector( CTRL_BRK_VEC );
            DPMISetPMInterruptVector( CTRL_BRK_VEC, __int_ctrl_break_handler );
        } else {        /* what it used to do */
            __old_int_ctrl_break = _dos_getvect( CTRL_BRK_VEC );
            _dos_setvect( CTRL_BRK_VEC, __int_ctrl_break_handler );
        }
#else
        __old_int_ctrl_break = _dos_getvect( CTRL_BRK_VEC );
        _dos_setvect( CTRL_BRK_VEC, __int_ctrl_break_handler );
#endif
        if( __int23_exit == __null_int23_exit ) {
            __int23_exit = __restore_int_ctrl_break;
        } else if( __int23_exit == __restore_int23 ) {
            __int23_exit = __restore_int;
        }
    }
}
Ejemplo n.º 2
0
Archivo: timer.c Proyecto: mdurrer/cgd
void init_timer(int res_hz)
{
	_disable();

	if(res_hz > 0) {
		int reload_val = DIV_ROUND(OSC_FREQ_HZ, res_hz);
		set_timer_reload(reload_val);

		tick_interval = DIV_ROUND(1000, res_hz);
		ticks_per_dos_intr = DIV_ROUND(65535L, reload_val);

		inum = PIT_TIMER_INTR;
		prev_timer_intr = _dos_getvect(inum);
		_dos_setvect(inum, timer_irq);
	} else {
		tick_interval = 55;

		inum = DOS_TIMER_INTR;
		prev_timer_intr = _dos_getvect(inum);
		_dos_setvect(inum, dos_timer_intr);
	}
	_enable();

	atexit(cleanup);
}
Ejemplo n.º 3
0
/*-----------------------------------------------------------*/
portBASE_TYPE xPortStartScheduler( void )
{
pxISR pxOriginalTickISR;

	/* This is called with interrupts already disabled. */

	/* Remember what was on the interrupts we are going to use
	so we can put them back later if required. */
	pxOldSwitchISR = _dos_getvect( portSWITCH_INT_NUMBER );
	pxOriginalTickISR = _dos_getvect( portTIMER_INT_NUMBER );
	pxOldSwitchISRPlus1 = _dos_getvect( portSWITCH_INT_NUMBER + 1 );

	prvSetTickFrequency( configTICK_RATE_HZ );

	/* Put our manual switch (yield) function on a known
	vector. */
	_dos_setvect( portSWITCH_INT_NUMBER, prvYieldProcessor );

	/* Put the old tick on a different interrupt number so we can
	call it when we want. */
	_dos_setvect( portSWITCH_INT_NUMBER + 1, pxOriginalTickISR );

	/* The ISR used depends on whether the preemptive or cooperative
	scheduler is being used. */
	#if( configUSE_PREEMPTION == 1 )
	{
		/* Put our tick switch function on the timer interrupt. */
		_dos_setvect( portTIMER_INT_NUMBER, prvPreemptiveTick );
	}
	#else
	{
		/* We want the timer interrupt to just increment the tick count. */
		_dos_setvect( portTIMER_INT_NUMBER, prvNonPreemptiveTick );
	}
    #endif

	/* Setup a counter that is used to call the DOS interrupt as close
	to it's original frequency as can be achieved given our chosen tick
	frequency. */
	sDOSTickCounter = portTICKS_PER_DOS_TICK;

	/* Clean up function if we want to return to DOS. */
	if( setjmp( xJumpBuf ) != 0 )
	{
		prvExitFunction();
		xSchedulerRunning = pdFALSE;
	}
	else
	{
		xSchedulerRunning = pdTRUE;

		/* Kick off the scheduler by setting up the context of the first task. */
		portFIRST_CONTEXT();
	}

	return xSchedulerRunning;
}
Ejemplo n.º 4
0
/*..........................................................................*/
void QF_onStartup(void) {
                                      /* save the origingal DOS vectors ... */
    l_dosTmrISR = _dos_getvect(TMR_VECTOR);
    l_dosKbdISR = _dos_getvect(KBD_VECTOR);

    QF_INT_DISABLE();
    _dos_setvect(TMR_VECTOR, &ISR_tmr);
    _dos_setvect(KBD_VECTOR, &ISR_kbd);
    QF_INT_ENABLE();
}
Ejemplo n.º 5
0
//............................................................................
void QF::onStartup(void) {
                                         // save the origingal DOS vectors ...
    l_dosTmrISR = _dos_getvect(TMR_VECTOR);
    l_dosKbdISR = _dos_getvect(KBD_VECTOR);

    QF_INT_LOCK(dummy);
    _dos_setvect(TMR_VECTOR, &ISR_tmr);
    _dos_setvect(KBD_VECTOR, &ISR_kbd);
    QF_INT_UNLOCK(dummy);
}
Ejemplo n.º 6
0
void    R_TrapInit( void ) {
//====================

    int enable_excpt;

    enable_excpt = __EnableF77RTExceptionHandling();

    if( enable_excpt ) {
        signal( SIGSEGV, AbnormalTerm );
        signal( SIGILL, AbnormalTerm );
    }
#if !defined( __WINDOWS__ )
    signal( SIGINT, BreakSignal );
#endif
#if defined( __DOS__ )
    if( __NonIBM ) {
        // Assume NEC
        BreakVector = 0x06;
    }
    CBSave = _dos_getvect( BreakVector );
    _dos_setvect( BreakVector, BreakHandler );
  #if defined( __386__ )
    if( _IsPharLap() ) {
        CBRealSave = _dos_getrealvect( BreakVector );
        _dos_setvectp( BreakVector, BreakHandler );
    }
  #endif
    ISave = _dos_getvect( IntOverFlow );
    _dos_setvect( IntOverFlow, IOvFlHandler );
    ZSave = _dos_getvect( IntDivBy0 );
    _dos_setvect( IntDivBy0, IDivZHandler );
#elif defined( __WINDOWS__ )
 #if !defined( __386__ )
    ISave = _dos_getvect( IntOverFlow );
    _dos_setvect( IntOverFlow, IOvFlHandler );
    ZSave = _dos_getvect( IntDivBy0 );
    _dos_setvect( IntDivBy0, IDivZHandler );
 #endif
#elif defined( __OS2_386__ ) || defined( __NT__ )
    signal( SIGBREAK, BreakSignal );
    if( enable_excpt ) {
        signal( SIGIDIVZ, IDivZSignal );
        signal( SIGIOVFL, IOvFlSignal );
    }
#elif defined( __OS2_286__ )
    signal( SIGBREAK, BreakSignal );
    DosSetVec( IntOverFlow, (PFN)IOvFlHandler, (PFN FAR *)&ISave );
    DosSetVec( IntDivBy0, (PFN)IDivZHandler, (PFN FAR *)&ZSave );
#endif
    FPTrapInit();
}
Ejemplo n.º 7
0
PUBLIC void SER_InitComInterrupts(SER_PComPort p, void __interrupt (__far *isr)(void)) {
    byte t;
    assert(p != NULL);

        // Init interrupts.
    outp(p->port + SERR_IER, 0);
    t = inp(p->port + SERR_MCR);
    t |= SERR_MCR_OUT2;
    t &= ~SERR_MCR_LOOPBACK;
    outp(p->port + SERR_MCR, t);

    if (isr != NULL) {
            // Save previous vector and hook vector.
        p->oldint = _dos_getvect(p->irq + 8);
        _dos_setvect(p->irq + 8, isr);
    }
        // Setup comm interrupts.

    outp(0x21, inp(0x21) & ~(1 << p->irq)); // Mask in port's IRQ.
    _disable();
    outp(p->port + SERR_IER, SERR_IER_RXREADY | SERR_IER_TXREADY);
    outp(0x20, 0xC2);

        // Raise DTR
    outp(p->port + SERR_MCR, inp(p->port + SERR_MCR) | SERR_MCR_DTR);

    _enable();
}
Ejemplo n.º 8
0
int kb_init(int bufsz)
{
	if(DONE_INIT) {
		fprintf(stderr, "keyboard driver already initialized!\n");
		return 0;
	}

	buffer_size = bufsz;
	if(buffer_size && !(buffer = malloc(buffer_size * sizeof *buffer))) {
		fprintf(stderr, "failed to allocate input buffer, continuing without\n");
		buffer_size = 0;
	}
	buf_ridx = buf_widx = 0;
	last_key = -1;

	memset(keystate, 0, sizeof keystate);
	num_pressed = 0;

	/* set our interrupt handler */
	_disable();
	prev_handler = _dos_getvect(KB_INTR);
	_dos_setvect(KB_INTR, kbintr);
	_enable();

	return 0;
}
Ejemplo n.º 9
0
static int pc_init_vidmode ()
{
	union REGS r;
	int i;

	clock_count = 0;
	clock_ticks = 0;

	screen_buffer = calloc (GFX_WIDTH, GFX_HEIGHT);

	prev_08 = _dos_getvect (0x08);
	_dos_setvect (0x08, tick_increment);

	memset (&r, 0x0, sizeof(union REGS));
#ifdef __WATCOMC__
	r.w.ax = 0x13;
	int386 (0x10, &r, &r);
#endif

#ifdef __TURBOC__
	r.x.ax = 0x13;
	int86 (0x10, &r, &r);
#endif

	__outp (0x3c8, 0);
	for (i = 0; i < 32 * 3; i++)
		__outp (0x3c9, palette[i]);

	return err_OK;
}
Ejemplo n.º 10
0
void main(void)
 {
   void interrupt (*original_handler)();

   int old_count = 0;

   original_handler = _dos_getvect(5);

   _disable();  // Turn off interrupts during _dos_setvect
   _dos_setvect(5, handler);
   _enable();

   printf("Press Shift-PrtSc three times or any key to end\n");
     
   while (count < 3)
     if (count != old_count)
       {
         printf("Shift-PrtSc pressed\n");
         old_count = count;
       }
   
   _disable();
   _dos_setvect(5, original_handler);
   _enable();
 }
Ejemplo n.º 11
0
 void GetSysIntVect (int16 Num, int32 *IHPtr1p, int32 *IHPtr2p) {
	INT_HANDLER_PTR IHPtr ;
	IHPtr =_dos_getvect(Num);
	// destruct IHPtr in two long int values
	*IHPtr1p = *((lptr)(&IHPtr));  // get low long word
	*IHPtr2p = *((lptr)(&IHPtr)+1); // get high long word
 }// GetSysIntVect
Ejemplo n.º 12
0
BOOL IsNetBiosInstalled(void)
    {
    unsigned int wNBRetCode;
    NCB ncbTest;
    DWORD dwHandler;

    /* Make sure interrupt vector 5C is not NULL */
    dwHandler = (DWORD)(_dos_getvect(NB_INTERRUPT));
    if ((dwHandler == 0) || (dwHandler >= 0xF0000000))
	return FALSE;

    /* Issue an invalid command, expecting a meaningful error code */
    memset(&ncbTest, 0, sizeof(NCB));
    ncbTest.ncb_command = 0xFF;
    wNBRetCode = NetBios(&ncbTest);

    switch (wNBRetCode)
	{
	case NRC_ILLCMD:
	/* case NB_ERR_BAD_ADAPTER: (?) */
	    return TRUE;

	default:
	    /* Return codes 0x40 to 0x4F mean "Unusual network condition"
			    0x50 to 0xFE mean "Adapter malfunction"
		These mean NetBIOS is there */
	    if ((wNBRetCode >= 0x40) && (wNBRetCode <= 0xFE))
		return TRUE;
	    else
		return FALSE;
	}
    }
Ejemplo n.º 13
0
void InitMSDOS(void)
{
#ifdef BPP8
  int J;
  /* Create RRR:GGG:BB static color palette in BPP8 mode */
  for(J=0;J<256;J++)
    SetPalette(J,(J>>5)*255/7,((J>>2)&0x07)*255/7,(J&0x03)*255/3);
#endif

  /* Initialize variables */
  IRQ1Old   = _dos_getvect(0x09);
  IRQ0Old   = 0;
  MouseON   = 0;
  SyncReady = 0;
  SyncFreq  = 0;
  VGAMode   = 0;
  JoyState  = 0;
  LastKey   = 0;
  KeyModes  = 0;
  SndRate   = 0;

  /* No output image yet */
  OutScreen.Data = 0;

  /* Install new keyboard interrupt */
  _dos_setvect(0x09,IRQ1Handler);
}
Ejemplo n.º 14
0
void main(void)
 {
   int i;

   // Zero the function counts
   for (i = 0; i < 255; i++)
     function[i] = 0;

   original_handler = _dos_getvect(0x21);
   _disable();
   _dos_setvect(0x21, handler);
   _enable();

   printf("This is a message\n");
   fprintf(stdout, "This is a second message\n");

   printf("Current disk is %c\n", getdisk() + 'A');

   _disable();
   _dos_setvect(0x21, original_handler);
   _enable();


   for (i = 0; i <= 255; i++)
     if (function[i])
       printf("Function %x called %d times\n", i, function[i]);
 }
Ejemplo n.º 15
0
/*..........................................................................*/
void QF_onStartup(void) {
    uint16_t count;
                                      /* save the origingal DOS vectors ... */
    l_dosTmrISR   = _dos_getvect(TMR_VECTOR);
    l_dosKbdISR   = _dos_getvect(KBD_VECTOR);

    QF_INT_DISABLE();
    count = (uint16_t)(((1193180 * 2) / BSP_TICKS_PER_SEC + 1) >> 1);
    outp(0x43, 0x36);                 /* use mode-3 for timer 0 in the 8254 */
    outp(0x40, count & 0xFF);                  /* load low  byte of timer 0 */
    outp(0x40, (count >> 8) & 0xFF);           /* load high byte of timer 0 */

    _dos_setvect(TMR_VECTOR, &ISR_tmr);
    _dos_setvect(KBD_VECTOR, &ISR_kbd);
    QF_INT_ENABLE();
}
Ejemplo n.º 16
0
T_void main(T_void)
{
    puts("Installing color mapper.") ;
    IOldTickerInterrupt = _dos_getvect(TICKER_INTERRUPT_NUMBER);
    _dos_setvect(TICKER_INTERRUPT_NUMBER, ITickerInterruptSimple);
    puts("Installed.") ;
    keep(0, (_SS + (_SP/16) - _psp));
}
Ejemplo n.º 17
0
int LM_Init(unsigned char **pScreenBuffer)
{
    prev_int_09 = _dos_getvect(9);
    _dos_setvect(9, _kb_handler);
    LM_GFX_Init();
    *pScreenBuffer = &ScreenBuffer[0];
    return 1;
}
Ejemplo n.º 18
0
/*..........................................................................*/
void QF_run(void) {
                                  /* install uC/OS-II context switch vector */
    l_dosSpareISR = _dos_getvect(uCOS);
    _dos_setvect(uCOS, (void interrupt (*)(void))&OSCtxSw);

    /* NOTE the QF_onStartup() callback must be invoked from the task level */
    OSStart();                               /* start uC/OS-II multitasking */
}
Ejemplo n.º 19
0
static int get_dpt(unsigned char *dpt)
{
	unsigned char __far *int1e = (unsigned char *)(_dos_getvect(0x1e));                                   
	int n;
    
   	if (int1e[0] == 0xC4 && int1e[1] == 0xC4) return 0;       
	for (n = 0; n < 11; n++) dpt[n] = int1e[n]; 
	return 1;	
}       
Ejemplo n.º 20
0
int monint( int print )
{
    int i;

    for( i = 0; i < NUM_INTS; i++ ) {
        prev_int[i] = _dos_getvect( i );
    }

    if( print ) techoutput( "\nInstalling interrupt handlers\n" );
    for( i = NUM_INTS - 1 ; i >= 0; i-- ) {
        _dos_setvect( i, new_int[i] );
    }

    if( print ) {
        Sample_On = 1;
        while( int_tick[ 8 ] < 24 );
        Sample_On = 0;

        techoutput( "Normal system operation:\n" );
        int_summary();
        memset( (void *)int_tick, 0, sizeof( int_tick ) );

        techoutput( "Starting exception test...\n" );
    }
    Sample_On = 1;
    _TEST_NDP();
    while( int_tick[ 8 ] < 24 );
    Sample_On = 0;

    _INIT_NDP();

    NDP_Status = NDP_Env.status_word;

    if( print ) {
        techoutput( "System operation with NDP divide by zero exception:\n" );
        int_summary();
        techoutput( "Restoring interrupt handlers\n" );
    }
    for( i = NUM_INTS - 1 ; i >= 0; i-- ) {
        _dos_setvect( i, prev_int[i] );
    }

#define TEST_FPU(x,y) techoutput( "\t%s " y "\n", \
                ((NDP_Status & x) ? "  " : "No") )

    if( print ) {
        techoutput( "80x87 status:\n" );
        TEST_FPU( SW_INVALID, "invalid operation" );
        TEST_FPU( SW_DENORMAL, "denormalized operand" );
        TEST_FPU( SW_ZERODIVIDE, "divide by zero" );
        TEST_FPU( SW_OVERFLOW, "overflow" );
        TEST_FPU( SW_UNDERFLOW, "underflow" );
        TEST_FPU( SW_INEXACT, "inexact result" );
    }

    return( (int_tick[ 2 ] != 0) && ((NDP_Status & SW_ZERODIVIDE) != 0) );
}
Ejemplo n.º 21
0
void key_init()
{
	// Initialize queue

	Status1= *(ubyte*)0x417;
	Status2= *(ubyte*)0x418;
 
	keyd_time_when_last_pressed = timer_get_fixed_seconds();
	keyd_buffer_type = 1;
	keyd_repeat = 1;
	key_data.in_key_handler = 0;
	key_data.E0Flag = 0;
	key_data.E1Flag = 0;

	// Clear the keyboard array
	key_flush();

	if (Installed) return;
	Installed = 1;

	//--------------- lock everything for the virtal memory ----------------------------------
	if (!dpmi_lock_region ((void near *)key_handler, (char *)key_handler_end - (char near *)key_handler))	{
		Error( "Can't lock keyboard handler!\n" );
	}
	if (!dpmi_lock_region (&key_data, sizeof(keyboard)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_buffer_type, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_repeat, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_editor_mode, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_last_pressed, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_last_released, sizeof(char)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_pressed, sizeof(char)*256))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}
	if (!dpmi_lock_region (&keyd_time_when_last_pressed, sizeof(int)))	{
		Error( "Can't lock keyboard handler's data!\n" );
	}

	key_data.prev_int_9 = _dos_getvect( 9 );
	_dos_setvect( 9, key_handler );

	atexit( key_close );
}
Ejemplo n.º 22
0
void init_sound(void)
{
        int audiodevice ;
        char *ptr ;

        init_record() ;

        if (!isSound) return ;
        audiodevice = detect_audiodevice() ;
        if (!audiodevice) {
                printf("Unable to found any suported soundcard.\n") ;
                isSound = FALSE ;
                return ;
        }


        if (!allocdosmem(samples_to_generate*2+65536+32, &lowmemsample)) {
                printf("*** Can't allocate lowmem area for sound emulation.\n") ;
                isSound = FALSE ;
                return ;
        }
        if (isMIDI&&(audiodevice == AUDIODEVICE_SOUNDBLASTER)) {
                printf("ST MIDI emulation enabled.\n") ;
                isSound = FALSE ;
                return ;
        }
        isMIDI = FALSE ;

        ptr = (char *)((lowmemsample.linear_base+65536)&0xffff0000) ;
        audio_buffer1 = ptr ;
        audio_buffer2 = audio_buffer1 + samples_to_generate ;
        memset(audio_buffer1,0x80,(samples_to_generate*2)+32) ;
        AudioDevice = audiodevice ;

        Reset_Sound() ;
        Ym2149Init() ;
        init_soundcard() ;

        if (AudioDevice == AUDIODEVICE_SOUNDBLASTER) {
                audio.vector = (audio.irq<8) ? audio.irq+8 : audio.irq+0x68 ;
                audio.picport= (audio.irq<8) ? 0x20 : 0xa0 ;
                audio.maskirq=1<<(audio.irq&7) ;
                prev_sound_handler = _dos_getvect(audio.vector) ;
                _dos_setvect(audio.vector,inthandler) ;
                outp(audio.picport+1,inp(audio.picport+1)&~audio.maskirq) ;
        }

        pause_sound() ;
        printf("soundchip emulation initialized. (c) Arnaud Carre.\n") ;
        if (isSamples)
                printf("STF samples support added (still *very* buggy - you've been warned)\n") ;
        else printf("no STF samples support.\n") ;
        printf("MIDI emulation disabled.\n") ;
}
Ejemplo n.º 23
0
void main()
  {
    prev_int_1c = _dos_getvect( 0x1c );
    _dos_setvect( 0x1c, timer_rtn );
    while( compile_a_line() ) {
        if( clock_ticks >= BLIP_COUNT ) {
            putchar( '.' );
            clock_ticks -= BLIP_COUNT;
        }
    }
    _dos_setvect( 0x1c, prev_int_1c );
  }
Ejemplo n.º 24
0
void CloserInit(void)
// i.e. closer to spawning child
{
	//----- get interrupt -------
	OldInt9 = _dos_getvect(0x09);

	//----- redirect interrupts -------
	_disable();
	_dos_setvect(0x09, MyInt9);
	_enable();

	atexit( CloserDone );
}
Ejemplo n.º 25
0
static void InitializeNonportableFeatures(
  void *theEnv)
  {
#if MAC_MCW || IBM_MCW
#pragma unused(theEnv)
#endif
#if ! WINDOW_INTERFACE

#if MAC
   AddPeriodicFunction("systemtask",CallSystemTask,0);
#endif

#if VAX_VMS || UNIX_V || UNIX_7 || IBM_GCC
   signal(SIGINT,CatchCtrlC);
#endif

#if IBM_TBC
   SystemDependentData(theEnv)->OldCtrlC = getvect(0x23);
   SystemDependentData(theEnv)->OldBreak = getvect(0x1b);
   setvect(0x23,CatchCtrlC);
   setvect(0x1b,CatchCtrlC);
   atexit(RestoreInterruptVectors);
#endif

#if IBM_MSC || IBM_ICB
   SystemDependentData(theEnv)->OldCtrlC = _dos_getvect(0x23);
   SystemDependentData(theEnv)->OldBreak = _dos_getvect(0x1b);
   _dos_setvect(0x23,CatchCtrlC);
   _dos_setvect(0x1b,CatchCtrlC);
   atexit(RestoreInterruptVectors);
#endif

#if IBM_ZTC || IBM_SC
   _controlc_handler = CatchCtrlC;
   controlc_open();
#endif

#endif
  }
Ejemplo n.º 26
0
int TimerInit(void)
{
  memset((char *)TimerArr,0,sizeof(TimerArr));
  OldTimerProc=_dos_getvect( TIMER_VECTOR );
  _dos_setvect( TIMER_VECTOR, TimerDeal );

  outp(0x43, 0x34);  /*- set timer_count, first low, then high byte -*/
  outp(0x40, 0x0);
  outp(0x40, 0x20);  /*- 0x2000, that is 1/8 of normal timer_count -*/

  TimerTicks_8=TimerTicks=0;
  ReturnOK();
}
Ejemplo n.º 27
0
void init_floppyio(void)
{
	int status;

	ticktimer = 0x00;
	intflag = 0x00;
	time_tick_count = 0x00;

	memset(&sector_buf,0,512);

	status	= chs_biosdisk(_DISK_RESET,0, 0, 255,0, 1, &sector_buf);
	if(status)
		hxc_printf(0,"FDC Reset error : Return value %d\n",status);

	prev_floppy_int	= _dos_getvect( 8+0x6 );
	_dos_setvect( 8+0x6, floppy_interrupt_handler );

	prev_timer_int = _dos_getvect( 8+0x0 );
	_dos_setvect( 8+0x0, timer_interrupt_handler	);

	if(_dos_allocmem( 32768/16, &dmabuf_seg_rd ))
	{
		hxc_printf(0,"Alloc Error !\n");
		for(;;);
	}
	bufrd = (unsigned char *)MK_FP(dmabuf_seg_rd, 0);

	if(_dos_allocmem( 32768/16, &dmabuf_seg_wr ))
	{
		hxc_printf(0,"Alloc Error !\n");
		for(;;);
	}
	bufwr = (unsigned char *)MK_FP(dmabuf_seg_wr, 0);

	reset_drive(0);
}
Ejemplo n.º 28
0
void init_com1(void)
  {
  cout << "Begin Com1 initialization.   ";
  // disable cpu interrupts
  _disable();
  
  // set vector for COM1, irq4
  com1_old_vector = _dos_getvect(4+8); // irq4
  _dos_setvect(4+8, com1_isr);
     
  // initialize COM1 16550
  _outp( COM1_LCR, (DLAB1 | NO | STOP1 | EIGHT));
  _outp( COM1_DLL, BR_9600);
  //_outp( COM1_DLL, BR_115200);
  //_outp( COM1_DLL, BR_57600);
  //_outp( COM1_DLL, BR_19200);
  _outp( COM1_DLM, 0);
  _outp( COM1_LCR, (DLAB0 | NO | STOP1 | EIGHT));
  //_outp( COM1_FCR, 0xc1); // enable FIFOs to 14, reset FIFOs
  _outp( COM1_FCR, 0xc7); // enable FIFOs to 14, reset FIFOs
    
  // unmask all com1 uart interrupts
  //_outp( COM1_IER, 0x0f);  //jtm
  _outp( COM1_IER, 0x07);
  
  // clear garbage from the com1 iir
  while((_inp(COM1_IIR) & 0x01) != 1)
    {
    _inp(COM1_RX);
    _inp(COM1_LSR);
    _inp(COM1_MSR);
    }
  
  // enable com1 irq4 interrupts at the pic
  _outp(0x21, _inp(0x21) & 0xef);

  // turn on the com1 mcr gate (out2)
  _outp( COM1_MCR, _inp(COM1_MCR) | 0x08); 
  
  // enable cpu interrupts          
  _enable();
  cout << "Com1 initialized." << endl;
  // done 
  } // end init_com1()
Ejemplo n.º 29
0
void init_com2(void)
  {
  cout << "Begin Com2 initialization.   ";
  // disable cpu interrupts
  _disable();
  
  // set vector for COM2, irq3
  com2_old_vector = _dos_getvect(3+8);
  _dos_setvect(3+8, com2_isr);
     
  // initialize COM2 16550
  _outp( COM2_LCR, (DLAB1 | NO | STOP1 | EIGHT));
  _outp( COM2_DLL, BR_19200);  // for acoustic modem
  //_outp( COM2_DLL, BR_9600);  // for acoustic modem
  //_outp( COM2_DLL, BR_4800);  // for desert star
  //_outp( COM2_DLL, BR_57600);  // for crossbow
  _outp( COM2_DLM, 0);
  _outp( COM2_LCR, (DLAB0 | NO | STOP1 | EIGHT));
//sjc  _outp( COM2_FCR, 0xc1); // enable FIFOs to 14, reset FIFOs
  _outp( COM2_FCR, 0xc7); // enable FIFOs to 14, reset FIFOs
    
  // unmask all com1 uart interrupts
//sjc  _outp( COM2_IER, 0x0f);
  _outp( COM2_IER, 0x07);
  
  // clear garbage from the com1 iir
  while((_inp(COM2_IIR) & 0x01) != 1)
    {
    _inp(COM2_RX);
    _inp(COM2_LSR);
    _inp(COM2_MSR);
    }
  
  // enable com2 irq3 interrupts at the pic
  _outp(0x21, _inp(0x21) & 0xf7);

  // turn on the com2 mcr gate (out2)
  _outp( COM2_MCR, _inp(COM2_MCR) | 0x08); 
  
  // enable cpu interrupts          
  _enable();
  cout << "Com2 initialized." << endl;
  // done 
  } // end init_com2()
Ejemplo n.º 30
0
int timer_init(float ticks_per_sec)
{
    timer.counter_init = (int) (PIT_BASE_FREQUENCY / ticks_per_sec);

    if (timer.counter_init >= PIT_COUNTER_MAX) {
        return error("Requested timer frequency of %.2f Hz too low;"
                     "minimum frequency is 18.2 Hz", ticks_per_sec);
    } else if (timer.counter_init < 1) {
        return error("Requested timer frequency of %.2f Hz too high;"
                     "maximum frequency is 1.193181 MHz", ticks_per_sec);
    }

    timer.ticks_per_sec = PIT_BASE_FREQUENCY / timer.counter_init;
    timer.ticks = 0;
    timer.last_ticks_value = 0;

    if (dpmi_lock_linear_region((uint32_t) &timer, sizeof(timer)) != 0)
        return error("Locking timer data failed");

    if (dpmi_lock_linear_region(
            (uint32_t) timer_handler,
            (char *) timer_handler_end - (char *) timer_handler) != 0) {
        dpmi_unlock_linear_region((uint32_t) &timer, sizeof(timer));
        return error("Locking timer interrupt handler failed");
    }

    timer.default_handler = _dos_getvect(PIT_SYSTEM_INT);

    _disable();

    /* Set channel 0 to rate generator mode, <ticks_per_sec> Hz. */

    outp(PIT_COMMAND, 52);
    outp(PIT_CH0_DATA, timer.counter_init & 0xFF);
    outp(PIT_CH0_DATA, timer.counter_init >> 8);

    _dos_setvect(PIT_SYSTEM_INT, timer_handler);

    _enable();

    timer_initialized = true;
    return 0;
}