Replaced flagalrm() timers with another technique to check for timeouts.

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.
This commit is contained in:
Jorrit Herder 2005-05-31 14:43:04 +00:00
parent e673eeee20
commit 0165662cd9
15 changed files with 91 additions and 167 deletions

View File

@ -8,7 +8,6 @@
* Changes: * Changes:
* Nov 18, 2004 moved AT disk driver to user-space (Jorrit N. Herder) * Nov 18, 2004 moved AT disk driver to user-space (Jorrit N. Herder)
* Aug 20, 2004 watchdogs replaced by sync alarms (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) * Mar 23, 2000 added ATAPI CDROM support (Michael Temari)
* May 14, 2000 d-d/i rewrite (Kees J. Bot) * May 14, 2000 d-d/i rewrite (Kees J. Bot)
* Apr 13, 1992 device dependent/independent split (Kees J. Bot) * Apr 13, 1992 device dependent/independent split (Kees J. Bot)
@ -883,17 +882,18 @@ int value; /* required status */
* ticks. Disabling the alarm is not needed, because a static flag is used * ticks. Disabling the alarm is not needed, because a static flag is used
* and a leftover timeout cannot do any harm. * and a leftover timeout cannot do any harm.
*/ */
static int timeout_flag; /* must be static, not cancelled */ clock_t t0, t1;
int s; int s;
timeout_flag = 0; getuptime(&t0);
sys_flagalrm(TIMEOUT_TICKS, &timeout_flag);
do { do {
if ((s=sys_inb(w_wn->base + REG_STATUS, &w_status)) != OK) if ((s=sys_inb(w_wn->base + REG_STATUS, &w_status)) != OK)
server_panic(w_name(),"Couldn't read register",s); server_panic(w_name(),"Couldn't read register",s);
if ((w_status & mask) == value) { if ((w_status & mask) == value) {
return 1; 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 */ w_need_reset(); /* controller gone deaf */
return(0); return(0);
} }

View File

@ -8,7 +8,6 @@
* Changes: * Changes:
* Dec 01, 2004 floppy driver moved to user-space (Jorrit N. Herder) * Dec 01, 2004 floppy driver moved to user-space (Jorrit N. Herder)
* Sep 15, 2004 sync alarms/ local timer management (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) * Aug 12, 2003 null seek no interrupt fix (Mike Haertel)
* May 14, 2000 d-d/i rewrite (Kees J. Bot) * May 14, 2000 d-d/i rewrite (Kees J. Bot)
* Apr 04, 1992 device dependent/independent split (Kees J. Bot) * Apr 04, 1992 device dependent/independent split (Kees J. Bot)
@ -689,7 +688,7 @@ PRIVATE void start_motor()
f_set_timer(&f_tmr_timeout, f_dp->start, f_timeout); f_set_timer(&f_tmr_timeout, f_dp->start, f_timeout);
f_busy = BSY_IO; f_busy = BSY_IO;
do { do {
receive(HARDWARE, &mess); receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) { if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL); f_expire_tmrs(NULL);
} else { } else {
@ -771,10 +770,7 @@ PRIVATE int seek()
f_set_timer(&f_tmr_timeout, HZ/30, f_timeout); f_set_timer(&f_tmr_timeout, HZ/30, f_timeout);
f_busy = BSY_IO; f_busy = BSY_IO;
do { do {
/* printf("Wait for message from HARDWARE 0\n"); */ receive(ANY, &mess);
receive(HARDWARE, &mess);
/* printf("Floppy: got message, type %d (HARD_INT %d)\n",
mess.m_type, (mess.m_type == HARD_INT)); */
if (mess.m_type == SYN_ALARM) { if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL); f_expire_tmrs(NULL);
} else { } else {
@ -872,15 +868,14 @@ PRIVATE int fdc_results()
*/ */
int s, result_nr, status; 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 /* 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. * really an outer loop on result_nr and an inner loop on status.
* A timeout flag alarm is set. * A timeout flag alarm is set.
*/ */
result_nr = 0; result_nr = 0;
timeout = 0; getuptime(&t0);
sys_flagalrm(TIMEOUT_TICKS, &timeout);
do { do {
/* Reading one byte is almost a mirror of fdc_out() - the DIRECTION /* 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 * bit must be set instead of clear, but the CTL_BUSY bit destroys
@ -900,14 +895,10 @@ PRIVATE int fdc_results()
if ((s=sys_irqenable(&irq_hook_id)) != OK) if ((s=sys_irqenable(&irq_hook_id)) != OK)
server_panic("FLOPPY", "Couldn't enable IRQs", s); 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 */ 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 */ need_reset = TRUE; /* controller chip must be reset */
if ((s=sys_irqenable(&irq_hook_id)) != OK) if ((s=sys_irqenable(&irq_hook_id)) != OK)
@ -952,19 +943,16 @@ int val; /* write this byte to floppy disk controller */
* can only write to it when it is listening, and it decides when to listen. * 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. * If the controller refuses to listen, the FDC chip is given a hard reset.
*/ */
clock_t t0, t1;
static int timeout; /* must be static if not cancelled */
int s, status; int s, status;
if (need_reset) return; /* if controller is not listening, return */ if (need_reset) return; /* if controller is not listening, return */
/* It may take several tries to get the FDC to accept a command. /* It may take several tries to get the FDC to accept a command. */
* A timeout flag alarm is set. getuptime(&t0);
*/
timeout = 0;
sys_flagalrm(TIMEOUT_TICKS, &timeout);
do { 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 */ need_reset = TRUE; /* hit it over the head */
return; return;
} }
@ -973,11 +961,6 @@ int val; /* write this byte to floppy disk controller */
} }
while ((status & (MASTER | DIRECTION)) != (MASTER | 0)); 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) if ((s=sys_outb(FDC_DATA, val)) != OK)
server_panic("FLOPPY","Sys_outb in fdc_out() failed", s); server_panic("FLOPPY","Sys_outb in fdc_out() failed", s);
} }
@ -1062,7 +1045,7 @@ PRIVATE void f_reset()
* SYN_ALARM message on a timeout. * SYN_ALARM message on a timeout.
*/ */
do { do {
receive(HARDWARE, &mess); receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) { if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL); f_expire_tmrs(NULL);
} else { /* expect HARD_INT */ } else { /* expect HARD_INT */
@ -1108,10 +1091,7 @@ PRIVATE int f_intr_wait()
* occurs, report an error. * occurs, report an error.
*/ */
do { do {
/* printf("Wait for message from HARDWARE 2\n"); */ receive(ANY, &mess);
receive(HARDWARE, &mess);
/* printf("Floppy: got message, type %d (HARD_INT %d) ",
mess.m_type, (mess.m_type == HARD_INT)); */
if (mess.m_type == SYN_ALARM) { if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL); f_expire_tmrs(NULL);
} else { } else {

View File

@ -904,8 +904,7 @@ fxp_t *fp;
{ {
static char eakey[]= FXP_ENVVAR "#_EA"; static char eakey[]= FXP_ENVVAR "#_EA";
static char eafmt[]= "x:x:x:x:x:x"; static char eafmt[]= "x:x:x:x:x:x";
static int timeout_flag; /* must be static */ clock_t t0,t1;
int i, r; int i, r;
port_t port; port_t port;
u32_t bus_addr; u32_t bus_addr;
@ -959,13 +958,12 @@ fxp_t *fp;
fxp_cu_ptr_cmd(fp, SC_CU_START, bus_addr, TRUE /* check idle */); fxp_cu_ptr_cmd(fp, SC_CU_START, bus_addr, TRUE /* check idle */);
timeout_flag= 0; getuptime(&t0);
sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
do { do {
/* Wait for CU command to complete */ /* Wait for CU command to complete */
if (ias.ias_status & CBL_F_C) if (ias.ias_status & CBL_F_C)
break; break;
} while (!timeout_flag); } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if (!(ias.ias_status & CBL_F_C)) if (!(ias.ias_status & CBL_F_C))
panic("fxp_confaddr: CU command failed to complete", NO_NUM); panic("fxp_confaddr: CU command failed to complete", NO_NUM);
@ -1361,11 +1359,10 @@ suspend:
static void fxp_do_conf(fp) static void fxp_do_conf(fp)
fxp_t *fp; fxp_t *fp;
{ {
static int timeout_flag; /* must be static */
int r; int r;
u32_t bus_addr; u32_t bus_addr;
struct cbl_conf cc; struct cbl_conf cc;
clock_t t0,t1;
/* Configure device */ /* Configure device */
cc.cc_status= 0; cc.cc_status= 0;
@ -1380,13 +1377,12 @@ fxp_t *fp;
fxp_cu_ptr_cmd(fp, SC_CU_START, bus_addr, TRUE /* check idle */); fxp_cu_ptr_cmd(fp, SC_CU_START, bus_addr, TRUE /* check idle */);
timeout_flag= 0; getuptime(&t0);
sys_flagalrm(MICROS_TO_TICKS(100000), &timeout_flag);
do { do {
/* Wait for CU command to complete */ /* Wait for CU command to complete */
if (cc.cc_status & CBL_F_C) if (cc.cc_status & CBL_F_C)
break; break;
} while (!timeout_flag); } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(100000));
if (!(cc.cc_status & CBL_F_C)) if (!(cc.cc_status & CBL_F_C))
panic("fxp_do_conf: CU command failed to complete", NO_NUM); panic("fxp_do_conf: CU command failed to complete", NO_NUM);
@ -1405,8 +1401,7 @@ int cmd;
phys_bytes bus_addr; phys_bytes bus_addr;
int check_idle; int check_idle;
{ {
static int timeout_flag; /* must be static */ clock_t t0,t1;
port_t port; port_t port;
u8_t scb_cmd; u8_t scb_cmd;
@ -1425,14 +1420,13 @@ int check_idle;
/* What is a reasonable time-out? There is nothing in the /* What is a reasonable time-out? There is nothing in the
* documentation. 1 ms should be enough. * documentation. 1 ms should be enough.
*/ */
timeout_flag= 0; getuptime(&t0);
sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
do { do {
/* Wait for CU command to be accepted */ /* Wait for CU command to be accepted */
scb_cmd= fxp_inb(port, SCB_CMD); scb_cmd= fxp_inb(port, SCB_CMD);
if ((scb_cmd & SC_CUC_MASK) == SC_CU_NOP) if ((scb_cmd & SC_CUC_MASK) == SC_CU_NOP)
break; break;
} while (!timeout_flag); } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if ((scb_cmd & SC_CUC_MASK) != SC_CU_NOP) if ((scb_cmd & SC_CUC_MASK) != SC_CU_NOP)
panic("fxp_cu_ptr_cmd: CU does not accept command", NO_NUM); panic("fxp_cu_ptr_cmd: CU does not accept command", NO_NUM);
@ -1448,8 +1442,7 @@ int cmd;
phys_bytes bus_addr; phys_bytes bus_addr;
int check_idle; int check_idle;
{ {
static int timeout_flag; /* must be static */ clock_t t0,t1;
port_t port; port_t port;
u8_t scb_cmd; u8_t scb_cmd;
@ -1465,14 +1458,13 @@ int check_idle;
fxp_outl(port, SCB_POINTER, bus_addr); fxp_outl(port, SCB_POINTER, bus_addr);
fxp_outb(port, SCB_CMD, cmd); fxp_outb(port, SCB_CMD, cmd);
timeout_flag= 0; getuptime(&t0);
sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
do { do {
/* Wait for RU command to be accepted */ /* Wait for RU command to be accepted */
scb_cmd= fxp_inb(port, SCB_CMD); scb_cmd= fxp_inb(port, SCB_CMD);
if ((scb_cmd & SC_RUC_MASK) == SC_RU_NOP) if ((scb_cmd & SC_RUC_MASK) == SC_RU_NOP)
break; break;
} while (!timeout_flag); } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if ((scb_cmd & SC_RUC_MASK) != SC_RU_NOP) if ((scb_cmd & SC_RUC_MASK) != SC_RU_NOP)
panic("fxp_ru_ptr_cmd: RU does not accept command", NO_NUM); panic("fxp_ru_ptr_cmd: RU does not accept command", NO_NUM);
@ -1519,8 +1511,7 @@ fxp_t *fp;
static void fxp_getstat(mp) static void fxp_getstat(mp)
message *mp; message *mp;
{ {
static int timeout_flag; /* Must be static */ clock_t t0,t1;
int dl_port; int dl_port;
port_t port; port_t port;
fxp_t *fp; fxp_t *fp;
@ -1546,13 +1537,12 @@ message *mp;
*/ */
fxp_cu_ptr_cmd(fp, SC_CU_DUMP_SC, 0, FALSE /* do not check idle */); fxp_cu_ptr_cmd(fp, SC_CU_DUMP_SC, 0, FALSE /* do not check idle */);
timeout_flag= 0; getuptime(&t0);
sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
do { do {
/* Wait for CU command to complete */ /* Wait for CU command to complete */
if (*p != 0) if (*p != 0)
break; break;
} while (!timeout_flag); } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if (*p == 0) if (*p == 0)
panic("fxp_getstat: CU command failed to complete", NO_NUM); panic("fxp_getstat: CU command failed to complete", NO_NUM);
@ -2331,8 +2321,7 @@ PRIVATE u16_t mii_read(fp, reg)
fxp_t *fp; fxp_t *fp;
int reg; int reg;
{ {
static int timeout_flag; /* must be static */ clock_t t0,t1;
port_t port; port_t port;
u32_t v; u32_t v;
@ -2346,13 +2335,12 @@ int reg;
fxp_outl(port, CSR_MDI_CTL, CM_READ | (1 << CM_PHYADDR_SHIFT) | fxp_outl(port, CSR_MDI_CTL, CM_READ | (1 << CM_PHYADDR_SHIFT) |
(reg << CM_REG_SHIFT)); (reg << CM_REG_SHIFT));
timeout_flag= 0; getuptime(&t0);
sys_flagalrm(MICROS_TO_TICKS(1000), &timeout_flag);
do { do {
v= fxp_inl(port, CSR_MDI_CTL); v= fxp_inl(port, CSR_MDI_CTL);
if (v & CM_READY) if (v & CM_READY)
break; break;
} while (!timeout_flag); } while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
if (!(v & CM_READY)) if (!(v & CM_READY))
panic("mii_read: MDI not ready after command", NO_NUM); panic("mii_read: MDI not ready after command", NO_NUM);

View File

@ -836,33 +836,29 @@ re_t *rep;
u32_t t; u32_t t;
phys_bytes bus_buf; phys_bytes bus_buf;
int i; int i;
static int timeout; /* must be static if not cancelled */ clock_t t0,t1;
port= rep->re_base_port; port= rep->re_base_port;
#if 0 #if 0
/* Reset the PHY */ /* Reset the PHY */
rl_outb(port, RL_BMCR, MII_CTRL_RST); rl_outb(port, RL_BMCR, MII_CTRL_RST);
timeout=0; getuptime(&t0);
sys_flagalrm(HZ, &timeout);
do { do {
if (!(rl_inb(port, RL_BMCR) & MII_CTRL_RST)) if (!(rl_inb(port, RL_BMCR) & MII_CTRL_RST))
break; break;
} while (! timeout); } while (getuptime(&t1)==OK && (t1-t0) < HZ);
sys_flagalrm(0, &timeout); /* for correctness */
if (rl_inb(port, RL_BMCR) & MII_CTRL_RST) if (rl_inb(port, RL_BMCR) & MII_CTRL_RST)
server_panic("rtl8139","reset PHY failed to complete", NO_NUM); server_panic("rtl8139","reset PHY failed to complete", NO_NUM);
#endif #endif
/* Reset the device */ /* Reset the device */
rl_outb(port, RL_CR, RL_CR_RST); rl_outb(port, RL_CR, RL_CR_RST);
timeout=0; getuptime(&t0);
sys_flagalrm(HZ, &timeout);
do { do {
if (!(rl_inb(port, RL_CR) & RL_CR_RST)) if (!(rl_inb(port, RL_CR) & RL_CR_RST))
break; break;
} while (! timeout); } while (getuptime(&t1)==OK && (t1-t0) < HZ);
sys_flagalrm(0, &timeout); /* for correctness */
if (rl_inb(port, RL_CR) & RL_CR_RST) if (rl_inb(port, RL_CR) & RL_CR_RST)
server_panic("rtl8139","reset failed to complete", NO_NUM); server_panic("rtl8139","reset failed to complete", NO_NUM);
@ -1789,7 +1785,7 @@ re_t *rep;
port_t port; port_t port;
u8_t cr; u8_t cr;
int i; int i;
static int timeout; /* must be static if not cancelled */ clock_t t0,t1;
rep->re_clear_rx= FALSE; rep->re_clear_rx= FALSE;
port= rep->re_base_port; port= rep->re_base_port;
@ -1798,13 +1794,11 @@ re_t *rep;
cr= rl_inb(port, RL_CR); cr= rl_inb(port, RL_CR);
cr &= ~RL_CR_RE; cr &= ~RL_CR_RE;
rl_outb(port, RL_CR, cr); rl_outb(port, RL_CR, cr);
timeout=0; getuptime(&t0);
sys_flagalrm(HZ, &timeout);
do { do {
if (!(rl_inb(port, RL_CR) & RL_CR_RE)) if (!(rl_inb(port, RL_CR) & RL_CR_RE))
break; break;
} while (! timeout); } while (getuptime(&t1)==OK && (t1-t0) < HZ);
sys_flagalrm(0, &timeout); /* for correctness */
if (rl_inb(port, RL_CR) & RL_CR_RE) if (rl_inb(port, RL_CR) & RL_CR_RE)
server_panic("rtl8139","cannot disable receiver", NO_NUM); server_panic("rtl8139","cannot disable receiver", NO_NUM);
@ -2063,8 +2057,7 @@ re_t *rep;
#if 0 #if 0
u8_t cr; u8_t cr;
#endif #endif
static int timeout; /* must be static if not cancelled */ clock_t t0,t1;
int_event_check = FALSE; /* disable check by default */ int_event_check = FALSE; /* disable check by default */
RAND_UPDATE RAND_UPDATE
@ -2160,13 +2153,11 @@ re_t *rep;
cr= rl_inb(port, RL_CR); cr= rl_inb(port, RL_CR);
cr &= ~RL_CR_TE; cr &= ~RL_CR_TE;
rl_outb(port, RL_CR, cr); rl_outb(port, RL_CR, cr);
timeout=0; getuptime(&t0);
sys_flagalrm(HZ, &timeout);
do { do {
if (!(rl_inb(port, RL_CR) & RL_CR_TE)) if (!(rl_inb(port, RL_CR) & RL_CR_TE))
break; break;
} while (! timeout); } while (getuptime(&t1)==OK && (t1-t0) < HZ);
sys_flagalrm(0, &timeout); /* for correctness */
if (rl_inb(port, RL_CR) & RL_CR_TE) if (rl_inb(port, RL_CR) & RL_CR_TE)
{ {
server_panic("rtl8139","cannot disable transmitter", server_panic("rtl8139","cannot disable transmitter",
@ -2575,7 +2566,7 @@ int a;
u16_t w; u16_t w;
{ {
int b, i, cmd; 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 | 0x8); /* Set CS */
@ -2602,13 +2593,11 @@ u16_t w;
outb_reg3(dep, 1, 0x80); /* Drop CS */ outb_reg3(dep, 1, 0x80); /* Drop CS */
/* micro_delay(1); */ /* Is this required? */ /* micro_delay(1); */ /* Is this required? */
outb_reg3(dep, 1, 0x80 | 0x8); /* Set CS */ outb_reg3(dep, 1, 0x80 | 0x8); /* Set CS */
timeout = 0; getuptime(&t0);
sys_flagalrm(1, &timeout);
do { do {
if (inb_reg3(dep, 1) & 1) if (inb_reg3(dep, 1) & 1)
break; break;
} while (! timeout); } while (getuptime(&t1) == OK && (t1 == t0));
sys_flagalrm(0, &timeout); /* for correctness */
if (!(inb_reg3(dep, 1) & 1)) if (!(inb_reg3(dep, 1) & 1))
server_panic("set_ee_word","device remains busy", NO_NUM); server_panic("set_ee_word","device remains busy", NO_NUM);
} }

View File

@ -22,6 +22,9 @@
#include <minix/com.h> #include <minix/com.h>
#include "tty.h" #include "tty.h"
#include "../../kernel/const.h"
#include "../../kernel/type.h"
/* Definitions used by the console driver. */ /* Definitions used by the console driver. */
#define MONO_BASE 0xB0000L /* base of mono video memory */ #define MONO_BASE 0xB0000L /* base of mono video memory */
#define COLOR_BASE 0xB8000L /* base of color video memory */ #define COLOR_BASE 0xB8000L /* base of color video memory */

View File

@ -47,12 +47,11 @@
#define NR_BUF_HASH 512 /* size of buf hash table; MUST BE POWER OF 2*/ #define NR_BUF_HASH 512 /* size of buf hash table; MUST BE POWER OF 2*/
#endif #endif
/* Defines for kernel configuration. */ /* Defines for driver and kernel configuration. */
#define AUTO_BIOS 0 /* xt_wini.c - use Western's autoconfig BIOS */ #define AUTO_BIOS 0 /* xt_wini.c - use Western's autoconfig BIOS */
#define LINEWRAP 1 /* console.c - wrap lines at column 80 */ #define LINEWRAP 1 /* console.c - wrap lines at column 80 */
#define ALLOW_GAP_MESSAGES 1 /* proc.c - allow messages in the gap between #define ALLOW_GAP_MESSAGES 1 /* proc.c - allow messages in the gap between
* the end of bss and lowest stack address */ * 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). */ /* Number of controller tasks (/dev/cN device classes). */
#define NR_CTRLRS 2 #define NR_CTRLRS 2

View File

@ -119,14 +119,4 @@ struct machine {
int vdu_vga; 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 */ #endif /* _TYPE_H */

View File

@ -43,9 +43,9 @@ _PROTOTYPE(int fkey_ctl, (int fkey_code, int enable_disable) );
_PROTOTYPE(void server_report, (char *who, char *mess, int num) ); _PROTOTYPE(void server_report, (char *who, char *mess, int num) );
_PROTOTYPE(void server_panic, (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 get_proc_nr, (int *proc_nr, char *proc_name) );
_PROTOTYPE(int getuptime, (clock_t *ticks));
_PROTOTYPE(int tick_delay, (clock_t ticks)); _PROTOTYPE(int tick_delay, (clock_t ticks));
#endif /* _EXTRALIB_H */ #endif /* _EXTRALIB_H */

View File

@ -4,8 +4,6 @@
#include <ibm/ports.h> /* port addresses and magic numbers */ #include <ibm/ports.h> /* port addresses and magic numbers */
#include <ibm/bios.h> /* BIOS addresses, sizes 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 /* 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. * the same as umap_local(proc_ptr, D, vir, sizeof(*vir)), but less costly.
*/ */
@ -27,6 +25,9 @@
/* How long should the process names be in the kernel? */ /* How long should the process names be in the kernel? */
#define P_NAME_LEN 8 #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. */ /* How many bytes for (port,value)-pairs vector to copy in. */
#define VDEVIO_BUF_SIZE 128 #define VDEVIO_BUF_SIZE 128
@ -48,6 +49,9 @@
#define SET_BIT(map,bit) ( MAP_CHUNK(map,bit) |= (1 << CHUNK_OFFSET(bit) ) #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) ) #define UNSET_BIT(map,bit) ( MAP_CHUNK(map,bit) &= ~(1 << CHUNK_OFFSET(bit) )
#if (CHIP == INTEL)
/* Program stack words and masks. */ /* Program stack words and masks. */
#define INIT_PSW 0x0200 /* initial psw */ #define INIT_PSW 0x0200 /* initial psw */
#define INIT_TASK_PSW 0x1200 /* initial psw for tasks (with IOPL 1) */ #define INIT_TASK_PSW 0x1200 /* initial psw for tasks (with IOPL 1) */
@ -67,7 +71,6 @@
*/ */
#define NR_MEMS 8 /* number of chunks of memory */ #define NR_MEMS 8 /* number of chunks of memory */
#endif /* (CHIP == INTEL) */ #endif /* (CHIP == INTEL) */
#if (CHIP == M68000) #if (CHIP == M68000)

View File

@ -45,19 +45,16 @@ struct proc {
clock_t p_user_time; /* user time in ticks */ clock_t p_user_time; /* user time in ticks */
clock_t p_sys_time; /* sys 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 proc *p_nextready; /* pointer to next ready process */
struct notification *p_ntf_q; /* queue of pending notifications */ 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_caller_q; /* head of list of procs wishing to send */
struct proc *p_q_link; /* link to next proc 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_getfrom; /* from whom does process want to receive? */
proc_nr_t p_sendto; /* to whom does process want to send? */ 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 */ unsigned p_pendcount; /* count of pending and unfinished signals */
char p_name[P_NAME_LEN]; /* name of the process, including \0 */ char p_name[P_NAME_LEN]; /* name of the process, including \0 */

View File

@ -114,9 +114,7 @@ PRIVATE void initialize(void)
/* Initialize all alarm timers for all processes. */ /* Initialize all alarm timers for all processes. */
for (rp=BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++) { for (rp=BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++) {
tmr_inittimer(&(rp->p_signalrm)); tmr_inittimer(&(rp->p_alarm_timer));
tmr_inittimer(&(rp->p_syncalrm));
tmr_inittimer(&(rp->p_flagalrm));
} }
/* Initialize the call vector to a safe default handler. Some system calls /* Initialize the call vector to a safe default handler. Some system calls
@ -146,7 +144,6 @@ PRIVATE void initialize(void)
map(SYS_TIMES, do_times); /* get uptime and process times */ map(SYS_TIMES, do_times); /* get uptime and process times */
map(SYS_SIGNALRM, do_signalrm); /* causes an alarm signal */ map(SYS_SIGNALRM, do_signalrm); /* causes an alarm signal */
map(SYS_SYNCALRM, do_syncalrm); /* send a notification message */ map(SYS_SYNCALRM, do_syncalrm); /* send a notification message */
map(SYS_FLAGALRM, do_flagalrm); /* set a timeout flag to 1 */
/* Device I/O. */ /* Device I/O. */
map(SYS_IRQCTL, do_irqctl); /* interrupt control operations */ map(SYS_IRQCTL, do_irqctl); /* interrupt control operations */
@ -192,9 +189,7 @@ int proc_nr; /* slot of process to clean up */
rc = proc_addr(proc_nr); rc = proc_addr(proc_nr);
/* Turn off any alarm timers at the clock. */ /* Turn off any alarm timers at the clock. */
reset_timer(&rc->p_signalrm); reset_timer(&rc->p_alarm_timer);
reset_timer(&rc->p_flagalrm);
reset_timer(&rc->p_syncalrm);
/* Make sure the exiting process is no longer scheduled. */ /* Make sure the exiting process is no longer scheduled. */
if (rc->p_flags == 0) lock_unready(rc); if (rc->p_flags == 0) lock_unready(rc);

View File

@ -39,22 +39,19 @@ register message *m_ptr; /* pointer to request message */
/* The system call implemented in this file: /* 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: * The parameters for this system call are:
* m2_i1: ALRM_PROC_NR (set alarm for this process) * m2_i1: ALRM_PROC_NR (set alarm for this process)
* m2_l1: ALRM_EXP_TIME (alarm's expiration time) * m2_l1: ALRM_EXP_TIME (alarm's expiration time)
* m2_i2: ALRM_ABS_TIME (expiration time is absolute?) * m2_i2: ALRM_ABS_TIME (expiration time is absolute?)
* m2_l1: ALRM_SEC_LEFT (return seconds left of previous) * m2_l1: ALRM_SEC_LEFT (return seconds left of previous)
* m2_p1: ALRM_FLAG_PTR (virtual addr of alarm flag)
* *
* Changes: * Changes:
* Aug 25, 2004 fully rewritten to unite all alarms (Jorrit N. Herder) * Aug 25, 2004 fully rewritten to clean up code (Jorrit N. Herder)
* May 02, 2004 added new timeout flag alarm (Jorrit N. Herder)
*/ */
FORWARD _PROTOTYPE( void cause_syncalrm, (timer_t *tp) ); FORWARD _PROTOTYPE( void cause_syncalrm, (timer_t *tp) );
FORWARD _PROTOTYPE( void cause_flagalrm, (timer_t *tp) );
FORWARD _PROTOTYPE( void cause_signalrm, (timer_t *tp) ); FORWARD _PROTOTYPE( void cause_signalrm, (timer_t *tp) );
/*===========================================================================* /*===========================================================================*
@ -64,7 +61,7 @@ PUBLIC int do_setalarm(m_ptr)
message *m_ptr; /* pointer to request message */ message *m_ptr; /* pointer to request message */
{ {
/* A process requests an alarm, or wants to cancel its alarm. This function /* 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 */ int proc_nr; /* which process wants the alarm */
long exp_time; /* expiration time for this alarm */ long exp_time; /* expiration time for this alarm */
@ -80,26 +77,12 @@ message *m_ptr; /* pointer to request message */
use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */ use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */
/* Get the timer structure and set the parameters for this alarm. */ /* 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) { switch (m_ptr->m_type) {
case SYS_SYNCALRM: /* notify with SYN_ALARM message */ case SYS_SYNCALRM: tp->tmr_func = cause_syncalrm; break;
tp = &(proc_addr(proc_nr)->p_syncalrm); case SYS_SIGNALRM: tp->tmr_func = cause_signalrm; break;
tmr_arg(tp)->ta_int = proc_nr; default: return(EINVAL); /* invalid alarm type */
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);
} }
/* Return the ticks left on the previous alarm. */ /* Return the ticks left on the previous alarm. */
@ -134,21 +117,6 @@ timer_t *tp;
cause_sig(tmr_arg(tp)->ta_int, SIGALRM); 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 * * cause_syncalrm *

View File

@ -45,6 +45,14 @@ struct notification {
struct notification* n_next; /* pointer to next notification */ 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) #if (CHIP == INTEL)
typedef unsigned reg_t; /* machine register */ typedef unsigned reg_t; /* machine register */

View File

@ -8,6 +8,7 @@ all: $(LIBUTILS)
OBJECTS = \ OBJECTS = \
$(LIBUTILS)(tick_delay.o) \ $(LIBUTILS)(tick_delay.o) \
$(LIBUTILS)(get_upt.o) \
$(LIBUTILS)(get_mon_prm.o) \ $(LIBUTILS)(get_mon_prm.o) \
$(LIBUTILS)(env_parse.o) \ $(LIBUTILS)(env_parse.o) \
$(LIBUTILS)(env_panic.o) \ $(LIBUTILS)(env_panic.o) \
@ -24,6 +25,9 @@ $(LIBUTILS): $(OBJECTS)
aal cr $@ *.o aal cr $@ *.o
rm *.o rm *.o
$(LIBUTILS)(get_upt.o): get_upt.c
$(CC1) get_upt.c
$(LIBUTILS)(tick_delay.o): tick_delay.c $(LIBUTILS)(tick_delay.o): tick_delay.c
$(CC1) tick_delay.c $(CC1) tick_delay.c

View File

@ -1,6 +1,7 @@
#include "fs.h" #include "fs.h"
#include <minix/com.h> #include <minix/com.h>
#include <minix/callnr.h> #include <minix/callnr.h>
#include <minix/utils.h>
#include <time.h> #include <time.h>
#include <ibm/cmos.h> #include <ibm/cmos.h>
#include <ibm/bios.h> #include <ibm/bios.h>
@ -75,16 +76,16 @@ PRIVATE int get_cmostime(struct tm *t, int y2kflag)
*/ */
int osec, n; int osec, n;
unsigned long i; unsigned long i;
static int timeout_flag; clock_t t0,t1;
/* Start a timer to keep us from getting stuck on a dead clock. */ /* Start a timer to keep us from getting stuck on a dead clock. */
timeout_flag = 0; getuptime(&t0);
sys_flagalrm(5*HZ, &timeout_flag);
do { do {
osec = -1; osec = -1;
n = 0; n = 0;
do { do {
if (timeout_flag) { getuptime(&t1);
if (t1-t0 > 5*HZ) {
printf("readclock: CMOS clock appears dead\n"); printf("readclock: CMOS clock appears dead\n");
return(1); return(1);
} }
@ -117,7 +118,6 @@ PRIVATE int get_cmostime(struct tm *t, int y2kflag)
|| read_register(RTC_MDAY) != t->tm_mday || read_register(RTC_MDAY) != t->tm_mday
|| read_register(RTC_MONTH) != t->tm_mon || read_register(RTC_MONTH) != t->tm_mon
|| read_register(RTC_YEAR) != t->tm_year); || 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) { if ((read_register(RTC_REG_B) & RTC_B_DM_BCD) == 0) {
/* Convert BCD to binary (default RTC mode). */ /* Convert BCD to binary (default RTC mode). */