. no more HZ, but use sys_hz() to get that value

. memory maps in physical memory (for /dev/mem) with new vm interface
 . pci complete_bars() seems to be buggy behaviour sometimes
 . startup script opens its own stdout, stderr and stdin so init doesn't
   have to do it
This commit is contained in:
Ben Gras 2008-12-11 14:42:23 +00:00
parent 6cfe4bdd2d
commit 1d8aed840c
13 changed files with 79 additions and 36 deletions

View file

@ -221,7 +221,7 @@ struct command {
/* Some controllers don't interrupt, the clock will wake us up. */
#define WAKEUP_SECS 32 /* drive may be out for 31 seconds max */
#define WAKEUP_TICKS (WAKEUP_SECS*HZ)
#define WAKEUP_TICKS (WAKEUP_SECS*system_hz)
/* Miscellaneous. */
#define MAX_DRIVES 8
@ -254,8 +254,7 @@ struct command {
/* Timeouts and max retries. */
int timeout_ticks = DEF_TIMEOUT_TICKS, max_errors = MAX_ERRORS;
long w_standard_timeouts = 0, w_pci_debug = 0, w_instance = 0,
disable_dma = 0, atapi_debug = 0, w_identify_wakeup_ticks = WAKEUP_TICKS,
wakeup_ticks = WAKEUP_TICKS;
disable_dma = 0, atapi_debug = 0, w_identify_wakeup_ticks, wakeup_ticks;
int w_testing = 0, w_silent = 0;
@ -432,8 +431,13 @@ PUBLIC int main(int argc, char *argv[])
/* Install signal handlers. Ask PM to transform signal into message. */
struct sigaction sa;
system_hz = sys_hz();
init_buffer();
w_identify_wakeup_ticks = WAKEUP_TICKS;
wakeup_ticks = WAKEUP_TICKS;
sa.sa_handler = SIG_MESS;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
@ -470,7 +474,7 @@ PRIVATE void init_params()
env_parse("ata_id_timeout", "d", WAKEUP_SECS, &wakeup_secs, 1, 60);
env_parse("atapi_debug", "d", 0, &atapi_debug, 0, 1);
w_identify_wakeup_ticks = wakeup_secs * HZ;
w_identify_wakeup_ticks = wakeup_secs * system_hz;
if(atapi_debug)
panic("at_wini", "atapi_debug", NO_NUM);
@ -1144,8 +1148,8 @@ PRIVATE int w_io_test(void)
save_wakeup = wakeup_ticks;
if (!w_standard_timeouts) {
timeout_ticks = HZ * 4;
wakeup_ticks = HZ * 6;
timeout_ticks = system_hz * 4;
wakeup_ticks = system_hz * 6;
max_errors = 3;
}

View file

@ -22,7 +22,9 @@
#if ENABLE_3C503
#define MILLIS_TO_TICKS(m) (((m)*HZ/1000)+1)
extern u32_t system_hz;
#define MILLIS_TO_TICKS(m) (((m)*system_hz/1000)+1)
_PROTOTYPE(static void el2_init, (dpeth_t *dep));
_PROTOTYPE(static void el2_stop, (dpeth_t *dep));

View file

@ -72,6 +72,8 @@ static dpeth_t de_table[DE_PORT_NR];
static u16_t eth_ign_proto;
static char *progname;
u32_t system_hz;
/* Configuration */
typedef struct dp_conf
{
@ -210,6 +212,8 @@ int main(int argc, char *argv[])
dpeth_t *dep;
long v;
system_hz = sys_hz();
if (argc < 1)
{
panic("DP8390",

View file

@ -23,7 +23,9 @@ Created: March 15, 1994 by Philip Homburg <philip@f-mnx.phicoh.com>
#define N 100
#define MILLIS_TO_TICKS(m) (((m)*HZ/1000)+1)
extern u32_t system_hz;
#define MILLIS_TO_TICKS(m) (((m)*system_hz/1000)+1)
_PROTOTYPE( typedef int (*testf_t), (dpeth_t *dep, int pos, u8_t *pat) );

View file

@ -102,8 +102,8 @@
#define MAX_SECTORS 18 /* largest # sectors per track */
#define DTL 0xFF /* determines data length (sector size) */
#define SPEC2 0x02 /* second parameter to SPECIFY */
#define MOTOR_OFF (3*HZ) /* how long to wait before stopping motor */
#define WAKEUP (2*HZ) /* timeout on I/O, FDC won't quit. */
#define MOTOR_OFF (3*system_hz) /* how long to wait before stopping motor */
#define WAKEUP (2*system_hz) /* timeout on I/O, FDC won't quit. */
/* Error codes */
#define ERR_SEEK (-1) /* bad seek */
@ -164,17 +164,17 @@ PRIVATE struct density {
u8_t steps; /* steps per cylinder (2 = double step) */
u8_t test; /* sector to try for density test */
u8_t rate; /* data rate (2=250, 1=300, 0=500 kbps) */
clock_t start; /* motor start (clock ticks) */
clock_t start_ms; /* motor start (milliseconds) */
u8_t gap; /* gap size */
u8_t spec1; /* first specify byte (SRT/HUT) */
} fdensity[NT] = {
{ 9, 40, 1, 4*9, 2, 4*HZ/8, 0x2A, 0xDF }, /* 360K / 360K */
{ 15, 80, 1, 14, 0, 4*HZ/8, 0x1B, 0xDF }, /* 1.2M / 1.2M */
{ 9, 40, 2, 2*9, 2, 4*HZ/8, 0x2A, 0xDF }, /* 360K / 720K */
{ 9, 80, 1, 4*9, 2, 6*HZ/8, 0x2A, 0xDF }, /* 720K / 720K */
{ 9, 40, 2, 2*9, 1, 4*HZ/8, 0x23, 0xDF }, /* 360K / 1.2M */
{ 9, 80, 1, 4*9, 1, 4*HZ/8, 0x23, 0xDF }, /* 720K / 1.2M */
{ 18, 80, 1, 17, 0, 6*HZ/8, 0x1B, 0xCF }, /* 1.44M / 1.44M */
{ 9, 40, 1, 4*9, 2, 500, 0x2A, 0xDF }, /* 360K / 360K */
{ 15, 80, 1, 14, 0, 500, 0x1B, 0xDF }, /* 1.2M / 1.2M */
{ 9, 40, 2, 2*9, 2, 500, 0x2A, 0xDF }, /* 360K / 720K */
{ 9, 80, 1, 4*9, 2, 750, 0x2A, 0xDF }, /* 720K / 720K */
{ 9, 40, 2, 2*9, 1, 500, 0x23, 0xDF }, /* 360K / 1.2M */
{ 9, 80, 1, 4*9, 1, 500, 0x23, 0xDF }, /* 720K / 1.2M */
{ 18, 80, 1, 17, 0, 750, 0x1B, 0xCF }, /* 1.44M / 1.44M */
};
/* The following table is used with the test_sector array to recognize a
@ -757,7 +757,7 @@ PRIVATE void start_motor()
/* Set an alarm timer to force a timeout if the hardware does not interrupt
* in time. Expect HARD_INT message, but check for SYN_ALARM timeout.
*/
f_set_timer(&f_tmr_timeout, f_dp->start, f_timeout);
f_set_timer(&f_tmr_timeout, f_dp->start_ms * system_hz / 1000, f_timeout);
f_busy = BSY_IO;
do {
receive(ANY, &mess);
@ -841,7 +841,7 @@ PRIVATE int seek()
/* Set a synchronous alarm to force a timeout if the hardware does
* not interrupt. Expect HARD_INT, but check for SYN_ALARM timeout.
*/
f_set_timer(&f_tmr_timeout, HZ/30, f_timeout);
f_set_timer(&f_tmr_timeout, system_hz/30, f_timeout);
f_busy = BSY_IO;
do {
receive(ANY, &mess);

View file

@ -220,6 +220,8 @@ static char *progname;
extern int errno;
u32_t system_hz;
#define fxp_inb(port, offset) (do_inb((port) + (offset)))
#define fxp_inw(port, offset) (do_inw((port) + (offset)))
#define fxp_inl(port, offset) (do_inl((port) + (offset)))
@ -284,6 +286,8 @@ int main(int argc, char *argv[])
long v;
vir_bytes ft = sizeof(*fxp_table)*FXP_PORT_NR;
system_hz = sys_hz();
if (argc < 1)
panic("FXP", "A head which at this time has no name", NO_NUM);
(progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]);
@ -381,7 +385,7 @@ message *mp;
tmra_inittimer(&fxp_watchdog);
tmr_arg(&fxp_watchdog)->ta_int= 0;
fxp_set_timer(&fxp_watchdog, HZ, fxp_watchdog_f);
fxp_set_timer(&fxp_watchdog, system_hz, fxp_watchdog_f);
}
port = mp->DL_PORT;
@ -2282,7 +2286,7 @@ timer_t *tp;
fxp_t *fp;
tmr_arg(&fxp_watchdog)->ta_int= 0;
fxp_set_timer(&fxp_watchdog, HZ, fxp_watchdog_f);
fxp_set_timer(&fxp_watchdog, system_hz, fxp_watchdog_f);
for (i= 0, fp = &fxp_table[0]; i<FXP_PORT_NR; i++, fp++)
{

View file

@ -67,6 +67,8 @@ struct driver *dp; /* Device dependent entry points. */
int r, proc_nr;
message mess;
system_hz = sys_hz();
/* Init MQ library. */
mq_init();

View file

@ -84,3 +84,5 @@ extern u8_t *tmp_buf; /* the DMA buffer */
extern u8_t tmp_buf[]; /* the DMA buffer */
#endif
extern phys_bytes tmp_phys; /* phys address of DMA buffer */
u32_t system_hz;

View file

@ -19,6 +19,8 @@
#include <sys/ioc_memory.h>
#include <env.h>
#include <minix/ds.h>
#include <minix/vm.h>
#include <sys/mman.h>
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"
@ -69,11 +71,13 @@ PRIVATE struct driver m_dtab = {
NULL
};
#if 0
/* One page of temporary mapping area - enough to be able to page-align
* one page.
*/
static char pagedata_buf[2*I386_PAGE_SIZE];
vir_bytes pagedata_aligned;
#endif
/* Buffer for the /dev/zero null byte feed. */
#define ZERO_BUF_SIZE 1024
@ -201,6 +205,7 @@ int safe; /* safe copies */
u32_t pagestart, page_off;
static u32_t pagestart_mapped;
static int any_mapped = 0;
static char *vaddr;
int r;
u32_t subcount;
@ -217,13 +222,18 @@ int safe; /* safe copies */
* Don't have to map same page over and over.
*/
if(!any_mapped || pagestart_mapped != pagestart) {
#if 0
if((r=sys_vm_map(SELF, 1, pagedata_aligned,
I386_PAGE_SIZE, pagestart)) != OK) {
#else
if(1) {
#endif
printf("memory: sys_vm_map failed: %d\n", r);
if(any_mapped) {
if(vm_unmap_phys(SELF, vaddr, I386_PAGE_SIZE) != OK)
panic("MEM","vm_unmap_phys failed",NO_NUM);
any_mapped = 0;
}
vaddr = vm_map_phys(SELF, (void *) pagestart, I386_PAGE_SIZE);
if(vaddr == MAP_FAILED)
r = ENOMEM;
else
r = OK;
if(r != OK) {
printf("memory: vm_map_phys failed\n");
return r;
}
any_mapped = 1;
@ -237,10 +247,10 @@ int safe; /* safe copies */
if (opcode == DEV_GATHER_S) { /* copy data */
s=sys_safecopyto(proc_nr, user_vir,
vir_offset, pagedata_aligned+page_off, subcount, D);
vir_offset, (vir_bytes) vaddr+page_off, subcount, D);
} else {
s=sys_safecopyfrom(proc_nr, user_vir,
vir_offset, pagedata_aligned+page_off, subcount, D);
vir_offset, (vir_bytes) vaddr+page_off, subcount, D);
}
if(s != OK)
return s;
@ -373,9 +383,11 @@ PRIVATE void m_init()
dev_zero[i] = '\0';
}
#if 0
/* Page-align page pointer. */
pagedata_aligned = (u32_t) pagedata_buf + I386_PAGE_SIZE;
pagedata_aligned -= pagedata_aligned % I386_PAGE_SIZE;
#endif
/* Set up memory range for /dev/mem. */
m_geom[MEM_DEV].dv_size = cvul64(0xffffffff);

View file

@ -1,5 +1,10 @@
#!/bin/sh
set -e
exec >/dev/log
exec 2>/dev/log
exec </dev/null
/bin/service up /bin/pci -config /etc/drivers.conf
/bin/service -c up /bin/floppy -config /etc/drivers.conf -dev /dev/fd0
if [ X`/bin/sysenv bios_wini` = Xyes ]

View file

@ -231,6 +231,8 @@ _PROTOTYPE (static void or_dump, (message *m));
PRIVATE message m;
PRIVATE int int_event_check; /* set to TRUE if events arrived */
u32_t system_hz;
static char *progname;
extern int errno;
@ -246,6 +248,8 @@ int main(int argc, char *argv[]) {
long v = 0;
t_or *orp;
system_hz = sys_hz();
(progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]);
env_setargs(argc, argv);
@ -440,7 +444,7 @@ static void or_reset() {
if (OK != (r = getuptime(&now)))
panic(__FILE__, "orinoco: getuptime() failed:", r);
if(now - last_reset < HZ * 10) {
if(now - last_reset < system_hz * 10) {
printf("Resetting card too often. Going to reset driver\n");
exit(1);
}
@ -521,7 +525,7 @@ static void or_init (message * mp) {
tmra_inittimer(&or_watchdog);
/* Use a synchronous alarm instead of a watchdog timer. */
sys_setalarm(HZ, 0);
sys_setalarm(system_hz, 0);
}
port = mp->DL_PORT;
@ -1287,7 +1291,7 @@ static void or_watchdog_f(timer_t *tp) {
t_or *orp;
/* Use a synchronous alarm instead of a watchdog timer. */
sys_setalarm(HZ, 0);
sys_setalarm(system_hz, 0);
for (i= 0, orp = &or_table[0]; i<OR_PORT_NR; i++, orp++) {
if (orp->or_mode != OR_M_ENABLED)

View file

@ -1269,6 +1269,7 @@ PRIVATE void complete_bridges()
*===========================================================================*/
PRIVATE void complete_bars()
{
#if 0
int i, j, r, bar_nr, reg;
u32_t memgap_low, memgap_high, iogap_low, iogap_high, io_high,
base, size, v32, diff1, diff2;
@ -1485,6 +1486,7 @@ PRIVATE void complete_bars()
printf("should allocate resources for device %d\n", i);
}
}
#endif
}
/*===========================================================================*

View file

@ -217,7 +217,7 @@ int safe; /* use virtual addresses or grant id's? */
do_printer_output();
return;
}
tickdelay(HZ/2); /* wait before retry */
micro_delay(500000); /* wait before retry */
}
/* If we reach this point, the printer was not online in time. */
done_status = status;
@ -342,7 +342,7 @@ PRIVATE void do_initialize()
printf("printer: sys_outb of %x failed\n", port_base+2);
panic(__FILE__, "do_initialize: sys_outb init failed", NO_NUM);
}
tickdelay(HZ/20); /* easily satisfies Centronics minimum */
micro_delay(1000000/20); /* easily satisfies Centronics minimum */
if(sys_outb(port_base + 2, PR_SELECT) != OK) {
printf("printer: sys_outb of %x failed\n", port_base+2);
panic(__FILE__, "do_initialize: sys_outb select failed", NO_NUM);