MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Initialize

Function Initialize

Kernel/src/arch/x86_64/timer.cpp:146–162  ·  view source on GitHub ↗

Initialize

Source from the content-addressed store, hash-verified

144
145 // Initialize
146 void Initialize(uint32_t freq) {
147 IDT::RegisterInterruptHandler(IRQ0, Handler);
148
149 frequency = freq;
150 uint32_t divisor = 1193182 / freq;
151
152 // Send the command byte.
153 outportb(0x43, 0x36);
154
155 // Divisor has to be sent byte-wise, so split here into upper/lower bytes.
156 uint8_t l = (uint8_t)(divisor & 0xFF);
157 uint8_t h = (uint8_t)( (divisor>>8) & 0xFF );
158
159 // Send the frequency divisor.
160 outportb(0x40, l);
161 outportb(0x40, h);
162 }
163}

Callers

nothing calls this directly

Calls 2

RegisterInterruptHandlerFunction · 0.85
outportbFunction · 0.85

Tested by

no test coverage detected