50 likes | 64 Views
Explore the timekeeping capabilities of RealTek 8139 network controller with Timer Count Register and Timer Interrupt Register. Learn how to increment and set intervals for timer interrupts efficiently using Interrupt Mask and Status Registers. Use nictimer.c driver and 2seconds.cpp program to calculate timer increment rate and expiration value.
E N D
The RealTek timer-count A look at how we could utilize the timekeeping capabilities of our RealTek 8139 network controller
The Timer Count Register 32-bits TCTR 0x48-0x4B How it works: This register may be read at any time. Its value steadily increments, at a fixed frequency. If any value is written, the register is reset to zero.
The Timer Interrupt Register 32-bits TimerInt 0x54-0x57 How it works: This register may be read or written at any time. Its value is initialized to zero by a reset command. So long as it’s zero, no timer-interrupt is generated. If any nonzero value is written, the ‘timeout’ flag in the Interrupt Status register will be set as soon as the TCTR becomes equal to this TimerInt amount.
Registers IMR and ISR 16-bits Interrupt Mask Register (read/write) (Bit: 1=enabled, 0=masked) T i m e O u t 0x3C-0x3D 14 16-bits Interrupt Status Register (read/only)* (bit: 1=active, 0=inactive) T i m e O u t 0x3E-0x3F 14 Writing ‘1’ to an active bit in IntStatus clears the active condition
In-Class Exercise • Use our ‘nictimer.c’ device-driver, and also our ‘2seconds.cpp’ program (plus your knowledge of arithmetic), to determine how rapidly the nic’s Timer Count Register will be incrementing • Compute the expiration-value you should write to the TimerInt register in order that a task will be awakened by a timer-interrupt after enough time has elapsed for a maximum-size packet to be transmitted