Spinlock save cpu flags

This commit is contained in:
2026-03-12 22:48:34 +01:00
parent 19793e9126
commit 4760818118
50 changed files with 704 additions and 461 deletions

View File

@@ -59,8 +59,10 @@ static void hpet_write32 (uint32_t reg, uint32_t value) {
/* Read current value of HPET_MCVR register. */
static uint64_t hpet_read_counter (void) {
uint64_t fh;
uint64_t value;
spin_lock (&hpet_lock);
spin_lock (&hpet_lock, &fh);
if (!hpet_32bits)
value = hpet_read64 (HPET_MCVR);
@@ -75,13 +77,15 @@ static uint64_t hpet_read_counter (void) {
value = ((uint64_t)hi1 << 32) | lo;
}
spin_unlock (&hpet_lock);
spin_unlock (&hpet_lock, fh);
return value;
}
static void hpet_write_counter (uint64_t value) {
spin_lock (&hpet_lock);
uint64_t fh;
spin_lock (&hpet_lock, &fh);
if (!hpet_32bits)
hpet_write64 (HPET_MCVR, value);
@@ -90,7 +94,7 @@ static void hpet_write_counter (uint64_t value) {
hpet_write32 (HPET_MCVR + 4, (uint32_t)(value >> 32));
}
spin_unlock (&hpet_lock);
spin_unlock (&hpet_lock, fh);
}
/* Sleep for a given amount of microseconds. This time can last longer due to \ref hpet_lock being