diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-09-02 17:55:56 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-09-02 17:55:56 -0700 |
commit | 733ec3ad95cf1df199cd0a8ec9b8352a6942e059 (patch) | |
tree | a3c753a7643264d817a76e08315a9a1ae88f026e | |
parent | 75d4dec2f651c9f25fa95d6b6960db7c4dcfd7a0 (diff) | |
download | syslinux-733ec3ad95cf1df199cd0a8ec9b8352a6942e059.tar.gz |
core: use jiffies instead of BIOS_timer
Use jiffies instead of BIOS_timer. In 16-bit code we can use the low
16 bits of __jiffies when appropriate, since we have proper 2's
complement wraparound at all times.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | core/fs/pxe/dnsresolv.c | 6 | ||||
-rw-r--r-- | core/fs/pxe/pxe.c | 30 | ||||
-rw-r--r-- | core/fs/pxe/pxe.h | 1 | ||||
-rw-r--r-- | core/idle.inc | 18 | ||||
-rw-r--r-- | core/pxelinux.asm | 2 | ||||
-rw-r--r-- | core/ui.inc | 4 |
6 files changed, 29 insertions, 32 deletions
diff --git a/core/fs/pxe/dnsresolv.c b/core/fs/pxe/dnsresolv.c index 98bc960e..15560447 100644 --- a/core/fs/pxe/dnsresolv.c +++ b/core/fs/pxe/dnsresolv.c @@ -181,7 +181,7 @@ uint32_t dns_resolv(const char *name) int ques, reps; /* number of questions and replies */ uint8_t timeout; const uint8_t *timeout_ptr = TimeoutTable; - uint16_t oldtime; + uint32_t oldtime; uint32_t srv; uint32_t *srv_ptr = dns_server; struct dnshdr *hd1 = (struct dnshdr *)DNSSendBuf; @@ -232,7 +232,7 @@ uint32_t dns_resolv(const char *name) if (err || udp_write.status != 0) continue; - oldtime = BIOS_timer; + oldtime = jiffies(); while (1) { udp_read.status = 0; udp_read.src_ip = srv; @@ -249,7 +249,7 @@ uint32_t dns_resolv(const char *name) if (hd2->id == hd1->id) break; - if ((uint16_t)(BIOS_timer-oldtime) >= timeout) { + if (jiffies()-oldtime >= timeout) { /* time out */ timeout = *timeout_ptr++; if (!timeout) diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c index d7527177..4613e321 100644 --- a/core/fs/pxe/pxe.c +++ b/core/fs/pxe/pxe.c @@ -514,7 +514,7 @@ static void fill_buffer(struct open_file_t *file) const uint8_t *timeout_ptr = TimeoutTable; uint8_t timeout; uint16_t buffersize; - uint16_t old_time; + uint32_t oldtime; void *data = NULL; static __lowmem struct s_PXENV_UDP_READ udp_read; @@ -538,7 +538,7 @@ static void fill_buffer(struct open_file_t *file) timeout_ptr = TimeoutTable; timeout = *timeout_ptr++; - old_time = BIOS_timer; + oldtime = jiffies(); while (timeout) { udp_read.buffer.offs = file->tftp_pktbuf; udp_read.buffer.seg = PKTBUF_SEG; @@ -549,13 +549,11 @@ static void fill_buffer(struct open_file_t *file) udp_read.d_port = file->tftp_localport; err = pxe_call(PXENV_UDP_READ, &udp_read); if (err) { - if (BIOS_timer == old_time) - continue; - - BIOS_timer = old_time; - timeout--; /* decrease one timer tick */ - if (!timeout) { - timeout = *timeout_ptr++; + uint32_t now = jiffies(); + + if (now-oldtime >= timeout) { + oldtime = now; + timeout = *timeout_ptr++; if (!timeout) break; } @@ -704,7 +702,7 @@ static void pxe_searchdir(char *filename, struct file *file) int buffersize; const uint8_t *timeout_ptr; uint8_t timeout; - uint16_t oldtime; + uint32_t oldtime; uint16_t tid; uint16_t opcode; uint16_t blk_num; @@ -786,7 +784,7 @@ static void pxe_searchdir(char *filename, struct file *file) /* Packet transmitted OK, now we need to receive */ timeout = *timeout_ptr++; - oldtime = BIOS_timer; + oldtime = jiffies(); for (;;) { buf = packet_buf; udp_read.buffer.offs = OFFS_WRT(buf, 0); @@ -796,13 +794,9 @@ static void pxe_searchdir(char *filename, struct file *file) udp_read.d_port = tid; err = pxe_call(PXENV_UDP_READ, &udp_read); if (err) { - uint16_t now = BIOS_timer; - if (oldtime != now) { - oldtime = now; - timeout--; /* Decrease one timer tick */ - if (!timeout) - goto failure; - } + uint32_t now = jiffies(); + if (now-oldtime >= timeout) + goto failure; continue; } diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h index 8a2b190c..f62fa7a7 100644 --- a/core/fs/pxe/pxe.h +++ b/core/fs/pxe/pxe.h @@ -197,7 +197,6 @@ extern int have_uuid; extern uint8_t uuid_type; extern char uuid[]; -extern volatile uint16_t BIOS_timer; extern uint16_t BIOS_fbm; extern const uint8_t TimeoutTable[]; diff --git a/core/idle.inc b/core/idle.inc index 966b6e26..8d699733 100644 --- a/core/idle.inc +++ b/core/idle.inc @@ -15,10 +15,10 @@ TICKS_TO_IDLE equ 4 reset_idle: - push ax - mov ax,[cs:BIOS_timer] - mov [cs:IdleTimer],ax - pop ax + push eax + mov eax,[cs:__jiffies] + mov [cs:IdleTimer],eax + pop eax sti ; Guard against BIOS/PXE brokenness... ret @@ -54,9 +54,9 @@ do_idle: pop si sti .ok: - mov ax,[BIOS_timer] - sub ax,[IdleTimer] - cmp ax,TICKS_TO_IDLE + mov eax,[__jiffies] + sub eax,[IdleTimer] + cmp eax,TICKS_TO_IDLE jb .done mov eax,[idle_hook_func] @@ -74,6 +74,7 @@ do_idle: .ret: ret section .data16 + alignz 4 global idle_hook_func idle_hook_func dd 0 NoHalt dw 0 @@ -81,4 +82,5 @@ NoHalt dw 0 hlt_err db 'ERROR: idle with IF=0', CR, LF, 0 section .bss16 -IdleTimer resw 1 + alignb 4 +IdleTimer resd 1 diff --git a/core/pxelinux.asm b/core/pxelinux.asm index 95aa58fb..995de327 100644 --- a/core/pxelinux.asm +++ b/core/pxelinux.asm @@ -243,6 +243,8 @@ local_boot: ; kaboom: write a message and bail out. Wait for quite a while, ; or a user keypress, then do a hard reboot. ; +; Note: use BIOS_timer here; we may not have jiffies set up. +; global kaboom kaboom: RESET_STACK_AND_SEGS AX diff --git a/core/ui.inc b/core/ui.inc index 87d0c647..9a653b1c 100644 --- a/core/ui.inc +++ b/core/ui.inc @@ -529,11 +529,11 @@ getchar_timeout: call reset_idle .loop: - push word [BIOS_timer] + push word [__jiffies] call pollchar jnz .got_char pop ax - cmp ax,[BIOS_timer] ; Has the timer advanced? + cmp ax,[__jiffies] ; Has the timer advanced? je .loop dec dword [ThisKbdTo] |