This allowed removing the p_flagarlm timer from the kernel's process table.
Furthermore, I merged p_syncalrm and p_signalrm into p_alarm_timer to save
even more space. Note that processes can no longer have both a signal and
synchronous alarm timer outstanding as of now.
* Changes:
* Nov 18, 2004 moved AT disk driver to user-space (Jorrit N. Herder)
* Aug 20, 2004 watchdogs replaced by sync alarms (Jorrit N. Herder)
- * May 02, 2004 sys_flagalrm() replaces micro_elapsed() (Jorrit N. Herder)
* Mar 23, 2000 added ATAPI CDROM support (Michael Temari)
* May 14, 2000 d-d/i rewrite (Kees J. Bot)
* Apr 13, 1992 device dependent/independent split (Kees J. Bot)
* ticks. Disabling the alarm is not needed, because a static flag is used
* and a leftover timeout cannot do any harm.
*/
- static int timeout_flag; /* must be static, not cancelled */
+ clock_t t0, t1;
int s;
- timeout_flag = 0;
- sys_flagalrm(TIMEOUT_TICKS, &timeout_flag);
+ getuptime(&t0);
do {
if ((s=sys_inb(w_wn->base + REG_STATUS, &w_status)) != OK)
server_panic(w_name(),"Couldn't read register",s);
if ((w_status & mask) == value) {
return 1;
}
- } while (! timeout_flag);
+ } while ((s=getuptime(&t1)) == OK && (t1-t0) < TIMEOUT_TICKS );
+ if (OK != s) printf("AT_WINI: warning, get_uptime failed: %d\n",s);
+
w_need_reset(); /* controller gone deaf */
return(0);
}
* Changes:
* Dec 01, 2004 floppy driver moved to user-space (Jorrit N. Herder)
* Sep 15, 2004 sync alarms/ local timer management (Jorrit N. Herder)
- * May 02, 2004 sys_flagalrm() replaces micro_elapsed() (Jorrit N. Herder)
* Aug 12, 2003 null seek no interrupt fix (Mike Haertel)
* May 14, 2000 d-d/i rewrite (Kees J. Bot)
* Apr 04, 1992 device dependent/independent split (Kees J. Bot)
f_set_timer(&f_tmr_timeout, f_dp->start, f_timeout);
f_busy = BSY_IO;
do {
- receive(HARDWARE, &mess);
+ receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
} else {
f_set_timer(&f_tmr_timeout, HZ/30, f_timeout);
f_busy = BSY_IO;
do {
- /* printf("Wait for message from HARDWARE 0\n"); */
- receive(HARDWARE, &mess);
- /* printf("Floppy: got message, type %d (HARD_INT %d)\n",
- mess.m_type, (mess.m_type == HARD_INT)); */
+ receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
} else {
*/
int s, result_nr, status;
- static int timeout; /* must be static if not cancelled */
+ clock_t t0,t1;
/* Extract bytes from FDC until it says it has no more. The loop is
* really an outer loop on result_nr and an inner loop on status.
* A timeout flag alarm is set.
*/
result_nr = 0;
- timeout = 0;
- sys_flagalrm(TIMEOUT_TICKS, &timeout);
+ getuptime(&t0);
do {
/* Reading one byte is almost a mirror of fdc_out() - the DIRECTION
* bit must be set instead of clear, but the CTL_BUSY bit destroys
if ((s=sys_irqenable(&irq_hook_id)) != OK)
server_panic("FLOPPY", "Couldn't enable IRQs", s);
- /* Disabling the alarm is not needed, because a static flag
- * is used and a leftover timeout cannot do any harm. It is
- * done for correctness. This can safely be removed, though.
- */
- sys_flagalrm(0, &timeout); /* for correctness */
return(OK); /* only good exit */
}
- } while (! timeout);
+ } while ( (s=getuptime(&t1))==OK && (t1-t0) < TIMEOUT_TICKS );
+ if (OK!=s) printf("FLOPPY: warning, getuptime failed: %d\n", s);
need_reset = TRUE; /* controller chip must be reset */
if ((s=sys_irqenable(&irq_hook_id)) != OK)
* can only write to it when it is listening, and it decides when to listen.
* If the controller refuses to listen, the FDC chip is given a hard reset.
*/
-
- static int timeout; /* must be static if not cancelled */
+ clock_t t0, t1;
int s, status;
if (need_reset) return; /* if controller is not listening, return */
- /* It may take several tries to get the FDC to accept a command.
- * A timeout flag alarm is set.
- */
- timeout = 0;
- sys_flagalrm(TIMEOUT_TICKS, &timeout);
+ /* It may take several tries to get the FDC to accept a command. */
+ getuptime(&t0);
do {
- if (timeout) { /* controller is not listening */
+ if ( (s=getuptime(&t1))==OK && (t1-t0) > TIMEOUT_TICKS ) {
+ if (OK!=s) printf("FLOPPY: warning, getuptime failed: %d\n", s);
need_reset = TRUE; /* hit it over the head */
return;
}
}
while ((status & (MASTER | DIRECTION)) != (MASTER | 0));
- /* Disabling the alarm is not needed, because a static flag is used and a
- * leftover timeout cannot do any harm. It is done for correctness. This
- * can safely be removed, though.
- */
- sys_flagalrm(0, &timeout); /* for correctness */
if ((s=sys_outb(FDC_DATA, val)) != OK)
server_panic("FLOPPY","Sys_outb in fdc_out() failed", s);
}
* SYN_ALARM message on a timeout.
*/
do {
- receive(HARDWARE, &mess);
+ receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
} else { /* expect HARD_INT */
* occurs, report an error.
*/
do {
- /* printf("Wait for message from HARDWARE 2\n"); */
- receive(HARDWARE, &mess);
- /* printf("Floppy: got message, type %d (HARD_INT %d) ",
- mess.m_type, (mess.m_type == HARD_INT)); */
+ receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
} else {
{
static char eakey[]= FXP_ENVVAR "#_EA";
static char eafmt[]= "x:x:x:x:x:x";
- static int timeout_flag; /* must be static */
-
+ clock_t t0,t1;
int i, r;
port_t port;
u32_t bus_addr;
fxp_cu_ptr_cmd(fp, SC_CU_START, bus_addr, TRUE /* check idle */);
- timeout_flag= 0;
- sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
+ getuptime(&t0);
do {
/* Wait for CU command to complete */
if (ias.ias_status & CBL_F_C)
break;
- } while (!timeout_flag);
+ } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if (!(ias.ias_status & CBL_F_C))
panic("fxp_confaddr: CU command failed to complete", NO_NUM);
static void fxp_do_conf(fp)
fxp_t *fp;
{
- static int timeout_flag; /* must be static */
-
int r;
u32_t bus_addr;
struct cbl_conf cc;
+ clock_t t0,t1;
/* Configure device */
cc.cc_status= 0;
fxp_cu_ptr_cmd(fp, SC_CU_START, bus_addr, TRUE /* check idle */);
- timeout_flag= 0;
- sys_flagalrm(MICROS_TO_TICKS(100000), &timeout_flag);
+ getuptime(&t0);
do {
/* Wait for CU command to complete */
if (cc.cc_status & CBL_F_C)
break;
- } while (!timeout_flag);
+ } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(100000));
if (!(cc.cc_status & CBL_F_C))
panic("fxp_do_conf: CU command failed to complete", NO_NUM);
phys_bytes bus_addr;
int check_idle;
{
- static int timeout_flag; /* must be static */
-
+ clock_t t0,t1;
port_t port;
u8_t scb_cmd;
/* What is a reasonable time-out? There is nothing in the
* documentation. 1 ms should be enough.
*/
- timeout_flag= 0;
- sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
+ getuptime(&t0);
do {
/* Wait for CU command to be accepted */
scb_cmd= fxp_inb(port, SCB_CMD);
if ((scb_cmd & SC_CUC_MASK) == SC_CU_NOP)
break;
- } while (!timeout_flag);
+ } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if ((scb_cmd & SC_CUC_MASK) != SC_CU_NOP)
panic("fxp_cu_ptr_cmd: CU does not accept command", NO_NUM);
phys_bytes bus_addr;
int check_idle;
{
- static int timeout_flag; /* must be static */
-
+ clock_t t0,t1;
port_t port;
u8_t scb_cmd;
fxp_outl(port, SCB_POINTER, bus_addr);
fxp_outb(port, SCB_CMD, cmd);
- timeout_flag= 0;
- sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
+ getuptime(&t0);
do {
/* Wait for RU command to be accepted */
scb_cmd= fxp_inb(port, SCB_CMD);
if ((scb_cmd & SC_RUC_MASK) == SC_RU_NOP)
break;
- } while (!timeout_flag);
+ } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if ((scb_cmd & SC_RUC_MASK) != SC_RU_NOP)
panic("fxp_ru_ptr_cmd: RU does not accept command", NO_NUM);
static void fxp_getstat(mp)
message *mp;
{
- static int timeout_flag; /* Must be static */
-
+ clock_t t0,t1;
int dl_port;
port_t port;
fxp_t *fp;
*/
fxp_cu_ptr_cmd(fp, SC_CU_DUMP_SC, 0, FALSE /* do not check idle */);
- timeout_flag= 0;
- sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
+ getuptime(&t0);
do {
/* Wait for CU command to complete */
if (*p != 0)
break;
- } while (!timeout_flag);
+ } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if (*p == 0)
panic("fxp_getstat: CU command failed to complete", NO_NUM);
fxp_t *fp;
int reg;
{
- static int timeout_flag; /* must be static */
-
+ clock_t t0,t1;
port_t port;
u32_t v;
fxp_outl(port, CSR_MDI_CTL, CM_READ | (1 << CM_PHYADDR_SHIFT) |
(reg << CM_REG_SHIFT));
- timeout_flag= 0;
- sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
+ getuptime(&t0);
do {
v= fxp_inl(port, CSR_MDI_CTL);
if (v & CM_READY)
break;
- } while (!timeout_flag);
+ } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if (!(v & CM_READY))
panic("mii_read: MDI not ready after command", NO_NUM);
u32_t t;
phys_bytes bus_buf;
int i;
- static int timeout; /* must be static if not cancelled */
+ clock_t t0,t1;
port= rep->re_base_port;
#if 0
/* Reset the PHY */
rl_outb(port, RL_BMCR, MII_CTRL_RST);
- timeout=0;
- sys_flagalrm(HZ, &timeout);
+ getuptime(&t0);
do {
if (!(rl_inb(port, RL_BMCR) & MII_CTRL_RST))
break;
- } while (! timeout);
- sys_flagalrm(0, &timeout); /* for correctness */
+ } while (getuptime(&t1)==OK && (t1-t0) < HZ);
if (rl_inb(port, RL_BMCR) & MII_CTRL_RST)
server_panic("rtl8139","reset PHY failed to complete", NO_NUM);
#endif
/* Reset the device */
rl_outb(port, RL_CR, RL_CR_RST);
- timeout=0;
- sys_flagalrm(HZ, &timeout);
+ getuptime(&t0);
do {
if (!(rl_inb(port, RL_CR) & RL_CR_RST))
break;
- } while (! timeout);
- sys_flagalrm(0, &timeout); /* for correctness */
+ } while (getuptime(&t1)==OK && (t1-t0) < HZ);
if (rl_inb(port, RL_CR) & RL_CR_RST)
server_panic("rtl8139","reset failed to complete", NO_NUM);
port_t port;
u8_t cr;
int i;
- static int timeout; /* must be static if not cancelled */
+ clock_t t0,t1;
rep->re_clear_rx= FALSE;
port= rep->re_base_port;
cr= rl_inb(port, RL_CR);
cr &= ~RL_CR_RE;
rl_outb(port, RL_CR, cr);
- timeout=0;
- sys_flagalrm(HZ, &timeout);
+ getuptime(&t0);
do {
if (!(rl_inb(port, RL_CR) & RL_CR_RE))
break;
- } while (! timeout);
- sys_flagalrm(0, &timeout); /* for correctness */
+ } while (getuptime(&t1)==OK && (t1-t0) < HZ);
if (rl_inb(port, RL_CR) & RL_CR_RE)
server_panic("rtl8139","cannot disable receiver", NO_NUM);
#if 0
u8_t cr;
#endif
- static int timeout; /* must be static if not cancelled */
-
+ clock_t t0,t1;
int_event_check = FALSE; /* disable check by default */
RAND_UPDATE
cr= rl_inb(port, RL_CR);
cr &= ~RL_CR_TE;
rl_outb(port, RL_CR, cr);
- timeout=0;
- sys_flagalrm(HZ, &timeout);
+ getuptime(&t0);
do {
if (!(rl_inb(port, RL_CR) & RL_CR_TE))
break;
- } while (! timeout);
- sys_flagalrm(0, &timeout); /* for correctness */
+ } while (getuptime(&t1)==OK && (t1-t0) < HZ);
if (rl_inb(port, RL_CR) & RL_CR_TE)
{
server_panic("rtl8139","cannot disable transmitter",
u16_t w;
{
int b, i, cmd;
- static int timeout; /* must be static if not cancelled */
+ clock_t t0, t1;
outb_reg3(dep, 1, 0x80 | 0x8); /* Set CS */
outb_reg3(dep, 1, 0x80); /* Drop CS */
/* micro_delay(1); */ /* Is this required? */
outb_reg3(dep, 1, 0x80 | 0x8); /* Set CS */
- timeout = 0;
- sys_flagalrm(1, &timeout);
+ getuptime(&t0);
do {
if (inb_reg3(dep, 1) & 1)
break;
- } while (! timeout);
- sys_flagalrm(0, &timeout); /* for correctness */
+ } while (getuptime(&t1) == OK && (t1 == t0));
if (!(inb_reg3(dep, 1) & 1))
server_panic("set_ee_word","device remains busy", NO_NUM);
}
#include <minix/com.h>
#include "tty.h"
+#include "../../kernel/const.h"
+#include "../../kernel/type.h"
+
/* Definitions used by the console driver. */
#define MONO_BASE 0xB0000L /* base of mono video memory */
#define COLOR_BASE 0xB8000L /* base of color video memory */
#define NR_BUF_HASH 512 /* size of buf hash table; MUST BE POWER OF 2*/
#endif
-/* Defines for kernel configuration. */
+/* Defines for driver and kernel configuration. */
#define AUTO_BIOS 0 /* xt_wini.c - use Western's autoconfig BIOS */
#define LINEWRAP 1 /* console.c - wrap lines at column 80 */
#define ALLOW_GAP_MESSAGES 1 /* proc.c - allow messages in the gap between
* the end of bss and lowest stack address */
-#define KMESS_BUF_SIZE 512 /* size in bytes for kernel messages */
/* Number of controller tasks (/dev/cN device classes). */
#define NR_CTRLRS 2
int vdu_vga;
};
-/* The kernel outputs messages in a local buffer, which can be requested and
- * printed by the TTY driver. The buffer structure is defined here.
- */
-struct kmessages {
- int km_next; /* next index to write */
- int km_size; /* current size in buffer */
- char km_buf[KMESS_BUF_SIZE]; /* buffer for messages */
-};
-
-
#endif /* _TYPE_H */
_PROTOTYPE(void server_report, (char *who, char *mess, int num) );
_PROTOTYPE(void server_panic, (char *who, char *mess, int num) );
-#define get_own_proc_nr(where) get_proc_nr((where), NULL)
_PROTOTYPE(int get_proc_nr, (int *proc_nr, char *proc_name) );
+_PROTOTYPE(int getuptime, (clock_t *ticks));
_PROTOTYPE(int tick_delay, (clock_t ticks));
#endif /* _EXTRALIB_H */
#include <ibm/ports.h> /* port addresses and magic numbers */
#include <ibm/bios.h> /* BIOS addresses, sizes and magic numbers */
-#if (CHIP == INTEL)
-
/* To translate an address in kernel space to a physical address. This is
* the same as umap_local(proc_ptr, D, vir, sizeof(*vir)), but less costly.
*/
/* How long should the process names be in the kernel? */
#define P_NAME_LEN 8
+/* How many bytes should the circular buffer for kernel diagnostics. */
+#define KMESS_BUF_SIZE 256
+
/* How many bytes for (port,value)-pairs vector to copy in. */
#define VDEVIO_BUF_SIZE 128
#define SET_BIT(map,bit) ( MAP_CHUNK(map,bit) |= (1 << CHUNK_OFFSET(bit) )
#define UNSET_BIT(map,bit) ( MAP_CHUNK(map,bit) &= ~(1 << CHUNK_OFFSET(bit) )
+
+#if (CHIP == INTEL)
+
/* Program stack words and masks. */
#define INIT_PSW 0x0200 /* initial psw */
#define INIT_TASK_PSW 0x1200 /* initial psw for tasks (with IOPL 1) */
*/
#define NR_MEMS 8 /* number of chunks of memory */
-
#endif /* (CHIP == INTEL) */
#if (CHIP == M68000)
clock_t p_user_time; /* user time in ticks */
clock_t p_sys_time; /* sys time in ticks */
- timer_t p_signalrm; /* signal alarm timer */
- timer_t p_flagalrm; /* flag alarm timer */
- timer_t p_syncalrm; /* synchronous alarm timer */
-
struct proc *p_nextready; /* pointer to next ready process */
struct notification *p_ntf_q; /* queue of pending notifications */
struct proc *p_caller_q; /* head of list of procs wishing to send */
struct proc *p_q_link; /* link to next proc wishing to send */
- message *p_messbuf; /* pointer to message buffer */
+ message *p_messbuf; /* pointer to passed message buffer */
proc_nr_t p_getfrom; /* from whom does process want to receive? */
proc_nr_t p_sendto; /* to whom does process want to send? */
- sigset_t p_pending; /* bit map for pending signals */
+ timer_t p_alarm_timer; /* timer shared by different alarm types */
+ sigset_t p_pending; /* bit map for pending kernel signals */
unsigned p_pendcount; /* count of pending and unfinished signals */
char p_name[P_NAME_LEN]; /* name of the process, including \0 */
/* Initialize all alarm timers for all processes. */
for (rp=BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++) {
- tmr_inittimer(&(rp->p_signalrm));
- tmr_inittimer(&(rp->p_syncalrm));
- tmr_inittimer(&(rp->p_flagalrm));
+ tmr_inittimer(&(rp->p_alarm_timer));
}
/* Initialize the call vector to a safe default handler. Some system calls
map(SYS_TIMES, do_times); /* get uptime and process times */
map(SYS_SIGNALRM, do_signalrm); /* causes an alarm signal */
map(SYS_SYNCALRM, do_syncalrm); /* send a notification message */
- map(SYS_FLAGALRM, do_flagalrm); /* set a timeout flag to 1 */
/* Device I/O. */
map(SYS_IRQCTL, do_irqctl); /* interrupt control operations */
rc = proc_addr(proc_nr);
/* Turn off any alarm timers at the clock. */
- reset_timer(&rc->p_signalrm);
- reset_timer(&rc->p_flagalrm);
- reset_timer(&rc->p_syncalrm);
+ reset_timer(&rc->p_alarm_timer);
/* Make sure the exiting process is no longer scheduled. */
if (rc->p_flags == 0) lock_unready(rc);
/* The system call implemented in this file:
- * m_type: SYS_SIGNALRM, SYS_SYNCALRM, SYS_FLAGALRM
+ * m_type: SYS_SIGNALRM, SYS_SYNCALRM
*
* The parameters for this system call are:
* m2_i1: ALRM_PROC_NR (set alarm for this process)
* m2_l1: ALRM_EXP_TIME (alarm's expiration time)
* m2_i2: ALRM_ABS_TIME (expiration time is absolute?)
* m2_l1: ALRM_SEC_LEFT (return seconds left of previous)
- * m2_p1: ALRM_FLAG_PTR (virtual addr of alarm flag)
*
* Changes:
- * Aug 25, 2004 fully rewritten to unite all alarms (Jorrit N. Herder)
- * May 02, 2004 added new timeout flag alarm (Jorrit N. Herder)
+ * Aug 25, 2004 fully rewritten to clean up code (Jorrit N. Herder)
*/
FORWARD _PROTOTYPE( void cause_syncalrm, (timer_t *tp) );
-FORWARD _PROTOTYPE( void cause_flagalrm, (timer_t *tp) );
FORWARD _PROTOTYPE( void cause_signalrm, (timer_t *tp) );
/*===========================================================================*
message *m_ptr; /* pointer to request message */
{
/* A process requests an alarm, or wants to cancel its alarm. This function
- * is shared used for all of SYS_SIGNALRM, SYS_SYNCALRM, and SYS_FLAGALRM.
+ * is shared used for both the SYS_SIGNALRM and SYS_SYNCALRM.
*/
int proc_nr; /* which process wants the alarm */
long exp_time; /* expiration time for this alarm */
use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */
/* Get the timer structure and set the parameters for this alarm. */
+ tp = &(proc_addr(proc_nr)->p_alarm_timer);
+ tmr_arg(tp)->ta_int = proc_nr;
switch (m_ptr->m_type) {
- case SYS_SYNCALRM: /* notify with SYN_ALARM message */
- tp = &(proc_addr(proc_nr)->p_syncalrm);
- tmr_arg(tp)->ta_int = proc_nr;
- tp->tmr_func = cause_syncalrm;
- break;
- case SYS_SIGNALRM: /* send process a SIGALRM signal */
- tp = &(proc_addr(proc_nr)->p_signalrm);
- tmr_arg(tp)->ta_int = proc_nr;
- tp->tmr_func = cause_signalrm;
- break;
- case SYS_FLAGALRM: /* set caller's timeout flag to 1 */
- tp = &(proc_addr(proc_nr)->p_flagalrm);
- tmr_arg(tp)->ta_long =
- numap_local(proc_nr,(vir_bytes) m_ptr->ALRM_FLAG_PTR,sizeof(int));
- if (! tmr_arg(tp)->ta_long) return(EFAULT);
- tp->tmr_func = cause_flagalrm;
- break;
- default: /* invalid alarm type */
- return(EINVAL);
+ case SYS_SYNCALRM: tp->tmr_func = cause_syncalrm; break;
+ case SYS_SIGNALRM: tp->tmr_func = cause_signalrm; break;
+ default: return(EINVAL); /* invalid alarm type */
}
/* Return the ticks left on the previous alarm. */
cause_sig(tmr_arg(tp)->ta_int, SIGALRM);
}
-/*===========================================================================*
- * cause_flagalrm *
- *===========================================================================*/
-PRIVATE void cause_flagalrm(tp)
-timer_t *tp;
-{
-/* Routine called if a timer goes off for a process that requested a timeout
- * flag to be set when the alarm expires. The timer argument 'ta_long' gives
- * the physical address of the timeout flag. No validity check was done when
- * setting the alarm, so check for 0 here.
- */
- int timeout = 1;
- phys_bytes timeout_flag = (phys_bytes) tmr_arg(tp)->ta_long;
- phys_copy(vir2phys(&timeout), tmr_arg(tp)->ta_long, sizeof(int));
-}
/*===========================================================================*
* cause_syncalrm *
struct notification* n_next; /* pointer to next notification */
};
+/* The kernel outputs diagnostic messages in a circular buffer. */
+struct kmessages {
+ int km_next; /* next index to write */
+ int km_size; /* current size in buffer */
+ char km_buf[KMESS_BUF_SIZE]; /* buffer for messages */
+};
+
+
#if (CHIP == INTEL)
typedef unsigned reg_t; /* machine register */
OBJECTS = \
$(LIBUTILS)(tick_delay.o) \
+ $(LIBUTILS)(get_upt.o) \
$(LIBUTILS)(get_mon_prm.o) \
$(LIBUTILS)(env_parse.o) \
$(LIBUTILS)(env_panic.o) \
aal cr $@ *.o
rm *.o
+$(LIBUTILS)(get_upt.o): get_upt.c
+ $(CC1) get_upt.c
+
$(LIBUTILS)(tick_delay.o): tick_delay.c
$(CC1) tick_delay.c
#include "fs.h"
#include <minix/com.h>
#include <minix/callnr.h>
+#include <minix/utils.h>
#include <time.h>
#include <ibm/cmos.h>
#include <ibm/bios.h>
*/
int osec, n;
unsigned long i;
- static int timeout_flag;
+ clock_t t0,t1;
/* Start a timer to keep us from getting stuck on a dead clock. */
- timeout_flag = 0;
- sys_flagalrm(5*HZ, &timeout_flag);
+ getuptime(&t0);
do {
osec = -1;
n = 0;
do {
- if (timeout_flag) {
+ getuptime(&t1);
+ if (t1-t0 > 5*HZ) {
printf("readclock: CMOS clock appears dead\n");
return(1);
}
|| read_register(RTC_MDAY) != t->tm_mday
|| read_register(RTC_MONTH) != t->tm_mon
|| read_register(RTC_YEAR) != t->tm_year);
- sys_flagalrm(0, &timeout_flag); /* not strictly necessarily; flag is static */
if ((read_register(RTC_REG_B) & RTC_B_DM_BCD) == 0) {
/* Convert BCD to binary (default RTC mode). */