The RealTek timer-count A look at how we could utilize the

advertisement
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
0x48-0x4B
TCTR
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
0x54-0x57
TimerInt
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
0x3C-0x3D
T
i
m
e
O
u
t
14
0x3E-0x3F
T
i
m
e
O
u
t
14
Interrupt Mask Register
(read/write)
(Bit: 1=enabled, 0=masked)
16-bits
Interrupt Status Register
(read/only)*
(bit: 1=active, 0=inactive)
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
Download