From: Ben Gras Date: Thu, 11 Dec 2008 14:42:23 +0000 (+0000) Subject: . no more HZ, but use sys_hz() to get that value X-Git-Tag: v3.1.4~195 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/cppcheck-error.log?a=commitdiff_plain;h=1d8aed840cd6947a9acdc1aa9b0e0371ce754c5f;p=minix.git . 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 --- diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index d69e661f8..2802cc476 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -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; } diff --git a/drivers/dp8390/3c503.c b/drivers/dp8390/3c503.c index 2ae7cc602..df5aba5d7 100644 --- a/drivers/dp8390/3c503.c +++ b/drivers/dp8390/3c503.c @@ -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)); diff --git a/drivers/dp8390/dp8390.c b/drivers/dp8390/dp8390.c index 479e421e9..365a16a53 100644 --- a/drivers/dp8390/dp8390.c +++ b/drivers/dp8390/dp8390.c @@ -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", diff --git a/drivers/dp8390/ne2000.c b/drivers/dp8390/ne2000.c index 4f8d698ff..8d7a84da1 100644 --- a/drivers/dp8390/ne2000.c +++ b/drivers/dp8390/ne2000.c @@ -23,7 +23,9 @@ Created: March 15, 1994 by Philip Homburg #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) ); diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index b1ed29c26..3d2b80a53 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -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); diff --git a/drivers/fxp/fxp.c b/drivers/fxp/fxp.c index 1a146f139..20a7779bf 100644 --- a/drivers/fxp/fxp.c +++ b/drivers/fxp/fxp.c @@ -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 #include #include +#include +#include #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); diff --git a/drivers/memory/ramdisk/rc b/drivers/memory/ramdisk/rc index 3aae388f8..6446da30f 100644 --- a/drivers/memory/ramdisk/rc +++ b/drivers/memory/ramdisk/rc @@ -1,5 +1,10 @@ #!/bin/sh set -e + +exec >/dev/log +exec 2>/dev/log +exec 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]; ior_mode != OR_M_ENABLED) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c319fcda0..0f577635a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -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 } /*===========================================================================* diff --git a/drivers/printer/printer.c b/drivers/printer/printer.c index 037268b41..d815f0dd7 100644 --- a/drivers/printer/printer.c +++ b/drivers/printer/printer.c @@ -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);