NOT WORKING
This commit is contained in:
parent
41aecc69f1
commit
8d7590ace4
|
@ -1,19 +0,0 @@
|
|||
#include "hal_atomic.h"
|
||||
|
||||
void KAPI hal_spin_lock(uint64_t *lock)
|
||||
{
|
||||
if (lock != NULL)
|
||||
{
|
||||
while (hal_interlocked_exchange(lock, 1) == 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void KAPI hal_spin_unlock(uint64_t *lock)
|
||||
{
|
||||
if (lock != NULL)
|
||||
{
|
||||
*lock = 0;
|
||||
}
|
||||
return;
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef _HAL_ATOMIC_H_
|
||||
#define _HAL_ATOMIC_H_
|
||||
#include "k_def.h"
|
||||
extern uint64_t KAPI hal_interlocked_exchange(uint64_t* dst,
|
||||
uint64_t val);
|
||||
extern uint64_t KAPI hal_interlocked_exchange(uint64_t* dst, uint64_t val);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef _ATOMIC_H_
|
||||
#define _ATOMIC_H_
|
||||
|
||||
#include "k_def.h"
|
||||
#include "k_intr.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t val;
|
||||
} k_spin_lock_t;
|
||||
|
||||
void KAPI k_spin_lock(k_spin_lock_t *lock);
|
||||
|
||||
void KAPI k_spin_unlock(k_spin_lock_t *lock);
|
||||
|
||||
k_irql_t KAPI k_spin_lock_irq_set(k_spin_lock_t *lock, k_irql_t irql);
|
||||
|
||||
void KAPI k_spin_lock_irq_restore(k_spin_lock_t *lock, k_irql_t irql);
|
||||
|
||||
#endif
|
|
@ -17,8 +17,7 @@ extern void KAPI hal_unmask_interrupt();
|
|||
extern void KAPI hal_set_interrupt_handler(uint64_t index, void (*handler)(void));
|
||||
|
||||
// concurrency
|
||||
extern void KAPI hal_spin_lock(uint64_t * lock);
|
||||
extern void KAPI hal_spin_unlock(uint64_t * lock);
|
||||
extern uint64_t KAPI hal_interlocked_exchange(uint64_t* dst, uint64_t val);
|
||||
|
||||
// loaded kernel addr
|
||||
extern char kernel_start[];
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
#include "k_type.h"
|
||||
#include "k_def.h"
|
||||
|
||||
typedef uint64_t irql_t;
|
||||
typedef uint64_t k_irql_t;
|
||||
|
||||
#define INTR_VEC_DPC 1
|
||||
#define INVR_VEC_APC 2
|
||||
#define INVR_VEC_TIMER 3
|
||||
|
||||
#define IRQL_DISABLED 0
|
||||
#define IRQL_DPC 1
|
||||
#define IRQL_APC 2
|
||||
#define IRQL_KERNEL 3
|
||||
#define IRQL_USER 4
|
||||
#define IRQL_USER 3
|
||||
|
||||
void KAPI k_set_interrupt_handler(uint64_t index, void (*handler)(void));
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#include "k_atomic.h"
|
||||
#include "k_hal.h"
|
||||
|
||||
void KAPI k_spin_lock(k_spin_lock_t *lock)
|
||||
{
|
||||
if (lock != NULL)
|
||||
{
|
||||
while (hal_interlocked_exchange(&lock->val, 1) == 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void KAPI k_spin_unlock(k_spin_lock_t *lock)
|
||||
{
|
||||
if (lock != NULL)
|
||||
{
|
||||
lock->val = 0;
|
||||
}
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue