aboutsummaryrefslogtreecommitdiff
path: root/src/hw/timer.c
AgeCommit message (Collapse)AuthorFilesLines
2020-06-26timer: Handle decrements of PIT counterRoman Bolshakov1-1/+1
There's a fallback to PIT if TSC is not present but it doesn't work properly. It prevents boot from floppy on isapc and 486 cpu [1][2]. SeaBIOS configures PIT in Mode 2. PIT counter is decremented in the mode but timer_adjust_bits() thinks that the counter overflows and increases 32-bit tick counter on each detected "overflow". Invalid overflow detection results in 55ms time advance (1 / 18.2Hz) on each read from PIT counter. So all timers expire much faster and 5-second floppy timeout expires in 83 real microseconds (or just a bit longer). It can be fixed by making the counter recieved from PIT an increasing value so it can be passed to timer_adjust_bits(): 0, 1, 2 and up to 65535 and then the counter is re-loaded with 0. 1. https://bugs.launchpad.net/seabios/+bug/1840719 2. https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg03924.html Fixes: eac11944019 ("Unify pmtimer_read() and pittimer_read() code.") Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
2020-03-16timer: add tsctimer_setfreq()Gerd Hoffmann1-1/+25
Add function to set tsc frequency directly, without calibration. Also tweak timer setup functions a bit: skip setup in case TimerPort has not the default value any more, i.e. another timer has been setup already. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200310102248.28412-1-kraxel@redhat.com
2017-11-02timer: Avoid integer overflows in usec and nsec calculationsKevin O'Connor1-24/+31
When timer_calc_usec() is used with large timeout values, such as 60s, the integer math can overflow and produce different results than when using timer_calc(time / 1000) for the same timeout. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-08-24Add minimal support for machines without hardware interruptsKevin O'Connor1-0/+2
Some Chromebooks (with Baytrail CPUs) apparently do not support routing of legacy interrupts. This patch adds minimal support for running SeaBIOS in such an environment. Even with this patch, it is known that old operating systems and even some recent bootloaders will not function without real hardware interrupts. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-23timer: Add CONFIG_TSC_TIMER build option to disable the CPU TSC timerKevin O'Connor1-15/+8
Allow users to remove the CPU timestamp counter support at compile time. The PMTIMER is frequently used instead of the TSC and this compile time option allows one to strip a few bytes from the final binary. This change also defaults the internal timer to use the PIT based timer until the PMTIMER or TSC is detected. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-11-12Minor - move PORT_PS2_CTRLB from hw/ps2port.h to hw/timer.cKevin O'Connor1-1/+1
The PORT_PS2_CTRLB port is only used by timers - it's just a historical artifact that it was part of the original ps2 controller. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-28Remove ioport.h; disperse its contents to other header files.Kevin O'Connor1-2/+7
Move the inb(), insb(), etc. code from ioport.h to x86.h. Move the PORT_* definitions to their appropriate hardware files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-28Move PIT setup from clock.c to hw/timer.c.Kevin O'Connor1-25/+33
Move the hardware setup to the hw/timer.c code. This eliminates the need for a separate hw/pit.h file with definitions. Also, move the IRQ counting code (which is dependent on the BDA) from hw/timer.c to clock.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Move function definitions for output.c from util.h to new file output.h.Kevin O'Connor1-4/+5
Also, sort the order of include files in the c files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Move stacks.c definitions from util.h to new file stacks.h.Kevin O'Connor1-0/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Split x86 specific functions out of util.c/h to new files x86.c/h.Kevin O'Connor1-0/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-02Move code centered around specific hardware devices to src/hw/Kevin O'Connor1-0/+241
Move many C files from the src/ directory to the new src/hw/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>