⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 miniexec.c

📁 嵌入式操作系统Nucleus Plus中使用的文件系统
💻 C
📖 第 1 页 / 共 2 页
字号:
	    else                     /* D: */
	    {
		*heads     = PCAT_read_cmos(38); /* Heads at loc 38 in cmos */
		*sectors   = PCAT_read_cmos(44); /* SpTRK at loc 44 in cmos */
	    }
	}
	else
	{
	    *heads     = bios_table[type].heads;
	    *sectors   = bios_table[type].sectors;
	}
    }
    return(YES);
}

static BOOL ide_vector_established = NO;

/* NUCLEUS Specific */
#ifdef  PLUS
#define PCAT_Set_Vector  NU_Setup_Vector
void (*old_ide_vector)();
extern VOID ide_init_HISR(VOID);
extern VOID fl_init_HISR(VOID);
#endif  /*  PLUS  */
extern void ide_isr();

VOID mex_establish_ide_vector()                     /*__fn__*/
{
INT             old_level;                  /* previous interrupt level */

/* set up the hardware int 14 interrupt vector (0x76 in the vector table)*/
    /* Lockout interrupts.  */
#ifdef  PLUS
    old_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
#else
    old_level =  IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
#endif  /* PLUS  */
    if (!ide_vector_established)
    {
	ide_vector_established = YES;
#ifdef PLUS
	NU_Register_LISR(0x76, ide_isr, &old_ide_vector);  /* Register Interrupt vector 118 */
	ide_init_HISR();
#else
	enable_irq14();
#endif  /*  PLUS  */
    }
    /* Restore previous interrupt lockout posture.  */
#ifdef PLUS
    NU_Control_Interrupts(old_level);
#else
    IND_Set_Interrupt_Level(old_level);
#endif  /*  PLUS  */
}
#endif

#if (EBS_FLOPPY)

UCOUNT motor_ticks = 0; /* Used by the next two routines */

/* This task needs to be started when the system starts. It will immediatley
   suspend infinately. When the floppy motor is turned on mex_rearm_alarm()
   will wake this task up and instruct it to wait 3 seconds and then turn off
   the floppy motor. If mex_rearm_alarm() is called again before the three 
   seconds are up, the taskp will wake up and wait another three seconds 
   without shutting down the motor. */

extern void fl_motor_off(int);

void floppy_timer_task()
{
#ifdef PLUS
UNSIGNED    current_events;
ULONG       events;
unsigned    sleep_ticks;

    events =(UNSIGNED) ~0;

#else
int sleep_ticks;
unsigned    current_events;
unsigned    int events;
    events =(unsigned) ~0;
#endif


    while(YES)
    {
	if (!motor_ticks)
#ifdef  PLUS
	    sleep_ticks = NU_SUSPEND;
#else
	    sleep_ticks = NU_WAIT_FOREVER;
#endif  /*  PLUS  */
	else
	    sleep_ticks = motor_ticks;

#ifdef  PLUS
	if (NU_Retrieve_Events(&NUFP_RTX_To_PLUS_Events[NUF_FLOPPY_TIMER_EVENT],
				events, NU_OR_CONSUME, &current_events,
				sleep_ticks) == NU_TIMEOUT)
#else
	if (NU_Wait_For_Events(NUF_FLOPPY_TIMER_EVENT, NU_EVENT_OR_CONSUME,
	    events, &current_events, sleep_ticks) == NU_EVENT_TIMEOUT)
#endif  /*  PLUS  */
	{
	    fl_motor_off(0);
	    /* don't shut down the motors again until signaled. */
	    motor_ticks = 0;
	}
    }
}

VOID mex_rearm_alarm(COUNT ticks)                  /* __fn__ */
{
    /* Set the bios motor count to FF. This will get the bios timer function
       out of our way while we manage the motor. */
/*     PCAT_disable_bios_motor(); */
    motor_ticks = ticks;
#ifdef  PLUS
    NU_Set_Events(&NUFP_RTX_To_PLUS_Events[NUF_FLOPPY_TIMER_EVENT],
		    (UNSIGNED) ~0, NU_OR);
#else
    NU_Set_Events(NUF_FLOPPY_TIMER_EVENT, NU_EVENT_OR, (unsigned int) ~0);
#endif  /*  PLUS  */
}


/* AT Floppy disk support code */

#ifndef POLLED

#ifdef  PLUS
#define PCAT_Set_Vector  NU_Setup_Vector
void (*old_floppy_vector)();
extern VOID fl_init_HISR(VOID);
#endif  /*  PLUS  */
extern void fl_isr();

#endif /* NOT POLLED */

static BOOL floppy_vector_established = NO;
VOID mex_establish_floppy_vector()                     /*__fn__*/
{

#ifndef POLLED

INT             old_level;                  /* previous interrupt level */

#ifdef  PLUS
    old_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
#else
    old_level =  IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
#endif  /* PLUS  */

    /* set up the hardware int (0x7E in the vector table)*/
    if (!floppy_vector_established)
    {
	floppy_vector_established = YES;
#ifdef PLUS
	NU_Register_LISR(0x7E, fl_isr, &old_floppy_vector);     /* Register Interrupt vector 38 */
	fl_init_HISR();
#else
	enable_irq6();
#endif
    }
    /* Restore previous interrupt lockout posture.  */
#ifdef  PLUS
    NU_Control_Interrupts(old_level);
#else
    IND_Set_Interrupt_Level(old_level);
#endif  /*  PLUS  */

#endif /* NOT POLLED */

}


/*
* Name:
*    mex_floppy_type()                Return the hardware drive number
*
* Summary:
*    UTINY mex_floppy_type(UCOUNT driveno)
*
* Inputs:
*   None
*
* Returns:
*   DT_NONE No drive
*   DT_360  360 K 5.25" drive
*   DT_12   1.2 M 5.25" drive
*   DT_720  720 K 3.50" drive
*   DT_144  1.44M 3.50" drive
*   DT_288  2.88M 3.50" drive
*
*   Nothing
*
* Description:
*   Returns the drive type at driveno.
*
*
* Porting considerations:
*   On the PC AT the drive types are stored in CMOS RAM. We return these
*   values. On a non AT platforms you need to find an alternate method.
*/

UTINY mex_floppy_type(COUNT driveno)                             /*__fn__*/
{
UTINY utemp;
    /* Read the CMOS */
    utemp = PCAT_read_cmos(0x90);
    if (driveno)
	return((UTINY)(utemp&0x0f));
    else
	return((UTINY) (utemp >> 4));
}

#endif

#ifdef PLUS
/* Restore vectors used by device drivers. */
#if (EBS_IDE || EBS_FLOPPY)
void mex_restore_vectors()
{

#ifndef POLLED

INT             old_level;                  /* previous interrupt level */

    /* set up the hardware int 14 interrupt vector (0x76 in the vector table)*/
    /* Lockout interrupts.  */
#ifdef  PLUS
    old_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
#else
    old_level =  IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
#endif  /* PLUS  */
#if (EBS_IDE)
    if (&old_ide_vector)
	   PCAT_Set_Vector(0x76, &old_ide_vector);
#endif
#if (EBS_FLOPPY)
     if (&old_floppy_vector)
	  PCAT_Set_Vector(0x7E, &old_floppy_vector);
#endif
    /* Restore previous interrupt lockout posture.  */
#ifdef  PLUS
    NU_Control_Interrupts(old_level);
#else
    IND_Set_Interrupt_Level(old_level);
#endif  /*  PLUS  */

#endif /* NOT POLLED */

}
#endif /* (EBS_IDE || EBS_FLOPPY) */
#endif /* ifdef PLUS */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -